repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
aws/aws-sdk-java | aws-java-sdk-elasticsearch/src/main/java/com/amazonaws/services/elasticsearch/model/ElasticsearchDomainStatus.java | ElasticsearchDomainStatus.withAdvancedOptions | public ElasticsearchDomainStatus withAdvancedOptions(java.util.Map<String, String> advancedOptions) {
"""
<p>
Specifies the status of the <code>AdvancedOptions</code>
</p>
@param advancedOptions
Specifies the status of the <code>AdvancedOptions</code>
@return Returns a reference to this object so that method calls can be chained together.
"""
setAdvancedOptions(advancedOptions);
return this;
} | java | public ElasticsearchDomainStatus withAdvancedOptions(java.util.Map<String, String> advancedOptions) {
setAdvancedOptions(advancedOptions);
return this;
} | [
"public",
"ElasticsearchDomainStatus",
"withAdvancedOptions",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"advancedOptions",
")",
"{",
"setAdvancedOptions",
"(",
"advancedOptions",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Specifies the status of the <code>AdvancedOptions</code>
</p>
@param advancedOptions
Specifies the status of the <code>AdvancedOptions</code>
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Specifies",
"the",
"status",
"of",
"the",
"<code",
">",
"AdvancedOptions<",
"/",
"code",
">",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-elasticsearch/src/main/java/com/amazonaws/services/elasticsearch/model/ElasticsearchDomainStatus.java#L1097-L1100 |
UrielCh/ovh-java-sdk | ovh-java-sdk-sms/src/main/java/net/minidev/ovh/api/ApiOvhSms.java | ApiOvhSms.serviceName_sendersAvailableForValidation_GET | public ArrayList<OvhSenderAvailable> serviceName_sendersAvailableForValidation_GET(String serviceName, OvhSenderRefererEnum referer) throws IOException {
"""
The senders that are attached to your personal informations or OVH services and that can be automatically validated
REST: GET /sms/{serviceName}/sendersAvailableForValidation
@param referer [required] Information type
@param serviceName [required] The internal name of your SMS offer
"""
String qPath = "/sms/{serviceName}/sendersAvailableForValidation";
StringBuilder sb = path(qPath, serviceName);
query(sb, "referer", referer);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t3);
} | java | public ArrayList<OvhSenderAvailable> serviceName_sendersAvailableForValidation_GET(String serviceName, OvhSenderRefererEnum referer) throws IOException {
String qPath = "/sms/{serviceName}/sendersAvailableForValidation";
StringBuilder sb = path(qPath, serviceName);
query(sb, "referer", referer);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t3);
} | [
"public",
"ArrayList",
"<",
"OvhSenderAvailable",
">",
"serviceName_sendersAvailableForValidation_GET",
"(",
"String",
"serviceName",
",",
"OvhSenderRefererEnum",
"referer",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/sms/{serviceName}/sendersAvailableForValidation\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"query",
"(",
"sb",
",",
"\"referer\"",
",",
"referer",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t3",
")",
";",
"}"
] | The senders that are attached to your personal informations or OVH services and that can be automatically validated
REST: GET /sms/{serviceName}/sendersAvailableForValidation
@param referer [required] Information type
@param serviceName [required] The internal name of your SMS offer | [
"The",
"senders",
"that",
"are",
"attached",
"to",
"your",
"personal",
"informations",
"or",
"OVH",
"services",
"and",
"that",
"can",
"be",
"automatically",
"validated"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-sms/src/main/java/net/minidev/ovh/api/ApiOvhSms.java#L1037-L1043 |
geomajas/geomajas-project-client-gwt2 | plugin/corewidget/example-jar/src/main/java/org/geomajas/gwt2/plugin/corewidget/example/client/sample/message/MessageBox.java | MessageBox.showYesNoMessageBox | public static MessageBox showYesNoMessageBox(String title, String question, Callback<Boolean, Void> onFinished) {
"""
This will show a MessageBox expecting an answer.
<p>
onFinished.onSuccess will be called with true for yes, and false for no.
<p>
if the dialogbox is closed with the closebutton instead of a button, onFinished.onFailure will be called.
@param title
@param question
@param onFinished
@return
"""
MessageBox box = new MessageBox(title, question, onFinished);
box.setMessageStyleType(MessageStyleType.HELP);
box.setMessageBoxType(MessageBoxType.YESNO);
box.center();
return box;
} | java | public static MessageBox showYesNoMessageBox(String title, String question, Callback<Boolean, Void> onFinished) {
MessageBox box = new MessageBox(title, question, onFinished);
box.setMessageStyleType(MessageStyleType.HELP);
box.setMessageBoxType(MessageBoxType.YESNO);
box.center();
return box;
} | [
"public",
"static",
"MessageBox",
"showYesNoMessageBox",
"(",
"String",
"title",
",",
"String",
"question",
",",
"Callback",
"<",
"Boolean",
",",
"Void",
">",
"onFinished",
")",
"{",
"MessageBox",
"box",
"=",
"new",
"MessageBox",
"(",
"title",
",",
"question",
",",
"onFinished",
")",
";",
"box",
".",
"setMessageStyleType",
"(",
"MessageStyleType",
".",
"HELP",
")",
";",
"box",
".",
"setMessageBoxType",
"(",
"MessageBoxType",
".",
"YESNO",
")",
";",
"box",
".",
"center",
"(",
")",
";",
"return",
"box",
";",
"}"
] | This will show a MessageBox expecting an answer.
<p>
onFinished.onSuccess will be called with true for yes, and false for no.
<p>
if the dialogbox is closed with the closebutton instead of a button, onFinished.onFailure will be called.
@param title
@param question
@param onFinished
@return | [
"This",
"will",
"show",
"a",
"MessageBox",
"expecting",
"an",
"answer",
".",
"<p",
">",
"onFinished",
".",
"onSuccess",
"will",
"be",
"called",
"with",
"true",
"for",
"yes",
"and",
"false",
"for",
"no",
".",
"<p",
">",
"if",
"the",
"dialogbox",
"is",
"closed",
"with",
"the",
"closebutton",
"instead",
"of",
"a",
"button",
"onFinished",
".",
"onFailure",
"will",
"be",
"called",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/corewidget/example-jar/src/main/java/org/geomajas/gwt2/plugin/corewidget/example/client/sample/message/MessageBox.java#L310-L316 |
structr/structr | structr-core/src/main/java/javatools/parsers/Char.java | Char.truncate | public static CharSequence truncate(CharSequence s, int len) {
"""
Returns a string of the given length, fills with spaces if necessary
"""
if (s.length() == len) return (s);
if (s.length() > len) return (s.subSequence(0, len));
StringBuilder result = new StringBuilder(s);
while (result.length() < len)
result.append(' ');
return (result);
} | java | public static CharSequence truncate(CharSequence s, int len) {
if (s.length() == len) return (s);
if (s.length() > len) return (s.subSequence(0, len));
StringBuilder result = new StringBuilder(s);
while (result.length() < len)
result.append(' ');
return (result);
} | [
"public",
"static",
"CharSequence",
"truncate",
"(",
"CharSequence",
"s",
",",
"int",
"len",
")",
"{",
"if",
"(",
"s",
".",
"length",
"(",
")",
"==",
"len",
")",
"return",
"(",
"s",
")",
";",
"if",
"(",
"s",
".",
"length",
"(",
")",
">",
"len",
")",
"return",
"(",
"s",
".",
"subSequence",
"(",
"0",
",",
"len",
")",
")",
";",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"s",
")",
";",
"while",
"(",
"result",
".",
"length",
"(",
")",
"<",
"len",
")",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"return",
"(",
"result",
")",
";",
"}"
] | Returns a string of the given length, fills with spaces if necessary | [
"Returns",
"a",
"string",
"of",
"the",
"given",
"length",
"fills",
"with",
"spaces",
"if",
"necessary"
] | train | https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-core/src/main/java/javatools/parsers/Char.java#L1410-L1417 |
camunda/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java | ScriptUtil.getScriptFromSourceExpression | public static ExecutableScript getScriptFromSourceExpression(String language, Expression sourceExpression, ScriptFactory scriptFactory) {
"""
Creates a new {@link ExecutableScript} from a dynamic source. Dynamic means that the source
is an expression which will be evaluated during execution.
@param language the language of the script
@param sourceExpression the expression which evaluates to the source code
@param scriptFactory the script factory used to create the script
@return the newly created script
@throws NotValidException if language is null or empty or sourceExpression is null
"""
ensureNotEmpty(NotValidException.class, "Script language", language);
ensureNotNull(NotValidException.class, "Script source expression", sourceExpression);
return scriptFactory.createScriptFromSource(language, sourceExpression);
} | java | public static ExecutableScript getScriptFromSourceExpression(String language, Expression sourceExpression, ScriptFactory scriptFactory) {
ensureNotEmpty(NotValidException.class, "Script language", language);
ensureNotNull(NotValidException.class, "Script source expression", sourceExpression);
return scriptFactory.createScriptFromSource(language, sourceExpression);
} | [
"public",
"static",
"ExecutableScript",
"getScriptFromSourceExpression",
"(",
"String",
"language",
",",
"Expression",
"sourceExpression",
",",
"ScriptFactory",
"scriptFactory",
")",
"{",
"ensureNotEmpty",
"(",
"NotValidException",
".",
"class",
",",
"\"Script language\"",
",",
"language",
")",
";",
"ensureNotNull",
"(",
"NotValidException",
".",
"class",
",",
"\"Script source expression\"",
",",
"sourceExpression",
")",
";",
"return",
"scriptFactory",
".",
"createScriptFromSource",
"(",
"language",
",",
"sourceExpression",
")",
";",
"}"
] | Creates a new {@link ExecutableScript} from a dynamic source. Dynamic means that the source
is an expression which will be evaluated during execution.
@param language the language of the script
@param sourceExpression the expression which evaluates to the source code
@param scriptFactory the script factory used to create the script
@return the newly created script
@throws NotValidException if language is null or empty or sourceExpression is null | [
"Creates",
"a",
"new",
"{",
"@link",
"ExecutableScript",
"}",
"from",
"a",
"dynamic",
"source",
".",
"Dynamic",
"means",
"that",
"the",
"source",
"is",
"an",
"expression",
"which",
"will",
"be",
"evaluated",
"during",
"execution",
"."
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java#L125-L129 |
landawn/AbacusUtil | src/com/landawn/abacus/util/MutableByte.java | MutableByte.setIf | public <E extends Exception> boolean setIf(byte newValue, Try.BytePredicate<E> predicate) throws E {
"""
Set with the specified new value and returns <code>true</code> if <code>predicate</code> returns true.
Otherwise just return <code>false</code> without setting the value to new value.
@param newValue
@param predicate - test the current value.
@return
"""
if (predicate.test(this.value)) {
this.value = newValue;
return true;
}
return false;
} | java | public <E extends Exception> boolean setIf(byte newValue, Try.BytePredicate<E> predicate) throws E {
if (predicate.test(this.value)) {
this.value = newValue;
return true;
}
return false;
} | [
"public",
"<",
"E",
"extends",
"Exception",
">",
"boolean",
"setIf",
"(",
"byte",
"newValue",
",",
"Try",
".",
"BytePredicate",
"<",
"E",
">",
"predicate",
")",
"throws",
"E",
"{",
"if",
"(",
"predicate",
".",
"test",
"(",
"this",
".",
"value",
")",
")",
"{",
"this",
".",
"value",
"=",
"newValue",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Set with the specified new value and returns <code>true</code> if <code>predicate</code> returns true.
Otherwise just return <code>false</code> without setting the value to new value.
@param newValue
@param predicate - test the current value.
@return | [
"Set",
"with",
"the",
"specified",
"new",
"value",
"and",
"returns",
"<code",
">",
"true<",
"/",
"code",
">",
"if",
"<code",
">",
"predicate<",
"/",
"code",
">",
"returns",
"true",
".",
"Otherwise",
"just",
"return",
"<code",
">",
"false<",
"/",
"code",
">",
"without",
"setting",
"the",
"value",
"to",
"new",
"value",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/MutableByte.java#L110-L117 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/misc/Pattern.java | Pattern.sequence | public static Pattern sequence(Pattern pattern1, Pattern pattern2) {
"""
A pattern which matches <code>pattern1</code> followed by <code>pattern2</code>.
@param pattern1
@param pattern2
@return
"""
if (pattern1 == null || pattern2 == null)
{
throw new IllegalArgumentException("Neither pattern can be null");
}
return new SequencePattern(pattern1, pattern2);
} | java | public static Pattern sequence(Pattern pattern1, Pattern pattern2)
{
if (pattern1 == null || pattern2 == null)
{
throw new IllegalArgumentException("Neither pattern can be null");
}
return new SequencePattern(pattern1, pattern2);
} | [
"public",
"static",
"Pattern",
"sequence",
"(",
"Pattern",
"pattern1",
",",
"Pattern",
"pattern2",
")",
"{",
"if",
"(",
"pattern1",
"==",
"null",
"||",
"pattern2",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Neither pattern can be null\"",
")",
";",
"}",
"return",
"new",
"SequencePattern",
"(",
"pattern1",
",",
"pattern2",
")",
";",
"}"
] | A pattern which matches <code>pattern1</code> followed by <code>pattern2</code>.
@param pattern1
@param pattern2
@return | [
"A",
"pattern",
"which",
"matches",
"<code",
">",
"pattern1<",
"/",
"code",
">",
"followed",
"by",
"<code",
">",
"pattern2<",
"/",
"code",
">",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/misc/Pattern.java#L178-L185 |
Samsung/GearVRf | GVRf/Extensions/3DCursor/IODevices/gearwear/GearWearIoDevice/src/main/java/com/gearvrf/io/gearwear/GearWearableDevice.java | GearWearableDevice.isInInnerCircle | private boolean isInInnerCircle(float x, float y) {
"""
Check if position is in inner circle
@param x x position
@param y y position
@return true if in inner circle, false otherwise
"""
return GearWearableUtility.isInCircle(x, y, CENTER_X, CENTER_Y, INNER_RADIUS);
} | java | private boolean isInInnerCircle(float x, float y) {
return GearWearableUtility.isInCircle(x, y, CENTER_X, CENTER_Y, INNER_RADIUS);
} | [
"private",
"boolean",
"isInInnerCircle",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"return",
"GearWearableUtility",
".",
"isInCircle",
"(",
"x",
",",
"y",
",",
"CENTER_X",
",",
"CENTER_Y",
",",
"INNER_RADIUS",
")",
";",
"}"
] | Check if position is in inner circle
@param x x position
@param y y position
@return true if in inner circle, false otherwise | [
"Check",
"if",
"position",
"is",
"in",
"inner",
"circle"
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/3DCursor/IODevices/gearwear/GearWearIoDevice/src/main/java/com/gearvrf/io/gearwear/GearWearableDevice.java#L639-L641 |
windup/windup | rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/scan/ast/TypeInterestFactoryTrie.java | TypeInterestFactoryTrie.newDefaultInstance | public static TypeInterestFactoryTrie newDefaultInstance() {
"""
Gets the default instance of the {@link TypeInterestFactoryTrie}.
"""
TrieStructureTypeRelation<RewritePatternToRegex, String> relation = new TrieStructureTypeRelation<RewritePatternToRegex, String>()
{
@Override
public String getStringToSearchFromSearchType(String search)
{
return search;
}
@Override
public String getStringPrefixToSaveSaveType(RewritePatternToRegex save)
{
/**
* Take the prefix of the windup regex and save it in the node up to the first "{..}"
*/
return save.getRewritePattern().split("\\{")[0];
}
@Override
public boolean checkIfMatchFound(RewritePatternToRegex saved, String searched)
{
return saved.getCompiledRegex().matcher(searched).matches();
}
};
return new TypeInterestFactoryTrie(relation);
} | java | public static TypeInterestFactoryTrie newDefaultInstance()
{
TrieStructureTypeRelation<RewritePatternToRegex, String> relation = new TrieStructureTypeRelation<RewritePatternToRegex, String>()
{
@Override
public String getStringToSearchFromSearchType(String search)
{
return search;
}
@Override
public String getStringPrefixToSaveSaveType(RewritePatternToRegex save)
{
/**
* Take the prefix of the windup regex and save it in the node up to the first "{..}"
*/
return save.getRewritePattern().split("\\{")[0];
}
@Override
public boolean checkIfMatchFound(RewritePatternToRegex saved, String searched)
{
return saved.getCompiledRegex().matcher(searched).matches();
}
};
return new TypeInterestFactoryTrie(relation);
} | [
"public",
"static",
"TypeInterestFactoryTrie",
"newDefaultInstance",
"(",
")",
"{",
"TrieStructureTypeRelation",
"<",
"RewritePatternToRegex",
",",
"String",
">",
"relation",
"=",
"new",
"TrieStructureTypeRelation",
"<",
"RewritePatternToRegex",
",",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"getStringToSearchFromSearchType",
"(",
"String",
"search",
")",
"{",
"return",
"search",
";",
"}",
"@",
"Override",
"public",
"String",
"getStringPrefixToSaveSaveType",
"(",
"RewritePatternToRegex",
"save",
")",
"{",
"/**\n * Take the prefix of the windup regex and save it in the node up to the first \"{..}\"\n */",
"return",
"save",
".",
"getRewritePattern",
"(",
")",
".",
"split",
"(",
"\"\\\\{\"",
")",
"[",
"0",
"]",
";",
"}",
"@",
"Override",
"public",
"boolean",
"checkIfMatchFound",
"(",
"RewritePatternToRegex",
"saved",
",",
"String",
"searched",
")",
"{",
"return",
"saved",
".",
"getCompiledRegex",
"(",
")",
".",
"matcher",
"(",
"searched",
")",
".",
"matches",
"(",
")",
";",
"}",
"}",
";",
"return",
"new",
"TypeInterestFactoryTrie",
"(",
"relation",
")",
";",
"}"
] | Gets the default instance of the {@link TypeInterestFactoryTrie}. | [
"Gets",
"the",
"default",
"instance",
"of",
"the",
"{"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/scan/ast/TypeInterestFactoryTrie.java#L18-L45 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/search/bingvideosearch/src/main/java/com/microsoft/azure/cognitiveservices/search/videosearch/implementation/BingVideosImpl.java | BingVideosImpl.trendingWithServiceResponseAsync | public Observable<ServiceResponse<TrendingVideos>> trendingWithServiceResponseAsync(TrendingOptionalParameter trendingOptionalParameter) {
"""
The Video Trending Search API lets you search on Bing and get back a list of videos that are trending based on search requests made by others. The videos are broken out into different categories. For example, Top Music Videos. For a list of markets that support trending videos, see [Trending Videos](https://docs.microsoft.com/azure/cognitive-services/bing-video-search/trending-videos).
@param trendingOptionalParameter 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 TrendingVideos object
"""
final String acceptLanguage = trendingOptionalParameter != null ? trendingOptionalParameter.acceptLanguage() : null;
final String userAgent = trendingOptionalParameter != null ? trendingOptionalParameter.userAgent() : this.client.userAgent();
final String clientId = trendingOptionalParameter != null ? trendingOptionalParameter.clientId() : null;
final String clientIp = trendingOptionalParameter != null ? trendingOptionalParameter.clientIp() : null;
final String location = trendingOptionalParameter != null ? trendingOptionalParameter.location() : null;
final String countryCode = trendingOptionalParameter != null ? trendingOptionalParameter.countryCode() : null;
final String market = trendingOptionalParameter != null ? trendingOptionalParameter.market() : null;
final SafeSearch safeSearch = trendingOptionalParameter != null ? trendingOptionalParameter.safeSearch() : null;
final String setLang = trendingOptionalParameter != null ? trendingOptionalParameter.setLang() : null;
final Boolean textDecorations = trendingOptionalParameter != null ? trendingOptionalParameter.textDecorations() : null;
final TextFormat textFormat = trendingOptionalParameter != null ? trendingOptionalParameter.textFormat() : null;
return trendingWithServiceResponseAsync(acceptLanguage, userAgent, clientId, clientIp, location, countryCode, market, safeSearch, setLang, textDecorations, textFormat);
} | java | public Observable<ServiceResponse<TrendingVideos>> trendingWithServiceResponseAsync(TrendingOptionalParameter trendingOptionalParameter) {
final String acceptLanguage = trendingOptionalParameter != null ? trendingOptionalParameter.acceptLanguage() : null;
final String userAgent = trendingOptionalParameter != null ? trendingOptionalParameter.userAgent() : this.client.userAgent();
final String clientId = trendingOptionalParameter != null ? trendingOptionalParameter.clientId() : null;
final String clientIp = trendingOptionalParameter != null ? trendingOptionalParameter.clientIp() : null;
final String location = trendingOptionalParameter != null ? trendingOptionalParameter.location() : null;
final String countryCode = trendingOptionalParameter != null ? trendingOptionalParameter.countryCode() : null;
final String market = trendingOptionalParameter != null ? trendingOptionalParameter.market() : null;
final SafeSearch safeSearch = trendingOptionalParameter != null ? trendingOptionalParameter.safeSearch() : null;
final String setLang = trendingOptionalParameter != null ? trendingOptionalParameter.setLang() : null;
final Boolean textDecorations = trendingOptionalParameter != null ? trendingOptionalParameter.textDecorations() : null;
final TextFormat textFormat = trendingOptionalParameter != null ? trendingOptionalParameter.textFormat() : null;
return trendingWithServiceResponseAsync(acceptLanguage, userAgent, clientId, clientIp, location, countryCode, market, safeSearch, setLang, textDecorations, textFormat);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"TrendingVideos",
">",
">",
"trendingWithServiceResponseAsync",
"(",
"TrendingOptionalParameter",
"trendingOptionalParameter",
")",
"{",
"final",
"String",
"acceptLanguage",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"acceptLanguage",
"(",
")",
":",
"null",
";",
"final",
"String",
"userAgent",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"userAgent",
"(",
")",
":",
"this",
".",
"client",
".",
"userAgent",
"(",
")",
";",
"final",
"String",
"clientId",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"clientId",
"(",
")",
":",
"null",
";",
"final",
"String",
"clientIp",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"clientIp",
"(",
")",
":",
"null",
";",
"final",
"String",
"location",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"location",
"(",
")",
":",
"null",
";",
"final",
"String",
"countryCode",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"countryCode",
"(",
")",
":",
"null",
";",
"final",
"String",
"market",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"market",
"(",
")",
":",
"null",
";",
"final",
"SafeSearch",
"safeSearch",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"safeSearch",
"(",
")",
":",
"null",
";",
"final",
"String",
"setLang",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"setLang",
"(",
")",
":",
"null",
";",
"final",
"Boolean",
"textDecorations",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"textDecorations",
"(",
")",
":",
"null",
";",
"final",
"TextFormat",
"textFormat",
"=",
"trendingOptionalParameter",
"!=",
"null",
"?",
"trendingOptionalParameter",
".",
"textFormat",
"(",
")",
":",
"null",
";",
"return",
"trendingWithServiceResponseAsync",
"(",
"acceptLanguage",
",",
"userAgent",
",",
"clientId",
",",
"clientIp",
",",
"location",
",",
"countryCode",
",",
"market",
",",
"safeSearch",
",",
"setLang",
",",
"textDecorations",
",",
"textFormat",
")",
";",
"}"
] | The Video Trending Search API lets you search on Bing and get back a list of videos that are trending based on search requests made by others. The videos are broken out into different categories. For example, Top Music Videos. For a list of markets that support trending videos, see [Trending Videos](https://docs.microsoft.com/azure/cognitive-services/bing-video-search/trending-videos).
@param trendingOptionalParameter 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 TrendingVideos object | [
"The",
"Video",
"Trending",
"Search",
"API",
"lets",
"you",
"search",
"on",
"Bing",
"and",
"get",
"back",
"a",
"list",
"of",
"videos",
"that",
"are",
"trending",
"based",
"on",
"search",
"requests",
"made",
"by",
"others",
".",
"The",
"videos",
"are",
"broken",
"out",
"into",
"different",
"categories",
".",
"For",
"example",
"Top",
"Music",
"Videos",
".",
"For",
"a",
"list",
"of",
"markets",
"that",
"support",
"trending",
"videos",
"see",
"[",
"Trending",
"Videos",
"]",
"(",
"https",
":",
"//",
"docs",
".",
"microsoft",
".",
"com",
"/",
"azure",
"/",
"cognitive",
"-",
"services",
"/",
"bing",
"-",
"video",
"-",
"search",
"/",
"trending",
"-",
"videos",
")",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/search/bingvideosearch/src/main/java/com/microsoft/azure/cognitiveservices/search/videosearch/implementation/BingVideosImpl.java#L695-L709 |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFile.java | BoxFile.uploadVersion | @Deprecated
public void uploadVersion(InputStream fileContent, Date modified, long fileSize, ProgressListener listener) {
"""
Uploads a new version of this file, replacing the current version, while reporting the progress to a
ProgressListener. Note that only users with premium accounts will be able to view and recover previous versions
of the file.
@param fileContent a stream containing the new file contents.
@param modified the date that the new version was modified.
@param fileSize the size of the file used for determining the progress of the upload.
@param listener a listener for monitoring the upload's progress.
@deprecated use uploadNewVersion() instead.
"""
this.uploadVersion(fileContent, null, modified, fileSize, listener);
} | java | @Deprecated
public void uploadVersion(InputStream fileContent, Date modified, long fileSize, ProgressListener listener) {
this.uploadVersion(fileContent, null, modified, fileSize, listener);
} | [
"@",
"Deprecated",
"public",
"void",
"uploadVersion",
"(",
"InputStream",
"fileContent",
",",
"Date",
"modified",
",",
"long",
"fileSize",
",",
"ProgressListener",
"listener",
")",
"{",
"this",
".",
"uploadVersion",
"(",
"fileContent",
",",
"null",
",",
"modified",
",",
"fileSize",
",",
"listener",
")",
";",
"}"
] | Uploads a new version of this file, replacing the current version, while reporting the progress to a
ProgressListener. Note that only users with premium accounts will be able to view and recover previous versions
of the file.
@param fileContent a stream containing the new file contents.
@param modified the date that the new version was modified.
@param fileSize the size of the file used for determining the progress of the upload.
@param listener a listener for monitoring the upload's progress.
@deprecated use uploadNewVersion() instead. | [
"Uploads",
"a",
"new",
"version",
"of",
"this",
"file",
"replacing",
"the",
"current",
"version",
"while",
"reporting",
"the",
"progress",
"to",
"a",
"ProgressListener",
".",
"Note",
"that",
"only",
"users",
"with",
"premium",
"accounts",
"will",
"be",
"able",
"to",
"view",
"and",
"recover",
"previous",
"versions",
"of",
"the",
"file",
"."
] | train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L767-L770 |
aws/aws-sdk-java | aws-java-sdk-cognitoidentity/src/main/java/com/amazonaws/services/cognitoidentity/model/GetIdentityPoolRolesResult.java | GetIdentityPoolRolesResult.withRoles | public GetIdentityPoolRolesResult withRoles(java.util.Map<String, String> roles) {
"""
<p>
The map of roles associated with this pool. Currently only authenticated and unauthenticated roles are supported.
</p>
@param roles
The map of roles associated with this pool. Currently only authenticated and unauthenticated roles are
supported.
@return Returns a reference to this object so that method calls can be chained together.
"""
setRoles(roles);
return this;
} | java | public GetIdentityPoolRolesResult withRoles(java.util.Map<String, String> roles) {
setRoles(roles);
return this;
} | [
"public",
"GetIdentityPoolRolesResult",
"withRoles",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"roles",
")",
"{",
"setRoles",
"(",
"roles",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The map of roles associated with this pool. Currently only authenticated and unauthenticated roles are supported.
</p>
@param roles
The map of roles associated with this pool. Currently only authenticated and unauthenticated roles are
supported.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"map",
"of",
"roles",
"associated",
"with",
"this",
"pool",
".",
"Currently",
"only",
"authenticated",
"and",
"unauthenticated",
"roles",
"are",
"supported",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-cognitoidentity/src/main/java/com/amazonaws/services/cognitoidentity/model/GetIdentityPoolRolesResult.java#L128-L131 |
haifengl/smile | core/src/main/java/smile/association/TotalSupportTree.java | TotalSupportTree.getFrequentItemsets | private long getFrequentItemsets(PrintStream out, List<ItemSet> list) {
"""
Returns the set of frequent item sets.
@param out a print stream for output of frequent item sets.
@param list a container to store frequent item sets on output.
@return the number of discovered frequent item sets
"""
long n = 0;
if (root.children != null) {
for (int i = 0; i < root.children.length; i++) {
Node child = root.children[i];
if (child != null && child.support >= minSupport) {
int[] itemset = {child.id};
n += getFrequentItemsets(out, list, itemset, i, child);
}
}
}
return n;
} | java | private long getFrequentItemsets(PrintStream out, List<ItemSet> list) {
long n = 0;
if (root.children != null) {
for (int i = 0; i < root.children.length; i++) {
Node child = root.children[i];
if (child != null && child.support >= minSupport) {
int[] itemset = {child.id};
n += getFrequentItemsets(out, list, itemset, i, child);
}
}
}
return n;
} | [
"private",
"long",
"getFrequentItemsets",
"(",
"PrintStream",
"out",
",",
"List",
"<",
"ItemSet",
">",
"list",
")",
"{",
"long",
"n",
"=",
"0",
";",
"if",
"(",
"root",
".",
"children",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"root",
".",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"Node",
"child",
"=",
"root",
".",
"children",
"[",
"i",
"]",
";",
"if",
"(",
"child",
"!=",
"null",
"&&",
"child",
".",
"support",
">=",
"minSupport",
")",
"{",
"int",
"[",
"]",
"itemset",
"=",
"{",
"child",
".",
"id",
"}",
";",
"n",
"+=",
"getFrequentItemsets",
"(",
"out",
",",
"list",
",",
"itemset",
",",
"i",
",",
"child",
")",
";",
"}",
"}",
"}",
"return",
"n",
";",
"}"
] | Returns the set of frequent item sets.
@param out a print stream for output of frequent item sets.
@param list a container to store frequent item sets on output.
@return the number of discovered frequent item sets | [
"Returns",
"the",
"set",
"of",
"frequent",
"item",
"sets",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/TotalSupportTree.java#L192-L205 |
JodaOrg/joda-beans | src/main/java/org/joda/beans/ser/JodaBeanSer.java | JodaBeanSer.withIncludeDerived | public JodaBeanSer withIncludeDerived(boolean includeDerived) {
"""
Returns a copy of this serializer with the specified include derived flag.
<p>
The default deserializers can be modified.
<p>
This is used to set the output to include derived properties.
@param includeDerived whether to include derived properties on output
@return a copy of this object with the converter changed, not null
"""
return new JodaBeanSer(indent, newLine, converter, iteratorFactory, shortTypes, deserializers, includeDerived);
} | java | public JodaBeanSer withIncludeDerived(boolean includeDerived) {
return new JodaBeanSer(indent, newLine, converter, iteratorFactory, shortTypes, deserializers, includeDerived);
} | [
"public",
"JodaBeanSer",
"withIncludeDerived",
"(",
"boolean",
"includeDerived",
")",
"{",
"return",
"new",
"JodaBeanSer",
"(",
"indent",
",",
"newLine",
",",
"converter",
",",
"iteratorFactory",
",",
"shortTypes",
",",
"deserializers",
",",
"includeDerived",
")",
";",
"}"
] | Returns a copy of this serializer with the specified include derived flag.
<p>
The default deserializers can be modified.
<p>
This is used to set the output to include derived properties.
@param includeDerived whether to include derived properties on output
@return a copy of this object with the converter changed, not null | [
"Returns",
"a",
"copy",
"of",
"this",
"serializer",
"with",
"the",
"specified",
"include",
"derived",
"flag",
".",
"<p",
">",
"The",
"default",
"deserializers",
"can",
"be",
"modified",
".",
"<p",
">",
"This",
"is",
"used",
"to",
"set",
"the",
"output",
"to",
"include",
"derived",
"properties",
"."
] | train | https://github.com/JodaOrg/joda-beans/blob/f07dbe42947150b23a173f35984c6ab33c5529bf/src/main/java/org/joda/beans/ser/JodaBeanSer.java#L253-L255 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/ECKey.java | ECKey.findRecoveryId | public byte findRecoveryId(Sha256Hash hash, ECDSASignature sig) {
"""
Returns the recovery ID, a byte with value between 0 and 3, inclusive, that specifies which of 4 possible
curve points was used to sign a message. This value is also referred to as "v".
@throws RuntimeException if no recovery ID can be found.
"""
byte recId = -1;
for (byte i = 0; i < 4; i++) {
ECKey k = ECKey.recoverFromSignature(i, sig, hash, isCompressed());
if (k != null && k.pub.equals(pub)) {
recId = i;
break;
}
}
if (recId == -1)
throw new RuntimeException("Could not construct a recoverable key. This should never happen.");
return recId;
} | java | public byte findRecoveryId(Sha256Hash hash, ECDSASignature sig) {
byte recId = -1;
for (byte i = 0; i < 4; i++) {
ECKey k = ECKey.recoverFromSignature(i, sig, hash, isCompressed());
if (k != null && k.pub.equals(pub)) {
recId = i;
break;
}
}
if (recId == -1)
throw new RuntimeException("Could not construct a recoverable key. This should never happen.");
return recId;
} | [
"public",
"byte",
"findRecoveryId",
"(",
"Sha256Hash",
"hash",
",",
"ECDSASignature",
"sig",
")",
"{",
"byte",
"recId",
"=",
"-",
"1",
";",
"for",
"(",
"byte",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"ECKey",
"k",
"=",
"ECKey",
".",
"recoverFromSignature",
"(",
"i",
",",
"sig",
",",
"hash",
",",
"isCompressed",
"(",
")",
")",
";",
"if",
"(",
"k",
"!=",
"null",
"&&",
"k",
".",
"pub",
".",
"equals",
"(",
"pub",
")",
")",
"{",
"recId",
"=",
"i",
";",
"break",
";",
"}",
"}",
"if",
"(",
"recId",
"==",
"-",
"1",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not construct a recoverable key. This should never happen.\"",
")",
";",
"return",
"recId",
";",
"}"
] | Returns the recovery ID, a byte with value between 0 and 3, inclusive, that specifies which of 4 possible
curve points was used to sign a message. This value is also referred to as "v".
@throws RuntimeException if no recovery ID can be found. | [
"Returns",
"the",
"recovery",
"ID",
"a",
"byte",
"with",
"value",
"between",
"0",
"and",
"3",
"inclusive",
"that",
"specifies",
"which",
"of",
"4",
"possible",
"curve",
"points",
"was",
"used",
"to",
"sign",
"a",
"message",
".",
"This",
"value",
"is",
"also",
"referred",
"to",
"as",
"v",
"."
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/ECKey.java#L947-L959 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java | CopyOnWriteArrayList.indexOf | public int indexOf(E object, int from) {
"""
Searches this list for {@code object} and returns the index of the first
occurrence that is at or after {@code from}.
@return the index or -1 if the object was not found.
"""
Object[] snapshot = elements;
return indexOf(object, snapshot, from, snapshot.length);
} | java | public int indexOf(E object, int from) {
Object[] snapshot = elements;
return indexOf(object, snapshot, from, snapshot.length);
} | [
"public",
"int",
"indexOf",
"(",
"E",
"object",
",",
"int",
"from",
")",
"{",
"Object",
"[",
"]",
"snapshot",
"=",
"elements",
";",
"return",
"indexOf",
"(",
"object",
",",
"snapshot",
",",
"from",
",",
"snapshot",
".",
"length",
")",
";",
"}"
] | Searches this list for {@code object} and returns the index of the first
occurrence that is at or after {@code from}.
@return the index or -1 if the object was not found. | [
"Searches",
"this",
"list",
"for",
"{",
"@code",
"object",
"}",
"and",
"returns",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"that",
"is",
"at",
"or",
"after",
"{",
"@code",
"from",
"}",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java#L166-L169 |
trellis-ldp-archive/trellis-constraint-rules | src/main/java/org/trellisldp/constraint/LdpConstraints.java | LdpConstraints.hasMembershipProps | private static Boolean hasMembershipProps(final Map<IRI, Long> data) {
"""
Verify that ldp:membershipResource and one of ldp:hasMemberRelation or ldp:isMemberOfRelation is present
"""
return data.containsKey(LDP.membershipResource) &&
data.getOrDefault(LDP.hasMemberRelation, 0L) + data.getOrDefault(LDP.isMemberOfRelation, 0L) == 1L;
} | java | private static Boolean hasMembershipProps(final Map<IRI, Long> data) {
return data.containsKey(LDP.membershipResource) &&
data.getOrDefault(LDP.hasMemberRelation, 0L) + data.getOrDefault(LDP.isMemberOfRelation, 0L) == 1L;
} | [
"private",
"static",
"Boolean",
"hasMembershipProps",
"(",
"final",
"Map",
"<",
"IRI",
",",
"Long",
">",
"data",
")",
"{",
"return",
"data",
".",
"containsKey",
"(",
"LDP",
".",
"membershipResource",
")",
"&&",
"data",
".",
"getOrDefault",
"(",
"LDP",
".",
"hasMemberRelation",
",",
"0L",
")",
"+",
"data",
".",
"getOrDefault",
"(",
"LDP",
".",
"isMemberOfRelation",
",",
"0L",
")",
"==",
"1L",
";",
"}"
] | Verify that ldp:membershipResource and one of ldp:hasMemberRelation or ldp:isMemberOfRelation is present | [
"Verify",
"that",
"ldp",
":",
"membershipResource",
"and",
"one",
"of",
"ldp",
":",
"hasMemberRelation",
"or",
"ldp",
":",
"isMemberOfRelation",
"is",
"present"
] | train | https://github.com/trellis-ldp-archive/trellis-constraint-rules/blob/e038f421da71a42591a69565575300f848271503/src/main/java/org/trellisldp/constraint/LdpConstraints.java#L117-L120 |
groovy/groovy-core | src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java | StaticTypeCheckingVisitor.checkOrMarkPrivateAccess | private void checkOrMarkPrivateAccess(Expression source, MethodNode mn) {
"""
Given a method node, checks if we are calling a private method from an inner class.
"""
if (mn==null) {
return;
}
ClassNode declaringClass = mn.getDeclaringClass();
ClassNode enclosingClassNode = typeCheckingContext.getEnclosingClassNode();
if (declaringClass != enclosingClassNode || typeCheckingContext.getEnclosingClosure() != null) {
int mods = mn.getModifiers();
boolean sameModule = declaringClass.getModule() == enclosingClassNode.getModule();
String packageName = declaringClass.getPackageName();
if (packageName==null) {
packageName = "";
}
if ((Modifier.isPrivate(mods) && sameModule)
|| (Modifier.isProtected(mods) && !packageName.equals(enclosingClassNode.getPackageName()))) {
addPrivateFieldOrMethodAccess(source, sameModule? declaringClass : enclosingClassNode, StaticTypesMarker.PV_METHODS_ACCESS, mn);
}
}
} | java | private void checkOrMarkPrivateAccess(Expression source, MethodNode mn) {
if (mn==null) {
return;
}
ClassNode declaringClass = mn.getDeclaringClass();
ClassNode enclosingClassNode = typeCheckingContext.getEnclosingClassNode();
if (declaringClass != enclosingClassNode || typeCheckingContext.getEnclosingClosure() != null) {
int mods = mn.getModifiers();
boolean sameModule = declaringClass.getModule() == enclosingClassNode.getModule();
String packageName = declaringClass.getPackageName();
if (packageName==null) {
packageName = "";
}
if ((Modifier.isPrivate(mods) && sameModule)
|| (Modifier.isProtected(mods) && !packageName.equals(enclosingClassNode.getPackageName()))) {
addPrivateFieldOrMethodAccess(source, sameModule? declaringClass : enclosingClassNode, StaticTypesMarker.PV_METHODS_ACCESS, mn);
}
}
} | [
"private",
"void",
"checkOrMarkPrivateAccess",
"(",
"Expression",
"source",
",",
"MethodNode",
"mn",
")",
"{",
"if",
"(",
"mn",
"==",
"null",
")",
"{",
"return",
";",
"}",
"ClassNode",
"declaringClass",
"=",
"mn",
".",
"getDeclaringClass",
"(",
")",
";",
"ClassNode",
"enclosingClassNode",
"=",
"typeCheckingContext",
".",
"getEnclosingClassNode",
"(",
")",
";",
"if",
"(",
"declaringClass",
"!=",
"enclosingClassNode",
"||",
"typeCheckingContext",
".",
"getEnclosingClosure",
"(",
")",
"!=",
"null",
")",
"{",
"int",
"mods",
"=",
"mn",
".",
"getModifiers",
"(",
")",
";",
"boolean",
"sameModule",
"=",
"declaringClass",
".",
"getModule",
"(",
")",
"==",
"enclosingClassNode",
".",
"getModule",
"(",
")",
";",
"String",
"packageName",
"=",
"declaringClass",
".",
"getPackageName",
"(",
")",
";",
"if",
"(",
"packageName",
"==",
"null",
")",
"{",
"packageName",
"=",
"\"\"",
";",
"}",
"if",
"(",
"(",
"Modifier",
".",
"isPrivate",
"(",
"mods",
")",
"&&",
"sameModule",
")",
"||",
"(",
"Modifier",
".",
"isProtected",
"(",
"mods",
")",
"&&",
"!",
"packageName",
".",
"equals",
"(",
"enclosingClassNode",
".",
"getPackageName",
"(",
")",
")",
")",
")",
"{",
"addPrivateFieldOrMethodAccess",
"(",
"source",
",",
"sameModule",
"?",
"declaringClass",
":",
"enclosingClassNode",
",",
"StaticTypesMarker",
".",
"PV_METHODS_ACCESS",
",",
"mn",
")",
";",
"}",
"}",
"}"
] | Given a method node, checks if we are calling a private method from an inner class. | [
"Given",
"a",
"method",
"node",
"checks",
"if",
"we",
"are",
"calling",
"a",
"private",
"method",
"from",
"an",
"inner",
"class",
"."
] | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java#L358-L376 |
UrielCh/ovh-java-sdk | ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java | ApiOvhIpLoadbalancing.serviceName_definedFarms_GET | public ArrayList<OvhDefinedFarm> serviceName_definedFarms_GET(String serviceName, Long vrackNetworkId) throws IOException {
"""
List of defined farms, and whether they are HTTP, TCP or UDP
REST: GET /ipLoadbalancing/{serviceName}/definedFarms
@param vrackNetworkId [required] The vrack network id you want to filter on
@param serviceName [required] The internal name of your IP load balancing
"""
String qPath = "/ipLoadbalancing/{serviceName}/definedFarms";
StringBuilder sb = path(qPath, serviceName);
query(sb, "vrackNetworkId", vrackNetworkId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t4);
} | java | public ArrayList<OvhDefinedFarm> serviceName_definedFarms_GET(String serviceName, Long vrackNetworkId) throws IOException {
String qPath = "/ipLoadbalancing/{serviceName}/definedFarms";
StringBuilder sb = path(qPath, serviceName);
query(sb, "vrackNetworkId", vrackNetworkId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t4);
} | [
"public",
"ArrayList",
"<",
"OvhDefinedFarm",
">",
"serviceName_definedFarms_GET",
"(",
"String",
"serviceName",
",",
"Long",
"vrackNetworkId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/ipLoadbalancing/{serviceName}/definedFarms\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"query",
"(",
"sb",
",",
"\"vrackNetworkId\"",
",",
"vrackNetworkId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t4",
")",
";",
"}"
] | List of defined farms, and whether they are HTTP, TCP or UDP
REST: GET /ipLoadbalancing/{serviceName}/definedFarms
@param vrackNetworkId [required] The vrack network id you want to filter on
@param serviceName [required] The internal name of your IP load balancing | [
"List",
"of",
"defined",
"farms",
"and",
"whether",
"they",
"are",
"HTTP",
"TCP",
"or",
"UDP"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java#L695-L701 |
elki-project/elki | elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/FPGrowth.java | FPGrowth.buildFPTree | private FPTree buildFPTree(final Relation<BitVector> relation, int[] iidx, final int items) {
"""
Build the actual FP-tree structure.
@param relation Data
@param iidx Inverse index (dimension to item rank)
@param items Number of items
@return FP-tree
"""
FPTree tree = new FPTree(items);
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Building FP-tree", relation.size(), LOG) : null;
int[] buf = new int[items];
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
// Convert item to index representation:
int l = 0;
SparseFeatureVector<?> bv = relation.get(iditer);
for(int it = bv.iter(); bv.iterValid(it); it = bv.iterAdvance(it)) {
int i = iidx[bv.iterDim(it)];
if(i < 0) {
continue; // Skip non-frequent items
}
buf[l++] = i;
}
// Skip too short entries
if(l >= minlength) {
Arrays.sort(buf, 0, l); // Sort ascending
tree.insert(buf, 0, l, 1);
}
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
return tree;
} | java | private FPTree buildFPTree(final Relation<BitVector> relation, int[] iidx, final int items) {
FPTree tree = new FPTree(items);
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Building FP-tree", relation.size(), LOG) : null;
int[] buf = new int[items];
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
// Convert item to index representation:
int l = 0;
SparseFeatureVector<?> bv = relation.get(iditer);
for(int it = bv.iter(); bv.iterValid(it); it = bv.iterAdvance(it)) {
int i = iidx[bv.iterDim(it)];
if(i < 0) {
continue; // Skip non-frequent items
}
buf[l++] = i;
}
// Skip too short entries
if(l >= minlength) {
Arrays.sort(buf, 0, l); // Sort ascending
tree.insert(buf, 0, l, 1);
}
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
return tree;
} | [
"private",
"FPTree",
"buildFPTree",
"(",
"final",
"Relation",
"<",
"BitVector",
">",
"relation",
",",
"int",
"[",
"]",
"iidx",
",",
"final",
"int",
"items",
")",
"{",
"FPTree",
"tree",
"=",
"new",
"FPTree",
"(",
"items",
")",
";",
"FiniteProgress",
"prog",
"=",
"LOG",
".",
"isVerbose",
"(",
")",
"?",
"new",
"FiniteProgress",
"(",
"\"Building FP-tree\"",
",",
"relation",
".",
"size",
"(",
")",
",",
"LOG",
")",
":",
"null",
";",
"int",
"[",
"]",
"buf",
"=",
"new",
"int",
"[",
"items",
"]",
";",
"for",
"(",
"DBIDIter",
"iditer",
"=",
"relation",
".",
"iterDBIDs",
"(",
")",
";",
"iditer",
".",
"valid",
"(",
")",
";",
"iditer",
".",
"advance",
"(",
")",
")",
"{",
"// Convert item to index representation:",
"int",
"l",
"=",
"0",
";",
"SparseFeatureVector",
"<",
"?",
">",
"bv",
"=",
"relation",
".",
"get",
"(",
"iditer",
")",
";",
"for",
"(",
"int",
"it",
"=",
"bv",
".",
"iter",
"(",
")",
";",
"bv",
".",
"iterValid",
"(",
"it",
")",
";",
"it",
"=",
"bv",
".",
"iterAdvance",
"(",
"it",
")",
")",
"{",
"int",
"i",
"=",
"iidx",
"[",
"bv",
".",
"iterDim",
"(",
"it",
")",
"]",
";",
"if",
"(",
"i",
"<",
"0",
")",
"{",
"continue",
";",
"// Skip non-frequent items",
"}",
"buf",
"[",
"l",
"++",
"]",
"=",
"i",
";",
"}",
"// Skip too short entries",
"if",
"(",
"l",
">=",
"minlength",
")",
"{",
"Arrays",
".",
"sort",
"(",
"buf",
",",
"0",
",",
"l",
")",
";",
"// Sort ascending",
"tree",
".",
"insert",
"(",
"buf",
",",
"0",
",",
"l",
",",
"1",
")",
";",
"}",
"LOG",
".",
"incrementProcessed",
"(",
"prog",
")",
";",
"}",
"LOG",
".",
"ensureCompleted",
"(",
"prog",
")",
";",
"return",
"tree",
";",
"}"
] | Build the actual FP-tree structure.
@param relation Data
@param iidx Inverse index (dimension to item rank)
@param items Number of items
@return FP-tree | [
"Build",
"the",
"actual",
"FP",
"-",
"tree",
"structure",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/FPGrowth.java#L217-L241 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/UtilMath.java | UtilMath.isBetween | public static boolean isBetween(double value, double min, double max) {
"""
Check if value is between an interval.
@param value The value to check.
@param min The minimum value.
@param max The maximum value.
@return <code>true</code> if between, <code>false</code> else.
"""
return Double.compare(value, min) >= 0 && Double.compare(value, max) <= 0;
} | java | public static boolean isBetween(double value, double min, double max)
{
return Double.compare(value, min) >= 0 && Double.compare(value, max) <= 0;
} | [
"public",
"static",
"boolean",
"isBetween",
"(",
"double",
"value",
",",
"double",
"min",
",",
"double",
"max",
")",
"{",
"return",
"Double",
".",
"compare",
"(",
"value",
",",
"min",
")",
">=",
"0",
"&&",
"Double",
".",
"compare",
"(",
"value",
",",
"max",
")",
"<=",
"0",
";",
"}"
] | Check if value is between an interval.
@param value The value to check.
@param min The minimum value.
@param max The maximum value.
@return <code>true</code> if between, <code>false</code> else. | [
"Check",
"if",
"value",
"is",
"between",
"an",
"interval",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/UtilMath.java#L65-L68 |
sshtools/j2ssh-maverick | j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpSubsystemChannel.java | SftpSubsystemChannel.openFile | public SftpFile openFile(String absolutePath, int flags)
throws SftpStatusException, SshException {
"""
Open a file.
@param absolutePath
@param flags
@return SftpFile
@throws SftpStatusException
, SshException
"""
return openFile(absolutePath, flags, new SftpFileAttributes(this,
SftpFileAttributes.SSH_FILEXFER_TYPE_UNKNOWN));
} | java | public SftpFile openFile(String absolutePath, int flags)
throws SftpStatusException, SshException {
return openFile(absolutePath, flags, new SftpFileAttributes(this,
SftpFileAttributes.SSH_FILEXFER_TYPE_UNKNOWN));
} | [
"public",
"SftpFile",
"openFile",
"(",
"String",
"absolutePath",
",",
"int",
"flags",
")",
"throws",
"SftpStatusException",
",",
"SshException",
"{",
"return",
"openFile",
"(",
"absolutePath",
",",
"flags",
",",
"new",
"SftpFileAttributes",
"(",
"this",
",",
"SftpFileAttributes",
".",
"SSH_FILEXFER_TYPE_UNKNOWN",
")",
")",
";",
"}"
] | Open a file.
@param absolutePath
@param flags
@return SftpFile
@throws SftpStatusException
, SshException | [
"Open",
"a",
"file",
"."
] | train | https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpSubsystemChannel.java#L1526-L1530 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/qe/IndexedQueryExecutor.java | IndexedQueryExecutor.compareWithNullHigh | static int compareWithNullHigh(Object a, Object b) {
"""
Compares two objects which are assumed to be Comparable. If one value is
null, it is treated as being higher. This consistent with all other
property value comparisons in carbonado.
"""
return a == null ? (b == null ? 0 : -1) : (b == null ? 1 : ((Comparable) a).compareTo(b));
} | java | static int compareWithNullHigh(Object a, Object b) {
return a == null ? (b == null ? 0 : -1) : (b == null ? 1 : ((Comparable) a).compareTo(b));
} | [
"static",
"int",
"compareWithNullHigh",
"(",
"Object",
"a",
",",
"Object",
"b",
")",
"{",
"return",
"a",
"==",
"null",
"?",
"(",
"b",
"==",
"null",
"?",
"0",
":",
"-",
"1",
")",
":",
"(",
"b",
"==",
"null",
"?",
"1",
":",
"(",
"(",
"Comparable",
")",
"a",
")",
".",
"compareTo",
"(",
"b",
")",
")",
";",
"}"
] | Compares two objects which are assumed to be Comparable. If one value is
null, it is treated as being higher. This consistent with all other
property value comparisons in carbonado. | [
"Compares",
"two",
"objects",
"which",
"are",
"assumed",
"to",
"be",
"Comparable",
".",
"If",
"one",
"value",
"is",
"null",
"it",
"is",
"treated",
"as",
"being",
"higher",
".",
"This",
"consistent",
"with",
"all",
"other",
"property",
"value",
"comparisons",
"in",
"carbonado",
"."
] | train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/IndexedQueryExecutor.java#L49-L51 |
facebookarchive/hadoop-20 | src/mapred/org/apache/hadoop/mapred/lib/db/DBOutputFormat.java | DBOutputFormat.setOutput | public static void setOutput(JobConf job, String tableName, String... fieldNames) {
"""
Initializes the reduce-part of the job with the appropriate output settings
@param job
The job
@param tableName
The table to insert data into
@param fieldNames
The field names in the table. If unknown, supply the appropriate
number of nulls.
"""
job.setOutputFormat(DBOutputFormat.class);
job.setReduceSpeculativeExecution(false);
DBConfiguration dbConf = new DBConfiguration(job);
dbConf.setOutputTableName(tableName);
dbConf.setOutputFieldNames(fieldNames);
} | java | public static void setOutput(JobConf job, String tableName, String... fieldNames) {
job.setOutputFormat(DBOutputFormat.class);
job.setReduceSpeculativeExecution(false);
DBConfiguration dbConf = new DBConfiguration(job);
dbConf.setOutputTableName(tableName);
dbConf.setOutputFieldNames(fieldNames);
} | [
"public",
"static",
"void",
"setOutput",
"(",
"JobConf",
"job",
",",
"String",
"tableName",
",",
"String",
"...",
"fieldNames",
")",
"{",
"job",
".",
"setOutputFormat",
"(",
"DBOutputFormat",
".",
"class",
")",
";",
"job",
".",
"setReduceSpeculativeExecution",
"(",
"false",
")",
";",
"DBConfiguration",
"dbConf",
"=",
"new",
"DBConfiguration",
"(",
"job",
")",
";",
"dbConf",
".",
"setOutputTableName",
"(",
"tableName",
")",
";",
"dbConf",
".",
"setOutputFieldNames",
"(",
"fieldNames",
")",
";",
"}"
] | Initializes the reduce-part of the job with the appropriate output settings
@param job
The job
@param tableName
The table to insert data into
@param fieldNames
The field names in the table. If unknown, supply the appropriate
number of nulls. | [
"Initializes",
"the",
"reduce",
"-",
"part",
"of",
"the",
"job",
"with",
"the",
"appropriate",
"output",
"settings"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/mapred/org/apache/hadoop/mapred/lib/db/DBOutputFormat.java#L177-L185 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/webapp/WebApp.java | WebApp.acceptAnnotationsFrom | protected boolean acceptAnnotationsFrom(String className, boolean acceptPartial, boolean acceptExcluded) {
"""
Tell if annotations on a target class are to be processed. This is
controlled by the metadata-complete and absolute ordering settings
of the web module.
Metadata complete may be set for the web-module as a whole, or may be set
individually on fragments. Annotations are ignored when the target class
is in a metadata complete region.
When an absolute ordering element is present in the web module descriptor,
jars not listed are excluded from annotation processing.
Control parameters are provided to allow testing for the several usage cases.
See {@link com.ibm.wsspi.anno.classsource.ClassSource_Aggregate} for detailed
documentation.
Caution: Extra testing is necessary for annotations on inherited methods.
An inherited methods have two associated classes: The class which defined
the method and the class which is using the method definition.
Caution: Extra testing is necessary for inheritable annotations. Normally,
class annotations apply only to the class which provides the annotation
definition. As a special case, a class annotation may be declared as being
inherited, in which case the annotation applies to all subclasses of the
class which has the annotation definition.
@param className The name of the class which is to be tested.
@param acceptPartial Control parameter: Tell if partial classes are accepted.
@param acceptExcluded Control parameter: Tell if excluded classes are accepted.
@return True if annotations are accepted from the class. Otherwise, false.
"""
String methodName = "acceptAnnotationsFrom";
// Don't unnecessarily obtain the annotation targets table:
// No seed annotations will be obtained when the module is metadata-complete.
if (config.isMetadataComplete()) {
if (!acceptPartial && !acceptExcluded) {
return false;
}
}
try {
WebAnnotations webAppAnnotations = getModuleContainer().adapt(WebAnnotations.class);
AnnotationTargets_Targets table = webAppAnnotations.getAnnotationTargets();
return ( table.isSeedClassName(className) ||
(acceptPartial && table.isPartialClassName(className)) ||
(acceptExcluded && table.isExcludedClassName(className)) );
} catch (UnableToAdaptException e) {
logger.logp(Level.FINE, CLASS_NAME, methodName, "caught UnableToAdaptException: " + e);
return false;
}
} | java | protected boolean acceptAnnotationsFrom(String className, boolean acceptPartial, boolean acceptExcluded) {
String methodName = "acceptAnnotationsFrom";
// Don't unnecessarily obtain the annotation targets table:
// No seed annotations will be obtained when the module is metadata-complete.
if (config.isMetadataComplete()) {
if (!acceptPartial && !acceptExcluded) {
return false;
}
}
try {
WebAnnotations webAppAnnotations = getModuleContainer().adapt(WebAnnotations.class);
AnnotationTargets_Targets table = webAppAnnotations.getAnnotationTargets();
return ( table.isSeedClassName(className) ||
(acceptPartial && table.isPartialClassName(className)) ||
(acceptExcluded && table.isExcludedClassName(className)) );
} catch (UnableToAdaptException e) {
logger.logp(Level.FINE, CLASS_NAME, methodName, "caught UnableToAdaptException: " + e);
return false;
}
} | [
"protected",
"boolean",
"acceptAnnotationsFrom",
"(",
"String",
"className",
",",
"boolean",
"acceptPartial",
",",
"boolean",
"acceptExcluded",
")",
"{",
"String",
"methodName",
"=",
"\"acceptAnnotationsFrom\"",
";",
"// Don't unnecessarily obtain the annotation targets table:",
"// No seed annotations will be obtained when the module is metadata-complete.",
"if",
"(",
"config",
".",
"isMetadataComplete",
"(",
")",
")",
"{",
"if",
"(",
"!",
"acceptPartial",
"&&",
"!",
"acceptExcluded",
")",
"{",
"return",
"false",
";",
"}",
"}",
"try",
"{",
"WebAnnotations",
"webAppAnnotations",
"=",
"getModuleContainer",
"(",
")",
".",
"adapt",
"(",
"WebAnnotations",
".",
"class",
")",
";",
"AnnotationTargets_Targets",
"table",
"=",
"webAppAnnotations",
".",
"getAnnotationTargets",
"(",
")",
";",
"return",
"(",
"table",
".",
"isSeedClassName",
"(",
"className",
")",
"||",
"(",
"acceptPartial",
"&&",
"table",
".",
"isPartialClassName",
"(",
"className",
")",
")",
"||",
"(",
"acceptExcluded",
"&&",
"table",
".",
"isExcludedClassName",
"(",
"className",
")",
")",
")",
";",
"}",
"catch",
"(",
"UnableToAdaptException",
"e",
")",
"{",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINE",
",",
"CLASS_NAME",
",",
"methodName",
",",
"\"caught UnableToAdaptException: \"",
"+",
"e",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Tell if annotations on a target class are to be processed. This is
controlled by the metadata-complete and absolute ordering settings
of the web module.
Metadata complete may be set for the web-module as a whole, or may be set
individually on fragments. Annotations are ignored when the target class
is in a metadata complete region.
When an absolute ordering element is present in the web module descriptor,
jars not listed are excluded from annotation processing.
Control parameters are provided to allow testing for the several usage cases.
See {@link com.ibm.wsspi.anno.classsource.ClassSource_Aggregate} for detailed
documentation.
Caution: Extra testing is necessary for annotations on inherited methods.
An inherited methods have two associated classes: The class which defined
the method and the class which is using the method definition.
Caution: Extra testing is necessary for inheritable annotations. Normally,
class annotations apply only to the class which provides the annotation
definition. As a special case, a class annotation may be declared as being
inherited, in which case the annotation applies to all subclasses of the
class which has the annotation definition.
@param className The name of the class which is to be tested.
@param acceptPartial Control parameter: Tell if partial classes are accepted.
@param acceptExcluded Control parameter: Tell if excluded classes are accepted.
@return True if annotations are accepted from the class. Otherwise, false. | [
"Tell",
"if",
"annotations",
"on",
"a",
"target",
"class",
"are",
"to",
"be",
"processed",
".",
"This",
"is",
"controlled",
"by",
"the",
"metadata",
"-",
"complete",
"and",
"absolute",
"ordering",
"settings",
"of",
"the",
"web",
"module",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/webapp/WebApp.java#L754-L778 |
UrielCh/ovh-java-sdk | ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java | ApiOvhCloud.project_serviceName_storage_containerId_user_POST | public OvhUserDetail project_serviceName_storage_containerId_user_POST(String serviceName, String containerId, String description, OvhRightEnum right) throws IOException {
"""
Create openstack user with only access to this container
REST: POST /cloud/project/{serviceName}/storage/{containerId}/user
@param containerId [required] Container ID
@param description [required] User description
@param right [required] User right (all, read, write)
@param serviceName [required] Service name
"""
String qPath = "/cloud/project/{serviceName}/storage/{containerId}/user";
StringBuilder sb = path(qPath, serviceName, containerId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "right", right);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhUserDetail.class);
} | java | public OvhUserDetail project_serviceName_storage_containerId_user_POST(String serviceName, String containerId, String description, OvhRightEnum right) throws IOException {
String qPath = "/cloud/project/{serviceName}/storage/{containerId}/user";
StringBuilder sb = path(qPath, serviceName, containerId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "right", right);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhUserDetail.class);
} | [
"public",
"OvhUserDetail",
"project_serviceName_storage_containerId_user_POST",
"(",
"String",
"serviceName",
",",
"String",
"containerId",
",",
"String",
"description",
",",
"OvhRightEnum",
"right",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/project/{serviceName}/storage/{containerId}/user\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"containerId",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"description\"",
",",
"description",
")",
";",
"addBody",
"(",
"o",
",",
"\"right\"",
",",
"right",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhUserDetail",
".",
"class",
")",
";",
"}"
] | Create openstack user with only access to this container
REST: POST /cloud/project/{serviceName}/storage/{containerId}/user
@param containerId [required] Container ID
@param description [required] User description
@param right [required] User right (all, read, write)
@param serviceName [required] Service name | [
"Create",
"openstack",
"user",
"with",
"only",
"access",
"to",
"this",
"container"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L695-L703 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/filter/RawScale3x.java | RawScale3x.computeE3 | private static int computeE3(int a, int b, int d, int e, int g, int h) {
"""
Compute E3 pixel.
@param a The a value.
@param b The b value.
@param d The d value.
@param e The e value.
@param g The g value.
@param h The h value.
@return The computed value.
"""
if (d == b && e != g || d == h && e != a)
{
return d;
}
return e;
} | java | private static int computeE3(int a, int b, int d, int e, int g, int h)
{
if (d == b && e != g || d == h && e != a)
{
return d;
}
return e;
} | [
"private",
"static",
"int",
"computeE3",
"(",
"int",
"a",
",",
"int",
"b",
",",
"int",
"d",
",",
"int",
"e",
",",
"int",
"g",
",",
"int",
"h",
")",
"{",
"if",
"(",
"d",
"==",
"b",
"&&",
"e",
"!=",
"g",
"||",
"d",
"==",
"h",
"&&",
"e",
"!=",
"a",
")",
"{",
"return",
"d",
";",
"}",
"return",
"e",
";",
"}"
] | Compute E3 pixel.
@param a The a value.
@param b The b value.
@param d The d value.
@param e The e value.
@param g The g value.
@param h The h value.
@return The computed value. | [
"Compute",
"E3",
"pixel",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/filter/RawScale3x.java#L93-L100 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICUService.java | ICUService.getDisplayNames | public SortedMap<String, String> getDisplayNames(ULocale locale, Comparator<Object> com) {
"""
Convenience override of getDisplayNames(ULocale, Comparator, String) that
uses null for the matchID, thus returning all display names.
"""
return getDisplayNames(locale, com, null);
} | java | public SortedMap<String, String> getDisplayNames(ULocale locale, Comparator<Object> com) {
return getDisplayNames(locale, com, null);
} | [
"public",
"SortedMap",
"<",
"String",
",",
"String",
">",
"getDisplayNames",
"(",
"ULocale",
"locale",
",",
"Comparator",
"<",
"Object",
">",
"com",
")",
"{",
"return",
"getDisplayNames",
"(",
"locale",
",",
"com",
",",
"null",
")",
";",
"}"
] | Convenience override of getDisplayNames(ULocale, Comparator, String) that
uses null for the matchID, thus returning all display names. | [
"Convenience",
"override",
"of",
"getDisplayNames",
"(",
"ULocale",
"Comparator",
"String",
")",
"that",
"uses",
"null",
"for",
"the",
"matchID",
"thus",
"returning",
"all",
"display",
"names",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICUService.java#L660-L662 |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/MeshGenerator.java | MeshGenerator.generateCrosshairs | public static VertexData generateCrosshairs(float length) {
"""
Generates a crosshairs shaped wireframe in 3D. The center is at the intersection point of the three lines.
@param length The length for the three lines
@return The vertex data
"""
final VertexData destination = new VertexData();
final VertexAttribute positionsAttribute = new VertexAttribute("positions", DataType.FLOAT, 3);
destination.addAttribute(0, positionsAttribute);
final TFloatList positions = new TFloatArrayList();
final TIntList indices = destination.getIndices();
// Generate the mesh
generateCrosshairs(positions, indices, length);
// Put the mesh in the vertex data
positionsAttribute.setData(positions);
return destination;
} | java | public static VertexData generateCrosshairs(float length) {
final VertexData destination = new VertexData();
final VertexAttribute positionsAttribute = new VertexAttribute("positions", DataType.FLOAT, 3);
destination.addAttribute(0, positionsAttribute);
final TFloatList positions = new TFloatArrayList();
final TIntList indices = destination.getIndices();
// Generate the mesh
generateCrosshairs(positions, indices, length);
// Put the mesh in the vertex data
positionsAttribute.setData(positions);
return destination;
} | [
"public",
"static",
"VertexData",
"generateCrosshairs",
"(",
"float",
"length",
")",
"{",
"final",
"VertexData",
"destination",
"=",
"new",
"VertexData",
"(",
")",
";",
"final",
"VertexAttribute",
"positionsAttribute",
"=",
"new",
"VertexAttribute",
"(",
"\"positions\"",
",",
"DataType",
".",
"FLOAT",
",",
"3",
")",
";",
"destination",
".",
"addAttribute",
"(",
"0",
",",
"positionsAttribute",
")",
";",
"final",
"TFloatList",
"positions",
"=",
"new",
"TFloatArrayList",
"(",
")",
";",
"final",
"TIntList",
"indices",
"=",
"destination",
".",
"getIndices",
"(",
")",
";",
"// Generate the mesh",
"generateCrosshairs",
"(",
"positions",
",",
"indices",
",",
"length",
")",
";",
"// Put the mesh in the vertex data",
"positionsAttribute",
".",
"setData",
"(",
"positions",
")",
";",
"return",
"destination",
";",
"}"
] | Generates a crosshairs shaped wireframe in 3D. The center is at the intersection point of the three lines.
@param length The length for the three lines
@return The vertex data | [
"Generates",
"a",
"crosshairs",
"shaped",
"wireframe",
"in",
"3D",
".",
"The",
"center",
"is",
"at",
"the",
"intersection",
"point",
"of",
"the",
"three",
"lines",
"."
] | train | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/MeshGenerator.java#L484-L495 |
apache/flink | flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/HadoopInputs.java | HadoopInputs.readHadoopFile | public static <K, V> org.apache.flink.api.java.hadoop.mapreduce.HadoopInputFormat<K, V> readHadoopFile(
org.apache.hadoop.mapreduce.lib.input.FileInputFormat<K, V> mapreduceInputFormat, Class<K> key, Class<V> value, String inputPath) throws IOException {
"""
Creates a Flink {@link InputFormat} that wraps the given Hadoop {@link org.apache.hadoop.mapreduce.lib.input.FileInputFormat}.
@return A Flink InputFormat that wraps the Hadoop FileInputFormat.
"""
return readHadoopFile(mapreduceInputFormat, key, value, inputPath, Job.getInstance());
} | java | public static <K, V> org.apache.flink.api.java.hadoop.mapreduce.HadoopInputFormat<K, V> readHadoopFile(
org.apache.hadoop.mapreduce.lib.input.FileInputFormat<K, V> mapreduceInputFormat, Class<K> key, Class<V> value, String inputPath) throws IOException {
return readHadoopFile(mapreduceInputFormat, key, value, inputPath, Job.getInstance());
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"org",
".",
"apache",
".",
"flink",
".",
"api",
".",
"java",
".",
"hadoop",
".",
"mapreduce",
".",
"HadoopInputFormat",
"<",
"K",
",",
"V",
">",
"readHadoopFile",
"(",
"org",
".",
"apache",
".",
"hadoop",
".",
"mapreduce",
".",
"lib",
".",
"input",
".",
"FileInputFormat",
"<",
"K",
",",
"V",
">",
"mapreduceInputFormat",
",",
"Class",
"<",
"K",
">",
"key",
",",
"Class",
"<",
"V",
">",
"value",
",",
"String",
"inputPath",
")",
"throws",
"IOException",
"{",
"return",
"readHadoopFile",
"(",
"mapreduceInputFormat",
",",
"key",
",",
"value",
",",
"inputPath",
",",
"Job",
".",
"getInstance",
"(",
")",
")",
";",
"}"
] | Creates a Flink {@link InputFormat} that wraps the given Hadoop {@link org.apache.hadoop.mapreduce.lib.input.FileInputFormat}.
@return A Flink InputFormat that wraps the Hadoop FileInputFormat. | [
"Creates",
"a",
"Flink",
"{",
"@link",
"InputFormat",
"}",
"that",
"wraps",
"the",
"given",
"Hadoop",
"{",
"@link",
"org",
".",
"apache",
".",
"hadoop",
".",
"mapreduce",
".",
"lib",
".",
"input",
".",
"FileInputFormat",
"}",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/HadoopInputs.java#L102-L105 |
lindar-open/well-rested-client | src/main/java/com/lindar/wellrested/vo/Result.java | Result.orElseDoAndReturnDefault | public T orElseDoAndReturnDefault(Consumer<Result<T>> consumer, T defaultVal) {
"""
The consumer function receives the entire result object as parameter in case you want to log or manage the error message or code in any way.
@param consumer
@param defaultVal
@return
"""
if (isSuccessAndNotNull()) {
return data;
}
consumer.accept(this);
return defaultVal;
} | java | public T orElseDoAndReturnDefault(Consumer<Result<T>> consumer, T defaultVal) {
if (isSuccessAndNotNull()) {
return data;
}
consumer.accept(this);
return defaultVal;
} | [
"public",
"T",
"orElseDoAndReturnDefault",
"(",
"Consumer",
"<",
"Result",
"<",
"T",
">",
">",
"consumer",
",",
"T",
"defaultVal",
")",
"{",
"if",
"(",
"isSuccessAndNotNull",
"(",
")",
")",
"{",
"return",
"data",
";",
"}",
"consumer",
".",
"accept",
"(",
"this",
")",
";",
"return",
"defaultVal",
";",
"}"
] | The consumer function receives the entire result object as parameter in case you want to log or manage the error message or code in any way.
@param consumer
@param defaultVal
@return | [
"The",
"consumer",
"function",
"receives",
"the",
"entire",
"result",
"object",
"as",
"parameter",
"in",
"case",
"you",
"want",
"to",
"log",
"or",
"manage",
"the",
"error",
"message",
"or",
"code",
"in",
"any",
"way",
"."
] | train | https://github.com/lindar-open/well-rested-client/blob/d87542f747cd624e3ce0cdc8230f51836326596b/src/main/java/com/lindar/wellrested/vo/Result.java#L138-L144 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java | EventListenerSupport.createProxy | private void createProxy(final Class<L> listenerInterface, final ClassLoader classLoader) {
"""
Create the proxy object.
@param listenerInterface the class of the listener interface
@param classLoader the class loader to be used
"""
proxy = listenerInterface.cast(Proxy.newProxyInstance(classLoader,
new Class[] { listenerInterface }, createInvocationHandler()));
} | java | private void createProxy(final Class<L> listenerInterface, final ClassLoader classLoader) {
proxy = listenerInterface.cast(Proxy.newProxyInstance(classLoader,
new Class[] { listenerInterface }, createInvocationHandler()));
} | [
"private",
"void",
"createProxy",
"(",
"final",
"Class",
"<",
"L",
">",
"listenerInterface",
",",
"final",
"ClassLoader",
"classLoader",
")",
"{",
"proxy",
"=",
"listenerInterface",
".",
"cast",
"(",
"Proxy",
".",
"newProxyInstance",
"(",
"classLoader",
",",
"new",
"Class",
"[",
"]",
"{",
"listenerInterface",
"}",
",",
"createInvocationHandler",
"(",
")",
")",
")",
";",
"}"
] | Create the proxy object.
@param listenerInterface the class of the listener interface
@param classLoader the class loader to be used | [
"Create",
"the",
"proxy",
"object",
"."
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java#L304-L307 |
pip-services3-java/pip-services3-components-java | src/org/pipservices3/components/connect/MemoryDiscovery.java | MemoryDiscovery.resolveOne | public ConnectionParams resolveOne(String correlationId, String key) {
"""
Resolves a single connection parameters by its key.
@param correlationId (optional) transaction id to trace execution through
call chain.
@param key a key to uniquely identify the connection.
@return receives found connection.
"""
ConnectionParams connection = null;
synchronized (_lock) {
for (DiscoveryItem item : _items) {
if (item.key == key && item.connection != null) {
connection = item.connection;
break;
}
}
}
return connection;
} | java | public ConnectionParams resolveOne(String correlationId, String key) {
ConnectionParams connection = null;
synchronized (_lock) {
for (DiscoveryItem item : _items) {
if (item.key == key && item.connection != null) {
connection = item.connection;
break;
}
}
}
return connection;
} | [
"public",
"ConnectionParams",
"resolveOne",
"(",
"String",
"correlationId",
",",
"String",
"key",
")",
"{",
"ConnectionParams",
"connection",
"=",
"null",
";",
"synchronized",
"(",
"_lock",
")",
"{",
"for",
"(",
"DiscoveryItem",
"item",
":",
"_items",
")",
"{",
"if",
"(",
"item",
".",
"key",
"==",
"key",
"&&",
"item",
".",
"connection",
"!=",
"null",
")",
"{",
"connection",
"=",
"item",
".",
"connection",
";",
"break",
";",
"}",
"}",
"}",
"return",
"connection",
";",
"}"
] | Resolves a single connection parameters by its key.
@param correlationId (optional) transaction id to trace execution through
call chain.
@param key a key to uniquely identify the connection.
@return receives found connection. | [
"Resolves",
"a",
"single",
"connection",
"parameters",
"by",
"its",
"key",
"."
] | train | https://github.com/pip-services3-java/pip-services3-components-java/blob/122352fbf9b208f6417376da7b8ad725bc85ee58/src/org/pipservices3/components/connect/MemoryDiscovery.java#L114-L127 |
racc/typesafeconfig-guice | src/main/java/com/github/racc/tscg/TypesafeConfigModule.java | TypesafeConfigModule.fromConfigWithReflections | public static TypesafeConfigModule fromConfigWithReflections(Config config, Reflections reflections) {
"""
Scans the specified packages for annotated classes, and applies Config values to them.
@param config the Config to derive values from
@param reflections the reflections object to use
@return The constructed TypesafeConfigModule.
"""
return new TypesafeConfigModule(config, new ReflectionsReflector(reflections));
} | java | public static TypesafeConfigModule fromConfigWithReflections(Config config, Reflections reflections) {
return new TypesafeConfigModule(config, new ReflectionsReflector(reflections));
} | [
"public",
"static",
"TypesafeConfigModule",
"fromConfigWithReflections",
"(",
"Config",
"config",
",",
"Reflections",
"reflections",
")",
"{",
"return",
"new",
"TypesafeConfigModule",
"(",
"config",
",",
"new",
"ReflectionsReflector",
"(",
"reflections",
")",
")",
";",
"}"
] | Scans the specified packages for annotated classes, and applies Config values to them.
@param config the Config to derive values from
@param reflections the reflections object to use
@return The constructed TypesafeConfigModule. | [
"Scans",
"the",
"specified",
"packages",
"for",
"annotated",
"classes",
"and",
"applies",
"Config",
"values",
"to",
"them",
"."
] | train | https://github.com/racc/typesafeconfig-guice/blob/95e383ced94fe59f4a651d043f9d1764bc618a94/src/main/java/com/github/racc/tscg/TypesafeConfigModule.java#L89-L91 |
samskivert/samskivert | src/main/java/com/samskivert/util/Config.java | Config.getValue | public long getValue (String name, long defval) {
"""
Fetches and returns the value for the specified configuration property. If the value is not
specified in the associated properties file, the supplied default value is returned instead.
If the property specified in the file is poorly formatted (not and integer, not in proper
array specification), a warning message will be logged and the default value will be
returned.
@param name name of the property.
@param defval the value to return if the property is not specified in the config file.
@return the value of the requested property.
"""
String val = _props.getProperty(name);
if (val != null) {
try {
defval = Long.parseLong(val);
} catch (NumberFormatException nfe) {
log.warning("Malformed long integer property", "name", name, "value", val);
}
}
return defval;
} | java | public long getValue (String name, long defval)
{
String val = _props.getProperty(name);
if (val != null) {
try {
defval = Long.parseLong(val);
} catch (NumberFormatException nfe) {
log.warning("Malformed long integer property", "name", name, "value", val);
}
}
return defval;
} | [
"public",
"long",
"getValue",
"(",
"String",
"name",
",",
"long",
"defval",
")",
"{",
"String",
"val",
"=",
"_props",
".",
"getProperty",
"(",
"name",
")",
";",
"if",
"(",
"val",
"!=",
"null",
")",
"{",
"try",
"{",
"defval",
"=",
"Long",
".",
"parseLong",
"(",
"val",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"log",
".",
"warning",
"(",
"\"Malformed long integer property\"",
",",
"\"name\"",
",",
"name",
",",
"\"value\"",
",",
"val",
")",
";",
"}",
"}",
"return",
"defval",
";",
"}"
] | Fetches and returns the value for the specified configuration property. If the value is not
specified in the associated properties file, the supplied default value is returned instead.
If the property specified in the file is poorly formatted (not and integer, not in proper
array specification), a warning message will be logged and the default value will be
returned.
@param name name of the property.
@param defval the value to return if the property is not specified in the config file.
@return the value of the requested property. | [
"Fetches",
"and",
"returns",
"the",
"value",
"for",
"the",
"specified",
"configuration",
"property",
".",
"If",
"the",
"value",
"is",
"not",
"specified",
"in",
"the",
"associated",
"properties",
"file",
"the",
"supplied",
"default",
"value",
"is",
"returned",
"instead",
".",
"If",
"the",
"property",
"specified",
"in",
"the",
"file",
"is",
"poorly",
"formatted",
"(",
"not",
"and",
"integer",
"not",
"in",
"proper",
"array",
"specification",
")",
"a",
"warning",
"message",
"will",
"be",
"logged",
"and",
"the",
"default",
"value",
"will",
"be",
"returned",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Config.java#L135-L146 |
svenkubiak/mangooio | mangooio-core/src/main/java/io/mangoo/services/ServerSentEventService.java | ServerSentEventService.setConnections | public void setConnections(String uri, Set<ServerSentEventConnection> uriConnections) {
"""
Sets the URI resources for a given URL
@param uri The URI resource for the connection
@param uriConnections The connections for the URI resource
"""
Objects.requireNonNull(uri, Required.URI.toString());
Objects.requireNonNull(uriConnections, Required.URI_CONNECTIONS.toString());
this.cache.put(Default.SSE_CACHE_PREFIX.toString() + uri, uriConnections);
} | java | public void setConnections(String uri, Set<ServerSentEventConnection> uriConnections) {
Objects.requireNonNull(uri, Required.URI.toString());
Objects.requireNonNull(uriConnections, Required.URI_CONNECTIONS.toString());
this.cache.put(Default.SSE_CACHE_PREFIX.toString() + uri, uriConnections);
} | [
"public",
"void",
"setConnections",
"(",
"String",
"uri",
",",
"Set",
"<",
"ServerSentEventConnection",
">",
"uriConnections",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"uri",
",",
"Required",
".",
"URI",
".",
"toString",
"(",
")",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"uriConnections",
",",
"Required",
".",
"URI_CONNECTIONS",
".",
"toString",
"(",
")",
")",
";",
"this",
".",
"cache",
".",
"put",
"(",
"Default",
".",
"SSE_CACHE_PREFIX",
".",
"toString",
"(",
")",
"+",
"uri",
",",
"uriConnections",
")",
";",
"}"
] | Sets the URI resources for a given URL
@param uri The URI resource for the connection
@param uriConnections The connections for the URI resource | [
"Sets",
"the",
"URI",
"resources",
"for",
"a",
"given",
"URL"
] | train | https://github.com/svenkubiak/mangooio/blob/b3beb6d09510dbbab0ed947d5069c463e1fda6e7/mangooio-core/src/main/java/io/mangoo/services/ServerSentEventService.java#L133-L138 |
apache/groovy | src/main/groovy/groovy/util/FactoryBuilderSupport.java | FactoryBuilderSupport.registerBeanFactory | public void registerBeanFactory(String theName, String groupName, final Class beanClass) {
"""
Registers a factory for a JavaBean.<br>
The JavaBean class should have a no-args constructor.
@param theName name of the node
@param groupName thr group to register this node in
@param beanClass the factory to handle the name
"""
getProxyBuilder().registerFactory(theName, new AbstractFactory() {
public Object newInstance(FactoryBuilderSupport builder, Object name, Object value,
Map properties) throws InstantiationException, IllegalAccessException {
if (checkValueIsTypeNotString(value, name, beanClass)) {
return value;
} else {
return beanClass.newInstance();
}
}
});
getRegistrationGroup(groupName).add(theName);
} | java | public void registerBeanFactory(String theName, String groupName, final Class beanClass) {
getProxyBuilder().registerFactory(theName, new AbstractFactory() {
public Object newInstance(FactoryBuilderSupport builder, Object name, Object value,
Map properties) throws InstantiationException, IllegalAccessException {
if (checkValueIsTypeNotString(value, name, beanClass)) {
return value;
} else {
return beanClass.newInstance();
}
}
});
getRegistrationGroup(groupName).add(theName);
} | [
"public",
"void",
"registerBeanFactory",
"(",
"String",
"theName",
",",
"String",
"groupName",
",",
"final",
"Class",
"beanClass",
")",
"{",
"getProxyBuilder",
"(",
")",
".",
"registerFactory",
"(",
"theName",
",",
"new",
"AbstractFactory",
"(",
")",
"{",
"public",
"Object",
"newInstance",
"(",
"FactoryBuilderSupport",
"builder",
",",
"Object",
"name",
",",
"Object",
"value",
",",
"Map",
"properties",
")",
"throws",
"InstantiationException",
",",
"IllegalAccessException",
"{",
"if",
"(",
"checkValueIsTypeNotString",
"(",
"value",
",",
"name",
",",
"beanClass",
")",
")",
"{",
"return",
"value",
";",
"}",
"else",
"{",
"return",
"beanClass",
".",
"newInstance",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"getRegistrationGroup",
"(",
"groupName",
")",
".",
"add",
"(",
"theName",
")",
";",
"}"
] | Registers a factory for a JavaBean.<br>
The JavaBean class should have a no-args constructor.
@param theName name of the node
@param groupName thr group to register this node in
@param beanClass the factory to handle the name | [
"Registers",
"a",
"factory",
"for",
"a",
"JavaBean",
".",
"<br",
">",
"The",
"JavaBean",
"class",
"should",
"have",
"a",
"no",
"-",
"args",
"constructor",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L659-L671 |
JOML-CI/JOML | src/org/joml/Matrix3x2f.java | Matrix3x2f.shearX | public Matrix3x2f shearX(float yFactor, Matrix3x2f dest) {
"""
Apply shearing to this matrix by shearing along the X axis using the Y axis factor <code>yFactor</code>,
and store the result in <code>dest</code>.
@param yFactor
the factor for the Y component to shear along the X axis
@param dest
will hold the result
@return dest
"""
float nm10 = m00 * yFactor + m10;
float nm11 = m01 * yFactor + m11;
dest.m00 = m00;
dest.m01 = m01;
dest.m10 = nm10;
dest.m11 = nm11;
dest.m20 = m20;
dest.m21 = m21;
return dest;
} | java | public Matrix3x2f shearX(float yFactor, Matrix3x2f dest) {
float nm10 = m00 * yFactor + m10;
float nm11 = m01 * yFactor + m11;
dest.m00 = m00;
dest.m01 = m01;
dest.m10 = nm10;
dest.m11 = nm11;
dest.m20 = m20;
dest.m21 = m21;
return dest;
} | [
"public",
"Matrix3x2f",
"shearX",
"(",
"float",
"yFactor",
",",
"Matrix3x2f",
"dest",
")",
"{",
"float",
"nm10",
"=",
"m00",
"*",
"yFactor",
"+",
"m10",
";",
"float",
"nm11",
"=",
"m01",
"*",
"yFactor",
"+",
"m11",
";",
"dest",
".",
"m00",
"=",
"m00",
";",
"dest",
".",
"m01",
"=",
"m01",
";",
"dest",
".",
"m10",
"=",
"nm10",
";",
"dest",
".",
"m11",
"=",
"nm11",
";",
"dest",
".",
"m20",
"=",
"m20",
";",
"dest",
".",
"m21",
"=",
"m21",
";",
"return",
"dest",
";",
"}"
] | Apply shearing to this matrix by shearing along the X axis using the Y axis factor <code>yFactor</code>,
and store the result in <code>dest</code>.
@param yFactor
the factor for the Y component to shear along the X axis
@param dest
will hold the result
@return dest | [
"Apply",
"shearing",
"to",
"this",
"matrix",
"by",
"shearing",
"along",
"the",
"X",
"axis",
"using",
"the",
"Y",
"axis",
"factor",
"<code",
">",
"yFactor<",
"/",
"code",
">",
"and",
"store",
"the",
"result",
"in",
"<code",
">",
"dest<",
"/",
"code",
">",
"."
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix3x2f.java#L2332-L2342 |
Azure/azure-sdk-for-java | network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/NetworkWatchersInner.java | NetworkWatchersInner.getByResourceGroupAsync | public Observable<NetworkWatcherInner> getByResourceGroupAsync(String resourceGroupName, String networkWatcherName) {
"""
Gets the specified network watcher by resource group.
@param resourceGroupName The name of the resource group.
@param networkWatcherName The name of the network watcher.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkWatcherInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, networkWatcherName).map(new Func1<ServiceResponse<NetworkWatcherInner>, NetworkWatcherInner>() {
@Override
public NetworkWatcherInner call(ServiceResponse<NetworkWatcherInner> response) {
return response.body();
}
});
} | java | public Observable<NetworkWatcherInner> getByResourceGroupAsync(String resourceGroupName, String networkWatcherName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, networkWatcherName).map(new Func1<ServiceResponse<NetworkWatcherInner>, NetworkWatcherInner>() {
@Override
public NetworkWatcherInner call(ServiceResponse<NetworkWatcherInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"NetworkWatcherInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkWatcherName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"networkWatcherName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"NetworkWatcherInner",
">",
",",
"NetworkWatcherInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"NetworkWatcherInner",
"call",
"(",
"ServiceResponse",
"<",
"NetworkWatcherInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the specified network watcher by resource group.
@param resourceGroupName The name of the resource group.
@param networkWatcherName The name of the network watcher.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkWatcherInner object | [
"Gets",
"the",
"specified",
"network",
"watcher",
"by",
"resource",
"group",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/NetworkWatchersInner.java#L320-L327 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/mining/word/TfIdf.java | TfIdf.tf | public static <TERM> Map<TERM, Double> tf(Collection<TERM> document) {
"""
单文档词频
@param document 词袋
@param <TERM> 词语类型
@return 一个包含词频的Map
"""
return tf(document, TfType.NATURAL);
} | java | public static <TERM> Map<TERM, Double> tf(Collection<TERM> document)
{
return tf(document, TfType.NATURAL);
} | [
"public",
"static",
"<",
"TERM",
">",
"Map",
"<",
"TERM",
",",
"Double",
">",
"tf",
"(",
"Collection",
"<",
"TERM",
">",
"document",
")",
"{",
"return",
"tf",
"(",
"document",
",",
"TfType",
".",
"NATURAL",
")",
";",
"}"
] | 单文档词频
@param document 词袋
@param <TERM> 词语类型
@return 一个包含词频的Map | [
"单文档词频"
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/mining/word/TfIdf.java#L88-L91 |
Azure/azure-sdk-for-java | mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/DatabasesInner.java | DatabasesInner.listByServerAsync | public Observable<List<DatabaseInner>> listByServerAsync(String resourceGroupName, String serverName) {
"""
List all the databases in a given server.
@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.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<DatabaseInner> object
"""
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<DatabaseInner>>, List<DatabaseInner>>() {
@Override
public List<DatabaseInner> call(ServiceResponse<List<DatabaseInner>> response) {
return response.body();
}
});
} | java | public Observable<List<DatabaseInner>> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<DatabaseInner>>, List<DatabaseInner>>() {
@Override
public List<DatabaseInner> call(ServiceResponse<List<DatabaseInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"DatabaseInner",
">",
">",
"listByServerAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"DatabaseInner",
">",
">",
",",
"List",
"<",
"DatabaseInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"DatabaseInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"DatabaseInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | List all the databases in a given server.
@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.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<DatabaseInner> object | [
"List",
"all",
"the",
"databases",
"in",
"a",
"given",
"server",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/DatabasesInner.java#L569-L576 |
googleads/googleads-java-lib | modules/adwords_axis/src/main/java/com/google/api/ads/adwords/axis/utils/v201809/shopping/ProductPartitionNode.java | ProductPartitionNode.putCustomParameter | public ProductPartitionNode putCustomParameter(String key, String value) {
"""
Puts the specified key/value pair in the map of custom parameters.
@throws IllegalStateException if this node is not a biddable UNIT node
"""
if (!nodeState.supportsCustomParameters()) {
throw new IllegalStateException(
String.format("Cannot set custom parameters on a %s node", nodeState.getNodeType()));
}
this.nodeState.getCustomParams().put(key, value);
return this;
} | java | public ProductPartitionNode putCustomParameter(String key, String value) {
if (!nodeState.supportsCustomParameters()) {
throw new IllegalStateException(
String.format("Cannot set custom parameters on a %s node", nodeState.getNodeType()));
}
this.nodeState.getCustomParams().put(key, value);
return this;
} | [
"public",
"ProductPartitionNode",
"putCustomParameter",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"!",
"nodeState",
".",
"supportsCustomParameters",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"Cannot set custom parameters on a %s node\"",
",",
"nodeState",
".",
"getNodeType",
"(",
")",
")",
")",
";",
"}",
"this",
".",
"nodeState",
".",
"getCustomParams",
"(",
")",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Puts the specified key/value pair in the map of custom parameters.
@throws IllegalStateException if this node is not a biddable UNIT node | [
"Puts",
"the",
"specified",
"key",
"/",
"value",
"pair",
"in",
"the",
"map",
"of",
"custom",
"parameters",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/adwords_axis/src/main/java/com/google/api/ads/adwords/axis/utils/v201809/shopping/ProductPartitionNode.java#L406-L413 |
soi-toolkit/soi-toolkit-mule | commons/components/studio-components/src/main/java/org/soitoolkit/commons/studio/components/logger/LoggerModule.java | LoggerModule.logInfo | @Processor
public Object logInfo(
@Optional @FriendlyName("Log Message") String message,
@Optional String integrationScenario,
@Optional String messageType,
@Optional String contractId,
@Optional String correlationId,
@Optional @FriendlyName("Extra Info") Map<String, String> extraInfo) {
"""
Log processor for level INFO
{@sample.xml ../../../doc/soitoolkit-connector.xml.sample soitoolkit:log-info}
@param message Log-message to be processed
@param integrationScenario Optional name of the integration scenario or business process
@param messageType Optional name of the message type, e.g. a XML Schema namespace for a XML payload
@param contractId Optional name of the contract in use
@param correlationId Optional correlation identity of the message
@param extraInfo Optional extra info
@return The incoming payload
"""
return doLog(LogLevelType.INFO, message, integrationScenario, contractId, correlationId, extraInfo);
} | java | @Processor
public Object logInfo(
@Optional @FriendlyName("Log Message") String message,
@Optional String integrationScenario,
@Optional String messageType,
@Optional String contractId,
@Optional String correlationId,
@Optional @FriendlyName("Extra Info") Map<String, String> extraInfo) {
return doLog(LogLevelType.INFO, message, integrationScenario, contractId, correlationId, extraInfo);
} | [
"@",
"Processor",
"public",
"Object",
"logInfo",
"(",
"@",
"Optional",
"@",
"FriendlyName",
"(",
"\"Log Message\"",
")",
"String",
"message",
",",
"@",
"Optional",
"String",
"integrationScenario",
",",
"@",
"Optional",
"String",
"messageType",
",",
"@",
"Optional",
"String",
"contractId",
",",
"@",
"Optional",
"String",
"correlationId",
",",
"@",
"Optional",
"@",
"FriendlyName",
"(",
"\"Extra Info\"",
")",
"Map",
"<",
"String",
",",
"String",
">",
"extraInfo",
")",
"{",
"return",
"doLog",
"(",
"LogLevelType",
".",
"INFO",
",",
"message",
",",
"integrationScenario",
",",
"contractId",
",",
"correlationId",
",",
"extraInfo",
")",
";",
"}"
] | Log processor for level INFO
{@sample.xml ../../../doc/soitoolkit-connector.xml.sample soitoolkit:log-info}
@param message Log-message to be processed
@param integrationScenario Optional name of the integration scenario or business process
@param messageType Optional name of the message type, e.g. a XML Schema namespace for a XML payload
@param contractId Optional name of the contract in use
@param correlationId Optional correlation identity of the message
@param extraInfo Optional extra info
@return The incoming payload | [
"Log",
"processor",
"for",
"level",
"INFO"
] | train | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/commons/components/studio-components/src/main/java/org/soitoolkit/commons/studio/components/logger/LoggerModule.java#L202-L212 |
codegist/crest | core/src/main/java/org/codegist/crest/CRestBuilder.java | CRestBuilder.bindDeserializer | public CRestBuilder bindDeserializer(Class<? extends Deserializer> deserializer, Class<?>... classes) {
"""
<p>Binds a deserializer to a list of interface method's return types.</p>
<p>By default, <b>CRest</b> handle the following types:</p>
<ul>
<li>all primitives and wrapper types</li>
<li>java.io.InputStream</li>
<li>java.io.Reader</li>
</ul>
<p>Meaning that any interface method return type can be by default one of these types.</p>
@param deserializer Deserializer class to use for the given interface method's return types
@param classes Interface method's return types to bind deserializer to
@return current builder
"""
return bindDeserializer(deserializer, classes, Collections.<String, Object>emptyMap());
} | java | public CRestBuilder bindDeserializer(Class<? extends Deserializer> deserializer, Class<?>... classes) {
return bindDeserializer(deserializer, classes, Collections.<String, Object>emptyMap());
} | [
"public",
"CRestBuilder",
"bindDeserializer",
"(",
"Class",
"<",
"?",
"extends",
"Deserializer",
">",
"deserializer",
",",
"Class",
"<",
"?",
">",
"...",
"classes",
")",
"{",
"return",
"bindDeserializer",
"(",
"deserializer",
",",
"classes",
",",
"Collections",
".",
"<",
"String",
",",
"Object",
">",
"emptyMap",
"(",
")",
")",
";",
"}"
] | <p>Binds a deserializer to a list of interface method's return types.</p>
<p>By default, <b>CRest</b> handle the following types:</p>
<ul>
<li>all primitives and wrapper types</li>
<li>java.io.InputStream</li>
<li>java.io.Reader</li>
</ul>
<p>Meaning that any interface method return type can be by default one of these types.</p>
@param deserializer Deserializer class to use for the given interface method's return types
@param classes Interface method's return types to bind deserializer to
@return current builder | [
"<p",
">",
"Binds",
"a",
"deserializer",
"to",
"a",
"list",
"of",
"interface",
"method",
"s",
"return",
"types",
".",
"<",
"/",
"p",
">",
"<p",
">",
"By",
"default",
"<b",
">",
"CRest<",
"/",
"b",
">",
"handle",
"the",
"following",
"types",
":",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"all",
"primitives",
"and",
"wrapper",
"types<",
"/",
"li",
">",
"<li",
">",
"java",
".",
"io",
".",
"InputStream<",
"/",
"li",
">",
"<li",
">",
"java",
".",
"io",
".",
"Reader<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<p",
">",
"Meaning",
"that",
"any",
"interface",
"method",
"return",
"type",
"can",
"be",
"by",
"default",
"one",
"of",
"these",
"types",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/codegist/crest/blob/e99ba7728b27d2ddb2c247261350f1b6fa7a6698/core/src/main/java/org/codegist/crest/CRestBuilder.java#L546-L548 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/ShortField.java | ShortField.setValue | public int setValue(double value, boolean bDisplayOption, int moveMode) {
"""
/*
Set the Value of this field as a double.
@param value The value of this field.
@param iDisplayOption If true, display the new field.
@param iMoveMove The move mode.
@return An error code (NORMAL_RETURN for success).
""" // Set this field's value
Short tempshort = new Short((short)value);
int errorCode = this.setData(tempshort, bDisplayOption, moveMode);
return errorCode;
} | java | public int setValue(double value, boolean bDisplayOption, int moveMode)
{ // Set this field's value
Short tempshort = new Short((short)value);
int errorCode = this.setData(tempshort, bDisplayOption, moveMode);
return errorCode;
} | [
"public",
"int",
"setValue",
"(",
"double",
"value",
",",
"boolean",
"bDisplayOption",
",",
"int",
"moveMode",
")",
"{",
"// Set this field's value",
"Short",
"tempshort",
"=",
"new",
"Short",
"(",
"(",
"short",
")",
"value",
")",
";",
"int",
"errorCode",
"=",
"this",
".",
"setData",
"(",
"tempshort",
",",
"bDisplayOption",
",",
"moveMode",
")",
";",
"return",
"errorCode",
";",
"}"
] | /*
Set the Value of this field as a double.
@param value The value of this field.
@param iDisplayOption If true, display the new field.
@param iMoveMove The move mode.
@return An error code (NORMAL_RETURN for success). | [
"/",
"*",
"Set",
"the",
"Value",
"of",
"this",
"field",
"as",
"a",
"double",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/ShortField.java#L191-L196 |
knowm/XChange | xchange-coinmate/src/main/java/org/knowm/xchange/coinmate/CoinmateAdapters.java | CoinmateAdapters.adaptTicker | public static Ticker adaptTicker(CoinmateTicker coinmateTicker, CurrencyPair currencyPair) {
"""
Adapts a CoinmateTicker to a Ticker Object
@param coinmateTicker The exchange specific ticker
@param currencyPair (e.g. BTC/USD)
@return The ticker
"""
BigDecimal last = coinmateTicker.getData().getLast();
BigDecimal bid = coinmateTicker.getData().getBid();
BigDecimal ask = coinmateTicker.getData().getAsk();
BigDecimal high = coinmateTicker.getData().getHigh();
BigDecimal low = coinmateTicker.getData().getLow();
BigDecimal volume = coinmateTicker.getData().getAmount();
Date timestamp = new Date(coinmateTicker.getData().getTimestamp() * 1000L);
return new Ticker.Builder()
.currencyPair(currencyPair)
.last(last)
.bid(bid)
.ask(ask)
.high(high)
.low(low)
.volume(volume)
.timestamp(timestamp)
.build();
} | java | public static Ticker adaptTicker(CoinmateTicker coinmateTicker, CurrencyPair currencyPair) {
BigDecimal last = coinmateTicker.getData().getLast();
BigDecimal bid = coinmateTicker.getData().getBid();
BigDecimal ask = coinmateTicker.getData().getAsk();
BigDecimal high = coinmateTicker.getData().getHigh();
BigDecimal low = coinmateTicker.getData().getLow();
BigDecimal volume = coinmateTicker.getData().getAmount();
Date timestamp = new Date(coinmateTicker.getData().getTimestamp() * 1000L);
return new Ticker.Builder()
.currencyPair(currencyPair)
.last(last)
.bid(bid)
.ask(ask)
.high(high)
.low(low)
.volume(volume)
.timestamp(timestamp)
.build();
} | [
"public",
"static",
"Ticker",
"adaptTicker",
"(",
"CoinmateTicker",
"coinmateTicker",
",",
"CurrencyPair",
"currencyPair",
")",
"{",
"BigDecimal",
"last",
"=",
"coinmateTicker",
".",
"getData",
"(",
")",
".",
"getLast",
"(",
")",
";",
"BigDecimal",
"bid",
"=",
"coinmateTicker",
".",
"getData",
"(",
")",
".",
"getBid",
"(",
")",
";",
"BigDecimal",
"ask",
"=",
"coinmateTicker",
".",
"getData",
"(",
")",
".",
"getAsk",
"(",
")",
";",
"BigDecimal",
"high",
"=",
"coinmateTicker",
".",
"getData",
"(",
")",
".",
"getHigh",
"(",
")",
";",
"BigDecimal",
"low",
"=",
"coinmateTicker",
".",
"getData",
"(",
")",
".",
"getLow",
"(",
")",
";",
"BigDecimal",
"volume",
"=",
"coinmateTicker",
".",
"getData",
"(",
")",
".",
"getAmount",
"(",
")",
";",
"Date",
"timestamp",
"=",
"new",
"Date",
"(",
"coinmateTicker",
".",
"getData",
"(",
")",
".",
"getTimestamp",
"(",
")",
"*",
"1000L",
")",
";",
"return",
"new",
"Ticker",
".",
"Builder",
"(",
")",
".",
"currencyPair",
"(",
"currencyPair",
")",
".",
"last",
"(",
"last",
")",
".",
"bid",
"(",
"bid",
")",
".",
"ask",
"(",
"ask",
")",
".",
"high",
"(",
"high",
")",
".",
"low",
"(",
"low",
")",
".",
"volume",
"(",
"volume",
")",
".",
"timestamp",
"(",
"timestamp",
")",
".",
"build",
"(",
")",
";",
"}"
] | Adapts a CoinmateTicker to a Ticker Object
@param coinmateTicker The exchange specific ticker
@param currencyPair (e.g. BTC/USD)
@return The ticker | [
"Adapts",
"a",
"CoinmateTicker",
"to",
"a",
"Ticker",
"Object"
] | train | https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinmate/src/main/java/org/knowm/xchange/coinmate/CoinmateAdapters.java#L66-L86 |
igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java | JingleManager.isServiceEnabled | public static boolean isServiceEnabled(XMPPConnection connection, Jid userID) throws XMPPException, SmackException, InterruptedException {
"""
Returns true if the specified user handles Jingle messages.
@param connection the connection to use to perform the service discovery
@param userID the user to check. A fully qualified xmpp ID, e.g.
[email protected]
@return a boolean indicating whether the specified user handles Jingle
messages
@throws SmackException if there was no response from the server.
@throws XMPPException
@throws InterruptedException
"""
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(userID, Jingle.NAMESPACE);
} | java | public static boolean isServiceEnabled(XMPPConnection connection, Jid userID) throws XMPPException, SmackException, InterruptedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(userID, Jingle.NAMESPACE);
} | [
"public",
"static",
"boolean",
"isServiceEnabled",
"(",
"XMPPConnection",
"connection",
",",
"Jid",
"userID",
")",
"throws",
"XMPPException",
",",
"SmackException",
",",
"InterruptedException",
"{",
"return",
"ServiceDiscoveryManager",
".",
"getInstanceFor",
"(",
"connection",
")",
".",
"supportsFeature",
"(",
"userID",
",",
"Jingle",
".",
"NAMESPACE",
")",
";",
"}"
] | Returns true if the specified user handles Jingle messages.
@param connection the connection to use to perform the service discovery
@param userID the user to check. A fully qualified xmpp ID, e.g.
[email protected]
@return a boolean indicating whether the specified user handles Jingle
messages
@throws SmackException if there was no response from the server.
@throws XMPPException
@throws InterruptedException | [
"Returns",
"true",
"if",
"the",
"specified",
"user",
"handles",
"Jingle",
"messages",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java#L309-L311 |
Azure/azure-sdk-for-java | mediaservices/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/mediaservices/v2018_07_01/implementation/StreamingEndpointsInner.java | StreamingEndpointsInner.beginScaleAsync | public Observable<Void> beginScaleAsync(String resourceGroupName, String accountName, String streamingEndpointName) {
"""
Scale StreamingEndpoint.
Scales an existing StreamingEndpoint.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param streamingEndpointName The name of the StreamingEndpoint.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return beginScaleWithServiceResponseAsync(resourceGroupName, accountName, streamingEndpointName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginScaleAsync(String resourceGroupName, String accountName, String streamingEndpointName) {
return beginScaleWithServiceResponseAsync(resourceGroupName, accountName, streamingEndpointName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginScaleAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"streamingEndpointName",
")",
"{",
"return",
"beginScaleWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"streamingEndpointName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Scale StreamingEndpoint.
Scales an existing StreamingEndpoint.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param streamingEndpointName The name of the StreamingEndpoint.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Scale",
"StreamingEndpoint",
".",
"Scales",
"an",
"existing",
"StreamingEndpoint",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/mediaservices/v2018_07_01/implementation/StreamingEndpointsInner.java#L1673-L1680 |
mirage-sql/mirage | src/main/java/com/miragesql/miragesql/bean/BeanDescFactory.java | BeanDescFactory.getBeanDesc | public BeanDesc getBeanDesc(Class<?> clazz) {
"""
Constructs a bean descriptor out of a class.
@param clazz the class to create the descriptor from. For <code>Map.class</code>, <code>HashMap.class</code> and
<code>LinkedHashMap.class</code> no properties can be extracted, so this operations needs to be done later.
@return a descriptor
"""
if(clazz == Map.class || clazz == HashMap.class || clazz == LinkedHashMap.class){
return new MapBeanDescImpl();
}
if(cacheEnabled && cacheMap.containsKey(clazz)){
return cacheMap.get(clazz);
}
BeanDesc beanDesc = new BeanDescImpl(clazz, propertyExtractor.extractProperties(clazz));
if(cacheEnabled){
cacheMap.put(clazz, beanDesc);
}
return beanDesc;
} | java | public BeanDesc getBeanDesc(Class<?> clazz){
if(clazz == Map.class || clazz == HashMap.class || clazz == LinkedHashMap.class){
return new MapBeanDescImpl();
}
if(cacheEnabled && cacheMap.containsKey(clazz)){
return cacheMap.get(clazz);
}
BeanDesc beanDesc = new BeanDescImpl(clazz, propertyExtractor.extractProperties(clazz));
if(cacheEnabled){
cacheMap.put(clazz, beanDesc);
}
return beanDesc;
} | [
"public",
"BeanDesc",
"getBeanDesc",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
"==",
"Map",
".",
"class",
"||",
"clazz",
"==",
"HashMap",
".",
"class",
"||",
"clazz",
"==",
"LinkedHashMap",
".",
"class",
")",
"{",
"return",
"new",
"MapBeanDescImpl",
"(",
")",
";",
"}",
"if",
"(",
"cacheEnabled",
"&&",
"cacheMap",
".",
"containsKey",
"(",
"clazz",
")",
")",
"{",
"return",
"cacheMap",
".",
"get",
"(",
"clazz",
")",
";",
"}",
"BeanDesc",
"beanDesc",
"=",
"new",
"BeanDescImpl",
"(",
"clazz",
",",
"propertyExtractor",
".",
"extractProperties",
"(",
"clazz",
")",
")",
";",
"if",
"(",
"cacheEnabled",
")",
"{",
"cacheMap",
".",
"put",
"(",
"clazz",
",",
"beanDesc",
")",
";",
"}",
"return",
"beanDesc",
";",
"}"
] | Constructs a bean descriptor out of a class.
@param clazz the class to create the descriptor from. For <code>Map.class</code>, <code>HashMap.class</code> and
<code>LinkedHashMap.class</code> no properties can be extracted, so this operations needs to be done later.
@return a descriptor | [
"Constructs",
"a",
"bean",
"descriptor",
"out",
"of",
"a",
"class",
"."
] | train | https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/bean/BeanDescFactory.java#L51-L67 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java | FSNamesystem.allocateBlock | private Block allocateBlock(String src, INode[] inodes) throws IOException {
"""
Allocate a block at the given pending filename
@param src path to the file
@param inodes INode representing each of the components of src.
<code>inodes[inodes.length-1]</code> is the INode for the file.
"""
Block b = new Block(generateBlockId(), 0, 0);
while (isValidBlock(b)) {
b.setBlockId(generateBlockId());
}
b.setGenerationStamp(getGenerationStamp());
b = dir.addBlock(src, inodes, b);
return b;
} | java | private Block allocateBlock(String src, INode[] inodes) throws IOException {
Block b = new Block(generateBlockId(), 0, 0);
while (isValidBlock(b)) {
b.setBlockId(generateBlockId());
}
b.setGenerationStamp(getGenerationStamp());
b = dir.addBlock(src, inodes, b);
return b;
} | [
"private",
"Block",
"allocateBlock",
"(",
"String",
"src",
",",
"INode",
"[",
"]",
"inodes",
")",
"throws",
"IOException",
"{",
"Block",
"b",
"=",
"new",
"Block",
"(",
"generateBlockId",
"(",
")",
",",
"0",
",",
"0",
")",
";",
"while",
"(",
"isValidBlock",
"(",
"b",
")",
")",
"{",
"b",
".",
"setBlockId",
"(",
"generateBlockId",
"(",
")",
")",
";",
"}",
"b",
".",
"setGenerationStamp",
"(",
"getGenerationStamp",
"(",
")",
")",
";",
"b",
"=",
"dir",
".",
"addBlock",
"(",
"src",
",",
"inodes",
",",
"b",
")",
";",
"return",
"b",
";",
"}"
] | Allocate a block at the given pending filename
@param src path to the file
@param inodes INode representing each of the components of src.
<code>inodes[inodes.length-1]</code> is the INode for the file. | [
"Allocate",
"a",
"block",
"at",
"the",
"given",
"pending",
"filename"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java#L3307-L3315 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/collidable/CollidableConfig.java | CollidableConfig.imports | public static Integer imports(Configurer configurer) {
"""
Create the collidable data from node.
@param configurer The configurer reference (must not be <code>null</code>).
@return The associated group, {@link #DEFAULT_GROUP} if not defined.
@throws LionEngineException If unable to read node.
"""
Check.notNull(configurer);
if (configurer.hasNode(NODE_GROUP))
{
final String group = configurer.getText(NODE_GROUP);
try
{
return Integer.valueOf(group);
}
catch (final NumberFormatException exception)
{
throw new LionEngineException(exception, ERROR_INVALID_GROUP + group);
}
}
return DEFAULT_GROUP;
} | java | public static Integer imports(Configurer configurer)
{
Check.notNull(configurer);
if (configurer.hasNode(NODE_GROUP))
{
final String group = configurer.getText(NODE_GROUP);
try
{
return Integer.valueOf(group);
}
catch (final NumberFormatException exception)
{
throw new LionEngineException(exception, ERROR_INVALID_GROUP + group);
}
}
return DEFAULT_GROUP;
} | [
"public",
"static",
"Integer",
"imports",
"(",
"Configurer",
"configurer",
")",
"{",
"Check",
".",
"notNull",
"(",
"configurer",
")",
";",
"if",
"(",
"configurer",
".",
"hasNode",
"(",
"NODE_GROUP",
")",
")",
"{",
"final",
"String",
"group",
"=",
"configurer",
".",
"getText",
"(",
"NODE_GROUP",
")",
";",
"try",
"{",
"return",
"Integer",
".",
"valueOf",
"(",
"group",
")",
";",
"}",
"catch",
"(",
"final",
"NumberFormatException",
"exception",
")",
"{",
"throw",
"new",
"LionEngineException",
"(",
"exception",
",",
"ERROR_INVALID_GROUP",
"+",
"group",
")",
";",
"}",
"}",
"return",
"DEFAULT_GROUP",
";",
"}"
] | Create the collidable data from node.
@param configurer The configurer reference (must not be <code>null</code>).
@return The associated group, {@link #DEFAULT_GROUP} if not defined.
@throws LionEngineException If unable to read node. | [
"Create",
"the",
"collidable",
"data",
"from",
"node",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/collidable/CollidableConfig.java#L50-L68 |
ArcBees/gwtquery | samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java | GwtQueryBenchModule.moveHorses | private void moveHorses(Benchmark[] b, int row, double[] totalTimes) {
"""
Update horse possition.
Note that the calculated position is relative with the faster horse,
so a horse could move back.
"""
if (!useTrack) return;
double winnerTime = Double.MAX_VALUE;
for (double d : totalTimes) {
winnerTime = Math.min(winnerTime, d);
}
double winnerPos = row * (double) trackWidth / (double) ds.length;
for (int i = 0; i < b.length; i++) {
GQuery g = $("#" + b[i].getId() + "horse");
double pos = winnerPos * winnerTime / totalTimes[i];
g.css("left", (int)pos + "px");
}
} | java | private void moveHorses(Benchmark[] b, int row, double[] totalTimes) {
if (!useTrack) return;
double winnerTime = Double.MAX_VALUE;
for (double d : totalTimes) {
winnerTime = Math.min(winnerTime, d);
}
double winnerPos = row * (double) trackWidth / (double) ds.length;
for (int i = 0; i < b.length; i++) {
GQuery g = $("#" + b[i].getId() + "horse");
double pos = winnerPos * winnerTime / totalTimes[i];
g.css("left", (int)pos + "px");
}
} | [
"private",
"void",
"moveHorses",
"(",
"Benchmark",
"[",
"]",
"b",
",",
"int",
"row",
",",
"double",
"[",
"]",
"totalTimes",
")",
"{",
"if",
"(",
"!",
"useTrack",
")",
"return",
";",
"double",
"winnerTime",
"=",
"Double",
".",
"MAX_VALUE",
";",
"for",
"(",
"double",
"d",
":",
"totalTimes",
")",
"{",
"winnerTime",
"=",
"Math",
".",
"min",
"(",
"winnerTime",
",",
"d",
")",
";",
"}",
"double",
"winnerPos",
"=",
"row",
"*",
"(",
"double",
")",
"trackWidth",
"/",
"(",
"double",
")",
"ds",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"b",
".",
"length",
";",
"i",
"++",
")",
"{",
"GQuery",
"g",
"=",
"$",
"(",
"\"#\"",
"+",
"b",
"[",
"i",
"]",
".",
"getId",
"(",
")",
"+",
"\"horse\"",
")",
";",
"double",
"pos",
"=",
"winnerPos",
"*",
"winnerTime",
"/",
"totalTimes",
"[",
"i",
"]",
";",
"g",
".",
"css",
"(",
"\"left\"",
",",
"(",
"int",
")",
"pos",
"+",
"\"px\"",
")",
";",
"}",
"}"
] | Update horse possition.
Note that the calculated position is relative with the faster horse,
so a horse could move back. | [
"Update",
"horse",
"possition",
".",
"Note",
"that",
"the",
"calculated",
"position",
"is",
"relative",
"with",
"the",
"faster",
"horse",
"so",
"a",
"horse",
"could",
"move",
"back",
"."
] | train | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java#L488-L500 |
Mozu/mozu-java | mozu-java-core/src/main/java/com/mozu/api/urls/commerce/customer/CustomerSegmentUrl.java | CustomerSegmentUrl.removeSegmentAccountUrl | public static MozuUrl removeSegmentAccountUrl(Integer accountId, Integer id) {
"""
Get Resource Url for RemoveSegmentAccount
@param accountId Unique identifier of the customer account.
@param id Unique identifier of the customer segment to retrieve.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/commerce/customer/segments/{id}/accounts/{accountId}");
formatter.formatUrl("accountId", accountId);
formatter.formatUrl("id", id);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl removeSegmentAccountUrl(Integer accountId, Integer id)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/customer/segments/{id}/accounts/{accountId}");
formatter.formatUrl("accountId", accountId);
formatter.formatUrl("id", id);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"removeSegmentAccountUrl",
"(",
"Integer",
"accountId",
",",
"Integer",
"id",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/customer/segments/{id}/accounts/{accountId}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"accountId\"",
",",
"accountId",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"id\"",
",",
"id",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] | Get Resource Url for RemoveSegmentAccount
@param accountId Unique identifier of the customer account.
@param id Unique identifier of the customer segment to retrieve.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"RemoveSegmentAccount"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/commerce/customer/CustomerSegmentUrl.java#L106-L112 |
google/closure-compiler | src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java | DevirtualizePrototypeMethods.rewriteDefinition | private void rewriteDefinition(Node definitionSite, String newMethodName) {
"""
Rewrites method definitions as global functions that take "this" as their first argument.
<p>Before: a.prototype.b = function(a, b, c) {...}
<p>After: var b = function(self, a, b, c) {...}
"""
final Node function;
final Node subtreeToRemove;
final Node nameSource;
switch (definitionSite.getToken()) {
case GETPROP:
function = definitionSite.getParent().getLastChild();
nameSource = definitionSite.getLastChild();
subtreeToRemove = NodeUtil.getEnclosingStatement(definitionSite);
break;
case STRING_KEY:
case MEMBER_FUNCTION_DEF:
function = definitionSite.getLastChild();
nameSource = definitionSite;
subtreeToRemove = definitionSite;
break;
default:
throw new IllegalArgumentException(definitionSite.toString());
}
// Define a new variable after the original declaration.
Node statement = NodeUtil.getEnclosingStatement(definitionSite);
Node newNameNode = IR.name(newMethodName).useSourceInfoIfMissingFrom(nameSource);
Node newVarNode = IR.var(newNameNode).useSourceInfoIfMissingFrom(nameSource);
statement.getParent().addChildBefore(newVarNode, statement);
// Attatch the function to the new variable.
function.detach();
newNameNode.addChildToFront(function);
// Create the `this` param.
String selfName = newMethodName + "$self";
Node paramList = function.getSecondChild();
paramList.addChildToFront(IR.name(selfName).useSourceInfoIfMissingFrom(function));
compiler.reportChangeToEnclosingScope(paramList);
// Eliminate `this`.
replaceReferencesToThis(function.getSecondChild(), selfName); // In default param values.
replaceReferencesToThis(function.getLastChild(), selfName); // In function body.
fixFunctionType(function);
// Clean up dangling AST.
NodeUtil.deleteNode(subtreeToRemove, compiler);
compiler.reportChangeToEnclosingScope(newVarNode);
} | java | private void rewriteDefinition(Node definitionSite, String newMethodName) {
final Node function;
final Node subtreeToRemove;
final Node nameSource;
switch (definitionSite.getToken()) {
case GETPROP:
function = definitionSite.getParent().getLastChild();
nameSource = definitionSite.getLastChild();
subtreeToRemove = NodeUtil.getEnclosingStatement(definitionSite);
break;
case STRING_KEY:
case MEMBER_FUNCTION_DEF:
function = definitionSite.getLastChild();
nameSource = definitionSite;
subtreeToRemove = definitionSite;
break;
default:
throw new IllegalArgumentException(definitionSite.toString());
}
// Define a new variable after the original declaration.
Node statement = NodeUtil.getEnclosingStatement(definitionSite);
Node newNameNode = IR.name(newMethodName).useSourceInfoIfMissingFrom(nameSource);
Node newVarNode = IR.var(newNameNode).useSourceInfoIfMissingFrom(nameSource);
statement.getParent().addChildBefore(newVarNode, statement);
// Attatch the function to the new variable.
function.detach();
newNameNode.addChildToFront(function);
// Create the `this` param.
String selfName = newMethodName + "$self";
Node paramList = function.getSecondChild();
paramList.addChildToFront(IR.name(selfName).useSourceInfoIfMissingFrom(function));
compiler.reportChangeToEnclosingScope(paramList);
// Eliminate `this`.
replaceReferencesToThis(function.getSecondChild(), selfName); // In default param values.
replaceReferencesToThis(function.getLastChild(), selfName); // In function body.
fixFunctionType(function);
// Clean up dangling AST.
NodeUtil.deleteNode(subtreeToRemove, compiler);
compiler.reportChangeToEnclosingScope(newVarNode);
} | [
"private",
"void",
"rewriteDefinition",
"(",
"Node",
"definitionSite",
",",
"String",
"newMethodName",
")",
"{",
"final",
"Node",
"function",
";",
"final",
"Node",
"subtreeToRemove",
";",
"final",
"Node",
"nameSource",
";",
"switch",
"(",
"definitionSite",
".",
"getToken",
"(",
")",
")",
"{",
"case",
"GETPROP",
":",
"function",
"=",
"definitionSite",
".",
"getParent",
"(",
")",
".",
"getLastChild",
"(",
")",
";",
"nameSource",
"=",
"definitionSite",
".",
"getLastChild",
"(",
")",
";",
"subtreeToRemove",
"=",
"NodeUtil",
".",
"getEnclosingStatement",
"(",
"definitionSite",
")",
";",
"break",
";",
"case",
"STRING_KEY",
":",
"case",
"MEMBER_FUNCTION_DEF",
":",
"function",
"=",
"definitionSite",
".",
"getLastChild",
"(",
")",
";",
"nameSource",
"=",
"definitionSite",
";",
"subtreeToRemove",
"=",
"definitionSite",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"definitionSite",
".",
"toString",
"(",
")",
")",
";",
"}",
"// Define a new variable after the original declaration.",
"Node",
"statement",
"=",
"NodeUtil",
".",
"getEnclosingStatement",
"(",
"definitionSite",
")",
";",
"Node",
"newNameNode",
"=",
"IR",
".",
"name",
"(",
"newMethodName",
")",
".",
"useSourceInfoIfMissingFrom",
"(",
"nameSource",
")",
";",
"Node",
"newVarNode",
"=",
"IR",
".",
"var",
"(",
"newNameNode",
")",
".",
"useSourceInfoIfMissingFrom",
"(",
"nameSource",
")",
";",
"statement",
".",
"getParent",
"(",
")",
".",
"addChildBefore",
"(",
"newVarNode",
",",
"statement",
")",
";",
"// Attatch the function to the new variable.",
"function",
".",
"detach",
"(",
")",
";",
"newNameNode",
".",
"addChildToFront",
"(",
"function",
")",
";",
"// Create the `this` param.",
"String",
"selfName",
"=",
"newMethodName",
"+",
"\"$self\"",
";",
"Node",
"paramList",
"=",
"function",
".",
"getSecondChild",
"(",
")",
";",
"paramList",
".",
"addChildToFront",
"(",
"IR",
".",
"name",
"(",
"selfName",
")",
".",
"useSourceInfoIfMissingFrom",
"(",
"function",
")",
")",
";",
"compiler",
".",
"reportChangeToEnclosingScope",
"(",
"paramList",
")",
";",
"// Eliminate `this`.",
"replaceReferencesToThis",
"(",
"function",
".",
"getSecondChild",
"(",
")",
",",
"selfName",
")",
";",
"// In default param values.",
"replaceReferencesToThis",
"(",
"function",
".",
"getLastChild",
"(",
")",
",",
"selfName",
")",
";",
"// In function body.",
"fixFunctionType",
"(",
"function",
")",
";",
"// Clean up dangling AST.",
"NodeUtil",
".",
"deleteNode",
"(",
"subtreeToRemove",
",",
"compiler",
")",
";",
"compiler",
".",
"reportChangeToEnclosingScope",
"(",
"newVarNode",
")",
";",
"}"
] | Rewrites method definitions as global functions that take "this" as their first argument.
<p>Before: a.prototype.b = function(a, b, c) {...}
<p>After: var b = function(self, a, b, c) {...} | [
"Rewrites",
"method",
"definitions",
"as",
"global",
"functions",
"that",
"take",
"this",
"as",
"their",
"first",
"argument",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java#L397-L445 |
cdk/cdk | base/silent/src/main/java/org/openscience/cdk/silent/SilentChemObjectBuilder.java | SilentChemObjectBuilder.getSystemProp | private static boolean getSystemProp(final String key, final boolean defaultValue) {
"""
an error rather than return false. The default can also be specified.
"""
String val = System.getProperty(key);
if (val == null)
val = System.getenv(key);
if (val == null) {
return defaultValue;
} else if (val.isEmpty()) {
return true;
} else {
switch (val.toLowerCase(Locale.ROOT)) {
case "t":
case "true":
case "1":
return true;
case "f":
case "false":
case "0":
return false;
default:
throw new IllegalArgumentException("Invalid value, expected true/false: " + val);
}
}
} | java | private static boolean getSystemProp(final String key, final boolean defaultValue) {
String val = System.getProperty(key);
if (val == null)
val = System.getenv(key);
if (val == null) {
return defaultValue;
} else if (val.isEmpty()) {
return true;
} else {
switch (val.toLowerCase(Locale.ROOT)) {
case "t":
case "true":
case "1":
return true;
case "f":
case "false":
case "0":
return false;
default:
throw new IllegalArgumentException("Invalid value, expected true/false: " + val);
}
}
} | [
"private",
"static",
"boolean",
"getSystemProp",
"(",
"final",
"String",
"key",
",",
"final",
"boolean",
"defaultValue",
")",
"{",
"String",
"val",
"=",
"System",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"val",
"==",
"null",
")",
"val",
"=",
"System",
".",
"getenv",
"(",
"key",
")",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"else",
"if",
"(",
"val",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"switch",
"(",
"val",
".",
"toLowerCase",
"(",
"Locale",
".",
"ROOT",
")",
")",
"{",
"case",
"\"t\"",
":",
"case",
"\"true\"",
":",
"case",
"\"1\"",
":",
"return",
"true",
";",
"case",
"\"f\"",
":",
"case",
"\"false\"",
":",
"case",
"\"0\"",
":",
"return",
"false",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid value, expected true/false: \"",
"+",
"val",
")",
";",
"}",
"}",
"}"
] | an error rather than return false. The default can also be specified. | [
"an",
"error",
"rather",
"than",
"return",
"false",
".",
"The",
"default",
"can",
"also",
"be",
"specified",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/silent/src/main/java/org/openscience/cdk/silent/SilentChemObjectBuilder.java#L91-L113 |
JodaOrg/joda-time | src/main/java/org/joda/time/Duration.java | Duration.standardHours | public static Duration standardHours(long hours) {
"""
Create a duration with the specified number of hours assuming that
there are the standard number of milliseconds in an hour.
<p>
This method assumes that there are 60 minutes in an hour,
60 seconds in a minute and 1000 milliseconds in a second.
All currently supplied chronologies use this definition.
<p>
A Duration is a representation of an amount of time. If you want to express
the concept of 'hours' you should consider using the {@link Hours} class.
@param hours the number of standard hours in this duration
@return the duration, never null
@throws ArithmeticException if the hours value is too large
@since 1.6
"""
if (hours == 0) {
return ZERO;
}
return new Duration(FieldUtils.safeMultiply(hours, DateTimeConstants.MILLIS_PER_HOUR));
} | java | public static Duration standardHours(long hours) {
if (hours == 0) {
return ZERO;
}
return new Duration(FieldUtils.safeMultiply(hours, DateTimeConstants.MILLIS_PER_HOUR));
} | [
"public",
"static",
"Duration",
"standardHours",
"(",
"long",
"hours",
")",
"{",
"if",
"(",
"hours",
"==",
"0",
")",
"{",
"return",
"ZERO",
";",
"}",
"return",
"new",
"Duration",
"(",
"FieldUtils",
".",
"safeMultiply",
"(",
"hours",
",",
"DateTimeConstants",
".",
"MILLIS_PER_HOUR",
")",
")",
";",
"}"
] | Create a duration with the specified number of hours assuming that
there are the standard number of milliseconds in an hour.
<p>
This method assumes that there are 60 minutes in an hour,
60 seconds in a minute and 1000 milliseconds in a second.
All currently supplied chronologies use this definition.
<p>
A Duration is a representation of an amount of time. If you want to express
the concept of 'hours' you should consider using the {@link Hours} class.
@param hours the number of standard hours in this duration
@return the duration, never null
@throws ArithmeticException if the hours value is too large
@since 1.6 | [
"Create",
"a",
"duration",
"with",
"the",
"specified",
"number",
"of",
"hours",
"assuming",
"that",
"there",
"are",
"the",
"standard",
"number",
"of",
"milliseconds",
"in",
"an",
"hour",
".",
"<p",
">",
"This",
"method",
"assumes",
"that",
"there",
"are",
"60",
"minutes",
"in",
"an",
"hour",
"60",
"seconds",
"in",
"a",
"minute",
"and",
"1000",
"milliseconds",
"in",
"a",
"second",
".",
"All",
"currently",
"supplied",
"chronologies",
"use",
"this",
"definition",
".",
"<p",
">",
"A",
"Duration",
"is",
"a",
"representation",
"of",
"an",
"amount",
"of",
"time",
".",
"If",
"you",
"want",
"to",
"express",
"the",
"concept",
"of",
"hours",
"you",
"should",
"consider",
"using",
"the",
"{",
"@link",
"Hours",
"}",
"class",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Duration.java#L105-L110 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/spatial/geometry/GeometryFactory.java | GeometryFactory.createMultiLineString | public MultiLineString createMultiLineString(LineString[] lineStrings) {
"""
Create a new {@link MultiLineString}, given an array of LineStrings.
@param lineStrings
An array of {@link LineString} objects.
@return Returns a {@link MultiLineString} object.
"""
if (lineStrings == null) {
return new MultiLineString(srid, precision);
}
LineString[] clones = new LineString[lineStrings.length];
for (int i = 0; i < lineStrings.length; i++) {
clones[i] = (LineString) lineStrings[i].clone();
}
return new MultiLineString(srid, precision, clones);
} | java | public MultiLineString createMultiLineString(LineString[] lineStrings) {
if (lineStrings == null) {
return new MultiLineString(srid, precision);
}
LineString[] clones = new LineString[lineStrings.length];
for (int i = 0; i < lineStrings.length; i++) {
clones[i] = (LineString) lineStrings[i].clone();
}
return new MultiLineString(srid, precision, clones);
} | [
"public",
"MultiLineString",
"createMultiLineString",
"(",
"LineString",
"[",
"]",
"lineStrings",
")",
"{",
"if",
"(",
"lineStrings",
"==",
"null",
")",
"{",
"return",
"new",
"MultiLineString",
"(",
"srid",
",",
"precision",
")",
";",
"}",
"LineString",
"[",
"]",
"clones",
"=",
"new",
"LineString",
"[",
"lineStrings",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lineStrings",
".",
"length",
";",
"i",
"++",
")",
"{",
"clones",
"[",
"i",
"]",
"=",
"(",
"LineString",
")",
"lineStrings",
"[",
"i",
"]",
".",
"clone",
"(",
")",
";",
"}",
"return",
"new",
"MultiLineString",
"(",
"srid",
",",
"precision",
",",
"clones",
")",
";",
"}"
] | Create a new {@link MultiLineString}, given an array of LineStrings.
@param lineStrings
An array of {@link LineString} objects.
@return Returns a {@link MultiLineString} object. | [
"Create",
"a",
"new",
"{",
"@link",
"MultiLineString",
"}",
"given",
"an",
"array",
"of",
"LineStrings",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/spatial/geometry/GeometryFactory.java#L108-L117 |
alkacon/opencms-core | src/org/opencms/jsp/decorator/CmsDecorationDefintion.java | CmsDecorationDefintion.createDecorationBundle | public CmsDecorationBundle createDecorationBundle(List<CmsDecorationMap> decorationMaps, Locale locale) {
"""
Creates a CmsDecorationBundle of text decoration to be used by the decorator based on a list of decoration maps.<p>
@param decorationMaps the decoration maps to build the bundle from
@param locale the locale to build the decoration bundle for. If no locale is given, a bundle of all locales is build
@return CmsDecorationBundle including all decoration lists that match the locale
"""
CmsDecorationBundle decorationBundle = new CmsDecorationBundle(locale);
// sort the bundles
Collections.sort(decorationMaps);
// now process the decoration maps to see which of those must be added to the bundle
Iterator<CmsDecorationMap> i = decorationMaps.iterator();
while (i.hasNext()) {
CmsDecorationMap decMap = i.next();
// a decoration map must be added to the bundle if one of the following conditions match:
// 1) the bundle has no locale
// 2) the bundle has a locale and the locale of the map is equal or a sublocale
// 3) the bundle has a locale and the map has no locale
if ((locale == null)
|| ((decMap.getLocale() == null))
|| (locale.getDisplayLanguage().equals(decMap.getLocale().getDisplayLanguage()))) {
decorationBundle.putAll(decMap.getDecorationMap());
if (LOG.isDebugEnabled()) {
LOG.debug(
Messages.get().getBundle().key(
Messages.LOG_DECORATION_DEFINITION_CREATE_BUNDLE_2,
decMap.getName(),
locale));
}
}
}
return decorationBundle;
} | java | public CmsDecorationBundle createDecorationBundle(List<CmsDecorationMap> decorationMaps, Locale locale) {
CmsDecorationBundle decorationBundle = new CmsDecorationBundle(locale);
// sort the bundles
Collections.sort(decorationMaps);
// now process the decoration maps to see which of those must be added to the bundle
Iterator<CmsDecorationMap> i = decorationMaps.iterator();
while (i.hasNext()) {
CmsDecorationMap decMap = i.next();
// a decoration map must be added to the bundle if one of the following conditions match:
// 1) the bundle has no locale
// 2) the bundle has a locale and the locale of the map is equal or a sublocale
// 3) the bundle has a locale and the map has no locale
if ((locale == null)
|| ((decMap.getLocale() == null))
|| (locale.getDisplayLanguage().equals(decMap.getLocale().getDisplayLanguage()))) {
decorationBundle.putAll(decMap.getDecorationMap());
if (LOG.isDebugEnabled()) {
LOG.debug(
Messages.get().getBundle().key(
Messages.LOG_DECORATION_DEFINITION_CREATE_BUNDLE_2,
decMap.getName(),
locale));
}
}
}
return decorationBundle;
} | [
"public",
"CmsDecorationBundle",
"createDecorationBundle",
"(",
"List",
"<",
"CmsDecorationMap",
">",
"decorationMaps",
",",
"Locale",
"locale",
")",
"{",
"CmsDecorationBundle",
"decorationBundle",
"=",
"new",
"CmsDecorationBundle",
"(",
"locale",
")",
";",
"// sort the bundles",
"Collections",
".",
"sort",
"(",
"decorationMaps",
")",
";",
"// now process the decoration maps to see which of those must be added to the bundle",
"Iterator",
"<",
"CmsDecorationMap",
">",
"i",
"=",
"decorationMaps",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"CmsDecorationMap",
"decMap",
"=",
"i",
".",
"next",
"(",
")",
";",
"// a decoration map must be added to the bundle if one of the following conditions match:",
"// 1) the bundle has no locale",
"// 2) the bundle has a locale and the locale of the map is equal or a sublocale",
"// 3) the bundle has a locale and the map has no locale",
"if",
"(",
"(",
"locale",
"==",
"null",
")",
"||",
"(",
"(",
"decMap",
".",
"getLocale",
"(",
")",
"==",
"null",
")",
")",
"||",
"(",
"locale",
".",
"getDisplayLanguage",
"(",
")",
".",
"equals",
"(",
"decMap",
".",
"getLocale",
"(",
")",
".",
"getDisplayLanguage",
"(",
")",
")",
")",
")",
"{",
"decorationBundle",
".",
"putAll",
"(",
"decMap",
".",
"getDecorationMap",
"(",
")",
")",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"LOG_DECORATION_DEFINITION_CREATE_BUNDLE_2",
",",
"decMap",
".",
"getName",
"(",
")",
",",
"locale",
")",
")",
";",
"}",
"}",
"}",
"return",
"decorationBundle",
";",
"}"
] | Creates a CmsDecorationBundle of text decoration to be used by the decorator based on a list of decoration maps.<p>
@param decorationMaps the decoration maps to build the bundle from
@param locale the locale to build the decoration bundle for. If no locale is given, a bundle of all locales is build
@return CmsDecorationBundle including all decoration lists that match the locale | [
"Creates",
"a",
"CmsDecorationBundle",
"of",
"text",
"decoration",
"to",
"be",
"used",
"by",
"the",
"decorator",
"based",
"on",
"a",
"list",
"of",
"decoration",
"maps",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/decorator/CmsDecorationDefintion.java#L198-L225 |
ahome-it/lienzo-core | src/main/java/com/ait/lienzo/shared/core/types/Color.java | Color.hex2RGB | public static final Color hex2RGB(final String hex) {
"""
Converts Hex string to RGB. Assumes
@param hex String of length 7, e.g. "#1234EF"
@return {@link Color}
"""
String r, g, b;
final int len = hex.length();
if (len == 7)
{
r = hex.substring(1, 3);
g = hex.substring(3, 5);
b = hex.substring(5, 7);
}
else if (len == 4)
{
r = hex.substring(1, 2);
g = hex.substring(2, 3);
b = hex.substring(3, 4);
r = r + r;
g = g + g;
b = b + b;
}
else
{
return null;// error - invalid length
}
try
{
return new Color(Integer.valueOf(r, 16), Integer.valueOf(g, 16), Integer.valueOf(b, 16));
}
catch (final NumberFormatException ignored)
{
return null;
}
} | java | public static final Color hex2RGB(final String hex)
{
String r, g, b;
final int len = hex.length();
if (len == 7)
{
r = hex.substring(1, 3);
g = hex.substring(3, 5);
b = hex.substring(5, 7);
}
else if (len == 4)
{
r = hex.substring(1, 2);
g = hex.substring(2, 3);
b = hex.substring(3, 4);
r = r + r;
g = g + g;
b = b + b;
}
else
{
return null;// error - invalid length
}
try
{
return new Color(Integer.valueOf(r, 16), Integer.valueOf(g, 16), Integer.valueOf(b, 16));
}
catch (final NumberFormatException ignored)
{
return null;
}
} | [
"public",
"static",
"final",
"Color",
"hex2RGB",
"(",
"final",
"String",
"hex",
")",
"{",
"String",
"r",
",",
"g",
",",
"b",
";",
"final",
"int",
"len",
"=",
"hex",
".",
"length",
"(",
")",
";",
"if",
"(",
"len",
"==",
"7",
")",
"{",
"r",
"=",
"hex",
".",
"substring",
"(",
"1",
",",
"3",
")",
";",
"g",
"=",
"hex",
".",
"substring",
"(",
"3",
",",
"5",
")",
";",
"b",
"=",
"hex",
".",
"substring",
"(",
"5",
",",
"7",
")",
";",
"}",
"else",
"if",
"(",
"len",
"==",
"4",
")",
"{",
"r",
"=",
"hex",
".",
"substring",
"(",
"1",
",",
"2",
")",
";",
"g",
"=",
"hex",
".",
"substring",
"(",
"2",
",",
"3",
")",
";",
"b",
"=",
"hex",
".",
"substring",
"(",
"3",
",",
"4",
")",
";",
"r",
"=",
"r",
"+",
"r",
";",
"g",
"=",
"g",
"+",
"g",
";",
"b",
"=",
"b",
"+",
"b",
";",
"}",
"else",
"{",
"return",
"null",
";",
"// error - invalid length",
"}",
"try",
"{",
"return",
"new",
"Color",
"(",
"Integer",
".",
"valueOf",
"(",
"r",
",",
"16",
")",
",",
"Integer",
".",
"valueOf",
"(",
"g",
",",
"16",
")",
",",
"Integer",
".",
"valueOf",
"(",
"b",
",",
"16",
")",
")",
";",
"}",
"catch",
"(",
"final",
"NumberFormatException",
"ignored",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Converts Hex string to RGB. Assumes
@param hex String of length 7, e.g. "#1234EF"
@return {@link Color} | [
"Converts",
"Hex",
"string",
"to",
"RGB",
".",
"Assumes"
] | train | https://github.com/ahome-it/lienzo-core/blob/8e03723700dec366f77064d12fb8676d8cd6be99/src/main/java/com/ait/lienzo/shared/core/types/Color.java#L521-L561 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/backend/MBeanServerHandler.java | MBeanServerHandler.registerMBean | public final ObjectName registerMBean(Object pMBean,String ... pOptionalName)
throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException {
"""
Register a MBean under a certain name to the platform MBeanServer
@param pMBean MBean to register
@param pOptionalName optional name under which the bean should be registered. If not provided,
it depends on whether the MBean to register implements {@link javax.management.MBeanRegistration} or
not.
@return the name under which the MBean is registered.
"""
synchronized (mBeanHandles) {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
try {
String name = pOptionalName != null && pOptionalName.length > 0 ? pOptionalName[0] : null;
ObjectName registeredName = serverHandle.registerMBeanAtServer(server, pMBean, name);
mBeanHandles.add(new MBeanHandle(server,registeredName));
return registeredName;
} catch (RuntimeException exp) {
throw new IllegalStateException("Could not register " + pMBean + ": " + exp, exp);
} catch (MBeanRegistrationException exp) {
throw new IllegalStateException("Could not register " + pMBean + ": " + exp, exp);
}
}
} | java | public final ObjectName registerMBean(Object pMBean,String ... pOptionalName)
throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException {
synchronized (mBeanHandles) {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
try {
String name = pOptionalName != null && pOptionalName.length > 0 ? pOptionalName[0] : null;
ObjectName registeredName = serverHandle.registerMBeanAtServer(server, pMBean, name);
mBeanHandles.add(new MBeanHandle(server,registeredName));
return registeredName;
} catch (RuntimeException exp) {
throw new IllegalStateException("Could not register " + pMBean + ": " + exp, exp);
} catch (MBeanRegistrationException exp) {
throw new IllegalStateException("Could not register " + pMBean + ": " + exp, exp);
}
}
} | [
"public",
"final",
"ObjectName",
"registerMBean",
"(",
"Object",
"pMBean",
",",
"String",
"...",
"pOptionalName",
")",
"throws",
"MalformedObjectNameException",
",",
"NotCompliantMBeanException",
",",
"InstanceAlreadyExistsException",
"{",
"synchronized",
"(",
"mBeanHandles",
")",
"{",
"MBeanServer",
"server",
"=",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
";",
"try",
"{",
"String",
"name",
"=",
"pOptionalName",
"!=",
"null",
"&&",
"pOptionalName",
".",
"length",
">",
"0",
"?",
"pOptionalName",
"[",
"0",
"]",
":",
"null",
";",
"ObjectName",
"registeredName",
"=",
"serverHandle",
".",
"registerMBeanAtServer",
"(",
"server",
",",
"pMBean",
",",
"name",
")",
";",
"mBeanHandles",
".",
"add",
"(",
"new",
"MBeanHandle",
"(",
"server",
",",
"registeredName",
")",
")",
";",
"return",
"registeredName",
";",
"}",
"catch",
"(",
"RuntimeException",
"exp",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Could not register \"",
"+",
"pMBean",
"+",
"\": \"",
"+",
"exp",
",",
"exp",
")",
";",
"}",
"catch",
"(",
"MBeanRegistrationException",
"exp",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Could not register \"",
"+",
"pMBean",
"+",
"\": \"",
"+",
"exp",
",",
"exp",
")",
";",
"}",
"}",
"}"
] | Register a MBean under a certain name to the platform MBeanServer
@param pMBean MBean to register
@param pOptionalName optional name under which the bean should be registered. If not provided,
it depends on whether the MBean to register implements {@link javax.management.MBeanRegistration} or
not.
@return the name under which the MBean is registered. | [
"Register",
"a",
"MBean",
"under",
"a",
"certain",
"name",
"to",
"the",
"platform",
"MBeanServer"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/backend/MBeanServerHandler.java#L175-L190 |
to2mbn/JMCCC | jmccc/src/main/java/org/to2mbn/jmccc/version/parsing/Versions.java | Versions.resolveAssets | public static Set<Asset> resolveAssets(MinecraftDirectory minecraftDir, Version version) throws IOException {
"""
Resolves the asset index.
@param minecraftDir the minecraft directory
@param version the owner version of the asset index
@return the asset index, or null if the asset index does not exist
@throws IOException if an I/O error occurs during resolving asset index
@throws NullPointerException if
<code>minecraftDir==null || version==null</code>
"""
return resolveAssets(minecraftDir, version.getAssets());
} | java | public static Set<Asset> resolveAssets(MinecraftDirectory minecraftDir, Version version) throws IOException {
return resolveAssets(minecraftDir, version.getAssets());
} | [
"public",
"static",
"Set",
"<",
"Asset",
">",
"resolveAssets",
"(",
"MinecraftDirectory",
"minecraftDir",
",",
"Version",
"version",
")",
"throws",
"IOException",
"{",
"return",
"resolveAssets",
"(",
"minecraftDir",
",",
"version",
".",
"getAssets",
"(",
")",
")",
";",
"}"
] | Resolves the asset index.
@param minecraftDir the minecraft directory
@param version the owner version of the asset index
@return the asset index, or null if the asset index does not exist
@throws IOException if an I/O error occurs during resolving asset index
@throws NullPointerException if
<code>minecraftDir==null || version==null</code> | [
"Resolves",
"the",
"asset",
"index",
"."
] | train | https://github.com/to2mbn/JMCCC/blob/17e5b1b56ff18255cfd60976dca1a24598946647/jmccc/src/main/java/org/to2mbn/jmccc/version/parsing/Versions.java#L86-L88 |
pippo-java/pippo | pippo-core/src/main/java/ro/pippo/core/PippoSettings.java | PippoSettings.getDurationInMilliseconds | public long getDurationInMilliseconds(String name, long defaultValue) {
"""
Gets the duration setting and converts it to milliseconds.
<p/>
The setting must be use one of the following conventions:
<ul>
<li>n MILLISECONDS
<li>n SECONDS
<li>n MINUTES
<li>n HOURS
<li>n DAYS
</ul>
@param name
@param defaultValue in milliseconds
@return milliseconds
"""
TimeUnit timeUnit = extractTimeUnit(name, defaultValue + " MILLISECONDS");
long duration = getLong(name, defaultValue);
return timeUnit.toMillis(duration);
} | java | public long getDurationInMilliseconds(String name, long defaultValue) {
TimeUnit timeUnit = extractTimeUnit(name, defaultValue + " MILLISECONDS");
long duration = getLong(name, defaultValue);
return timeUnit.toMillis(duration);
} | [
"public",
"long",
"getDurationInMilliseconds",
"(",
"String",
"name",
",",
"long",
"defaultValue",
")",
"{",
"TimeUnit",
"timeUnit",
"=",
"extractTimeUnit",
"(",
"name",
",",
"defaultValue",
"+",
"\" MILLISECONDS\"",
")",
";",
"long",
"duration",
"=",
"getLong",
"(",
"name",
",",
"defaultValue",
")",
";",
"return",
"timeUnit",
".",
"toMillis",
"(",
"duration",
")",
";",
"}"
] | Gets the duration setting and converts it to milliseconds.
<p/>
The setting must be use one of the following conventions:
<ul>
<li>n MILLISECONDS
<li>n SECONDS
<li>n MINUTES
<li>n HOURS
<li>n DAYS
</ul>
@param name
@param defaultValue in milliseconds
@return milliseconds | [
"Gets",
"the",
"duration",
"setting",
"and",
"converts",
"it",
"to",
"milliseconds",
".",
"<p",
"/",
">",
"The",
"setting",
"must",
"be",
"use",
"one",
"of",
"the",
"following",
"conventions",
":",
"<ul",
">",
"<li",
">",
"n",
"MILLISECONDS",
"<li",
">",
"n",
"SECONDS",
"<li",
">",
"n",
"MINUTES",
"<li",
">",
"n",
"HOURS",
"<li",
">",
"n",
"DAYS",
"<",
"/",
"ul",
">"
] | train | https://github.com/pippo-java/pippo/blob/cb5ccb453bffcc3cf386adc660674812d10b9726/pippo-core/src/main/java/ro/pippo/core/PippoSettings.java#L803-L808 |
agmip/agmip-common-functions | src/main/java/org/agmip/functions/PTSaxton2006.java | PTSaxton2006.getSLSAT | public static String getSLSAT(String[] soilParas) {
"""
For calculating SLSAT
@param soilParas should include 1. Sand weight percentage by layer
([0,100]%), 2. Clay weight percentage by layer ([0,100]%), 3. Organic
matter weight percentage by layer ([0,100]%), (= SLOC * 1.72)
@return Soil water, saturated, fraction
"""
if (soilParas != null && soilParas.length >= 3) {
return divide(calcSaturatedMoisture(soilParas[0], soilParas[1], soilParas[2]), "100", 3);
} else {
return null;
}
} | java | public static String getSLSAT(String[] soilParas) {
if (soilParas != null && soilParas.length >= 3) {
return divide(calcSaturatedMoisture(soilParas[0], soilParas[1], soilParas[2]), "100", 3);
} else {
return null;
}
} | [
"public",
"static",
"String",
"getSLSAT",
"(",
"String",
"[",
"]",
"soilParas",
")",
"{",
"if",
"(",
"soilParas",
"!=",
"null",
"&&",
"soilParas",
".",
"length",
">=",
"3",
")",
"{",
"return",
"divide",
"(",
"calcSaturatedMoisture",
"(",
"soilParas",
"[",
"0",
"]",
",",
"soilParas",
"[",
"1",
"]",
",",
"soilParas",
"[",
"2",
"]",
")",
",",
"\"100\"",
",",
"3",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | For calculating SLSAT
@param soilParas should include 1. Sand weight percentage by layer
([0,100]%), 2. Clay weight percentage by layer ([0,100]%), 3. Organic
matter weight percentage by layer ([0,100]%), (= SLOC * 1.72)
@return Soil water, saturated, fraction | [
"For",
"calculating",
"SLSAT"
] | train | https://github.com/agmip/agmip-common-functions/blob/4efa3042178841b026ca6fba9c96da02fbfb9a8e/src/main/java/org/agmip/functions/PTSaxton2006.java#L63-L69 |
openwms/org.openwms | org.openwms.core.util/src/main/java/org/openwms/core/SecurityUtils.java | SecurityUtils.createHeaders | public static HttpHeaders createHeaders(String username, String password) {
"""
With the given {@code username} and {@code password} create a Base64 encoded valid
http BASIC schema authorization header, and return it within a {@link HttpHeaders}
object.
@param username The BASIC auth username
@param password The BASIC auth password
@return The HttpHeaders object containing the Authorization Header
"""
if (username == null || username.isEmpty()) {
return new HttpHeaders();
}
String auth = username + ":" + password;
byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8));
String authHeader = "Basic " + new String(encodedAuth);
HttpHeaders result = new HttpHeaders();
result.add(HttpHeaders.AUTHORIZATION, authHeader);
return result;
} | java | public static HttpHeaders createHeaders(String username, String password) {
if (username == null || username.isEmpty()) {
return new HttpHeaders();
}
String auth = username + ":" + password;
byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8));
String authHeader = "Basic " + new String(encodedAuth);
HttpHeaders result = new HttpHeaders();
result.add(HttpHeaders.AUTHORIZATION, authHeader);
return result;
} | [
"public",
"static",
"HttpHeaders",
"createHeaders",
"(",
"String",
"username",
",",
"String",
"password",
")",
"{",
"if",
"(",
"username",
"==",
"null",
"||",
"username",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"new",
"HttpHeaders",
"(",
")",
";",
"}",
"String",
"auth",
"=",
"username",
"+",
"\":\"",
"+",
"password",
";",
"byte",
"[",
"]",
"encodedAuth",
"=",
"Base64",
".",
"getEncoder",
"(",
")",
".",
"encode",
"(",
"auth",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"String",
"authHeader",
"=",
"\"Basic \"",
"+",
"new",
"String",
"(",
"encodedAuth",
")",
";",
"HttpHeaders",
"result",
"=",
"new",
"HttpHeaders",
"(",
")",
";",
"result",
".",
"add",
"(",
"HttpHeaders",
".",
"AUTHORIZATION",
",",
"authHeader",
")",
";",
"return",
"result",
";",
"}"
] | With the given {@code username} and {@code password} create a Base64 encoded valid
http BASIC schema authorization header, and return it within a {@link HttpHeaders}
object.
@param username The BASIC auth username
@param password The BASIC auth password
@return The HttpHeaders object containing the Authorization Header | [
"With",
"the",
"given",
"{",
"@code",
"username",
"}",
"and",
"{",
"@code",
"password",
"}",
"create",
"a",
"Base64",
"encoded",
"valid",
"http",
"BASIC",
"schema",
"authorization",
"header",
"and",
"return",
"it",
"within",
"a",
"{",
"@link",
"HttpHeaders",
"}",
"object",
"."
] | train | https://github.com/openwms/org.openwms/blob/b24a95c5d09a7ec3c723d7e107d1cb0039d06a7e/org.openwms.core.util/src/main/java/org/openwms/core/SecurityUtils.java#L41-L52 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/PathUtils.java | PathUtils.getChildUnder | public static String getChildUnder(String path, String parentPath) {
"""
Answer the first path element of a path which follows a leading sub-path.
For example, for path "/grandParent/parent/child/grandChild" and
leading sub-path "/grandParent/parent", answer "child".
The result is unpredictable if the leading path does not start the
target path, and does not reach a separator character in the target
path. An exception will be thrown if the leading path is longer
than the target path.
@param path The path from which to obtain a path element.
@param leadingPath A leading sub-path of the target path.
@return The first path element of the target path following the
leading sub-path.
"""
int start = parentPath.length();
String local = path.substring(start, path.length());
String name = getFirstPathComponent(local);
return name;
} | java | public static String getChildUnder(String path, String parentPath) {
int start = parentPath.length();
String local = path.substring(start, path.length());
String name = getFirstPathComponent(local);
return name;
} | [
"public",
"static",
"String",
"getChildUnder",
"(",
"String",
"path",
",",
"String",
"parentPath",
")",
"{",
"int",
"start",
"=",
"parentPath",
".",
"length",
"(",
")",
";",
"String",
"local",
"=",
"path",
".",
"substring",
"(",
"start",
",",
"path",
".",
"length",
"(",
")",
")",
";",
"String",
"name",
"=",
"getFirstPathComponent",
"(",
"local",
")",
";",
"return",
"name",
";",
"}"
] | Answer the first path element of a path which follows a leading sub-path.
For example, for path "/grandParent/parent/child/grandChild" and
leading sub-path "/grandParent/parent", answer "child".
The result is unpredictable if the leading path does not start the
target path, and does not reach a separator character in the target
path. An exception will be thrown if the leading path is longer
than the target path.
@param path The path from which to obtain a path element.
@param leadingPath A leading sub-path of the target path.
@return The first path element of the target path following the
leading sub-path. | [
"Answer",
"the",
"first",
"path",
"element",
"of",
"a",
"path",
"which",
"follows",
"a",
"leading",
"sub",
"-",
"path",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/PathUtils.java#L861-L866 |
pmwmedia/tinylog | tinylog-impl/src/main/java/org/tinylog/pattern/FormatPatternParser.java | FormatPatternParser.styleToken | private static Token styleToken(final Token token, final String[] options) {
"""
Creates style decorators for a token.
@param token
Token to style
@param options
Style options
@return Styled token
"""
Token styledToken = token;
for (String option : options) {
int splitIndex = option.indexOf('=');
if (splitIndex == -1) {
InternalLogger.log(Level.ERROR, "No value set for '" + option.trim() + "'");
} else {
String key = option.substring(0, splitIndex).trim();
String value = option.substring(splitIndex + 1).trim();
int number;
try {
number = parsePositiveInteger(value);
} catch (NumberFormatException ex) {
InternalLogger.log(Level.ERROR, "'" + value + "' is an invalid value for '" + key + "'");
continue;
}
if ("min-size".equals(key)) {
styledToken = new MinimumSizeToken(styledToken, number);
} else if ("indent".equals(key)) {
styledToken = new IndentationToken(styledToken, number);
} else {
InternalLogger.log(Level.ERROR, "Unknown style option: '" + key + "'");
}
}
}
return styledToken;
} | java | private static Token styleToken(final Token token, final String[] options) {
Token styledToken = token;
for (String option : options) {
int splitIndex = option.indexOf('=');
if (splitIndex == -1) {
InternalLogger.log(Level.ERROR, "No value set for '" + option.trim() + "'");
} else {
String key = option.substring(0, splitIndex).trim();
String value = option.substring(splitIndex + 1).trim();
int number;
try {
number = parsePositiveInteger(value);
} catch (NumberFormatException ex) {
InternalLogger.log(Level.ERROR, "'" + value + "' is an invalid value for '" + key + "'");
continue;
}
if ("min-size".equals(key)) {
styledToken = new MinimumSizeToken(styledToken, number);
} else if ("indent".equals(key)) {
styledToken = new IndentationToken(styledToken, number);
} else {
InternalLogger.log(Level.ERROR, "Unknown style option: '" + key + "'");
}
}
}
return styledToken;
} | [
"private",
"static",
"Token",
"styleToken",
"(",
"final",
"Token",
"token",
",",
"final",
"String",
"[",
"]",
"options",
")",
"{",
"Token",
"styledToken",
"=",
"token",
";",
"for",
"(",
"String",
"option",
":",
"options",
")",
"{",
"int",
"splitIndex",
"=",
"option",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"splitIndex",
"==",
"-",
"1",
")",
"{",
"InternalLogger",
".",
"log",
"(",
"Level",
".",
"ERROR",
",",
"\"No value set for '\"",
"+",
"option",
".",
"trim",
"(",
")",
"+",
"\"'\"",
")",
";",
"}",
"else",
"{",
"String",
"key",
"=",
"option",
".",
"substring",
"(",
"0",
",",
"splitIndex",
")",
".",
"trim",
"(",
")",
";",
"String",
"value",
"=",
"option",
".",
"substring",
"(",
"splitIndex",
"+",
"1",
")",
".",
"trim",
"(",
")",
";",
"int",
"number",
";",
"try",
"{",
"number",
"=",
"parsePositiveInteger",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"ex",
")",
"{",
"InternalLogger",
".",
"log",
"(",
"Level",
".",
"ERROR",
",",
"\"'\"",
"+",
"value",
"+",
"\"' is an invalid value for '\"",
"+",
"key",
"+",
"\"'\"",
")",
";",
"continue",
";",
"}",
"if",
"(",
"\"min-size\"",
".",
"equals",
"(",
"key",
")",
")",
"{",
"styledToken",
"=",
"new",
"MinimumSizeToken",
"(",
"styledToken",
",",
"number",
")",
";",
"}",
"else",
"if",
"(",
"\"indent\"",
".",
"equals",
"(",
"key",
")",
")",
"{",
"styledToken",
"=",
"new",
"IndentationToken",
"(",
"styledToken",
",",
"number",
")",
";",
"}",
"else",
"{",
"InternalLogger",
".",
"log",
"(",
"Level",
".",
"ERROR",
",",
"\"Unknown style option: '\"",
"+",
"key",
"+",
"\"'\"",
")",
";",
"}",
"}",
"}",
"return",
"styledToken",
";",
"}"
] | Creates style decorators for a token.
@param token
Token to style
@param options
Style options
@return Styled token | [
"Creates",
"style",
"decorators",
"for",
"a",
"token",
"."
] | train | https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/pattern/FormatPatternParser.java#L217-L247 |
spacecowboy/NoNonsense-FilePicker | sample/src/main/java/com/nononsenseapps/filepicker/sample/dropbox/DropboxFilePickerFragment.java | DropboxFilePickerFragment.onLoadFinished | @Override
public void onLoadFinished(Loader<SortedList<Metadata>> loader, SortedList<Metadata> data) {
"""
Once loading has finished, show the list and hide the progress bar.
"""
progressBar.setVisibility(View.INVISIBLE);
recyclerView.setVisibility(View.VISIBLE);
super.onLoadFinished(loader, data);
} | java | @Override
public void onLoadFinished(Loader<SortedList<Metadata>> loader, SortedList<Metadata> data) {
progressBar.setVisibility(View.INVISIBLE);
recyclerView.setVisibility(View.VISIBLE);
super.onLoadFinished(loader, data);
} | [
"@",
"Override",
"public",
"void",
"onLoadFinished",
"(",
"Loader",
"<",
"SortedList",
"<",
"Metadata",
">",
">",
"loader",
",",
"SortedList",
"<",
"Metadata",
">",
"data",
")",
"{",
"progressBar",
".",
"setVisibility",
"(",
"View",
".",
"INVISIBLE",
")",
";",
"recyclerView",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"super",
".",
"onLoadFinished",
"(",
"loader",
",",
"data",
")",
";",
"}"
] | Once loading has finished, show the list and hide the progress bar. | [
"Once",
"loading",
"has",
"finished",
"show",
"the",
"list",
"and",
"hide",
"the",
"progress",
"bar",
"."
] | train | https://github.com/spacecowboy/NoNonsense-FilePicker/blob/396ef7fa5e87791170791f9d94c78f6e42a7679a/sample/src/main/java/com/nononsenseapps/filepicker/sample/dropbox/DropboxFilePickerFragment.java#L80-L85 |
citrusframework/citrus | modules/citrus-core/src/main/java/com/consol/citrus/message/MessageHeaderUtils.java | MessageHeaderUtils.checkHeaderTypes | public static void checkHeaderTypes(Map<String, Object> headers) {
"""
Method checks all header types to meet Spring Integration type requirements. For instance
sequence number must be of type {@link Integer}.
@param headers the headers to check.
"""
if (headers.containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER)) {
String number = headers.get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER).toString();
headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, Integer.valueOf(number));
}
if (headers.containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE)) {
String size = headers.get(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE).toString();
headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE, Integer.valueOf(size));
}
if (headers.containsKey(IntegrationMessageHeaderAccessor.PRIORITY)) {
String size = headers.get(IntegrationMessageHeaderAccessor.PRIORITY).toString();
headers.put(IntegrationMessageHeaderAccessor.PRIORITY, Integer.valueOf(size));
}
} | java | public static void checkHeaderTypes(Map<String, Object> headers) {
if (headers.containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER)) {
String number = headers.get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER).toString();
headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, Integer.valueOf(number));
}
if (headers.containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE)) {
String size = headers.get(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE).toString();
headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE, Integer.valueOf(size));
}
if (headers.containsKey(IntegrationMessageHeaderAccessor.PRIORITY)) {
String size = headers.get(IntegrationMessageHeaderAccessor.PRIORITY).toString();
headers.put(IntegrationMessageHeaderAccessor.PRIORITY, Integer.valueOf(size));
}
} | [
"public",
"static",
"void",
"checkHeaderTypes",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"headers",
")",
"{",
"if",
"(",
"headers",
".",
"containsKey",
"(",
"IntegrationMessageHeaderAccessor",
".",
"SEQUENCE_NUMBER",
")",
")",
"{",
"String",
"number",
"=",
"headers",
".",
"get",
"(",
"IntegrationMessageHeaderAccessor",
".",
"SEQUENCE_NUMBER",
")",
".",
"toString",
"(",
")",
";",
"headers",
".",
"put",
"(",
"IntegrationMessageHeaderAccessor",
".",
"SEQUENCE_NUMBER",
",",
"Integer",
".",
"valueOf",
"(",
"number",
")",
")",
";",
"}",
"if",
"(",
"headers",
".",
"containsKey",
"(",
"IntegrationMessageHeaderAccessor",
".",
"SEQUENCE_SIZE",
")",
")",
"{",
"String",
"size",
"=",
"headers",
".",
"get",
"(",
"IntegrationMessageHeaderAccessor",
".",
"SEQUENCE_SIZE",
")",
".",
"toString",
"(",
")",
";",
"headers",
".",
"put",
"(",
"IntegrationMessageHeaderAccessor",
".",
"SEQUENCE_SIZE",
",",
"Integer",
".",
"valueOf",
"(",
"size",
")",
")",
";",
"}",
"if",
"(",
"headers",
".",
"containsKey",
"(",
"IntegrationMessageHeaderAccessor",
".",
"PRIORITY",
")",
")",
"{",
"String",
"size",
"=",
"headers",
".",
"get",
"(",
"IntegrationMessageHeaderAccessor",
".",
"PRIORITY",
")",
".",
"toString",
"(",
")",
";",
"headers",
".",
"put",
"(",
"IntegrationMessageHeaderAccessor",
".",
"PRIORITY",
",",
"Integer",
".",
"valueOf",
"(",
"size",
")",
")",
";",
"}",
"}"
] | Method checks all header types to meet Spring Integration type requirements. For instance
sequence number must be of type {@link Integer}.
@param headers the headers to check. | [
"Method",
"checks",
"all",
"header",
"types",
"to",
"meet",
"Spring",
"Integration",
"type",
"requirements",
".",
"For",
"instance",
"sequence",
"number",
"must",
"be",
"of",
"type",
"{",
"@link",
"Integer",
"}",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-core/src/main/java/com/consol/citrus/message/MessageHeaderUtils.java#L107-L122 |
JoeKerouac/utils | src/main/java/com/joe/utils/validator/ValidatorUtil.java | ValidatorUtil.validateParameters | public static void validateParameters(Object instance, Method method, Object[] params) {
"""
验证方法参数是否符合规则
@param instance 方法所在的类的实例
@param method 方法实例
@param params 参数
"""
Assert.notNull(instance, "instance不能为null");
Assert.notNull(method, "method不能为null");
Set<ConstraintViolation<Object>> constraintViolations = executableValidator
.validateParameters(instance, method, params);
check(constraintViolations);
} | java | public static void validateParameters(Object instance, Method method, Object[] params) {
Assert.notNull(instance, "instance不能为null");
Assert.notNull(method, "method不能为null");
Set<ConstraintViolation<Object>> constraintViolations = executableValidator
.validateParameters(instance, method, params);
check(constraintViolations);
} | [
"public",
"static",
"void",
"validateParameters",
"(",
"Object",
"instance",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"params",
")",
"{",
"Assert",
".",
"notNull",
"(",
"instance",
",",
"\"instance不能为null\");",
"",
"",
"Assert",
".",
"notNull",
"(",
"method",
",",
"\"method不能为null\");",
"",
"",
"Set",
"<",
"ConstraintViolation",
"<",
"Object",
">",
">",
"constraintViolations",
"=",
"executableValidator",
".",
"validateParameters",
"(",
"instance",
",",
"method",
",",
"params",
")",
";",
"check",
"(",
"constraintViolations",
")",
";",
"}"
] | 验证方法参数是否符合规则
@param instance 方法所在的类的实例
@param method 方法实例
@param params 参数 | [
"验证方法参数是否符合规则"
] | train | https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/validator/ValidatorUtil.java#L56-L62 |
versionone/VersionOne.SDK.Java.ObjectModel | src/main/java/com/versionone/om/Project.java | Project.createRegressionPlan | public RegressionPlan createRegressionPlan(String name, Map<String, Object> attributes) {
"""
Creates a new Regression Plan in the Project with additional attributes.
@param name Regression Plan title.
@param attributes Additional attributes for initialization Regression Plan
@return A new Regression Plan
"""
return getInstance().create().regressionPlan(name, this, attributes);
} | java | public RegressionPlan createRegressionPlan(String name, Map<String, Object> attributes) {
return getInstance().create().regressionPlan(name, this, attributes);
} | [
"public",
"RegressionPlan",
"createRegressionPlan",
"(",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
")",
"{",
"return",
"getInstance",
"(",
")",
".",
"create",
"(",
")",
".",
"regressionPlan",
"(",
"name",
",",
"this",
",",
"attributes",
")",
";",
"}"
] | Creates a new Regression Plan in the Project with additional attributes.
@param name Regression Plan title.
@param attributes Additional attributes for initialization Regression Plan
@return A new Regression Plan | [
"Creates",
"a",
"new",
"Regression",
"Plan",
"in",
"the",
"Project",
"with",
"additional",
"attributes",
"."
] | train | https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/Project.java#L403-L405 |
cdk/cdk | tool/forcefield/src/main/java/org/openscience/cdk/modeling/builder3d/MMFF94ParametersCall.java | MMFF94ParametersCall.getDefaultStretchBendData | public List getDefaultStretchBendData(int iR, int jR, int kR) throws Exception {
"""
Gets the bond-angle interaction parameter set.
@param iR ID from Atom 1.
@param jR ID from Atom 2.
@param kR ID from Atom 3.
@return The bond-angle interaction data from the force field parameter set
@exception Exception Description of the Exception
"""
String dfsbkey = "";
if (pSet.containsKey(("DFSB" + iR + ";" + jR + ";" + kR))) {
dfsbkey = "DFSB" + iR + ";" + jR + ";" + kR;
} /*
* else { System.out.println(
* "KEYErrorDefaultStretchBend:Unknown default stretch-bend key in pSet: "
* + iR + " ; " + jR + " ; " + kR); }
*/
//logger.debug("dfsbkey : " + dfsbkey);
return (List) pSet.get(dfsbkey);
} | java | public List getDefaultStretchBendData(int iR, int jR, int kR) throws Exception {
String dfsbkey = "";
if (pSet.containsKey(("DFSB" + iR + ";" + jR + ";" + kR))) {
dfsbkey = "DFSB" + iR + ";" + jR + ";" + kR;
} /*
* else { System.out.println(
* "KEYErrorDefaultStretchBend:Unknown default stretch-bend key in pSet: "
* + iR + " ; " + jR + " ; " + kR); }
*/
//logger.debug("dfsbkey : " + dfsbkey);
return (List) pSet.get(dfsbkey);
} | [
"public",
"List",
"getDefaultStretchBendData",
"(",
"int",
"iR",
",",
"int",
"jR",
",",
"int",
"kR",
")",
"throws",
"Exception",
"{",
"String",
"dfsbkey",
"=",
"\"\"",
";",
"if",
"(",
"pSet",
".",
"containsKey",
"(",
"(",
"\"DFSB\"",
"+",
"iR",
"+",
"\";\"",
"+",
"jR",
"+",
"\";\"",
"+",
"kR",
")",
")",
")",
"{",
"dfsbkey",
"=",
"\"DFSB\"",
"+",
"iR",
"+",
"\";\"",
"+",
"jR",
"+",
"\";\"",
"+",
"kR",
";",
"}",
"/*\n * else { System.out.println(\n * \"KEYErrorDefaultStretchBend:Unknown default stretch-bend key in pSet: \"\n * + iR + \" ; \" + jR + \" ; \" + kR); }\n */",
"//logger.debug(\"dfsbkey : \" + dfsbkey);",
"return",
"(",
"List",
")",
"pSet",
".",
"get",
"(",
"dfsbkey",
")",
";",
"}"
] | Gets the bond-angle interaction parameter set.
@param iR ID from Atom 1.
@param jR ID from Atom 2.
@param kR ID from Atom 3.
@return The bond-angle interaction data from the force field parameter set
@exception Exception Description of the Exception | [
"Gets",
"the",
"bond",
"-",
"angle",
"interaction",
"parameter",
"set",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/forcefield/src/main/java/org/openscience/cdk/modeling/builder3d/MMFF94ParametersCall.java#L124-L135 |
stevespringett/Alpine | alpine/src/main/java/alpine/resources/Pagination.java | Pagination.calculateStrategy | private void calculateStrategy(final Strategy strategy, final int o1, final int o2) {
"""
Determines the offset and limit based on pagination strategy.
@param strategy the pagination strategy to use
@param o1 the offset or page number to use
@param o2 the number of results to limit a result-set to (aka, the size of the page)
"""
if (Strategy.OFFSET == strategy) {
this.offset = o1;
this.limit = o2;
} else if (Strategy.PAGES == strategy) {
this.offset = (o1 * o2) - o2;
this.limit = o2;
}
} | java | private void calculateStrategy(final Strategy strategy, final int o1, final int o2) {
if (Strategy.OFFSET == strategy) {
this.offset = o1;
this.limit = o2;
} else if (Strategy.PAGES == strategy) {
this.offset = (o1 * o2) - o2;
this.limit = o2;
}
} | [
"private",
"void",
"calculateStrategy",
"(",
"final",
"Strategy",
"strategy",
",",
"final",
"int",
"o1",
",",
"final",
"int",
"o2",
")",
"{",
"if",
"(",
"Strategy",
".",
"OFFSET",
"==",
"strategy",
")",
"{",
"this",
".",
"offset",
"=",
"o1",
";",
"this",
".",
"limit",
"=",
"o2",
";",
"}",
"else",
"if",
"(",
"Strategy",
".",
"PAGES",
"==",
"strategy",
")",
"{",
"this",
".",
"offset",
"=",
"(",
"o1",
"*",
"o2",
")",
"-",
"o2",
";",
"this",
".",
"limit",
"=",
"o2",
";",
"}",
"}"
] | Determines the offset and limit based on pagination strategy.
@param strategy the pagination strategy to use
@param o1 the offset or page number to use
@param o2 the number of results to limit a result-set to (aka, the size of the page) | [
"Determines",
"the",
"offset",
"and",
"limit",
"based",
"on",
"pagination",
"strategy",
"."
] | train | https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/resources/Pagination.java#L72-L80 |
getsentry/sentry-java | sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java | SentryAppender.extractExceptionQueue | protected Deque<SentryException> extractExceptionQueue(ILoggingEvent iLoggingEvent) {
"""
Creates a sequence of {@link SentryException}s given a particular {@link ILoggingEvent}.
@param iLoggingEvent Information detailing a particular logging event
@return A {@link Deque} of {@link SentryException}s detailing the exception chain
"""
IThrowableProxy throwableProxy = iLoggingEvent.getThrowableProxy();
Deque<SentryException> exceptions = new ArrayDeque<>();
Set<IThrowableProxy> circularityDetector = new HashSet<>();
StackTraceElement[] enclosingStackTrace = new StackTraceElement[0];
//Stack the exceptions to send them in the reverse order
while (throwableProxy != null) {
if (!circularityDetector.add(throwableProxy)) {
addWarn("Exiting a circular exception!");
break;
}
StackTraceElement[] stackTraceElements = toStackTraceElements(throwableProxy);
StackTraceInterface stackTrace = new StackTraceInterface(stackTraceElements, enclosingStackTrace);
exceptions.push(createSentryExceptionFrom(throwableProxy, stackTrace));
enclosingStackTrace = stackTraceElements;
throwableProxy = throwableProxy.getCause();
}
return exceptions;
} | java | protected Deque<SentryException> extractExceptionQueue(ILoggingEvent iLoggingEvent) {
IThrowableProxy throwableProxy = iLoggingEvent.getThrowableProxy();
Deque<SentryException> exceptions = new ArrayDeque<>();
Set<IThrowableProxy> circularityDetector = new HashSet<>();
StackTraceElement[] enclosingStackTrace = new StackTraceElement[0];
//Stack the exceptions to send them in the reverse order
while (throwableProxy != null) {
if (!circularityDetector.add(throwableProxy)) {
addWarn("Exiting a circular exception!");
break;
}
StackTraceElement[] stackTraceElements = toStackTraceElements(throwableProxy);
StackTraceInterface stackTrace = new StackTraceInterface(stackTraceElements, enclosingStackTrace);
exceptions.push(createSentryExceptionFrom(throwableProxy, stackTrace));
enclosingStackTrace = stackTraceElements;
throwableProxy = throwableProxy.getCause();
}
return exceptions;
} | [
"protected",
"Deque",
"<",
"SentryException",
">",
"extractExceptionQueue",
"(",
"ILoggingEvent",
"iLoggingEvent",
")",
"{",
"IThrowableProxy",
"throwableProxy",
"=",
"iLoggingEvent",
".",
"getThrowableProxy",
"(",
")",
";",
"Deque",
"<",
"SentryException",
">",
"exceptions",
"=",
"new",
"ArrayDeque",
"<>",
"(",
")",
";",
"Set",
"<",
"IThrowableProxy",
">",
"circularityDetector",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"StackTraceElement",
"[",
"]",
"enclosingStackTrace",
"=",
"new",
"StackTraceElement",
"[",
"0",
"]",
";",
"//Stack the exceptions to send them in the reverse order",
"while",
"(",
"throwableProxy",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"circularityDetector",
".",
"add",
"(",
"throwableProxy",
")",
")",
"{",
"addWarn",
"(",
"\"Exiting a circular exception!\"",
")",
";",
"break",
";",
"}",
"StackTraceElement",
"[",
"]",
"stackTraceElements",
"=",
"toStackTraceElements",
"(",
"throwableProxy",
")",
";",
"StackTraceInterface",
"stackTrace",
"=",
"new",
"StackTraceInterface",
"(",
"stackTraceElements",
",",
"enclosingStackTrace",
")",
";",
"exceptions",
".",
"push",
"(",
"createSentryExceptionFrom",
"(",
"throwableProxy",
",",
"stackTrace",
")",
")",
";",
"enclosingStackTrace",
"=",
"stackTraceElements",
";",
"throwableProxy",
"=",
"throwableProxy",
".",
"getCause",
"(",
")",
";",
"}",
"return",
"exceptions",
";",
"}"
] | Creates a sequence of {@link SentryException}s given a particular {@link ILoggingEvent}.
@param iLoggingEvent Information detailing a particular logging event
@return A {@link Deque} of {@link SentryException}s detailing the exception chain | [
"Creates",
"a",
"sequence",
"of",
"{",
"@link",
"SentryException",
"}",
"s",
"given",
"a",
"particular",
"{",
"@link",
"ILoggingEvent",
"}",
"."
] | train | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java#L172-L193 |
tvesalainen/lpg | src/main/java/org/vesalainen/grammar/Grammar.java | Grammar.addRule | public void addRule(String nonterminal, List<String> rhs) {
"""
Adds new rule if the same rule doesn't exist already.
@param nonterminal Left hand side of the rule.
@param rhs
"""
addRule(null, nonterminal, "", false, rhs);
} | java | public void addRule(String nonterminal, List<String> rhs)
{
addRule(null, nonterminal, "", false, rhs);
} | [
"public",
"void",
"addRule",
"(",
"String",
"nonterminal",
",",
"List",
"<",
"String",
">",
"rhs",
")",
"{",
"addRule",
"(",
"null",
",",
"nonterminal",
",",
"\"\"",
",",
"false",
",",
"rhs",
")",
";",
"}"
] | Adds new rule if the same rule doesn't exist already.
@param nonterminal Left hand side of the rule.
@param rhs | [
"Adds",
"new",
"rule",
"if",
"the",
"same",
"rule",
"doesn",
"t",
"exist",
"already",
"."
] | train | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/grammar/Grammar.java#L283-L286 |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java | LoggingSystem.get | public static LoggingSystem get(ClassLoader classLoader) {
"""
Detect and return the logging system in use. Supports Logback and Java Logging.
@param classLoader the classloader
@return the logging system
"""
String loggingSystem = System.getProperty(SYSTEM_PROPERTY);
if (StringUtils.hasLength(loggingSystem)) {
if (NONE.equals(loggingSystem)) {
return new NoOpLoggingSystem();
}
return get(classLoader, loggingSystem);
}
return SYSTEMS.entrySet().stream()
.filter((entry) -> ClassUtils.isPresent(entry.getKey(), classLoader))
.map((entry) -> get(classLoader, entry.getValue())).findFirst()
.orElseThrow(() -> new IllegalStateException(
"No suitable logging system located"));
} | java | public static LoggingSystem get(ClassLoader classLoader) {
String loggingSystem = System.getProperty(SYSTEM_PROPERTY);
if (StringUtils.hasLength(loggingSystem)) {
if (NONE.equals(loggingSystem)) {
return new NoOpLoggingSystem();
}
return get(classLoader, loggingSystem);
}
return SYSTEMS.entrySet().stream()
.filter((entry) -> ClassUtils.isPresent(entry.getKey(), classLoader))
.map((entry) -> get(classLoader, entry.getValue())).findFirst()
.orElseThrow(() -> new IllegalStateException(
"No suitable logging system located"));
} | [
"public",
"static",
"LoggingSystem",
"get",
"(",
"ClassLoader",
"classLoader",
")",
"{",
"String",
"loggingSystem",
"=",
"System",
".",
"getProperty",
"(",
"SYSTEM_PROPERTY",
")",
";",
"if",
"(",
"StringUtils",
".",
"hasLength",
"(",
"loggingSystem",
")",
")",
"{",
"if",
"(",
"NONE",
".",
"equals",
"(",
"loggingSystem",
")",
")",
"{",
"return",
"new",
"NoOpLoggingSystem",
"(",
")",
";",
"}",
"return",
"get",
"(",
"classLoader",
",",
"loggingSystem",
")",
";",
"}",
"return",
"SYSTEMS",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"(",
"entry",
")",
"-",
">",
"ClassUtils",
".",
"isPresent",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"classLoader",
")",
")",
".",
"map",
"(",
"(",
"entry",
")",
"-",
">",
"get",
"(",
"classLoader",
",",
"entry",
".",
"getValue",
"(",
")",
")",
")",
".",
"findFirst",
"(",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"IllegalStateException",
"(",
"\"No suitable logging system located\"",
")",
")",
";",
"}"
] | Detect and return the logging system in use. Supports Logback and Java Logging.
@param classLoader the classloader
@return the logging system | [
"Detect",
"and",
"return",
"the",
"logging",
"system",
"in",
"use",
".",
"Supports",
"Logback",
"and",
"Java",
"Logging",
"."
] | train | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java#L151-L164 |
couchbase/couchbase-jvm-core | src/main/java/com/couchbase/client/core/endpoint/query/QueryHandler.java | QueryHandler.parseQueryRows | private void parseQueryRows(boolean lastChunk) {
"""
Parses the query rows from the content stream as long as there is data to be found.
"""
while (true) {
int openBracketPos = findNextChar(responseContent, '{');
if (isEmptySection(openBracketPos) || (lastChunk && openBracketPos < 0)) {
sectionDone();
queryParsingState = transitionToNextToken(lastChunk);
queryRowClosingPositionProcessor = null;
queryRowClosingProcessorIndex = 0;
break;
}
if (queryRowClosingPositionProcessor == null) {
queryRowClosingPositionProcessor = new ClosingPositionBufProcessor('{', '}', true);
queryRowClosingProcessorIndex = responseContent.readerIndex();
}
int lengthToScan = responseContent.writerIndex() - this.queryRowClosingProcessorIndex;
int closeBracketPos = responseContent.forEachByte(queryRowClosingProcessorIndex,
lengthToScan, queryRowClosingPositionProcessor);
if (closeBracketPos == -1) {
queryRowClosingProcessorIndex = responseContent.writerIndex();
break;
}
queryRowClosingPositionProcessor = null;
queryRowClosingProcessorIndex = 0;
int length = closeBracketPos - openBracketPos - responseContent.readerIndex() + 1;
responseContent.skipBytes(openBracketPos);
ByteBuf resultSlice = responseContent.readSlice(length);
queryRowObservable.onNext(resultSlice.copy());
responseContent.discardSomeReadBytes();
}
} | java | private void parseQueryRows(boolean lastChunk) {
while (true) {
int openBracketPos = findNextChar(responseContent, '{');
if (isEmptySection(openBracketPos) || (lastChunk && openBracketPos < 0)) {
sectionDone();
queryParsingState = transitionToNextToken(lastChunk);
queryRowClosingPositionProcessor = null;
queryRowClosingProcessorIndex = 0;
break;
}
if (queryRowClosingPositionProcessor == null) {
queryRowClosingPositionProcessor = new ClosingPositionBufProcessor('{', '}', true);
queryRowClosingProcessorIndex = responseContent.readerIndex();
}
int lengthToScan = responseContent.writerIndex() - this.queryRowClosingProcessorIndex;
int closeBracketPos = responseContent.forEachByte(queryRowClosingProcessorIndex,
lengthToScan, queryRowClosingPositionProcessor);
if (closeBracketPos == -1) {
queryRowClosingProcessorIndex = responseContent.writerIndex();
break;
}
queryRowClosingPositionProcessor = null;
queryRowClosingProcessorIndex = 0;
int length = closeBracketPos - openBracketPos - responseContent.readerIndex() + 1;
responseContent.skipBytes(openBracketPos);
ByteBuf resultSlice = responseContent.readSlice(length);
queryRowObservable.onNext(resultSlice.copy());
responseContent.discardSomeReadBytes();
}
} | [
"private",
"void",
"parseQueryRows",
"(",
"boolean",
"lastChunk",
")",
"{",
"while",
"(",
"true",
")",
"{",
"int",
"openBracketPos",
"=",
"findNextChar",
"(",
"responseContent",
",",
"'",
"'",
")",
";",
"if",
"(",
"isEmptySection",
"(",
"openBracketPos",
")",
"||",
"(",
"lastChunk",
"&&",
"openBracketPos",
"<",
"0",
")",
")",
"{",
"sectionDone",
"(",
")",
";",
"queryParsingState",
"=",
"transitionToNextToken",
"(",
"lastChunk",
")",
";",
"queryRowClosingPositionProcessor",
"=",
"null",
";",
"queryRowClosingProcessorIndex",
"=",
"0",
";",
"break",
";",
"}",
"if",
"(",
"queryRowClosingPositionProcessor",
"==",
"null",
")",
"{",
"queryRowClosingPositionProcessor",
"=",
"new",
"ClosingPositionBufProcessor",
"(",
"'",
"'",
",",
"'",
"'",
",",
"true",
")",
";",
"queryRowClosingProcessorIndex",
"=",
"responseContent",
".",
"readerIndex",
"(",
")",
";",
"}",
"int",
"lengthToScan",
"=",
"responseContent",
".",
"writerIndex",
"(",
")",
"-",
"this",
".",
"queryRowClosingProcessorIndex",
";",
"int",
"closeBracketPos",
"=",
"responseContent",
".",
"forEachByte",
"(",
"queryRowClosingProcessorIndex",
",",
"lengthToScan",
",",
"queryRowClosingPositionProcessor",
")",
";",
"if",
"(",
"closeBracketPos",
"==",
"-",
"1",
")",
"{",
"queryRowClosingProcessorIndex",
"=",
"responseContent",
".",
"writerIndex",
"(",
")",
";",
"break",
";",
"}",
"queryRowClosingPositionProcessor",
"=",
"null",
";",
"queryRowClosingProcessorIndex",
"=",
"0",
";",
"int",
"length",
"=",
"closeBracketPos",
"-",
"openBracketPos",
"-",
"responseContent",
".",
"readerIndex",
"(",
")",
"+",
"1",
";",
"responseContent",
".",
"skipBytes",
"(",
"openBracketPos",
")",
";",
"ByteBuf",
"resultSlice",
"=",
"responseContent",
".",
"readSlice",
"(",
"length",
")",
";",
"queryRowObservable",
".",
"onNext",
"(",
"resultSlice",
".",
"copy",
"(",
")",
")",
";",
"responseContent",
".",
"discardSomeReadBytes",
"(",
")",
";",
"}",
"}"
] | Parses the query rows from the content stream as long as there is data to be found. | [
"Parses",
"the",
"query",
"rows",
"from",
"the",
"content",
"stream",
"as",
"long",
"as",
"there",
"is",
"data",
"to",
"be",
"found",
"."
] | train | https://github.com/couchbase/couchbase-jvm-core/blob/97f0427112c2168fee1d6499904f5fa0e24c6797/src/main/java/com/couchbase/client/core/endpoint/query/QueryHandler.java#L616-L649 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/WebSiteManagementClientImpl.java | WebSiteManagementClientImpl.listGeoRegionsAsync | public Observable<Page<GeoRegionInner>> listGeoRegionsAsync(final SkuName sku, final Boolean linuxWorkersEnabled) {
"""
Get a list of available geographical regions.
Get a list of available geographical regions.
@param sku Name of SKU used to filter the regions. Possible values include: 'Free', 'Shared', 'Basic', 'Standard', 'Premium', 'Dynamic', 'Isolated', 'PremiumV2'
@param linuxWorkersEnabled Specify <code>true</code> if you want to filter to only regions that support Linux workers.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<GeoRegionInner> object
"""
return listGeoRegionsWithServiceResponseAsync(sku, linuxWorkersEnabled)
.map(new Func1<ServiceResponse<Page<GeoRegionInner>>, Page<GeoRegionInner>>() {
@Override
public Page<GeoRegionInner> call(ServiceResponse<Page<GeoRegionInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<GeoRegionInner>> listGeoRegionsAsync(final SkuName sku, final Boolean linuxWorkersEnabled) {
return listGeoRegionsWithServiceResponseAsync(sku, linuxWorkersEnabled)
.map(new Func1<ServiceResponse<Page<GeoRegionInner>>, Page<GeoRegionInner>>() {
@Override
public Page<GeoRegionInner> call(ServiceResponse<Page<GeoRegionInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"GeoRegionInner",
">",
">",
"listGeoRegionsAsync",
"(",
"final",
"SkuName",
"sku",
",",
"final",
"Boolean",
"linuxWorkersEnabled",
")",
"{",
"return",
"listGeoRegionsWithServiceResponseAsync",
"(",
"sku",
",",
"linuxWorkersEnabled",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"GeoRegionInner",
">",
">",
",",
"Page",
"<",
"GeoRegionInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"GeoRegionInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"GeoRegionInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get a list of available geographical regions.
Get a list of available geographical regions.
@param sku Name of SKU used to filter the regions. Possible values include: 'Free', 'Shared', 'Basic', 'Standard', 'Premium', 'Dynamic', 'Isolated', 'PremiumV2'
@param linuxWorkersEnabled Specify <code>true</code> if you want to filter to only regions that support Linux workers.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<GeoRegionInner> object | [
"Get",
"a",
"list",
"of",
"available",
"geographical",
"regions",
".",
"Get",
"a",
"list",
"of",
"available",
"geographical",
"regions",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/WebSiteManagementClientImpl.java#L1570-L1578 |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/OjbMemberTagsHandler.java | OjbMemberTagsHandler.ifMemberTagValueEquals | public void ifMemberTagValueEquals(String template, Properties attributes) throws XDocletException {
"""
Evaluates the body if value for the member tag equals the specified value.
@param template The body of the block tag
@param attributes The attributes of the template tag
@exception XDocletException If an error occurs
@doc.tag type="block"
@doc.param name="tagName" optional="false" description="The tag name."
@doc.param name="paramName" description="The parameter name. If not specified, then the raw
content of the tag is returned."
@doc.param name="paramNum" description="The zero-based parameter number. It's used if the user
used the space-separated format for specifying parameters."
@doc.param name="value" optional="false" description="The expected value."
"""
if (getCurrentField() != null) {
if (isTagValueEqual(attributes, FOR_FIELD)) {
generate(template);
}
}
else if (getCurrentMethod() != null) {
if (isTagValueEqual(attributes, FOR_METHOD)) {
generate(template);
}
}
} | java | public void ifMemberTagValueEquals(String template, Properties attributes) throws XDocletException
{
if (getCurrentField() != null) {
if (isTagValueEqual(attributes, FOR_FIELD)) {
generate(template);
}
}
else if (getCurrentMethod() != null) {
if (isTagValueEqual(attributes, FOR_METHOD)) {
generate(template);
}
}
} | [
"public",
"void",
"ifMemberTagValueEquals",
"(",
"String",
"template",
",",
"Properties",
"attributes",
")",
"throws",
"XDocletException",
"{",
"if",
"(",
"getCurrentField",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"isTagValueEqual",
"(",
"attributes",
",",
"FOR_FIELD",
")",
")",
"{",
"generate",
"(",
"template",
")",
";",
"}",
"}",
"else",
"if",
"(",
"getCurrentMethod",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"isTagValueEqual",
"(",
"attributes",
",",
"FOR_METHOD",
")",
")",
"{",
"generate",
"(",
"template",
")",
";",
"}",
"}",
"}"
] | Evaluates the body if value for the member tag equals the specified value.
@param template The body of the block tag
@param attributes The attributes of the template tag
@exception XDocletException If an error occurs
@doc.tag type="block"
@doc.param name="tagName" optional="false" description="The tag name."
@doc.param name="paramName" description="The parameter name. If not specified, then the raw
content of the tag is returned."
@doc.param name="paramNum" description="The zero-based parameter number. It's used if the user
used the space-separated format for specifying parameters."
@doc.param name="value" optional="false" description="The expected value." | [
"Evaluates",
"the",
"body",
"if",
"value",
"for",
"the",
"member",
"tag",
"equals",
"the",
"specified",
"value",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/OjbMemberTagsHandler.java#L452-L464 |
gitblit/fathom | fathom-core/src/main/java/fathom/utils/ClassUtil.java | ClassUtil.getAnnotation | public static <T extends Annotation> T getAnnotation(Method method, Class<T> annotationClass) {
"""
Extract the annotation from the method or the declaring class.
@param method
@param annotationClass
@param <T>
@return the annotation or null
"""
T t = method.getAnnotation(annotationClass);
if (t == null) {
t = getAnnotation(method.getDeclaringClass(), annotationClass);
}
return t;
} | java | public static <T extends Annotation> T getAnnotation(Method method, Class<T> annotationClass) {
T t = method.getAnnotation(annotationClass);
if (t == null) {
t = getAnnotation(method.getDeclaringClass(), annotationClass);
}
return t;
} | [
"public",
"static",
"<",
"T",
"extends",
"Annotation",
">",
"T",
"getAnnotation",
"(",
"Method",
"method",
",",
"Class",
"<",
"T",
">",
"annotationClass",
")",
"{",
"T",
"t",
"=",
"method",
".",
"getAnnotation",
"(",
"annotationClass",
")",
";",
"if",
"(",
"t",
"==",
"null",
")",
"{",
"t",
"=",
"getAnnotation",
"(",
"method",
".",
"getDeclaringClass",
"(",
")",
",",
"annotationClass",
")",
";",
"}",
"return",
"t",
";",
"}"
] | Extract the annotation from the method or the declaring class.
@param method
@param annotationClass
@param <T>
@return the annotation or null | [
"Extract",
"the",
"annotation",
"from",
"the",
"method",
"or",
"the",
"declaring",
"class",
"."
] | train | https://github.com/gitblit/fathom/blob/f2f820eb16e9fea1e36ad4eda4ed51b35f056538/fathom-core/src/main/java/fathom/utils/ClassUtil.java#L180-L186 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/ReviewsImpl.java | ReviewsImpl.addVideoFrameWithServiceResponseAsync | public Observable<ServiceResponse<Void>> addVideoFrameWithServiceResponseAsync(String teamName, String reviewId, AddVideoFrameOptionalParameter addVideoFrameOptionalParameter) {
"""
The reviews created would show up for Reviewers on your team. As Reviewers complete reviewing, results of the Review would be POSTED (i.e. HTTP POST) on the specified CallBackEndpoint.
<h3>CallBack Schemas </h3>
<h4>Review Completion CallBack Sample</h4>
<p>
{<br/>
"ReviewId": "<Review Id>",<br/>
"ModifiedOn": "2016-10-11T22:36:32.9934851Z",<br/>
"ModifiedBy": "<Name of the Reviewer>",<br/>
"CallBackType": "Review",<br/>
"ContentId": "<The ContentId that was specified input>",<br/>
"Metadata": {<br/>
"adultscore": "0.xxx",<br/>
"a": "False",<br/>
"racyscore": "0.xxx",<br/>
"r": "True"<br/>
},<br/>
"ReviewerResultTags": {<br/>
"a": "False",<br/>
"r": "True"<br/>
}<br/>
}<br/>
</p>.
@param teamName Your team name.
@param reviewId Id of the review.
@param addVideoFrameOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
if (this.client.baseUrl() == null) {
throw new IllegalArgumentException("Parameter this.client.baseUrl() is required and cannot be null.");
}
if (teamName == null) {
throw new IllegalArgumentException("Parameter teamName is required and cannot be null.");
}
if (reviewId == null) {
throw new IllegalArgumentException("Parameter reviewId is required and cannot be null.");
}
final Integer timescale = addVideoFrameOptionalParameter != null ? addVideoFrameOptionalParameter.timescale() : null;
return addVideoFrameWithServiceResponseAsync(teamName, reviewId, timescale);
} | java | public Observable<ServiceResponse<Void>> addVideoFrameWithServiceResponseAsync(String teamName, String reviewId, AddVideoFrameOptionalParameter addVideoFrameOptionalParameter) {
if (this.client.baseUrl() == null) {
throw new IllegalArgumentException("Parameter this.client.baseUrl() is required and cannot be null.");
}
if (teamName == null) {
throw new IllegalArgumentException("Parameter teamName is required and cannot be null.");
}
if (reviewId == null) {
throw new IllegalArgumentException("Parameter reviewId is required and cannot be null.");
}
final Integer timescale = addVideoFrameOptionalParameter != null ? addVideoFrameOptionalParameter.timescale() : null;
return addVideoFrameWithServiceResponseAsync(teamName, reviewId, timescale);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Void",
">",
">",
"addVideoFrameWithServiceResponseAsync",
"(",
"String",
"teamName",
",",
"String",
"reviewId",
",",
"AddVideoFrameOptionalParameter",
"addVideoFrameOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"baseUrl",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.baseUrl() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"teamName",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter teamName is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"reviewId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter reviewId is required and cannot be null.\"",
")",
";",
"}",
"final",
"Integer",
"timescale",
"=",
"addVideoFrameOptionalParameter",
"!=",
"null",
"?",
"addVideoFrameOptionalParameter",
".",
"timescale",
"(",
")",
":",
"null",
";",
"return",
"addVideoFrameWithServiceResponseAsync",
"(",
"teamName",
",",
"reviewId",
",",
"timescale",
")",
";",
"}"
] | The reviews created would show up for Reviewers on your team. As Reviewers complete reviewing, results of the Review would be POSTED (i.e. HTTP POST) on the specified CallBackEndpoint.
<h3>CallBack Schemas </h3>
<h4>Review Completion CallBack Sample</h4>
<p>
{<br/>
"ReviewId": "<Review Id>",<br/>
"ModifiedOn": "2016-10-11T22:36:32.9934851Z",<br/>
"ModifiedBy": "<Name of the Reviewer>",<br/>
"CallBackType": "Review",<br/>
"ContentId": "<The ContentId that was specified input>",<br/>
"Metadata": {<br/>
"adultscore": "0.xxx",<br/>
"a": "False",<br/>
"racyscore": "0.xxx",<br/>
"r": "True"<br/>
},<br/>
"ReviewerResultTags": {<br/>
"a": "False",<br/>
"r": "True"<br/>
}<br/>
}<br/>
</p>.
@param teamName Your team name.
@param reviewId Id of the review.
@param addVideoFrameOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"The",
"reviews",
"created",
"would",
"show",
"up",
"for",
"Reviewers",
"on",
"your",
"team",
".",
"As",
"Reviewers",
"complete",
"reviewing",
"results",
"of",
"the",
"Review",
"would",
"be",
"POSTED",
"(",
"i",
".",
"e",
".",
"HTTP",
"POST",
")",
"on",
"the",
"specified",
"CallBackEndpoint",
".",
"<",
";",
"h3>",
";",
"CallBack",
"Schemas",
"<",
";",
"/",
"h3>",
";",
"<",
";",
"h4>",
";",
"Review",
"Completion",
"CallBack",
"Sample<",
";",
"/",
"h4>",
";",
"<",
";",
"p>",
";",
"{",
"<",
";",
"br",
"/",
">",
";",
"ReviewId",
":",
"<",
";",
"Review",
"Id>",
";",
"<",
";",
"br",
"/",
">",
";",
"ModifiedOn",
":",
"2016",
"-",
"10",
"-",
"11T22",
":",
"36",
":",
"32",
".",
"9934851Z",
"<",
";",
"br",
"/",
">",
";",
"ModifiedBy",
":",
"<",
";",
"Name",
"of",
"the",
"Reviewer>",
";",
"<",
";",
"br",
"/",
">",
";",
"CallBackType",
":",
"Review",
"<",
";",
"br",
"/",
">",
";",
"ContentId",
":",
"<",
";",
"The",
"ContentId",
"that",
"was",
"specified",
"input>",
";",
"<",
";",
"br",
"/",
">",
";",
"Metadata",
":",
"{",
"<",
";",
"br",
"/",
">",
";",
"adultscore",
":",
"0",
".",
"xxx",
"<",
";",
"br",
"/",
">",
";",
"a",
":",
"False",
"<",
";",
"br",
"/",
">",
";",
"racyscore",
":",
"0",
".",
"xxx",
"<",
";",
"br",
"/",
">",
";",
"r",
":",
"True",
"<",
";",
"br",
"/",
">",
";",
"}",
"<",
";",
"br",
"/",
">",
";",
"ReviewerResultTags",
":",
"{",
"<",
";",
"br",
"/",
">",
";",
"a",
":",
"False",
"<",
";",
"br",
"/",
">",
";",
"r",
":",
"True",
"<",
";",
"br",
"/",
">",
";",
"}",
"<",
";",
"br",
"/",
">",
";",
"}",
"<",
";",
"br",
"/",
">",
";",
"<",
";",
"/",
"p>",
";",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/ReviewsImpl.java#L1176-L1189 |
Mozu/mozu-java | mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/CouponSetUrl.java | CouponSetUrl.getCouponSetUrl | public static MozuUrl getCouponSetUrl(String couponSetCode, Boolean includeCounts, String responseFields) {
"""
Get Resource Url for GetCouponSet
@param couponSetCode The unique identifier of the coupon set.
@param includeCounts Specifies whether to include the number of redeemed coupons, existing coupon codes, and assigned discounts in the response body.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/couponsets/{couponSetCode}?includeCounts={includeCounts}&responseFields={responseFields}");
formatter.formatUrl("couponSetCode", couponSetCode);
formatter.formatUrl("includeCounts", includeCounts);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl getCouponSetUrl(String couponSetCode, Boolean includeCounts, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/couponsets/{couponSetCode}?includeCounts={includeCounts}&responseFields={responseFields}");
formatter.formatUrl("couponSetCode", couponSetCode);
formatter.formatUrl("includeCounts", includeCounts);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"getCouponSetUrl",
"(",
"String",
"couponSetCode",
",",
"Boolean",
"includeCounts",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/catalog/admin/couponsets/{couponSetCode}?includeCounts={includeCounts}&responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"couponSetCode\"",
",",
"couponSetCode",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"includeCounts\"",
",",
"includeCounts",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] | Get Resource Url for GetCouponSet
@param couponSetCode The unique identifier of the coupon set.
@param includeCounts Specifies whether to include the number of redeemed coupons, existing coupon codes, and assigned discounts in the response body.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"GetCouponSet"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/CouponSetUrl.java#L45-L52 |
mijecu25/dsa | src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java | LinearSearch.searchLast | public static int searchLast(long[] longArray, long value, int occurrence) {
"""
Search for the value in the long array and return the index of the first occurrence from the
end of the array.
@param longArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
"""
if(occurrence <= 0 || occurrence > longArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = longArray.length-1; i >=0; i--) {
if(longArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
} | java | public static int searchLast(long[] longArray, long value, int occurrence) {
if(occurrence <= 0 || occurrence > longArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = longArray.length-1; i >=0; i--) {
if(longArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
} | [
"public",
"static",
"int",
"searchLast",
"(",
"long",
"[",
"]",
"longArray",
",",
"long",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"longArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"longArray",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"longArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Search for the value in the long array and return the index of the first occurrence from the
end of the array.
@param longArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1. | [
"Search",
"for",
"the",
"value",
"in",
"the",
"long",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"end",
"of",
"the",
"array",
"."
] | train | https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1650-L1669 |
Alluxio/alluxio | shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java | FileSystemShellUtils.getIntArg | public static int getIntArg(CommandLine cl, Option option, int defaultValue) {
"""
Gets the value of an option from the command line.
@param cl command line object
@param option the option to check for in the command line
@param defaultValue default value for the option
@return argument from command line or default if not present
"""
int arg = defaultValue;
if (cl.hasOption(option.getLongOpt())) {
String argOption = cl.getOptionValue(option.getLongOpt());
arg = Integer.parseInt(argOption);
}
return arg;
} | java | public static int getIntArg(CommandLine cl, Option option, int defaultValue) {
int arg = defaultValue;
if (cl.hasOption(option.getLongOpt())) {
String argOption = cl.getOptionValue(option.getLongOpt());
arg = Integer.parseInt(argOption);
}
return arg;
} | [
"public",
"static",
"int",
"getIntArg",
"(",
"CommandLine",
"cl",
",",
"Option",
"option",
",",
"int",
"defaultValue",
")",
"{",
"int",
"arg",
"=",
"defaultValue",
";",
"if",
"(",
"cl",
".",
"hasOption",
"(",
"option",
".",
"getLongOpt",
"(",
")",
")",
")",
"{",
"String",
"argOption",
"=",
"cl",
".",
"getOptionValue",
"(",
"option",
".",
"getLongOpt",
"(",
")",
")",
";",
"arg",
"=",
"Integer",
".",
"parseInt",
"(",
"argOption",
")",
";",
"}",
"return",
"arg",
";",
"}"
] | Gets the value of an option from the command line.
@param cl command line object
@param option the option to check for in the command line
@param defaultValue default value for the option
@return argument from command line or default if not present | [
"Gets",
"the",
"value",
"of",
"an",
"option",
"from",
"the",
"command",
"line",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java#L231-L238 |
Red5/red5-io | src/main/java/org/red5/io/object/Serializer.java | Serializer.writeList | protected static void writeList(Output out, List<?> list) {
"""
Writes a List out as an Object
@param out
Output writer
@param list
List to write as Object
"""
if (!list.isEmpty()) {
int size = list.size();
// if its a small list, write it as an array
if (size < 100) {
out.writeArray(list);
return;
}
// else we should check for lots of null values,
// if there are over 80% then its probably best to do it as a map
int nullCount = 0;
for (int i = 0; i < size; i++) {
if (list.get(i) == null) {
nullCount++;
}
}
if (nullCount > (size * 0.8)) {
out.writeMap(list);
} else {
out.writeArray(list);
}
} else {
out.writeArray(new Object[] {});
}
} | java | protected static void writeList(Output out, List<?> list) {
if (!list.isEmpty()) {
int size = list.size();
// if its a small list, write it as an array
if (size < 100) {
out.writeArray(list);
return;
}
// else we should check for lots of null values,
// if there are over 80% then its probably best to do it as a map
int nullCount = 0;
for (int i = 0; i < size; i++) {
if (list.get(i) == null) {
nullCount++;
}
}
if (nullCount > (size * 0.8)) {
out.writeMap(list);
} else {
out.writeArray(list);
}
} else {
out.writeArray(new Object[] {});
}
} | [
"protected",
"static",
"void",
"writeList",
"(",
"Output",
"out",
",",
"List",
"<",
"?",
">",
"list",
")",
"{",
"if",
"(",
"!",
"list",
".",
"isEmpty",
"(",
")",
")",
"{",
"int",
"size",
"=",
"list",
".",
"size",
"(",
")",
";",
"// if its a small list, write it as an array",
"if",
"(",
"size",
"<",
"100",
")",
"{",
"out",
".",
"writeArray",
"(",
"list",
")",
";",
"return",
";",
"}",
"// else we should check for lots of null values,",
"// if there are over 80% then its probably best to do it as a map",
"int",
"nullCount",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"if",
"(",
"list",
".",
"get",
"(",
"i",
")",
"==",
"null",
")",
"{",
"nullCount",
"++",
";",
"}",
"}",
"if",
"(",
"nullCount",
">",
"(",
"size",
"*",
"0.8",
")",
")",
"{",
"out",
".",
"writeMap",
"(",
"list",
")",
";",
"}",
"else",
"{",
"out",
".",
"writeArray",
"(",
"list",
")",
";",
"}",
"}",
"else",
"{",
"out",
".",
"writeArray",
"(",
"new",
"Object",
"[",
"]",
"{",
"}",
")",
";",
"}",
"}"
] | Writes a List out as an Object
@param out
Output writer
@param list
List to write as Object | [
"Writes",
"a",
"List",
"out",
"as",
"an",
"Object"
] | train | https://github.com/Red5/red5-io/blob/9bbbc506423c5a8f18169d46d400df56c0072a33/src/main/java/org/red5/io/object/Serializer.java#L218-L242 |
cloudant/sync-android | cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/documentstore/RevisionHistoryHelper.java | RevisionHistoryHelper.revisionHistoryToJson | public static Map<String, Object> revisionHistoryToJson(List<InternalDocumentRevision> history,
Map<String, ? extends Attachment> attachments,
boolean shouldInline,
int minRevPos) {
"""
<p>Serialise a branch's revision history, in the form of a list of
{@link InternalDocumentRevision}s, into the JSON format expected by CouchDB's _bulk_docs
endpoint.</p>
@param history list of {@code DocumentRevision}s. This should be a complete list
from the revision furthest down the branch to the root.
@param attachments list of {@code Attachment}s, if any. This allows the {@code _attachments}
dictionary to be correctly serialised. If there are no attachments, set
to null.
@param shouldInline whether to upload attachments inline or separately via multipart/related.
@param minRevPos generation number of most recent ancestor on the remote database. If the
{@code revpos} value of a given attachment is greater than {@code minRevPos},
then it is newer than the version on the remote database and must be sent.
Otherwise, a stub can be sent.
@return JSON-serialised {@code String} suitable for sending to CouchDB's
_bulk_docs endpoint.
@see DocumentRevs
"""
Misc.checkNotNull(history, "History");
Misc.checkArgument(history.size() > 0, "History must have at least one DocumentRevision.");
Misc.checkArgument(checkHistoryIsInDescendingOrder(history),
"History must be in descending order.");
InternalDocumentRevision currentNode = history.get(0);
Map<String, Object> m = currentNode.asMap();
if (attachments != null && !attachments.isEmpty()) {
// graft attachments on to m for this particular revision here
addAttachments(attachments, m, shouldInline, minRevPos);
}
m.put(CouchConstants._revisions, createRevisions(history));
return m;
} | java | public static Map<String, Object> revisionHistoryToJson(List<InternalDocumentRevision> history,
Map<String, ? extends Attachment> attachments,
boolean shouldInline,
int minRevPos) {
Misc.checkNotNull(history, "History");
Misc.checkArgument(history.size() > 0, "History must have at least one DocumentRevision.");
Misc.checkArgument(checkHistoryIsInDescendingOrder(history),
"History must be in descending order.");
InternalDocumentRevision currentNode = history.get(0);
Map<String, Object> m = currentNode.asMap();
if (attachments != null && !attachments.isEmpty()) {
// graft attachments on to m for this particular revision here
addAttachments(attachments, m, shouldInline, minRevPos);
}
m.put(CouchConstants._revisions, createRevisions(history));
return m;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"revisionHistoryToJson",
"(",
"List",
"<",
"InternalDocumentRevision",
">",
"history",
",",
"Map",
"<",
"String",
",",
"?",
"extends",
"Attachment",
">",
"attachments",
",",
"boolean",
"shouldInline",
",",
"int",
"minRevPos",
")",
"{",
"Misc",
".",
"checkNotNull",
"(",
"history",
",",
"\"History\"",
")",
";",
"Misc",
".",
"checkArgument",
"(",
"history",
".",
"size",
"(",
")",
">",
"0",
",",
"\"History must have at least one DocumentRevision.\"",
")",
";",
"Misc",
".",
"checkArgument",
"(",
"checkHistoryIsInDescendingOrder",
"(",
"history",
")",
",",
"\"History must be in descending order.\"",
")",
";",
"InternalDocumentRevision",
"currentNode",
"=",
"history",
".",
"get",
"(",
"0",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"m",
"=",
"currentNode",
".",
"asMap",
"(",
")",
";",
"if",
"(",
"attachments",
"!=",
"null",
"&&",
"!",
"attachments",
".",
"isEmpty",
"(",
")",
")",
"{",
"// graft attachments on to m for this particular revision here",
"addAttachments",
"(",
"attachments",
",",
"m",
",",
"shouldInline",
",",
"minRevPos",
")",
";",
"}",
"m",
".",
"put",
"(",
"CouchConstants",
".",
"_revisions",
",",
"createRevisions",
"(",
"history",
")",
")",
";",
"return",
"m",
";",
"}"
] | <p>Serialise a branch's revision history, in the form of a list of
{@link InternalDocumentRevision}s, into the JSON format expected by CouchDB's _bulk_docs
endpoint.</p>
@param history list of {@code DocumentRevision}s. This should be a complete list
from the revision furthest down the branch to the root.
@param attachments list of {@code Attachment}s, if any. This allows the {@code _attachments}
dictionary to be correctly serialised. If there are no attachments, set
to null.
@param shouldInline whether to upload attachments inline or separately via multipart/related.
@param minRevPos generation number of most recent ancestor on the remote database. If the
{@code revpos} value of a given attachment is greater than {@code minRevPos},
then it is newer than the version on the remote database and must be sent.
Otherwise, a stub can be sent.
@return JSON-serialised {@code String} suitable for sending to CouchDB's
_bulk_docs endpoint.
@see DocumentRevs | [
"<p",
">",
"Serialise",
"a",
"branch",
"s",
"revision",
"history",
"in",
"the",
"form",
"of",
"a",
"list",
"of",
"{",
"@link",
"InternalDocumentRevision",
"}",
"s",
"into",
"the",
"JSON",
"format",
"expected",
"by",
"CouchDB",
"s",
"_bulk_docs",
"endpoint",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/cloudant/sync-android/blob/5f1416ed1bd9ab05d7a4b8736480c8ae68bd7383/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/documentstore/RevisionHistoryHelper.java#L145-L165 |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java | HttpUtil.getCharset | public static Charset getCharset(CharSequence contentTypeValue, Charset defaultCharset) {
"""
Fetch charset from Content-Type header value.
@param contentTypeValue Content-Type header value to parse
@param defaultCharset result to use in case of empty, incorrect or doesn't contain required part header value
@return the charset from message's Content-Type header or {@code defaultCharset}
if charset is not presented or unparsable
"""
if (contentTypeValue != null) {
CharSequence charsetCharSequence = getCharsetAsSequence(contentTypeValue);
if (charsetCharSequence != null) {
try {
return Charset.forName(charsetCharSequence.toString());
} catch (UnsupportedCharsetException ignored) {
return defaultCharset;
}
} else {
return defaultCharset;
}
} else {
return defaultCharset;
}
} | java | public static Charset getCharset(CharSequence contentTypeValue, Charset defaultCharset) {
if (contentTypeValue != null) {
CharSequence charsetCharSequence = getCharsetAsSequence(contentTypeValue);
if (charsetCharSequence != null) {
try {
return Charset.forName(charsetCharSequence.toString());
} catch (UnsupportedCharsetException ignored) {
return defaultCharset;
}
} else {
return defaultCharset;
}
} else {
return defaultCharset;
}
} | [
"public",
"static",
"Charset",
"getCharset",
"(",
"CharSequence",
"contentTypeValue",
",",
"Charset",
"defaultCharset",
")",
"{",
"if",
"(",
"contentTypeValue",
"!=",
"null",
")",
"{",
"CharSequence",
"charsetCharSequence",
"=",
"getCharsetAsSequence",
"(",
"contentTypeValue",
")",
";",
"if",
"(",
"charsetCharSequence",
"!=",
"null",
")",
"{",
"try",
"{",
"return",
"Charset",
".",
"forName",
"(",
"charsetCharSequence",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"UnsupportedCharsetException",
"ignored",
")",
"{",
"return",
"defaultCharset",
";",
"}",
"}",
"else",
"{",
"return",
"defaultCharset",
";",
"}",
"}",
"else",
"{",
"return",
"defaultCharset",
";",
"}",
"}"
] | Fetch charset from Content-Type header value.
@param contentTypeValue Content-Type header value to parse
@param defaultCharset result to use in case of empty, incorrect or doesn't contain required part header value
@return the charset from message's Content-Type header or {@code defaultCharset}
if charset is not presented or unparsable | [
"Fetch",
"charset",
"from",
"Content",
"-",
"Type",
"header",
"value",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java#L388-L403 |
davidcarboni/cryptolite-java | src/main/java/com/github/davidcarboni/cryptolite/Password.java | Password.verify | public static boolean verify(String password, String hash) {
"""
Verifies the given plaintext password against a value that
{@link #hash(String)} produced.
@param password A plaintext password. If this is null, false will be returned.
@param hash A value previously produced by {@link #hash(String)}. If this
is empty or shorter than expected, false will be returned.
@return If the password hashes to the same value as that contained in the
hash parameter, true.
"""
boolean result = false;
if (StringUtils.isNotBlank(hash) && password != null) {
// Get the salt and hash from the input string:
byte[] bytes = ByteArray.fromBase64(hash);
// Check the size of the value to ensure it's at least as long as
// the salt:
if (bytes.length >= Generate.SALT_BYTES) {
// Extract the salt and password hash:
String salt = getSalt(bytes);
byte[] existingHash = getHash(bytes);
// Hash the password with the same salt in order to get the same
// result:
byte[] comparisonHash = hash(password, salt);
// See whether they match:
result = Arrays.equals(existingHash, comparisonHash);
}
}
return result;
} | java | public static boolean verify(String password, String hash) {
boolean result = false;
if (StringUtils.isNotBlank(hash) && password != null) {
// Get the salt and hash from the input string:
byte[] bytes = ByteArray.fromBase64(hash);
// Check the size of the value to ensure it's at least as long as
// the salt:
if (bytes.length >= Generate.SALT_BYTES) {
// Extract the salt and password hash:
String salt = getSalt(bytes);
byte[] existingHash = getHash(bytes);
// Hash the password with the same salt in order to get the same
// result:
byte[] comparisonHash = hash(password, salt);
// See whether they match:
result = Arrays.equals(existingHash, comparisonHash);
}
}
return result;
} | [
"public",
"static",
"boolean",
"verify",
"(",
"String",
"password",
",",
"String",
"hash",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"hash",
")",
"&&",
"password",
"!=",
"null",
")",
"{",
"// Get the salt and hash from the input string:",
"byte",
"[",
"]",
"bytes",
"=",
"ByteArray",
".",
"fromBase64",
"(",
"hash",
")",
";",
"// Check the size of the value to ensure it's at least as long as",
"// the salt:",
"if",
"(",
"bytes",
".",
"length",
">=",
"Generate",
".",
"SALT_BYTES",
")",
"{",
"// Extract the salt and password hash:",
"String",
"salt",
"=",
"getSalt",
"(",
"bytes",
")",
";",
"byte",
"[",
"]",
"existingHash",
"=",
"getHash",
"(",
"bytes",
")",
";",
"// Hash the password with the same salt in order to get the same",
"// result:",
"byte",
"[",
"]",
"comparisonHash",
"=",
"hash",
"(",
"password",
",",
"salt",
")",
";",
"// See whether they match:",
"result",
"=",
"Arrays",
".",
"equals",
"(",
"existingHash",
",",
"comparisonHash",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Verifies the given plaintext password against a value that
{@link #hash(String)} produced.
@param password A plaintext password. If this is null, false will be returned.
@param hash A value previously produced by {@link #hash(String)}. If this
is empty or shorter than expected, false will be returned.
@return If the password hashes to the same value as that contained in the
hash parameter, true. | [
"Verifies",
"the",
"given",
"plaintext",
"password",
"against",
"a",
"value",
"that",
"{",
"@link",
"#hash",
"(",
"String",
")",
"}",
"produced",
"."
] | train | https://github.com/davidcarboni/cryptolite-java/blob/e67954181a04ffc9beb1d9abca1421195fcf9764/src/main/java/com/github/davidcarboni/cryptolite/Password.java#L81-L107 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF3.java | CommonOps_DDF3.subtract | public static void subtract( DMatrix3 a , DMatrix3 b , DMatrix3 c ) {
"""
<p>Performs the following operation:<br>
<br>
c = a - b <br>
c<sub>i</sub> = a<sub>i</sub> - b<sub>i</sub> <br>
</p>
<p>
Vector C can be the same instance as Vector A and/or B.
</p>
@param a A Vector. Not modified.
@param b A Vector. Not modified.
@param c A Vector where the results are stored. Modified.
"""
c.a1 = a.a1 - b.a1;
c.a2 = a.a2 - b.a2;
c.a3 = a.a3 - b.a3;
} | java | public static void subtract( DMatrix3 a , DMatrix3 b , DMatrix3 c ) {
c.a1 = a.a1 - b.a1;
c.a2 = a.a2 - b.a2;
c.a3 = a.a3 - b.a3;
} | [
"public",
"static",
"void",
"subtract",
"(",
"DMatrix3",
"a",
",",
"DMatrix3",
"b",
",",
"DMatrix3",
"c",
")",
"{",
"c",
".",
"a1",
"=",
"a",
".",
"a1",
"-",
"b",
".",
"a1",
";",
"c",
".",
"a2",
"=",
"a",
".",
"a2",
"-",
"b",
".",
"a2",
";",
"c",
".",
"a3",
"=",
"a",
".",
"a3",
"-",
"b",
".",
"a3",
";",
"}"
] | <p>Performs the following operation:<br>
<br>
c = a - b <br>
c<sub>i</sub> = a<sub>i</sub> - b<sub>i</sub> <br>
</p>
<p>
Vector C can be the same instance as Vector A and/or B.
</p>
@param a A Vector. Not modified.
@param b A Vector. Not modified.
@param c A Vector where the results are stored. Modified. | [
"<p",
">",
"Performs",
"the",
"following",
"operation",
":",
"<br",
">",
"<br",
">",
"c",
"=",
"a",
"-",
"b",
"<br",
">",
"c<sub",
">",
"i<",
"/",
"sub",
">",
"=",
"a<sub",
">",
"i<",
"/",
"sub",
">",
"-",
"b<sub",
">",
"i<",
"/",
"sub",
">",
"<br",
">",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF3.java#L160-L164 |
lessthanoptimal/BoofCV | integration/boofcv-WebcamCapture/src/main/java/boofcv/io/webcamcapture/UtilWebcamCapture.java | UtilWebcamCapture.openDevice | public static Webcam openDevice( String deviceName , int desiredWidth , int desiredHeight ) {
"""
Searches for the first device which matches the pattern. Webcam capture doesn't name devices
using the standard "/dev/video0" scheme, but it includes that in its name.
@param deviceName Partial or complete name of the device you wish to pen
@return The webcam it found
"""
Webcam webcam = findDevice(deviceName);
if( webcam == null )
throw new IllegalArgumentException("Can't find camera "+deviceName);
adjustResolution(webcam,desiredWidth,desiredHeight);
webcam.open();
return webcam;
} | java | public static Webcam openDevice( String deviceName , int desiredWidth , int desiredHeight ) {
Webcam webcam = findDevice(deviceName);
if( webcam == null )
throw new IllegalArgumentException("Can't find camera "+deviceName);
adjustResolution(webcam,desiredWidth,desiredHeight);
webcam.open();
return webcam;
} | [
"public",
"static",
"Webcam",
"openDevice",
"(",
"String",
"deviceName",
",",
"int",
"desiredWidth",
",",
"int",
"desiredHeight",
")",
"{",
"Webcam",
"webcam",
"=",
"findDevice",
"(",
"deviceName",
")",
";",
"if",
"(",
"webcam",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can't find camera \"",
"+",
"deviceName",
")",
";",
"adjustResolution",
"(",
"webcam",
",",
"desiredWidth",
",",
"desiredHeight",
")",
";",
"webcam",
".",
"open",
"(",
")",
";",
"return",
"webcam",
";",
"}"
] | Searches for the first device which matches the pattern. Webcam capture doesn't name devices
using the standard "/dev/video0" scheme, but it includes that in its name.
@param deviceName Partial or complete name of the device you wish to pen
@return The webcam it found | [
"Searches",
"for",
"the",
"first",
"device",
"which",
"matches",
"the",
"pattern",
".",
"Webcam",
"capture",
"doesn",
"t",
"name",
"devices",
"using",
"the",
"standard",
"/",
"dev",
"/",
"video0",
"scheme",
"but",
"it",
"includes",
"that",
"in",
"its",
"name",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-WebcamCapture/src/main/java/boofcv/io/webcamcapture/UtilWebcamCapture.java#L55-L62 |
graphhopper/graphhopper | core/src/main/java/com/graphhopper/GraphHopper.java | GraphHopper.createTurnWeighting | public Weighting createTurnWeighting(Graph graph, Weighting weighting, TraversalMode tMode) {
"""
Potentially wraps the specified weighting into a TurnWeighting instance.
"""
FlagEncoder encoder = weighting.getFlagEncoder();
if (encoder.supports(TurnWeighting.class) && !tMode.equals(TraversalMode.NODE_BASED))
return new TurnWeighting(weighting, (TurnCostExtension) graph.getExtension());
return weighting;
} | java | public Weighting createTurnWeighting(Graph graph, Weighting weighting, TraversalMode tMode) {
FlagEncoder encoder = weighting.getFlagEncoder();
if (encoder.supports(TurnWeighting.class) && !tMode.equals(TraversalMode.NODE_BASED))
return new TurnWeighting(weighting, (TurnCostExtension) graph.getExtension());
return weighting;
} | [
"public",
"Weighting",
"createTurnWeighting",
"(",
"Graph",
"graph",
",",
"Weighting",
"weighting",
",",
"TraversalMode",
"tMode",
")",
"{",
"FlagEncoder",
"encoder",
"=",
"weighting",
".",
"getFlagEncoder",
"(",
")",
";",
"if",
"(",
"encoder",
".",
"supports",
"(",
"TurnWeighting",
".",
"class",
")",
"&&",
"!",
"tMode",
".",
"equals",
"(",
"TraversalMode",
".",
"NODE_BASED",
")",
")",
"return",
"new",
"TurnWeighting",
"(",
"weighting",
",",
"(",
"TurnCostExtension",
")",
"graph",
".",
"getExtension",
"(",
")",
")",
";",
"return",
"weighting",
";",
"}"
] | Potentially wraps the specified weighting into a TurnWeighting instance. | [
"Potentially",
"wraps",
"the",
"specified",
"weighting",
"into",
"a",
"TurnWeighting",
"instance",
"."
] | train | https://github.com/graphhopper/graphhopper/blob/c235e306e6e823043cadcc41ead0e685bdebf737/core/src/main/java/com/graphhopper/GraphHopper.java#L912-L917 |
ngageoint/geopackage-android-map | geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeConverter.java | GoogleMapShapeConverter.toCircularString | public CircularString toCircularString(List<LatLng> latLngs, boolean hasZ,
boolean hasM) {
"""
Convert a list of {@link LatLng} to a {@link CircularString}
@param latLngs lat lngs
@param hasZ has z flag
@param hasM has m flag
@return circular string
"""
CircularString circularString = new CircularString(hasZ, hasM);
populateLineString(circularString, latLngs);
return circularString;
} | java | public CircularString toCircularString(List<LatLng> latLngs, boolean hasZ,
boolean hasM) {
CircularString circularString = new CircularString(hasZ, hasM);
populateLineString(circularString, latLngs);
return circularString;
} | [
"public",
"CircularString",
"toCircularString",
"(",
"List",
"<",
"LatLng",
">",
"latLngs",
",",
"boolean",
"hasZ",
",",
"boolean",
"hasM",
")",
"{",
"CircularString",
"circularString",
"=",
"new",
"CircularString",
"(",
"hasZ",
",",
"hasM",
")",
";",
"populateLineString",
"(",
"circularString",
",",
"latLngs",
")",
";",
"return",
"circularString",
";",
"}"
] | Convert a list of {@link LatLng} to a {@link CircularString}
@param latLngs lat lngs
@param hasZ has z flag
@param hasM has m flag
@return circular string | [
"Convert",
"a",
"list",
"of",
"{",
"@link",
"LatLng",
"}",
"to",
"a",
"{",
"@link",
"CircularString",
"}"
] | train | https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeConverter.java#L375-L383 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/os/BundleUtils.java | BundleUtils.optLong | public static long optLong(@Nullable Bundle bundle, @Nullable String key, long fallback) {
"""
Returns a optional long value. In other words, returns the value mapped by key if it exists and is a long.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns a fallback value.
@param bundle a bundle. If the bundle is null, this method will return a fallback value.
@param key a key for the value.
@param fallback fallback value.
@return a long value if exists, fallback value otherwise.
@see android.os.Bundle#getLong(String, long)
"""
if (bundle == null) {
return fallback;
}
return bundle.getLong(key, fallback);
} | java | public static long optLong(@Nullable Bundle bundle, @Nullable String key, long fallback) {
if (bundle == null) {
return fallback;
}
return bundle.getLong(key, fallback);
} | [
"public",
"static",
"long",
"optLong",
"(",
"@",
"Nullable",
"Bundle",
"bundle",
",",
"@",
"Nullable",
"String",
"key",
",",
"long",
"fallback",
")",
"{",
"if",
"(",
"bundle",
"==",
"null",
")",
"{",
"return",
"fallback",
";",
"}",
"return",
"bundle",
".",
"getLong",
"(",
"key",
",",
"fallback",
")",
";",
"}"
] | Returns a optional long value. In other words, returns the value mapped by key if it exists and is a long.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns a fallback value.
@param bundle a bundle. If the bundle is null, this method will return a fallback value.
@param key a key for the value.
@param fallback fallback value.
@return a long value if exists, fallback value otherwise.
@see android.os.Bundle#getLong(String, long) | [
"Returns",
"a",
"optional",
"long",
"value",
".",
"In",
"other",
"words",
"returns",
"the",
"value",
"mapped",
"by",
"key",
"if",
"it",
"exists",
"and",
"is",
"a",
"long",
".",
"The",
"bundle",
"argument",
"is",
"allowed",
"to",
"be",
"{"
] | train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/os/BundleUtils.java#L644-L649 |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/resource/Import.java | Import.serialize | public JSONObject serialize(Map<String, Object> out) {
"""
Custom serialization method for this object to JSON.
@param out In-out parameter that maps JSON keys to their values.
@return A JSONObject representing this object.
"""
JSONObject json = new JSONObject();
json.put("device_id", deviceId);
json.put("project_id", projectId);
out.put("device_id", deviceId);
out.put("project_id", projectId);
JSONArray sourcesArr = new JSONArray();
List<String> sourceNames = new ArrayList<String>(store.keySet());
Collections.sort(sourceNames);
for (String k : sourceNames) {
JSONObject temp = new JSONObject();
temp.put("name", k);
JSONArray dataArr = new JSONArray();
for (DataPoint d : store.get(k)) {
dataArr.put(d.toJson());
}
temp.put("data", dataArr);
sourcesArr.put(temp);
}
json.put("sources", sourcesArr);
out.put("sources", sourcesArr);
return json;
} | java | public JSONObject serialize(Map<String, Object> out) {
JSONObject json = new JSONObject();
json.put("device_id", deviceId);
json.put("project_id", projectId);
out.put("device_id", deviceId);
out.put("project_id", projectId);
JSONArray sourcesArr = new JSONArray();
List<String> sourceNames = new ArrayList<String>(store.keySet());
Collections.sort(sourceNames);
for (String k : sourceNames) {
JSONObject temp = new JSONObject();
temp.put("name", k);
JSONArray dataArr = new JSONArray();
for (DataPoint d : store.get(k)) {
dataArr.put(d.toJson());
}
temp.put("data", dataArr);
sourcesArr.put(temp);
}
json.put("sources", sourcesArr);
out.put("sources", sourcesArr);
return json;
} | [
"public",
"JSONObject",
"serialize",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"out",
")",
"{",
"JSONObject",
"json",
"=",
"new",
"JSONObject",
"(",
")",
";",
"json",
".",
"put",
"(",
"\"device_id\"",
",",
"deviceId",
")",
";",
"json",
".",
"put",
"(",
"\"project_id\"",
",",
"projectId",
")",
";",
"out",
".",
"put",
"(",
"\"device_id\"",
",",
"deviceId",
")",
";",
"out",
".",
"put",
"(",
"\"project_id\"",
",",
"projectId",
")",
";",
"JSONArray",
"sourcesArr",
"=",
"new",
"JSONArray",
"(",
")",
";",
"List",
"<",
"String",
">",
"sourceNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"store",
".",
"keySet",
"(",
")",
")",
";",
"Collections",
".",
"sort",
"(",
"sourceNames",
")",
";",
"for",
"(",
"String",
"k",
":",
"sourceNames",
")",
"{",
"JSONObject",
"temp",
"=",
"new",
"JSONObject",
"(",
")",
";",
"temp",
".",
"put",
"(",
"\"name\"",
",",
"k",
")",
";",
"JSONArray",
"dataArr",
"=",
"new",
"JSONArray",
"(",
")",
";",
"for",
"(",
"DataPoint",
"d",
":",
"store",
".",
"get",
"(",
"k",
")",
")",
"{",
"dataArr",
".",
"put",
"(",
"d",
".",
"toJson",
"(",
")",
")",
";",
"}",
"temp",
".",
"put",
"(",
"\"data\"",
",",
"dataArr",
")",
";",
"sourcesArr",
".",
"put",
"(",
"temp",
")",
";",
"}",
"json",
".",
"put",
"(",
"\"sources\"",
",",
"sourcesArr",
")",
";",
"out",
".",
"put",
"(",
"\"sources\"",
",",
"sourcesArr",
")",
";",
"return",
"json",
";",
"}"
] | Custom serialization method for this object to JSON.
@param out In-out parameter that maps JSON keys to their values.
@return A JSONObject representing this object. | [
"Custom",
"serialization",
"method",
"for",
"this",
"object",
"to",
"JSON",
"."
] | train | https://github.com/iobeam/iobeam-client-java/blob/06e7aeb2a313503392358a3671de7d28628d0e33/src/main/java/com/iobeam/api/resource/Import.java#L162-L184 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.hosting_web_serviceName_cdn_duration_GET | public OvhOrder hosting_web_serviceName_cdn_duration_GET(String serviceName, String duration, OvhCdnOfferEnum offer) throws IOException {
"""
Get prices and contracts information
REST: GET /order/hosting/web/{serviceName}/cdn/{duration}
@param offer [required] Cdn offers you can add to your hosting
@param serviceName [required] The internal name of your hosting
@param duration [required] Duration
"""
String qPath = "/order/hosting/web/{serviceName}/cdn/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
query(sb, "offer", offer);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | java | public OvhOrder hosting_web_serviceName_cdn_duration_GET(String serviceName, String duration, OvhCdnOfferEnum offer) throws IOException {
String qPath = "/order/hosting/web/{serviceName}/cdn/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
query(sb, "offer", offer);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | [
"public",
"OvhOrder",
"hosting_web_serviceName_cdn_duration_GET",
"(",
"String",
"serviceName",
",",
"String",
"duration",
",",
"OvhCdnOfferEnum",
"offer",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/hosting/web/{serviceName}/cdn/{duration}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"duration",
")",
";",
"query",
"(",
"sb",
",",
"\"offer\"",
",",
"offer",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] | Get prices and contracts information
REST: GET /order/hosting/web/{serviceName}/cdn/{duration}
@param offer [required] Cdn offers you can add to your hosting
@param serviceName [required] The internal name of your hosting
@param duration [required] Duration | [
"Get",
"prices",
"and",
"contracts",
"information"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L4997-L5003 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLInverseFunctionalObjectPropertyAxiomImpl_CustomFieldSerializer.java | OWLInverseFunctionalObjectPropertyAxiomImpl_CustomFieldSerializer.deserializeInstance | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLInverseFunctionalObjectPropertyAxiomImpl instance) throws SerializationException {
"""
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
"""
deserialize(streamReader, instance);
} | java | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLInverseFunctionalObjectPropertyAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
} | [
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLInverseFunctionalObjectPropertyAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
] | Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful | [
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLInverseFunctionalObjectPropertyAxiomImpl_CustomFieldSerializer.java#L95-L98 |
grails/grails-core | grails-core/src/main/groovy/grails/util/GrailsClassUtils.java | GrailsClassUtils.isSetter | @SuppressWarnings("rawtypes")
public static boolean isSetter(String name, Class[] args) {
"""
Returns true if the name of the method specified and the number of arguments make it a javabean property setter.
The name is assumed to be a valid Java method name, that is not verified.
@param name The name of the method
@param args The arguments
@return true if it is a javabean property setter
"""
if (!StringUtils.hasText(name) || args == null)return false;
if (name.startsWith("set")) {
if (args.length != 1) return false;
return GrailsNameUtils.isPropertyMethodSuffix(name.substring(3));
}
return false;
} | java | @SuppressWarnings("rawtypes")
public static boolean isSetter(String name, Class[] args) {
if (!StringUtils.hasText(name) || args == null)return false;
if (name.startsWith("set")) {
if (args.length != 1) return false;
return GrailsNameUtils.isPropertyMethodSuffix(name.substring(3));
}
return false;
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"boolean",
"isSetter",
"(",
"String",
"name",
",",
"Class",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"!",
"StringUtils",
".",
"hasText",
"(",
"name",
")",
"||",
"args",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"name",
".",
"startsWith",
"(",
"\"set\"",
")",
")",
"{",
"if",
"(",
"args",
".",
"length",
"!=",
"1",
")",
"return",
"false",
";",
"return",
"GrailsNameUtils",
".",
"isPropertyMethodSuffix",
"(",
"name",
".",
"substring",
"(",
"3",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Returns true if the name of the method specified and the number of arguments make it a javabean property setter.
The name is assumed to be a valid Java method name, that is not verified.
@param name The name of the method
@param args The arguments
@return true if it is a javabean property setter | [
"Returns",
"true",
"if",
"the",
"name",
"of",
"the",
"method",
"specified",
"and",
"the",
"number",
"of",
"arguments",
"make",
"it",
"a",
"javabean",
"property",
"setter",
".",
"The",
"name",
"is",
"assumed",
"to",
"be",
"a",
"valid",
"Java",
"method",
"name",
"that",
"is",
"not",
"verified",
"."
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L743-L753 |
xvik/generics-resolver | src/main/java/ru/vyarus/java/generics/resolver/util/TypeVariableUtils.java | TypeVariableUtils.trackRootVariables | public static Map<Class<?>, LinkedHashMap<String, Type>> trackRootVariables(final Class type) {
"""
Shortcut for {@link #trackRootVariables(Class, List)} to simplify usage without ignore classes.
@param type class to analyze
@return resolved generics for all types in class hierarchy with root variables preserved
"""
return trackRootVariables(type, null);
} | java | public static Map<Class<?>, LinkedHashMap<String, Type>> trackRootVariables(final Class type) {
return trackRootVariables(type, null);
} | [
"public",
"static",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
">",
"trackRootVariables",
"(",
"final",
"Class",
"type",
")",
"{",
"return",
"trackRootVariables",
"(",
"type",
",",
"null",
")",
";",
"}"
] | Shortcut for {@link #trackRootVariables(Class, List)} to simplify usage without ignore classes.
@param type class to analyze
@return resolved generics for all types in class hierarchy with root variables preserved | [
"Shortcut",
"for",
"{",
"@link",
"#trackRootVariables",
"(",
"Class",
"List",
")",
"}",
"to",
"simplify",
"usage",
"without",
"ignore",
"classes",
"."
] | train | https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/TypeVariableUtils.java#L77-L79 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java | VirtualNetworkGatewaysInner.beginCreateOrUpdateAsync | public Observable<VirtualNetworkGatewayInner> beginCreateOrUpdateAsync(String resourceGroupName, String virtualNetworkGatewayName, VirtualNetworkGatewayInner parameters) {
"""
Creates or updates a virtual network gateway in the specified resource group.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@param parameters Parameters supplied to create or update virtual network gateway operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualNetworkGatewayInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, parameters).map(new Func1<ServiceResponse<VirtualNetworkGatewayInner>, VirtualNetworkGatewayInner>() {
@Override
public VirtualNetworkGatewayInner call(ServiceResponse<VirtualNetworkGatewayInner> response) {
return response.body();
}
});
} | java | public Observable<VirtualNetworkGatewayInner> beginCreateOrUpdateAsync(String resourceGroupName, String virtualNetworkGatewayName, VirtualNetworkGatewayInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, parameters).map(new Func1<ServiceResponse<VirtualNetworkGatewayInner>, VirtualNetworkGatewayInner>() {
@Override
public VirtualNetworkGatewayInner call(ServiceResponse<VirtualNetworkGatewayInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"VirtualNetworkGatewayInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayName",
",",
"VirtualNetworkGatewayInner",
"parameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"VirtualNetworkGatewayInner",
">",
",",
"VirtualNetworkGatewayInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"VirtualNetworkGatewayInner",
"call",
"(",
"ServiceResponse",
"<",
"VirtualNetworkGatewayInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates or updates a virtual network gateway in the specified resource group.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@param parameters Parameters supplied to create or update virtual network gateway operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualNetworkGatewayInner object | [
"Creates",
"or",
"updates",
"a",
"virtual",
"network",
"gateway",
"in",
"the",
"specified",
"resource",
"group",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java#L311-L318 |
umano/AndroidSlidingUpPanel | library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java | ViewDragHelper.captureChildView | public void captureChildView(View childView, int activePointerId) {
"""
Capture a specific child view for dragging within the parent. The callback will be notified
but {@link Callback#tryCaptureView(android.view.View, int)} will not be asked permission to
capture this view.
@param childView Child view to capture
@param activePointerId ID of the pointer that is dragging the captured child view
"""
if (childView.getParent() != mParentView) {
throw new IllegalArgumentException("captureChildView: parameter must be a descendant " +
"of the ViewDragHelper's tracked parent view (" + mParentView + ")");
}
mCapturedView = childView;
mActivePointerId = activePointerId;
mCallback.onViewCaptured(childView, activePointerId);
setDragState(STATE_DRAGGING);
} | java | public void captureChildView(View childView, int activePointerId) {
if (childView.getParent() != mParentView) {
throw new IllegalArgumentException("captureChildView: parameter must be a descendant " +
"of the ViewDragHelper's tracked parent view (" + mParentView + ")");
}
mCapturedView = childView;
mActivePointerId = activePointerId;
mCallback.onViewCaptured(childView, activePointerId);
setDragState(STATE_DRAGGING);
} | [
"public",
"void",
"captureChildView",
"(",
"View",
"childView",
",",
"int",
"activePointerId",
")",
"{",
"if",
"(",
"childView",
".",
"getParent",
"(",
")",
"!=",
"mParentView",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"captureChildView: parameter must be a descendant \"",
"+",
"\"of the ViewDragHelper's tracked parent view (\"",
"+",
"mParentView",
"+",
"\")\"",
")",
";",
"}",
"mCapturedView",
"=",
"childView",
";",
"mActivePointerId",
"=",
"activePointerId",
";",
"mCallback",
".",
"onViewCaptured",
"(",
"childView",
",",
"activePointerId",
")",
";",
"setDragState",
"(",
"STATE_DRAGGING",
")",
";",
"}"
] | Capture a specific child view for dragging within the parent. The callback will be notified
but {@link Callback#tryCaptureView(android.view.View, int)} will not be asked permission to
capture this view.
@param childView Child view to capture
@param activePointerId ID of the pointer that is dragging the captured child view | [
"Capture",
"a",
"specific",
"child",
"view",
"for",
"dragging",
"within",
"the",
"parent",
".",
"The",
"callback",
"will",
"be",
"notified",
"but",
"{",
"@link",
"Callback#tryCaptureView",
"(",
"android",
".",
"view",
".",
"View",
"int",
")",
"}",
"will",
"not",
"be",
"asked",
"permission",
"to",
"capture",
"this",
"view",
"."
] | train | https://github.com/umano/AndroidSlidingUpPanel/blob/45a460435b07e764138a700328836cafc1ed5c42/library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java#L490-L500 |
waldheinz/fat32-lib | src/main/java/de/waldheinz/fs/fat/FatLfnDirectoryEntry.java | FatLfnDirectoryEntry.moveTo | public void moveTo(FatLfnDirectory target, String newName)
throws IOException, ReadOnlyException {
"""
Moves this entry to a new directory under the specified name.
@param target the direcrory where this entry should be moved to
@param newName the new name under which this entry will be accessible
in the target directory
@throws IOException on error moving this entry
@throws ReadOnlyException if this directory is read-only
"""
checkWritable();
if (!target.isFreeName(newName)) {
throw new IOException(
"the name \"" + newName + "\" is already in use");
}
this.parent.unlinkEntry(this);
this.parent = target;
this.fileName = newName;
this.parent.linkEntry(this);
} | java | public void moveTo(FatLfnDirectory target, String newName)
throws IOException, ReadOnlyException {
checkWritable();
if (!target.isFreeName(newName)) {
throw new IOException(
"the name \"" + newName + "\" is already in use");
}
this.parent.unlinkEntry(this);
this.parent = target;
this.fileName = newName;
this.parent.linkEntry(this);
} | [
"public",
"void",
"moveTo",
"(",
"FatLfnDirectory",
"target",
",",
"String",
"newName",
")",
"throws",
"IOException",
",",
"ReadOnlyException",
"{",
"checkWritable",
"(",
")",
";",
"if",
"(",
"!",
"target",
".",
"isFreeName",
"(",
"newName",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"the name \\\"\"",
"+",
"newName",
"+",
"\"\\\" is already in use\"",
")",
";",
"}",
"this",
".",
"parent",
".",
"unlinkEntry",
"(",
"this",
")",
";",
"this",
".",
"parent",
"=",
"target",
";",
"this",
".",
"fileName",
"=",
"newName",
";",
"this",
".",
"parent",
".",
"linkEntry",
"(",
"this",
")",
";",
"}"
] | Moves this entry to a new directory under the specified name.
@param target the direcrory where this entry should be moved to
@param newName the new name under which this entry will be accessible
in the target directory
@throws IOException on error moving this entry
@throws ReadOnlyException if this directory is read-only | [
"Moves",
"this",
"entry",
"to",
"a",
"new",
"directory",
"under",
"the",
"specified",
"name",
"."
] | train | https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/FatLfnDirectoryEntry.java#L281-L295 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.