repository_name stringlengths 7 54 | func_path_in_repository stringlengths 18 218 | func_name stringlengths 5 140 | whole_func_string stringlengths 79 3.99k | language stringclasses 1
value | func_code_string stringlengths 79 3.99k | func_code_tokens listlengths 20 624 | func_documentation_string stringlengths 61 1.96k | func_documentation_tokens listlengths 1 478 | split_name stringclasses 1
value | func_code_url stringlengths 107 339 |
|---|---|---|---|---|---|---|---|---|---|---|
Azure/azure-sdk-for-java | network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/SecurityRulesInner.java | SecurityRulesInner.beginCreateOrUpdate | public SecurityRuleInner beginCreateOrUpdate(String resourceGroupName, String networkSecurityGroupName, String securityRuleName, SecurityRuleInner securityRuleParameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters).toBlocking().single().body();
} | java | public SecurityRuleInner beginCreateOrUpdate(String resourceGroupName, String networkSecurityGroupName, String securityRuleName, SecurityRuleInner securityRuleParameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters).toBlocking().single().body();
} | [
"public",
"SecurityRuleInner",
"beginCreateOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkSecurityGroupName",
",",
"String",
"securityRuleName",
",",
"SecurityRuleInner",
"securityRuleParameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseA... | Creates or updates a security rule in the specified network security group.
@param resourceGroupName The name of the resource group.
@param networkSecurityGroupName The name of the network security group.
@param securityRuleName The name of the security rule.
@param securityRuleParameters Parameters supplied to the create or update network security rule operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the SecurityRuleInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"security",
"rule",
"in",
"the",
"specified",
"network",
"security",
"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/SecurityRulesInner.java#L444-L446 |
passwordmaker/java-passwordmaker-lib | src/main/java/org/daveware/passwordmaker/Database.java | Database.removeAccount | private void removeAccount(Account parent, Account child) {
parent.getChildren().remove(child);
sendAccountRemoved(parent, child);
} | java | private void removeAccount(Account parent, Account child) {
parent.getChildren().remove(child);
sendAccountRemoved(parent, child);
} | [
"private",
"void",
"removeAccount",
"(",
"Account",
"parent",
",",
"Account",
"child",
")",
"{",
"parent",
".",
"getChildren",
"(",
")",
".",
"remove",
"(",
"child",
")",
";",
"sendAccountRemoved",
"(",
"parent",
",",
"child",
")",
";",
"}"
] | Internal routine to remove a child from a parent.
Notifies the listeners of the removal
@param parent - The parent to remove the child from
@param child - The child to remove from parent | [
"Internal",
"routine",
"to",
"remove",
"a",
"child",
"from",
"a",
"parent",
".",
"Notifies",
"the",
"listeners",
"of",
"the",
"removal"
] | train | https://github.com/passwordmaker/java-passwordmaker-lib/blob/18c22fca7dd9a47f08161425b85a5bd257afbb2b/src/main/java/org/daveware/passwordmaker/Database.java#L152-L155 |
liferay/com-liferay-commerce | commerce-payment-api/src/main/java/com/liferay/commerce/payment/model/CommercePaymentMethodGroupRelWrapper.java | CommercePaymentMethodGroupRelWrapper.getDescription | @Override
public String getDescription(String languageId, boolean useDefault) {
return _commercePaymentMethodGroupRel.getDescription(languageId,
useDefault);
} | java | @Override
public String getDescription(String languageId, boolean useDefault) {
return _commercePaymentMethodGroupRel.getDescription(languageId,
useDefault);
} | [
"@",
"Override",
"public",
"String",
"getDescription",
"(",
"String",
"languageId",
",",
"boolean",
"useDefault",
")",
"{",
"return",
"_commercePaymentMethodGroupRel",
".",
"getDescription",
"(",
"languageId",
",",
"useDefault",
")",
";",
"}"
] | Returns the localized description of this commerce payment method group rel in the language, optionally using the default language if no localization exists for the requested language.
@param languageId the ID of the language
@param useDefault whether to use the default language if no localization exists for the requested language
@return the localized description of this commerce payment method group rel | [
"Returns",
"the",
"localized",
"description",
"of",
"this",
"commerce",
"payment",
"method",
"group",
"rel",
"in",
"the",
"language",
"optionally",
"using",
"the",
"default",
"language",
"if",
"no",
"localization",
"exists",
"for",
"the",
"requested",
"language",
... | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-payment-api/src/main/java/com/liferay/commerce/payment/model/CommercePaymentMethodGroupRelWrapper.java#L275-L279 |
ngageoint/geopackage-core-java | src/main/java/mil/nga/geopackage/style/ColorUtils.java | ColorUtils.toColorWithAlpha | public static int toColorWithAlpha(int red, int green, int blue, int alpha) {
validateRGB(red);
validateRGB(green);
validateRGB(blue);
int color = (red & 0xff) << 16 | (green & 0xff) << 8 | (blue & 0xff);
if (alpha != -1) {
validateRGB(alpha);
color = (alpha & 0xff) << 24 | color;
}
return color;
} | java | public static int toColorWithAlpha(int red, int green, int blue, int alpha) {
validateRGB(red);
validateRGB(green);
validateRGB(blue);
int color = (red & 0xff) << 16 | (green & 0xff) << 8 | (blue & 0xff);
if (alpha != -1) {
validateRGB(alpha);
color = (alpha & 0xff) << 24 | color;
}
return color;
} | [
"public",
"static",
"int",
"toColorWithAlpha",
"(",
"int",
"red",
",",
"int",
"green",
",",
"int",
"blue",
",",
"int",
"alpha",
")",
"{",
"validateRGB",
"(",
"red",
")",
";",
"validateRGB",
"(",
"green",
")",
";",
"validateRGB",
"(",
"blue",
")",
";",
... | Convert the RBGA values to a color integer
@param red
red integer color inclusively between 0 and 255
@param green
green integer color inclusively between 0 and 255
@param blue
blue integer color inclusively between 0 and 255
@param alpha
alpha integer color inclusively between 0 and 255, -1 to not
include alpha
@return integer color | [
"Convert",
"the",
"RBGA",
"values",
"to",
"a",
"color",
"integer"
] | train | https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/style/ColorUtils.java#L196-L206 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/spillover/spilloveraction.java | spilloveraction.get | public static spilloveraction get(nitro_service service, String name) throws Exception{
spilloveraction obj = new spilloveraction();
obj.set_name(name);
spilloveraction response = (spilloveraction) obj.get_resource(service);
return response;
} | java | public static spilloveraction get(nitro_service service, String name) throws Exception{
spilloveraction obj = new spilloveraction();
obj.set_name(name);
spilloveraction response = (spilloveraction) obj.get_resource(service);
return response;
} | [
"public",
"static",
"spilloveraction",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"spilloveraction",
"obj",
"=",
"new",
"spilloveraction",
"(",
")",
";",
"obj",
".",
"set_name",
"(",
"name",
")",
";",
"spi... | Use this API to fetch spilloveraction resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"spilloveraction",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/spillover/spilloveraction.java#L265-L270 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/preprocessing/text/KerasTokenizer.java | KerasTokenizer.fromJson | public static KerasTokenizer fromJson(String jsonFileName) throws IOException, InvalidKerasConfigurationException {
String json = new String(Files.readAllBytes(Paths.get(jsonFileName)));
Map<String, Object> tokenizerBaseConfig = parseJsonString(json);
Map<String, Object> tokenizerConfig;
if (tokenizerBaseConfig.containsKey("config"))
tokenizerConfig = (Map<String, Object>) tokenizerBaseConfig.get("config");
else
throw new InvalidKerasConfigurationException("No configuration found for Keras tokenizer");
Integer numWords = (Integer) tokenizerConfig.get("num_words");
String filters = (String) tokenizerConfig.get("filters");
Boolean lower = (Boolean) tokenizerConfig.get("lower");
String split = (String) tokenizerConfig.get("split");
Boolean charLevel = (Boolean) tokenizerConfig.get("char_level");
String oovToken = (String) tokenizerConfig.get("oov_token");
Integer documentCount = (Integer) tokenizerConfig.get("document_count");
@SuppressWarnings("unchecked")
Map<String, Integer> wordCounts = (Map) parseJsonString((String) tokenizerConfig.get("word_counts"));
@SuppressWarnings("unchecked")
Map<String, Integer> wordDocs = (Map) parseJsonString((String) tokenizerConfig.get("word_docs"));
@SuppressWarnings("unchecked")
Map<String, Integer> wordIndex = (Map) parseJsonString((String) tokenizerConfig.get("word_index"));
@SuppressWarnings("unchecked")
Map<Integer, String> indexWord = (Map) parseJsonString((String) tokenizerConfig.get("index_word"));
@SuppressWarnings("unchecked")
Map<Integer, Integer> indexDocs = (Map) parseJsonString((String) tokenizerConfig.get("index_docs"));
KerasTokenizer tokenizer = new KerasTokenizer(numWords, filters, lower, split, charLevel, oovToken);
tokenizer.setDocumentCount(documentCount);
tokenizer.setWordCounts(wordCounts);
tokenizer.setWordDocs(new HashMap<>(wordDocs));
tokenizer.setWordIndex(wordIndex);
tokenizer.setIndexWord(indexWord);
tokenizer.setIndexDocs(indexDocs);
return tokenizer;
} | java | public static KerasTokenizer fromJson(String jsonFileName) throws IOException, InvalidKerasConfigurationException {
String json = new String(Files.readAllBytes(Paths.get(jsonFileName)));
Map<String, Object> tokenizerBaseConfig = parseJsonString(json);
Map<String, Object> tokenizerConfig;
if (tokenizerBaseConfig.containsKey("config"))
tokenizerConfig = (Map<String, Object>) tokenizerBaseConfig.get("config");
else
throw new InvalidKerasConfigurationException("No configuration found for Keras tokenizer");
Integer numWords = (Integer) tokenizerConfig.get("num_words");
String filters = (String) tokenizerConfig.get("filters");
Boolean lower = (Boolean) tokenizerConfig.get("lower");
String split = (String) tokenizerConfig.get("split");
Boolean charLevel = (Boolean) tokenizerConfig.get("char_level");
String oovToken = (String) tokenizerConfig.get("oov_token");
Integer documentCount = (Integer) tokenizerConfig.get("document_count");
@SuppressWarnings("unchecked")
Map<String, Integer> wordCounts = (Map) parseJsonString((String) tokenizerConfig.get("word_counts"));
@SuppressWarnings("unchecked")
Map<String, Integer> wordDocs = (Map) parseJsonString((String) tokenizerConfig.get("word_docs"));
@SuppressWarnings("unchecked")
Map<String, Integer> wordIndex = (Map) parseJsonString((String) tokenizerConfig.get("word_index"));
@SuppressWarnings("unchecked")
Map<Integer, String> indexWord = (Map) parseJsonString((String) tokenizerConfig.get("index_word"));
@SuppressWarnings("unchecked")
Map<Integer, Integer> indexDocs = (Map) parseJsonString((String) tokenizerConfig.get("index_docs"));
KerasTokenizer tokenizer = new KerasTokenizer(numWords, filters, lower, split, charLevel, oovToken);
tokenizer.setDocumentCount(documentCount);
tokenizer.setWordCounts(wordCounts);
tokenizer.setWordDocs(new HashMap<>(wordDocs));
tokenizer.setWordIndex(wordIndex);
tokenizer.setIndexWord(indexWord);
tokenizer.setIndexDocs(indexDocs);
return tokenizer;
} | [
"public",
"static",
"KerasTokenizer",
"fromJson",
"(",
"String",
"jsonFileName",
")",
"throws",
"IOException",
",",
"InvalidKerasConfigurationException",
"{",
"String",
"json",
"=",
"new",
"String",
"(",
"Files",
".",
"readAllBytes",
"(",
"Paths",
".",
"get",
"(",... | Import Keras Tokenizer from JSON file created with `tokenizer.to_json()` in Python.
@param jsonFileName Full path of the JSON file to load
@return Keras Tokenizer instance loaded from JSON
@throws IOException I/O exception
@throws InvalidKerasConfigurationException Invalid Keras configuration | [
"Import",
"Keras",
"Tokenizer",
"from",
"JSON",
"file",
"created",
"with",
"tokenizer",
".",
"to_json",
"()",
"in",
"Python",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/preprocessing/text/KerasTokenizer.java#L107-L145 |
igniterealtime/jbosh | src/main/java/org/igniterealtime/jbosh/ApacheHTTPResponse.java | ApacheHTTPResponse.awaitResponse | private synchronized void awaitResponse() throws BOSHException {
HttpEntity entity = null;
try {
HttpResponse httpResp = client.execute(post, context);
entity = httpResp.getEntity();
byte[] data = EntityUtils.toByteArray(entity);
String encoding = entity.getContentEncoding() != null ?
entity.getContentEncoding().getValue() :
null;
if (ZLIBCodec.getID().equalsIgnoreCase(encoding)) {
data = ZLIBCodec.decode(data);
} else if (GZIPCodec.getID().equalsIgnoreCase(encoding)) {
data = GZIPCodec.decode(data);
}
body = StaticBody.fromString(new String(data, CHARSET));
statusCode = httpResp.getStatusLine().getStatusCode();
sent = true;
} catch (IOException iox) {
abort();
toThrow = new BOSHException("Could not obtain response", iox);
throw(toThrow);
} catch (RuntimeException ex) {
abort();
throw(ex);
}
} | java | private synchronized void awaitResponse() throws BOSHException {
HttpEntity entity = null;
try {
HttpResponse httpResp = client.execute(post, context);
entity = httpResp.getEntity();
byte[] data = EntityUtils.toByteArray(entity);
String encoding = entity.getContentEncoding() != null ?
entity.getContentEncoding().getValue() :
null;
if (ZLIBCodec.getID().equalsIgnoreCase(encoding)) {
data = ZLIBCodec.decode(data);
} else if (GZIPCodec.getID().equalsIgnoreCase(encoding)) {
data = GZIPCodec.decode(data);
}
body = StaticBody.fromString(new String(data, CHARSET));
statusCode = httpResp.getStatusLine().getStatusCode();
sent = true;
} catch (IOException iox) {
abort();
toThrow = new BOSHException("Could not obtain response", iox);
throw(toThrow);
} catch (RuntimeException ex) {
abort();
throw(ex);
}
} | [
"private",
"synchronized",
"void",
"awaitResponse",
"(",
")",
"throws",
"BOSHException",
"{",
"HttpEntity",
"entity",
"=",
"null",
";",
"try",
"{",
"HttpResponse",
"httpResp",
"=",
"client",
".",
"execute",
"(",
"post",
",",
"context",
")",
";",
"entity",
"=... | Await the response, storing the result in the instance variables of
this class when they arrive.
@throws InterruptedException if interrupted while awaiting the response
@throws BOSHException on communication failure | [
"Await",
"the",
"response",
"storing",
"the",
"result",
"in",
"the",
"instance",
"variables",
"of",
"this",
"class",
"when",
"they",
"arrive",
"."
] | train | https://github.com/igniterealtime/jbosh/blob/b43378f27e19b753b552b1e9666abc0476cdceff/src/main/java/org/igniterealtime/jbosh/ApacheHTTPResponse.java#L232-L257 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/flow/FlowPath.java | FlowPath.setRewindPositionOnce | public void setRewindPositionOnce(@NonNull String frameName, int position) {
if (getRewindPosition(frameName) >= 0)
return;
frames.get(frameName).setRewindPosition(position);
} | java | public void setRewindPositionOnce(@NonNull String frameName, int position) {
if (getRewindPosition(frameName) >= 0)
return;
frames.get(frameName).setRewindPosition(position);
} | [
"public",
"void",
"setRewindPositionOnce",
"(",
"@",
"NonNull",
"String",
"frameName",
",",
"int",
"position",
")",
"{",
"if",
"(",
"getRewindPosition",
"(",
"frameName",
")",
">=",
"0",
")",
"return",
";",
"frames",
".",
"get",
"(",
"frameName",
")",
".",... | This method allows to set position for next rewind within graph.
PLEASE NOTE: This methods check, if rewind position wasn't set yet. If it was already set for this frame - it'll be no-op method
@param frameName
@param position | [
"This",
"method",
"allows",
"to",
"set",
"position",
"for",
"next",
"rewind",
"within",
"graph",
".",
"PLEASE",
"NOTE",
":",
"This",
"methods",
"check",
"if",
"rewind",
"position",
"wasn",
"t",
"set",
"yet",
".",
"If",
"it",
"was",
"already",
"set",
"for... | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/flow/FlowPath.java#L208-L213 |
kotcrab/vis-ui | ui/src/main/java/com/kotcrab/vis/ui/FocusManager.java | FocusManager.resetFocus | public static void resetFocus (Stage stage, Actor caller) {
if (focusedWidget != null) focusedWidget.focusLost();
if (stage != null && stage.getKeyboardFocus() == caller) stage.setKeyboardFocus(null);
focusedWidget = null;
} | java | public static void resetFocus (Stage stage, Actor caller) {
if (focusedWidget != null) focusedWidget.focusLost();
if (stage != null && stage.getKeyboardFocus() == caller) stage.setKeyboardFocus(null);
focusedWidget = null;
} | [
"public",
"static",
"void",
"resetFocus",
"(",
"Stage",
"stage",
",",
"Actor",
"caller",
")",
"{",
"if",
"(",
"focusedWidget",
"!=",
"null",
")",
"focusedWidget",
".",
"focusLost",
"(",
")",
";",
"if",
"(",
"stage",
"!=",
"null",
"&&",
"stage",
".",
"g... | Takes focus from current focused widget (if any), and sets current focused widget to null
@param stage if passed stage is not null then stage keyboard focus will be set to null only if current
focus owner is passed actor | [
"Takes",
"focus",
"from",
"current",
"focused",
"widget",
"(",
"if",
"any",
")",
"and",
"sets",
"current",
"focused",
"widget",
"to",
"null"
] | train | https://github.com/kotcrab/vis-ui/blob/3b68f82d94ae32bffa2a3399c63f432e0f4908e0/ui/src/main/java/com/kotcrab/vis/ui/FocusManager.java#L61-L65 |
codelibs/minhash | src/main/java/org/codelibs/minhash/MinHash.java | MinHash.newData | public static Data newData(final Analyzer analyzer, final String text,
final int numOfBits) {
return new Data(analyzer, text, numOfBits);
} | java | public static Data newData(final Analyzer analyzer, final String text,
final int numOfBits) {
return new Data(analyzer, text, numOfBits);
} | [
"public",
"static",
"Data",
"newData",
"(",
"final",
"Analyzer",
"analyzer",
",",
"final",
"String",
"text",
",",
"final",
"int",
"numOfBits",
")",
"{",
"return",
"new",
"Data",
"(",
"analyzer",
",",
"text",
",",
"numOfBits",
")",
";",
"}"
] | Create a target data which has analyzer, text and the number of bits.
@param analyzer
@param text
@param numOfBits
@return | [
"Create",
"a",
"target",
"data",
"which",
"has",
"analyzer",
"text",
"and",
"the",
"number",
"of",
"bits",
"."
] | train | https://github.com/codelibs/minhash/blob/2aaa16e3096461c0f550d0eb462ae9e69d1b7749/src/main/java/org/codelibs/minhash/MinHash.java#L273-L276 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/AppServiceCertificateOrdersInner.java | AppServiceCertificateOrdersInner.createOrUpdateAsync | public Observable<AppServiceCertificateOrderInner> createOrUpdateAsync(String resourceGroupName, String certificateOrderName, AppServiceCertificateOrderInner certificateDistinguishedName) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, certificateOrderName, certificateDistinguishedName).map(new Func1<ServiceResponse<AppServiceCertificateOrderInner>, AppServiceCertificateOrderInner>() {
@Override
public AppServiceCertificateOrderInner call(ServiceResponse<AppServiceCertificateOrderInner> response) {
return response.body();
}
});
} | java | public Observable<AppServiceCertificateOrderInner> createOrUpdateAsync(String resourceGroupName, String certificateOrderName, AppServiceCertificateOrderInner certificateDistinguishedName) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, certificateOrderName, certificateDistinguishedName).map(new Func1<ServiceResponse<AppServiceCertificateOrderInner>, AppServiceCertificateOrderInner>() {
@Override
public AppServiceCertificateOrderInner call(ServiceResponse<AppServiceCertificateOrderInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"AppServiceCertificateOrderInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"certificateOrderName",
",",
"AppServiceCertificateOrderInner",
"certificateDistinguishedName",
")",
"{",
"return",
"createOrUpdateWithSe... | Create or update a certificate purchase order.
Create or update a certificate purchase order.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param certificateOrderName Name of the certificate order.
@param certificateDistinguishedName Distinguished name to to use for the certificate order.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Create",
"or",
"update",
"a",
"certificate",
"purchase",
"order",
".",
"Create",
"or",
"update",
"a",
"certificate",
"purchase",
"order",
"."
] | 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/AppServiceCertificateOrdersInner.java#L623-L630 |
ujmp/universal-java-matrix-package | ujmp-core/src/main/java/org/ujmp/core/util/EuclidianDistance.java | EuclidianDistance.getDistance | public double getDistance(double[] sample1, double[] sample2) throws IllegalArgumentException {
int n = sample1.length;
if (n != sample2.length || n < 1)
throw new IllegalArgumentException("Input arrays must have the same length.");
double sumOfSquares = 0;
for (int i = 0; i < n; i++) {
if (Double.isNaN(sample1[i]) || Double.isNaN(sample2[i]))
continue;
sumOfSquares += (sample1[i] - sample2[i]) * (sample1[i] - sample2[i]);
}
return Math.sqrt(sumOfSquares);
} | java | public double getDistance(double[] sample1, double[] sample2) throws IllegalArgumentException {
int n = sample1.length;
if (n != sample2.length || n < 1)
throw new IllegalArgumentException("Input arrays must have the same length.");
double sumOfSquares = 0;
for (int i = 0; i < n; i++) {
if (Double.isNaN(sample1[i]) || Double.isNaN(sample2[i]))
continue;
sumOfSquares += (sample1[i] - sample2[i]) * (sample1[i] - sample2[i]);
}
return Math.sqrt(sumOfSquares);
} | [
"public",
"double",
"getDistance",
"(",
"double",
"[",
"]",
"sample1",
",",
"double",
"[",
"]",
"sample2",
")",
"throws",
"IllegalArgumentException",
"{",
"int",
"n",
"=",
"sample1",
".",
"length",
";",
"if",
"(",
"n",
"!=",
"sample2",
".",
"length",
"||... | Get the distance between two data samples.
@param sample1
the first sample of <code>double</code> values
@param sample2
the second sample of <code>double</code> values
@return the distance between <code>sample1</code> and
<code>sample2</code>
@throws IllegalArgumentException
if the two samples contain different amounts of values | [
"Get",
"the",
"distance",
"between",
"two",
"data",
"samples",
"."
] | train | https://github.com/ujmp/universal-java-matrix-package/blob/b7e1d293adeadaf35d208ffe8884028d6c06b63b/ujmp-core/src/main/java/org/ujmp/core/util/EuclidianDistance.java#L44-L59 |
grpc/grpc-java | api/src/main/java/io/grpc/ClientInterceptors.java | ClientInterceptors.wrapClientInterceptor | static <WReqT, WRespT> ClientInterceptor wrapClientInterceptor(
final ClientInterceptor interceptor,
final Marshaller<WReqT> reqMarshaller,
final Marshaller<WRespT> respMarshaller) {
return new ClientInterceptor() {
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
final MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) {
final MethodDescriptor<WReqT, WRespT> wrappedMethod =
method.toBuilder(reqMarshaller, respMarshaller).build();
final ClientCall<WReqT, WRespT> wrappedCall =
interceptor.interceptCall(wrappedMethod, callOptions, next);
return new PartialForwardingClientCall<ReqT, RespT>() {
@Override
public void start(final Listener<RespT> responseListener, Metadata headers) {
wrappedCall.start(new PartialForwardingClientCallListener<WRespT>() {
@Override
public void onMessage(WRespT wMessage) {
InputStream bytes = respMarshaller.stream(wMessage);
RespT message = method.getResponseMarshaller().parse(bytes);
responseListener.onMessage(message);
}
@Override
protected Listener<?> delegate() {
return responseListener;
}
}, headers);
}
@Override
public void sendMessage(ReqT message) {
InputStream bytes = method.getRequestMarshaller().stream(message);
WReqT wReq = reqMarshaller.parse(bytes);
wrappedCall.sendMessage(wReq);
}
@Override
protected ClientCall<?, ?> delegate() {
return wrappedCall;
}
};
}
};
} | java | static <WReqT, WRespT> ClientInterceptor wrapClientInterceptor(
final ClientInterceptor interceptor,
final Marshaller<WReqT> reqMarshaller,
final Marshaller<WRespT> respMarshaller) {
return new ClientInterceptor() {
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
final MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) {
final MethodDescriptor<WReqT, WRespT> wrappedMethod =
method.toBuilder(reqMarshaller, respMarshaller).build();
final ClientCall<WReqT, WRespT> wrappedCall =
interceptor.interceptCall(wrappedMethod, callOptions, next);
return new PartialForwardingClientCall<ReqT, RespT>() {
@Override
public void start(final Listener<RespT> responseListener, Metadata headers) {
wrappedCall.start(new PartialForwardingClientCallListener<WRespT>() {
@Override
public void onMessage(WRespT wMessage) {
InputStream bytes = respMarshaller.stream(wMessage);
RespT message = method.getResponseMarshaller().parse(bytes);
responseListener.onMessage(message);
}
@Override
protected Listener<?> delegate() {
return responseListener;
}
}, headers);
}
@Override
public void sendMessage(ReqT message) {
InputStream bytes = method.getRequestMarshaller().stream(message);
WReqT wReq = reqMarshaller.parse(bytes);
wrappedCall.sendMessage(wReq);
}
@Override
protected ClientCall<?, ?> delegate() {
return wrappedCall;
}
};
}
};
} | [
"static",
"<",
"WReqT",
",",
"WRespT",
">",
"ClientInterceptor",
"wrapClientInterceptor",
"(",
"final",
"ClientInterceptor",
"interceptor",
",",
"final",
"Marshaller",
"<",
"WReqT",
">",
"reqMarshaller",
",",
"final",
"Marshaller",
"<",
"WRespT",
">",
"respMarshalle... | Creates a new ClientInterceptor that transforms requests into {@code WReqT} and responses into
{@code WRespT} before passing them into the {@code interceptor}. | [
"Creates",
"a",
"new",
"ClientInterceptor",
"that",
"transforms",
"requests",
"into",
"{"
] | train | https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/ClientInterceptors.java#L98-L142 |
EdwardRaff/JSAT | JSAT/src/jsat/io/CSV.java | CSV.readR | public static RegressionDataSet readR(int numeric_target_column, Reader reader, char delimiter, int lines_to_skip, char comment, Set<Integer> cat_cols) throws IOException
{
return (RegressionDataSet) readCSV(reader, lines_to_skip, delimiter, comment, cat_cols, numeric_target_column, -1);
} | java | public static RegressionDataSet readR(int numeric_target_column, Reader reader, char delimiter, int lines_to_skip, char comment, Set<Integer> cat_cols) throws IOException
{
return (RegressionDataSet) readCSV(reader, lines_to_skip, delimiter, comment, cat_cols, numeric_target_column, -1);
} | [
"public",
"static",
"RegressionDataSet",
"readR",
"(",
"int",
"numeric_target_column",
",",
"Reader",
"reader",
",",
"char",
"delimiter",
",",
"int",
"lines_to_skip",
",",
"char",
"comment",
",",
"Set",
"<",
"Integer",
">",
"cat_cols",
")",
"throws",
"IOExceptio... | Reads in a CSV dataset as a regression dataset.
@param numeric_target_column the column index (starting from zero) of the
feature that will be the target regression value
@param reader the reader for the CSV content
@param delimiter the delimiter to separate columns, usually a comma
@param lines_to_skip the number of lines to skip when reading in the CSV
(used to skip header information)
@param comment the character used to indicate the start of a comment.
Once this character is reached, anything at and after the character will
be ignored.
@param cat_cols a set of the indices to treat as categorical features.
@return the regression dataset from the given CSV file
@throws IOException | [
"Reads",
"in",
"a",
"CSV",
"dataset",
"as",
"a",
"regression",
"dataset",
"."
] | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/io/CSV.java#L136-L139 |
javagl/ND | nd-tuples/src/main/java/de/javagl/nd/tuples/Utils.java | Utils.checkForValidIndex | public static void checkForValidIndex(int index, int size)
{
if (index < 0)
{
throw new IndexOutOfBoundsException(
"Index "+index+" is negative");
}
if (index >= size)
{
throw new IndexOutOfBoundsException(
"Index "+index+", size "+size);
}
} | java | public static void checkForValidIndex(int index, int size)
{
if (index < 0)
{
throw new IndexOutOfBoundsException(
"Index "+index+" is negative");
}
if (index >= size)
{
throw new IndexOutOfBoundsException(
"Index "+index+", size "+size);
}
} | [
"public",
"static",
"void",
"checkForValidIndex",
"(",
"int",
"index",
",",
"int",
"size",
")",
"{",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"Index \"",
"+",
"index",
"+",
"\" is negative\"",
")",
";",
"}... | Checks whether the given index is valid for accessing a tuple with
the given size, and throws an <code>IndexOutOfBoundsException</code>
if not.
@param index The index
@param size The size
@throws IndexOutOfBoundsException If the given index is negative
or not smaller than then given size | [
"Checks",
"whether",
"the",
"given",
"index",
"is",
"valid",
"for",
"accessing",
"a",
"tuple",
"with",
"the",
"given",
"size",
"and",
"throws",
"an",
"<code",
">",
"IndexOutOfBoundsException<",
"/",
"code",
">",
"if",
"not",
"."
] | train | https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-tuples/src/main/java/de/javagl/nd/tuples/Utils.java#L100-L112 |
UrielCh/ovh-java-sdk | ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java | ApiOvhXdsl.serviceName_modem_connectedDevices_macAddress_GET | public OvhConnectedDevice serviceName_modem_connectedDevices_macAddress_GET(String serviceName, String macAddress) throws IOException {
String qPath = "/xdsl/{serviceName}/modem/connectedDevices/{macAddress}";
StringBuilder sb = path(qPath, serviceName, macAddress);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhConnectedDevice.class);
} | java | public OvhConnectedDevice serviceName_modem_connectedDevices_macAddress_GET(String serviceName, String macAddress) throws IOException {
String qPath = "/xdsl/{serviceName}/modem/connectedDevices/{macAddress}";
StringBuilder sb = path(qPath, serviceName, macAddress);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhConnectedDevice.class);
} | [
"public",
"OvhConnectedDevice",
"serviceName_modem_connectedDevices_macAddress_GET",
"(",
"String",
"serviceName",
",",
"String",
"macAddress",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/xdsl/{serviceName}/modem/connectedDevices/{macAddress}\"",
";",
"StringBu... | Get this object properties
REST: GET /xdsl/{serviceName}/modem/connectedDevices/{macAddress}
@param serviceName [required] The internal name of your XDSL offer
@param macAddress [required] MAC address of the device | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java#L1371-L1376 |
oaqa/uima-ecd | src/main/java/edu/cmu/lti/oaqa/ecd/driver/SimplePipelineRev803.java | SimplePipelineRev803.runPipeline | public static void runPipeline(final CAS aCas, final AnalysisEngineDescription... aDescs)
throws UIMAException, IOException {
// Create aggregate AE
final AnalysisEngineDescription aaeDesc = createAggregateDescription(aDescs);
// Instantiate
final AnalysisEngine aae = createAggregate(aaeDesc);
try {
// Process
aae.process(aCas);
// Signal end of processing
aae.collectionProcessComplete();
}
finally {
// Destroy
aae.destroy();
}
} | java | public static void runPipeline(final CAS aCas, final AnalysisEngineDescription... aDescs)
throws UIMAException, IOException {
// Create aggregate AE
final AnalysisEngineDescription aaeDesc = createAggregateDescription(aDescs);
// Instantiate
final AnalysisEngine aae = createAggregate(aaeDesc);
try {
// Process
aae.process(aCas);
// Signal end of processing
aae.collectionProcessComplete();
}
finally {
// Destroy
aae.destroy();
}
} | [
"public",
"static",
"void",
"runPipeline",
"(",
"final",
"CAS",
"aCas",
",",
"final",
"AnalysisEngineDescription",
"...",
"aDescs",
")",
"throws",
"UIMAException",
",",
"IOException",
"{",
"// Create aggregate AE",
"final",
"AnalysisEngineDescription",
"aaeDesc",
"=",
... | Run a sequence of {@link AnalysisEngine analysis engines} over a {@link JCas}. The result of
the analysis can be read from the JCas.
@param aCas
the CAS to process
@param aDescs
a sequence of analysis engines to run on the jCas
@throws UIMAException
@throws IOException | [
"Run",
"a",
"sequence",
"of",
"{",
"@link",
"AnalysisEngine",
"analysis",
"engines",
"}",
"over",
"a",
"{",
"@link",
"JCas",
"}",
".",
"The",
"result",
"of",
"the",
"analysis",
"can",
"be",
"read",
"from",
"the",
"JCas",
"."
] | train | https://github.com/oaqa/uima-ecd/blob/09a0ae26647490b43affc36ab3a01100702b989f/src/main/java/edu/cmu/lti/oaqa/ecd/driver/SimplePipelineRev803.java#L177-L195 |
wcm-io/wcm-io-handler | richtext/src/main/java/io/wcm/handler/richtext/DefaultRewriteContentHandler.java | DefaultRewriteContentHandler.getAnchorLegacyMetadataFromSingleData | private boolean getAnchorLegacyMetadataFromSingleData(ValueMap resourceProps, Element element) {
boolean foundAny = false;
JSONObject metadata = null;
Attribute dataAttribute = element.getAttribute("data");
if (dataAttribute != null) {
String metadataString = dataAttribute.getValue();
if (StringUtils.isNotEmpty(metadataString)) {
try {
metadata = new JSONObject(metadataString);
}
catch (JSONException ex) {
log.debug("Invalid link metadata: " + metadataString, ex);
}
}
}
if (metadata != null) {
JSONArray names = metadata.names();
for (int i = 0; i < names.length(); i++) {
String name = names.optString(i);
resourceProps.put(name, metadata.opt(name));
foundAny = true;
}
}
return foundAny;
} | java | private boolean getAnchorLegacyMetadataFromSingleData(ValueMap resourceProps, Element element) {
boolean foundAny = false;
JSONObject metadata = null;
Attribute dataAttribute = element.getAttribute("data");
if (dataAttribute != null) {
String metadataString = dataAttribute.getValue();
if (StringUtils.isNotEmpty(metadataString)) {
try {
metadata = new JSONObject(metadataString);
}
catch (JSONException ex) {
log.debug("Invalid link metadata: " + metadataString, ex);
}
}
}
if (metadata != null) {
JSONArray names = metadata.names();
for (int i = 0; i < names.length(); i++) {
String name = names.optString(i);
resourceProps.put(name, metadata.opt(name));
foundAny = true;
}
}
return foundAny;
} | [
"private",
"boolean",
"getAnchorLegacyMetadataFromSingleData",
"(",
"ValueMap",
"resourceProps",
",",
"Element",
"element",
")",
"{",
"boolean",
"foundAny",
"=",
"false",
";",
"JSONObject",
"metadata",
"=",
"null",
";",
"Attribute",
"dataAttribute",
"=",
"element",
... | Support legacy data structures where link metadata is stored as JSON fragment in single HTML5 data attribute.
@param resourceProps ValueMap to write link metadata to
@param element Link element | [
"Support",
"legacy",
"data",
"structures",
"where",
"link",
"metadata",
"is",
"stored",
"as",
"JSON",
"fragment",
"in",
"single",
"HTML5",
"data",
"attribute",
"."
] | train | https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/richtext/src/main/java/io/wcm/handler/richtext/DefaultRewriteContentHandler.java#L257-L283 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/rules/constraint/Constraints.java | Constraints.ifTrue | public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint, String type) {
return new ConditionalPropertyConstraint(ifConstraint, thenConstraint, type);
} | java | public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint, String type) {
return new ConditionalPropertyConstraint(ifConstraint, thenConstraint, type);
} | [
"public",
"PropertyConstraint",
"ifTrue",
"(",
"PropertyConstraint",
"ifConstraint",
",",
"PropertyConstraint",
"thenConstraint",
",",
"String",
"type",
")",
"{",
"return",
"new",
"ConditionalPropertyConstraint",
"(",
"ifConstraint",
",",
"thenConstraint",
",",
"type",
... | Returns a ConditionalPropertyConstraint: one property will trigger the
validation of another.
@see ConditionalPropertyConstraint | [
"Returns",
"a",
"ConditionalPropertyConstraint",
":",
"one",
"property",
"will",
"trigger",
"the",
"validation",
"of",
"another",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/rules/constraint/Constraints.java#L318-L320 |
playn/playn | scene/src/playn/scene/Layer.java | Layer.setOrigin | public Layer setOrigin (float x, float y) {
this.originX = x;
this.originY = y;
this.origin = Origin.FIXED;
setFlag(Flag.ODIRTY, false);
return this;
} | java | public Layer setOrigin (float x, float y) {
this.originX = x;
this.originY = y;
this.origin = Origin.FIXED;
setFlag(Flag.ODIRTY, false);
return this;
} | [
"public",
"Layer",
"setOrigin",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"this",
".",
"originX",
"=",
"x",
";",
"this",
".",
"originY",
"=",
"y",
";",
"this",
".",
"origin",
"=",
"Origin",
".",
"FIXED",
";",
"setFlag",
"(",
"Flag",
".",
"O... | Sets the origin of the layer to a fixed position. This automatically sets the layer's logical
origin to {@link Origin#FIXED}.
@param x origin on x axis in display units.
@param y origin on y axis in display units.
@return a reference to this layer for call chaining. | [
"Sets",
"the",
"origin",
"of",
"the",
"layer",
"to",
"a",
"fixed",
"position",
".",
"This",
"automatically",
"sets",
"the",
"layer",
"s",
"logical",
"origin",
"to",
"{",
"@link",
"Origin#FIXED",
"}",
"."
] | train | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/Layer.java#L387-L393 |
SonarSource/sonarqube | sonar-duplications/src/main/java/org/sonar/duplications/detector/original/Filter.java | Filter.add | public void add(CloneGroup current) {
Iterator<CloneGroup> i = filtered.iterator();
while (i.hasNext()) {
CloneGroup earlier = i.next();
// Note that following two conditions cannot be true together - proof by contradiction:
// let C be the current clone and A and B were found earlier
// then since relation is transitive - (A in C) and (C in B) => (A in B)
// so A should be filtered earlier
if (Filter.containsIn(current, earlier)) {
// current clone fully covered by clone, which was found earlier
return;
}
if (Filter.containsIn(earlier, current)) {
// current clone fully covers clone, which was found earlier
i.remove();
}
}
filtered.add(current);
} | java | public void add(CloneGroup current) {
Iterator<CloneGroup> i = filtered.iterator();
while (i.hasNext()) {
CloneGroup earlier = i.next();
// Note that following two conditions cannot be true together - proof by contradiction:
// let C be the current clone and A and B were found earlier
// then since relation is transitive - (A in C) and (C in B) => (A in B)
// so A should be filtered earlier
if (Filter.containsIn(current, earlier)) {
// current clone fully covered by clone, which was found earlier
return;
}
if (Filter.containsIn(earlier, current)) {
// current clone fully covers clone, which was found earlier
i.remove();
}
}
filtered.add(current);
} | [
"public",
"void",
"add",
"(",
"CloneGroup",
"current",
")",
"{",
"Iterator",
"<",
"CloneGroup",
">",
"i",
"=",
"filtered",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"CloneGroup",
"earlier",
"=",
"i",
".",
... | Running time - O(N*2*C), where N - number of clones, which was found earlier and C - time of {@link #containsIn(CloneGroup, CloneGroup)}. | [
"Running",
"time",
"-",
"O",
"(",
"N",
"*",
"2",
"*",
"C",
")",
"where",
"N",
"-",
"number",
"of",
"clones",
"which",
"was",
"found",
"earlier",
"and",
"C",
"-",
"time",
"of",
"{"
] | train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/Filter.java#L61-L79 |
geomajas/geomajas-project-client-gwt2 | impl/src/main/java/org/geomajas/gwt2/client/controller/TouchNavigationController.java | TouchNavigationController.calculatePosition | protected Coordinate calculatePosition(double scale, Coordinate rescalePoint) {
ViewPort viewPort = mapPresenter.getViewPort();
Coordinate position = viewPort.getPosition();
double dX = (rescalePoint.getX() - position.getX()) * (1 - 1 / scale);
double dY = (rescalePoint.getY() - position.getY()) * (1 - 1 / scale);
return new Coordinate(position.getX() + dX, position.getY() + dY);
} | java | protected Coordinate calculatePosition(double scale, Coordinate rescalePoint) {
ViewPort viewPort = mapPresenter.getViewPort();
Coordinate position = viewPort.getPosition();
double dX = (rescalePoint.getX() - position.getX()) * (1 - 1 / scale);
double dY = (rescalePoint.getY() - position.getY()) * (1 - 1 / scale);
return new Coordinate(position.getX() + dX, position.getY() + dY);
} | [
"protected",
"Coordinate",
"calculatePosition",
"(",
"double",
"scale",
",",
"Coordinate",
"rescalePoint",
")",
"{",
"ViewPort",
"viewPort",
"=",
"mapPresenter",
".",
"getViewPort",
"(",
")",
";",
"Coordinate",
"position",
"=",
"viewPort",
".",
"getPosition",
"(",... | Calculate the target position should there be a rescale point. The idea is that after zooming in or out, the
mouse cursor would still lie at the same position in world space. | [
"Calculate",
"the",
"target",
"position",
"should",
"there",
"be",
"a",
"rescale",
"point",
".",
"The",
"idea",
"is",
"that",
"after",
"zooming",
"in",
"or",
"out",
"the",
"mouse",
"cursor",
"would",
"still",
"lie",
"at",
"the",
"same",
"position",
"in",
... | train | https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/impl/src/main/java/org/geomajas/gwt2/client/controller/TouchNavigationController.java#L108-L114 |
aws/aws-sdk-java | aws-java-sdk-lambda/src/main/java/com/amazonaws/services/lambda/model/Environment.java | Environment.withVariables | public Environment withVariables(java.util.Map<String, String> variables) {
setVariables(variables);
return this;
} | java | public Environment withVariables(java.util.Map<String, String> variables) {
setVariables(variables);
return this;
} | [
"public",
"Environment",
"withVariables",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"variables",
")",
"{",
"setVariables",
"(",
"variables",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Environment variable key-value pairs.
</p>
@param variables
Environment variable key-value pairs.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Environment",
"variable",
"key",
"-",
"value",
"pairs",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-lambda/src/main/java/com/amazonaws/services/lambda/model/Environment.java#L76-L79 |
maxirosson/jdroid-android | jdroid-android-sqlite/src/main/java/com/jdroid/android/sqlite/repository/SQLiteRepository.java | SQLiteRepository.replaceChildren | public static <T extends Entity> void replaceChildren(List<T> list, String parentId, Class<T> clazz) {
SQLiteRepository<T> repository = (SQLiteRepository<T>)AbstractApplication.get().getRepositoryInstance(clazz);
repository.replaceChildren(list, parentId);
} | java | public static <T extends Entity> void replaceChildren(List<T> list, String parentId, Class<T> clazz) {
SQLiteRepository<T> repository = (SQLiteRepository<T>)AbstractApplication.get().getRepositoryInstance(clazz);
repository.replaceChildren(list, parentId);
} | [
"public",
"static",
"<",
"T",
"extends",
"Entity",
">",
"void",
"replaceChildren",
"(",
"List",
"<",
"T",
">",
"list",
",",
"String",
"parentId",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"SQLiteRepository",
"<",
"T",
">",
"repository",
"=",
"(",... | This method allows to replace all entity children of a given parent, it will remove any children which are not in
the list, add the new ones and update which are in the list..
@param list of children to replace.
@param parentId id of parent entity.
@param clazz entity class. | [
"This",
"method",
"allows",
"to",
"replace",
"all",
"entity",
"children",
"of",
"a",
"given",
"parent",
"it",
"will",
"remove",
"any",
"children",
"which",
"are",
"not",
"in",
"the",
"list",
"add",
"the",
"new",
"ones",
"and",
"update",
"which",
"are",
"... | train | https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-sqlite/src/main/java/com/jdroid/android/sqlite/repository/SQLiteRepository.java#L443-L446 |
threerings/nenya | tools/src/main/java/com/threerings/media/tile/tools/xml/XMLTileSetParser.java | XMLTileSetParser.loadTileSets | public void loadTileSets (InputStream source, Map<String, TileSet> tilesets)
throws IOException
{
// stick an array list on the top of the stack for collecting
// parsed tilesets
List<TileSet> setlist = Lists.newArrayList();
_digester.push(setlist);
// now fire up the digester to parse the stream
try {
_digester.parse(source);
} catch (SAXException saxe) {
log.warning("Exception parsing tile set descriptions.", saxe);
}
// stick the tilesets from the list into the hashtable
for (int ii = 0; ii < setlist.size(); ii++) {
TileSet set = setlist.get(ii);
if (set.getName() == null) {
log.warning("Tileset did not receive name during " +
"parsing process [set=" + set + "].");
} else {
tilesets.put(set.getName(), set);
}
}
// and clear out the list for next time
setlist.clear();
} | java | public void loadTileSets (InputStream source, Map<String, TileSet> tilesets)
throws IOException
{
// stick an array list on the top of the stack for collecting
// parsed tilesets
List<TileSet> setlist = Lists.newArrayList();
_digester.push(setlist);
// now fire up the digester to parse the stream
try {
_digester.parse(source);
} catch (SAXException saxe) {
log.warning("Exception parsing tile set descriptions.", saxe);
}
// stick the tilesets from the list into the hashtable
for (int ii = 0; ii < setlist.size(); ii++) {
TileSet set = setlist.get(ii);
if (set.getName() == null) {
log.warning("Tileset did not receive name during " +
"parsing process [set=" + set + "].");
} else {
tilesets.put(set.getName(), set);
}
}
// and clear out the list for next time
setlist.clear();
} | [
"public",
"void",
"loadTileSets",
"(",
"InputStream",
"source",
",",
"Map",
"<",
"String",
",",
"TileSet",
">",
"tilesets",
")",
"throws",
"IOException",
"{",
"// stick an array list on the top of the stack for collecting",
"// parsed tilesets",
"List",
"<",
"TileSet",
... | Loads all of the tilesets specified in the supplied XML tileset
description file and places them into the supplied map indexed
by tileset name. This method is not reentrant, so don't go calling
it from multiple threads.
@param source an input stream from which the tileset definition
file can be read.
@param tilesets the map into which the tilesets will be placed,
indexed by tileset name. | [
"Loads",
"all",
"of",
"the",
"tilesets",
"specified",
"in",
"the",
"supplied",
"XML",
"tileset",
"description",
"file",
"and",
"places",
"them",
"into",
"the",
"supplied",
"map",
"indexed",
"by",
"tileset",
"name",
".",
"This",
"method",
"is",
"not",
"reentr... | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/tools/src/main/java/com/threerings/media/tile/tools/xml/XMLTileSetParser.java#L141-L169 |
JodaOrg/joda-time | src/main/java/org/joda/time/tz/ZoneInfoProvider.java | ZoneInfoProvider.openResource | @SuppressWarnings("resource")
private InputStream openResource(String name) throws IOException {
InputStream in;
if (iFileDir != null) {
in = new FileInputStream(new File(iFileDir, name));
} else {
final String path = iResourcePath.concat(name);
in = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
public InputStream run() {
if (iLoader != null) {
return iLoader.getResourceAsStream(path);
} else {
return ClassLoader.getSystemResourceAsStream(path);
}
}
});
if (in == null) {
StringBuilder buf = new StringBuilder(40)
.append("Resource not found: \"")
.append(path)
.append("\" ClassLoader: ")
.append(iLoader != null ? iLoader.toString() : "system");
throw new IOException(buf.toString());
}
}
return in;
} | java | @SuppressWarnings("resource")
private InputStream openResource(String name) throws IOException {
InputStream in;
if (iFileDir != null) {
in = new FileInputStream(new File(iFileDir, name));
} else {
final String path = iResourcePath.concat(name);
in = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
public InputStream run() {
if (iLoader != null) {
return iLoader.getResourceAsStream(path);
} else {
return ClassLoader.getSystemResourceAsStream(path);
}
}
});
if (in == null) {
StringBuilder buf = new StringBuilder(40)
.append("Resource not found: \"")
.append(path)
.append("\" ClassLoader: ")
.append(iLoader != null ? iLoader.toString() : "system");
throw new IOException(buf.toString());
}
}
return in;
} | [
"@",
"SuppressWarnings",
"(",
"\"resource\"",
")",
"private",
"InputStream",
"openResource",
"(",
"String",
"name",
")",
"throws",
"IOException",
"{",
"InputStream",
"in",
";",
"if",
"(",
"iFileDir",
"!=",
"null",
")",
"{",
"in",
"=",
"new",
"FileInputStream",... | Opens a resource from file or classpath.
@param name the name to open
@return the input stream
@throws IOException if an error occurs | [
"Opens",
"a",
"resource",
"from",
"file",
"or",
"classpath",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/tz/ZoneInfoProvider.java#L203-L229 |
sporniket/core | sporniket-core-lang/src/main/java/com/sporniket/libre/lang/functor/FunctorFactory.java | FunctorFactory.instanciateFunctorWithParameterAsAnInstanceMethodWrapper | public static FunctorWithParameter instanciateFunctorWithParameterAsAnInstanceMethodWrapper(final Object instance,
String methodName) throws Exception
{
if (null == instance)
{
throw new NullPointerException("Instance is null");
}
Method _method = instance.getClass().getMethod(methodName, (Class<?>[]) null);
return instanciateFunctorWithParameterAsAMethodWrapper(instance, _method);
} | java | public static FunctorWithParameter instanciateFunctorWithParameterAsAnInstanceMethodWrapper(final Object instance,
String methodName) throws Exception
{
if (null == instance)
{
throw new NullPointerException("Instance is null");
}
Method _method = instance.getClass().getMethod(methodName, (Class<?>[]) null);
return instanciateFunctorWithParameterAsAMethodWrapper(instance, _method);
} | [
"public",
"static",
"FunctorWithParameter",
"instanciateFunctorWithParameterAsAnInstanceMethodWrapper",
"(",
"final",
"Object",
"instance",
",",
"String",
"methodName",
")",
"throws",
"Exception",
"{",
"if",
"(",
"null",
"==",
"instance",
")",
"{",
"throw",
"new",
"Nu... | Create a functor with parameter, wrapping a call to another method.
@param instance
instance to call the method upon. Should not be null.
@param methodName
Name of the method, it must exist.
@return a Functor with parameter that call the specified method on the specified instance.
@throws Exception if there is a problem to deal with. | [
"Create",
"a",
"functor",
"with",
"parameter",
"wrapping",
"a",
"call",
"to",
"another",
"method",
"."
] | train | https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/functor/FunctorFactory.java#L175-L184 |
carewebframework/carewebframework-vista | org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/RPCParameter.java | RPCParameter.put | public void put(Object[] subscript, Object value) {
put(BrokerUtil.buildSubscript(subscript), value);
} | java | public void put(Object[] subscript, Object value) {
put(BrokerUtil.buildSubscript(subscript), value);
} | [
"public",
"void",
"put",
"(",
"Object",
"[",
"]",
"subscript",
",",
"Object",
"value",
")",
"{",
"put",
"(",
"BrokerUtil",
".",
"buildSubscript",
"(",
"subscript",
")",
",",
"value",
")",
";",
"}"
] | Adds a vector value at the specified subscript.
@param subscript Array of subscript values.
@param value Value. | [
"Adds",
"a",
"vector",
"value",
"at",
"the",
"specified",
"subscript",
"."
] | train | https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/RPCParameter.java#L186-L188 |
reapzor/FiloFirmata | src/main/java/com/bortbort/arduino/FiloFirmata/Firmata.java | Firmata.sendMessageSynchronous | public <T extends Message> T sendMessageSynchronous(Class<T> responseType, TransmittableMessage message) {
T responseMessage = null;
SynchronousMessageListener<T> messageListener = new SynchronousMessageListener<>(responseType);
addMessageListener(messageListener);
if (sendMessage(message)) {
if (messageListener.waitForResponse()) {
responseMessage = messageListener.getResponseMessage();
}
}
removeMessageListener(messageListener);
return responseMessage;
} | java | public <T extends Message> T sendMessageSynchronous(Class<T> responseType, TransmittableMessage message) {
T responseMessage = null;
SynchronousMessageListener<T> messageListener = new SynchronousMessageListener<>(responseType);
addMessageListener(messageListener);
if (sendMessage(message)) {
if (messageListener.waitForResponse()) {
responseMessage = messageListener.getResponseMessage();
}
}
removeMessageListener(messageListener);
return responseMessage;
} | [
"public",
"<",
"T",
"extends",
"Message",
">",
"T",
"sendMessageSynchronous",
"(",
"Class",
"<",
"T",
">",
"responseType",
",",
"TransmittableMessage",
"message",
")",
"{",
"T",
"responseMessage",
"=",
"null",
";",
"SynchronousMessageListener",
"<",
"T",
">",
... | Send a Message over the serial port and block/wait for the message response.
In cases where you do not need ASync behavior, or just want to send a single message and
handle a single response, where the async design may be a bit too verbose, use this instead.
By sending a message and dictacting the type of response, you will get the response message as the return
value, or null if the message was not received within the timeout blocking period.
@param message TransmittableMessage to be sent over the serial port
@param <T> Message type that you are expecting as a reply to the message being transmitted.
@return T message object if the project board sends a reply. null if no reply was sent in time. | [
"Send",
"a",
"Message",
"over",
"the",
"serial",
"port",
"and",
"block",
"/",
"wait",
"for",
"the",
"message",
"response",
".",
"In",
"cases",
"where",
"you",
"do",
"not",
"need",
"ASync",
"behavior",
"or",
"just",
"want",
"to",
"send",
"a",
"single",
... | train | https://github.com/reapzor/FiloFirmata/blob/39c26c1a577b8fff8690245e105cb62e02284f16/src/main/java/com/bortbort/arduino/FiloFirmata/Firmata.java#L346-L361 |
paymill/paymill-java | src/main/java/com/paymill/services/TransactionService.java | TransactionService.createWithToken | public Transaction createWithToken( String token, Integer amount, String currency, String description ) {
return this.createWithTokenAndFee( token, amount, currency, description, null );
} | java | public Transaction createWithToken( String token, Integer amount, String currency, String description ) {
return this.createWithTokenAndFee( token, amount, currency, description, null );
} | [
"public",
"Transaction",
"createWithToken",
"(",
"String",
"token",
",",
"Integer",
"amount",
",",
"String",
"currency",
",",
"String",
"description",
")",
"{",
"return",
"this",
".",
"createWithTokenAndFee",
"(",
"token",
",",
"amount",
",",
"currency",
",",
... | Executes a {@link Transaction} with token for the given amount in the given currency.
@param token
Token generated by PAYMILL Bridge, which represents a credit card or direct debit.
@param amount
Amount (in cents) which will be charged.
@param currency
ISO 4217 formatted currency code.
@param description
A short description for the transaction.
@return {@link Transaction} object indicating whether a the call was successful or not. | [
"Executes",
"a",
"{"
] | train | https://github.com/paymill/paymill-java/blob/17281a0d4376c76f1711af9f09bfc138c90ba65a/src/main/java/com/paymill/services/TransactionService.java#L127-L129 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/compiler/Compiler.java | Compiler.compileExtension | private Expression compileExtension(int opPos)
throws TransformerException
{
int endExtFunc = opPos + getOp(opPos + 1) - 1;
opPos = getFirstChildPos(opPos);
java.lang.String ns = (java.lang.String) getTokenQueue().elementAt(getOp(opPos));
opPos++;
java.lang.String funcName =
(java.lang.String) getTokenQueue().elementAt(getOp(opPos));
opPos++;
// We create a method key to uniquely identify this function so that we
// can cache the object needed to invoke it. This way, we only pay the
// reflection overhead on the first call.
Function extension = new FuncExtFunction(ns, funcName, String.valueOf(getNextMethodId()));
try
{
int i = 0;
while (opPos < endExtFunc)
{
int nextOpPos = getNextOpPos(opPos);
extension.setArg(this.compile(opPos), i);
opPos = nextOpPos;
i++;
}
}
catch (WrongNumberArgsException wnae)
{
; // should never happen
}
return extension;
} | java | private Expression compileExtension(int opPos)
throws TransformerException
{
int endExtFunc = opPos + getOp(opPos + 1) - 1;
opPos = getFirstChildPos(opPos);
java.lang.String ns = (java.lang.String) getTokenQueue().elementAt(getOp(opPos));
opPos++;
java.lang.String funcName =
(java.lang.String) getTokenQueue().elementAt(getOp(opPos));
opPos++;
// We create a method key to uniquely identify this function so that we
// can cache the object needed to invoke it. This way, we only pay the
// reflection overhead on the first call.
Function extension = new FuncExtFunction(ns, funcName, String.valueOf(getNextMethodId()));
try
{
int i = 0;
while (opPos < endExtFunc)
{
int nextOpPos = getNextOpPos(opPos);
extension.setArg(this.compile(opPos), i);
opPos = nextOpPos;
i++;
}
}
catch (WrongNumberArgsException wnae)
{
; // should never happen
}
return extension;
} | [
"private",
"Expression",
"compileExtension",
"(",
"int",
"opPos",
")",
"throws",
"TransformerException",
"{",
"int",
"endExtFunc",
"=",
"opPos",
"+",
"getOp",
"(",
"opPos",
"+",
"1",
")",
"-",
"1",
";",
"opPos",
"=",
"getFirstChildPos",
"(",
"opPos",
")",
... | Compile an extension function.
@param opPos The current position in the m_opMap array.
@return reference to {@link org.apache.xpath.functions.FuncExtFunction} instance.
@throws TransformerException if a error occurs creating the Expression. | [
"Compile",
"an",
"extension",
"function",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/compiler/Compiler.java#L1100-L1144 |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/SpriteManager.java | SpriteManager.getHighestHitSprite | public Sprite getHighestHitSprite (int x, int y)
{
// since they're stored in lowest -> highest order..
for (int ii = _sprites.size() - 1; ii >= 0; ii--) {
Sprite sprite = _sprites.get(ii);
if (sprite.hitTest(x, y)) {
return sprite;
}
}
return null;
} | java | public Sprite getHighestHitSprite (int x, int y)
{
// since they're stored in lowest -> highest order..
for (int ii = _sprites.size() - 1; ii >= 0; ii--) {
Sprite sprite = _sprites.get(ii);
if (sprite.hitTest(x, y)) {
return sprite;
}
}
return null;
} | [
"public",
"Sprite",
"getHighestHitSprite",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"// since they're stored in lowest -> highest order..",
"for",
"(",
"int",
"ii",
"=",
"_sprites",
".",
"size",
"(",
")",
"-",
"1",
";",
"ii",
">=",
"0",
";",
"ii",
"--",... | Finds the sprite with the highest render order that hits the specified pixel.
@param x the x (screen) coordinate to be checked
@param y the y (screen) coordinate to be checked
@return the highest sprite hit | [
"Finds",
"the",
"sprite",
"with",
"the",
"highest",
"render",
"order",
"that",
"hits",
"the",
"specified",
"pixel",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/SpriteManager.java#L89-L99 |
kaazing/gateway | management/src/main/java/org/kaazing/gateway/management/gateway/GatewayManagementBeanImpl.java | GatewayManagementBeanImpl.doExceptionCaughtListeners | @Override
public void doExceptionCaughtListeners(final long sessionId, final Throwable cause) {
runManagementTask(new Runnable() {
@Override
public void run() {
try {
// The particular management listeners change on strategy, so get them here.
for (final GatewayManagementListener listener : getManagementListeners()) {
listener.doExceptionCaught(GatewayManagementBeanImpl.this, sessionId);
}
markChanged(); // mark ourselves as changed, possibly tell listeners
} catch (Exception ex) {
logger.warn("Error during exceptionCaught gateway listener notifications:", ex);
}
}
});
} | java | @Override
public void doExceptionCaughtListeners(final long sessionId, final Throwable cause) {
runManagementTask(new Runnable() {
@Override
public void run() {
try {
// The particular management listeners change on strategy, so get them here.
for (final GatewayManagementListener listener : getManagementListeners()) {
listener.doExceptionCaught(GatewayManagementBeanImpl.this, sessionId);
}
markChanged(); // mark ourselves as changed, possibly tell listeners
} catch (Exception ex) {
logger.warn("Error during exceptionCaught gateway listener notifications:", ex);
}
}
});
} | [
"@",
"Override",
"public",
"void",
"doExceptionCaughtListeners",
"(",
"final",
"long",
"sessionId",
",",
"final",
"Throwable",
"cause",
")",
"{",
"runManagementTask",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
... | Notify the management listeners on a filterWrite.
<p/>
NOTE: this starts on the IO thread, but runs a task OFF the thread. | [
"Notify",
"the",
"management",
"listeners",
"on",
"a",
"filterWrite",
".",
"<p",
"/",
">",
"NOTE",
":",
"this",
"starts",
"on",
"the",
"IO",
"thread",
"but",
"runs",
"a",
"task",
"OFF",
"the",
"thread",
"."
] | train | https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/management/src/main/java/org/kaazing/gateway/management/gateway/GatewayManagementBeanImpl.java#L560-L577 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java | WTreeRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WTree tree = (WTree) component;
XmlStringBuilder xml = renderContext.getWriter();
// Check if rendering an open item request
String openId = tree.getOpenRequestItemId();
if (openId != null) {
handleOpenItemRequest(tree, xml, openId);
return;
}
// Check the tree has tree items (WCAG requirement)
TreeItemModel model = tree.getTreeModel();
if (model == null || model.getRowCount() <= 0) {
LOG.warn("Tree not rendered as it has no items.");
return;
}
xml.appendTagOpen("ui:tree");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("htree", WTree.Type.HORIZONTAL == tree.getType(), "true");
xml.appendOptionalAttribute("multiple", WTree.SelectMode.MULTIPLE == tree.getSelectMode(), "true");
xml.appendOptionalAttribute("disabled", tree.isDisabled(), "true");
xml.appendOptionalAttribute("hidden", tree.isHidden(), "true");
xml.appendOptionalAttribute("required", tree.isMandatory(), "true");
switch (tree.getExpandMode()) {
case CLIENT:
xml.appendAttribute("mode", "client");
break;
case DYNAMIC:
xml.appendAttribute("mode", "dynamic");
break;
case LAZY:
xml.appendAttribute("mode", "lazy");
break;
default:
throw new IllegalStateException("Invalid expand mode: " + tree.getType());
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(tree, renderContext);
if (tree.getCustomTree() == null) {
handlePaintItems(tree, xml);
} else {
handlePaintCustom(tree, xml);
}
DiagnosticRenderUtil.renderDiagnostics(tree, renderContext);
xml.appendEndTag("ui:tree");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WTree tree = (WTree) component;
XmlStringBuilder xml = renderContext.getWriter();
// Check if rendering an open item request
String openId = tree.getOpenRequestItemId();
if (openId != null) {
handleOpenItemRequest(tree, xml, openId);
return;
}
// Check the tree has tree items (WCAG requirement)
TreeItemModel model = tree.getTreeModel();
if (model == null || model.getRowCount() <= 0) {
LOG.warn("Tree not rendered as it has no items.");
return;
}
xml.appendTagOpen("ui:tree");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("htree", WTree.Type.HORIZONTAL == tree.getType(), "true");
xml.appendOptionalAttribute("multiple", WTree.SelectMode.MULTIPLE == tree.getSelectMode(), "true");
xml.appendOptionalAttribute("disabled", tree.isDisabled(), "true");
xml.appendOptionalAttribute("hidden", tree.isHidden(), "true");
xml.appendOptionalAttribute("required", tree.isMandatory(), "true");
switch (tree.getExpandMode()) {
case CLIENT:
xml.appendAttribute("mode", "client");
break;
case DYNAMIC:
xml.appendAttribute("mode", "dynamic");
break;
case LAZY:
xml.appendAttribute("mode", "lazy");
break;
default:
throw new IllegalStateException("Invalid expand mode: " + tree.getType());
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(tree, renderContext);
if (tree.getCustomTree() == null) {
handlePaintItems(tree, xml);
} else {
handlePaintCustom(tree, xml);
}
DiagnosticRenderUtil.renderDiagnostics(tree, renderContext);
xml.appendEndTag("ui:tree");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WTree",
"tree",
"=",
"(",
"WTree",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".... | Paints the given WTree.
@param component the WTree to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WTree",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java#L36-L95 |
HtmlUnit/htmlunit-cssparser | src/main/java/com/gargoylesoftware/css/parser/CSSOMParser.java | CSSOMParser.parseStyleDeclaration | public void parseStyleDeclaration(final CSSStyleDeclarationImpl sd, final String styleDecl) throws IOException {
try (InputSource source = new InputSource(new StringReader(styleDecl))) {
final Stack<Object> nodeStack = new Stack<>();
nodeStack.push(sd);
final CSSOMHandler handler = new CSSOMHandler(nodeStack);
parser_.setDocumentHandler(handler);
parser_.parseStyleDeclaration(source);
}
} | java | public void parseStyleDeclaration(final CSSStyleDeclarationImpl sd, final String styleDecl) throws IOException {
try (InputSource source = new InputSource(new StringReader(styleDecl))) {
final Stack<Object> nodeStack = new Stack<>();
nodeStack.push(sd);
final CSSOMHandler handler = new CSSOMHandler(nodeStack);
parser_.setDocumentHandler(handler);
parser_.parseStyleDeclaration(source);
}
} | [
"public",
"void",
"parseStyleDeclaration",
"(",
"final",
"CSSStyleDeclarationImpl",
"sd",
",",
"final",
"String",
"styleDecl",
")",
"throws",
"IOException",
"{",
"try",
"(",
"InputSource",
"source",
"=",
"new",
"InputSource",
"(",
"new",
"StringReader",
"(",
"styl... | Parses a input string into a CSSOM style declaration.
@param styleDecl the input string
@param sd the CSSOM style declaration
@throws IOException if the underlying SAC parser throws an IOException | [
"Parses",
"a",
"input",
"string",
"into",
"a",
"CSSOM",
"style",
"declaration",
"."
] | train | https://github.com/HtmlUnit/htmlunit-cssparser/blob/384e4170737169b5b4c87c5766495d9b8a6d3866/src/main/java/com/gargoylesoftware/css/parser/CSSOMParser.java#L111-L119 |
h2oai/h2o-3 | h2o-parsers/h2o-orc-parser/src/main/java/water/parser/orc/OrcParser.java | OrcParser.check_Min_Value | private void check_Min_Value(long l, int cIdx, int rowNumber, ParseWriter dout) {
if (l <= Long.MIN_VALUE) {
String warning = "Orc Parser: Long.MIN_VALUE: " + l + " is found in column "+cIdx+" row "+rowNumber +
" of stripe "+_cidx +". This value is used for sentinel and will not be parsed correctly.";
dout.addError(new ParseWriter.ParseErr(warning, _cidx, rowNumber, -2L));
}
} | java | private void check_Min_Value(long l, int cIdx, int rowNumber, ParseWriter dout) {
if (l <= Long.MIN_VALUE) {
String warning = "Orc Parser: Long.MIN_VALUE: " + l + " is found in column "+cIdx+" row "+rowNumber +
" of stripe "+_cidx +". This value is used for sentinel and will not be parsed correctly.";
dout.addError(new ParseWriter.ParseErr(warning, _cidx, rowNumber, -2L));
}
} | [
"private",
"void",
"check_Min_Value",
"(",
"long",
"l",
",",
"int",
"cIdx",
",",
"int",
"rowNumber",
",",
"ParseWriter",
"dout",
")",
"{",
"if",
"(",
"l",
"<=",
"Long",
".",
"MIN_VALUE",
")",
"{",
"String",
"warning",
"=",
"\"Orc Parser: Long.MIN_VALUE: \"",... | This method is written to check and make sure any value written to a column of type long
is more than Long.MIN_VALUE. If this is not true, a warning will be passed to the user.
@param l
@param cIdx
@param rowNumber
@param dout | [
"This",
"method",
"is",
"written",
"to",
"check",
"and",
"make",
"sure",
"any",
"value",
"written",
"to",
"a",
"column",
"of",
"type",
"long",
"is",
"more",
"than",
"Long",
".",
"MIN_VALUE",
".",
"If",
"this",
"is",
"not",
"true",
"a",
"warning",
"will... | train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-parsers/h2o-orc-parser/src/main/java/water/parser/orc/OrcParser.java#L467-L473 |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.withNodeKeys | public static NodeSequence withNodeKeys( final Iterator<NodeKey> keys,
final long keyCount,
final float score,
final String workspaceName,
final RepositoryCache repository ) {
assert keyCount >= -1;
if (keys == null) return emptySequence(1);
return withBatch(batchOfKeys(keys, keyCount, score, workspaceName, repository));
} | java | public static NodeSequence withNodeKeys( final Iterator<NodeKey> keys,
final long keyCount,
final float score,
final String workspaceName,
final RepositoryCache repository ) {
assert keyCount >= -1;
if (keys == null) return emptySequence(1);
return withBatch(batchOfKeys(keys, keyCount, score, workspaceName, repository));
} | [
"public",
"static",
"NodeSequence",
"withNodeKeys",
"(",
"final",
"Iterator",
"<",
"NodeKey",
">",
"keys",
",",
"final",
"long",
"keyCount",
",",
"final",
"float",
"score",
",",
"final",
"String",
"workspaceName",
",",
"final",
"RepositoryCache",
"repository",
"... | Create a sequence of nodes that iterates over the supplied node keys. Note that the supplied iterator is accessed lazily as
the resulting sequence's {@link #nextBatch() first batch} is {@link Batch#nextRow() used}.
@param keys the iterator over the keys of the node keys to be returned; if null, an {@link #emptySequence empty instance}
is returned
@param keyCount the number of node keys in the iterator; must be -1 if not known, 0 if known to be empty, or a positive
number if the number of node keys is known
@param score the score to return for all of the nodes
@param workspaceName the name of the workspace in which all of the nodes exist
@param repository the repository cache used to access the workspaces and cached nodes; may be null only if the key sequence
is null or empty
@return the sequence of nodes; never null | [
"Create",
"a",
"sequence",
"of",
"nodes",
"that",
"iterates",
"over",
"the",
"supplied",
"node",
"keys",
".",
"Note",
"that",
"the",
"supplied",
"iterator",
"is",
"accessed",
"lazily",
"as",
"the",
"resulting",
"sequence",
"s",
"{",
"@link",
"#nextBatch",
"(... | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L578-L586 |
aoindustries/aocode-public | src/main/java/com/aoindustries/util/StringUtility.java | StringUtility.compareToDDMMYYYY | public static int compareToDDMMYYYY(String date1, String date2) {
if(date1.length()!=8 || date2.length()!=8) return 0;
return compareToDDMMYYYY0(date1)-compareToDDMMYYYY0(date2);
} | java | public static int compareToDDMMYYYY(String date1, String date2) {
if(date1.length()!=8 || date2.length()!=8) return 0;
return compareToDDMMYYYY0(date1)-compareToDDMMYYYY0(date2);
} | [
"public",
"static",
"int",
"compareToDDMMYYYY",
"(",
"String",
"date1",
",",
"String",
"date2",
")",
"{",
"if",
"(",
"date1",
".",
"length",
"(",
")",
"!=",
"8",
"||",
"date2",
".",
"length",
"(",
")",
"!=",
"8",
")",
"return",
"0",
";",
"return",
... | Compare one date to another, must be in the DDMMYYYY format.
@return <0 if the first date is before the second<br>
0 if the dates are the same or the format is invalid<br>
>0 if the first date is after the second | [
"Compare",
"one",
"date",
"to",
"another",
"must",
"be",
"in",
"the",
"DDMMYYYY",
"format",
"."
] | train | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/util/StringUtility.java#L230-L233 |
citrusframework/citrus | modules/citrus-cucumber/src/main/java/cucumber/runtime/java/CitrusBackend.java | CitrusBackend.getObjectFactory | private ObjectFactory getObjectFactory() throws IllegalAccessException {
if (Env.INSTANCE.get(ObjectFactory.class.getName()).equals(CitrusObjectFactory.class.getName())) {
return CitrusObjectFactory.instance();
} else if (Env.INSTANCE.get(ObjectFactory.class.getName()).equals(CitrusSpringObjectFactory.class.getName())) {
return CitrusSpringObjectFactory.instance();
}
return ObjectFactoryLoader.loadObjectFactory(new ResourceLoaderClassFinder(resourceLoader, Thread.currentThread().getContextClassLoader()),
Env.INSTANCE.get(ObjectFactory.class.getName()));
} | java | private ObjectFactory getObjectFactory() throws IllegalAccessException {
if (Env.INSTANCE.get(ObjectFactory.class.getName()).equals(CitrusObjectFactory.class.getName())) {
return CitrusObjectFactory.instance();
} else if (Env.INSTANCE.get(ObjectFactory.class.getName()).equals(CitrusSpringObjectFactory.class.getName())) {
return CitrusSpringObjectFactory.instance();
}
return ObjectFactoryLoader.loadObjectFactory(new ResourceLoaderClassFinder(resourceLoader, Thread.currentThread().getContextClassLoader()),
Env.INSTANCE.get(ObjectFactory.class.getName()));
} | [
"private",
"ObjectFactory",
"getObjectFactory",
"(",
")",
"throws",
"IllegalAccessException",
"{",
"if",
"(",
"Env",
".",
"INSTANCE",
".",
"get",
"(",
"ObjectFactory",
".",
"class",
".",
"getName",
"(",
")",
")",
".",
"equals",
"(",
"CitrusObjectFactory",
".",... | Gets the object factory instance that is configured in environment.
@return | [
"Gets",
"the",
"object",
"factory",
"instance",
"that",
"is",
"configured",
"in",
"environment",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-cucumber/src/main/java/cucumber/runtime/java/CitrusBackend.java#L111-L120 |
Metatavu/edelphi | edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java | QueryDataUtils.writeCsv | private static byte[] writeCsv(String[] columnHeaders, String[][] rows) throws IOException {
try (ByteArrayOutputStream csvStream = new ByteArrayOutputStream(); OutputStreamWriter streamWriter = new OutputStreamWriter(csvStream, Charset.forName("UTF-8"))) {
CSVWriter csvWriter = new CSVWriter(streamWriter, ',');
csvWriter.writeNext(columnHeaders);
for (String[] row : rows) {
csvWriter.writeNext(row);
}
csvWriter.close();
return csvStream.toByteArray();
}
} | java | private static byte[] writeCsv(String[] columnHeaders, String[][] rows) throws IOException {
try (ByteArrayOutputStream csvStream = new ByteArrayOutputStream(); OutputStreamWriter streamWriter = new OutputStreamWriter(csvStream, Charset.forName("UTF-8"))) {
CSVWriter csvWriter = new CSVWriter(streamWriter, ',');
csvWriter.writeNext(columnHeaders);
for (String[] row : rows) {
csvWriter.writeNext(row);
}
csvWriter.close();
return csvStream.toByteArray();
}
} | [
"private",
"static",
"byte",
"[",
"]",
"writeCsv",
"(",
"String",
"[",
"]",
"columnHeaders",
",",
"String",
"[",
"]",
"[",
"]",
"rows",
")",
"throws",
"IOException",
"{",
"try",
"(",
"ByteArrayOutputStream",
"csvStream",
"=",
"new",
"ByteArrayOutputStream",
... | Writes a CSV file
@param columnHeaders headers
@param rows rows
@return CSV file
@throws IOException throws IOException when CSV writing fails | [
"Writes",
"a",
"CSV",
"file"
] | train | https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/QueryDataUtils.java#L256-L270 |
igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java | AdHocCommandManager.respondError | private static IQ respondError(AdHocCommandData response, StanzaError.Condition condition,
AdHocCommand.SpecificErrorCondition specificCondition) {
StanzaError.Builder error = StanzaError.getBuilder(condition).addExtension(new AdHocCommandData.SpecificError(specificCondition));
return respondError(response, error);
} | java | private static IQ respondError(AdHocCommandData response, StanzaError.Condition condition,
AdHocCommand.SpecificErrorCondition specificCondition) {
StanzaError.Builder error = StanzaError.getBuilder(condition).addExtension(new AdHocCommandData.SpecificError(specificCondition));
return respondError(response, error);
} | [
"private",
"static",
"IQ",
"respondError",
"(",
"AdHocCommandData",
"response",
",",
"StanzaError",
".",
"Condition",
"condition",
",",
"AdHocCommand",
".",
"SpecificErrorCondition",
"specificCondition",
")",
"{",
"StanzaError",
".",
"Builder",
"error",
"=",
"StanzaEr... | Responds an error with an specific condition.
@param response the response to send.
@param condition the condition of the error.
@param specificCondition the adhoc command error condition.
@throws NotConnectedException | [
"Responds",
"an",
"error",
"with",
"an",
"specific",
"condition",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java#L581-L585 |
google/closure-compiler | src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java | Es6RewriteBlockScopedDeclaration.createCommaNode | private Node createCommaNode(Node expr1, Node expr2) {
Node commaNode = IR.comma(expr1, expr2);
if (shouldAddTypesOnNewAstNodes) {
commaNode.setJSType(expr2.getJSType());
}
return commaNode;
} | java | private Node createCommaNode(Node expr1, Node expr2) {
Node commaNode = IR.comma(expr1, expr2);
if (shouldAddTypesOnNewAstNodes) {
commaNode.setJSType(expr2.getJSType());
}
return commaNode;
} | [
"private",
"Node",
"createCommaNode",
"(",
"Node",
"expr1",
",",
"Node",
"expr2",
")",
"{",
"Node",
"commaNode",
"=",
"IR",
".",
"comma",
"(",
"expr1",
",",
"expr2",
")",
";",
"if",
"(",
"shouldAddTypesOnNewAstNodes",
")",
"{",
"commaNode",
".",
"setJSType... | Creates a COMMA node with type information matching its second argument. | [
"Creates",
"a",
"COMMA",
"node",
"with",
"type",
"information",
"matching",
"its",
"second",
"argument",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java#L718-L724 |
spring-projects/spring-hateoas | src/main/java/org/springframework/hateoas/client/Rels.java | Rels.getRelFor | public static Rel getRelFor(String rel, LinkDiscoverers discoverers) {
Assert.hasText(rel, "Relation name must not be null!");
Assert.notNull(discoverers, "LinkDiscoverers must not be null!");
if (rel.startsWith("$")) {
return new JsonPathRel(rel);
}
return new LinkDiscovererRel(rel, discoverers);
} | java | public static Rel getRelFor(String rel, LinkDiscoverers discoverers) {
Assert.hasText(rel, "Relation name must not be null!");
Assert.notNull(discoverers, "LinkDiscoverers must not be null!");
if (rel.startsWith("$")) {
return new JsonPathRel(rel);
}
return new LinkDiscovererRel(rel, discoverers);
} | [
"public",
"static",
"Rel",
"getRelFor",
"(",
"String",
"rel",
",",
"LinkDiscoverers",
"discoverers",
")",
"{",
"Assert",
".",
"hasText",
"(",
"rel",
",",
"\"Relation name must not be null!\"",
")",
";",
"Assert",
".",
"notNull",
"(",
"discoverers",
",",
"\"LinkD... | Creates a new {@link Rel} for the given relation name and {@link LinkDiscoverers}.
@param rel must not be {@literal null} or empty.
@param discoverers must not be {@literal null}.
@return | [
"Creates",
"a",
"new",
"{",
"@link",
"Rel",
"}",
"for",
"the",
"given",
"relation",
"name",
"and",
"{",
"@link",
"LinkDiscoverers",
"}",
"."
] | train | https://github.com/spring-projects/spring-hateoas/blob/70ebff9309f086cd8d6a97daf67e0dc215c87d9c/src/main/java/org/springframework/hateoas/client/Rels.java#L43-L53 |
icon-Systemhaus-GmbH/javassist-maven-plugin | src/main/java/de/icongmbh/oss/maven/plugin/javassist/ClassnameExtractor.java | ClassnameExtractor.extractClassNameFromFile | public static String extractClassNameFromFile(final File parentDirectory,
final File classFile) throws IOException {
if (null == classFile) {
return null;
}
final String qualifiedFileName = parentDirectory != null
? classFile.getCanonicalPath()
.substring(parentDirectory.getCanonicalPath().length() + 1)
: classFile.getCanonicalPath();
return removeExtension(qualifiedFileName.replace(File.separator, "."));
} | java | public static String extractClassNameFromFile(final File parentDirectory,
final File classFile) throws IOException {
if (null == classFile) {
return null;
}
final String qualifiedFileName = parentDirectory != null
? classFile.getCanonicalPath()
.substring(parentDirectory.getCanonicalPath().length() + 1)
: classFile.getCanonicalPath();
return removeExtension(qualifiedFileName.replace(File.separator, "."));
} | [
"public",
"static",
"String",
"extractClassNameFromFile",
"(",
"final",
"File",
"parentDirectory",
",",
"final",
"File",
"classFile",
")",
"throws",
"IOException",
"{",
"if",
"(",
"null",
"==",
"classFile",
")",
"{",
"return",
"null",
";",
"}",
"final",
"Strin... | Remove parent directory from file name and replace directory separator with dots.
<ul>
<li>parentDirectory: {@code /tmp/my/parent/src/}</li>
<li>classFile: {@code /tmp/my/parent/src/foo/bar/MyApp.class}</li>
</ul>
returns: {@code foo.bar.MyApp}
@param parentDirectory to remove from {@code classFile} and maybe {@code null}.
@param classFile to extract the name from. Maybe {@code null}
@return class name extracted from file name or {@code null}
@throws IOException by file operations | [
"Remove",
"parent",
"directory",
"from",
"file",
"name",
"and",
"replace",
"directory",
"separator",
"with",
"dots",
"."
] | train | https://github.com/icon-Systemhaus-GmbH/javassist-maven-plugin/blob/798368f79a0bd641648bebd8546388daf013a50e/src/main/java/de/icongmbh/oss/maven/plugin/javassist/ClassnameExtractor.java#L54-L64 |
gildur/jshint4j | src/main/java/pl/gildur/jshint4j/JsHint.java | JsHint.lint | public List<Error> lint(String source, String options) {
if (source == null) {
throw new NullPointerException("Source must not be null.");
}
Context cx = Context.enter();
try {
Scriptable scope = cx.initStandardObjects();
evaluateJSHint(cx, scope);
return lint(cx, scope, source, options);
} finally {
Context.exit();
}
} | java | public List<Error> lint(String source, String options) {
if (source == null) {
throw new NullPointerException("Source must not be null.");
}
Context cx = Context.enter();
try {
Scriptable scope = cx.initStandardObjects();
evaluateJSHint(cx, scope);
return lint(cx, scope, source, options);
} finally {
Context.exit();
}
} | [
"public",
"List",
"<",
"Error",
">",
"lint",
"(",
"String",
"source",
",",
"String",
"options",
")",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Source must not be null.\"",
")",
";",
"}",
"Context",
"c... | Runs JSHint on given JavaScript source code.
@param source JavaScript source code
@param options JSHint options
@return JSHint errors | [
"Runs",
"JSHint",
"on",
"given",
"JavaScript",
"source",
"code",
"."
] | train | https://github.com/gildur/jshint4j/blob/b6f9e2fb00e248a4194f38a2df07eb34d55177f7/src/main/java/pl/gildur/jshint4j/JsHint.java#L26-L39 |
BranchMetrics/android-branch-deep-linking | Branch-SDK/src/io/branch/referral/Branch.java | Branch.initSession | public boolean initSession(boolean isReferrable, @NonNull Activity activity) {
return initSession((BranchReferralInitListener) null, isReferrable, activity);
} | java | public boolean initSession(boolean isReferrable, @NonNull Activity activity) {
return initSession((BranchReferralInitListener) null, isReferrable, activity);
} | [
"public",
"boolean",
"initSession",
"(",
"boolean",
"isReferrable",
",",
"@",
"NonNull",
"Activity",
"activity",
")",
"{",
"return",
"initSession",
"(",
"(",
"BranchReferralInitListener",
")",
"null",
",",
"isReferrable",
",",
"activity",
")",
";",
"}"
] | <p>Initialises a session with the Branch API, specifying whether the initialisation can count
as a referrable action, and supplying the calling {@link Activity} for context.</p>
@param isReferrable A {@link Boolean} value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.
@param activity The calling {@link Activity} for context.
@return A {@link Boolean} value that returns <i>false</i> if unsuccessful. | [
"<p",
">",
"Initialises",
"a",
"session",
"with",
"the",
"Branch",
"API",
"specifying",
"whether",
"the",
"initialisation",
"can",
"count",
"as",
"a",
"referrable",
"action",
"and",
"supplying",
"the",
"calling",
"{",
"@link",
"Activity",
"}",
"for",
"context"... | train | https://github.com/BranchMetrics/android-branch-deep-linking/blob/e3bee2ccfcbf6d4bf1a5815b5b86666e4ff8f848/Branch-SDK/src/io/branch/referral/Branch.java#L1186-L1188 |
zeroturnaround/zt-zip | src/main/java/org/zeroturnaround/zip/Zips.java | Zips.iterate | public void iterate(ZipEntryCallback zipEntryCallback) {
ZipEntryOrInfoAdapter zipEntryAdapter = new ZipEntryOrInfoAdapter(zipEntryCallback, null);
processAllEntries(zipEntryAdapter);
} | java | public void iterate(ZipEntryCallback zipEntryCallback) {
ZipEntryOrInfoAdapter zipEntryAdapter = new ZipEntryOrInfoAdapter(zipEntryCallback, null);
processAllEntries(zipEntryAdapter);
} | [
"public",
"void",
"iterate",
"(",
"ZipEntryCallback",
"zipEntryCallback",
")",
"{",
"ZipEntryOrInfoAdapter",
"zipEntryAdapter",
"=",
"new",
"ZipEntryOrInfoAdapter",
"(",
"zipEntryCallback",
",",
"null",
")",
";",
"processAllEntries",
"(",
"zipEntryAdapter",
")",
";",
... | Reads the source ZIP file and executes the given callback for each entry.
<p>
For each entry the corresponding input stream is also passed to the callback. If you want to stop the loop then throw a ZipBreakException.
This method is charset aware and uses Zips.charset.
@param zipEntryCallback
callback to be called for each entry.
@see ZipEntryCallback | [
"Reads",
"the",
"source",
"ZIP",
"file",
"and",
"executes",
"the",
"given",
"callback",
"for",
"each",
"entry",
".",
"<p",
">",
"For",
"each",
"entry",
"the",
"corresponding",
"input",
"stream",
"is",
"also",
"passed",
"to",
"the",
"callback",
".",
"If",
... | train | https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/Zips.java#L435-L438 |
dbracewell/mango | src/main/java/com/davidbracewell/json/JsonReader.java | JsonReader.nextCollection | public <T extends Collection<Val>> T nextCollection(@NonNull Supplier<T> supplier) throws IOException {
return nextCollection(supplier, StringUtils.EMPTY);
} | java | public <T extends Collection<Val>> T nextCollection(@NonNull Supplier<T> supplier) throws IOException {
return nextCollection(supplier, StringUtils.EMPTY);
} | [
"public",
"<",
"T",
"extends",
"Collection",
"<",
"Val",
">",
">",
"T",
"nextCollection",
"(",
"@",
"NonNull",
"Supplier",
"<",
"T",
">",
"supplier",
")",
"throws",
"IOException",
"{",
"return",
"nextCollection",
"(",
"supplier",
",",
"StringUtils",
".",
"... | Reads the next array as a collection.
@param <T> the collection type
@param supplier the supplier to create a new collection
@return the collection containing the items in the next array
@throws IOException Something went wrong reading | [
"Reads",
"the",
"next",
"array",
"as",
"a",
"collection",
"."
] | train | https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L394-L396 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/BaseWorkflowExecutor.java | BaseWorkflowExecutor.createPrintableDataContext | protected Map<String, Map<String, String>> createPrintableDataContext(Map<String, Map<String, String>>
dataContext) {
return createPrintableDataContext(OPTION_KEY, SECURE_OPTION_KEY, SECURE_OPTION_VALUE, dataContext);
} | java | protected Map<String, Map<String, String>> createPrintableDataContext(Map<String, Map<String, String>>
dataContext) {
return createPrintableDataContext(OPTION_KEY, SECURE_OPTION_KEY, SECURE_OPTION_VALUE, dataContext);
} | [
"protected",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"createPrintableDataContext",
"(",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"dataContext",
")",
"{",
"return",
"createPrintableDataContext... | Creates a copy of the given data context with the secure option values obfuscated.
This does not modify the original data context.
"secureOption" map values will always be obfuscated. "option" entries that are also in "secureOption"
will have their values obfuscated. All other maps within the data context will be added
directly to the copy.
@param dataContext data
@return printable data | [
"Creates",
"a",
"copy",
"of",
"the",
"given",
"data",
"context",
"with",
"the",
"secure",
"option",
"values",
"obfuscated",
".",
"This",
"does",
"not",
"modify",
"the",
"original",
"data",
"context",
"."
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/BaseWorkflowExecutor.java#L571-L574 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/DocEnv.java | DocEnv.printError | public void printError(SourcePosition pos, String msg) {
if (silent)
return;
messager.printError(pos, msg);
} | java | public void printError(SourcePosition pos, String msg) {
if (silent)
return;
messager.printError(pos, msg);
} | [
"public",
"void",
"printError",
"(",
"SourcePosition",
"pos",
",",
"String",
"msg",
")",
"{",
"if",
"(",
"silent",
")",
"return",
";",
"messager",
".",
"printError",
"(",
"pos",
",",
"msg",
")",
";",
"}"
] | Print error message, increment error count.
@param msg message to print. | [
"Print",
"error",
"message",
"increment",
"error",
"count",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/DocEnv.java#L347-L351 |
Javacord/Javacord | javacord-core/src/main/java/org/javacord/core/DiscordApiImpl.java | DiscordApiImpl.getOrCreateKnownCustomEmoji | public KnownCustomEmoji getOrCreateKnownCustomEmoji(Server server, JsonNode data) {
long id = Long.parseLong(data.get("id").asText());
return customEmojis.computeIfAbsent(id, key -> new KnownCustomEmojiImpl(this, server, data));
} | java | public KnownCustomEmoji getOrCreateKnownCustomEmoji(Server server, JsonNode data) {
long id = Long.parseLong(data.get("id").asText());
return customEmojis.computeIfAbsent(id, key -> new KnownCustomEmojiImpl(this, server, data));
} | [
"public",
"KnownCustomEmoji",
"getOrCreateKnownCustomEmoji",
"(",
"Server",
"server",
",",
"JsonNode",
"data",
")",
"{",
"long",
"id",
"=",
"Long",
".",
"parseLong",
"(",
"data",
".",
"get",
"(",
"\"id\"",
")",
".",
"asText",
"(",
")",
")",
";",
"return",
... | Gets or creates a new known custom emoji object.
@param server The server of the emoji.
@param data The data of the emoji.
@return The emoji for the given json object. | [
"Gets",
"or",
"creates",
"a",
"new",
"known",
"custom",
"emoji",
"object",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-core/src/main/java/org/javacord/core/DiscordApiImpl.java#L813-L816 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/mock/CommonsMock.java | MockSupplier.createNoParams | @Nonnull
public static <T> MockSupplier createNoParams (@Nonnull final Class <T> aDstClass,
@Nonnull final Supplier <T> aSupplier)
{
ValueEnforcer.notNull (aDstClass, "DstClass");
ValueEnforcer.notNull (aSupplier, "Supplier");
return new MockSupplier (aDstClass, null, aParam -> aSupplier.get ());
} | java | @Nonnull
public static <T> MockSupplier createNoParams (@Nonnull final Class <T> aDstClass,
@Nonnull final Supplier <T> aSupplier)
{
ValueEnforcer.notNull (aDstClass, "DstClass");
ValueEnforcer.notNull (aSupplier, "Supplier");
return new MockSupplier (aDstClass, null, aParam -> aSupplier.get ());
} | [
"@",
"Nonnull",
"public",
"static",
"<",
"T",
">",
"MockSupplier",
"createNoParams",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"T",
">",
"aDstClass",
",",
"@",
"Nonnull",
"final",
"Supplier",
"<",
"T",
">",
"aSupplier",
")",
"{",
"ValueEnforcer",
".",
... | Create a mock supplier for a factory without parameters.
@param aDstClass
The destination class to be mocked. May not be <code>null</code>.
@param aSupplier
The supplier/factory without parameters to be used. May not be
<code>null</code>.
@return Never <code>null</code>.
@param <T>
The type to be mocked | [
"Create",
"a",
"mock",
"supplier",
"for",
"a",
"factory",
"without",
"parameters",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/mock/CommonsMock.java#L231-L238 |
real-logic/simple-binary-encoding | sbe-tool/src/main/java/uk/co/real_logic/sbe/otf/Types.java | Types.getLong | public static long getLong(final DirectBuffer buffer, final int index, final Encoding encoding)
{
switch (encoding.primitiveType())
{
case CHAR:
return buffer.getByte(index);
case INT8:
return buffer.getByte(index);
case INT16:
return buffer.getShort(index, encoding.byteOrder());
case INT32:
return buffer.getInt(index, encoding.byteOrder());
case INT64:
return buffer.getLong(index, encoding.byteOrder());
case UINT8:
return (short)(buffer.getByte(index) & 0xFF);
case UINT16:
return buffer.getShort(index, encoding.byteOrder()) & 0xFFFF;
case UINT32:
return buffer.getInt(index, encoding.byteOrder()) & 0xFFFF_FFFFL;
case UINT64:
return buffer.getLong(index, encoding.byteOrder());
default:
throw new IllegalArgumentException("Unsupported type for long: " + encoding.primitiveType());
}
} | java | public static long getLong(final DirectBuffer buffer, final int index, final Encoding encoding)
{
switch (encoding.primitiveType())
{
case CHAR:
return buffer.getByte(index);
case INT8:
return buffer.getByte(index);
case INT16:
return buffer.getShort(index, encoding.byteOrder());
case INT32:
return buffer.getInt(index, encoding.byteOrder());
case INT64:
return buffer.getLong(index, encoding.byteOrder());
case UINT8:
return (short)(buffer.getByte(index) & 0xFF);
case UINT16:
return buffer.getShort(index, encoding.byteOrder()) & 0xFFFF;
case UINT32:
return buffer.getInt(index, encoding.byteOrder()) & 0xFFFF_FFFFL;
case UINT64:
return buffer.getLong(index, encoding.byteOrder());
default:
throw new IllegalArgumentException("Unsupported type for long: " + encoding.primitiveType());
}
} | [
"public",
"static",
"long",
"getLong",
"(",
"final",
"DirectBuffer",
"buffer",
",",
"final",
"int",
"index",
",",
"final",
"Encoding",
"encoding",
")",
"{",
"switch",
"(",
"encoding",
".",
"primitiveType",
"(",
")",
")",
"{",
"case",
"CHAR",
":",
"return",... | Get a long value from a buffer at a given index for a given {@link Encoding}.
@param buffer from which to read.
@param index at which he integer should be read.
@param encoding of the value.
@return the value of the encoded long. | [
"Get",
"a",
"long",
"value",
"from",
"a",
"buffer",
"at",
"a",
"given",
"index",
"for",
"a",
"given",
"{",
"@link",
"Encoding",
"}",
"."
] | train | https://github.com/real-logic/simple-binary-encoding/blob/9a7be490c86d98f0e430e4189bc6c8c4fbef658b/sbe-tool/src/main/java/uk/co/real_logic/sbe/otf/Types.java#L80-L114 |
evernote/evernote-sdk-android | library/src/main/java/com/evernote/client/android/EvernoteUtil.java | EvernoteUtil.getEvernoteInstallStatus | public static EvernoteInstallStatus getEvernoteInstallStatus(Context context, String action) {
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(action).setPackage(PACKAGE_NAME);
List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (!resolveInfos.isEmpty()) {
return validateSignature(packageManager);
}
try {
// authentication feature not available, yet
packageManager.getPackageInfo(PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
return EvernoteInstallStatus.OLD_VERSION;
} catch (Exception e) {
return EvernoteInstallStatus.NOT_INSTALLED;
}
} | java | public static EvernoteInstallStatus getEvernoteInstallStatus(Context context, String action) {
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(action).setPackage(PACKAGE_NAME);
List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (!resolveInfos.isEmpty()) {
return validateSignature(packageManager);
}
try {
// authentication feature not available, yet
packageManager.getPackageInfo(PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
return EvernoteInstallStatus.OLD_VERSION;
} catch (Exception e) {
return EvernoteInstallStatus.NOT_INSTALLED;
}
} | [
"public",
"static",
"EvernoteInstallStatus",
"getEvernoteInstallStatus",
"(",
"Context",
"context",
",",
"String",
"action",
")",
"{",
"PackageManager",
"packageManager",
"=",
"context",
".",
"getPackageManager",
"(",
")",
";",
"Intent",
"intent",
"=",
"new",
"Inten... | Checks if Evernote is installed and if the app can resolve this action. | [
"Checks",
"if",
"Evernote",
"is",
"installed",
"and",
"if",
"the",
"app",
"can",
"resolve",
"this",
"action",
"."
] | train | https://github.com/evernote/evernote-sdk-android/blob/fc59be643e85c4f59d562d1bfe76563997aa73cf/library/src/main/java/com/evernote/client/android/EvernoteUtil.java#L256-L273 |
http-builder-ng/http-builder-ng | http-builder-ng-core/src/main/java/groovyx/net/http/HttpBuilder.java | HttpBuilder.headAsync | public CompletableFuture<Object> headAsync(final Consumer<HttpConfig> configuration) {
return CompletableFuture.supplyAsync(() -> head(configuration), getExecutor());
} | java | public CompletableFuture<Object> headAsync(final Consumer<HttpConfig> configuration) {
return CompletableFuture.supplyAsync(() -> head(configuration), getExecutor());
} | [
"public",
"CompletableFuture",
"<",
"Object",
">",
"headAsync",
"(",
"final",
"Consumer",
"<",
"HttpConfig",
">",
"configuration",
")",
"{",
"return",
"CompletableFuture",
".",
"supplyAsync",
"(",
"(",
")",
"->",
"head",
"(",
"configuration",
")",
",",
"getExe... | Executes an asynchronous HEAD request on the configured URI (asynchronous alias to `head(Consumer)`), with additional configuration provided by the
configuration function.
This method is generally used for Java-specific configuration.
[source,java]
----
HttpBuilder http = HttpBuilder.configure(config -> {
config.getRequest().setUri("http://localhost:10101");
});
CompletableFuture<Object> future = http.headAsync(config -> {
config.getRequest().getUri().setPath("/foo");
});
Object result = future.get();
----
The `configuration` function allows additional configuration for this request based on the {@link HttpConfig} interface.
@param configuration the additional configuration closure (delegated to {@link HttpConfig})
@return the resulting content wrapped in a {@link CompletableFuture} | [
"Executes",
"an",
"asynchronous",
"HEAD",
"request",
"on",
"the",
"configured",
"URI",
"(",
"asynchronous",
"alias",
"to",
"head",
"(",
"Consumer",
")",
")",
"with",
"additional",
"configuration",
"provided",
"by",
"the",
"configuration",
"function",
"."
] | train | https://github.com/http-builder-ng/http-builder-ng/blob/865f37732c102c748d3db8b905199dac9222a525/http-builder-ng-core/src/main/java/groovyx/net/http/HttpBuilder.java#L631-L633 |
artikcloud/artikcloud-java | src/main/java/cloud/artik/api/UsersApi.java | UsersApi.getUserDeviceTypes | public DeviceTypesEnvelope getUserDeviceTypes(String userId, Integer offset, Integer count, Boolean includeShared) throws ApiException {
ApiResponse<DeviceTypesEnvelope> resp = getUserDeviceTypesWithHttpInfo(userId, offset, count, includeShared);
return resp.getData();
} | java | public DeviceTypesEnvelope getUserDeviceTypes(String userId, Integer offset, Integer count, Boolean includeShared) throws ApiException {
ApiResponse<DeviceTypesEnvelope> resp = getUserDeviceTypesWithHttpInfo(userId, offset, count, includeShared);
return resp.getData();
} | [
"public",
"DeviceTypesEnvelope",
"getUserDeviceTypes",
"(",
"String",
"userId",
",",
"Integer",
"offset",
",",
"Integer",
"count",
",",
"Boolean",
"includeShared",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"DeviceTypesEnvelope",
">",
"resp",
"=",
"getU... | Get User Device Types
Retrieve User's Device Types
@param userId User ID. (required)
@param offset Offset for pagination. (optional)
@param count Desired count of items in the result set (optional)
@param includeShared Optional. Boolean (true/false) - If false, only return the user's device types. If true, also return device types shared by other users. (optional)
@return DeviceTypesEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Get",
"User",
"Device",
"Types",
"Retrieve",
"User'",
";",
"s",
"Device",
"Types"
] | train | https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/UsersApi.java#L505-L508 |
alkacon/opencms-core | src/org/opencms/db/CmsSecurityManager.java | CmsSecurityManager.lookupPrincipal | public I_CmsPrincipal lookupPrincipal(CmsRequestContext context, String principalName) {
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
I_CmsPrincipal result = null;
try {
result = m_driverManager.lookupPrincipal(dbc, CmsOrganizationalUnit.removeLeadingSeparator(principalName));
} finally {
dbc.clear();
}
return result;
} | java | public I_CmsPrincipal lookupPrincipal(CmsRequestContext context, String principalName) {
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
I_CmsPrincipal result = null;
try {
result = m_driverManager.lookupPrincipal(dbc, CmsOrganizationalUnit.removeLeadingSeparator(principalName));
} finally {
dbc.clear();
}
return result;
} | [
"public",
"I_CmsPrincipal",
"lookupPrincipal",
"(",
"CmsRequestContext",
"context",
",",
"String",
"principalName",
")",
"{",
"CmsDbContext",
"dbc",
"=",
"m_dbContextFactory",
".",
"getDbContext",
"(",
"context",
")",
";",
"I_CmsPrincipal",
"result",
"=",
"null",
";... | Lookup and read the user or group with the given name.<p>
@param context the current request context
@param principalName the name of the principal to lookup
@return the principal (group or user) if found, otherwise <code>null</code> | [
"Lookup",
"and",
"read",
"the",
"user",
"or",
"group",
"with",
"the",
"given",
"name",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsSecurityManager.java#L3642-L3652 |
alipay/sofa-hessian | src/main/java/com/caucho/hessian/io/Hessian2Output.java | Hessian2Output.writeFault | public void writeFault(String code, String message, Object detail)
throws IOException
{
flushIfFull();
writeVersion();
_buffer[_offset++] = (byte) 'F';
_buffer[_offset++] = (byte) 'H';
addRef(new Object(), _refCount++, false);
writeString("code");
writeString(code);
writeString("message");
writeString(message);
if (detail != null) {
writeString("detail");
writeObject(detail);
}
flushIfFull();
_buffer[_offset++] = (byte) 'Z';
} | java | public void writeFault(String code, String message, Object detail)
throws IOException
{
flushIfFull();
writeVersion();
_buffer[_offset++] = (byte) 'F';
_buffer[_offset++] = (byte) 'H';
addRef(new Object(), _refCount++, false);
writeString("code");
writeString(code);
writeString("message");
writeString(message);
if (detail != null) {
writeString("detail");
writeObject(detail);
}
flushIfFull();
_buffer[_offset++] = (byte) 'Z';
} | [
"public",
"void",
"writeFault",
"(",
"String",
"code",
",",
"String",
"message",
",",
"Object",
"detail",
")",
"throws",
"IOException",
"{",
"flushIfFull",
"(",
")",
";",
"writeVersion",
"(",
")",
";",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byt... | Writes a fault. The fault will be written
as a descriptive string followed by an object:
<code><pre>
F map
</pre></code>
<code><pre>
F H
\x04code
\x10the fault code
\x07message
\x11the fault message
\x06detail
M\xnnjavax.ejb.FinderException
...
Z
Z
</pre></code>
@param code the fault code, a three digit | [
"Writes",
"a",
"fault",
".",
"The",
"fault",
"will",
"be",
"written",
"as",
"a",
"descriptive",
"string",
"followed",
"by",
"an",
"object",
":"
] | train | https://github.com/alipay/sofa-hessian/blob/89e4f5af28602101dab7b498995018871616357b/src/main/java/com/caucho/hessian/io/Hessian2Output.java#L421-L446 |
jbundle/jbundle | thin/base/message/src/main/java/org/jbundle/thin/base/message/TreeMessage.java | TreeMessage.putNative | public void putNative(String key, Object value)
{
String strValue = null;
if (value != null)
strValue = value.toString();
CreateMode createMode = CreateMode.DONT_CREATE;
if (value != null)
{
createMode = CreateMode.CREATE_IF_NOT_FOUND;
if (Util.isCData(strValue))
createMode = CreateMode.CREATE_CDATA_NODE;
}
Node node = this.getNode(null, key, createMode, true);
if (node != null)
{
if (strValue != null)
node.setNodeValue(strValue);
else
node.getParentNode().removeChild(node);
}
} | java | public void putNative(String key, Object value)
{
String strValue = null;
if (value != null)
strValue = value.toString();
CreateMode createMode = CreateMode.DONT_CREATE;
if (value != null)
{
createMode = CreateMode.CREATE_IF_NOT_FOUND;
if (Util.isCData(strValue))
createMode = CreateMode.CREATE_CDATA_NODE;
}
Node node = this.getNode(null, key, createMode, true);
if (node != null)
{
if (strValue != null)
node.setNodeValue(strValue);
else
node.getParentNode().removeChild(node);
}
} | [
"public",
"void",
"putNative",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"String",
"strValue",
"=",
"null",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"strValue",
"=",
"value",
".",
"toString",
"(",
")",
";",
"CreateMode",
"createMode",
... | Put the raw value for this param in the (xpath) map.
@param strParam The xpath key.
@param objValue The raw data to set this location in the message. | [
"Put",
"the",
"raw",
"value",
"for",
"this",
"param",
"in",
"the",
"(",
"xpath",
")",
"map",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/TreeMessage.java#L114-L134 |
twitter/cloudhopper-commons | ch-sxmp/src/main/java/com/cloudhopper/sxmp/OptionalParamMap.java | OptionalParamMap.getLong | public Long getLong(String key, Long defaultValue) {
Object o = get(key);
if (o != null) {
if (o instanceof Long) {
return (Long) o;
} else if (o instanceof Integer) {
return new Long((Integer)o);
}
}
return defaultValue;
} | java | public Long getLong(String key, Long defaultValue) {
Object o = get(key);
if (o != null) {
if (o instanceof Long) {
return (Long) o;
} else if (o instanceof Integer) {
return new Long((Integer)o);
}
}
return defaultValue;
} | [
"public",
"Long",
"getLong",
"(",
"String",
"key",
",",
"Long",
"defaultValue",
")",
"{",
"Object",
"o",
"=",
"get",
"(",
"key",
")",
";",
"if",
"(",
"o",
"!=",
"null",
")",
"{",
"if",
"(",
"o",
"instanceof",
"Long",
")",
"{",
"return",
"(",
"Lon... | /*
getLong will successfully return for both Long values and Integer values
it will convert the Integer to a Long | [
"/",
"*",
"getLong",
"will",
"successfully",
"return",
"for",
"both",
"Long",
"values",
"and",
"Integer",
"values",
"it",
"will",
"convert",
"the",
"Integer",
"to",
"a",
"Long"
] | train | https://github.com/twitter/cloudhopper-commons/blob/b5bc397dbec4537e8149e7ec0733c1d7ed477499/ch-sxmp/src/main/java/com/cloudhopper/sxmp/OptionalParamMap.java#L110-L120 |
alkacon/opencms-core | src/org/opencms/jsp/CmsJspTagInfo.java | CmsJspTagInfo.infoTagAction | public static String infoTagAction(String property, HttpServletRequest req) {
if (property == null) {
CmsMessageContainer errMsgContainer = Messages.get().container(Messages.GUI_ERR_INVALID_INFO_PROP_0);
return Messages.getLocalizedMessage(errMsgContainer, req);
}
CmsFlexController controller = CmsFlexController.getController(req);
String result = null;
switch (SYSTEM_PROPERTIES_LIST.indexOf(property)) {
case 0: // opencms.version
result = OpenCms.getSystemInfo().getVersionNumber();
break;
case 1: // opencms.url
result = req.getRequestURL().toString();
break;
case 2: // opencms.uri
result = req.getRequestURI();
break;
case 3: // opencms.webapp
result = OpenCms.getSystemInfo().getWebApplicationName();
break;
case 4: // opencms.webbasepath
result = OpenCms.getSystemInfo().getWebApplicationRfsPath();
break;
case 5: // opencms.request.uri
result = controller.getCmsObject().getRequestContext().getUri();
break;
case 6: // opencms.request.element.uri
result = controller.getCurrentRequest().getElementUri();
break;
case 7: // opencms.request.folder
result = CmsResource.getParentFolder(controller.getCmsObject().getRequestContext().getUri());
break;
case 8: // opencms.request.encoding
result = controller.getCmsObject().getRequestContext().getEncoding();
break;
case 9: // opencms.request.locale
result = controller.getCmsObject().getRequestContext().getLocale().toString();
break;
case 10: // opencms.title
result = getTitleInfo(controller, req);
break;
case 11: // opencms.description
result = getDescriptionInfo(controller, req);
break;
case 12: // opencms.keywords
result = getKeywordsInfo(controller, req);
break;
default:
result = System.getProperty(property);
if (result == null) {
CmsMessageContainer errMsgContainer = Messages.get().container(
Messages.GUI_ERR_INVALID_INFO_PROP_1,
property);
return Messages.getLocalizedMessage(errMsgContainer, req);
}
}
return result;
} | java | public static String infoTagAction(String property, HttpServletRequest req) {
if (property == null) {
CmsMessageContainer errMsgContainer = Messages.get().container(Messages.GUI_ERR_INVALID_INFO_PROP_0);
return Messages.getLocalizedMessage(errMsgContainer, req);
}
CmsFlexController controller = CmsFlexController.getController(req);
String result = null;
switch (SYSTEM_PROPERTIES_LIST.indexOf(property)) {
case 0: // opencms.version
result = OpenCms.getSystemInfo().getVersionNumber();
break;
case 1: // opencms.url
result = req.getRequestURL().toString();
break;
case 2: // opencms.uri
result = req.getRequestURI();
break;
case 3: // opencms.webapp
result = OpenCms.getSystemInfo().getWebApplicationName();
break;
case 4: // opencms.webbasepath
result = OpenCms.getSystemInfo().getWebApplicationRfsPath();
break;
case 5: // opencms.request.uri
result = controller.getCmsObject().getRequestContext().getUri();
break;
case 6: // opencms.request.element.uri
result = controller.getCurrentRequest().getElementUri();
break;
case 7: // opencms.request.folder
result = CmsResource.getParentFolder(controller.getCmsObject().getRequestContext().getUri());
break;
case 8: // opencms.request.encoding
result = controller.getCmsObject().getRequestContext().getEncoding();
break;
case 9: // opencms.request.locale
result = controller.getCmsObject().getRequestContext().getLocale().toString();
break;
case 10: // opencms.title
result = getTitleInfo(controller, req);
break;
case 11: // opencms.description
result = getDescriptionInfo(controller, req);
break;
case 12: // opencms.keywords
result = getKeywordsInfo(controller, req);
break;
default:
result = System.getProperty(property);
if (result == null) {
CmsMessageContainer errMsgContainer = Messages.get().container(
Messages.GUI_ERR_INVALID_INFO_PROP_1,
property);
return Messages.getLocalizedMessage(errMsgContainer, req);
}
}
return result;
} | [
"public",
"static",
"String",
"infoTagAction",
"(",
"String",
"property",
",",
"HttpServletRequest",
"req",
")",
"{",
"if",
"(",
"property",
"==",
"null",
")",
"{",
"CmsMessageContainer",
"errMsgContainer",
"=",
"Messages",
".",
"get",
"(",
")",
".",
"containe... | Returns the selected info property value based on the provided
parameters.<p>
@param property the info property to look up
@param req the currents request
@return the looked up property value | [
"Returns",
"the",
"selected",
"info",
"property",
"value",
"based",
"on",
"the",
"provided",
"parameters",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/CmsJspTagInfo.java#L264-L324 |
elki-project/elki | elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/timeseries/AbstractEditDistanceFunction.java | AbstractEditDistanceFunction.effectiveBandSize | protected int effectiveBandSize(final int dim1, final int dim2) {
if(bandSize == Double.POSITIVE_INFINITY) {
return (dim1 > dim2) ? dim1 : dim2;
}
if(bandSize >= 1.) {
return (int) bandSize;
}
// Max * bandSize:
return (int) Math.ceil((dim1 >= dim2 ? dim1 : dim2) * bandSize);
} | java | protected int effectiveBandSize(final int dim1, final int dim2) {
if(bandSize == Double.POSITIVE_INFINITY) {
return (dim1 > dim2) ? dim1 : dim2;
}
if(bandSize >= 1.) {
return (int) bandSize;
}
// Max * bandSize:
return (int) Math.ceil((dim1 >= dim2 ? dim1 : dim2) * bandSize);
} | [
"protected",
"int",
"effectiveBandSize",
"(",
"final",
"int",
"dim1",
",",
"final",
"int",
"dim2",
")",
"{",
"if",
"(",
"bandSize",
"==",
"Double",
".",
"POSITIVE_INFINITY",
")",
"{",
"return",
"(",
"dim1",
">",
"dim2",
")",
"?",
"dim1",
":",
"dim2",
"... | Compute the effective band size.
@param dim1 First dimensionality
@param dim2 Second dimensionality
@return Effective bandsize | [
"Compute",
"the",
"effective",
"band",
"size",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/timeseries/AbstractEditDistanceFunction.java#L61-L70 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/wsspi/connmgmt/ConnectionHandle.java | ConnectionHandle.setConnectionHandle | public static void setConnectionHandle(VirtualConnection vc, ConnectionHandle handle) {
if (vc == null || handle == null) {
return;
}
Map<Object, Object> map = vc.getStateMap();
// set connection handle into VC
Object vcLock = vc.getLockObject();
synchronized (vcLock) {
Object tmpHandle = map.get(CONNECTION_HANDLE_VC_KEY);
// If this connection already has a unique handle when we get here,
// something went wrong.
if (tmpHandle != null) {
throw new IllegalStateException("Connection " + tmpHandle + " has already been created");
}
map.put(CONNECTION_HANDLE_VC_KEY, handle);
}
} | java | public static void setConnectionHandle(VirtualConnection vc, ConnectionHandle handle) {
if (vc == null || handle == null) {
return;
}
Map<Object, Object> map = vc.getStateMap();
// set connection handle into VC
Object vcLock = vc.getLockObject();
synchronized (vcLock) {
Object tmpHandle = map.get(CONNECTION_HANDLE_VC_KEY);
// If this connection already has a unique handle when we get here,
// something went wrong.
if (tmpHandle != null) {
throw new IllegalStateException("Connection " + tmpHandle + " has already been created");
}
map.put(CONNECTION_HANDLE_VC_KEY, handle);
}
} | [
"public",
"static",
"void",
"setConnectionHandle",
"(",
"VirtualConnection",
"vc",
",",
"ConnectionHandle",
"handle",
")",
"{",
"if",
"(",
"vc",
"==",
"null",
"||",
"handle",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Map",
"<",
"Object",
",",
"Object",
... | Set the connection handle on the virtual connection.
@param vc
VirtualConnection containing simple state for this connection
@param handle
ConnectionHandle for the VirtualConnection | [
"Set",
"the",
"connection",
"handle",
"on",
"the",
"virtual",
"connection",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/wsspi/connmgmt/ConnectionHandle.java#L107-L126 |
Harium/keel | src/main/java/com/harium/keel/catalano/math/Tools.java | Tools.Angle | public static float Angle(float x, float y) {
if (y >= 0) {
if (x >= 0)
return (float) Math.atan(y / x);
return (float) (Math.PI - Math.atan(-y / x));
} else {
if (x >= 0)
return (float) (2 * Math.PI - Math.atan(-y / x));
return (float) (Math.PI + Math.atan(y / x));
}
} | java | public static float Angle(float x, float y) {
if (y >= 0) {
if (x >= 0)
return (float) Math.atan(y / x);
return (float) (Math.PI - Math.atan(-y / x));
} else {
if (x >= 0)
return (float) (2 * Math.PI - Math.atan(-y / x));
return (float) (Math.PI + Math.atan(y / x));
}
} | [
"public",
"static",
"float",
"Angle",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"if",
"(",
"y",
">=",
"0",
")",
"{",
"if",
"(",
"x",
">=",
"0",
")",
"return",
"(",
"float",
")",
"Math",
".",
"atan",
"(",
"y",
"/",
"x",
")",
";",
"retu... | Gets the angle formed by the vector [x,y].
@param x X axis coordinate.
@param y Y axis coordinate.
@return Angle formed by the vector. | [
"Gets",
"the",
"angle",
"formed",
"by",
"the",
"vector",
"[",
"x",
"y",
"]",
"."
] | train | https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/Tools.java#L85-L95 |
FaritorKang/unmz-common-util | src/main/java/net/unmz/java/util/http/Img2Base64Utils.java | Img2Base64Utils.generateImage | public static boolean generateImage(String imgStr, String imgFilePath) {
if (imgStr == null) //图像数据为空
return false;
try {
//Base64解码
byte[] b = Base64.decodeBase64(imgStr);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {//调整异常数据
b[i] += 256;
}
}
//生成jpeg图片
OutputStream out = new FileOutputStream(imgFilePath);
out.write(b);
out.flush();
out.close();
return true;
} catch (Exception e) {
return false;
}
} | java | public static boolean generateImage(String imgStr, String imgFilePath) {
if (imgStr == null) //图像数据为空
return false;
try {
//Base64解码
byte[] b = Base64.decodeBase64(imgStr);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {//调整异常数据
b[i] += 256;
}
}
//生成jpeg图片
OutputStream out = new FileOutputStream(imgFilePath);
out.write(b);
out.flush();
out.close();
return true;
} catch (Exception e) {
return false;
}
} | [
"public",
"static",
"boolean",
"generateImage",
"(",
"String",
"imgStr",
",",
"String",
"imgFilePath",
")",
"{",
"if",
"(",
"imgStr",
"==",
"null",
")",
"//图像数据为空",
"return",
"false",
";",
"try",
"{",
"//Base64解码",
"byte",
"[",
"]",
"b",
"=",
"Base64",
"... | 对字节数组字符串进行Base64解码并生成图片
@param imgStr 图片数据
@param imgFilePath 保存图片全路径地址
@return | [
"对字节数组字符串进行Base64解码并生成图片"
] | train | https://github.com/FaritorKang/unmz-common-util/blob/2912b8889b85ed910d536f85b24b6fa68035814a/src/main/java/net/unmz/java/util/http/Img2Base64Utils.java#L62-L83 |
ops4j/org.ops4j.pax.exam2 | core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/war/ZipBuilder.java | ZipBuilder.addDirectory | private void addDirectory(File root, File directory, String targetPath, ZipOutputStream zos) throws IOException {
String prefix = targetPath;
if (!prefix.isEmpty() && !prefix.endsWith("/")) {
prefix += "/";
}
// directory entries are required, or else bundle classpath may be
// broken
if (!directory.equals(root)) {
String path = normalizePath(root, directory);
ZipEntry jarEntry = new ZipEntry(prefix + path + "/");
jarOutputStream.putNextEntry(jarEntry);
}
File[] children = directory.listFiles();
// loop through dirList, and zip the files
for (File child : children) {
if (child.isDirectory()) {
addDirectory(root, child, prefix, jarOutputStream);
}
else {
addFile(root, child, prefix, jarOutputStream);
}
}
} | java | private void addDirectory(File root, File directory, String targetPath, ZipOutputStream zos) throws IOException {
String prefix = targetPath;
if (!prefix.isEmpty() && !prefix.endsWith("/")) {
prefix += "/";
}
// directory entries are required, or else bundle classpath may be
// broken
if (!directory.equals(root)) {
String path = normalizePath(root, directory);
ZipEntry jarEntry = new ZipEntry(prefix + path + "/");
jarOutputStream.putNextEntry(jarEntry);
}
File[] children = directory.listFiles();
// loop through dirList, and zip the files
for (File child : children) {
if (child.isDirectory()) {
addDirectory(root, child, prefix, jarOutputStream);
}
else {
addFile(root, child, prefix, jarOutputStream);
}
}
} | [
"private",
"void",
"addDirectory",
"(",
"File",
"root",
",",
"File",
"directory",
",",
"String",
"targetPath",
",",
"ZipOutputStream",
"zos",
")",
"throws",
"IOException",
"{",
"String",
"prefix",
"=",
"targetPath",
";",
"if",
"(",
"!",
"prefix",
".",
"isEmp... | Recursively adds the contents of the given directory and all subdirectories to the given ZIP
output stream.
@param root
an ancestor of {@code directory}, used to determine the relative path within the
archive
@param directory
current directory to be added
@param zos
ZIP output stream
@throws IOException | [
"Recursively",
"adds",
"the",
"contents",
"of",
"the",
"given",
"directory",
"and",
"all",
"subdirectories",
"to",
"the",
"given",
"ZIP",
"output",
"stream",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.exam2/blob/7f83796cbbb857123d8fc7fe817a7637218d5d77/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/war/ZipBuilder.java#L141-L163 |
marcos-garcia/smartsantanderdataanalysis | ssjsonformatterinterceptor/src/main/java/com/marcosgarciacasado/ssjsonformatterinterceptor/MeasureExtractor.java | MeasureExtractor.fillMeasures | public void fillMeasures(String measure, JSONObject jsonContent, Pattern pattern, HashMap<String,Double> i){
String tem = (String)jsonContent.get(measure);
if(tem != null){
Matcher tM = pattern.matcher(tem);
if(tM.find() && !tM.group(1).isEmpty()){
try{
i.put(measure, Double.valueOf(tM.group(1)));
}catch(NumberFormatException e){
e.printStackTrace();
}
}
}
} | java | public void fillMeasures(String measure, JSONObject jsonContent, Pattern pattern, HashMap<String,Double> i){
String tem = (String)jsonContent.get(measure);
if(tem != null){
Matcher tM = pattern.matcher(tem);
if(tM.find() && !tM.group(1).isEmpty()){
try{
i.put(measure, Double.valueOf(tM.group(1)));
}catch(NumberFormatException e){
e.printStackTrace();
}
}
}
} | [
"public",
"void",
"fillMeasures",
"(",
"String",
"measure",
",",
"JSONObject",
"jsonContent",
",",
"Pattern",
"pattern",
",",
"HashMap",
"<",
"String",
",",
"Double",
">",
"i",
")",
"{",
"String",
"tem",
"=",
"(",
"String",
")",
"jsonContent",
".",
"get",
... | Extracts a pattern from a measure value located in a JSONObject and stores it in a HashMap whether finds it.
@author Marcos García Casado | [
"Extracts",
"a",
"pattern",
"from",
"a",
"measure",
"value",
"located",
"in",
"a",
"JSONObject",
"and",
"stores",
"it",
"in",
"a",
"HashMap",
"whether",
"finds",
"it",
"."
] | train | https://github.com/marcos-garcia/smartsantanderdataanalysis/blob/dc259618887886e294c839a905b18994171d21ef/ssjsonformatterinterceptor/src/main/java/com/marcosgarciacasado/ssjsonformatterinterceptor/MeasureExtractor.java#L72-L84 |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java | PlaceRegistry.createPlace | public PlaceManager createPlace (PlaceConfig config)
throws InstantiationException, InvocationException
{
return createPlace(config, null, null);
} | java | public PlaceManager createPlace (PlaceConfig config)
throws InstantiationException, InvocationException
{
return createPlace(config, null, null);
} | [
"public",
"PlaceManager",
"createPlace",
"(",
"PlaceConfig",
"config",
")",
"throws",
"InstantiationException",
",",
"InvocationException",
"{",
"return",
"createPlace",
"(",
"config",
",",
"null",
",",
"null",
")",
";",
"}"
] | Creates and registers a new place manager with no delegates.
@see #createPlace(PlaceConfig,List) | [
"Creates",
"and",
"registers",
"a",
"new",
"place",
"manager",
"with",
"no",
"delegates",
"."
] | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java#L82-L86 |
tvbarthel/Cheerleader | library/src/main/java/fr/tvbarthel/cheerleader/library/helpers/SoundCloudArtworkHelper.java | SoundCloudArtworkHelper.getArtworkUrl | public static String getArtworkUrl(SoundCloudTrack track, String size) {
String defaultUrl = track.getArtworkUrl();
if (defaultUrl == null) {
return null;
}
switch (size) {
case MINI:
case TINY:
case SMALL:
case BADGE:
case LARGE:
case XLARGE:
case XXLARGE:
case XXXLARGE:
return defaultUrl.replace(LARGE, size);
default:
return defaultUrl;
}
} | java | public static String getArtworkUrl(SoundCloudTrack track, String size) {
String defaultUrl = track.getArtworkUrl();
if (defaultUrl == null) {
return null;
}
switch (size) {
case MINI:
case TINY:
case SMALL:
case BADGE:
case LARGE:
case XLARGE:
case XXLARGE:
case XXXLARGE:
return defaultUrl.replace(LARGE, size);
default:
return defaultUrl;
}
} | [
"public",
"static",
"String",
"getArtworkUrl",
"(",
"SoundCloudTrack",
"track",
",",
"String",
"size",
")",
"{",
"String",
"defaultUrl",
"=",
"track",
".",
"getArtworkUrl",
"(",
")",
";",
"if",
"(",
"defaultUrl",
"==",
"null",
")",
"{",
"return",
"null",
"... | Retrieve the artwork url of a track pointing to the requested size.
<p/>
By default, {@link fr.tvbarthel.cheerleader.library.client.SoundCloudTrack#getArtworkUrl()}
points to the {@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#LARGE}
<p/>
Available size are :
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#MINI}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#TINY}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#SMALL}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#BADGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#LARGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#XLARGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#XXLARGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#XXXLARGE}
@param track track from which artwork url should be returned.
@param size wished size.
@return artwork url or null if no artwork are available. | [
"Retrieve",
"the",
"artwork",
"url",
"of",
"a",
"track",
"pointing",
"to",
"the",
"requested",
"size",
".",
"<p",
"/",
">",
"By",
"default",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"client",
".",
"SoundCloudTrack#getA... | train | https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/helpers/SoundCloudArtworkHelper.java#L78-L96 |
SeaCloudsEU/SeaCloudsPlatform | dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java | DeployerProxy.getEntitySensorsValue | public String getEntitySensorsValue(String brooklynId, String brooklynEntityId, String sensorId) throws IOException {
Invocation invocation = getJerseyClient().target(
getEndpoint() + "/v1/applications/" + brooklynId + "/entities/" + brooklynEntityId + "/sensors/" + sensorId + "?raw=true")
.request().buildGet();
return invocation.invoke().readEntity(String.class);
} | java | public String getEntitySensorsValue(String brooklynId, String brooklynEntityId, String sensorId) throws IOException {
Invocation invocation = getJerseyClient().target(
getEndpoint() + "/v1/applications/" + brooklynId + "/entities/" + brooklynEntityId + "/sensors/" + sensorId + "?raw=true")
.request().buildGet();
return invocation.invoke().readEntity(String.class);
} | [
"public",
"String",
"getEntitySensorsValue",
"(",
"String",
"brooklynId",
",",
"String",
"brooklynEntityId",
",",
"String",
"sensorId",
")",
"throws",
"IOException",
"{",
"Invocation",
"invocation",
"=",
"getJerseyClient",
"(",
")",
".",
"target",
"(",
"getEndpoint"... | Creates a proxied HTTP GET request to Apache Brooklyn to retrieve Sensors from a particular Entity
@param brooklynId of the desired application to fetch. This ID may differ from SeaClouds Application ID
@param brooklynEntityId of the desired entity. This Entity ID should be children of brooklynId
@param sensorId of the desired sensor. This Sensor ID should be children of brooklynEntityid
@return String representing the sensor value | [
"Creates",
"a",
"proxied",
"HTTP",
"GET",
"request",
"to",
"Apache",
"Brooklyn",
"to",
"retrieve",
"Sensors",
"from",
"a",
"particular",
"Entity"
] | train | https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java#L122-L128 |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/Zips.java | Zips.createZipFile | public static void createZipFile(Logger log, File sourceDir, File outputZipFile) throws IOException {
FileFilter filter = null;
createZipFile(log, sourceDir, outputZipFile, filter);
} | java | public static void createZipFile(Logger log, File sourceDir, File outputZipFile) throws IOException {
FileFilter filter = null;
createZipFile(log, sourceDir, outputZipFile, filter);
} | [
"public",
"static",
"void",
"createZipFile",
"(",
"Logger",
"log",
",",
"File",
"sourceDir",
",",
"File",
"outputZipFile",
")",
"throws",
"IOException",
"{",
"FileFilter",
"filter",
"=",
"null",
";",
"createZipFile",
"(",
"log",
",",
"sourceDir",
",",
"outputZ... | Creates a zip fie from the given source directory and output zip file name | [
"Creates",
"a",
"zip",
"fie",
"from",
"the",
"given",
"source",
"directory",
"and",
"output",
"zip",
"file",
"name"
] | train | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/Zips.java#L43-L46 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java | AppServiceEnvironmentsInner.listMultiRolePoolSkusWithServiceResponseAsync | public Observable<ServiceResponse<Page<SkuInfoInner>>> listMultiRolePoolSkusWithServiceResponseAsync(final String resourceGroupName, final String name) {
return listMultiRolePoolSkusSinglePageAsync(resourceGroupName, name)
.concatMap(new Func1<ServiceResponse<Page<SkuInfoInner>>, Observable<ServiceResponse<Page<SkuInfoInner>>>>() {
@Override
public Observable<ServiceResponse<Page<SkuInfoInner>>> call(ServiceResponse<Page<SkuInfoInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listMultiRolePoolSkusNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<SkuInfoInner>>> listMultiRolePoolSkusWithServiceResponseAsync(final String resourceGroupName, final String name) {
return listMultiRolePoolSkusSinglePageAsync(resourceGroupName, name)
.concatMap(new Func1<ServiceResponse<Page<SkuInfoInner>>, Observable<ServiceResponse<Page<SkuInfoInner>>>>() {
@Override
public Observable<ServiceResponse<Page<SkuInfoInner>>> call(ServiceResponse<Page<SkuInfoInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listMultiRolePoolSkusNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"SkuInfoInner",
">",
">",
">",
"listMultiRolePoolSkusWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"name",
")",
"{",
"return",
"listMultiRolePoolSkusSingl... | Get available SKUs for scaling a multi-role pool.
Get available SKUs for scaling a multi-role pool.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<SkuInfoInner> object | [
"Get",
"available",
"SKUs",
"for",
"scaling",
"a",
"multi",
"-",
"role",
"pool",
".",
"Get",
"available",
"SKUs",
"for",
"scaling",
"a",
"multi",
"-",
"role",
"pool",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L3431-L3443 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/CassandraClientBase.java | CassandraClientBase.setBatchSize | private void setBatchSize(String persistenceUnit, Map<String, Object> puProperties) {
String batch_Size = null;
PersistenceUnitMetadata puMetadata =
KunderaMetadataManager.getPersistenceUnitMetadata(kunderaMetadata, persistenceUnit);
String externalBatchSize =
puProperties != null ? (String) puProperties.get(PersistenceProperties.KUNDERA_BATCH_SIZE) : null;
Integer intbatch = null;
if (puMetadata.getBatchSize() > 0) {
intbatch = new Integer(puMetadata.getBatchSize());
}
batch_Size =
(String) (externalBatchSize != null ? externalBatchSize : intbatch != null ? intbatch.toString() : null);
setBatchSize(batch_Size);
} | java | private void setBatchSize(String persistenceUnit, Map<String, Object> puProperties) {
String batch_Size = null;
PersistenceUnitMetadata puMetadata =
KunderaMetadataManager.getPersistenceUnitMetadata(kunderaMetadata, persistenceUnit);
String externalBatchSize =
puProperties != null ? (String) puProperties.get(PersistenceProperties.KUNDERA_BATCH_SIZE) : null;
Integer intbatch = null;
if (puMetadata.getBatchSize() > 0) {
intbatch = new Integer(puMetadata.getBatchSize());
}
batch_Size =
(String) (externalBatchSize != null ? externalBatchSize : intbatch != null ? intbatch.toString() : null);
setBatchSize(batch_Size);
} | [
"private",
"void",
"setBatchSize",
"(",
"String",
"persistenceUnit",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"puProperties",
")",
"{",
"String",
"batch_Size",
"=",
"null",
";",
"PersistenceUnitMetadata",
"puMetadata",
"=",
"KunderaMetadataManager",
".",
"ge... | Sets the batch size.
@param persistenceUnit
the persistence unit
@param puProperties
the pu properties | [
"Sets",
"the",
"batch",
"size",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/CassandraClientBase.java#L1880-L1897 |
jhunters/jprotobuf | v3/src/main/java/com/baidu/bjf/remoting/protobuf/code/CodedConstant.java | CodedConstant.computeElementSizeNoTag | public static int computeElementSizeNoTag(final WireFormat.FieldType type, final Object value) {
switch (type) {
// Note: Minor violation of 80-char limit rule here because this would
// actually be harder to read if we wrapped the lines.
case DOUBLE:
return CodedOutputStream.computeDoubleSizeNoTag((Double) value);
case FLOAT:
return CodedOutputStream.computeFloatSizeNoTag((Float) value);
case INT64:
return CodedOutputStream.computeInt64SizeNoTag((Long) value);
case UINT64:
return CodedOutputStream.computeUInt64SizeNoTag((Long) value);
case INT32:
return CodedOutputStream.computeInt32SizeNoTag((Integer) value);
case FIXED64:
return CodedOutputStream.computeFixed64SizeNoTag((Long) value);
case FIXED32:
return CodedOutputStream.computeFixed32SizeNoTag((Integer) value);
case BOOL:
return CodedOutputStream.computeBoolSizeNoTag((Boolean) value);
case STRING:
return CodedOutputStream.computeStringSizeNoTag((String) value);
case GROUP:
return CodedOutputStream.computeGroupSizeNoTag((MessageLite) value);
case BYTES:
if (value instanceof ByteString) {
return CodedOutputStream.computeBytesSizeNoTag((ByteString) value);
} else {
return CodedOutputStream.computeByteArraySizeNoTag((byte[]) value);
}
case UINT32:
return CodedOutputStream.computeUInt32SizeNoTag((Integer) value);
case SFIXED32:
return CodedOutputStream.computeSFixed32SizeNoTag((Integer) value);
case SFIXED64:
return CodedOutputStream.computeSFixed64SizeNoTag((Long) value);
case SINT32:
return CodedOutputStream.computeSInt32SizeNoTag((Integer) value);
case SINT64:
return CodedOutputStream.computeSInt64SizeNoTag((Long) value);
case MESSAGE:
if (value instanceof LazyField) {
return CodedOutputStream.computeLazyFieldSizeNoTag((LazyField) value);
} else {
return computeObjectSizeNoTag(value);
}
case ENUM:
if (value instanceof Internal.EnumLite) {
return CodedOutputStream.computeEnumSizeNoTag(((Internal.EnumLite) value).getNumber());
} else {
if (value instanceof EnumReadable) {
return CodedOutputStream.computeEnumSizeNoTag(((EnumReadable) value).value());
} else if (value instanceof Enum) {
return CodedOutputStream.computeEnumSizeNoTag(((Enum) value).ordinal());
}
return CodedOutputStream.computeEnumSizeNoTag((Integer) value);
}
}
throw new RuntimeException("There is no way to get here, but the compiler thinks otherwise.");
} | java | public static int computeElementSizeNoTag(final WireFormat.FieldType type, final Object value) {
switch (type) {
// Note: Minor violation of 80-char limit rule here because this would
// actually be harder to read if we wrapped the lines.
case DOUBLE:
return CodedOutputStream.computeDoubleSizeNoTag((Double) value);
case FLOAT:
return CodedOutputStream.computeFloatSizeNoTag((Float) value);
case INT64:
return CodedOutputStream.computeInt64SizeNoTag((Long) value);
case UINT64:
return CodedOutputStream.computeUInt64SizeNoTag((Long) value);
case INT32:
return CodedOutputStream.computeInt32SizeNoTag((Integer) value);
case FIXED64:
return CodedOutputStream.computeFixed64SizeNoTag((Long) value);
case FIXED32:
return CodedOutputStream.computeFixed32SizeNoTag((Integer) value);
case BOOL:
return CodedOutputStream.computeBoolSizeNoTag((Boolean) value);
case STRING:
return CodedOutputStream.computeStringSizeNoTag((String) value);
case GROUP:
return CodedOutputStream.computeGroupSizeNoTag((MessageLite) value);
case BYTES:
if (value instanceof ByteString) {
return CodedOutputStream.computeBytesSizeNoTag((ByteString) value);
} else {
return CodedOutputStream.computeByteArraySizeNoTag((byte[]) value);
}
case UINT32:
return CodedOutputStream.computeUInt32SizeNoTag((Integer) value);
case SFIXED32:
return CodedOutputStream.computeSFixed32SizeNoTag((Integer) value);
case SFIXED64:
return CodedOutputStream.computeSFixed64SizeNoTag((Long) value);
case SINT32:
return CodedOutputStream.computeSInt32SizeNoTag((Integer) value);
case SINT64:
return CodedOutputStream.computeSInt64SizeNoTag((Long) value);
case MESSAGE:
if (value instanceof LazyField) {
return CodedOutputStream.computeLazyFieldSizeNoTag((LazyField) value);
} else {
return computeObjectSizeNoTag(value);
}
case ENUM:
if (value instanceof Internal.EnumLite) {
return CodedOutputStream.computeEnumSizeNoTag(((Internal.EnumLite) value).getNumber());
} else {
if (value instanceof EnumReadable) {
return CodedOutputStream.computeEnumSizeNoTag(((EnumReadable) value).value());
} else if (value instanceof Enum) {
return CodedOutputStream.computeEnumSizeNoTag(((Enum) value).ordinal());
}
return CodedOutputStream.computeEnumSizeNoTag((Integer) value);
}
}
throw new RuntimeException("There is no way to get here, but the compiler thinks otherwise.");
} | [
"public",
"static",
"int",
"computeElementSizeNoTag",
"(",
"final",
"WireFormat",
".",
"FieldType",
"type",
",",
"final",
"Object",
"value",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"// Note: Minor violation of 80-char limit rule here because this would\r",
"// actually... | Compute the number of bytes that would be needed to encode a particular value of arbitrary type, excluding tag.
@param type The field's type.
@param value Object representing the field's value. Must be of the exact type which would be returned by
{@link Message#getField(Descriptors.FieldDescriptor)} for this field.
@return the int | [
"Compute",
"the",
"number",
"of",
"bytes",
"that",
"would",
"be",
"needed",
"to",
"encode",
"a",
"particular",
"value",
"of",
"arbitrary",
"type",
"excluding",
"tag",
"."
] | train | https://github.com/jhunters/jprotobuf/blob/55832c9b4792afb128e5b35139d8a3891561d8a3/v3/src/main/java/com/baidu/bjf/remoting/protobuf/code/CodedConstant.java#L1296-L1359 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/CollationController.java | CollationController.reduceNameFilter | private void reduceNameFilter(QueryFilter filter, ColumnFamily container, long sstableTimestamp)
{
if (container == null)
return;
for (Iterator<CellName> iterator = ((NamesQueryFilter) filter.filter).columns.iterator(); iterator.hasNext(); )
{
CellName filterColumn = iterator.next();
Cell cell = container.getColumn(filterColumn);
if (cell != null && cell.timestamp() > sstableTimestamp)
iterator.remove();
}
} | java | private void reduceNameFilter(QueryFilter filter, ColumnFamily container, long sstableTimestamp)
{
if (container == null)
return;
for (Iterator<CellName> iterator = ((NamesQueryFilter) filter.filter).columns.iterator(); iterator.hasNext(); )
{
CellName filterColumn = iterator.next();
Cell cell = container.getColumn(filterColumn);
if (cell != null && cell.timestamp() > sstableTimestamp)
iterator.remove();
}
} | [
"private",
"void",
"reduceNameFilter",
"(",
"QueryFilter",
"filter",
",",
"ColumnFamily",
"container",
",",
"long",
"sstableTimestamp",
")",
"{",
"if",
"(",
"container",
"==",
"null",
")",
"return",
";",
"for",
"(",
"Iterator",
"<",
"CellName",
">",
"iterator"... | remove columns from @param filter where we already have data in @param container newer than @param sstableTimestamp | [
"remove",
"columns",
"from"
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/CollationController.java#L184-L196 |
ThreeTen/threetenbp | src/main/java/org/threeten/bp/format/DateTimeFormatterBuilder.java | DateTimeFormatterBuilder.appendFraction | public DateTimeFormatterBuilder appendFraction(
TemporalField field, int minWidth, int maxWidth, boolean decimalPoint) {
appendInternal(new FractionPrinterParser(field, minWidth, maxWidth, decimalPoint));
return this;
} | java | public DateTimeFormatterBuilder appendFraction(
TemporalField field, int minWidth, int maxWidth, boolean decimalPoint) {
appendInternal(new FractionPrinterParser(field, minWidth, maxWidth, decimalPoint));
return this;
} | [
"public",
"DateTimeFormatterBuilder",
"appendFraction",
"(",
"TemporalField",
"field",
",",
"int",
"minWidth",
",",
"int",
"maxWidth",
",",
"boolean",
"decimalPoint",
")",
"{",
"appendInternal",
"(",
"new",
"FractionPrinterParser",
"(",
"field",
",",
"minWidth",
","... | Appends the fractional value of a date-time field to the formatter.
<p>
The fractional value of the field will be output including the
preceding decimal point. The preceding value is not output.
For example, the second-of-minute value of 15 would be output as {@code .25}.
<p>
The width of the printed fraction can be controlled. Setting the
minimum width to zero will cause no output to be generated.
The printed fraction will have the minimum width necessary between
the minimum and maximum widths - trailing zeroes are omitted.
No rounding occurs due to the maximum width - digits are simply dropped.
<p>
When parsing in strict mode, the number of parsed digits must be between
the minimum and maximum width. When parsing in lenient mode, the minimum
width is considered to be zero and the maximum is nine.
<p>
If the value cannot be obtained then an exception will be thrown.
If the value is negative an exception will be thrown.
If the field does not have a fixed set of valid values then an
exception will be thrown.
If the field value in the date-time to be printed is invalid it
cannot be printed and an exception will be thrown.
@param field the field to append, not null
@param minWidth the minimum width of the field excluding the decimal point, from 0 to 9
@param maxWidth the maximum width of the field excluding the decimal point, from 1 to 9
@param decimalPoint whether to output the localized decimal point symbol
@return this, for chaining, not null
@throws IllegalArgumentException if the field has a variable set of valid values or
either width is invalid | [
"Appends",
"the",
"fractional",
"value",
"of",
"a",
"date",
"-",
"time",
"field",
"to",
"the",
"formatter",
".",
"<p",
">",
"The",
"fractional",
"value",
"of",
"the",
"field",
"will",
"be",
"output",
"including",
"the",
"preceding",
"decimal",
"point",
"."... | train | https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/format/DateTimeFormatterBuilder.java#L639-L643 |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java | ExpandableRecyclerAdapter.notifyChildRemoved | @UiThread
public void notifyChildRemoved(int parentPosition, int childPosition) {
int flatParentPosition = getFlatParentPosition(parentPosition);
ExpandableWrapper<P, C> parentWrapper = mFlatItemList.get(flatParentPosition);
parentWrapper.setParent(mParentList.get(parentPosition));
if (parentWrapper.isExpanded()) {
mFlatItemList.remove(flatParentPosition + childPosition + 1);
notifyItemRemoved(flatParentPosition + childPosition + 1);
}
} | java | @UiThread
public void notifyChildRemoved(int parentPosition, int childPosition) {
int flatParentPosition = getFlatParentPosition(parentPosition);
ExpandableWrapper<P, C> parentWrapper = mFlatItemList.get(flatParentPosition);
parentWrapper.setParent(mParentList.get(parentPosition));
if (parentWrapper.isExpanded()) {
mFlatItemList.remove(flatParentPosition + childPosition + 1);
notifyItemRemoved(flatParentPosition + childPosition + 1);
}
} | [
"@",
"UiThread",
"public",
"void",
"notifyChildRemoved",
"(",
"int",
"parentPosition",
",",
"int",
"childPosition",
")",
"{",
"int",
"flatParentPosition",
"=",
"getFlatParentPosition",
"(",
"parentPosition",
")",
";",
"ExpandableWrapper",
"<",
"P",
",",
"C",
">",
... | Notify any registered observers that the parent located at {@code parentPosition}
has a child that has been removed from the data set, previously located at {@code childPosition}.
The child list item previously located at and after {@code childPosition} may
now be found at {@code childPosition - 1}.
<p>
This is a structural change event. Representations of other existing items in the
data set are still considered up to date and will not be rebound, though their positions
may be altered.
@param parentPosition Position of the parent which has a child removed from, relative
to the list of parents only.
@param childPosition Position of the child that has been removed, relative to children
of the parent specified by {@code parentPosition} only. | [
"Notify",
"any",
"registered",
"observers",
"that",
"the",
"parent",
"located",
"at",
"{",
"@code",
"parentPosition",
"}",
"has",
"a",
"child",
"that",
"has",
"been",
"removed",
"from",
"the",
"data",
"set",
"previously",
"located",
"at",
"{",
"@code",
"chil... | train | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java#L1188-L1198 |
google/error-prone-javac | src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java | JShellTool.prefixError | String prefixError(String s) {
return prefix(s, feedback.getErrorPre(), feedback.getErrorPost());
} | java | String prefixError(String s) {
return prefix(s, feedback.getErrorPre(), feedback.getErrorPost());
} | [
"String",
"prefixError",
"(",
"String",
"s",
")",
"{",
"return",
"prefix",
"(",
"s",
",",
"feedback",
".",
"getErrorPre",
"(",
")",
",",
"feedback",
".",
"getErrorPost",
"(",
")",
")",
";",
"}"
] | Add error prefixing/postfixing to embedded newlines in a string,
bracketing with error prefix/postfix
@param s the string to prefix
@return the pre/post-fixed and bracketed string | [
"Add",
"error",
"prefixing",
"/",
"postfixing",
"to",
"embedded",
"newlines",
"in",
"a",
"string",
"bracketing",
"with",
"error",
"prefix",
"/",
"postfix"
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java#L746-L748 |
alipay/sofa-rpc | core/common/src/main/java/com/alipay/sofa/rpc/common/utils/ClassUtils.java | ClassUtils.forName | public static Class forName(String className, ClassLoader cl) {
try {
return Class.forName(className, true, cl);
} catch (Exception e) {
throw new SofaRpcRuntimeException(e);
}
} | java | public static Class forName(String className, ClassLoader cl) {
try {
return Class.forName(className, true, cl);
} catch (Exception e) {
throw new SofaRpcRuntimeException(e);
}
} | [
"public",
"static",
"Class",
"forName",
"(",
"String",
"className",
",",
"ClassLoader",
"cl",
")",
"{",
"try",
"{",
"return",
"Class",
".",
"forName",
"(",
"className",
",",
"true",
",",
"cl",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
... | 根据类名加载Class
@param className 类名
@param cl Classloader
@return Class | [
"根据类名加载Class"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core/common/src/main/java/com/alipay/sofa/rpc/common/utils/ClassUtils.java#L70-L76 |
dbracewell/mango | src/main/java/com/davidbracewell/scripting/ScriptEnvironment.java | ScriptEnvironment.invokeMethod | public Object invokeMethod(Object o, String name, Object... args) throws ScriptException,
NoSuchMethodException {
Invocable inv = (Invocable) engine;
return inv.invokeMethod(o, name, args);
} | java | public Object invokeMethod(Object o, String name, Object... args) throws ScriptException,
NoSuchMethodException {
Invocable inv = (Invocable) engine;
return inv.invokeMethod(o, name, args);
} | [
"public",
"Object",
"invokeMethod",
"(",
"Object",
"o",
",",
"String",
"name",
",",
"Object",
"...",
"args",
")",
"throws",
"ScriptException",
",",
"NoSuchMethodException",
"{",
"Invocable",
"inv",
"=",
"(",
"Invocable",
")",
"engine",
";",
"return",
"inv",
... | <p> Calls a method on a script object compiled during a previous script execution, which is retained in the state
of the ScriptEngine. </p>
@param o If the procedure is a member of a class defined in the script and o is an instance of that class
returned by a previous execution or invocation, the named method is called through that instance.
@param name The name of the procedure to be called.
@param args Arguments to pass to the procedure. The rules for converting the arguments to scripting variables are
implementation-specific.
@return The value returned by the procedure. The rules for converting the scripting variable returned by the
script
method to a Java Object are implementation-specific.
@throws javax.script.ScriptException Something went wrong
@throws NoSuchMethodException Method did not exist | [
"<p",
">",
"Calls",
"a",
"method",
"on",
"a",
"script",
"object",
"compiled",
"during",
"a",
"previous",
"script",
"execution",
"which",
"is",
"retained",
"in",
"the",
"state",
"of",
"the",
"ScriptEngine",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/scripting/ScriptEnvironment.java#L145-L149 |
undertow-io/undertow | core/src/main/java/io/undertow/server/handlers/ChannelUpgradeHandler.java | ChannelUpgradeHandler.removeProtocol | public synchronized void removeProtocol(String productString, ChannelListener<? super StreamConnection> openListener) {
List<Holder> holders = handlers.get(productString);
if (holders == null) {
return;
}
Iterator<Holder> it = holders.iterator();
while (it.hasNext()) {
Holder holder = it.next();
if (holder.channelListener == openListener) {
holders.remove(holder);
break;
}
}
if (holders.isEmpty()) {
handlers.remove(productString);
}
} | java | public synchronized void removeProtocol(String productString, ChannelListener<? super StreamConnection> openListener) {
List<Holder> holders = handlers.get(productString);
if (holders == null) {
return;
}
Iterator<Holder> it = holders.iterator();
while (it.hasNext()) {
Holder holder = it.next();
if (holder.channelListener == openListener) {
holders.remove(holder);
break;
}
}
if (holders.isEmpty()) {
handlers.remove(productString);
}
} | [
"public",
"synchronized",
"void",
"removeProtocol",
"(",
"String",
"productString",
",",
"ChannelListener",
"<",
"?",
"super",
"StreamConnection",
">",
"openListener",
")",
"{",
"List",
"<",
"Holder",
">",
"holders",
"=",
"handlers",
".",
"get",
"(",
"productStr... | Remove a protocol from this handler.
@param productString the product string to match
@param openListener The open listener | [
"Remove",
"a",
"protocol",
"from",
"this",
"handler",
"."
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/server/handlers/ChannelUpgradeHandler.java#L126-L142 |
jamesagnew/hapi-fhir | hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/CSVReader.java | CSVReader.parseLine | public String[] parseLine() throws IOException, FHIRException {
List<String> res = new ArrayList<String>();
StringBuilder b = new StringBuilder();
boolean inQuote = false;
while (inQuote || (peek() != '\r' && peek() != '\n')) {
char c = peek();
next();
if (c == '"')
inQuote = !inQuote;
else if (!inQuote && c == ',') {
res.add(b.toString().trim());
b = new StringBuilder();
}
else
b.append(c);
}
res.add(b.toString().trim());
while (ready() && (peek() == '\r' || peek() == '\n')) {
next();
}
String[] r = new String[] {};
r = res.toArray(r);
return r;
} | java | public String[] parseLine() throws IOException, FHIRException {
List<String> res = new ArrayList<String>();
StringBuilder b = new StringBuilder();
boolean inQuote = false;
while (inQuote || (peek() != '\r' && peek() != '\n')) {
char c = peek();
next();
if (c == '"')
inQuote = !inQuote;
else if (!inQuote && c == ',') {
res.add(b.toString().trim());
b = new StringBuilder();
}
else
b.append(c);
}
res.add(b.toString().trim());
while (ready() && (peek() == '\r' || peek() == '\n')) {
next();
}
String[] r = new String[] {};
r = res.toArray(r);
return r;
} | [
"public",
"String",
"[",
"]",
"parseLine",
"(",
")",
"throws",
"IOException",
",",
"FHIRException",
"{",
"List",
"<",
"String",
">",
"res",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"StringBuilder",
"b",
"=",
"new",
"StringBuilder",
"("... | Split one line in a CSV file into its rows. Comma's appearing in double quoted strings will
not be seen as a separator.
@return
@throws IOException
@throws FHIRException
@ | [
"Split",
"one",
"line",
"in",
"a",
"CSV",
"file",
"into",
"its",
"rows",
".",
"Comma",
"s",
"appearing",
"in",
"double",
"quoted",
"strings",
"will",
"not",
"be",
"seen",
"as",
"a",
"separator",
"."
] | train | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/CSVReader.java#L119-L145 |
apache/groovy | subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/extensions/DateUtilExtensions.java | DateUtilExtensions.putAt | public static void putAt(Date self, int field, int value) {
Calendar cal = Calendar.getInstance();
cal.setTime(self);
putAt(cal, field, value);
self.setTime(cal.getTimeInMillis());
} | java | public static void putAt(Date self, int field, int value) {
Calendar cal = Calendar.getInstance();
cal.setTime(self);
putAt(cal, field, value);
self.setTime(cal.getTimeInMillis());
} | [
"public",
"static",
"void",
"putAt",
"(",
"Date",
"self",
",",
"int",
"field",
",",
"int",
"value",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"self",
")",
";",
"putAt",
"(",
"cal",
... | Support the subscript operator for mutating a Date.
@param self A Date
@param field A Calendar field, e.g. MONTH
@param value The value for the given field, e.g. FEBRUARY
@see #putAt(java.util.Calendar, int, int)
@see java.util.Calendar#set(int, int)
@since 1.7.3 | [
"Support",
"the",
"subscript",
"operator",
"for",
"mutating",
"a",
"Date",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/extensions/DateUtilExtensions.java#L111-L116 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/validation/DOValidatorImpl.java | DOValidatorImpl.validateXMLSchema | private void validateXMLSchema(InputStream objectAsStream, DOValidatorXMLSchema xsv)
throws ObjectValidityException, GeneralException {
try {
xsv.validate(objectAsStream);
} catch (ObjectValidityException e) {
logger.error("VALIDATE: ERROR - failed XML Schema validation.", e);
throw e;
} catch (Exception e) {
logger.error("VALIDATE: ERROR - failed XML Schema validation.", e);
throw new ObjectValidityException("[DOValidatorImpl]: validateXMLSchema. "
+ e.getMessage());
}
logger.debug("VALIDATE: SUCCESS - passed XML Schema validation.");
} | java | private void validateXMLSchema(InputStream objectAsStream, DOValidatorXMLSchema xsv)
throws ObjectValidityException, GeneralException {
try {
xsv.validate(objectAsStream);
} catch (ObjectValidityException e) {
logger.error("VALIDATE: ERROR - failed XML Schema validation.", e);
throw e;
} catch (Exception e) {
logger.error("VALIDATE: ERROR - failed XML Schema validation.", e);
throw new ObjectValidityException("[DOValidatorImpl]: validateXMLSchema. "
+ e.getMessage());
}
logger.debug("VALIDATE: SUCCESS - passed XML Schema validation.");
} | [
"private",
"void",
"validateXMLSchema",
"(",
"InputStream",
"objectAsStream",
",",
"DOValidatorXMLSchema",
"xsv",
")",
"throws",
"ObjectValidityException",
",",
"GeneralException",
"{",
"try",
"{",
"xsv",
".",
"validate",
"(",
"objectAsStream",
")",
";",
"}",
"catch... | Do XML Schema validation on the Fedora object.
@param objectAsFile
The digital object provided as a file.
@throws ObjectValidityException
If validation fails for any reason.
@throws GeneralException
If validation fails for any reason. | [
"Do",
"XML",
"Schema",
"validation",
"on",
"the",
"Fedora",
"object",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/validation/DOValidatorImpl.java#L357-L371 |
pugwoo/nimble-orm | src/main/java/com/pugwoo/dbhelper/sql/SQLUtils.java | SQLUtils.getSelectSQL | public static String getSelectSQL(Class<?> clazz, boolean selectOnlyKey, boolean withSQL_CALC_FOUND_ROWS) {
StringBuilder sql = new StringBuilder();
sql.append("SELECT ");
if(withSQL_CALC_FOUND_ROWS) {
sql.append("SQL_CALC_FOUND_ROWS ");
}
// 处理join方式clazz
JoinTable joinTable = DOInfoReader.getJoinTable(clazz);
if(joinTable != null) {
Field leftTableField = DOInfoReader.getJoinLeftTable(clazz);
Field rightTableField = DOInfoReader.getJoinRightTable(clazz);
JoinLeftTable joinLeftTable = leftTableField.getAnnotation(JoinLeftTable.class);
JoinRightTable joinRightTable = rightTableField.getAnnotation(JoinRightTable.class);
Table table1 = DOInfoReader.getTable(leftTableField.getType());
List<Field> fields1 = DOInfoReader.getColumnsForSelect(leftTableField.getType(), selectOnlyKey);
Table table2 = DOInfoReader.getTable(rightTableField.getType());
List<Field> fields2 = DOInfoReader.getColumnsForSelect(rightTableField.getType(), selectOnlyKey);
sql.append(join(fields1, ",", joinLeftTable.alias() + "."));
sql.append(",");
sql.append(join(fields2, ",", joinRightTable.alias() + "."));
sql.append(" FROM ").append(getTableName(table1))
.append(" ").append(joinLeftTable.alias()).append(" ");
sql.append(joinTable.joinType().getCode()).append(" ");
sql.append(getTableName(table2)).append(" ").append(joinRightTable.alias());
if(joinTable.on() == null || joinTable.on().trim().isEmpty()) {
throw new OnConditionIsNeedException("join table :" + clazz.getName());
}
sql.append(" on ").append(joinTable.on().trim());
} else {
Table table = DOInfoReader.getTable(clazz);
List<Field> fields = DOInfoReader.getColumnsForSelect(clazz, selectOnlyKey);
sql.append(join(fields, ","));
sql.append(" FROM ").append(getTableName(table)).append(" ").append(table.alias());
}
return sql.toString();
} | java | public static String getSelectSQL(Class<?> clazz, boolean selectOnlyKey, boolean withSQL_CALC_FOUND_ROWS) {
StringBuilder sql = new StringBuilder();
sql.append("SELECT ");
if(withSQL_CALC_FOUND_ROWS) {
sql.append("SQL_CALC_FOUND_ROWS ");
}
// 处理join方式clazz
JoinTable joinTable = DOInfoReader.getJoinTable(clazz);
if(joinTable != null) {
Field leftTableField = DOInfoReader.getJoinLeftTable(clazz);
Field rightTableField = DOInfoReader.getJoinRightTable(clazz);
JoinLeftTable joinLeftTable = leftTableField.getAnnotation(JoinLeftTable.class);
JoinRightTable joinRightTable = rightTableField.getAnnotation(JoinRightTable.class);
Table table1 = DOInfoReader.getTable(leftTableField.getType());
List<Field> fields1 = DOInfoReader.getColumnsForSelect(leftTableField.getType(), selectOnlyKey);
Table table2 = DOInfoReader.getTable(rightTableField.getType());
List<Field> fields2 = DOInfoReader.getColumnsForSelect(rightTableField.getType(), selectOnlyKey);
sql.append(join(fields1, ",", joinLeftTable.alias() + "."));
sql.append(",");
sql.append(join(fields2, ",", joinRightTable.alias() + "."));
sql.append(" FROM ").append(getTableName(table1))
.append(" ").append(joinLeftTable.alias()).append(" ");
sql.append(joinTable.joinType().getCode()).append(" ");
sql.append(getTableName(table2)).append(" ").append(joinRightTable.alias());
if(joinTable.on() == null || joinTable.on().trim().isEmpty()) {
throw new OnConditionIsNeedException("join table :" + clazz.getName());
}
sql.append(" on ").append(joinTable.on().trim());
} else {
Table table = DOInfoReader.getTable(clazz);
List<Field> fields = DOInfoReader.getColumnsForSelect(clazz, selectOnlyKey);
sql.append(join(fields, ","));
sql.append(" FROM ").append(getTableName(table)).append(" ").append(table.alias());
}
return sql.toString();
} | [
"public",
"static",
"String",
"getSelectSQL",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"boolean",
"selectOnlyKey",
",",
"boolean",
"withSQL_CALC_FOUND_ROWS",
")",
"{",
"StringBuilder",
"sql",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sql",
".",
"append",
... | select 字段 from t_table, 不包含where子句及以后的语句
@param clazz
@param selectOnlyKey 是否只查询key
@param withSQL_CALC_FOUND_ROWS 查询是否带上SQL_CALC_FOUND_ROWS,当配合select FOUND_ROWS();时需要为true
@return | [
"select",
"字段",
"from",
"t_table",
"不包含where子句及以后的语句"
] | train | https://github.com/pugwoo/nimble-orm/blob/dd496f3e57029e4f22f9a2f00d18a6513ef94d08/src/main/java/com/pugwoo/dbhelper/sql/SQLUtils.java#L62-L105 |
square/protoparser | src/main/java/com/squareup/protoparser/ProtoParser.java | ProtoParser.readList | private List<Object> readList() {
if (readChar() != '[') throw new AssertionError();
List<Object> result = new ArrayList<>();
while (true) {
if (peekChar() == ']') {
// If we see the close brace, finish immediately. This handles [] and ,] cases.
pos++;
return result;
}
result.add(readKindAndValue().value());
char c = peekChar();
if (c == ',') {
pos++;
} else if (c != ']') {
throw unexpected("expected ',' or ']'");
}
}
} | java | private List<Object> readList() {
if (readChar() != '[') throw new AssertionError();
List<Object> result = new ArrayList<>();
while (true) {
if (peekChar() == ']') {
// If we see the close brace, finish immediately. This handles [] and ,] cases.
pos++;
return result;
}
result.add(readKindAndValue().value());
char c = peekChar();
if (c == ',') {
pos++;
} else if (c != ']') {
throw unexpected("expected ',' or ']'");
}
}
} | [
"private",
"List",
"<",
"Object",
">",
"readList",
"(",
")",
"{",
"if",
"(",
"readChar",
"(",
")",
"!=",
"'",
"'",
")",
"throw",
"new",
"AssertionError",
"(",
")",
";",
"List",
"<",
"Object",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
... | Returns a list of values. This is similar to JSON with '[' and ']'
surrounding the list and ',' separating values. | [
"Returns",
"a",
"list",
"of",
"values",
".",
"This",
"is",
"similar",
"to",
"JSON",
"with",
"[",
"and",
"]",
"surrounding",
"the",
"list",
"and",
"separating",
"values",
"."
] | train | https://github.com/square/protoparser/blob/8be66bb8fe6658b04741df0358daabca501f2524/src/main/java/com/squareup/protoparser/ProtoParser.java#L516-L535 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java | ToTextStream.charactersRaw | public void charactersRaw(char ch[], int start, int length)
throws org.xml.sax.SAXException
{
try
{
writeNormalizedChars(ch, start, length, m_lineSepUse);
}
catch(IOException ioe)
{
throw new SAXException(ioe);
}
} | java | public void charactersRaw(char ch[], int start, int length)
throws org.xml.sax.SAXException
{
try
{
writeNormalizedChars(ch, start, length, m_lineSepUse);
}
catch(IOException ioe)
{
throw new SAXException(ioe);
}
} | [
"public",
"void",
"charactersRaw",
"(",
"char",
"ch",
"[",
"]",
",",
"int",
"start",
",",
"int",
"length",
")",
"throws",
"org",
".",
"xml",
".",
"sax",
".",
"SAXException",
"{",
"try",
"{",
"writeNormalizedChars",
"(",
"ch",
",",
"start",
",",
"length... | If available, when the disable-output-escaping attribute is used,
output raw text without escaping.
@param ch The characters from the XML document.
@param start The start position in the array.
@param length The number of characters to read from the array.
@throws org.xml.sax.SAXException Any SAX exception, possibly
wrapping another exception. | [
"If",
"available",
"when",
"the",
"disable",
"-",
"output",
"-",
"escaping",
"attribute",
"is",
"used",
"output",
"raw",
"text",
"without",
"escaping",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java#L242-L254 |
mgormley/pacaya | src/main/java/edu/jhu/pacaya/parse/dep/EdgeScores.java | EdgeScores.tensorToEdgeScores | public static EdgeScores tensorToEdgeScores(Tensor t) {
if (t.getDims().length != 2) {
throw new IllegalArgumentException("Tensor must be an nxn matrix.");
}
int n = t.getDims()[1];
EdgeScores es = new EdgeScores(n, 0);
for (int p = -1; p < n; p++) {
for (int c = 0; c < n; c++) {
if (p == c) { continue; }
int pp = getTensorParent(p, c);
es.setScore(p, c, t.get(pp, c));
}
}
return es;
} | java | public static EdgeScores tensorToEdgeScores(Tensor t) {
if (t.getDims().length != 2) {
throw new IllegalArgumentException("Tensor must be an nxn matrix.");
}
int n = t.getDims()[1];
EdgeScores es = new EdgeScores(n, 0);
for (int p = -1; p < n; p++) {
for (int c = 0; c < n; c++) {
if (p == c) { continue; }
int pp = getTensorParent(p, c);
es.setScore(p, c, t.get(pp, c));
}
}
return es;
} | [
"public",
"static",
"EdgeScores",
"tensorToEdgeScores",
"(",
"Tensor",
"t",
")",
"{",
"if",
"(",
"t",
".",
"getDims",
"(",
")",
".",
"length",
"!=",
"2",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Tensor must be an nxn matrix.\"",
")",
";",
... | Convert a Tensor object to an EdgeScores, where the wall node is indexed as position n+1 in the Tensor. | [
"Convert",
"a",
"Tensor",
"object",
"to",
"an",
"EdgeScores",
"where",
"the",
"wall",
"node",
"is",
"indexed",
"as",
"position",
"n",
"+",
"1",
"in",
"the",
"Tensor",
"."
] | train | https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/dep/EdgeScores.java#L99-L113 |
zaproxy/zaproxy | src/org/parosproxy/paros/common/AbstractParam.java | AbstractParam.getInt | protected int getInt(String key, int defaultValue) {
try {
return getConfig().getInt(key, defaultValue);
} catch (ConversionException e) {
logConversionException(key, e);
}
return defaultValue;
} | java | protected int getInt(String key, int defaultValue) {
try {
return getConfig().getInt(key, defaultValue);
} catch (ConversionException e) {
logConversionException(key, e);
}
return defaultValue;
} | [
"protected",
"int",
"getInt",
"(",
"String",
"key",
",",
"int",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"getConfig",
"(",
")",
".",
"getInt",
"(",
"key",
",",
"defaultValue",
")",
";",
"}",
"catch",
"(",
"ConversionException",
"e",
")",
"{",
"l... | Gets the {@code int} with the given configuration key.
<p>
The default value is returned if the key doesn't exist or it's not a {@code int}.
@param key the configuration key.
@param defaultValue the default value, if the key doesn't exist or it's not an {@code int}.
@return the value of the configuration, or default value.
@since 2.7.0 | [
"Gets",
"the",
"{",
"@code",
"int",
"}",
"with",
"the",
"given",
"configuration",
"key",
".",
"<p",
">",
"The",
"default",
"value",
"is",
"returned",
"if",
"the",
"key",
"doesn",
"t",
"exist",
"or",
"it",
"s",
"not",
"a",
"{",
"@code",
"int",
"}",
... | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/common/AbstractParam.java#L193-L200 |
zaproxy/zaproxy | src/org/parosproxy/paros/common/AbstractParam.java | AbstractParam.getString | protected String getString(String key, String defaultValue) {
try {
return getConfig().getString(key, defaultValue);
} catch (ConversionException e) {
logConversionException(key, e);
}
return defaultValue;
} | java | protected String getString(String key, String defaultValue) {
try {
return getConfig().getString(key, defaultValue);
} catch (ConversionException e) {
logConversionException(key, e);
}
return defaultValue;
} | [
"protected",
"String",
"getString",
"(",
"String",
"key",
",",
"String",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"getConfig",
"(",
")",
".",
"getString",
"(",
"key",
",",
"defaultValue",
")",
";",
"}",
"catch",
"(",
"ConversionException",
"e",
")",... | Gets the {@code String} with the given configuration key.
<p>
The default value is returned if the key doesn't exist or it's not a {@code String}.
@param key the configuration key.
@param defaultValue the default value, if the key doesn't exist or it's not a {@code String}.
@return the value of the configuration, or default value.
@since 2.7.0 | [
"Gets",
"the",
"{",
"@code",
"String",
"}",
"with",
"the",
"given",
"configuration",
"key",
".",
"<p",
">",
"The",
"default",
"value",
"is",
"returned",
"if",
"the",
"key",
"doesn",
"t",
"exist",
"or",
"it",
"s",
"not",
"a",
"{",
"@code",
"String",
"... | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/common/AbstractParam.java#L144-L151 |
eurekaclinical/javautil | src/main/java/org/arp/javautil/io/IOUtil.java | IOUtil.getResourceAsStream | public static InputStream getResourceAsStream(String name, Class<?> cls)
throws IOException {
if (cls == null) {
cls = IOUtil.class;
}
if (name == null) {
throw new IllegalArgumentException("resource cannot be null");
}
InputStream result = cls.getResourceAsStream(name);
if (result == null) {
throw new IOException("Could not open resource " + name
+ " using " + cls.getName() + "'s class loader");
}
return result;
} | java | public static InputStream getResourceAsStream(String name, Class<?> cls)
throws IOException {
if (cls == null) {
cls = IOUtil.class;
}
if (name == null) {
throw new IllegalArgumentException("resource cannot be null");
}
InputStream result = cls.getResourceAsStream(name);
if (result == null) {
throw new IOException("Could not open resource " + name
+ " using " + cls.getName() + "'s class loader");
}
return result;
} | [
"public",
"static",
"InputStream",
"getResourceAsStream",
"(",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"cls",
")",
"throws",
"IOException",
"{",
"if",
"(",
"cls",
"==",
"null",
")",
"{",
"cls",
"=",
"IOUtil",
".",
"class",
";",
"}",
"if",
"(",
... | Finds a resource with a given name using the class loader of the
specified class. Functions identically to
{@link Class#getResourceAsStream(java.lang.String)}, except it throws an
{@link IllegalArgumentException} if the specified resource name is
<code>null</code>, and it throws an {@link IOException} if no resource
with the specified name is found.
@param name name {@link String} of the desired resource. Cannot be
<code>null</code>.
@param cls the {@link Class} whose loader to use.
@return an {@link InputStream}.
@throws IOException if no resource with this name is found. | [
"Finds",
"a",
"resource",
"with",
"a",
"given",
"name",
"using",
"the",
"class",
"loader",
"of",
"the",
"specified",
"class",
".",
"Functions",
"identically",
"to",
"{",
"@link",
"Class#getResourceAsStream",
"(",
"java",
".",
"lang",
".",
"String",
")",
"}",... | train | https://github.com/eurekaclinical/javautil/blob/779bbc5bf096c75f8eed4f99ca45b99c1d44df43/src/main/java/org/arp/javautil/io/IOUtil.java#L223-L237 |
samskivert/samskivert | src/main/java/com/samskivert/servlet/MessageManager.java | MessageManager.getMessage | public String getMessage (HttpServletRequest req, String path)
{
return getMessage(req, path, true);
} | java | public String getMessage (HttpServletRequest req, String path)
{
return getMessage(req, path, true);
} | [
"public",
"String",
"getMessage",
"(",
"HttpServletRequest",
"req",
",",
"String",
"path",
")",
"{",
"return",
"getMessage",
"(",
"req",
",",
"path",
",",
"true",
")",
";",
"}"
] | Looks up the message with the specified path in the resource bundle most appropriate for the
locales described as preferred by the request. Always reports missing paths. | [
"Looks",
"up",
"the",
"message",
"with",
"the",
"specified",
"path",
"in",
"the",
"resource",
"bundle",
"most",
"appropriate",
"for",
"the",
"locales",
"described",
"as",
"preferred",
"by",
"the",
"request",
".",
"Always",
"reports",
"missing",
"paths",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/MessageManager.java#L72-L75 |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/AnnotatedMethodScanner.java | AnnotatedMethodScanner.findAnnotatedMethods | public Set<Method> findAnnotatedMethods(String scanBase, Class<? extends Annotation> annotationClass) {
Set<BeanDefinition> filteredComponents = findCandidateBeans(scanBase, annotationClass);
return extractAnnotatedMethods(filteredComponents, annotationClass);
} | java | public Set<Method> findAnnotatedMethods(String scanBase, Class<? extends Annotation> annotationClass) {
Set<BeanDefinition> filteredComponents = findCandidateBeans(scanBase, annotationClass);
return extractAnnotatedMethods(filteredComponents, annotationClass);
} | [
"public",
"Set",
"<",
"Method",
">",
"findAnnotatedMethods",
"(",
"String",
"scanBase",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
")",
"{",
"Set",
"<",
"BeanDefinition",
">",
"filteredComponents",
"=",
"findCandidateBeans",
"(",
"s... | Find all methods on classes under scanBase that are annotated with annotationClass.
@param scanBase Package to scan recursively, in dot notation (ie: org.jrugged...)
@param annotationClass Class of the annotation to search for
@return Set<Method> The set of all @{java.lang.reflect.Method}s having the annotation | [
"Find",
"all",
"methods",
"on",
"classes",
"under",
"scanBase",
"that",
"are",
"annotated",
"with",
"annotationClass",
"."
] | train | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/AnnotatedMethodScanner.java#L48-L51 |
hawkular/hawkular-commons | hawkular-command-gateway/hawkular-command-gateway-war/src/main/java/org/hawkular/cmdgw/command/ws/server/AbstractGatewayWebSocket.java | AbstractGatewayWebSocket.onBinaryMessage | @OnMessage
public void onBinaryMessage(InputStream binaryDataStream, Session session) {
String requestClassName = "?";
try {
// parse the JSON and get its message POJO, including any additional binary data being streamed
BasicMessageWithExtraData<BasicMessage> reqWithData = new ApiDeserializer().deserialize(binaryDataStream);
BasicMessage request = reqWithData.getBasicMessage();
requestClassName = request.getClass().getName();
log.infoReceivedBinaryData(requestClassName, session.getId(), endpoint);
handleRequest(session, reqWithData);
} catch (Throwable t) {
log.errorWsCommandExecutionFailure(requestClassName, session.getId(), endpoint, t);
String errorMessage = "BusCommand failed [" + requestClassName + "]";
sendErrorResponse(session, errorMessage, t);
}
} | java | @OnMessage
public void onBinaryMessage(InputStream binaryDataStream, Session session) {
String requestClassName = "?";
try {
// parse the JSON and get its message POJO, including any additional binary data being streamed
BasicMessageWithExtraData<BasicMessage> reqWithData = new ApiDeserializer().deserialize(binaryDataStream);
BasicMessage request = reqWithData.getBasicMessage();
requestClassName = request.getClass().getName();
log.infoReceivedBinaryData(requestClassName, session.getId(), endpoint);
handleRequest(session, reqWithData);
} catch (Throwable t) {
log.errorWsCommandExecutionFailure(requestClassName, session.getId(), endpoint, t);
String errorMessage = "BusCommand failed [" + requestClassName + "]";
sendErrorResponse(session, errorMessage, t);
}
} | [
"@",
"OnMessage",
"public",
"void",
"onBinaryMessage",
"(",
"InputStream",
"binaryDataStream",
",",
"Session",
"session",
")",
"{",
"String",
"requestClassName",
"=",
"\"?\"",
";",
"try",
"{",
"// parse the JSON and get its message POJO, including any additional binary data b... | When a binary message is received from a WebSocket client, this method will lookup the {@link WsCommand} for the
given request class and execute it.
@param binaryDataStream contains the JSON request and additional binary data
@param session the client session making the request | [
"When",
"a",
"binary",
"message",
"is",
"received",
"from",
"a",
"WebSocket",
"client",
"this",
"method",
"will",
"lookup",
"the",
"{",
"@link",
"WsCommand",
"}",
"for",
"the",
"given",
"request",
"class",
"and",
"execute",
"it",
"."
] | train | https://github.com/hawkular/hawkular-commons/blob/e4a832862b3446d7f4d629bb05790f2df578e035/hawkular-command-gateway/hawkular-command-gateway-war/src/main/java/org/hawkular/cmdgw/command/ws/server/AbstractGatewayWebSocket.java#L114-L131 |
openbase/jul | visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java | SVGIcon.setForegroundIconColor | public void setForegroundIconColor(final Color color, final Color outline, final double width) {
setForegroundIconColor(color);
foregroundIcon.setStroke(outline);
foregroundIcon.setStrokeWidth(width);
} | java | public void setForegroundIconColor(final Color color, final Color outline, final double width) {
setForegroundIconColor(color);
foregroundIcon.setStroke(outline);
foregroundIcon.setStrokeWidth(width);
} | [
"public",
"void",
"setForegroundIconColor",
"(",
"final",
"Color",
"color",
",",
"final",
"Color",
"outline",
",",
"final",
"double",
"width",
")",
"{",
"setForegroundIconColor",
"(",
"color",
")",
";",
"foregroundIcon",
".",
"setStroke",
"(",
"outline",
")",
... | Method sets the icon color and a stroke with a given color and width.
@param color color for the foreground icon to be set
@param outline color for the stroke
@param width width of the stroke | [
"Method",
"sets",
"the",
"icon",
"color",
"and",
"a",
"stroke",
"with",
"a",
"given",
"color",
"and",
"width",
"."
] | train | https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java#L466-L470 |
ops4j/org.ops4j.pax.exam2 | containers/pax-exam-container-karaf/src/main/java/org/ops4j/pax/exam/karaf/options/KarafDistributionOption.java | KarafDistributionOption.karafDistributionConfiguration | public static KarafDistributionBaseConfigurationOption karafDistributionConfiguration(
String frameworkURL, String name, String karafVersion) {
return new KarafDistributionConfigurationOption(frameworkURL, name, karafVersion);
} | java | public static KarafDistributionBaseConfigurationOption karafDistributionConfiguration(
String frameworkURL, String name, String karafVersion) {
return new KarafDistributionConfigurationOption(frameworkURL, name, karafVersion);
} | [
"public",
"static",
"KarafDistributionBaseConfigurationOption",
"karafDistributionConfiguration",
"(",
"String",
"frameworkURL",
",",
"String",
"name",
",",
"String",
"karafVersion",
")",
"{",
"return",
"new",
"KarafDistributionConfigurationOption",
"(",
"frameworkURL",
",",
... | Configures which distribution options to use. Relevant are the frameworkURL, the
frameworkName and the Karaf version since all of those params are relevant to decide which
wrapper configurations to use.
@param frameworkURL
frameworkURL
@param name
framework name
@param karafVersion
Karaf version
@return option | [
"Configures",
"which",
"distribution",
"options",
"to",
"use",
".",
"Relevant",
"are",
"the",
"frameworkURL",
"the",
"frameworkName",
"and",
"the",
"Karaf",
"version",
"since",
"all",
"of",
"those",
"params",
"are",
"relevant",
"to",
"decide",
"which",
"wrapper"... | train | https://github.com/ops4j/org.ops4j.pax.exam2/blob/7f83796cbbb857123d8fc7fe817a7637218d5d77/containers/pax-exam-container-karaf/src/main/java/org/ops4j/pax/exam/karaf/options/KarafDistributionOption.java#L126-L129 |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/ParseBool.java | ParseBool.checkPreconditions | private static void checkPreconditions(final String[] trueValues, final String[] falseValues) {
if( trueValues == null ) {
throw new NullPointerException("trueValues should not be null");
} else if( trueValues.length == 0 ) {
throw new IllegalArgumentException("trueValues should not be empty");
}
if( falseValues == null ) {
throw new NullPointerException("falseValues should not be null");
} else if( falseValues.length == 0 ) {
throw new IllegalArgumentException("falseValues should not be empty");
}
} | java | private static void checkPreconditions(final String[] trueValues, final String[] falseValues) {
if( trueValues == null ) {
throw new NullPointerException("trueValues should not be null");
} else if( trueValues.length == 0 ) {
throw new IllegalArgumentException("trueValues should not be empty");
}
if( falseValues == null ) {
throw new NullPointerException("falseValues should not be null");
} else if( falseValues.length == 0 ) {
throw new IllegalArgumentException("falseValues should not be empty");
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"final",
"String",
"[",
"]",
"trueValues",
",",
"final",
"String",
"[",
"]",
"falseValues",
")",
"{",
"if",
"(",
"trueValues",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"tru... | Checks the preconditions for constructing a new ParseBool processor.
@param trueValues
the array of Strings which represent true
@param falseValues
the array of Strings which represent false
@throws IllegalArgumentException
if trueValues or falseValues is empty
@throws NullPointerException
if trueValues or falseValues is null | [
"Checks",
"the",
"preconditions",
"for",
"constructing",
"a",
"new",
"ParseBool",
"processor",
"."
] | train | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/ParseBool.java#L304-L318 |
alkacon/opencms-core | src/org/opencms/db/CmsSecurityManager.java | CmsSecurityManager.getPermissions | public CmsPermissionSetCustom getPermissions(CmsRequestContext context, CmsResource resource, CmsUser user)
throws CmsException {
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
CmsPermissionSetCustom result = null;
try {
result = m_driverManager.getPermissions(dbc, resource, user);
} catch (Exception e) {
dbc.report(
null,
Messages.get().container(Messages.ERR_GET_PERMISSIONS_2, user.getName(), context.getSitePath(resource)),
e);
} finally {
dbc.clear();
}
return result;
} | java | public CmsPermissionSetCustom getPermissions(CmsRequestContext context, CmsResource resource, CmsUser user)
throws CmsException {
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
CmsPermissionSetCustom result = null;
try {
result = m_driverManager.getPermissions(dbc, resource, user);
} catch (Exception e) {
dbc.report(
null,
Messages.get().container(Messages.ERR_GET_PERMISSIONS_2, user.getName(), context.getSitePath(resource)),
e);
} finally {
dbc.clear();
}
return result;
} | [
"public",
"CmsPermissionSetCustom",
"getPermissions",
"(",
"CmsRequestContext",
"context",
",",
"CmsResource",
"resource",
",",
"CmsUser",
"user",
")",
"throws",
"CmsException",
"{",
"CmsDbContext",
"dbc",
"=",
"m_dbContextFactory",
".",
"getDbContext",
"(",
"context",
... | Returns the set of permissions of the current user for a given resource.<p>
@param context the current request context
@param resource the resource
@param user the user
@return bit set with allowed permissions
@throws CmsException if something goes wrong | [
"Returns",
"the",
"set",
"of",
"permissions",
"of",
"the",
"current",
"user",
"for",
"a",
"given",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsSecurityManager.java#L2519-L2535 |
google/auto | value/src/main/java/com/google/auto/value/processor/BuilderMethodClassifier.java | BuilderMethodClassifier.checkSetterParameter | private boolean checkSetterParameter(ExecutableElement valueGetter, ExecutableElement setter) {
TypeMirror targetType = getterToPropertyType.get(valueGetter);
ExecutableType finalSetter =
MoreTypes.asExecutable(
typeUtils.asMemberOf(MoreTypes.asDeclared(builderType.asType()), setter));
TypeMirror parameterType = finalSetter.getParameterTypes().get(0);
if (typeUtils.isSameType(parameterType, targetType)) {
return true;
}
// Parameter type is not equal to property type, but might be convertible with copyOf.
ImmutableList<ExecutableElement> copyOfMethods = copyOfMethods(targetType);
if (!copyOfMethods.isEmpty()) {
return canMakeCopyUsing(copyOfMethods, valueGetter, setter);
}
String error =
String.format(
"Parameter type %s of setter method should be %s to match getter %s.%s",
parameterType, targetType, autoValueClass, valueGetter.getSimpleName());
errorReporter.reportError(error, setter);
return false;
} | java | private boolean checkSetterParameter(ExecutableElement valueGetter, ExecutableElement setter) {
TypeMirror targetType = getterToPropertyType.get(valueGetter);
ExecutableType finalSetter =
MoreTypes.asExecutable(
typeUtils.asMemberOf(MoreTypes.asDeclared(builderType.asType()), setter));
TypeMirror parameterType = finalSetter.getParameterTypes().get(0);
if (typeUtils.isSameType(parameterType, targetType)) {
return true;
}
// Parameter type is not equal to property type, but might be convertible with copyOf.
ImmutableList<ExecutableElement> copyOfMethods = copyOfMethods(targetType);
if (!copyOfMethods.isEmpty()) {
return canMakeCopyUsing(copyOfMethods, valueGetter, setter);
}
String error =
String.format(
"Parameter type %s of setter method should be %s to match getter %s.%s",
parameterType, targetType, autoValueClass, valueGetter.getSimpleName());
errorReporter.reportError(error, setter);
return false;
} | [
"private",
"boolean",
"checkSetterParameter",
"(",
"ExecutableElement",
"valueGetter",
",",
"ExecutableElement",
"setter",
")",
"{",
"TypeMirror",
"targetType",
"=",
"getterToPropertyType",
".",
"get",
"(",
"valueGetter",
")",
";",
"ExecutableType",
"finalSetter",
"=",
... | Checks that the given setter method has a parameter type that is compatible with the return
type of the given getter. Compatible means either that it is the same, or that it is a type
that can be copied using a method like {@code ImmutableList.copyOf} or {@code Optional.of}.
@return true if the types correspond, false if an error has been reported. | [
"Checks",
"that",
"the",
"given",
"setter",
"method",
"has",
"a",
"parameter",
"type",
"that",
"is",
"compatible",
"with",
"the",
"return",
"type",
"of",
"the",
"given",
"getter",
".",
"Compatible",
"means",
"either",
"that",
"it",
"is",
"the",
"same",
"or... | train | https://github.com/google/auto/blob/4158a5fa71f1ef763e683b627f4d29bc04cfde9d/value/src/main/java/com/google/auto/value/processor/BuilderMethodClassifier.java#L417-L438 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java | VarOptItemsSketch.updateHeavyGeneral | private void updateHeavyGeneral(final T item, final double weight, final boolean mark) {
assert m_ == 0;
assert r_ >= 2;
assert (r_ + h_) == k_;
// put into H, although may come back out momentarily
push(item, weight, mark);
growCandidateSet(totalWtR_, r_);
} | java | private void updateHeavyGeneral(final T item, final double weight, final boolean mark) {
assert m_ == 0;
assert r_ >= 2;
assert (r_ + h_) == k_;
// put into H, although may come back out momentarily
push(item, weight, mark);
growCandidateSet(totalWtR_, r_);
} | [
"private",
"void",
"updateHeavyGeneral",
"(",
"final",
"T",
"item",
",",
"final",
"double",
"weight",
",",
"final",
"boolean",
"mark",
")",
"{",
"assert",
"m_",
"==",
"0",
";",
"assert",
"r_",
">=",
"2",
";",
"assert",
"(",
"r_",
"+",
"h_",
")",
"=="... | /* In the "heavy" case the new item has weight > old_tau, so would
appear to the left of items in R in a hypothetical reverse-sorted list and
might or might not be light enough be part of this round's downsampling.
[After first splitting off the R=1 case] we greatly simplify the code by
putting the new item into the H heap whether it needs to be there or not.
In other words, it might go into the heap and then come right back out,
but that should be okay because pseudo_heavy items cannot predominate
in long streams unless (max wt) / (min wt) > o(exp(N)) | [
"/",
"*",
"In",
"the",
"heavy",
"case",
"the",
"new",
"item",
"has",
"weight",
">",
"old_tau",
"so",
"would",
"appear",
"to",
"the",
"left",
"of",
"items",
"in",
"R",
"in",
"a",
"hypothetical",
"reverse",
"-",
"sorted",
"list",
"and",
"might",
"or",
... | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java#L923-L932 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.