repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
apereo/cas | core/cas-server-core-web-api/src/main/java/org/apereo/cas/web/support/WebUtils.java | WebUtils.produceErrorView | public static ModelAndView produceErrorView(final String view, final Exception e) {
"""
Produce error view model and view.
@param view the view
@param e the e
@return the model and view
"""
return new ModelAndView(view, CollectionUtils.wrap("rootCauseException", e));
} | java | public static ModelAndView produceErrorView(final String view, final Exception e) {
return new ModelAndView(view, CollectionUtils.wrap("rootCauseException", e));
} | [
"public",
"static",
"ModelAndView",
"produceErrorView",
"(",
"final",
"String",
"view",
",",
"final",
"Exception",
"e",
")",
"{",
"return",
"new",
"ModelAndView",
"(",
"view",
",",
"CollectionUtils",
".",
"wrap",
"(",
"\"rootCauseException\"",
",",
"e",
")",
")",
";",
"}"
] | Produce error view model and view.
@param view the view
@param e the e
@return the model and view | [
"Produce",
"error",
"view",
"model",
"and",
"view",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-web-api/src/main/java/org/apereo/cas/web/support/WebUtils.java#L793-L795 |
synchronoss/cpo-api | cpo-jdbc/src/main/java/org/synchronoss/cpo/jdbc/JdbcCpoAdapter.java | JdbcCpoAdapter.setContext | protected void setContext(Context context) throws CpoException {
"""
DOCUMENT ME!
@param context DOCUMENT ME!
@throws CpoException DOCUMENT ME!
"""
try {
if (context == null) {
context_ = new InitialContext();
} else {
context_ = context;
}
} catch (NamingException e) {
throw new CpoException("Error setting Context", e);
}
} | java | protected void setContext(Context context) throws CpoException {
try {
if (context == null) {
context_ = new InitialContext();
} else {
context_ = context;
}
} catch (NamingException e) {
throw new CpoException("Error setting Context", e);
}
} | [
"protected",
"void",
"setContext",
"(",
"Context",
"context",
")",
"throws",
"CpoException",
"{",
"try",
"{",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"context_",
"=",
"new",
"InitialContext",
"(",
")",
";",
"}",
"else",
"{",
"context_",
"=",
"context",
";",
"}",
"}",
"catch",
"(",
"NamingException",
"e",
")",
"{",
"throw",
"new",
"CpoException",
"(",
"\"Error setting Context\"",
",",
"e",
")",
";",
"}",
"}"
] | DOCUMENT ME!
@param context DOCUMENT ME!
@throws CpoException DOCUMENT ME! | [
"DOCUMENT",
"ME!"
] | train | https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-jdbc/src/main/java/org/synchronoss/cpo/jdbc/JdbcCpoAdapter.java#L1988-L1998 |
Waikato/moa | moa/src/main/java/moa/classifiers/meta/AccuracyWeightedEnsemble.java | AccuracyWeightedEnsemble.addToStored | protected Classifier addToStored(Classifier newClassifier, double newClassifiersWeight) {
"""
Adds a classifier to the storage.
@param newClassifier The classifier to add.
@param newClassifiersWeight The new classifiers weight.
"""
Classifier addedClassifier = null;
Classifier[] newStored = new Classifier[this.storedLearners.length + 1];
double[][] newStoredWeights = new double[newStored.length][2];
for (int i = 0; i < newStored.length; i++) {
if (i < this.storedLearners.length) {
newStored[i] = this.storedLearners[i];
newStoredWeights[i][0] = this.storedWeights[i][0];
newStoredWeights[i][1] = this.storedWeights[i][1];
} else {
newStored[i] = addedClassifier = newClassifier.copy();
newStoredWeights[i][0] = newClassifiersWeight;
newStoredWeights[i][1] = i;
}
}
this.storedLearners = newStored;
this.storedWeights = newStoredWeights;
return addedClassifier;
} | java | protected Classifier addToStored(Classifier newClassifier, double newClassifiersWeight) {
Classifier addedClassifier = null;
Classifier[] newStored = new Classifier[this.storedLearners.length + 1];
double[][] newStoredWeights = new double[newStored.length][2];
for (int i = 0; i < newStored.length; i++) {
if (i < this.storedLearners.length) {
newStored[i] = this.storedLearners[i];
newStoredWeights[i][0] = this.storedWeights[i][0];
newStoredWeights[i][1] = this.storedWeights[i][1];
} else {
newStored[i] = addedClassifier = newClassifier.copy();
newStoredWeights[i][0] = newClassifiersWeight;
newStoredWeights[i][1] = i;
}
}
this.storedLearners = newStored;
this.storedWeights = newStoredWeights;
return addedClassifier;
} | [
"protected",
"Classifier",
"addToStored",
"(",
"Classifier",
"newClassifier",
",",
"double",
"newClassifiersWeight",
")",
"{",
"Classifier",
"addedClassifier",
"=",
"null",
";",
"Classifier",
"[",
"]",
"newStored",
"=",
"new",
"Classifier",
"[",
"this",
".",
"storedLearners",
".",
"length",
"+",
"1",
"]",
";",
"double",
"[",
"]",
"[",
"]",
"newStoredWeights",
"=",
"new",
"double",
"[",
"newStored",
".",
"length",
"]",
"[",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"newStored",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"<",
"this",
".",
"storedLearners",
".",
"length",
")",
"{",
"newStored",
"[",
"i",
"]",
"=",
"this",
".",
"storedLearners",
"[",
"i",
"]",
";",
"newStoredWeights",
"[",
"i",
"]",
"[",
"0",
"]",
"=",
"this",
".",
"storedWeights",
"[",
"i",
"]",
"[",
"0",
"]",
";",
"newStoredWeights",
"[",
"i",
"]",
"[",
"1",
"]",
"=",
"this",
".",
"storedWeights",
"[",
"i",
"]",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"newStored",
"[",
"i",
"]",
"=",
"addedClassifier",
"=",
"newClassifier",
".",
"copy",
"(",
")",
";",
"newStoredWeights",
"[",
"i",
"]",
"[",
"0",
"]",
"=",
"newClassifiersWeight",
";",
"newStoredWeights",
"[",
"i",
"]",
"[",
"1",
"]",
"=",
"i",
";",
"}",
"}",
"this",
".",
"storedLearners",
"=",
"newStored",
";",
"this",
".",
"storedWeights",
"=",
"newStoredWeights",
";",
"return",
"addedClassifier",
";",
"}"
] | Adds a classifier to the storage.
@param newClassifier The classifier to add.
@param newClassifiersWeight The new classifiers weight. | [
"Adds",
"a",
"classifier",
"to",
"the",
"storage",
"."
] | train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/classifiers/meta/AccuracyWeightedEnsemble.java#L409-L429 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ServiceEndpointPolicyDefinitionsInner.java | ServiceEndpointPolicyDefinitionsInner.beginCreateOrUpdate | public ServiceEndpointPolicyDefinitionInner beginCreateOrUpdate(String resourceGroupName, String serviceEndpointPolicyName, String serviceEndpointPolicyDefinitionName, ServiceEndpointPolicyDefinitionInner serviceEndpointPolicyDefinitions) {
"""
Creates or updates a service endpoint policy definition in the specified service endpoint policy.
@param resourceGroupName The name of the resource group.
@param serviceEndpointPolicyName The name of the service endpoint policy.
@param serviceEndpointPolicyDefinitionName The name of the service endpoint policy definition name.
@param serviceEndpointPolicyDefinitions Parameters supplied to the create or update service endpoint policy 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 ServiceEndpointPolicyDefinitionInner object if successful.
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serviceEndpointPolicyName, serviceEndpointPolicyDefinitionName, serviceEndpointPolicyDefinitions).toBlocking().single().body();
} | java | public ServiceEndpointPolicyDefinitionInner beginCreateOrUpdate(String resourceGroupName, String serviceEndpointPolicyName, String serviceEndpointPolicyDefinitionName, ServiceEndpointPolicyDefinitionInner serviceEndpointPolicyDefinitions) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serviceEndpointPolicyName, serviceEndpointPolicyDefinitionName, serviceEndpointPolicyDefinitions).toBlocking().single().body();
} | [
"public",
"ServiceEndpointPolicyDefinitionInner",
"beginCreateOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"serviceEndpointPolicyName",
",",
"String",
"serviceEndpointPolicyDefinitionName",
",",
"ServiceEndpointPolicyDefinitionInner",
"serviceEndpointPolicyDefinitions",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serviceEndpointPolicyName",
",",
"serviceEndpointPolicyDefinitionName",
",",
"serviceEndpointPolicyDefinitions",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates or updates a service endpoint policy definition in the specified service endpoint policy.
@param resourceGroupName The name of the resource group.
@param serviceEndpointPolicyName The name of the service endpoint policy.
@param serviceEndpointPolicyDefinitionName The name of the service endpoint policy definition name.
@param serviceEndpointPolicyDefinitions Parameters supplied to the create or update service endpoint policy 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 ServiceEndpointPolicyDefinitionInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"service",
"endpoint",
"policy",
"definition",
"in",
"the",
"specified",
"service",
"endpoint",
"policy",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ServiceEndpointPolicyDefinitionsInner.java#L444-L446 |
btrplace/scheduler | choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/KnapsackDecorator.java | KnapsackDecorator.filterFullDim | @SuppressWarnings("squid:S3346")
private void filterFullDim(int bin, int dim) throws ContradictionException {
"""
remove all candidate items from a bin that is full
then synchronize potentialLoad and sup(binLoad) accordingly
if an item becomes instantiated then propagate the newly assigned bin
@param bin the full bin
@throws ContradictionException
"""
for (int i = candidate.get(bin).nextSetBit(0); i >= 0; i = candidate.get(bin).nextSetBit(i + 1)) {
if (prop.iSizes[dim][i] == 0) {
continue;
}
// ISSUE 86: the event 'i removed from bin' can already been in the propagation stack but not yet considered
// ie. !prop.bins[i].contains(bin) && candidate[bin].contains(i): in this case, do not process it yet
if (prop.bins[i].removeValue(bin, prop)) {
candidate.get(bin).clear(i);
prop.updateLoads(i, bin);
if (prop.bins[i].isInstantiated()) {
prop.assignItem(i, prop.bins[i].getValue());
}
}
}
if (candidate.get(bin).isEmpty()) {
assert prop.potentialLoad[dim][bin].get() == prop.assignedLoad[dim][bin].get();
assert prop.loads[dim][bin].getUB() == prop.potentialLoad[dim][bin].get();
}
} | java | @SuppressWarnings("squid:S3346")
private void filterFullDim(int bin, int dim) throws ContradictionException {
for (int i = candidate.get(bin).nextSetBit(0); i >= 0; i = candidate.get(bin).nextSetBit(i + 1)) {
if (prop.iSizes[dim][i] == 0) {
continue;
}
// ISSUE 86: the event 'i removed from bin' can already been in the propagation stack but not yet considered
// ie. !prop.bins[i].contains(bin) && candidate[bin].contains(i): in this case, do not process it yet
if (prop.bins[i].removeValue(bin, prop)) {
candidate.get(bin).clear(i);
prop.updateLoads(i, bin);
if (prop.bins[i].isInstantiated()) {
prop.assignItem(i, prop.bins[i].getValue());
}
}
}
if (candidate.get(bin).isEmpty()) {
assert prop.potentialLoad[dim][bin].get() == prop.assignedLoad[dim][bin].get();
assert prop.loads[dim][bin].getUB() == prop.potentialLoad[dim][bin].get();
}
} | [
"@",
"SuppressWarnings",
"(",
"\"squid:S3346\"",
")",
"private",
"void",
"filterFullDim",
"(",
"int",
"bin",
",",
"int",
"dim",
")",
"throws",
"ContradictionException",
"{",
"for",
"(",
"int",
"i",
"=",
"candidate",
".",
"get",
"(",
"bin",
")",
".",
"nextSetBit",
"(",
"0",
")",
";",
"i",
">=",
"0",
";",
"i",
"=",
"candidate",
".",
"get",
"(",
"bin",
")",
".",
"nextSetBit",
"(",
"i",
"+",
"1",
")",
")",
"{",
"if",
"(",
"prop",
".",
"iSizes",
"[",
"dim",
"]",
"[",
"i",
"]",
"==",
"0",
")",
"{",
"continue",
";",
"}",
"// ISSUE 86: the event 'i removed from bin' can already been in the propagation stack but not yet considered",
"// ie. !prop.bins[i].contains(bin) && candidate[bin].contains(i): in this case, do not process it yet",
"if",
"(",
"prop",
".",
"bins",
"[",
"i",
"]",
".",
"removeValue",
"(",
"bin",
",",
"prop",
")",
")",
"{",
"candidate",
".",
"get",
"(",
"bin",
")",
".",
"clear",
"(",
"i",
")",
";",
"prop",
".",
"updateLoads",
"(",
"i",
",",
"bin",
")",
";",
"if",
"(",
"prop",
".",
"bins",
"[",
"i",
"]",
".",
"isInstantiated",
"(",
")",
")",
"{",
"prop",
".",
"assignItem",
"(",
"i",
",",
"prop",
".",
"bins",
"[",
"i",
"]",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"candidate",
".",
"get",
"(",
"bin",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"assert",
"prop",
".",
"potentialLoad",
"[",
"dim",
"]",
"[",
"bin",
"]",
".",
"get",
"(",
")",
"==",
"prop",
".",
"assignedLoad",
"[",
"dim",
"]",
"[",
"bin",
"]",
".",
"get",
"(",
")",
";",
"assert",
"prop",
".",
"loads",
"[",
"dim",
"]",
"[",
"bin",
"]",
".",
"getUB",
"(",
")",
"==",
"prop",
".",
"potentialLoad",
"[",
"dim",
"]",
"[",
"bin",
"]",
".",
"get",
"(",
")",
";",
"}",
"}"
] | remove all candidate items from a bin that is full
then synchronize potentialLoad and sup(binLoad) accordingly
if an item becomes instantiated then propagate the newly assigned bin
@param bin the full bin
@throws ContradictionException | [
"remove",
"all",
"candidate",
"items",
"from",
"a",
"bin",
"that",
"is",
"full",
"then",
"synchronize",
"potentialLoad",
"and",
"sup",
"(",
"binLoad",
")",
"accordingly",
"if",
"an",
"item",
"becomes",
"instantiated",
"then",
"propagate",
"the",
"newly",
"assigned",
"bin"
] | train | https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/KnapsackDecorator.java#L118-L140 |
Cornutum/tcases | tcases-io/src/main/java/org/cornutum/tcases/io/SystemInputJson.java | SystemInputJson.asValueDef | private static VarValueDef asValueDef( String valueName, JsonObject json) {
"""
Returns the value definition represented by the given JSON object.
"""
try
{
VarValueDef valueDef = new VarValueDef( ObjectUtils.toObject( valueName));
// Get the type of this value
boolean failure = json.getBoolean( FAILURE_KEY, false);
boolean once = json.getBoolean( ONCE_KEY, false);
valueDef.setType
( failure? VarValueDef.Type.FAILURE :
once? VarValueDef.Type.ONCE :
VarValueDef.Type.VALID);
if( failure && json.containsKey( PROPERTIES_KEY))
{
throw new SystemInputException( "Failure type values can't define properties");
}
// Get annotations for this value
Optional.ofNullable( json.getJsonObject( HAS_KEY))
.ifPresent( has -> has.keySet().stream().forEach( key -> valueDef.setAnnotation( key, has.getString( key))));
// Get the condition for this value
Optional.ofNullable( json.getJsonObject( WHEN_KEY))
.ifPresent( object -> valueDef.setCondition( asValidCondition( object)));
// Get properties for this value
Optional.ofNullable( json.getJsonArray( PROPERTIES_KEY))
.map( properties -> toIdentifiers( properties))
.ifPresent( properties -> valueDef.addProperties( properties));
return valueDef;
}
catch( SystemInputException e)
{
throw new SystemInputException( String.format( "Error defining value=%s", valueName), e);
}
} | java | private static VarValueDef asValueDef( String valueName, JsonObject json)
{
try
{
VarValueDef valueDef = new VarValueDef( ObjectUtils.toObject( valueName));
// Get the type of this value
boolean failure = json.getBoolean( FAILURE_KEY, false);
boolean once = json.getBoolean( ONCE_KEY, false);
valueDef.setType
( failure? VarValueDef.Type.FAILURE :
once? VarValueDef.Type.ONCE :
VarValueDef.Type.VALID);
if( failure && json.containsKey( PROPERTIES_KEY))
{
throw new SystemInputException( "Failure type values can't define properties");
}
// Get annotations for this value
Optional.ofNullable( json.getJsonObject( HAS_KEY))
.ifPresent( has -> has.keySet().stream().forEach( key -> valueDef.setAnnotation( key, has.getString( key))));
// Get the condition for this value
Optional.ofNullable( json.getJsonObject( WHEN_KEY))
.ifPresent( object -> valueDef.setCondition( asValidCondition( object)));
// Get properties for this value
Optional.ofNullable( json.getJsonArray( PROPERTIES_KEY))
.map( properties -> toIdentifiers( properties))
.ifPresent( properties -> valueDef.addProperties( properties));
return valueDef;
}
catch( SystemInputException e)
{
throw new SystemInputException( String.format( "Error defining value=%s", valueName), e);
}
} | [
"private",
"static",
"VarValueDef",
"asValueDef",
"(",
"String",
"valueName",
",",
"JsonObject",
"json",
")",
"{",
"try",
"{",
"VarValueDef",
"valueDef",
"=",
"new",
"VarValueDef",
"(",
"ObjectUtils",
".",
"toObject",
"(",
"valueName",
")",
")",
";",
"// Get the type of this value",
"boolean",
"failure",
"=",
"json",
".",
"getBoolean",
"(",
"FAILURE_KEY",
",",
"false",
")",
";",
"boolean",
"once",
"=",
"json",
".",
"getBoolean",
"(",
"ONCE_KEY",
",",
"false",
")",
";",
"valueDef",
".",
"setType",
"(",
"failure",
"?",
"VarValueDef",
".",
"Type",
".",
"FAILURE",
":",
"once",
"?",
"VarValueDef",
".",
"Type",
".",
"ONCE",
":",
"VarValueDef",
".",
"Type",
".",
"VALID",
")",
";",
"if",
"(",
"failure",
"&&",
"json",
".",
"containsKey",
"(",
"PROPERTIES_KEY",
")",
")",
"{",
"throw",
"new",
"SystemInputException",
"(",
"\"Failure type values can't define properties\"",
")",
";",
"}",
"// Get annotations for this value",
"Optional",
".",
"ofNullable",
"(",
"json",
".",
"getJsonObject",
"(",
"HAS_KEY",
")",
")",
".",
"ifPresent",
"(",
"has",
"->",
"has",
".",
"keySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"key",
"->",
"valueDef",
".",
"setAnnotation",
"(",
"key",
",",
"has",
".",
"getString",
"(",
"key",
")",
")",
")",
")",
";",
"// Get the condition for this value",
"Optional",
".",
"ofNullable",
"(",
"json",
".",
"getJsonObject",
"(",
"WHEN_KEY",
")",
")",
".",
"ifPresent",
"(",
"object",
"->",
"valueDef",
".",
"setCondition",
"(",
"asValidCondition",
"(",
"object",
")",
")",
")",
";",
"// Get properties for this value",
"Optional",
".",
"ofNullable",
"(",
"json",
".",
"getJsonArray",
"(",
"PROPERTIES_KEY",
")",
")",
".",
"map",
"(",
"properties",
"->",
"toIdentifiers",
"(",
"properties",
")",
")",
".",
"ifPresent",
"(",
"properties",
"->",
"valueDef",
".",
"addProperties",
"(",
"properties",
")",
")",
";",
"return",
"valueDef",
";",
"}",
"catch",
"(",
"SystemInputException",
"e",
")",
"{",
"throw",
"new",
"SystemInputException",
"(",
"String",
".",
"format",
"(",
"\"Error defining value=%s\"",
",",
"valueName",
")",
",",
"e",
")",
";",
"}",
"}"
] | Returns the value definition represented by the given JSON object. | [
"Returns",
"the",
"value",
"definition",
"represented",
"by",
"the",
"given",
"JSON",
"object",
"."
] | train | https://github.com/Cornutum/tcases/blob/21e15cf107fa149620c40f4bda1829c1224fcfb1/tcases-io/src/main/java/org/cornutum/tcases/io/SystemInputJson.java#L342-L380 |
yoojia/NextInputs-Android | inputs/src/main/java/com/github/yoojia/inputs/Texts.java | Texts.regexMatch | public static boolean regexMatch(String input, String regex) {
"""
If input matched regex
@param input Input String
@param regex Regex
@return is matched
"""
return Pattern.compile(regex).matcher(input).matches();
} | java | public static boolean regexMatch(String input, String regex) {
return Pattern.compile(regex).matcher(input).matches();
} | [
"public",
"static",
"boolean",
"regexMatch",
"(",
"String",
"input",
",",
"String",
"regex",
")",
"{",
"return",
"Pattern",
".",
"compile",
"(",
"regex",
")",
".",
"matcher",
"(",
"input",
")",
".",
"matches",
"(",
")",
";",
"}"
] | If input matched regex
@param input Input String
@param regex Regex
@return is matched | [
"If",
"input",
"matched",
"regex"
] | train | https://github.com/yoojia/NextInputs-Android/blob/9ca90cf47e84c41ac226d04694194334d2923252/inputs/src/main/java/com/github/yoojia/inputs/Texts.java#L27-L29 |
alexvasilkov/GestureViews | library/src/main/java/com/alexvasilkov/gestures/utils/GravityUtils.java | GravityUtils.getImagePosition | public static void getImagePosition(Matrix matrix, Settings settings, Rect out) {
"""
Calculates image position (scaled and rotated) within viewport area with gravity applied.
@param matrix Image matrix
@param settings Image settings
@param out Output rectangle
"""
tmpRectF.set(0, 0, settings.getImageW(), settings.getImageH());
matrix.mapRect(tmpRectF);
final int w = Math.round(tmpRectF.width());
final int h = Math.round(tmpRectF.height());
// Calculating image position basing on gravity
tmpRect1.set(0, 0, settings.getViewportW(), settings.getViewportH());
Gravity.apply(settings.getGravity(), w, h, tmpRect1, out);
} | java | public static void getImagePosition(Matrix matrix, Settings settings, Rect out) {
tmpRectF.set(0, 0, settings.getImageW(), settings.getImageH());
matrix.mapRect(tmpRectF);
final int w = Math.round(tmpRectF.width());
final int h = Math.round(tmpRectF.height());
// Calculating image position basing on gravity
tmpRect1.set(0, 0, settings.getViewportW(), settings.getViewportH());
Gravity.apply(settings.getGravity(), w, h, tmpRect1, out);
} | [
"public",
"static",
"void",
"getImagePosition",
"(",
"Matrix",
"matrix",
",",
"Settings",
"settings",
",",
"Rect",
"out",
")",
"{",
"tmpRectF",
".",
"set",
"(",
"0",
",",
"0",
",",
"settings",
".",
"getImageW",
"(",
")",
",",
"settings",
".",
"getImageH",
"(",
")",
")",
";",
"matrix",
".",
"mapRect",
"(",
"tmpRectF",
")",
";",
"final",
"int",
"w",
"=",
"Math",
".",
"round",
"(",
"tmpRectF",
".",
"width",
"(",
")",
")",
";",
"final",
"int",
"h",
"=",
"Math",
".",
"round",
"(",
"tmpRectF",
".",
"height",
"(",
")",
")",
";",
"// Calculating image position basing on gravity",
"tmpRect1",
".",
"set",
"(",
"0",
",",
"0",
",",
"settings",
".",
"getViewportW",
"(",
")",
",",
"settings",
".",
"getViewportH",
"(",
")",
")",
";",
"Gravity",
".",
"apply",
"(",
"settings",
".",
"getGravity",
"(",
")",
",",
"w",
",",
"h",
",",
"tmpRect1",
",",
"out",
")",
";",
"}"
] | Calculates image position (scaled and rotated) within viewport area with gravity applied.
@param matrix Image matrix
@param settings Image settings
@param out Output rectangle | [
"Calculates",
"image",
"position",
"(",
"scaled",
"and",
"rotated",
")",
"within",
"viewport",
"area",
"with",
"gravity",
"applied",
"."
] | train | https://github.com/alexvasilkov/GestureViews/blob/f0a4c266e31dcad23bd0d9013531bc1c501b9c9f/library/src/main/java/com/alexvasilkov/gestures/utils/GravityUtils.java#L42-L53 |
kuujo/vertigo | core/src/main/java/net/kuujo/vertigo/util/Configs.java | Configs.unmergeNetworks | public static NetworkConfig unmergeNetworks(NetworkConfig base, NetworkConfig unmerge) {
"""
Unmerges one network configuration from another.
@param base The base network configuration.
@param unmerge The configuration to extract.
@return The cleaned configuration.
"""
if (!base.getName().equals(unmerge.getName())) {
throw new IllegalArgumentException("Cannot merge networks of different names.");
}
for (ComponentConfig<?> component : unmerge.getComponents()) {
base.removeComponent(component.getName());
}
for (ConnectionConfig connection : unmerge.getConnections()) {
base.destroyConnection(connection);
}
return base;
} | java | public static NetworkConfig unmergeNetworks(NetworkConfig base, NetworkConfig unmerge) {
if (!base.getName().equals(unmerge.getName())) {
throw new IllegalArgumentException("Cannot merge networks of different names.");
}
for (ComponentConfig<?> component : unmerge.getComponents()) {
base.removeComponent(component.getName());
}
for (ConnectionConfig connection : unmerge.getConnections()) {
base.destroyConnection(connection);
}
return base;
} | [
"public",
"static",
"NetworkConfig",
"unmergeNetworks",
"(",
"NetworkConfig",
"base",
",",
"NetworkConfig",
"unmerge",
")",
"{",
"if",
"(",
"!",
"base",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"unmerge",
".",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot merge networks of different names.\"",
")",
";",
"}",
"for",
"(",
"ComponentConfig",
"<",
"?",
">",
"component",
":",
"unmerge",
".",
"getComponents",
"(",
")",
")",
"{",
"base",
".",
"removeComponent",
"(",
"component",
".",
"getName",
"(",
")",
")",
";",
"}",
"for",
"(",
"ConnectionConfig",
"connection",
":",
"unmerge",
".",
"getConnections",
"(",
")",
")",
"{",
"base",
".",
"destroyConnection",
"(",
"connection",
")",
";",
"}",
"return",
"base",
";",
"}"
] | Unmerges one network configuration from another.
@param base The base network configuration.
@param unmerge The configuration to extract.
@return The cleaned configuration. | [
"Unmerges",
"one",
"network",
"configuration",
"from",
"another",
"."
] | train | https://github.com/kuujo/vertigo/blob/c5869dbc5fff89eb5262e83f7a81719b01a5ba6f/core/src/main/java/net/kuujo/vertigo/util/Configs.java#L106-L119 |
Omertron/api-rottentomatoes | src/main/java/com/omertron/rottentomatoesapi/RottenTomatoesApi.java | RottenTomatoesApi.getUpcomingMovies | public List<RTMovie> getUpcomingMovies(String country) throws RottenTomatoesException {
"""
Retrieves upcoming movies
@param country Provides localized data for the selected country
@return
@throws RottenTomatoesException
"""
return getUpcomingMovies(country, DEFAULT_PAGE, DEFAULT_PAGE_LIMIT);
} | java | public List<RTMovie> getUpcomingMovies(String country) throws RottenTomatoesException {
return getUpcomingMovies(country, DEFAULT_PAGE, DEFAULT_PAGE_LIMIT);
} | [
"public",
"List",
"<",
"RTMovie",
">",
"getUpcomingMovies",
"(",
"String",
"country",
")",
"throws",
"RottenTomatoesException",
"{",
"return",
"getUpcomingMovies",
"(",
"country",
",",
"DEFAULT_PAGE",
",",
"DEFAULT_PAGE_LIMIT",
")",
";",
"}"
] | Retrieves upcoming movies
@param country Provides localized data for the selected country
@return
@throws RottenTomatoesException | [
"Retrieves",
"upcoming",
"movies"
] | train | https://github.com/Omertron/api-rottentomatoes/blob/abaf1833acafc6ada593d52b14ff1bacb4e441ee/src/main/java/com/omertron/rottentomatoesapi/RottenTomatoesApi.java#L306-L308 |
encoway/edu | edu/src/main/java/com/encoway/edu/EventDrivenUpdatesMap.java | EventDrivenUpdatesMap.get | public String get(String events, String defaultValue) {
"""
Returns a space separated list of component IDs of components registered for at least one the `events`.
@param events a comma/space separated list of event names
@param defaultValue will be returned if no component is registered for one of the `events`
@return a space separated list of fully qualified component IDs or `defaultValue`
"""
return get(parseEvents(events), defaultValue);
} | java | public String get(String events, String defaultValue) {
return get(parseEvents(events), defaultValue);
} | [
"public",
"String",
"get",
"(",
"String",
"events",
",",
"String",
"defaultValue",
")",
"{",
"return",
"get",
"(",
"parseEvents",
"(",
"events",
")",
",",
"defaultValue",
")",
";",
"}"
] | Returns a space separated list of component IDs of components registered for at least one the `events`.
@param events a comma/space separated list of event names
@param defaultValue will be returned if no component is registered for one of the `events`
@return a space separated list of fully qualified component IDs or `defaultValue` | [
"Returns",
"a",
"space",
"separated",
"list",
"of",
"component",
"IDs",
"of",
"components",
"registered",
"for",
"at",
"least",
"one",
"the",
"events",
"."
] | train | https://github.com/encoway/edu/blob/52ae92b2207f7d5668e212904359fbeb360f3f05/edu/src/main/java/com/encoway/edu/EventDrivenUpdatesMap.java#L120-L122 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/FastStringBuffer.java | FastStringBuffer.setLength | private final void setLength(int l, FastStringBuffer rootFSB) {
"""
Subroutine for the public setLength() method. Deals with the fact
that truncation may require restoring one of the innerFSBs
NEEDSDOC @param l
NEEDSDOC @param rootFSB
"""
m_lastChunk = l >>> m_chunkBits;
if (m_lastChunk == 0 && m_innerFSB != null)
{
m_innerFSB.setLength(l, rootFSB);
}
else
{
// Undo encapsulation -- pop the innerFSB data back up to root.
// Inefficient, but attempts to keep the code simple.
rootFSB.m_chunkBits = m_chunkBits;
rootFSB.m_maxChunkBits = m_maxChunkBits;
rootFSB.m_rebundleBits = m_rebundleBits;
rootFSB.m_chunkSize = m_chunkSize;
rootFSB.m_chunkMask = m_chunkMask;
rootFSB.m_array = m_array;
rootFSB.m_innerFSB = m_innerFSB;
rootFSB.m_lastChunk = m_lastChunk;
// Finally, truncate this sucker.
rootFSB.m_firstFree = l & m_chunkMask;
}
} | java | private final void setLength(int l, FastStringBuffer rootFSB)
{
m_lastChunk = l >>> m_chunkBits;
if (m_lastChunk == 0 && m_innerFSB != null)
{
m_innerFSB.setLength(l, rootFSB);
}
else
{
// Undo encapsulation -- pop the innerFSB data back up to root.
// Inefficient, but attempts to keep the code simple.
rootFSB.m_chunkBits = m_chunkBits;
rootFSB.m_maxChunkBits = m_maxChunkBits;
rootFSB.m_rebundleBits = m_rebundleBits;
rootFSB.m_chunkSize = m_chunkSize;
rootFSB.m_chunkMask = m_chunkMask;
rootFSB.m_array = m_array;
rootFSB.m_innerFSB = m_innerFSB;
rootFSB.m_lastChunk = m_lastChunk;
// Finally, truncate this sucker.
rootFSB.m_firstFree = l & m_chunkMask;
}
} | [
"private",
"final",
"void",
"setLength",
"(",
"int",
"l",
",",
"FastStringBuffer",
"rootFSB",
")",
"{",
"m_lastChunk",
"=",
"l",
">>>",
"m_chunkBits",
";",
"if",
"(",
"m_lastChunk",
"==",
"0",
"&&",
"m_innerFSB",
"!=",
"null",
")",
"{",
"m_innerFSB",
".",
"setLength",
"(",
"l",
",",
"rootFSB",
")",
";",
"}",
"else",
"{",
"// Undo encapsulation -- pop the innerFSB data back up to root.",
"// Inefficient, but attempts to keep the code simple.",
"rootFSB",
".",
"m_chunkBits",
"=",
"m_chunkBits",
";",
"rootFSB",
".",
"m_maxChunkBits",
"=",
"m_maxChunkBits",
";",
"rootFSB",
".",
"m_rebundleBits",
"=",
"m_rebundleBits",
";",
"rootFSB",
".",
"m_chunkSize",
"=",
"m_chunkSize",
";",
"rootFSB",
".",
"m_chunkMask",
"=",
"m_chunkMask",
";",
"rootFSB",
".",
"m_array",
"=",
"m_array",
";",
"rootFSB",
".",
"m_innerFSB",
"=",
"m_innerFSB",
";",
"rootFSB",
".",
"m_lastChunk",
"=",
"m_lastChunk",
";",
"// Finally, truncate this sucker.",
"rootFSB",
".",
"m_firstFree",
"=",
"l",
"&",
"m_chunkMask",
";",
"}",
"}"
] | Subroutine for the public setLength() method. Deals with the fact
that truncation may require restoring one of the innerFSBs
NEEDSDOC @param l
NEEDSDOC @param rootFSB | [
"Subroutine",
"for",
"the",
"public",
"setLength",
"()",
"method",
".",
"Deals",
"with",
"the",
"fact",
"that",
"truncation",
"may",
"require",
"restoring",
"one",
"of",
"the",
"innerFSBs"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/FastStringBuffer.java#L357-L383 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nearestneighbors-parent/nearestneighbor-core/src/main/java/org/deeplearning4j/clustering/quadtree/QuadTree.java | QuadTree.computeNonEdgeForces | public void computeNonEdgeForces(int pointIndex, double theta, INDArray negativeForce, AtomicDouble sumQ) {
"""
Compute non edge forces using barnes hut
@param pointIndex
@param theta
@param negativeForce
@param sumQ
"""
// Make sure that we spend no time on empty nodes or self-interactions
if (cumSize == 0 || (isLeaf() && size == 1 && index[0] == pointIndex))
return;
// Compute distance between point and center-of-mass
buf.assign(data.slice(pointIndex)).subi(centerOfMass);
double D = Nd4j.getBlasWrapper().dot(buf, buf);
// Check whether we can use this node as a "summary"
if (isLeaf || FastMath.max(boundary.getHh(), boundary.getHw()) / FastMath.sqrt(D) < theta) {
// Compute and add t-SNE force between point and current node
double Q = 1.0 / (1.0 + D);
double mult = cumSize * Q;
sumQ.addAndGet(mult);
mult *= Q;
negativeForce.addi(buf.mul(mult));
} else {
// Recursively apply Barnes-Hut to children
northWest.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
northEast.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
southWest.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
southEast.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
}
} | java | public void computeNonEdgeForces(int pointIndex, double theta, INDArray negativeForce, AtomicDouble sumQ) {
// Make sure that we spend no time on empty nodes or self-interactions
if (cumSize == 0 || (isLeaf() && size == 1 && index[0] == pointIndex))
return;
// Compute distance between point and center-of-mass
buf.assign(data.slice(pointIndex)).subi(centerOfMass);
double D = Nd4j.getBlasWrapper().dot(buf, buf);
// Check whether we can use this node as a "summary"
if (isLeaf || FastMath.max(boundary.getHh(), boundary.getHw()) / FastMath.sqrt(D) < theta) {
// Compute and add t-SNE force between point and current node
double Q = 1.0 / (1.0 + D);
double mult = cumSize * Q;
sumQ.addAndGet(mult);
mult *= Q;
negativeForce.addi(buf.mul(mult));
} else {
// Recursively apply Barnes-Hut to children
northWest.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
northEast.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
southWest.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
southEast.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
}
} | [
"public",
"void",
"computeNonEdgeForces",
"(",
"int",
"pointIndex",
",",
"double",
"theta",
",",
"INDArray",
"negativeForce",
",",
"AtomicDouble",
"sumQ",
")",
"{",
"// Make sure that we spend no time on empty nodes or self-interactions",
"if",
"(",
"cumSize",
"==",
"0",
"||",
"(",
"isLeaf",
"(",
")",
"&&",
"size",
"==",
"1",
"&&",
"index",
"[",
"0",
"]",
"==",
"pointIndex",
")",
")",
"return",
";",
"// Compute distance between point and center-of-mass",
"buf",
".",
"assign",
"(",
"data",
".",
"slice",
"(",
"pointIndex",
")",
")",
".",
"subi",
"(",
"centerOfMass",
")",
";",
"double",
"D",
"=",
"Nd4j",
".",
"getBlasWrapper",
"(",
")",
".",
"dot",
"(",
"buf",
",",
"buf",
")",
";",
"// Check whether we can use this node as a \"summary\"",
"if",
"(",
"isLeaf",
"||",
"FastMath",
".",
"max",
"(",
"boundary",
".",
"getHh",
"(",
")",
",",
"boundary",
".",
"getHw",
"(",
")",
")",
"/",
"FastMath",
".",
"sqrt",
"(",
"D",
")",
"<",
"theta",
")",
"{",
"// Compute and add t-SNE force between point and current node",
"double",
"Q",
"=",
"1.0",
"/",
"(",
"1.0",
"+",
"D",
")",
";",
"double",
"mult",
"=",
"cumSize",
"*",
"Q",
";",
"sumQ",
".",
"addAndGet",
"(",
"mult",
")",
";",
"mult",
"*=",
"Q",
";",
"negativeForce",
".",
"addi",
"(",
"buf",
".",
"mul",
"(",
"mult",
")",
")",
";",
"}",
"else",
"{",
"// Recursively apply Barnes-Hut to children",
"northWest",
".",
"computeNonEdgeForces",
"(",
"pointIndex",
",",
"theta",
",",
"negativeForce",
",",
"sumQ",
")",
";",
"northEast",
".",
"computeNonEdgeForces",
"(",
"pointIndex",
",",
"theta",
",",
"negativeForce",
",",
"sumQ",
")",
";",
"southWest",
".",
"computeNonEdgeForces",
"(",
"pointIndex",
",",
"theta",
",",
"negativeForce",
",",
"sumQ",
")",
";",
"southEast",
".",
"computeNonEdgeForces",
"(",
"pointIndex",
",",
"theta",
",",
"negativeForce",
",",
"sumQ",
")",
";",
"}",
"}"
] | Compute non edge forces using barnes hut
@param pointIndex
@param theta
@param negativeForce
@param sumQ | [
"Compute",
"non",
"edge",
"forces",
"using",
"barnes",
"hut"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nearestneighbors-parent/nearestneighbor-core/src/main/java/org/deeplearning4j/clustering/quadtree/QuadTree.java#L236-L265 |
spring-projects/spring-social-facebook | spring-social-facebook-web/src/main/java/org/springframework/social/facebook/web/SignedRequestDecoder.java | SignedRequestDecoder.decodeSignedRequest | @SuppressWarnings("unchecked")
public Map<String, ?> decodeSignedRequest(String signedRequest) throws SignedRequestException {
"""
Decodes a signed request, returning the payload of the signed request as a Map
@param signedRequest the value of the signed_request parameter sent by Facebook.
@return the payload of the signed request as a Map
@throws SignedRequestException if there is an error decoding the signed request
"""
return decodeSignedRequest(signedRequest, Map.class);
} | java | @SuppressWarnings("unchecked")
public Map<String, ?> decodeSignedRequest(String signedRequest) throws SignedRequestException {
return decodeSignedRequest(signedRequest, Map.class);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Map",
"<",
"String",
",",
"?",
">",
"decodeSignedRequest",
"(",
"String",
"signedRequest",
")",
"throws",
"SignedRequestException",
"{",
"return",
"decodeSignedRequest",
"(",
"signedRequest",
",",
"Map",
".",
"class",
")",
";",
"}"
] | Decodes a signed request, returning the payload of the signed request as a Map
@param signedRequest the value of the signed_request parameter sent by Facebook.
@return the payload of the signed request as a Map
@throws SignedRequestException if there is an error decoding the signed request | [
"Decodes",
"a",
"signed",
"request",
"returning",
"the",
"payload",
"of",
"the",
"signed",
"request",
"as",
"a",
"Map"
] | train | https://github.com/spring-projects/spring-social-facebook/blob/ae2234d94367eaa3adbba251ec7790d5ba7ffa41/spring-social-facebook-web/src/main/java/org/springframework/social/facebook/web/SignedRequestDecoder.java#L58-L61 |
qiujiayu/AutoLoadCache | src/main/java/com/jarvis/cache/script/AbstractScriptParser.java | AbstractScriptParser.getRealExpire | public int getRealExpire(int expire, String expireExpression, Object[] arguments, Object result) throws Exception {
"""
获取真实的缓存时间值
@param expire 缓存时间
@param expireExpression 缓存时间表达式
@param arguments 方法参数
@param result 方法执行返回结果
@return real expire
@throws Exception 异常
"""
Integer tmpExpire = null;
if (null != expireExpression && expireExpression.length() > 0) {
tmpExpire = this.getElValue(expireExpression, null, arguments, result, true, Integer.class);
if (null != tmpExpire && tmpExpire.intValue() >= 0) {
// 返回缓存时间表达式计算的时间
return tmpExpire.intValue();
}
}
return expire;
} | java | public int getRealExpire(int expire, String expireExpression, Object[] arguments, Object result) throws Exception {
Integer tmpExpire = null;
if (null != expireExpression && expireExpression.length() > 0) {
tmpExpire = this.getElValue(expireExpression, null, arguments, result, true, Integer.class);
if (null != tmpExpire && tmpExpire.intValue() >= 0) {
// 返回缓存时间表达式计算的时间
return tmpExpire.intValue();
}
}
return expire;
} | [
"public",
"int",
"getRealExpire",
"(",
"int",
"expire",
",",
"String",
"expireExpression",
",",
"Object",
"[",
"]",
"arguments",
",",
"Object",
"result",
")",
"throws",
"Exception",
"{",
"Integer",
"tmpExpire",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"expireExpression",
"&&",
"expireExpression",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"tmpExpire",
"=",
"this",
".",
"getElValue",
"(",
"expireExpression",
",",
"null",
",",
"arguments",
",",
"result",
",",
"true",
",",
"Integer",
".",
"class",
")",
";",
"if",
"(",
"null",
"!=",
"tmpExpire",
"&&",
"tmpExpire",
".",
"intValue",
"(",
")",
">=",
"0",
")",
"{",
"// 返回缓存时间表达式计算的时间\r",
"return",
"tmpExpire",
".",
"intValue",
"(",
")",
";",
"}",
"}",
"return",
"expire",
";",
"}"
] | 获取真实的缓存时间值
@param expire 缓存时间
@param expireExpression 缓存时间表达式
@param arguments 方法参数
@param result 方法执行返回结果
@return real expire
@throws Exception 异常 | [
"获取真实的缓存时间值"
] | train | https://github.com/qiujiayu/AutoLoadCache/blob/8121c146f1a420fa6d6832e849acadb547c13622/src/main/java/com/jarvis/cache/script/AbstractScriptParser.java#L188-L198 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheProviderWrapper.java | CacheProviderWrapper.invalidateAndSet | @Override
public Object invalidateAndSet(com.ibm.ws.cache.EntryInfo ei, Object value, boolean coordinate) {
"""
Puts an entry into the cache. If the entry already exists in the
cache, this method will ALSO update the same.
Called by DistributedMap
@param ei The EntryInfo object
@param value The value of the object
@param coordinate Indicates that the value should be set in other caches caching this value. (No effect on CoreCache)
"""
final String methodName = "invalidateAndSet()";
Object oldValue = null;
Object id = null;
if (ei != null && value != null) {
id = ei.getIdObject();
com.ibm.websphere.cache.CacheEntry oldCacheEntry = this.coreCache.put(ei, value);
if (oldCacheEntry != null) {
oldValue = oldCacheEntry.getValue();
}
}
if (tc.isDebugEnabled()) {
Tr.debug(tc, methodName + " cacheName=" + cacheName + " id=" + id + " value=" + value);
}
return oldValue;
} | java | @Override
public Object invalidateAndSet(com.ibm.ws.cache.EntryInfo ei, Object value, boolean coordinate) {
final String methodName = "invalidateAndSet()";
Object oldValue = null;
Object id = null;
if (ei != null && value != null) {
id = ei.getIdObject();
com.ibm.websphere.cache.CacheEntry oldCacheEntry = this.coreCache.put(ei, value);
if (oldCacheEntry != null) {
oldValue = oldCacheEntry.getValue();
}
}
if (tc.isDebugEnabled()) {
Tr.debug(tc, methodName + " cacheName=" + cacheName + " id=" + id + " value=" + value);
}
return oldValue;
} | [
"@",
"Override",
"public",
"Object",
"invalidateAndSet",
"(",
"com",
".",
"ibm",
".",
"ws",
".",
"cache",
".",
"EntryInfo",
"ei",
",",
"Object",
"value",
",",
"boolean",
"coordinate",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"invalidateAndSet()\"",
";",
"Object",
"oldValue",
"=",
"null",
";",
"Object",
"id",
"=",
"null",
";",
"if",
"(",
"ei",
"!=",
"null",
"&&",
"value",
"!=",
"null",
")",
"{",
"id",
"=",
"ei",
".",
"getIdObject",
"(",
")",
";",
"com",
".",
"ibm",
".",
"websphere",
".",
"cache",
".",
"CacheEntry",
"oldCacheEntry",
"=",
"this",
".",
"coreCache",
".",
"put",
"(",
"ei",
",",
"value",
")",
";",
"if",
"(",
"oldCacheEntry",
"!=",
"null",
")",
"{",
"oldValue",
"=",
"oldCacheEntry",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"methodName",
"+",
"\" cacheName=\"",
"+",
"cacheName",
"+",
"\" id=\"",
"+",
"id",
"+",
"\" value=\"",
"+",
"value",
")",
";",
"}",
"return",
"oldValue",
";",
"}"
] | Puts an entry into the cache. If the entry already exists in the
cache, this method will ALSO update the same.
Called by DistributedMap
@param ei The EntryInfo object
@param value The value of the object
@param coordinate Indicates that the value should be set in other caches caching this value. (No effect on CoreCache) | [
"Puts",
"an",
"entry",
"into",
"the",
"cache",
".",
"If",
"the",
"entry",
"already",
"exists",
"in",
"the",
"cache",
"this",
"method",
"will",
"ALSO",
"update",
"the",
"same",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheProviderWrapper.java#L439-L455 |
sawano/java-commons | src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java | AbstractValidate.matchesPattern | public CharSequence matchesPattern(final CharSequence input, final String pattern, final String message, final Object... values) {
"""
<p>Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception with the specified message.</p>
<pre>Validate.matchesPattern("hi", "[a-z]*", "%s does not match %s", "hi" "[a-z]*");</pre>
<p>The syntax of the pattern is the one used in the {@link java.util.regex.Pattern} class.</p>
@param input
the character sequence to validate, not null
@param pattern
the regular expression pattern, not null
@param message
the {@link String#format(String, Object...)} exception message if invalid, not null
@param values
the optional values for the formatted exception message, null array not recommended
@return the input
@throws IllegalArgumentValidationException
if the character sequence does not match the pattern
@see #matchesPattern(CharSequence, String)
"""
if (!Pattern.matches(pattern, input)) {
fail(String.format(message, values));
}
return input;
} | java | public CharSequence matchesPattern(final CharSequence input, final String pattern, final String message, final Object... values) {
if (!Pattern.matches(pattern, input)) {
fail(String.format(message, values));
}
return input;
} | [
"public",
"CharSequence",
"matchesPattern",
"(",
"final",
"CharSequence",
"input",
",",
"final",
"String",
"pattern",
",",
"final",
"String",
"message",
",",
"final",
"Object",
"...",
"values",
")",
"{",
"if",
"(",
"!",
"Pattern",
".",
"matches",
"(",
"pattern",
",",
"input",
")",
")",
"{",
"fail",
"(",
"String",
".",
"format",
"(",
"message",
",",
"values",
")",
")",
";",
"}",
"return",
"input",
";",
"}"
] | <p>Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception with the specified message.</p>
<pre>Validate.matchesPattern("hi", "[a-z]*", "%s does not match %s", "hi" "[a-z]*");</pre>
<p>The syntax of the pattern is the one used in the {@link java.util.regex.Pattern} class.</p>
@param input
the character sequence to validate, not null
@param pattern
the regular expression pattern, not null
@param message
the {@link String#format(String, Object...)} exception message if invalid, not null
@param values
the optional values for the formatted exception message, null array not recommended
@return the input
@throws IllegalArgumentValidationException
if the character sequence does not match the pattern
@see #matchesPattern(CharSequence, String) | [
"<p",
">",
"Validate",
"that",
"the",
"specified",
"argument",
"character",
"sequence",
"matches",
"the",
"specified",
"regular",
"expression",
"pattern",
";",
"otherwise",
"throwing",
"an",
"exception",
"with",
"the",
"specified",
"message",
".",
"<",
"/",
"p",
">",
"<pre",
">",
"Validate",
".",
"matchesPattern",
"(",
"hi",
"[",
"a",
"-",
"z",
"]",
"*",
"%s",
"does",
"not",
"match",
"%s",
"hi",
"[",
"a",
"-",
"z",
"]",
"*",
")",
";",
"<",
"/",
"pre",
">",
"<p",
">",
"The",
"syntax",
"of",
"the",
"pattern",
"is",
"the",
"one",
"used",
"in",
"the",
"{",
"@link",
"java",
".",
"util",
".",
"regex",
".",
"Pattern",
"}",
"class",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/sawano/java-commons/blob/6f219c9e8dec4401dbe528d17ae6ec1ef9c0d284/src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java#L1197-L1202 |
Mozu/mozu-java | mozu-java-core/src/main/java/com/mozu/api/urls/platform/entitylists/ListViewUrl.java | ListViewUrl.getViewEntityContainersUrl | public static MozuUrl getViewEntityContainersUrl(String entityListFullName, String filter, Integer pageSize, String responseFields, Integer startIndex, String viewName) {
"""
Get Resource Url for GetViewEntityContainers
@param entityListFullName The full name of the EntityList including namespace in name@nameSpace format
@param filter A set of filter expressions representing the search parameters for a query. This parameter is optional. Refer to [Sorting and Filtering](../../../../Developer/api-guides/sorting-filtering.htm) for a list of supported filters.
@param pageSize When creating paged results from a query, this value indicates the zero-based offset in the complete result set where the returned entities begin. For example, with this parameter set to 25, to get the 51st through the 75th items, set startIndex to 50.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@param startIndex When creating paged results from a query, this value indicates the zero-based offset in the complete result set where the returned entities begin. For example, with pageSize set to 25, to get the 51st through the 75th items, set this parameter to 50.
@param viewName The name for a view. Views are used to render data in , such as document and entity lists. Each view includes a schema, format, name, ID, and associated data types to render.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/platform/entitylists/{entityListFullName}/views/{viewName}/entityContainers?pageSize={pageSize}&startIndex={startIndex}&filter={filter}&responseFields={responseFields}");
formatter.formatUrl("entityListFullName", entityListFullName);
formatter.formatUrl("filter", filter);
formatter.formatUrl("pageSize", pageSize);
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("startIndex", startIndex);
formatter.formatUrl("viewName", viewName);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl getViewEntityContainersUrl(String entityListFullName, String filter, Integer pageSize, String responseFields, Integer startIndex, String viewName)
{
UrlFormatter formatter = new UrlFormatter("/api/platform/entitylists/{entityListFullName}/views/{viewName}/entityContainers?pageSize={pageSize}&startIndex={startIndex}&filter={filter}&responseFields={responseFields}");
formatter.formatUrl("entityListFullName", entityListFullName);
formatter.formatUrl("filter", filter);
formatter.formatUrl("pageSize", pageSize);
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("startIndex", startIndex);
formatter.formatUrl("viewName", viewName);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"getViewEntityContainersUrl",
"(",
"String",
"entityListFullName",
",",
"String",
"filter",
",",
"Integer",
"pageSize",
",",
"String",
"responseFields",
",",
"Integer",
"startIndex",
",",
"String",
"viewName",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/platform/entitylists/{entityListFullName}/views/{viewName}/entityContainers?pageSize={pageSize}&startIndex={startIndex}&filter={filter}&responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"entityListFullName\"",
",",
"entityListFullName",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"filter\"",
",",
"filter",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"pageSize\"",
",",
"pageSize",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"startIndex\"",
",",
"startIndex",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"viewName\"",
",",
"viewName",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] | Get Resource Url for GetViewEntityContainers
@param entityListFullName The full name of the EntityList including namespace in name@nameSpace format
@param filter A set of filter expressions representing the search parameters for a query. This parameter is optional. Refer to [Sorting and Filtering](../../../../Developer/api-guides/sorting-filtering.htm) for a list of supported filters.
@param pageSize When creating paged results from a query, this value indicates the zero-based offset in the complete result set where the returned entities begin. For example, with this parameter set to 25, to get the 51st through the 75th items, set startIndex to 50.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@param startIndex When creating paged results from a query, this value indicates the zero-based offset in the complete result set where the returned entities begin. For example, with pageSize set to 25, to get the 51st through the 75th items, set this parameter to 50.
@param viewName The name for a view. Views are used to render data in , such as document and entity lists. Each view includes a schema, format, name, ID, and associated data types to render.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"GetViewEntityContainers"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/platform/entitylists/ListViewUrl.java#L84-L94 |
apache/groovy | subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java | XmlSlurper.setEntityBaseUrl | public void setEntityBaseUrl(final URL base) {
"""
Resolves entities against using the supplied URL as the base for relative URLs
@param base The URL used to resolve relative URLs
"""
reader.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(final String publicId, final String systemId) throws IOException {
return new InputSource(new URL(base, systemId).openStream());
}
});
} | java | public void setEntityBaseUrl(final URL base) {
reader.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(final String publicId, final String systemId) throws IOException {
return new InputSource(new URL(base, systemId).openStream());
}
});
} | [
"public",
"void",
"setEntityBaseUrl",
"(",
"final",
"URL",
"base",
")",
"{",
"reader",
".",
"setEntityResolver",
"(",
"new",
"EntityResolver",
"(",
")",
"{",
"public",
"InputSource",
"resolveEntity",
"(",
"final",
"String",
"publicId",
",",
"final",
"String",
"systemId",
")",
"throws",
"IOException",
"{",
"return",
"new",
"InputSource",
"(",
"new",
"URL",
"(",
"base",
",",
"systemId",
")",
".",
"openStream",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Resolves entities against using the supplied URL as the base for relative URLs
@param base The URL used to resolve relative URLs | [
"Resolves",
"entities",
"against",
"using",
"the",
"supplied",
"URL",
"as",
"the",
"base",
"for",
"relative",
"URLs"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java#L340-L346 |
kiegroup/drools | kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/codegen/feel11/CompiledFEELSemanticMappings.java | CompiledFEELSemanticMappings.sub | public static Object sub(Object left, Object right) {
"""
FEEL spec Table 45
Delegates to {@link InfixOpNode} except evaluationcontext
"""
return InfixOpNode.sub(left, right, null);
} | java | public static Object sub(Object left, Object right) {
return InfixOpNode.sub(left, right, null);
} | [
"public",
"static",
"Object",
"sub",
"(",
"Object",
"left",
",",
"Object",
"right",
")",
"{",
"return",
"InfixOpNode",
".",
"sub",
"(",
"left",
",",
"right",
",",
"null",
")",
";",
"}"
] | FEEL spec Table 45
Delegates to {@link InfixOpNode} except evaluationcontext | [
"FEEL",
"spec",
"Table",
"45",
"Delegates",
"to",
"{"
] | train | https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/codegen/feel11/CompiledFEELSemanticMappings.java#L306-L308 |
alkacon/opencms-core | src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageController.java | CmsContainerpageController.requiresOptionBar | public boolean requiresOptionBar(CmsContainerPageElementPanel element, I_CmsDropContainer dragParent) {
"""
Checks whether the given element should display the option bar.<p>
@param element the element
@param dragParent the element parent
@return <code>true</code> if the given element should display the option bar
"""
return element.hasViewPermission()
&& (!element.hasModelGroupParent() || getData().isModelGroup())
&& (matchRootView(element.getElementView())
|| isGroupcontainerEditing()
|| shouldShowModelgroupOptionBar(element))
&& isContainerEditable(dragParent)
&& matchesCurrentEditLevel(dragParent);
} | java | public boolean requiresOptionBar(CmsContainerPageElementPanel element, I_CmsDropContainer dragParent) {
return element.hasViewPermission()
&& (!element.hasModelGroupParent() || getData().isModelGroup())
&& (matchRootView(element.getElementView())
|| isGroupcontainerEditing()
|| shouldShowModelgroupOptionBar(element))
&& isContainerEditable(dragParent)
&& matchesCurrentEditLevel(dragParent);
} | [
"public",
"boolean",
"requiresOptionBar",
"(",
"CmsContainerPageElementPanel",
"element",
",",
"I_CmsDropContainer",
"dragParent",
")",
"{",
"return",
"element",
".",
"hasViewPermission",
"(",
")",
"&&",
"(",
"!",
"element",
".",
"hasModelGroupParent",
"(",
")",
"||",
"getData",
"(",
")",
".",
"isModelGroup",
"(",
")",
")",
"&&",
"(",
"matchRootView",
"(",
"element",
".",
"getElementView",
"(",
")",
")",
"||",
"isGroupcontainerEditing",
"(",
")",
"||",
"shouldShowModelgroupOptionBar",
"(",
"element",
")",
")",
"&&",
"isContainerEditable",
"(",
"dragParent",
")",
"&&",
"matchesCurrentEditLevel",
"(",
"dragParent",
")",
";",
"}"
] | Checks whether the given element should display the option bar.<p>
@param element the element
@param dragParent the element parent
@return <code>true</code> if the given element should display the option bar | [
"Checks",
"whether",
"the",
"given",
"element",
"should",
"display",
"the",
"option",
"bar",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageController.java#L2825-L2834 |
Stratio/deep-spark | deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java | Cells.getShort | public Short getShort(String nameSpace, String cellName) {
"""
Returns the {@code Short} value of the {@link Cell} (associated to {@code table}) whose name iscellName, or null
if this Cells object contains no cell whose name is cellName.
@param nameSpace the name of the owning table
@param cellName the name of the Cell we want to retrieve from this Cells object.
@return the {@code Short} value of the {@link Cell} (associated to {@code table}) whose name is cellName, or null
if this Cells object contains no cell whose name is cellName
"""
return getValue(nameSpace, cellName, Short.class);
} | java | public Short getShort(String nameSpace, String cellName) {
return getValue(nameSpace, cellName, Short.class);
} | [
"public",
"Short",
"getShort",
"(",
"String",
"nameSpace",
",",
"String",
"cellName",
")",
"{",
"return",
"getValue",
"(",
"nameSpace",
",",
"cellName",
",",
"Short",
".",
"class",
")",
";",
"}"
] | Returns the {@code Short} value of the {@link Cell} (associated to {@code table}) whose name iscellName, or null
if this Cells object contains no cell whose name is cellName.
@param nameSpace the name of the owning table
@param cellName the name of the Cell we want to retrieve from this Cells object.
@return the {@code Short} value of the {@link Cell} (associated to {@code table}) whose name is cellName, or null
if this Cells object contains no cell whose name is cellName | [
"Returns",
"the",
"{",
"@code",
"Short",
"}",
"value",
"of",
"the",
"{",
"@link",
"Cell",
"}",
"(",
"associated",
"to",
"{",
"@code",
"table",
"}",
")",
"whose",
"name",
"iscellName",
"or",
"null",
"if",
"this",
"Cells",
"object",
"contains",
"no",
"cell",
"whose",
"name",
"is",
"cellName",
"."
] | train | https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java#L979-L981 |
casmi/casmi | src/main/java/casmi/graphics/element/Quad.java | Quad.setCorner | public void setCorner(int index, double x, double y) {
"""
Sets x,y-coordinate of a corner.
@param index The index of a corner.
@param x The x-coordinate of a corner.
@param y The y-coordinate of a corner.
"""
if (index <= 0) {
this.x1 = x;
this.y1 = y;
} else if (index == 1) {
this.x2 = x;
this.y2 = y;
} else if (index == 2) {
this.x3 = x;
this.y3 = y;
} else if (index >= 3) {
this.x4 = x;
this.y4 = y;
}
calcG();
} | java | public void setCorner(int index, double x, double y) {
if (index <= 0) {
this.x1 = x;
this.y1 = y;
} else if (index == 1) {
this.x2 = x;
this.y2 = y;
} else if (index == 2) {
this.x3 = x;
this.y3 = y;
} else if (index >= 3) {
this.x4 = x;
this.y4 = y;
}
calcG();
} | [
"public",
"void",
"setCorner",
"(",
"int",
"index",
",",
"double",
"x",
",",
"double",
"y",
")",
"{",
"if",
"(",
"index",
"<=",
"0",
")",
"{",
"this",
".",
"x1",
"=",
"x",
";",
"this",
".",
"y1",
"=",
"y",
";",
"}",
"else",
"if",
"(",
"index",
"==",
"1",
")",
"{",
"this",
".",
"x2",
"=",
"x",
";",
"this",
".",
"y2",
"=",
"y",
";",
"}",
"else",
"if",
"(",
"index",
"==",
"2",
")",
"{",
"this",
".",
"x3",
"=",
"x",
";",
"this",
".",
"y3",
"=",
"y",
";",
"}",
"else",
"if",
"(",
"index",
">=",
"3",
")",
"{",
"this",
".",
"x4",
"=",
"x",
";",
"this",
".",
"y4",
"=",
"y",
";",
"}",
"calcG",
"(",
")",
";",
"}"
] | Sets x,y-coordinate of a corner.
@param index The index of a corner.
@param x The x-coordinate of a corner.
@param y The y-coordinate of a corner. | [
"Sets",
"x",
"y",
"-",
"coordinate",
"of",
"a",
"corner",
"."
] | train | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/element/Quad.java#L151-L166 |
querydsl/querydsl | querydsl-mongodb/src/main/java/com/querydsl/mongodb/MongodbExpressions.java | MongodbExpressions.nearSphere | public static BooleanExpression nearSphere(Expression<Double[]> expr, double latVal, double longVal) {
"""
Finds the closest points relative to the given location on a sphere and orders the results with decreasing proximity
@param expr location
@param latVal latitude
@param longVal longitude
@return predicate
"""
return Expressions.booleanOperation(MongodbOps.NEAR_SPHERE, expr, ConstantImpl.create(new Double[]{latVal, longVal}));
} | java | public static BooleanExpression nearSphere(Expression<Double[]> expr, double latVal, double longVal) {
return Expressions.booleanOperation(MongodbOps.NEAR_SPHERE, expr, ConstantImpl.create(new Double[]{latVal, longVal}));
} | [
"public",
"static",
"BooleanExpression",
"nearSphere",
"(",
"Expression",
"<",
"Double",
"[",
"]",
">",
"expr",
",",
"double",
"latVal",
",",
"double",
"longVal",
")",
"{",
"return",
"Expressions",
".",
"booleanOperation",
"(",
"MongodbOps",
".",
"NEAR_SPHERE",
",",
"expr",
",",
"ConstantImpl",
".",
"create",
"(",
"new",
"Double",
"[",
"]",
"{",
"latVal",
",",
"longVal",
"}",
")",
")",
";",
"}"
] | Finds the closest points relative to the given location on a sphere and orders the results with decreasing proximity
@param expr location
@param latVal latitude
@param longVal longitude
@return predicate | [
"Finds",
"the",
"closest",
"points",
"relative",
"to",
"the",
"given",
"location",
"on",
"a",
"sphere",
"and",
"orders",
"the",
"results",
"with",
"decreasing",
"proximity"
] | train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-mongodb/src/main/java/com/querydsl/mongodb/MongodbExpressions.java#L51-L53 |
vigna/Sux4J | src/it/unimi/dsi/sux4j/mph/HypergraphSorter.java | HypergraphSorter.tripleToEdge | public static void tripleToEdge(final long[] triple, final long seed, final int numVertices, final int partSize, final int e[]) {
"""
Turns a triple of longs into a 3-hyperedge.
@param triple a triple of intermediate hashes.
@param seed the seed for the hash function.
@param numVertices the number of vertices in the underlying hypergraph.
@param partSize <code>numVertices</code>/3 (to avoid a division).
@param e an array to store the resulting edge.
@see #bitVectorToEdge(BitVector, long, int, int, int[])
"""
if (numVertices == 0) {
e[0] = e[1] = e[2] = -1;
return;
}
final long[] hash = new long[3];
Hashes.spooky4(triple, seed, hash);
e[0] = (int)((hash[0] & 0x7FFFFFFFFFFFFFFFL) % partSize);
e[1] = (int)(partSize + (hash[1] & 0x7FFFFFFFFFFFFFFFL) % partSize);
e[2] = (int)((partSize << 1) + (hash[2] & 0x7FFFFFFFFFFFFFFFL) % partSize);
} | java | public static void tripleToEdge(final long[] triple, final long seed, final int numVertices, final int partSize, final int e[]) {
if (numVertices == 0) {
e[0] = e[1] = e[2] = -1;
return;
}
final long[] hash = new long[3];
Hashes.spooky4(triple, seed, hash);
e[0] = (int)((hash[0] & 0x7FFFFFFFFFFFFFFFL) % partSize);
e[1] = (int)(partSize + (hash[1] & 0x7FFFFFFFFFFFFFFFL) % partSize);
e[2] = (int)((partSize << 1) + (hash[2] & 0x7FFFFFFFFFFFFFFFL) % partSize);
} | [
"public",
"static",
"void",
"tripleToEdge",
"(",
"final",
"long",
"[",
"]",
"triple",
",",
"final",
"long",
"seed",
",",
"final",
"int",
"numVertices",
",",
"final",
"int",
"partSize",
",",
"final",
"int",
"e",
"[",
"]",
")",
"{",
"if",
"(",
"numVertices",
"==",
"0",
")",
"{",
"e",
"[",
"0",
"]",
"=",
"e",
"[",
"1",
"]",
"=",
"e",
"[",
"2",
"]",
"=",
"-",
"1",
";",
"return",
";",
"}",
"final",
"long",
"[",
"]",
"hash",
"=",
"new",
"long",
"[",
"3",
"]",
";",
"Hashes",
".",
"spooky4",
"(",
"triple",
",",
"seed",
",",
"hash",
")",
";",
"e",
"[",
"0",
"]",
"=",
"(",
"int",
")",
"(",
"(",
"hash",
"[",
"0",
"]",
"&",
"0x7FFFFFFFFFFFFFFF",
"L",
")",
"%",
"partSize",
")",
";",
"e",
"[",
"1",
"]",
"=",
"(",
"int",
")",
"(",
"partSize",
"+",
"(",
"hash",
"[",
"1",
"]",
"&",
"0x7FFFFFFFFFFFFFFF",
"L",
")",
"%",
"partSize",
")",
";",
"e",
"[",
"2",
"]",
"=",
"(",
"int",
")",
"(",
"(",
"partSize",
"<<",
"1",
")",
"+",
"(",
"hash",
"[",
"2",
"]",
"&",
"0x7FFFFFFFFFFFFFFF",
"L",
")",
"%",
"partSize",
")",
";",
"}"
] | Turns a triple of longs into a 3-hyperedge.
@param triple a triple of intermediate hashes.
@param seed the seed for the hash function.
@param numVertices the number of vertices in the underlying hypergraph.
@param partSize <code>numVertices</code>/3 (to avoid a division).
@param e an array to store the resulting edge.
@see #bitVectorToEdge(BitVector, long, int, int, int[]) | [
"Turns",
"a",
"triple",
"of",
"longs",
"into",
"a",
"3",
"-",
"hyperedge",
"."
] | train | https://github.com/vigna/Sux4J/blob/d57de8fa897c7d273e0e6dae7a3274174f175a5f/src/it/unimi/dsi/sux4j/mph/HypergraphSorter.java#L232-L242 |
mikepenz/MaterialDrawer | library/src/main/java/com/mikepenz/materialdrawer/Drawer.java | Drawer.addItemAtPosition | public void addItemAtPosition(@NonNull IDrawerItem drawerItem, int position) {
"""
Add a drawerItem at a specific position
@param drawerItem
@param position
"""
mDrawerBuilder.getItemAdapter().add(position, drawerItem);
} | java | public void addItemAtPosition(@NonNull IDrawerItem drawerItem, int position) {
mDrawerBuilder.getItemAdapter().add(position, drawerItem);
} | [
"public",
"void",
"addItemAtPosition",
"(",
"@",
"NonNull",
"IDrawerItem",
"drawerItem",
",",
"int",
"position",
")",
"{",
"mDrawerBuilder",
".",
"getItemAdapter",
"(",
")",
".",
"add",
"(",
"position",
",",
"drawerItem",
")",
";",
"}"
] | Add a drawerItem at a specific position
@param drawerItem
@param position | [
"Add",
"a",
"drawerItem",
"at",
"a",
"specific",
"position"
] | train | https://github.com/mikepenz/MaterialDrawer/blob/f4fb31635767edead0a01cee7b7588942b89d8d9/library/src/main/java/com/mikepenz/materialdrawer/Drawer.java#L733-L735 |
stephenc/simple-java-mail | src/main/java/org/codemonkey/simplejavamail/Email.java | Email.addRecipient | public void addRecipient(final String name, final String address, final RecipientType type) {
"""
Adds a new {@link Recipient} to the list on account of name, address and recipient type (eg.
{@link RecipientType#CC}).
@param name The name of the recipient.
@param address The emailadres of the recipient.
@param type The type of receiver (eg. {@link RecipientType#CC}).
@see #recipients
@see Recipient
@see RecipientType
"""
recipients.add(new Recipient(name, address, type));
} | java | public void addRecipient(final String name, final String address, final RecipientType type) {
recipients.add(new Recipient(name, address, type));
} | [
"public",
"void",
"addRecipient",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"address",
",",
"final",
"RecipientType",
"type",
")",
"{",
"recipients",
".",
"add",
"(",
"new",
"Recipient",
"(",
"name",
",",
"address",
",",
"type",
")",
")",
";",
"}"
] | Adds a new {@link Recipient} to the list on account of name, address and recipient type (eg.
{@link RecipientType#CC}).
@param name The name of the recipient.
@param address The emailadres of the recipient.
@param type The type of receiver (eg. {@link RecipientType#CC}).
@see #recipients
@see Recipient
@see RecipientType | [
"Adds",
"a",
"new",
"{",
"@link",
"Recipient",
"}",
"to",
"the",
"list",
"on",
"account",
"of",
"name",
"address",
"and",
"recipient",
"type",
"(",
"eg",
".",
"{",
"@link",
"RecipientType#CC",
"}",
")",
"."
] | train | https://github.com/stephenc/simple-java-mail/blob/8c5897e6bbc23c11e7c7eb5064f407625c653923/src/main/java/org/codemonkey/simplejavamail/Email.java#L100-L102 |
oboehm/jfachwert | src/main/java/de/jfachwert/FachwertFactory.java | FachwertFactory.getFachwert | public Fachwert getFachwert(Class<? extends Fachwert> clazz, Object... args) {
"""
Liefert einen Fachwert zur angegebenen Klasse.
@param clazz Fachwert-Klasse
@param args Argument(e) fuer den Konstruktor der Fachwert-Klasse
@return ein Fachwert
"""
Class[] argTypes = toTypes(args);
try {
Constructor<? extends Fachwert> ctor = clazz.getConstructor(argTypes);
return ctor.newInstance(args);
} catch (ReflectiveOperationException ex) {
Throwable cause = ex.getCause();
if (cause instanceof ValidationException) {
throw (ValidationException) cause;
} else if (cause instanceof IllegalArgumentException) {
throw new LocalizedValidationException(cause.getMessage(), cause);
} else {
throw new IllegalArgumentException("cannot create " + clazz + " with " + Arrays.toString(args), ex);
}
}
} | java | public Fachwert getFachwert(Class<? extends Fachwert> clazz, Object... args) {
Class[] argTypes = toTypes(args);
try {
Constructor<? extends Fachwert> ctor = clazz.getConstructor(argTypes);
return ctor.newInstance(args);
} catch (ReflectiveOperationException ex) {
Throwable cause = ex.getCause();
if (cause instanceof ValidationException) {
throw (ValidationException) cause;
} else if (cause instanceof IllegalArgumentException) {
throw new LocalizedValidationException(cause.getMessage(), cause);
} else {
throw new IllegalArgumentException("cannot create " + clazz + " with " + Arrays.toString(args), ex);
}
}
} | [
"public",
"Fachwert",
"getFachwert",
"(",
"Class",
"<",
"?",
"extends",
"Fachwert",
">",
"clazz",
",",
"Object",
"...",
"args",
")",
"{",
"Class",
"[",
"]",
"argTypes",
"=",
"toTypes",
"(",
"args",
")",
";",
"try",
"{",
"Constructor",
"<",
"?",
"extends",
"Fachwert",
">",
"ctor",
"=",
"clazz",
".",
"getConstructor",
"(",
"argTypes",
")",
";",
"return",
"ctor",
".",
"newInstance",
"(",
"args",
")",
";",
"}",
"catch",
"(",
"ReflectiveOperationException",
"ex",
")",
"{",
"Throwable",
"cause",
"=",
"ex",
".",
"getCause",
"(",
")",
";",
"if",
"(",
"cause",
"instanceof",
"ValidationException",
")",
"{",
"throw",
"(",
"ValidationException",
")",
"cause",
";",
"}",
"else",
"if",
"(",
"cause",
"instanceof",
"IllegalArgumentException",
")",
"{",
"throw",
"new",
"LocalizedValidationException",
"(",
"cause",
".",
"getMessage",
"(",
")",
",",
"cause",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"cannot create \"",
"+",
"clazz",
"+",
"\" with \"",
"+",
"Arrays",
".",
"toString",
"(",
"args",
")",
",",
"ex",
")",
";",
"}",
"}",
"}"
] | Liefert einen Fachwert zur angegebenen Klasse.
@param clazz Fachwert-Klasse
@param args Argument(e) fuer den Konstruktor der Fachwert-Klasse
@return ein Fachwert | [
"Liefert",
"einen",
"Fachwert",
"zur",
"angegebenen",
"Klasse",
"."
] | train | https://github.com/oboehm/jfachwert/blob/67b513d29e3114c7aee65cd1ea7a5b7e540b0d1b/src/main/java/de/jfachwert/FachwertFactory.java#L181-L196 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jpa.container/src/com/ibm/ws/jpa/container/osgi/internal/JPAComponentImpl.java | JPAComponentImpl.getPXmlRootURL | private URL getPXmlRootURL(String appName, String archiveName, Entry pxml) {
"""
Determine the root of all persistence units defined in a persistence.xml. <p>
This is the value that should be returned by the method getPersistenceUnitRootUrl
on javax.persistence.spi.PersistenceUnitInfo. It is defined in the JPA 2.0
specification as follows: <p>
The jar file or directory whose META-INF directory contains the persistence.xml
file is termed the root of the persistence unit. <p>
@param appName name of the application that contains the persistence.xml file
@param archiveName name of the archive that contains the persistence.xml file
@param pxml reference to the persistence.xml file
"""
URL pxmlUrl = pxml.getResource();
String pxmlStr = pxmlUrl.toString();
String pxmlRootStr = pxmlStr.substring(0, pxmlStr.length() - PERSISTENCE_XML_RESOURCE_NAME.length());
URL pxmlRootUrl = null;
try {
pxmlRootUrl = new URL(pxmlRootStr);
} catch (MalformedURLException e) {
e.getClass(); // findbugs
Tr.error(tc, "INCORRECT_PU_ROOT_URL_SPEC_CWWJP0025E", pxmlRootStr, appName, archiveName);
}
return pxmlRootUrl;
} | java | private URL getPXmlRootURL(String appName, String archiveName, Entry pxml) {
URL pxmlUrl = pxml.getResource();
String pxmlStr = pxmlUrl.toString();
String pxmlRootStr = pxmlStr.substring(0, pxmlStr.length() - PERSISTENCE_XML_RESOURCE_NAME.length());
URL pxmlRootUrl = null;
try {
pxmlRootUrl = new URL(pxmlRootStr);
} catch (MalformedURLException e) {
e.getClass(); // findbugs
Tr.error(tc, "INCORRECT_PU_ROOT_URL_SPEC_CWWJP0025E", pxmlRootStr, appName, archiveName);
}
return pxmlRootUrl;
} | [
"private",
"URL",
"getPXmlRootURL",
"(",
"String",
"appName",
",",
"String",
"archiveName",
",",
"Entry",
"pxml",
")",
"{",
"URL",
"pxmlUrl",
"=",
"pxml",
".",
"getResource",
"(",
")",
";",
"String",
"pxmlStr",
"=",
"pxmlUrl",
".",
"toString",
"(",
")",
";",
"String",
"pxmlRootStr",
"=",
"pxmlStr",
".",
"substring",
"(",
"0",
",",
"pxmlStr",
".",
"length",
"(",
")",
"-",
"PERSISTENCE_XML_RESOURCE_NAME",
".",
"length",
"(",
")",
")",
";",
"URL",
"pxmlRootUrl",
"=",
"null",
";",
"try",
"{",
"pxmlRootUrl",
"=",
"new",
"URL",
"(",
"pxmlRootStr",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"e",
".",
"getClass",
"(",
")",
";",
"// findbugs",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"INCORRECT_PU_ROOT_URL_SPEC_CWWJP0025E\"",
",",
"pxmlRootStr",
",",
"appName",
",",
"archiveName",
")",
";",
"}",
"return",
"pxmlRootUrl",
";",
"}"
] | Determine the root of all persistence units defined in a persistence.xml. <p>
This is the value that should be returned by the method getPersistenceUnitRootUrl
on javax.persistence.spi.PersistenceUnitInfo. It is defined in the JPA 2.0
specification as follows: <p>
The jar file or directory whose META-INF directory contains the persistence.xml
file is termed the root of the persistence unit. <p>
@param appName name of the application that contains the persistence.xml file
@param archiveName name of the archive that contains the persistence.xml file
@param pxml reference to the persistence.xml file | [
"Determine",
"the",
"root",
"of",
"all",
"persistence",
"units",
"defined",
"in",
"a",
"persistence",
".",
"xml",
".",
"<p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jpa.container/src/com/ibm/ws/jpa/container/osgi/internal/JPAComponentImpl.java#L413-L425 |
Bedework/bw-util | bw-util-misc/src/main/java/org/bedework/util/misc/Util.java | Util.fmtMsg | public static String fmtMsg(final String fmt, final int arg) {
"""
Format a message consisting of a format string plus one integer parameter
@param fmt
@param arg
@return String formatted message
"""
Object[] o = new Object[1];
o[0] = new Integer(arg);
return MessageFormat.format(fmt, o);
} | java | public static String fmtMsg(final String fmt, final int arg) {
Object[] o = new Object[1];
o[0] = new Integer(arg);
return MessageFormat.format(fmt, o);
} | [
"public",
"static",
"String",
"fmtMsg",
"(",
"final",
"String",
"fmt",
",",
"final",
"int",
"arg",
")",
"{",
"Object",
"[",
"]",
"o",
"=",
"new",
"Object",
"[",
"1",
"]",
";",
"o",
"[",
"0",
"]",
"=",
"new",
"Integer",
"(",
"arg",
")",
";",
"return",
"MessageFormat",
".",
"format",
"(",
"fmt",
",",
"o",
")",
";",
"}"
] | Format a message consisting of a format string plus one integer parameter
@param fmt
@param arg
@return String formatted message | [
"Format",
"a",
"message",
"consisting",
"of",
"a",
"format",
"string",
"plus",
"one",
"integer",
"parameter"
] | train | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-misc/src/main/java/org/bedework/util/misc/Util.java#L436-L441 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java | TrainingsImpl.getExports | public List<Export> getExports(UUID projectId, UUID iterationId) {
"""
Get the list of exports for a specific iteration.
@param projectId The project id
@param iterationId The iteration id
@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 List<Export> object if successful.
"""
return getExportsWithServiceResponseAsync(projectId, iterationId).toBlocking().single().body();
} | java | public List<Export> getExports(UUID projectId, UUID iterationId) {
return getExportsWithServiceResponseAsync(projectId, iterationId).toBlocking().single().body();
} | [
"public",
"List",
"<",
"Export",
">",
"getExports",
"(",
"UUID",
"projectId",
",",
"UUID",
"iterationId",
")",
"{",
"return",
"getExportsWithServiceResponseAsync",
"(",
"projectId",
",",
"iterationId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Get the list of exports for a specific iteration.
@param projectId The project id
@param iterationId The iteration id
@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 List<Export> object if successful. | [
"Get",
"the",
"list",
"of",
"exports",
"for",
"a",
"specific",
"iteration",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L1129-L1131 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java | ElementsExceptionsFactory.newDataAccessException | public static DataAccessException newDataAccessException(Throwable cause, String message, Object... args) {
"""
Constructs and initializes a new {@link DataAccessException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link DataAccessException} was thrown.
@param message {@link String} describing the {@link DataAccessException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link DataAccessException} with the given {@link Throwable cause} and {@link String message}.
@see org.cp.elements.dao.DataAccessException
"""
return new DataAccessException(format(message, args), cause);
} | java | public static DataAccessException newDataAccessException(Throwable cause, String message, Object... args) {
return new DataAccessException(format(message, args), cause);
} | [
"public",
"static",
"DataAccessException",
"newDataAccessException",
"(",
"Throwable",
"cause",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"DataAccessException",
"(",
"format",
"(",
"message",
",",
"args",
")",
",",
"cause",
")",
";",
"}"
] | Constructs and initializes a new {@link DataAccessException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link DataAccessException} was thrown.
@param message {@link String} describing the {@link DataAccessException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link DataAccessException} with the given {@link Throwable cause} and {@link String message}.
@see org.cp.elements.dao.DataAccessException | [
"Constructs",
"and",
"initializes",
"a",
"new",
"{",
"@link",
"DataAccessException",
"}",
"with",
"the",
"given",
"{",
"@link",
"Throwable",
"cause",
"}",
"and",
"{",
"@link",
"String",
"message",
"}",
"formatted",
"with",
"the",
"given",
"{",
"@link",
"Object",
"[]",
"arguments",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java#L167-L169 |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java | ExpandableRecyclerAdapter.collapseParentRange | @UiThread
public void collapseParentRange(int startParentPosition, int parentCount) {
"""
Collapses all parents in a range of indices in the list of parents.
@param startParentPosition The index at which to to start collapsing parents
@param parentCount The number of parents to collapse
"""
int endParentPosition = startParentPosition + parentCount;
for (int i = startParentPosition; i < endParentPosition; i++) {
collapseParent(i);
}
} | java | @UiThread
public void collapseParentRange(int startParentPosition, int parentCount) {
int endParentPosition = startParentPosition + parentCount;
for (int i = startParentPosition; i < endParentPosition; i++) {
collapseParent(i);
}
} | [
"@",
"UiThread",
"public",
"void",
"collapseParentRange",
"(",
"int",
"startParentPosition",
",",
"int",
"parentCount",
")",
"{",
"int",
"endParentPosition",
"=",
"startParentPosition",
"+",
"parentCount",
";",
"for",
"(",
"int",
"i",
"=",
"startParentPosition",
";",
"i",
"<",
"endParentPosition",
";",
"i",
"++",
")",
"{",
"collapseParent",
"(",
"i",
")",
";",
"}",
"}"
] | Collapses all parents in a range of indices in the list of parents.
@param startParentPosition The index at which to to start collapsing parents
@param parentCount The number of parents to collapse | [
"Collapses",
"all",
"parents",
"in",
"a",
"range",
"of",
"indices",
"in",
"the",
"list",
"of",
"parents",
"."
] | train | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java#L547-L553 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachinesInner.java | VirtualMachinesInner.deallocate | public OperationStatusResponseInner deallocate(String resourceGroupName, String vmName) {
"""
Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.
@param resourceGroupName The name of the resource group.
@param vmName The name of the virtual machine.
@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 OperationStatusResponseInner object if successful.
"""
return deallocateWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().body();
} | java | public OperationStatusResponseInner deallocate(String resourceGroupName, String vmName) {
return deallocateWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().body();
} | [
"public",
"OperationStatusResponseInner",
"deallocate",
"(",
"String",
"resourceGroupName",
",",
"String",
"vmName",
")",
"{",
"return",
"deallocateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vmName",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.
@param resourceGroupName The name of the resource group.
@param vmName The name of the virtual machine.
@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 OperationStatusResponseInner object if successful. | [
"Shuts",
"down",
"the",
"virtual",
"machine",
"and",
"releases",
"the",
"compute",
"resources",
".",
"You",
"are",
"not",
"billed",
"for",
"the",
"compute",
"resources",
"that",
"this",
"virtual",
"machine",
"uses",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachinesInner.java#L1290-L1292 |
MenoData/Time4J | base/src/main/java/net/time4j/AnnualDate.java | AnnualDate.parseXML | public static AnnualDate parseXML(String xml) throws ParseException {
"""
/*[deutsch]
<p>Interpretiert den angegebenen Text als Jahrestag im XML-Format "--MM-dd". </p>
@param xml string compatible to lexical space of xsd:gMonthDay
@return AnnualDate
@throws ParseException if parsing fails
@see #toString()
"""
if ((xml.length() == 7) && (xml.charAt(0) == '-') && (xml.charAt(1) == '-') && (xml.charAt(4) == '-')) {
int m1 = toDigit(xml, 2);
int m2 = toDigit(xml, 3);
int d1 = toDigit(xml, 5);
int d2 = toDigit(xml, 6);
return new AnnualDate(m1 * 10 + m2, d1 * 10 + d2);
} else {
throw new ParseException("Not compatible to standard XML-format: " + xml, xml.length());
}
} | java | public static AnnualDate parseXML(String xml) throws ParseException {
if ((xml.length() == 7) && (xml.charAt(0) == '-') && (xml.charAt(1) == '-') && (xml.charAt(4) == '-')) {
int m1 = toDigit(xml, 2);
int m2 = toDigit(xml, 3);
int d1 = toDigit(xml, 5);
int d2 = toDigit(xml, 6);
return new AnnualDate(m1 * 10 + m2, d1 * 10 + d2);
} else {
throw new ParseException("Not compatible to standard XML-format: " + xml, xml.length());
}
} | [
"public",
"static",
"AnnualDate",
"parseXML",
"(",
"String",
"xml",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"(",
"xml",
".",
"length",
"(",
")",
"==",
"7",
")",
"&&",
"(",
"xml",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"&&",
"(",
"xml",
".",
"charAt",
"(",
"1",
")",
"==",
"'",
"'",
")",
"&&",
"(",
"xml",
".",
"charAt",
"(",
"4",
")",
"==",
"'",
"'",
")",
")",
"{",
"int",
"m1",
"=",
"toDigit",
"(",
"xml",
",",
"2",
")",
";",
"int",
"m2",
"=",
"toDigit",
"(",
"xml",
",",
"3",
")",
";",
"int",
"d1",
"=",
"toDigit",
"(",
"xml",
",",
"5",
")",
";",
"int",
"d2",
"=",
"toDigit",
"(",
"xml",
",",
"6",
")",
";",
"return",
"new",
"AnnualDate",
"(",
"m1",
"*",
"10",
"+",
"m2",
",",
"d1",
"*",
"10",
"+",
"d2",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ParseException",
"(",
"\"Not compatible to standard XML-format: \"",
"+",
"xml",
",",
"xml",
".",
"length",
"(",
")",
")",
";",
"}",
"}"
] | /*[deutsch]
<p>Interpretiert den angegebenen Text als Jahrestag im XML-Format "--MM-dd". </p>
@param xml string compatible to lexical space of xsd:gMonthDay
@return AnnualDate
@throws ParseException if parsing fails
@see #toString() | [
"/",
"*",
"[",
"deutsch",
"]",
"<p",
">",
"Interpretiert",
"den",
"angegebenen",
"Text",
"als",
"Jahrestag",
"im",
"XML",
"-",
"Format",
""",
";",
"--",
"MM",
"-",
"dd"",
";",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/AnnualDate.java#L472-L484 |
radkovo/jStyleParser | src/main/java/cz/vutbr/web/domassign/Analyzer.java | Analyzer.assingDeclarationsToDOM | protected DeclarationMap assingDeclarationsToDOM(Document doc, MediaSpec media, final boolean inherit) {
"""
Creates map of declarations assigned to each element of a DOM tree
@param doc
DOM document
@param media
Media type to be used for declarations
@param inherit
Inheritance (cascade propagation of values)
@return Map of elements as keys and their declarations
"""
// classify the rules
classifyAllSheets(media);
// resulting map
DeclarationMap declarations = new DeclarationMap();
// if the holder is empty skip evaluation
if(rules!=null && !rules.isEmpty()) {
Traversal<DeclarationMap> traversal = new Traversal<DeclarationMap>(
doc, (Object) rules, NodeFilter.SHOW_ELEMENT) {
protected void processNode(DeclarationMap result,
Node current, Object source) {
assignDeclarationsToElement(result, walker, (Element) current,
(Holder) source);
}
};
// list traversal will be enough
if (!inherit)
traversal.listTraversal(declarations);
// we will do level traversal to economize blind returning
// in tree
else
traversal.levelTraversal(declarations);
}
return declarations;
} | java | protected DeclarationMap assingDeclarationsToDOM(Document doc, MediaSpec media, final boolean inherit) {
// classify the rules
classifyAllSheets(media);
// resulting map
DeclarationMap declarations = new DeclarationMap();
// if the holder is empty skip evaluation
if(rules!=null && !rules.isEmpty()) {
Traversal<DeclarationMap> traversal = new Traversal<DeclarationMap>(
doc, (Object) rules, NodeFilter.SHOW_ELEMENT) {
protected void processNode(DeclarationMap result,
Node current, Object source) {
assignDeclarationsToElement(result, walker, (Element) current,
(Holder) source);
}
};
// list traversal will be enough
if (!inherit)
traversal.listTraversal(declarations);
// we will do level traversal to economize blind returning
// in tree
else
traversal.levelTraversal(declarations);
}
return declarations;
} | [
"protected",
"DeclarationMap",
"assingDeclarationsToDOM",
"(",
"Document",
"doc",
",",
"MediaSpec",
"media",
",",
"final",
"boolean",
"inherit",
")",
"{",
"// classify the rules",
"classifyAllSheets",
"(",
"media",
")",
";",
"// resulting map",
"DeclarationMap",
"declarations",
"=",
"new",
"DeclarationMap",
"(",
")",
";",
"// if the holder is empty skip evaluation",
"if",
"(",
"rules",
"!=",
"null",
"&&",
"!",
"rules",
".",
"isEmpty",
"(",
")",
")",
"{",
"Traversal",
"<",
"DeclarationMap",
">",
"traversal",
"=",
"new",
"Traversal",
"<",
"DeclarationMap",
">",
"(",
"doc",
",",
"(",
"Object",
")",
"rules",
",",
"NodeFilter",
".",
"SHOW_ELEMENT",
")",
"{",
"protected",
"void",
"processNode",
"(",
"DeclarationMap",
"result",
",",
"Node",
"current",
",",
"Object",
"source",
")",
"{",
"assignDeclarationsToElement",
"(",
"result",
",",
"walker",
",",
"(",
"Element",
")",
"current",
",",
"(",
"Holder",
")",
"source",
")",
";",
"}",
"}",
";",
"// list traversal will be enough",
"if",
"(",
"!",
"inherit",
")",
"traversal",
".",
"listTraversal",
"(",
"declarations",
")",
";",
"// we will do level traversal to economize blind returning",
"// in tree",
"else",
"traversal",
".",
"levelTraversal",
"(",
"declarations",
")",
";",
"}",
"return",
"declarations",
";",
"}"
] | Creates map of declarations assigned to each element of a DOM tree
@param doc
DOM document
@param media
Media type to be used for declarations
@param inherit
Inheritance (cascade propagation of values)
@return Map of elements as keys and their declarations | [
"Creates",
"map",
"of",
"declarations",
"assigned",
"to",
"each",
"element",
"of",
"a",
"DOM",
"tree"
] | train | https://github.com/radkovo/jStyleParser/blob/8ab049ac6866aa52c4d7deee25c9e294e7191957/src/main/java/cz/vutbr/web/domassign/Analyzer.java#L200-L230 |
aws/aws-sdk-java | aws-java-sdk-workdocs/src/main/java/com/amazonaws/services/workdocs/model/GetFolderResult.java | GetFolderResult.withCustomMetadata | public GetFolderResult withCustomMetadata(java.util.Map<String, String> customMetadata) {
"""
<p>
The custom metadata on the folder.
</p>
@param customMetadata
The custom metadata on the folder.
@return Returns a reference to this object so that method calls can be chained together.
"""
setCustomMetadata(customMetadata);
return this;
} | java | public GetFolderResult withCustomMetadata(java.util.Map<String, String> customMetadata) {
setCustomMetadata(customMetadata);
return this;
} | [
"public",
"GetFolderResult",
"withCustomMetadata",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"customMetadata",
")",
"{",
"setCustomMetadata",
"(",
"customMetadata",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The custom metadata on the folder.
</p>
@param customMetadata
The custom metadata on the folder.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"custom",
"metadata",
"on",
"the",
"folder",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-workdocs/src/main/java/com/amazonaws/services/workdocs/model/GetFolderResult.java#L114-L117 |
code4craft/webmagic | webmagic-core/src/main/java/us/codecraft/webmagic/utils/UrlUtils.java | UrlUtils.canonicalizeUrl | public static String canonicalizeUrl(String url, String refer) {
"""
canonicalizeUrl
<br>
Borrowed from Jsoup.
@param url url
@param refer refer
@return canonicalizeUrl
"""
URL base;
try {
try {
base = new URL(refer);
} catch (MalformedURLException e) {
// the base is unsuitable, but the attribute may be abs on its own, so try that
URL abs = new URL(refer);
return abs.toExternalForm();
}
// workaround: java resolves '//path/file + ?foo' to '//path/?foo', not '//path/file?foo' as desired
if (url.startsWith("?"))
url = base.getPath() + url;
URL abs = new URL(base, url);
return abs.toExternalForm();
} catch (MalformedURLException e) {
return "";
}
} | java | public static String canonicalizeUrl(String url, String refer) {
URL base;
try {
try {
base = new URL(refer);
} catch (MalformedURLException e) {
// the base is unsuitable, but the attribute may be abs on its own, so try that
URL abs = new URL(refer);
return abs.toExternalForm();
}
// workaround: java resolves '//path/file + ?foo' to '//path/?foo', not '//path/file?foo' as desired
if (url.startsWith("?"))
url = base.getPath() + url;
URL abs = new URL(base, url);
return abs.toExternalForm();
} catch (MalformedURLException e) {
return "";
}
} | [
"public",
"static",
"String",
"canonicalizeUrl",
"(",
"String",
"url",
",",
"String",
"refer",
")",
"{",
"URL",
"base",
";",
"try",
"{",
"try",
"{",
"base",
"=",
"new",
"URL",
"(",
"refer",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"// the base is unsuitable, but the attribute may be abs on its own, so try that",
"URL",
"abs",
"=",
"new",
"URL",
"(",
"refer",
")",
";",
"return",
"abs",
".",
"toExternalForm",
"(",
")",
";",
"}",
"// workaround: java resolves '//path/file + ?foo' to '//path/?foo', not '//path/file?foo' as desired",
"if",
"(",
"url",
".",
"startsWith",
"(",
"\"?\"",
")",
")",
"url",
"=",
"base",
".",
"getPath",
"(",
")",
"+",
"url",
";",
"URL",
"abs",
"=",
"new",
"URL",
"(",
"base",
",",
"url",
")",
";",
"return",
"abs",
".",
"toExternalForm",
"(",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"return",
"\"\"",
";",
"}",
"}"
] | canonicalizeUrl
<br>
Borrowed from Jsoup.
@param url url
@param refer refer
@return canonicalizeUrl | [
"canonicalizeUrl",
"<br",
">",
"Borrowed",
"from",
"Jsoup",
"."
] | train | https://github.com/code4craft/webmagic/blob/be892b80bf6682cd063d30ac25a79be0c079a901/webmagic-core/src/main/java/us/codecraft/webmagic/utils/UrlUtils.java#L32-L50 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java | JDBCResultSet.updateBytes | public void updateBytes(int columnIndex, byte[] x) throws SQLException {
"""
<!-- start generic documentation -->
Updates the designated column with a <code>byte</code> array value.
The updater methods are used to update column values in the
current row or the insert row. The updater methods do not
update the underlying database; instead the <code>updateRow</code> or
<code>insertRow</code> methods are called to update the database.
<!-- end generic documentation -->
<!-- start release-specific documentation -->
<div class="ReleaseSpecificDocumentation">
<h3>HSQLDB-Specific Information:</h3> <p>
HSQLDB supports this feature. <p>
</div>
<!-- end release-specific documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@param x the new column value
@exception SQLException if a database access error occurs,
the result set concurrency is <code>CONCUR_READ_ONLY</code>
or this method is called on a closed result set
@exception SQLFeatureNotSupportedException if the JDBC driver does not support
this method
@since JDK 1.2 (JDK 1.1.x developers: read the overview for
JDBCResultSet)
"""
startUpdate(columnIndex);
preparedStatement.setParameter(columnIndex, x);
} | java | public void updateBytes(int columnIndex, byte[] x) throws SQLException {
startUpdate(columnIndex);
preparedStatement.setParameter(columnIndex, x);
} | [
"public",
"void",
"updateBytes",
"(",
"int",
"columnIndex",
",",
"byte",
"[",
"]",
"x",
")",
"throws",
"SQLException",
"{",
"startUpdate",
"(",
"columnIndex",
")",
";",
"preparedStatement",
".",
"setParameter",
"(",
"columnIndex",
",",
"x",
")",
";",
"}"
] | <!-- start generic documentation -->
Updates the designated column with a <code>byte</code> array value.
The updater methods are used to update column values in the
current row or the insert row. The updater methods do not
update the underlying database; instead the <code>updateRow</code> or
<code>insertRow</code> methods are called to update the database.
<!-- end generic documentation -->
<!-- start release-specific documentation -->
<div class="ReleaseSpecificDocumentation">
<h3>HSQLDB-Specific Information:</h3> <p>
HSQLDB supports this feature. <p>
</div>
<!-- end release-specific documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@param x the new column value
@exception SQLException if a database access error occurs,
the result set concurrency is <code>CONCUR_READ_ONLY</code>
or this method is called on a closed result set
@exception SQLFeatureNotSupportedException if the JDBC driver does not support
this method
@since JDK 1.2 (JDK 1.1.x developers: read the overview for
JDBCResultSet) | [
"<!",
"--",
"start",
"generic",
"documentation",
"--",
">",
"Updates",
"the",
"designated",
"column",
"with",
"a",
"<code",
">",
"byte<",
"/",
"code",
">",
"array",
"value",
".",
"The",
"updater",
"methods",
"are",
"used",
"to",
"update",
"column",
"values",
"in",
"the",
"current",
"row",
"or",
"the",
"insert",
"row",
".",
"The",
"updater",
"methods",
"do",
"not",
"update",
"the",
"underlying",
"database",
";",
"instead",
"the",
"<code",
">",
"updateRow<",
"/",
"code",
">",
"or",
"<code",
">",
"insertRow<",
"/",
"code",
">",
"methods",
"are",
"called",
"to",
"update",
"the",
"database",
".",
"<!",
"--",
"end",
"generic",
"documentation",
"--",
">"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java#L2949-L2952 |
io7m/jaffirm | com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Preconditions.java | Preconditions.checkPreconditionD | public static double checkPreconditionD(
final double value,
final boolean condition,
final DoubleFunction<String> describer) {
"""
A {@code double} specialized version of {@link #checkPrecondition(Object,
boolean, Function)}
@param value The value
@param condition The predicate
@param describer The describer of the predicate
@return value
@throws PreconditionViolationException If the predicate is false
"""
return innerCheckD(value, condition, describer);
} | java | public static double checkPreconditionD(
final double value,
final boolean condition,
final DoubleFunction<String> describer)
{
return innerCheckD(value, condition, describer);
} | [
"public",
"static",
"double",
"checkPreconditionD",
"(",
"final",
"double",
"value",
",",
"final",
"boolean",
"condition",
",",
"final",
"DoubleFunction",
"<",
"String",
">",
"describer",
")",
"{",
"return",
"innerCheckD",
"(",
"value",
",",
"condition",
",",
"describer",
")",
";",
"}"
] | A {@code double} specialized version of {@link #checkPrecondition(Object,
boolean, Function)}
@param value The value
@param condition The predicate
@param describer The describer of the predicate
@return value
@throws PreconditionViolationException If the predicate is false | [
"A",
"{",
"@code",
"double",
"}",
"specialized",
"version",
"of",
"{",
"@link",
"#checkPrecondition",
"(",
"Object",
"boolean",
"Function",
")",
"}"
] | train | https://github.com/io7m/jaffirm/blob/c97d246242d381e48832838737418cfe4cb57b4d/com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Preconditions.java#L551-L557 |
apache/fluo | modules/core/src/main/java/org/apache/fluo/core/util/SpanUtil.java | SpanUtil.toRowColumn | public static RowColumn toRowColumn(Key key) {
"""
Converts from an Accumulo Key to a Fluo RowColumn
@param key Key
@return RowColumn
"""
if (key == null) {
return RowColumn.EMPTY;
}
if ((key.getRow() == null) || key.getRow().getLength() == 0) {
return RowColumn.EMPTY;
}
Bytes row = ByteUtil.toBytes(key.getRow());
if ((key.getColumnFamily() == null) || key.getColumnFamily().getLength() == 0) {
return new RowColumn(row);
}
Bytes cf = ByteUtil.toBytes(key.getColumnFamily());
if ((key.getColumnQualifier() == null) || key.getColumnQualifier().getLength() == 0) {
return new RowColumn(row, new Column(cf));
}
Bytes cq = ByteUtil.toBytes(key.getColumnQualifier());
if ((key.getColumnVisibility() == null) || key.getColumnVisibility().getLength() == 0) {
return new RowColumn(row, new Column(cf, cq));
}
Bytes cv = ByteUtil.toBytes(key.getColumnVisibility());
return new RowColumn(row, new Column(cf, cq, cv));
} | java | public static RowColumn toRowColumn(Key key) {
if (key == null) {
return RowColumn.EMPTY;
}
if ((key.getRow() == null) || key.getRow().getLength() == 0) {
return RowColumn.EMPTY;
}
Bytes row = ByteUtil.toBytes(key.getRow());
if ((key.getColumnFamily() == null) || key.getColumnFamily().getLength() == 0) {
return new RowColumn(row);
}
Bytes cf = ByteUtil.toBytes(key.getColumnFamily());
if ((key.getColumnQualifier() == null) || key.getColumnQualifier().getLength() == 0) {
return new RowColumn(row, new Column(cf));
}
Bytes cq = ByteUtil.toBytes(key.getColumnQualifier());
if ((key.getColumnVisibility() == null) || key.getColumnVisibility().getLength() == 0) {
return new RowColumn(row, new Column(cf, cq));
}
Bytes cv = ByteUtil.toBytes(key.getColumnVisibility());
return new RowColumn(row, new Column(cf, cq, cv));
} | [
"public",
"static",
"RowColumn",
"toRowColumn",
"(",
"Key",
"key",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"return",
"RowColumn",
".",
"EMPTY",
";",
"}",
"if",
"(",
"(",
"key",
".",
"getRow",
"(",
")",
"==",
"null",
")",
"||",
"key",
".",
"getRow",
"(",
")",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"{",
"return",
"RowColumn",
".",
"EMPTY",
";",
"}",
"Bytes",
"row",
"=",
"ByteUtil",
".",
"toBytes",
"(",
"key",
".",
"getRow",
"(",
")",
")",
";",
"if",
"(",
"(",
"key",
".",
"getColumnFamily",
"(",
")",
"==",
"null",
")",
"||",
"key",
".",
"getColumnFamily",
"(",
")",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"{",
"return",
"new",
"RowColumn",
"(",
"row",
")",
";",
"}",
"Bytes",
"cf",
"=",
"ByteUtil",
".",
"toBytes",
"(",
"key",
".",
"getColumnFamily",
"(",
")",
")",
";",
"if",
"(",
"(",
"key",
".",
"getColumnQualifier",
"(",
")",
"==",
"null",
")",
"||",
"key",
".",
"getColumnQualifier",
"(",
")",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"{",
"return",
"new",
"RowColumn",
"(",
"row",
",",
"new",
"Column",
"(",
"cf",
")",
")",
";",
"}",
"Bytes",
"cq",
"=",
"ByteUtil",
".",
"toBytes",
"(",
"key",
".",
"getColumnQualifier",
"(",
")",
")",
";",
"if",
"(",
"(",
"key",
".",
"getColumnVisibility",
"(",
")",
"==",
"null",
")",
"||",
"key",
".",
"getColumnVisibility",
"(",
")",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"{",
"return",
"new",
"RowColumn",
"(",
"row",
",",
"new",
"Column",
"(",
"cf",
",",
"cq",
")",
")",
";",
"}",
"Bytes",
"cv",
"=",
"ByteUtil",
".",
"toBytes",
"(",
"key",
".",
"getColumnVisibility",
"(",
")",
")",
";",
"return",
"new",
"RowColumn",
"(",
"row",
",",
"new",
"Column",
"(",
"cf",
",",
"cq",
",",
"cv",
")",
")",
";",
"}"
] | Converts from an Accumulo Key to a Fluo RowColumn
@param key Key
@return RowColumn | [
"Converts",
"from",
"an",
"Accumulo",
"Key",
"to",
"a",
"Fluo",
"RowColumn"
] | train | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/SpanUtil.java#L87-L108 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Uris.java | Uris.getRawFile | public static String getRawFile(final URI uri, final boolean strict) {
"""
Returns the raw (and normalized) file portion of the given URI. The file is everything in the raw path after
(but not including) the last slash. This could also be an empty string, but will not be null.
@param uri the URI to extract the file from
@param strict whether or not to do strict escaping
@return the extracted file
"""
return esc(strict).escapePath(getFile(getRawPath(uri, strict)));
} | java | public static String getRawFile(final URI uri, final boolean strict) {
return esc(strict).escapePath(getFile(getRawPath(uri, strict)));
} | [
"public",
"static",
"String",
"getRawFile",
"(",
"final",
"URI",
"uri",
",",
"final",
"boolean",
"strict",
")",
"{",
"return",
"esc",
"(",
"strict",
")",
".",
"escapePath",
"(",
"getFile",
"(",
"getRawPath",
"(",
"uri",
",",
"strict",
")",
")",
")",
";",
"}"
] | Returns the raw (and normalized) file portion of the given URI. The file is everything in the raw path after
(but not including) the last slash. This could also be an empty string, but will not be null.
@param uri the URI to extract the file from
@param strict whether or not to do strict escaping
@return the extracted file | [
"Returns",
"the",
"raw",
"(",
"and",
"normalized",
")",
"file",
"portion",
"of",
"the",
"given",
"URI",
".",
"The",
"file",
"is",
"everything",
"in",
"the",
"raw",
"path",
"after",
"(",
"but",
"not",
"including",
")",
"the",
"last",
"slash",
".",
"This",
"could",
"also",
"be",
"an",
"empty",
"string",
"but",
"will",
"not",
"be",
"null",
"."
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Uris.java#L211-L213 |
facebookarchive/hadoop-20 | src/mapred/org/apache/hadoop/mapred/TaskRunner.java | TaskRunner.getChildJavaOpts | @Deprecated
public String getChildJavaOpts(JobConf jobConf, String defaultValue) {
"""
Get the java command line options for the child map/reduce tasks.
Overriden by specific launchers.
@param jobConf job configuration
@param defaultValue default value
@return the java command line options for child map/reduce tasks
@deprecated Use command line options specific to map or reduce tasks set
via {@link JobConf#MAPRED_MAP_TASK_JAVA_OPTS} or
{@link JobConf#MAPRED_REDUCE_TASK_JAVA_OPTS}
"""
if (getTask().isJobSetupTask()) {
return jobConf.get(JobConf.MAPRED_JOB_SETUP_TASK_JAVA_OPTS,
defaultValue);
} else if (getTask().isJobCleanupTask()) {
return jobConf.get(JobConf.MAPRED_JOB_CLEANUP_TASK_JAVA_OPTS,
defaultValue);
} else if (getTask().isTaskCleanupTask()) {
return jobConf.get(JobConf.MAPRED_TASK_CLEANUP_TASK_JAVA_OPTS,
defaultValue);
} else {
return jobConf.get(JobConf.MAPRED_TASK_JAVA_OPTS, defaultValue);
}
} | java | @Deprecated
public String getChildJavaOpts(JobConf jobConf, String defaultValue) {
if (getTask().isJobSetupTask()) {
return jobConf.get(JobConf.MAPRED_JOB_SETUP_TASK_JAVA_OPTS,
defaultValue);
} else if (getTask().isJobCleanupTask()) {
return jobConf.get(JobConf.MAPRED_JOB_CLEANUP_TASK_JAVA_OPTS,
defaultValue);
} else if (getTask().isTaskCleanupTask()) {
return jobConf.get(JobConf.MAPRED_TASK_CLEANUP_TASK_JAVA_OPTS,
defaultValue);
} else {
return jobConf.get(JobConf.MAPRED_TASK_JAVA_OPTS, defaultValue);
}
} | [
"@",
"Deprecated",
"public",
"String",
"getChildJavaOpts",
"(",
"JobConf",
"jobConf",
",",
"String",
"defaultValue",
")",
"{",
"if",
"(",
"getTask",
"(",
")",
".",
"isJobSetupTask",
"(",
")",
")",
"{",
"return",
"jobConf",
".",
"get",
"(",
"JobConf",
".",
"MAPRED_JOB_SETUP_TASK_JAVA_OPTS",
",",
"defaultValue",
")",
";",
"}",
"else",
"if",
"(",
"getTask",
"(",
")",
".",
"isJobCleanupTask",
"(",
")",
")",
"{",
"return",
"jobConf",
".",
"get",
"(",
"JobConf",
".",
"MAPRED_JOB_CLEANUP_TASK_JAVA_OPTS",
",",
"defaultValue",
")",
";",
"}",
"else",
"if",
"(",
"getTask",
"(",
")",
".",
"isTaskCleanupTask",
"(",
")",
")",
"{",
"return",
"jobConf",
".",
"get",
"(",
"JobConf",
".",
"MAPRED_TASK_CLEANUP_TASK_JAVA_OPTS",
",",
"defaultValue",
")",
";",
"}",
"else",
"{",
"return",
"jobConf",
".",
"get",
"(",
"JobConf",
".",
"MAPRED_TASK_JAVA_OPTS",
",",
"defaultValue",
")",
";",
"}",
"}"
] | Get the java command line options for the child map/reduce tasks.
Overriden by specific launchers.
@param jobConf job configuration
@param defaultValue default value
@return the java command line options for child map/reduce tasks
@deprecated Use command line options specific to map or reduce tasks set
via {@link JobConf#MAPRED_MAP_TASK_JAVA_OPTS} or
{@link JobConf#MAPRED_REDUCE_TASK_JAVA_OPTS} | [
"Get",
"the",
"java",
"command",
"line",
"options",
"for",
"the",
"child",
"map",
"/",
"reduce",
"tasks",
".",
"Overriden",
"by",
"specific",
"launchers",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/mapred/org/apache/hadoop/mapred/TaskRunner.java#L135-L149 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/images/ImageUtilities.java | ImageUtilities.imageFromReader | public static BufferedImage imageFromReader( AbstractGridCoverage2DReader reader, int cols, int rows, double w, double e,
double s, double n, CoordinateReferenceSystem resampleCrs ) throws IOException {
"""
Read an image from a coverage reader.
@param reader the reader.
@param cols the expected cols.
@param rows the expected rows.
@param w west bound.
@param e east bound.
@param s south bound.
@param n north bound.
@return the image or <code>null</code> if unable to read it.
@throws IOException
"""
CoordinateReferenceSystem sourceCrs = reader.getCoordinateReferenceSystem();
GeneralParameterValue[] readParams = new GeneralParameterValue[1];
Parameter<GridGeometry2D> readGG = new Parameter<GridGeometry2D>(AbstractGridFormat.READ_GRIDGEOMETRY2D);
GridEnvelope2D gridEnvelope = new GridEnvelope2D(0, 0, cols, rows);
DirectPosition2D minDp = new DirectPosition2D(sourceCrs, w, s);
DirectPosition2D maxDp = new DirectPosition2D(sourceCrs, e, n);
Envelope env = new Envelope2D(minDp, maxDp);
readGG.setValue(new GridGeometry2D(gridEnvelope, env));
readParams[0] = readGG;
GridCoverage2D gridCoverage2D = reader.read(readParams);
if (gridCoverage2D == null) {
return null;
}
if (resampleCrs != null) {
gridCoverage2D = (GridCoverage2D) Operations.DEFAULT.resample(gridCoverage2D, resampleCrs);
}
RenderedImage image = gridCoverage2D.getRenderedImage();
if (image instanceof BufferedImage) {
BufferedImage bImage = (BufferedImage) image;
return bImage;
} else {
ColorModel cm = image.getColorModel();
int width = image.getWidth();
int height = image.getHeight();
WritableRaster raster = cm.createCompatibleWritableRaster(width, height);
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
Hashtable properties = new Hashtable();
String[] keys = image.getPropertyNames();
if (keys != null) {
for( int i = 0; i < keys.length; i++ ) {
properties.put(keys[i], image.getProperty(keys[i]));
}
}
BufferedImage result = new BufferedImage(cm, raster, isAlphaPremultiplied, properties);
image.copyData(raster);
return result;
}
} | java | public static BufferedImage imageFromReader( AbstractGridCoverage2DReader reader, int cols, int rows, double w, double e,
double s, double n, CoordinateReferenceSystem resampleCrs ) throws IOException {
CoordinateReferenceSystem sourceCrs = reader.getCoordinateReferenceSystem();
GeneralParameterValue[] readParams = new GeneralParameterValue[1];
Parameter<GridGeometry2D> readGG = new Parameter<GridGeometry2D>(AbstractGridFormat.READ_GRIDGEOMETRY2D);
GridEnvelope2D gridEnvelope = new GridEnvelope2D(0, 0, cols, rows);
DirectPosition2D minDp = new DirectPosition2D(sourceCrs, w, s);
DirectPosition2D maxDp = new DirectPosition2D(sourceCrs, e, n);
Envelope env = new Envelope2D(minDp, maxDp);
readGG.setValue(new GridGeometry2D(gridEnvelope, env));
readParams[0] = readGG;
GridCoverage2D gridCoverage2D = reader.read(readParams);
if (gridCoverage2D == null) {
return null;
}
if (resampleCrs != null) {
gridCoverage2D = (GridCoverage2D) Operations.DEFAULT.resample(gridCoverage2D, resampleCrs);
}
RenderedImage image = gridCoverage2D.getRenderedImage();
if (image instanceof BufferedImage) {
BufferedImage bImage = (BufferedImage) image;
return bImage;
} else {
ColorModel cm = image.getColorModel();
int width = image.getWidth();
int height = image.getHeight();
WritableRaster raster = cm.createCompatibleWritableRaster(width, height);
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
Hashtable properties = new Hashtable();
String[] keys = image.getPropertyNames();
if (keys != null) {
for( int i = 0; i < keys.length; i++ ) {
properties.put(keys[i], image.getProperty(keys[i]));
}
}
BufferedImage result = new BufferedImage(cm, raster, isAlphaPremultiplied, properties);
image.copyData(raster);
return result;
}
} | [
"public",
"static",
"BufferedImage",
"imageFromReader",
"(",
"AbstractGridCoverage2DReader",
"reader",
",",
"int",
"cols",
",",
"int",
"rows",
",",
"double",
"w",
",",
"double",
"e",
",",
"double",
"s",
",",
"double",
"n",
",",
"CoordinateReferenceSystem",
"resampleCrs",
")",
"throws",
"IOException",
"{",
"CoordinateReferenceSystem",
"sourceCrs",
"=",
"reader",
".",
"getCoordinateReferenceSystem",
"(",
")",
";",
"GeneralParameterValue",
"[",
"]",
"readParams",
"=",
"new",
"GeneralParameterValue",
"[",
"1",
"]",
";",
"Parameter",
"<",
"GridGeometry2D",
">",
"readGG",
"=",
"new",
"Parameter",
"<",
"GridGeometry2D",
">",
"(",
"AbstractGridFormat",
".",
"READ_GRIDGEOMETRY2D",
")",
";",
"GridEnvelope2D",
"gridEnvelope",
"=",
"new",
"GridEnvelope2D",
"(",
"0",
",",
"0",
",",
"cols",
",",
"rows",
")",
";",
"DirectPosition2D",
"minDp",
"=",
"new",
"DirectPosition2D",
"(",
"sourceCrs",
",",
"w",
",",
"s",
")",
";",
"DirectPosition2D",
"maxDp",
"=",
"new",
"DirectPosition2D",
"(",
"sourceCrs",
",",
"e",
",",
"n",
")",
";",
"Envelope",
"env",
"=",
"new",
"Envelope2D",
"(",
"minDp",
",",
"maxDp",
")",
";",
"readGG",
".",
"setValue",
"(",
"new",
"GridGeometry2D",
"(",
"gridEnvelope",
",",
"env",
")",
")",
";",
"readParams",
"[",
"0",
"]",
"=",
"readGG",
";",
"GridCoverage2D",
"gridCoverage2D",
"=",
"reader",
".",
"read",
"(",
"readParams",
")",
";",
"if",
"(",
"gridCoverage2D",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"resampleCrs",
"!=",
"null",
")",
"{",
"gridCoverage2D",
"=",
"(",
"GridCoverage2D",
")",
"Operations",
".",
"DEFAULT",
".",
"resample",
"(",
"gridCoverage2D",
",",
"resampleCrs",
")",
";",
"}",
"RenderedImage",
"image",
"=",
"gridCoverage2D",
".",
"getRenderedImage",
"(",
")",
";",
"if",
"(",
"image",
"instanceof",
"BufferedImage",
")",
"{",
"BufferedImage",
"bImage",
"=",
"(",
"BufferedImage",
")",
"image",
";",
"return",
"bImage",
";",
"}",
"else",
"{",
"ColorModel",
"cm",
"=",
"image",
".",
"getColorModel",
"(",
")",
";",
"int",
"width",
"=",
"image",
".",
"getWidth",
"(",
")",
";",
"int",
"height",
"=",
"image",
".",
"getHeight",
"(",
")",
";",
"WritableRaster",
"raster",
"=",
"cm",
".",
"createCompatibleWritableRaster",
"(",
"width",
",",
"height",
")",
";",
"boolean",
"isAlphaPremultiplied",
"=",
"cm",
".",
"isAlphaPremultiplied",
"(",
")",
";",
"Hashtable",
"properties",
"=",
"new",
"Hashtable",
"(",
")",
";",
"String",
"[",
"]",
"keys",
"=",
"image",
".",
"getPropertyNames",
"(",
")",
";",
"if",
"(",
"keys",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"properties",
".",
"put",
"(",
"keys",
"[",
"i",
"]",
",",
"image",
".",
"getProperty",
"(",
"keys",
"[",
"i",
"]",
")",
")",
";",
"}",
"}",
"BufferedImage",
"result",
"=",
"new",
"BufferedImage",
"(",
"cm",
",",
"raster",
",",
"isAlphaPremultiplied",
",",
"properties",
")",
";",
"image",
".",
"copyData",
"(",
"raster",
")",
";",
"return",
"result",
";",
"}",
"}"
] | Read an image from a coverage reader.
@param reader the reader.
@param cols the expected cols.
@param rows the expected rows.
@param w west bound.
@param e east bound.
@param s south bound.
@param n north bound.
@return the image or <code>null</code> if unable to read it.
@throws IOException | [
"Read",
"an",
"image",
"from",
"a",
"coverage",
"reader",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/images/ImageUtilities.java#L126-L166 |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/SpriteManager.java | SpriteManager.getHitSprites | public void getHitSprites (List<Sprite> list, int x, int y) {
"""
When an animated view is determining what entity in its view is under the mouse pointer, it
may require a list of sprites that are "hit" by a particular pixel. The sprites' bounds are
first checked and sprites with bounds that contain the supplied point are further checked
for a non-transparent at the specified location.
@param list the list to fill with any intersecting sprites, the sprites with the highest
render order provided first.
@param x the x (screen) coordinate to be checked.
@param y the y (screen) coordinate to be checked.
"""
for (int ii = _sprites.size() - 1; ii >= 0; ii--) {
Sprite sprite = _sprites.get(ii);
if (sprite.hitTest(x, y)) {
list.add(sprite);
}
}
} | java | public void getHitSprites (List<Sprite> list, int x, int y)
{
for (int ii = _sprites.size() - 1; ii >= 0; ii--) {
Sprite sprite = _sprites.get(ii);
if (sprite.hitTest(x, y)) {
list.add(sprite);
}
}
} | [
"public",
"void",
"getHitSprites",
"(",
"List",
"<",
"Sprite",
">",
"list",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"for",
"(",
"int",
"ii",
"=",
"_sprites",
".",
"size",
"(",
")",
"-",
"1",
";",
"ii",
">=",
"0",
";",
"ii",
"--",
")",
"{",
"Sprite",
"sprite",
"=",
"_sprites",
".",
"get",
"(",
"ii",
")",
";",
"if",
"(",
"sprite",
".",
"hitTest",
"(",
"x",
",",
"y",
")",
")",
"{",
"list",
".",
"add",
"(",
"sprite",
")",
";",
"}",
"}",
"}"
] | When an animated view is determining what entity in its view is under the mouse pointer, it
may require a list of sprites that are "hit" by a particular pixel. The sprites' bounds are
first checked and sprites with bounds that contain the supplied point are further checked
for a non-transparent at the specified location.
@param list the list to fill with any intersecting sprites, the sprites with the highest
render order provided first.
@param x the x (screen) coordinate to be checked.
@param y the y (screen) coordinate to be checked. | [
"When",
"an",
"animated",
"view",
"is",
"determining",
"what",
"entity",
"in",
"its",
"view",
"is",
"under",
"the",
"mouse",
"pointer",
"it",
"may",
"require",
"a",
"list",
"of",
"sprites",
"that",
"are",
"hit",
"by",
"a",
"particular",
"pixel",
".",
"The",
"sprites",
"bounds",
"are",
"first",
"checked",
"and",
"sprites",
"with",
"bounds",
"that",
"contain",
"the",
"supplied",
"point",
"are",
"further",
"checked",
"for",
"a",
"non",
"-",
"transparent",
"at",
"the",
"specified",
"location",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/SpriteManager.java#L72-L80 |
apache/flink | flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/HadoopInputs.java | HadoopInputs.readHadoopFile | public static <K, V> HadoopInputFormat<K, V> readHadoopFile(org.apache.hadoop.mapred.FileInputFormat<K, V> mapredInputFormat, Class<K> key, Class<V> value, String inputPath, JobConf job) {
"""
Creates a Flink {@link InputFormat} that wraps the given Hadoop {@link org.apache.hadoop.mapred.FileInputFormat}.
@return A Flink InputFormat that wraps the Hadoop FileInputFormat.
"""
// set input path in JobConf
org.apache.hadoop.mapred.FileInputFormat.addInputPath(job, new org.apache.hadoop.fs.Path(inputPath));
// return wrapping InputFormat
return createHadoopInput(mapredInputFormat, key, value, job);
} | java | public static <K, V> HadoopInputFormat<K, V> readHadoopFile(org.apache.hadoop.mapred.FileInputFormat<K, V> mapredInputFormat, Class<K> key, Class<V> value, String inputPath, JobConf job) {
// set input path in JobConf
org.apache.hadoop.mapred.FileInputFormat.addInputPath(job, new org.apache.hadoop.fs.Path(inputPath));
// return wrapping InputFormat
return createHadoopInput(mapredInputFormat, key, value, job);
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"HadoopInputFormat",
"<",
"K",
",",
"V",
">",
"readHadoopFile",
"(",
"org",
".",
"apache",
".",
"hadoop",
".",
"mapred",
".",
"FileInputFormat",
"<",
"K",
",",
"V",
">",
"mapredInputFormat",
",",
"Class",
"<",
"K",
">",
"key",
",",
"Class",
"<",
"V",
">",
"value",
",",
"String",
"inputPath",
",",
"JobConf",
"job",
")",
"{",
"// set input path in JobConf",
"org",
".",
"apache",
".",
"hadoop",
".",
"mapred",
".",
"FileInputFormat",
".",
"addInputPath",
"(",
"job",
",",
"new",
"org",
".",
"apache",
".",
"hadoop",
".",
"fs",
".",
"Path",
"(",
"inputPath",
")",
")",
";",
"// return wrapping InputFormat",
"return",
"createHadoopInput",
"(",
"mapredInputFormat",
",",
"key",
",",
"value",
",",
"job",
")",
";",
"}"
] | Creates a Flink {@link InputFormat} that wraps the given Hadoop {@link org.apache.hadoop.mapred.FileInputFormat}.
@return A Flink InputFormat that wraps the Hadoop FileInputFormat. | [
"Creates",
"a",
"Flink",
"{",
"@link",
"InputFormat",
"}",
"that",
"wraps",
"the",
"given",
"Hadoop",
"{",
"@link",
"org",
".",
"apache",
".",
"hadoop",
".",
"mapred",
".",
"FileInputFormat",
"}",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/HadoopInputs.java#L50-L55 |
aws/aws-sdk-java | aws-java-sdk-core/src/main/java/com/amazonaws/monitoring/internal/AsynchronousAgentDispatcher.java | AsynchronousAgentDispatcher.addWriteTask | public void addWriteTask(MonitoringEvent event, DatagramChannel channel, int maxSize) {
"""
Add a task to asynchronously write {@code event} to the {@code channel}
if its serialized form does not exceed {@code maxSize}.
@param event The event to write.
@param channel The channel to write to.
@param maxSize The maximum allowed size for the serialized {@code event}.
@throws IllegalStateException If this dispatcher has not yet been
initialized via {@link #init()}.
"""
if (!initialized) {
throw new IllegalStateException("Dispatcher is not initialized!");
}
tasks.add(new WriteTask(event, channel, maxSize));
} | java | public void addWriteTask(MonitoringEvent event, DatagramChannel channel, int maxSize) {
if (!initialized) {
throw new IllegalStateException("Dispatcher is not initialized!");
}
tasks.add(new WriteTask(event, channel, maxSize));
} | [
"public",
"void",
"addWriteTask",
"(",
"MonitoringEvent",
"event",
",",
"DatagramChannel",
"channel",
",",
"int",
"maxSize",
")",
"{",
"if",
"(",
"!",
"initialized",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Dispatcher is not initialized!\"",
")",
";",
"}",
"tasks",
".",
"add",
"(",
"new",
"WriteTask",
"(",
"event",
",",
"channel",
",",
"maxSize",
")",
")",
";",
"}"
] | Add a task to asynchronously write {@code event} to the {@code channel}
if its serialized form does not exceed {@code maxSize}.
@param event The event to write.
@param channel The channel to write to.
@param maxSize The maximum allowed size for the serialized {@code event}.
@throws IllegalStateException If this dispatcher has not yet been
initialized via {@link #init()}. | [
"Add",
"a",
"task",
"to",
"asynchronously",
"write",
"{",
"@code",
"event",
"}",
"to",
"the",
"{",
"@code",
"channel",
"}",
"if",
"its",
"serialized",
"form",
"does",
"not",
"exceed",
"{",
"@code",
"maxSize",
"}",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-core/src/main/java/com/amazonaws/monitoring/internal/AsynchronousAgentDispatcher.java#L79-L84 |
ThreeTen/threetenbp | src/main/java/org/threeten/bp/LocalDateTime.java | LocalDateTime.ofEpochSecond | public static LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset) {
"""
Obtains an instance of {@code LocalDateTime} using seconds from the
epoch of 1970-01-01T00:00:00Z.
<p>
This allows the {@link ChronoField#INSTANT_SECONDS epoch-second} field
to be converted to a local date-time. This is primarily intended for
low-level conversions rather than general application usage.
@param epochSecond the number of seconds from the epoch of 1970-01-01T00:00:00Z
@param nanoOfSecond the nanosecond within the second, from 0 to 999,999,999
@param offset the zone offset, not null
@return the local date-time, not null
@throws DateTimeException if the result exceeds the supported range
"""
Jdk8Methods.requireNonNull(offset, "offset");
long localSecond = epochSecond + offset.getTotalSeconds(); // overflow caught later
long localEpochDay = Jdk8Methods.floorDiv(localSecond, SECONDS_PER_DAY);
int secsOfDay = Jdk8Methods.floorMod(localSecond, SECONDS_PER_DAY);
LocalDate date = LocalDate.ofEpochDay(localEpochDay);
LocalTime time = LocalTime.ofSecondOfDay(secsOfDay, nanoOfSecond);
return new LocalDateTime(date, time);
} | java | public static LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset) {
Jdk8Methods.requireNonNull(offset, "offset");
long localSecond = epochSecond + offset.getTotalSeconds(); // overflow caught later
long localEpochDay = Jdk8Methods.floorDiv(localSecond, SECONDS_PER_DAY);
int secsOfDay = Jdk8Methods.floorMod(localSecond, SECONDS_PER_DAY);
LocalDate date = LocalDate.ofEpochDay(localEpochDay);
LocalTime time = LocalTime.ofSecondOfDay(secsOfDay, nanoOfSecond);
return new LocalDateTime(date, time);
} | [
"public",
"static",
"LocalDateTime",
"ofEpochSecond",
"(",
"long",
"epochSecond",
",",
"int",
"nanoOfSecond",
",",
"ZoneOffset",
"offset",
")",
"{",
"Jdk8Methods",
".",
"requireNonNull",
"(",
"offset",
",",
"\"offset\"",
")",
";",
"long",
"localSecond",
"=",
"epochSecond",
"+",
"offset",
".",
"getTotalSeconds",
"(",
")",
";",
"// overflow caught later",
"long",
"localEpochDay",
"=",
"Jdk8Methods",
".",
"floorDiv",
"(",
"localSecond",
",",
"SECONDS_PER_DAY",
")",
";",
"int",
"secsOfDay",
"=",
"Jdk8Methods",
".",
"floorMod",
"(",
"localSecond",
",",
"SECONDS_PER_DAY",
")",
";",
"LocalDate",
"date",
"=",
"LocalDate",
".",
"ofEpochDay",
"(",
"localEpochDay",
")",
";",
"LocalTime",
"time",
"=",
"LocalTime",
".",
"ofSecondOfDay",
"(",
"secsOfDay",
",",
"nanoOfSecond",
")",
";",
"return",
"new",
"LocalDateTime",
"(",
"date",
",",
"time",
")",
";",
"}"
] | Obtains an instance of {@code LocalDateTime} using seconds from the
epoch of 1970-01-01T00:00:00Z.
<p>
This allows the {@link ChronoField#INSTANT_SECONDS epoch-second} field
to be converted to a local date-time. This is primarily intended for
low-level conversions rather than general application usage.
@param epochSecond the number of seconds from the epoch of 1970-01-01T00:00:00Z
@param nanoOfSecond the nanosecond within the second, from 0 to 999,999,999
@param offset the zone offset, not null
@return the local date-time, not null
@throws DateTimeException if the result exceeds the supported range | [
"Obtains",
"an",
"instance",
"of",
"{",
"@code",
"LocalDateTime",
"}",
"using",
"seconds",
"from",
"the",
"epoch",
"of",
"1970",
"-",
"01",
"-",
"01T00",
":",
"00",
":",
"00Z",
".",
"<p",
">",
"This",
"allows",
"the",
"{",
"@link",
"ChronoField#INSTANT_SECONDS",
"epoch",
"-",
"second",
"}",
"field",
"to",
"be",
"converted",
"to",
"a",
"local",
"date",
"-",
"time",
".",
"This",
"is",
"primarily",
"intended",
"for",
"low",
"-",
"level",
"conversions",
"rather",
"than",
"general",
"application",
"usage",
"."
] | train | https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/LocalDateTime.java#L375-L383 |
igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java | AgentSession.getAgentRoster | public AgentRoster getAgentRoster() throws NotConnectedException, InterruptedException {
"""
Returns the agent roster for the workgroup, which contains.
@return the AgentRoster
@throws NotConnectedException
@throws InterruptedException
"""
if (agentRoster == null) {
agentRoster = new AgentRoster(connection, workgroupJID);
}
// This might be the first time the user has asked for the roster. If so, we
// want to wait up to 2 seconds for the server to send back the list of agents.
// This behavior shields API users from having to worry about the fact that the
// operation is asynchronous, although they'll still have to listen for changes
// to the roster.
int elapsed = 0;
while (!agentRoster.rosterInitialized && elapsed <= 2000) {
try {
Thread.sleep(500);
}
catch (Exception e) {
// Ignore
}
elapsed += 500;
}
return agentRoster;
} | java | public AgentRoster getAgentRoster() throws NotConnectedException, InterruptedException {
if (agentRoster == null) {
agentRoster = new AgentRoster(connection, workgroupJID);
}
// This might be the first time the user has asked for the roster. If so, we
// want to wait up to 2 seconds for the server to send back the list of agents.
// This behavior shields API users from having to worry about the fact that the
// operation is asynchronous, although they'll still have to listen for changes
// to the roster.
int elapsed = 0;
while (!agentRoster.rosterInitialized && elapsed <= 2000) {
try {
Thread.sleep(500);
}
catch (Exception e) {
// Ignore
}
elapsed += 500;
}
return agentRoster;
} | [
"public",
"AgentRoster",
"getAgentRoster",
"(",
")",
"throws",
"NotConnectedException",
",",
"InterruptedException",
"{",
"if",
"(",
"agentRoster",
"==",
"null",
")",
"{",
"agentRoster",
"=",
"new",
"AgentRoster",
"(",
"connection",
",",
"workgroupJID",
")",
";",
"}",
"// This might be the first time the user has asked for the roster. If so, we",
"// want to wait up to 2 seconds for the server to send back the list of agents.",
"// This behavior shields API users from having to worry about the fact that the",
"// operation is asynchronous, although they'll still have to listen for changes",
"// to the roster.",
"int",
"elapsed",
"=",
"0",
";",
"while",
"(",
"!",
"agentRoster",
".",
"rosterInitialized",
"&&",
"elapsed",
"<=",
"2000",
")",
"{",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Ignore",
"}",
"elapsed",
"+=",
"500",
";",
"}",
"return",
"agentRoster",
";",
"}"
] | Returns the agent roster for the workgroup, which contains.
@return the AgentRoster
@throws NotConnectedException
@throws InterruptedException | [
"Returns",
"the",
"agent",
"roster",
"for",
"the",
"workgroup",
"which",
"contains",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L215-L236 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/renderer/icon/provider/SidesIconProvider.java | SidesIconProvider.getIcon | @Override
public Icon getIcon(IBlockAccess world, BlockPos pos, IBlockState state, EnumFacing side) {
"""
Gets the {@link Icon} for the side for the block in world.<br>
Takes in account the facing of the block.<br>
If no icon was set for the side, {@link #defaultIcon} is used.
@param world the world
@param pos the pos
@param state the state
@param side the side
@return the icon
"""
return getIcon(side);
} | java | @Override
public Icon getIcon(IBlockAccess world, BlockPos pos, IBlockState state, EnumFacing side)
{
return getIcon(side);
} | [
"@",
"Override",
"public",
"Icon",
"getIcon",
"(",
"IBlockAccess",
"world",
",",
"BlockPos",
"pos",
",",
"IBlockState",
"state",
",",
"EnumFacing",
"side",
")",
"{",
"return",
"getIcon",
"(",
"side",
")",
";",
"}"
] | Gets the {@link Icon} for the side for the block in world.<br>
Takes in account the facing of the block.<br>
If no icon was set for the side, {@link #defaultIcon} is used.
@param world the world
@param pos the pos
@param state the state
@param side the side
@return the icon | [
"Gets",
"the",
"{",
"@link",
"Icon",
"}",
"for",
"the",
"side",
"for",
"the",
"block",
"in",
"world",
".",
"<br",
">",
"Takes",
"in",
"account",
"the",
"facing",
"of",
"the",
"block",
".",
"<br",
">",
"If",
"no",
"icon",
"was",
"set",
"for",
"the",
"side",
"{",
"@link",
"#defaultIcon",
"}",
"is",
"used",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/icon/provider/SidesIconProvider.java#L166-L170 |
protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/IntSerializer.java | IntSerializer.writeInt16LE | public static void writeInt16LE(final int value, final byte[] buffer, int offset) {
"""
Writes the 16-bit int into the buffer starting with the least significant byte.
"""
buffer[offset++] = (byte) value;
buffer[offset] = (byte) ((value >>> 8) & 0xFF);
} | java | public static void writeInt16LE(final int value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) value;
buffer[offset] = (byte) ((value >>> 8) & 0xFF);
} | [
"public",
"static",
"void",
"writeInt16LE",
"(",
"final",
"int",
"value",
",",
"final",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
")",
"{",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"value",
";",
"buffer",
"[",
"offset",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"8",
")",
"&",
"0xFF",
")",
";",
"}"
] | Writes the 16-bit int into the buffer starting with the least significant byte. | [
"Writes",
"the",
"16",
"-",
"bit",
"int",
"into",
"the",
"buffer",
"starting",
"with",
"the",
"least",
"significant",
"byte",
"."
] | train | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/IntSerializer.java#L44-L48 |
jbundle/jbundle | thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/BaseApplet.java | BaseApplet.pushHistory | public void pushHistory(String strHistory, boolean bPushToBrowser) {
"""
Push this command onto the history stack.
@param strHistory The history command to push onto the stack.
"""
if (m_vHistory == null)
m_vHistory = new Vector<String>();
String strHelpURL = ThinUtil.fixDisplayURL(strHistory, true, true, true, this);
if (bPushToBrowser)
if ((strHistory != null) && (strHistory.length() > 0))
if (strHistory.indexOf(Params.APPLET + '=') == -1)
strHistory = UrlUtil.addURLParam(strHistory, Params.APPLET, this.getClass().getName()); // Adding &applet says this is a screen on not back/etc
m_vHistory.addElement(strHistory);
this.getApplication().showTheDocument(strHelpURL, this, ThinMenuConstants.HELP_WINDOW_CHANGE);
this.pushBrowserHistory(strHistory, this.getStatusText(Constants.INFORMATION), bPushToBrowser); // Let browser know about the new screen
} | java | public void pushHistory(String strHistory, boolean bPushToBrowser)
{
if (m_vHistory == null)
m_vHistory = new Vector<String>();
String strHelpURL = ThinUtil.fixDisplayURL(strHistory, true, true, true, this);
if (bPushToBrowser)
if ((strHistory != null) && (strHistory.length() > 0))
if (strHistory.indexOf(Params.APPLET + '=') == -1)
strHistory = UrlUtil.addURLParam(strHistory, Params.APPLET, this.getClass().getName()); // Adding &applet says this is a screen on not back/etc
m_vHistory.addElement(strHistory);
this.getApplication().showTheDocument(strHelpURL, this, ThinMenuConstants.HELP_WINDOW_CHANGE);
this.pushBrowserHistory(strHistory, this.getStatusText(Constants.INFORMATION), bPushToBrowser); // Let browser know about the new screen
} | [
"public",
"void",
"pushHistory",
"(",
"String",
"strHistory",
",",
"boolean",
"bPushToBrowser",
")",
"{",
"if",
"(",
"m_vHistory",
"==",
"null",
")",
"m_vHistory",
"=",
"new",
"Vector",
"<",
"String",
">",
"(",
")",
";",
"String",
"strHelpURL",
"=",
"ThinUtil",
".",
"fixDisplayURL",
"(",
"strHistory",
",",
"true",
",",
"true",
",",
"true",
",",
"this",
")",
";",
"if",
"(",
"bPushToBrowser",
")",
"if",
"(",
"(",
"strHistory",
"!=",
"null",
")",
"&&",
"(",
"strHistory",
".",
"length",
"(",
")",
">",
"0",
")",
")",
"if",
"(",
"strHistory",
".",
"indexOf",
"(",
"Params",
".",
"APPLET",
"+",
"'",
"'",
")",
"==",
"-",
"1",
")",
"strHistory",
"=",
"UrlUtil",
".",
"addURLParam",
"(",
"strHistory",
",",
"Params",
".",
"APPLET",
",",
"this",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"// Adding &applet says this is a screen on not back/etc",
"m_vHistory",
".",
"addElement",
"(",
"strHistory",
")",
";",
"this",
".",
"getApplication",
"(",
")",
".",
"showTheDocument",
"(",
"strHelpURL",
",",
"this",
",",
"ThinMenuConstants",
".",
"HELP_WINDOW_CHANGE",
")",
";",
"this",
".",
"pushBrowserHistory",
"(",
"strHistory",
",",
"this",
".",
"getStatusText",
"(",
"Constants",
".",
"INFORMATION",
")",
",",
"bPushToBrowser",
")",
";",
"// Let browser know about the new screen",
"}"
] | Push this command onto the history stack.
@param strHistory The history command to push onto the stack. | [
"Push",
"this",
"command",
"onto",
"the",
"history",
"stack",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/BaseApplet.java#L1232-L1244 |
netceteragroup/valdr-bean-validation | valdr-bean-validation/src/main/java/com/github/valdr/thirdparty/spring/AnnotationUtils.java | AnnotationUtils.findAnnotation | public static <A extends Annotation> A findAnnotation(Method method, Class<A> annotationType) {
"""
Get a single {@link java.lang.annotation.Annotation} of {@code annotationType} from the supplied {@link java.lang.reflect.Method},
traversing its super methods if no annotation can be found on the given method itself.
<p>Annotations on methods are not inherited by default, so we need to handle this explicitly.
@param method the method to look for annotations on
@param annotationType the annotation class to look for
@param <A> annotation type
@return the annotation found, or {@code null} if none found
"""
A annotation = getAnnotation(method, annotationType);
Class<?> clazz = method.getDeclaringClass();
if (annotation == null) {
annotation = searchOnInterfaces(method, annotationType, clazz.getInterfaces());
}
while (annotation == null) {
clazz = clazz.getSuperclass();
if (clazz == null || clazz.equals(Object.class)) {
break;
}
try {
Method equivalentMethod = clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());
annotation = getAnnotation(equivalentMethod, annotationType);
}
catch (NoSuchMethodException ex) {
// No equivalent method found
}
if (annotation == null) {
annotation = searchOnInterfaces(method, annotationType, clazz.getInterfaces());
}
}
return annotation;
} | java | public static <A extends Annotation> A findAnnotation(Method method, Class<A> annotationType) {
A annotation = getAnnotation(method, annotationType);
Class<?> clazz = method.getDeclaringClass();
if (annotation == null) {
annotation = searchOnInterfaces(method, annotationType, clazz.getInterfaces());
}
while (annotation == null) {
clazz = clazz.getSuperclass();
if (clazz == null || clazz.equals(Object.class)) {
break;
}
try {
Method equivalentMethod = clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());
annotation = getAnnotation(equivalentMethod, annotationType);
}
catch (NoSuchMethodException ex) {
// No equivalent method found
}
if (annotation == null) {
annotation = searchOnInterfaces(method, annotationType, clazz.getInterfaces());
}
}
return annotation;
} | [
"public",
"static",
"<",
"A",
"extends",
"Annotation",
">",
"A",
"findAnnotation",
"(",
"Method",
"method",
",",
"Class",
"<",
"A",
">",
"annotationType",
")",
"{",
"A",
"annotation",
"=",
"getAnnotation",
"(",
"method",
",",
"annotationType",
")",
";",
"Class",
"<",
"?",
">",
"clazz",
"=",
"method",
".",
"getDeclaringClass",
"(",
")",
";",
"if",
"(",
"annotation",
"==",
"null",
")",
"{",
"annotation",
"=",
"searchOnInterfaces",
"(",
"method",
",",
"annotationType",
",",
"clazz",
".",
"getInterfaces",
"(",
")",
")",
";",
"}",
"while",
"(",
"annotation",
"==",
"null",
")",
"{",
"clazz",
"=",
"clazz",
".",
"getSuperclass",
"(",
")",
";",
"if",
"(",
"clazz",
"==",
"null",
"||",
"clazz",
".",
"equals",
"(",
"Object",
".",
"class",
")",
")",
"{",
"break",
";",
"}",
"try",
"{",
"Method",
"equivalentMethod",
"=",
"clazz",
".",
"getDeclaredMethod",
"(",
"method",
".",
"getName",
"(",
")",
",",
"method",
".",
"getParameterTypes",
"(",
")",
")",
";",
"annotation",
"=",
"getAnnotation",
"(",
"equivalentMethod",
",",
"annotationType",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"ex",
")",
"{",
"// No equivalent method found",
"}",
"if",
"(",
"annotation",
"==",
"null",
")",
"{",
"annotation",
"=",
"searchOnInterfaces",
"(",
"method",
",",
"annotationType",
",",
"clazz",
".",
"getInterfaces",
"(",
")",
")",
";",
"}",
"}",
"return",
"annotation",
";",
"}"
] | Get a single {@link java.lang.annotation.Annotation} of {@code annotationType} from the supplied {@link java.lang.reflect.Method},
traversing its super methods if no annotation can be found on the given method itself.
<p>Annotations on methods are not inherited by default, so we need to handle this explicitly.
@param method the method to look for annotations on
@param annotationType the annotation class to look for
@param <A> annotation type
@return the annotation found, or {@code null} if none found | [
"Get",
"a",
"single",
"{"
] | train | https://github.com/netceteragroup/valdr-bean-validation/blob/3f49f1357c575a11331be2de867cf47809a83823/valdr-bean-validation/src/main/java/com/github/valdr/thirdparty/spring/AnnotationUtils.java#L91-L114 |
HeidelTime/heideltime | src/de/unihd/dbs/uima/annotator/heideltime/processors/HolidayProcessor.java | HolidayProcessor.getWeekdayOfMonth | public String getWeekdayOfMonth(int number, int weekday, int month, int year) {
"""
Get the date of a the first, second, third etc. weekday in a month
@author Hans-Peter Pfeiffer
@param number
@param weekday
@param month
@param year
@return date
"""
return getWeekdayRelativeTo(String.format("%04d-%02d-01", year, month), weekday, number, true);
} | java | public String getWeekdayOfMonth(int number, int weekday, int month, int year) {
return getWeekdayRelativeTo(String.format("%04d-%02d-01", year, month), weekday, number, true);
} | [
"public",
"String",
"getWeekdayOfMonth",
"(",
"int",
"number",
",",
"int",
"weekday",
",",
"int",
"month",
",",
"int",
"year",
")",
"{",
"return",
"getWeekdayRelativeTo",
"(",
"String",
".",
"format",
"(",
"\"%04d-%02d-01\"",
",",
"year",
",",
"month",
")",
",",
"weekday",
",",
"number",
",",
"true",
")",
";",
"}"
] | Get the date of a the first, second, third etc. weekday in a month
@author Hans-Peter Pfeiffer
@param number
@param weekday
@param month
@param year
@return date | [
"Get",
"the",
"date",
"of",
"a",
"the",
"first",
"second",
"third",
"etc",
".",
"weekday",
"in",
"a",
"month"
] | train | https://github.com/HeidelTime/heideltime/blob/4ef5002eb5ecfeb818086ff7e394e792ee360335/src/de/unihd/dbs/uima/annotator/heideltime/processors/HolidayProcessor.java#L401-L403 |
NoraUi/NoraUi | src/main/java/com/github/noraui/application/steps/CommonSteps.java | CommonSteps.selectCheckbox | @Lorsque("Je mets à jour la case à cocher '(.*)-(.*)' avec '(.*)' à partir de ces valeurs:")
@Then("I update checkbox '(.*)-(.*)' with '(.*)' from these values:")
public void selectCheckbox(String page, String elementKey, String value, Map<String, Boolean> values) throws TechnicalException, FailureException {
"""
Updates the value of a html checkbox element with conditions regarding the provided keys/values map.
@param page
The concerned page of elementKey
@param elementKey
The key of PageElement to select
@param value
A key to map with 'values' to find the final right checkbox value
@param values
A list of keys/values to map a scenario input value with a checkbox value
@throws TechnicalException
if the scenario encounters a technical error
@throws FailureException
if the scenario encounters a functional error
"""
selectCheckbox(Page.getInstance(page).getPageElementByKey('-' + elementKey), value, values);
} | java | @Lorsque("Je mets à jour la case à cocher '(.*)-(.*)' avec '(.*)' à partir de ces valeurs:")
@Then("I update checkbox '(.*)-(.*)' with '(.*)' from these values:")
public void selectCheckbox(String page, String elementKey, String value, Map<String, Boolean> values) throws TechnicalException, FailureException {
selectCheckbox(Page.getInstance(page).getPageElementByKey('-' + elementKey), value, values);
} | [
"@",
"Lorsque",
"(",
"\"Je mets à jour la case à cocher '(.*)-(.*)' avec '(.*)' à partir de ces valeurs:\")\r",
"",
"@",
"Then",
"(",
"\"I update checkbox '(.*)-(.*)' with '(.*)' from these values:\"",
")",
"public",
"void",
"selectCheckbox",
"(",
"String",
"page",
",",
"String",
"elementKey",
",",
"String",
"value",
",",
"Map",
"<",
"String",
",",
"Boolean",
">",
"values",
")",
"throws",
"TechnicalException",
",",
"FailureException",
"{",
"selectCheckbox",
"(",
"Page",
".",
"getInstance",
"(",
"page",
")",
".",
"getPageElementByKey",
"(",
"'",
"'",
"+",
"elementKey",
")",
",",
"value",
",",
"values",
")",
";",
"}"
] | Updates the value of a html checkbox element with conditions regarding the provided keys/values map.
@param page
The concerned page of elementKey
@param elementKey
The key of PageElement to select
@param value
A key to map with 'values' to find the final right checkbox value
@param values
A list of keys/values to map a scenario input value with a checkbox value
@throws TechnicalException
if the scenario encounters a technical error
@throws FailureException
if the scenario encounters a functional error | [
"Updates",
"the",
"value",
"of",
"a",
"html",
"checkbox",
"element",
"with",
"conditions",
"regarding",
"the",
"provided",
"keys",
"/",
"values",
"map",
"."
] | train | https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/application/steps/CommonSteps.java#L912-L916 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/Barcode.java | Barcode.createImageWithBarcode | public Image createImageWithBarcode(PdfContentByte cb, Color barColor, Color textColor) {
"""
Creates an <CODE>Image</CODE> with the barcode.
@param cb the <CODE>PdfContentByte</CODE> to create the <CODE>Image</CODE>. It
serves no other use
@param barColor the color of the bars. It can be <CODE>null</CODE>
@param textColor the color of the text. It can be <CODE>null</CODE>
@return the <CODE>Image</CODE>
@see #placeBarcode(PdfContentByte cb, Color barColor, Color textColor)
"""
try {
return Image.getInstance(createTemplateWithBarcode(cb, barColor, textColor));
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
} | java | public Image createImageWithBarcode(PdfContentByte cb, Color barColor, Color textColor) {
try {
return Image.getInstance(createTemplateWithBarcode(cb, barColor, textColor));
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
} | [
"public",
"Image",
"createImageWithBarcode",
"(",
"PdfContentByte",
"cb",
",",
"Color",
"barColor",
",",
"Color",
"textColor",
")",
"{",
"try",
"{",
"return",
"Image",
".",
"getInstance",
"(",
"createTemplateWithBarcode",
"(",
"cb",
",",
"barColor",
",",
"textColor",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ExceptionConverter",
"(",
"e",
")",
";",
"}",
"}"
] | Creates an <CODE>Image</CODE> with the barcode.
@param cb the <CODE>PdfContentByte</CODE> to create the <CODE>Image</CODE>. It
serves no other use
@param barColor the color of the bars. It can be <CODE>null</CODE>
@param textColor the color of the text. It can be <CODE>null</CODE>
@return the <CODE>Image</CODE>
@see #placeBarcode(PdfContentByte cb, Color barColor, Color textColor) | [
"Creates",
"an",
"<CODE",
">",
"Image<",
"/",
"CODE",
">",
"with",
"the",
"barcode",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/Barcode.java#L422-L429 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ULocale.java | ULocale.getDisplayLanguageWithDialect | public static String getDisplayLanguageWithDialect(String localeID, String displayLocaleID) {
"""
<strong>[icu]</strong> Returns a locale's language localized for display in the provided locale.
If a dialect name is present in the data, then it is returned.
This is a cover for the ICU4C API.
@param localeID the id of the locale whose language will be displayed
@param displayLocaleID the id of the locale in which to display the name.
@return the localized language name.
"""
return getDisplayLanguageInternal(new ULocale(localeID), new ULocale(displayLocaleID),
true);
} | java | public static String getDisplayLanguageWithDialect(String localeID, String displayLocaleID) {
return getDisplayLanguageInternal(new ULocale(localeID), new ULocale(displayLocaleID),
true);
} | [
"public",
"static",
"String",
"getDisplayLanguageWithDialect",
"(",
"String",
"localeID",
",",
"String",
"displayLocaleID",
")",
"{",
"return",
"getDisplayLanguageInternal",
"(",
"new",
"ULocale",
"(",
"localeID",
")",
",",
"new",
"ULocale",
"(",
"displayLocaleID",
")",
",",
"true",
")",
";",
"}"
] | <strong>[icu]</strong> Returns a locale's language localized for display in the provided locale.
If a dialect name is present in the data, then it is returned.
This is a cover for the ICU4C API.
@param localeID the id of the locale whose language will be displayed
@param displayLocaleID the id of the locale in which to display the name.
@return the localized language name. | [
"<strong",
">",
"[",
"icu",
"]",
"<",
"/",
"strong",
">",
"Returns",
"a",
"locale",
"s",
"language",
"localized",
"for",
"display",
"in",
"the",
"provided",
"locale",
".",
"If",
"a",
"dialect",
"name",
"is",
"present",
"in",
"the",
"data",
"then",
"it",
"is",
"returned",
".",
"This",
"is",
"a",
"cover",
"for",
"the",
"ICU4C",
"API",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ULocale.java#L1436-L1439 |
netty/netty | codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyMessage.java | HAProxyMessage.checkAddress | private static void checkAddress(String address, AddressFamily addrFamily) {
"""
Validate an address (IPv4, IPv6, Unix Socket)
@param address human-readable address
@param addrFamily the {@link AddressFamily} to check the address against
@throws HAProxyProtocolException if the address is invalid
"""
if (addrFamily == null) {
throw new NullPointerException("addrFamily");
}
switch (addrFamily) {
case AF_UNSPEC:
if (address != null) {
throw new HAProxyProtocolException("unable to validate an AF_UNSPEC address: " + address);
}
return;
case AF_UNIX:
return;
}
if (address == null) {
throw new NullPointerException("address");
}
switch (addrFamily) {
case AF_IPv4:
if (!NetUtil.isValidIpV4Address(address)) {
throw new HAProxyProtocolException("invalid IPv4 address: " + address);
}
break;
case AF_IPv6:
if (!NetUtil.isValidIpV6Address(address)) {
throw new HAProxyProtocolException("invalid IPv6 address: " + address);
}
break;
default:
throw new Error();
}
} | java | private static void checkAddress(String address, AddressFamily addrFamily) {
if (addrFamily == null) {
throw new NullPointerException("addrFamily");
}
switch (addrFamily) {
case AF_UNSPEC:
if (address != null) {
throw new HAProxyProtocolException("unable to validate an AF_UNSPEC address: " + address);
}
return;
case AF_UNIX:
return;
}
if (address == null) {
throw new NullPointerException("address");
}
switch (addrFamily) {
case AF_IPv4:
if (!NetUtil.isValidIpV4Address(address)) {
throw new HAProxyProtocolException("invalid IPv4 address: " + address);
}
break;
case AF_IPv6:
if (!NetUtil.isValidIpV6Address(address)) {
throw new HAProxyProtocolException("invalid IPv6 address: " + address);
}
break;
default:
throw new Error();
}
} | [
"private",
"static",
"void",
"checkAddress",
"(",
"String",
"address",
",",
"AddressFamily",
"addrFamily",
")",
"{",
"if",
"(",
"addrFamily",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"addrFamily\"",
")",
";",
"}",
"switch",
"(",
"addrFamily",
")",
"{",
"case",
"AF_UNSPEC",
":",
"if",
"(",
"address",
"!=",
"null",
")",
"{",
"throw",
"new",
"HAProxyProtocolException",
"(",
"\"unable to validate an AF_UNSPEC address: \"",
"+",
"address",
")",
";",
"}",
"return",
";",
"case",
"AF_UNIX",
":",
"return",
";",
"}",
"if",
"(",
"address",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"address\"",
")",
";",
"}",
"switch",
"(",
"addrFamily",
")",
"{",
"case",
"AF_IPv4",
":",
"if",
"(",
"!",
"NetUtil",
".",
"isValidIpV4Address",
"(",
"address",
")",
")",
"{",
"throw",
"new",
"HAProxyProtocolException",
"(",
"\"invalid IPv4 address: \"",
"+",
"address",
")",
";",
"}",
"break",
";",
"case",
"AF_IPv6",
":",
"if",
"(",
"!",
"NetUtil",
".",
"isValidIpV6Address",
"(",
"address",
")",
")",
"{",
"throw",
"new",
"HAProxyProtocolException",
"(",
"\"invalid IPv6 address: \"",
"+",
"address",
")",
";",
"}",
"break",
";",
"default",
":",
"throw",
"new",
"Error",
"(",
")",
";",
"}",
"}"
] | Validate an address (IPv4, IPv6, Unix Socket)
@param address human-readable address
@param addrFamily the {@link AddressFamily} to check the address against
@throws HAProxyProtocolException if the address is invalid | [
"Validate",
"an",
"address",
"(",
"IPv4",
"IPv6",
"Unix",
"Socket",
")"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyMessage.java#L418-L451 |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/CommonOps_ZDRM.java | CommonOps_ZDRM.multAdd | public static void multAdd(double realAlpha , double imgAlpha , ZMatrixRMaj a , ZMatrixRMaj b , ZMatrixRMaj c ) {
"""
<p>
Performs the following operation:<br>
<br>
c = c + α * a * b<br>
c<sub>ij</sub> = c<sub>ij</sub> + α * ∑<sub>k=1:n</sub> { a<sub>ik</sub> * b<sub>kj</sub>}
</p>
@param realAlpha real component of scaling factor.
@param imgAlpha imaginary component of scaling factor.
@param a The left matrix in the multiplication operation. Not modified.
@param b The right matrix in the multiplication operation. Not modified.
@param c Where the results of the operation are stored. Modified.
"""
if( b.numCols >= EjmlParameters.CMULT_COLUMN_SWITCH ) {
MatrixMatrixMult_ZDRM.multAdd_reorder(realAlpha,imgAlpha,a,b,c);
} else {
MatrixMatrixMult_ZDRM.multAdd_small(realAlpha,imgAlpha,a,b,c);
}
} | java | public static void multAdd(double realAlpha , double imgAlpha , ZMatrixRMaj a , ZMatrixRMaj b , ZMatrixRMaj c )
{
if( b.numCols >= EjmlParameters.CMULT_COLUMN_SWITCH ) {
MatrixMatrixMult_ZDRM.multAdd_reorder(realAlpha,imgAlpha,a,b,c);
} else {
MatrixMatrixMult_ZDRM.multAdd_small(realAlpha,imgAlpha,a,b,c);
}
} | [
"public",
"static",
"void",
"multAdd",
"(",
"double",
"realAlpha",
",",
"double",
"imgAlpha",
",",
"ZMatrixRMaj",
"a",
",",
"ZMatrixRMaj",
"b",
",",
"ZMatrixRMaj",
"c",
")",
"{",
"if",
"(",
"b",
".",
"numCols",
">=",
"EjmlParameters",
".",
"CMULT_COLUMN_SWITCH",
")",
"{",
"MatrixMatrixMult_ZDRM",
".",
"multAdd_reorder",
"(",
"realAlpha",
",",
"imgAlpha",
",",
"a",
",",
"b",
",",
"c",
")",
";",
"}",
"else",
"{",
"MatrixMatrixMult_ZDRM",
".",
"multAdd_small",
"(",
"realAlpha",
",",
"imgAlpha",
",",
"a",
",",
"b",
",",
"c",
")",
";",
"}",
"}"
] | <p>
Performs the following operation:<br>
<br>
c = c + α * a * b<br>
c<sub>ij</sub> = c<sub>ij</sub> + α * ∑<sub>k=1:n</sub> { a<sub>ik</sub> * b<sub>kj</sub>}
</p>
@param realAlpha real component of scaling factor.
@param imgAlpha imaginary component of scaling factor.
@param a The left matrix in the multiplication operation. Not modified.
@param b The right matrix in the multiplication operation. Not modified.
@param c Where the results of the operation are stored. Modified. | [
"<p",
">",
"Performs",
"the",
"following",
"operation",
":",
"<br",
">",
"<br",
">",
"c",
"=",
"c",
"+",
"&alpha",
";",
"*",
"a",
"*",
"b<br",
">",
"c<sub",
">",
"ij<",
"/",
"sub",
">",
"=",
"c<sub",
">",
"ij<",
"/",
"sub",
">",
"+",
"&alpha",
";",
"*",
"&sum",
";",
"<sub",
">",
"k",
"=",
"1",
":",
"n<",
"/",
"sub",
">",
"{",
"a<sub",
">",
"ik<",
"/",
"sub",
">",
"*",
"b<sub",
">",
"kj<",
"/",
"sub",
">",
"}",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/CommonOps_ZDRM.java#L433-L440 |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java | EsStorage.indexEntity | @SuppressWarnings("nls")
private void indexEntity(String type, String id, XContentBuilder sourceEntity, boolean refresh)
throws StorageException {
"""
Indexes an entity.
@param type
@param id
@param sourceEntity
@param refresh true if the operation should wait for a refresh before it returns
@throws StorageException
"""
try {
String json = sourceEntity.string();
JestResult response = esClient.execute(new Index.Builder(json).refresh(refresh).index(getIndexName())
.setParameter(Parameters.OP_TYPE, "create").type(type).id(id).build());
if (!response.isSucceeded()) {
throw new StorageException("Failed to index document " + id + " of type " + type + ": " + response.getErrorMessage());
}
} catch (StorageException e) {
throw e;
} catch (Exception e) {
throw new StorageException(e);
}
} | java | @SuppressWarnings("nls")
private void indexEntity(String type, String id, XContentBuilder sourceEntity, boolean refresh)
throws StorageException {
try {
String json = sourceEntity.string();
JestResult response = esClient.execute(new Index.Builder(json).refresh(refresh).index(getIndexName())
.setParameter(Parameters.OP_TYPE, "create").type(type).id(id).build());
if (!response.isSucceeded()) {
throw new StorageException("Failed to index document " + id + " of type " + type + ": " + response.getErrorMessage());
}
} catch (StorageException e) {
throw e;
} catch (Exception e) {
throw new StorageException(e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"nls\"",
")",
"private",
"void",
"indexEntity",
"(",
"String",
"type",
",",
"String",
"id",
",",
"XContentBuilder",
"sourceEntity",
",",
"boolean",
"refresh",
")",
"throws",
"StorageException",
"{",
"try",
"{",
"String",
"json",
"=",
"sourceEntity",
".",
"string",
"(",
")",
";",
"JestResult",
"response",
"=",
"esClient",
".",
"execute",
"(",
"new",
"Index",
".",
"Builder",
"(",
"json",
")",
".",
"refresh",
"(",
"refresh",
")",
".",
"index",
"(",
"getIndexName",
"(",
")",
")",
".",
"setParameter",
"(",
"Parameters",
".",
"OP_TYPE",
",",
"\"create\"",
")",
".",
"type",
"(",
"type",
")",
".",
"id",
"(",
"id",
")",
".",
"build",
"(",
")",
")",
";",
"if",
"(",
"!",
"response",
".",
"isSucceeded",
"(",
")",
")",
"{",
"throw",
"new",
"StorageException",
"(",
"\"Failed to index document \"",
"+",
"id",
"+",
"\" of type \"",
"+",
"type",
"+",
"\": \"",
"+",
"response",
".",
"getErrorMessage",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"StorageException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"StorageException",
"(",
"e",
")",
";",
"}",
"}"
] | Indexes an entity.
@param type
@param id
@param sourceEntity
@param refresh true if the operation should wait for a refresh before it returns
@throws StorageException | [
"Indexes",
"an",
"entity",
"."
] | train | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java#L2000-L2015 |
TestFX/Monocle | src/main/java/com/sun/glass/ui/monocle/X11WarpingCursor.java | X11WarpingCursor.setLocation | @Override
void setLocation(int x, int y) {
"""
Update the next coordinates for the cursor. The actual move will occur
on the next buffer swap
@param x the new X location on the screen
@param y the new Y location on the screen
"""
if (x != nextX || y != nextY) {
nextX = x;
nextY = y;
MonocleWindowManager.getInstance().repaintAll();
}
} | java | @Override
void setLocation(int x, int y) {
if (x != nextX || y != nextY) {
nextX = x;
nextY = y;
MonocleWindowManager.getInstance().repaintAll();
}
} | [
"@",
"Override",
"void",
"setLocation",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"if",
"(",
"x",
"!=",
"nextX",
"||",
"y",
"!=",
"nextY",
")",
"{",
"nextX",
"=",
"x",
";",
"nextY",
"=",
"y",
";",
"MonocleWindowManager",
".",
"getInstance",
"(",
")",
".",
"repaintAll",
"(",
")",
";",
"}",
"}"
] | Update the next coordinates for the cursor. The actual move will occur
on the next buffer swap
@param x the new X location on the screen
@param y the new Y location on the screen | [
"Update",
"the",
"next",
"coordinates",
"for",
"the",
"cursor",
".",
"The",
"actual",
"move",
"will",
"occur",
"on",
"the",
"next",
"buffer",
"swap"
] | train | https://github.com/TestFX/Monocle/blob/267ccba8889cab244bf8c562dbaa0345a612874c/src/main/java/com/sun/glass/ui/monocle/X11WarpingCursor.java#L41-L48 |
wcm-io/wcm-io-tooling | commons/crx-packmgr-helper/src/main/java/io/wcm/tooling/commons/packmgr/PackageManagerHttpActionException.java | PackageManagerHttpActionException.forIOException | public static PackageManagerHttpActionException forIOException(String url, IOException ex) {
"""
Create exception instance for I/O exception.
@param url HTTP url called
@param ex I/O exception
@return Exception instance
"""
String message = "HTTP call to " + url + " failed: "
+ StringUtils.defaultString(ex.getMessage(), ex.getClass().getSimpleName());
if (ex instanceof SocketTimeoutException) {
message += " (consider to increase the socket timeout using -Dvault.httpSocketTimeoutSec)";
}
return new PackageManagerHttpActionException(message, ex);
} | java | public static PackageManagerHttpActionException forIOException(String url, IOException ex) {
String message = "HTTP call to " + url + " failed: "
+ StringUtils.defaultString(ex.getMessage(), ex.getClass().getSimpleName());
if (ex instanceof SocketTimeoutException) {
message += " (consider to increase the socket timeout using -Dvault.httpSocketTimeoutSec)";
}
return new PackageManagerHttpActionException(message, ex);
} | [
"public",
"static",
"PackageManagerHttpActionException",
"forIOException",
"(",
"String",
"url",
",",
"IOException",
"ex",
")",
"{",
"String",
"message",
"=",
"\"HTTP call to \"",
"+",
"url",
"+",
"\" failed: \"",
"+",
"StringUtils",
".",
"defaultString",
"(",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"if",
"(",
"ex",
"instanceof",
"SocketTimeoutException",
")",
"{",
"message",
"+=",
"\" (consider to increase the socket timeout using -Dvault.httpSocketTimeoutSec)\"",
";",
"}",
"return",
"new",
"PackageManagerHttpActionException",
"(",
"message",
",",
"ex",
")",
";",
"}"
] | Create exception instance for I/O exception.
@param url HTTP url called
@param ex I/O exception
@return Exception instance | [
"Create",
"exception",
"instance",
"for",
"I",
"/",
"O",
"exception",
"."
] | train | https://github.com/wcm-io/wcm-io-tooling/blob/1abcd01dd3ad4cc248f03b431f929573d84fa9b4/commons/crx-packmgr-helper/src/main/java/io/wcm/tooling/commons/packmgr/PackageManagerHttpActionException.java#L55-L62 |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CreateSyntheticOverheadView.java | CreateSyntheticOverheadView.configure | public void configure( CameraPinholeBrown intrinsic ,
Se3_F64 planeToCamera ,
double centerX, double centerY, double cellSize ,
int overheadWidth , int overheadHeight ) {
"""
Specifies camera configurations.
@param intrinsic Intrinsic camera parameters
@param planeToCamera Transform from the plane to the camera. This is the extrinsic parameters.
@param centerX X-coordinate of camera center in the overhead image in world units.
@param centerY Y-coordinate of camera center in the overhead image in world units.
@param cellSize Size of each cell in the overhead image in world units.
@param overheadWidth Number of columns in overhead image
@param overheadHeight Number of rows in overhead image
"""
this.overheadWidth = overheadWidth;
this.overheadHeight = overheadHeight;
Point2Transform2_F64 normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false, true);
// Declare storage for precomputed pixel locations
int overheadPixels = overheadHeight*overheadWidth;
if( mapPixels == null || mapPixels.length < overheadPixels) {
mapPixels = new Point2D_F32[overheadPixels];
}
points.reset();
// -------- storage for intermediate results
Point2D_F64 pixel = new Point2D_F64();
// coordinate on the plane
Point3D_F64 pt_plane = new Point3D_F64();
// coordinate in camera reference frame
Point3D_F64 pt_cam = new Point3D_F64();
int indexOut = 0;
for( int i = 0; i < overheadHeight; i++ ) {
pt_plane.x = -(i*cellSize - centerY);
for( int j = 0; j < overheadWidth; j++ , indexOut++ ) {
pt_plane.z = j*cellSize - centerX;
// plane to camera reference frame
SePointOps_F64.transform(planeToCamera, pt_plane, pt_cam);
// can't see behind the camera
if( pt_cam.z > 0 ) {
// compute normalized then convert to pixels
normToPixel.compute(pt_cam.x/pt_cam.z,pt_cam.y/pt_cam.z,pixel);
float x = (float)pixel.x;
float y = (float)pixel.y;
// make sure it's in the image
if(BoofMiscOps.checkInside(intrinsic.width,intrinsic.height,x,y) ){
Point2D_F32 p = points.grow();
p.set(x,y);
mapPixels[ indexOut ]= p;
} else {
mapPixels[ indexOut ]= null;
}
}
}
}
} | java | public void configure( CameraPinholeBrown intrinsic ,
Se3_F64 planeToCamera ,
double centerX, double centerY, double cellSize ,
int overheadWidth , int overheadHeight )
{
this.overheadWidth = overheadWidth;
this.overheadHeight = overheadHeight;
Point2Transform2_F64 normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false, true);
// Declare storage for precomputed pixel locations
int overheadPixels = overheadHeight*overheadWidth;
if( mapPixels == null || mapPixels.length < overheadPixels) {
mapPixels = new Point2D_F32[overheadPixels];
}
points.reset();
// -------- storage for intermediate results
Point2D_F64 pixel = new Point2D_F64();
// coordinate on the plane
Point3D_F64 pt_plane = new Point3D_F64();
// coordinate in camera reference frame
Point3D_F64 pt_cam = new Point3D_F64();
int indexOut = 0;
for( int i = 0; i < overheadHeight; i++ ) {
pt_plane.x = -(i*cellSize - centerY);
for( int j = 0; j < overheadWidth; j++ , indexOut++ ) {
pt_plane.z = j*cellSize - centerX;
// plane to camera reference frame
SePointOps_F64.transform(planeToCamera, pt_plane, pt_cam);
// can't see behind the camera
if( pt_cam.z > 0 ) {
// compute normalized then convert to pixels
normToPixel.compute(pt_cam.x/pt_cam.z,pt_cam.y/pt_cam.z,pixel);
float x = (float)pixel.x;
float y = (float)pixel.y;
// make sure it's in the image
if(BoofMiscOps.checkInside(intrinsic.width,intrinsic.height,x,y) ){
Point2D_F32 p = points.grow();
p.set(x,y);
mapPixels[ indexOut ]= p;
} else {
mapPixels[ indexOut ]= null;
}
}
}
}
} | [
"public",
"void",
"configure",
"(",
"CameraPinholeBrown",
"intrinsic",
",",
"Se3_F64",
"planeToCamera",
",",
"double",
"centerX",
",",
"double",
"centerY",
",",
"double",
"cellSize",
",",
"int",
"overheadWidth",
",",
"int",
"overheadHeight",
")",
"{",
"this",
".",
"overheadWidth",
"=",
"overheadWidth",
";",
"this",
".",
"overheadHeight",
"=",
"overheadHeight",
";",
"Point2Transform2_F64",
"normToPixel",
"=",
"LensDistortionFactory",
".",
"narrow",
"(",
"intrinsic",
")",
".",
"distort_F64",
"(",
"false",
",",
"true",
")",
";",
"// Declare storage for precomputed pixel locations",
"int",
"overheadPixels",
"=",
"overheadHeight",
"*",
"overheadWidth",
";",
"if",
"(",
"mapPixels",
"==",
"null",
"||",
"mapPixels",
".",
"length",
"<",
"overheadPixels",
")",
"{",
"mapPixels",
"=",
"new",
"Point2D_F32",
"[",
"overheadPixels",
"]",
";",
"}",
"points",
".",
"reset",
"(",
")",
";",
"// -------- storage for intermediate results",
"Point2D_F64",
"pixel",
"=",
"new",
"Point2D_F64",
"(",
")",
";",
"// coordinate on the plane",
"Point3D_F64",
"pt_plane",
"=",
"new",
"Point3D_F64",
"(",
")",
";",
"// coordinate in camera reference frame",
"Point3D_F64",
"pt_cam",
"=",
"new",
"Point3D_F64",
"(",
")",
";",
"int",
"indexOut",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"overheadHeight",
";",
"i",
"++",
")",
"{",
"pt_plane",
".",
"x",
"=",
"-",
"(",
"i",
"*",
"cellSize",
"-",
"centerY",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"overheadWidth",
";",
"j",
"++",
",",
"indexOut",
"++",
")",
"{",
"pt_plane",
".",
"z",
"=",
"j",
"*",
"cellSize",
"-",
"centerX",
";",
"// plane to camera reference frame",
"SePointOps_F64",
".",
"transform",
"(",
"planeToCamera",
",",
"pt_plane",
",",
"pt_cam",
")",
";",
"// can't see behind the camera",
"if",
"(",
"pt_cam",
".",
"z",
">",
"0",
")",
"{",
"// compute normalized then convert to pixels",
"normToPixel",
".",
"compute",
"(",
"pt_cam",
".",
"x",
"/",
"pt_cam",
".",
"z",
",",
"pt_cam",
".",
"y",
"/",
"pt_cam",
".",
"z",
",",
"pixel",
")",
";",
"float",
"x",
"=",
"(",
"float",
")",
"pixel",
".",
"x",
";",
"float",
"y",
"=",
"(",
"float",
")",
"pixel",
".",
"y",
";",
"// make sure it's in the image",
"if",
"(",
"BoofMiscOps",
".",
"checkInside",
"(",
"intrinsic",
".",
"width",
",",
"intrinsic",
".",
"height",
",",
"x",
",",
"y",
")",
")",
"{",
"Point2D_F32",
"p",
"=",
"points",
".",
"grow",
"(",
")",
";",
"p",
".",
"set",
"(",
"x",
",",
"y",
")",
";",
"mapPixels",
"[",
"indexOut",
"]",
"=",
"p",
";",
"}",
"else",
"{",
"mapPixels",
"[",
"indexOut",
"]",
"=",
"null",
";",
"}",
"}",
"}",
"}",
"}"
] | Specifies camera configurations.
@param intrinsic Intrinsic camera parameters
@param planeToCamera Transform from the plane to the camera. This is the extrinsic parameters.
@param centerX X-coordinate of camera center in the overhead image in world units.
@param centerY Y-coordinate of camera center in the overhead image in world units.
@param cellSize Size of each cell in the overhead image in world units.
@param overheadWidth Number of columns in overhead image
@param overheadHeight Number of rows in overhead image | [
"Specifies",
"camera",
"configurations",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CreateSyntheticOverheadView.java#L81-L133 |
deeplearning4j/deeplearning4j | nd4j/nd4j-common/src/main/java/org/nd4j/tools/PropertyParser.java | PropertyParser.toBoolean | public boolean toBoolean(String name, boolean defaultValue) {
"""
Get property. The method returns the default value if the property is not parsed.
@param name property name
@param defaultValue default value
@return property
"""
String property = getProperties().getProperty(name);
return property != null ? Boolean.parseBoolean(property) : defaultValue;
} | java | public boolean toBoolean(String name, boolean defaultValue) {
String property = getProperties().getProperty(name);
return property != null ? Boolean.parseBoolean(property) : defaultValue;
} | [
"public",
"boolean",
"toBoolean",
"(",
"String",
"name",
",",
"boolean",
"defaultValue",
")",
"{",
"String",
"property",
"=",
"getProperties",
"(",
")",
".",
"getProperty",
"(",
"name",
")",
";",
"return",
"property",
"!=",
"null",
"?",
"Boolean",
".",
"parseBoolean",
"(",
"property",
")",
":",
"defaultValue",
";",
"}"
] | Get property. The method returns the default value if the property is not parsed.
@param name property name
@param defaultValue default value
@return property | [
"Get",
"property",
".",
"The",
"method",
"returns",
"the",
"default",
"value",
"if",
"the",
"property",
"is",
"not",
"parsed",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-common/src/main/java/org/nd4j/tools/PropertyParser.java#L228-L231 |
alkacon/opencms-core | src/org/opencms/db/CmsSubscriptionManager.java | CmsSubscriptionManager.unsubscribeAllResourcesFor | public void unsubscribeAllResourcesFor(CmsObject cms, CmsPrincipal principal) throws CmsException {
"""
Unsubscribes the user or group from all resources.<p>
@param cms the current users context
@param principal the principal that unsubscribes from all resources
@throws CmsException if something goes wrong
"""
if (!isEnabled()) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_SUBSCRIPTION_MANAGER_DISABLED_0));
}
m_securityManager.unsubscribeAllResourcesFor(cms.getRequestContext(), getPoolName(), principal);
} | java | public void unsubscribeAllResourcesFor(CmsObject cms, CmsPrincipal principal) throws CmsException {
if (!isEnabled()) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_SUBSCRIPTION_MANAGER_DISABLED_0));
}
m_securityManager.unsubscribeAllResourcesFor(cms.getRequestContext(), getPoolName(), principal);
} | [
"public",
"void",
"unsubscribeAllResourcesFor",
"(",
"CmsObject",
"cms",
",",
"CmsPrincipal",
"principal",
")",
"throws",
"CmsException",
"{",
"if",
"(",
"!",
"isEnabled",
"(",
")",
")",
"{",
"throw",
"new",
"CmsRuntimeException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_SUBSCRIPTION_MANAGER_DISABLED_0",
")",
")",
";",
"}",
"m_securityManager",
".",
"unsubscribeAllResourcesFor",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
",",
"getPoolName",
"(",
")",
",",
"principal",
")",
";",
"}"
] | Unsubscribes the user or group from all resources.<p>
@param cms the current users context
@param principal the principal that unsubscribes from all resources
@throws CmsException if something goes wrong | [
"Unsubscribes",
"the",
"user",
"or",
"group",
"from",
"all",
"resources",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsSubscriptionManager.java#L426-L432 |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java | GaliosFieldTableOps.polyEvalContinue | public int polyEvalContinue( int previousOutput, GrowQueue_I8 part , int x ) {
"""
Continue evaluating a polynomial which has been broken up into multiple arrays.
@param previousOutput Output from the evaluation of the prior part of the polynomial
@param part Additional segment of the polynomial
@param x Point it's being evaluated at
@return results
"""
int y = previousOutput;
for (int i = 0; i < part.size; i++) {
y = multiply(y,x) ^ (part.data[i]&0xFF);
}
return y;
} | java | public int polyEvalContinue( int previousOutput, GrowQueue_I8 part , int x ) {
int y = previousOutput;
for (int i = 0; i < part.size; i++) {
y = multiply(y,x) ^ (part.data[i]&0xFF);
}
return y;
} | [
"public",
"int",
"polyEvalContinue",
"(",
"int",
"previousOutput",
",",
"GrowQueue_I8",
"part",
",",
"int",
"x",
")",
"{",
"int",
"y",
"=",
"previousOutput",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"part",
".",
"size",
";",
"i",
"++",
")",
"{",
"y",
"=",
"multiply",
"(",
"y",
",",
"x",
")",
"^",
"(",
"part",
".",
"data",
"[",
"i",
"]",
"&",
"0xFF",
")",
";",
"}",
"return",
"y",
";",
"}"
] | Continue evaluating a polynomial which has been broken up into multiple arrays.
@param previousOutput Output from the evaluation of the prior part of the polynomial
@param part Additional segment of the polynomial
@param x Point it's being evaluated at
@return results | [
"Continue",
"evaluating",
"a",
"polynomial",
"which",
"has",
"been",
"broken",
"up",
"into",
"multiple",
"arrays",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java#L335-L342 |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/ReturnValue.java | ReturnValue.withPerformanceData | public ReturnValue withPerformanceData(final Metric metric, final UnitOfMeasure uom, final String warningRange,
final String criticalRange) {
"""
Adds performance data to the plugin result. Thos data will be added to
the output formatted as specified in Nagios specifications
(http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201)
@param metric
The metric relative to this result
@param uom
The Unit Of Measure
@param warningRange
The warning threshold used to check this metric (can be null)
@param criticalRange
The critical threshold used to check this value (can be null)
@return this
"""
performanceDataList.add(new PerformanceData(metric, uom, warningRange, criticalRange));
return this;
} | java | public ReturnValue withPerformanceData(final Metric metric, final UnitOfMeasure uom, final String warningRange,
final String criticalRange) {
performanceDataList.add(new PerformanceData(metric, uom, warningRange, criticalRange));
return this;
} | [
"public",
"ReturnValue",
"withPerformanceData",
"(",
"final",
"Metric",
"metric",
",",
"final",
"UnitOfMeasure",
"uom",
",",
"final",
"String",
"warningRange",
",",
"final",
"String",
"criticalRange",
")",
"{",
"performanceDataList",
".",
"add",
"(",
"new",
"PerformanceData",
"(",
"metric",
",",
"uom",
",",
"warningRange",
",",
"criticalRange",
")",
")",
";",
"return",
"this",
";",
"}"
] | Adds performance data to the plugin result. Thos data will be added to
the output formatted as specified in Nagios specifications
(http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201)
@param metric
The metric relative to this result
@param uom
The Unit Of Measure
@param warningRange
The warning threshold used to check this metric (can be null)
@param criticalRange
The critical threshold used to check this value (can be null)
@return this | [
"Adds",
"performance",
"data",
"to",
"the",
"plugin",
"result",
".",
"Thos",
"data",
"will",
"be",
"added",
"to",
"the",
"output",
"formatted",
"as",
"specified",
"in",
"Nagios",
"specifications",
"(",
"http",
":",
"//",
"nagiosplug",
".",
"sourceforge",
".",
"net",
"/",
"developer",
"-",
"guidelines",
".",
"html#AEN201",
")"
] | train | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/ReturnValue.java#L237-L241 |
apache/incubator-atlas | repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java | GraphHelper.getRelationshipDefName | public String getRelationshipDefName(AtlasVertex entityVertex, AtlasEntityType entityType, String attributeName) {
"""
Get relationshipDef name from entityType using relationship attribute.
if more than one relationDefs are returned for an attribute.
e.g. hive_column.table
hive_table.columns -> hive_column.table
hive_table.partitionKeys -> hive_column.table
resolve by comparing all incoming edges typename with relationDefs name returned for an attribute
to pick the right relationshipDef name
"""
AtlasRelationshipDef relationshipDef = getRelationshipDef(entityVertex, entityType, attributeName);
return (relationshipDef != null) ? relationshipDef.getName() : null;
} | java | public String getRelationshipDefName(AtlasVertex entityVertex, AtlasEntityType entityType, String attributeName) {
AtlasRelationshipDef relationshipDef = getRelationshipDef(entityVertex, entityType, attributeName);
return (relationshipDef != null) ? relationshipDef.getName() : null;
} | [
"public",
"String",
"getRelationshipDefName",
"(",
"AtlasVertex",
"entityVertex",
",",
"AtlasEntityType",
"entityType",
",",
"String",
"attributeName",
")",
"{",
"AtlasRelationshipDef",
"relationshipDef",
"=",
"getRelationshipDef",
"(",
"entityVertex",
",",
"entityType",
",",
"attributeName",
")",
";",
"return",
"(",
"relationshipDef",
"!=",
"null",
")",
"?",
"relationshipDef",
".",
"getName",
"(",
")",
":",
"null",
";",
"}"
] | Get relationshipDef name from entityType using relationship attribute.
if more than one relationDefs are returned for an attribute.
e.g. hive_column.table
hive_table.columns -> hive_column.table
hive_table.partitionKeys -> hive_column.table
resolve by comparing all incoming edges typename with relationDefs name returned for an attribute
to pick the right relationshipDef name | [
"Get",
"relationshipDef",
"name",
"from",
"entityType",
"using",
"relationship",
"attribute",
".",
"if",
"more",
"than",
"one",
"relationDefs",
"are",
"returned",
"for",
"an",
"attribute",
".",
"e",
".",
"g",
".",
"hive_column",
".",
"table"
] | train | https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java#L1286-L1290 |
alipay/sofa-rpc | extension-impl/metrics-lookout/src/main/java/com/alipay/sofa/rpc/metrics/lookout/RpcLookout.java | RpcLookout.collectThreadPool | public void collectThreadPool(ServerConfig serverConfig, final ThreadPoolExecutor threadPoolExecutor) {
"""
Collect the thread pool information
@param serverConfig ServerConfig
@param threadPoolExecutor ThreadPoolExecutor
"""
try {
int coreSize = serverConfig.getCoreThreads();
int maxSize = serverConfig.getMaxThreads();
int queueSize = serverConfig.getQueues();
final ThreadPoolConfig threadPoolConfig = new ThreadPoolConfig(coreSize, maxSize, queueSize);
Lookout.registry().info(rpcLookoutId.fetchServerThreadConfigId(serverConfig), new Info<ThreadPoolConfig>() {
@Override
public ThreadPoolConfig value() {
return threadPoolConfig;
}
});
Lookout.registry().gauge(rpcLookoutId.fetchServerThreadPoolActiveCountId(serverConfig),
new Gauge<Integer>() {
@Override
public Integer value() {
return threadPoolExecutor.getActiveCount();
}
});
Lookout.registry().gauge(rpcLookoutId.fetchServerThreadPoolIdleCountId(serverConfig), new Gauge<Integer>() {
@Override
public Integer value() {
return threadPoolExecutor.getPoolSize() - threadPoolExecutor.getActiveCount();
}
});
Lookout.registry().gauge(rpcLookoutId.fetchServerThreadPoolQueueSizeId(serverConfig), new Gauge<Integer>() {
@Override
public Integer value() {
return threadPoolExecutor.getQueue().size();
}
});
} catch (Throwable t) {
LOGGER.error(LogCodes.getLog(LogCodes.ERROR_METRIC_REPORT_ERROR), t);
}
} | java | public void collectThreadPool(ServerConfig serverConfig, final ThreadPoolExecutor threadPoolExecutor) {
try {
int coreSize = serverConfig.getCoreThreads();
int maxSize = serverConfig.getMaxThreads();
int queueSize = serverConfig.getQueues();
final ThreadPoolConfig threadPoolConfig = new ThreadPoolConfig(coreSize, maxSize, queueSize);
Lookout.registry().info(rpcLookoutId.fetchServerThreadConfigId(serverConfig), new Info<ThreadPoolConfig>() {
@Override
public ThreadPoolConfig value() {
return threadPoolConfig;
}
});
Lookout.registry().gauge(rpcLookoutId.fetchServerThreadPoolActiveCountId(serverConfig),
new Gauge<Integer>() {
@Override
public Integer value() {
return threadPoolExecutor.getActiveCount();
}
});
Lookout.registry().gauge(rpcLookoutId.fetchServerThreadPoolIdleCountId(serverConfig), new Gauge<Integer>() {
@Override
public Integer value() {
return threadPoolExecutor.getPoolSize() - threadPoolExecutor.getActiveCount();
}
});
Lookout.registry().gauge(rpcLookoutId.fetchServerThreadPoolQueueSizeId(serverConfig), new Gauge<Integer>() {
@Override
public Integer value() {
return threadPoolExecutor.getQueue().size();
}
});
} catch (Throwable t) {
LOGGER.error(LogCodes.getLog(LogCodes.ERROR_METRIC_REPORT_ERROR), t);
}
} | [
"public",
"void",
"collectThreadPool",
"(",
"ServerConfig",
"serverConfig",
",",
"final",
"ThreadPoolExecutor",
"threadPoolExecutor",
")",
"{",
"try",
"{",
"int",
"coreSize",
"=",
"serverConfig",
".",
"getCoreThreads",
"(",
")",
";",
"int",
"maxSize",
"=",
"serverConfig",
".",
"getMaxThreads",
"(",
")",
";",
"int",
"queueSize",
"=",
"serverConfig",
".",
"getQueues",
"(",
")",
";",
"final",
"ThreadPoolConfig",
"threadPoolConfig",
"=",
"new",
"ThreadPoolConfig",
"(",
"coreSize",
",",
"maxSize",
",",
"queueSize",
")",
";",
"Lookout",
".",
"registry",
"(",
")",
".",
"info",
"(",
"rpcLookoutId",
".",
"fetchServerThreadConfigId",
"(",
"serverConfig",
")",
",",
"new",
"Info",
"<",
"ThreadPoolConfig",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ThreadPoolConfig",
"value",
"(",
")",
"{",
"return",
"threadPoolConfig",
";",
"}",
"}",
")",
";",
"Lookout",
".",
"registry",
"(",
")",
".",
"gauge",
"(",
"rpcLookoutId",
".",
"fetchServerThreadPoolActiveCountId",
"(",
"serverConfig",
")",
",",
"new",
"Gauge",
"<",
"Integer",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Integer",
"value",
"(",
")",
"{",
"return",
"threadPoolExecutor",
".",
"getActiveCount",
"(",
")",
";",
"}",
"}",
")",
";",
"Lookout",
".",
"registry",
"(",
")",
".",
"gauge",
"(",
"rpcLookoutId",
".",
"fetchServerThreadPoolIdleCountId",
"(",
"serverConfig",
")",
",",
"new",
"Gauge",
"<",
"Integer",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Integer",
"value",
"(",
")",
"{",
"return",
"threadPoolExecutor",
".",
"getPoolSize",
"(",
")",
"-",
"threadPoolExecutor",
".",
"getActiveCount",
"(",
")",
";",
"}",
"}",
")",
";",
"Lookout",
".",
"registry",
"(",
")",
".",
"gauge",
"(",
"rpcLookoutId",
".",
"fetchServerThreadPoolQueueSizeId",
"(",
"serverConfig",
")",
",",
"new",
"Gauge",
"<",
"Integer",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Integer",
"value",
"(",
")",
"{",
"return",
"threadPoolExecutor",
".",
"getQueue",
"(",
")",
".",
"size",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"LOGGER",
".",
"error",
"(",
"LogCodes",
".",
"getLog",
"(",
"LogCodes",
".",
"ERROR_METRIC_REPORT_ERROR",
")",
",",
"t",
")",
";",
"}",
"}"
] | Collect the thread pool information
@param serverConfig ServerConfig
@param threadPoolExecutor ThreadPoolExecutor | [
"Collect",
"the",
"thread",
"pool",
"information"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/extension-impl/metrics-lookout/src/main/java/com/alipay/sofa/rpc/metrics/lookout/RpcLookout.java#L98-L142 |
maxirosson/jdroid-android | jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java | SharedPreferencesHelper.loadPreference | public String loadPreference(String key, String defaultValue) {
"""
Retrieve a string value from the preferences.
@param key The name of the preference to retrieve
@param defaultValue Value to return if this preference does not exist
@return the preference value if it exists, or defaultValue.
"""
String value = getSharedPreferences().getString(key, defaultValue);
logLoad(key, value);
return value;
} | java | public String loadPreference(String key, String defaultValue) {
String value = getSharedPreferences().getString(key, defaultValue);
logLoad(key, value);
return value;
} | [
"public",
"String",
"loadPreference",
"(",
"String",
"key",
",",
"String",
"defaultValue",
")",
"{",
"String",
"value",
"=",
"getSharedPreferences",
"(",
")",
".",
"getString",
"(",
"key",
",",
"defaultValue",
")",
";",
"logLoad",
"(",
"key",
",",
"value",
")",
";",
"return",
"value",
";",
"}"
] | Retrieve a string value from the preferences.
@param key The name of the preference to retrieve
@param defaultValue Value to return if this preference does not exist
@return the preference value if it exists, or defaultValue. | [
"Retrieve",
"a",
"string",
"value",
"from",
"the",
"preferences",
"."
] | train | https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/SharedPreferencesHelper.java#L179-L183 |
kaazing/gateway | mina.netty/src/main/java/org/kaazing/mina/core/future/DefaultUnbindFuture.java | DefaultUnbindFuture.combineFutures | public static UnbindFuture combineFutures(UnbindFuture future1, UnbindFuture future2) {
"""
Combine futures in a way that minimizes cost(no object creation) for the common case where
both have already been fulfilled.
"""
if (future1 == null || future1.isUnbound()) {
return future2;
}
else if (future2 == null || future2.isUnbound()) {
return future1;
}
else {
return new CompositeUnbindFuture(Arrays.asList(future1, future2));
}
} | java | public static UnbindFuture combineFutures(UnbindFuture future1, UnbindFuture future2) {
if (future1 == null || future1.isUnbound()) {
return future2;
}
else if (future2 == null || future2.isUnbound()) {
return future1;
}
else {
return new CompositeUnbindFuture(Arrays.asList(future1, future2));
}
} | [
"public",
"static",
"UnbindFuture",
"combineFutures",
"(",
"UnbindFuture",
"future1",
",",
"UnbindFuture",
"future2",
")",
"{",
"if",
"(",
"future1",
"==",
"null",
"||",
"future1",
".",
"isUnbound",
"(",
")",
")",
"{",
"return",
"future2",
";",
"}",
"else",
"if",
"(",
"future2",
"==",
"null",
"||",
"future2",
".",
"isUnbound",
"(",
")",
")",
"{",
"return",
"future1",
";",
"}",
"else",
"{",
"return",
"new",
"CompositeUnbindFuture",
"(",
"Arrays",
".",
"asList",
"(",
"future1",
",",
"future2",
")",
")",
";",
"}",
"}"
] | Combine futures in a way that minimizes cost(no object creation) for the common case where
both have already been fulfilled. | [
"Combine",
"futures",
"in",
"a",
"way",
"that",
"minimizes",
"cost",
"(",
"no",
"object",
"creation",
")",
"for",
"the",
"common",
"case",
"where",
"both",
"have",
"already",
"been",
"fulfilled",
"."
] | train | https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/mina.netty/src/main/java/org/kaazing/mina/core/future/DefaultUnbindFuture.java#L45-L55 |
JetBrains/xodus | utils/src/main/java/jetbrains/exodus/util/UTFUtil.java | UTFUtil.writeUTF | public static void writeUTF(@NotNull final OutputStream stream, @NotNull final String str) throws IOException {
"""
Writes long strings to output stream as several chunks.
@param stream stream to write to.
@param str string to be written.
@throws IOException if something went wrong
"""
try (DataOutputStream dataStream = new DataOutputStream(stream)) {
int len = str.length();
if (len < SINGLE_UTF_CHUNK_SIZE) {
dataStream.writeUTF(str);
} else {
int startIndex = 0;
int endIndex;
do {
endIndex = startIndex + SINGLE_UTF_CHUNK_SIZE;
if (endIndex > len) {
endIndex = len;
}
dataStream.writeUTF(str.substring(startIndex, endIndex));
startIndex += SINGLE_UTF_CHUNK_SIZE;
} while (endIndex < len);
}
}
} | java | public static void writeUTF(@NotNull final OutputStream stream, @NotNull final String str) throws IOException {
try (DataOutputStream dataStream = new DataOutputStream(stream)) {
int len = str.length();
if (len < SINGLE_UTF_CHUNK_SIZE) {
dataStream.writeUTF(str);
} else {
int startIndex = 0;
int endIndex;
do {
endIndex = startIndex + SINGLE_UTF_CHUNK_SIZE;
if (endIndex > len) {
endIndex = len;
}
dataStream.writeUTF(str.substring(startIndex, endIndex));
startIndex += SINGLE_UTF_CHUNK_SIZE;
} while (endIndex < len);
}
}
} | [
"public",
"static",
"void",
"writeUTF",
"(",
"@",
"NotNull",
"final",
"OutputStream",
"stream",
",",
"@",
"NotNull",
"final",
"String",
"str",
")",
"throws",
"IOException",
"{",
"try",
"(",
"DataOutputStream",
"dataStream",
"=",
"new",
"DataOutputStream",
"(",
"stream",
")",
")",
"{",
"int",
"len",
"=",
"str",
".",
"length",
"(",
")",
";",
"if",
"(",
"len",
"<",
"SINGLE_UTF_CHUNK_SIZE",
")",
"{",
"dataStream",
".",
"writeUTF",
"(",
"str",
")",
";",
"}",
"else",
"{",
"int",
"startIndex",
"=",
"0",
";",
"int",
"endIndex",
";",
"do",
"{",
"endIndex",
"=",
"startIndex",
"+",
"SINGLE_UTF_CHUNK_SIZE",
";",
"if",
"(",
"endIndex",
">",
"len",
")",
"{",
"endIndex",
"=",
"len",
";",
"}",
"dataStream",
".",
"writeUTF",
"(",
"str",
".",
"substring",
"(",
"startIndex",
",",
"endIndex",
")",
")",
";",
"startIndex",
"+=",
"SINGLE_UTF_CHUNK_SIZE",
";",
"}",
"while",
"(",
"endIndex",
"<",
"len",
")",
";",
"}",
"}",
"}"
] | Writes long strings to output stream as several chunks.
@param stream stream to write to.
@param str string to be written.
@throws IOException if something went wrong | [
"Writes",
"long",
"strings",
"to",
"output",
"stream",
"as",
"several",
"chunks",
"."
] | train | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/util/UTFUtil.java#L39-L57 |
cdk/cdk | base/isomorphism/src/main/java/org/openscience/cdk/isomorphism/Mappings.java | Mappings.toChemObjects | public Iterable<IChemObject> toChemObjects() {
"""
Obtain the chem objects (atoms and bonds) that have 'hit' in the target molecule.
<blockquote><pre>
for (IChemObject obj : mappings.toChemObjects()) {
if (obj instanceof IAtom) {
// this atom was 'hit' by the pattern
}
}
</pre></blockquote>
@return lazy iterable of chem objects
"""
return FluentIterable.from(map(new ToAtomBondMap(query, target)))
.transformAndConcat(new Function<Map<IChemObject, IChemObject>, Iterable<? extends IChemObject>>() {
@Override
public Iterable<? extends IChemObject> apply(Map<IChemObject, IChemObject> map) {
return map.values();
}
});
} | java | public Iterable<IChemObject> toChemObjects() {
return FluentIterable.from(map(new ToAtomBondMap(query, target)))
.transformAndConcat(new Function<Map<IChemObject, IChemObject>, Iterable<? extends IChemObject>>() {
@Override
public Iterable<? extends IChemObject> apply(Map<IChemObject, IChemObject> map) {
return map.values();
}
});
} | [
"public",
"Iterable",
"<",
"IChemObject",
">",
"toChemObjects",
"(",
")",
"{",
"return",
"FluentIterable",
".",
"from",
"(",
"map",
"(",
"new",
"ToAtomBondMap",
"(",
"query",
",",
"target",
")",
")",
")",
".",
"transformAndConcat",
"(",
"new",
"Function",
"<",
"Map",
"<",
"IChemObject",
",",
"IChemObject",
">",
",",
"Iterable",
"<",
"?",
"extends",
"IChemObject",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Iterable",
"<",
"?",
"extends",
"IChemObject",
">",
"apply",
"(",
"Map",
"<",
"IChemObject",
",",
"IChemObject",
">",
"map",
")",
"{",
"return",
"map",
".",
"values",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Obtain the chem objects (atoms and bonds) that have 'hit' in the target molecule.
<blockquote><pre>
for (IChemObject obj : mappings.toChemObjects()) {
if (obj instanceof IAtom) {
// this atom was 'hit' by the pattern
}
}
</pre></blockquote>
@return lazy iterable of chem objects | [
"Obtain",
"the",
"chem",
"objects",
"(",
"atoms",
"and",
"bonds",
")",
"that",
"have",
"hit",
"in",
"the",
"target",
"molecule",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/isomorphism/src/main/java/org/openscience/cdk/isomorphism/Mappings.java#L436-L444 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.pathString | protected DocPath pathString(PackageDoc pd, DocPath name) {
"""
Return path to the given file name in the given package. So if the name
passed is "Object.html" and the name of the package is "java.lang", and
if the relative path is "../.." then returned string will be
"../../java/lang/Object.html"
@param pd Package in which the file name is assumed to be.
@param name File name, to which path string is.
"""
return pathToRoot.resolve(DocPath.forPackage(pd).resolve(name));
} | java | protected DocPath pathString(PackageDoc pd, DocPath name) {
return pathToRoot.resolve(DocPath.forPackage(pd).resolve(name));
} | [
"protected",
"DocPath",
"pathString",
"(",
"PackageDoc",
"pd",
",",
"DocPath",
"name",
")",
"{",
"return",
"pathToRoot",
".",
"resolve",
"(",
"DocPath",
".",
"forPackage",
"(",
"pd",
")",
".",
"resolve",
"(",
"name",
")",
")",
";",
"}"
] | Return path to the given file name in the given package. So if the name
passed is "Object.html" and the name of the package is "java.lang", and
if the relative path is "../.." then returned string will be
"../../java/lang/Object.html"
@param pd Package in which the file name is assumed to be.
@param name File name, to which path string is. | [
"Return",
"path",
"to",
"the",
"given",
"file",
"name",
"in",
"the",
"given",
"package",
".",
"So",
"if",
"the",
"name",
"passed",
"is",
"Object",
".",
"html",
"and",
"the",
"name",
"of",
"the",
"package",
"is",
"java",
".",
"lang",
"and",
"if",
"the",
"relative",
"path",
"is",
"..",
"/",
"..",
"then",
"returned",
"string",
"will",
"be",
"..",
"/",
"..",
"/",
"java",
"/",
"lang",
"/",
"Object",
".",
"html"
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L927-L929 |
jeremybrooks/jinx | src/main/java/net/jeremybrooks/jinx/api/BlogApi.java | BlogApi.postPhoto | public Response postPhoto(String blogId, String photoId, String title, String description, String blogPassword, String serviceId) throws JinxException {
"""
Post a photo to a blogging service.
<br>
Authentication
<br>
This method requires authentication with 'write' permission.
<br>
Note: This method requires an HTTP POST request.
<br>
<br>
This method has no specific response - It returns an empty success response if it completes without error.
<p>
The blogId and serviceId are marked optional, but you must provide one of them so that Flickr knows
where you want to post the photo.
</p>
@param blogId (Optional) the id of the blog to post to.
@param photoId (Required) the id of the photo to blog
@param title (Required) the blog post title
@param description (Required) the blog post body
@param blogPassword (Optional) the password for the blog (used when the blog does not have a stored password).
@param serviceId (Optional) a Flickr supported blogging service. Instead of passing a blog id you can pass a service id and we'll post to the first blog of that service we find.
@return response object indicating success or fail.
@throws JinxException if required parameters are missing or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.blogs.postPhoto.html">flickr.blogs.postPhoto</a>
"""
JinxUtils.validateParams(photoId, title, description);
Map<String, String> params = new TreeMap<String, String>();
params.put("method", "flickr.blogs.postPhoto");
params.put("photo_id", photoId);
params.put("title", title);
params.put("description", description);
if (blogId != null) {
params.put("blog_id", blogId);
}
if (blogPassword != null) {
params.put("blog_password", blogPassword);
}
if (serviceId != null) {
params.put("service", serviceId);
}
return jinx.flickrPost(params, Response.class);
} | java | public Response postPhoto(String blogId, String photoId, String title, String description, String blogPassword, String serviceId) throws JinxException {
JinxUtils.validateParams(photoId, title, description);
Map<String, String> params = new TreeMap<String, String>();
params.put("method", "flickr.blogs.postPhoto");
params.put("photo_id", photoId);
params.put("title", title);
params.put("description", description);
if (blogId != null) {
params.put("blog_id", blogId);
}
if (blogPassword != null) {
params.put("blog_password", blogPassword);
}
if (serviceId != null) {
params.put("service", serviceId);
}
return jinx.flickrPost(params, Response.class);
} | [
"public",
"Response",
"postPhoto",
"(",
"String",
"blogId",
",",
"String",
"photoId",
",",
"String",
"title",
",",
"String",
"description",
",",
"String",
"blogPassword",
",",
"String",
"serviceId",
")",
"throws",
"JinxException",
"{",
"JinxUtils",
".",
"validateParams",
"(",
"photoId",
",",
"title",
",",
"description",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"method\"",
",",
"\"flickr.blogs.postPhoto\"",
")",
";",
"params",
".",
"put",
"(",
"\"photo_id\"",
",",
"photoId",
")",
";",
"params",
".",
"put",
"(",
"\"title\"",
",",
"title",
")",
";",
"params",
".",
"put",
"(",
"\"description\"",
",",
"description",
")",
";",
"if",
"(",
"blogId",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"blog_id\"",
",",
"blogId",
")",
";",
"}",
"if",
"(",
"blogPassword",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"blog_password\"",
",",
"blogPassword",
")",
";",
"}",
"if",
"(",
"serviceId",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"service\"",
",",
"serviceId",
")",
";",
"}",
"return",
"jinx",
".",
"flickrPost",
"(",
"params",
",",
"Response",
".",
"class",
")",
";",
"}"
] | Post a photo to a blogging service.
<br>
Authentication
<br>
This method requires authentication with 'write' permission.
<br>
Note: This method requires an HTTP POST request.
<br>
<br>
This method has no specific response - It returns an empty success response if it completes without error.
<p>
The blogId and serviceId are marked optional, but you must provide one of them so that Flickr knows
where you want to post the photo.
</p>
@param blogId (Optional) the id of the blog to post to.
@param photoId (Required) the id of the photo to blog
@param title (Required) the blog post title
@param description (Required) the blog post body
@param blogPassword (Optional) the password for the blog (used when the blog does not have a stored password).
@param serviceId (Optional) a Flickr supported blogging service. Instead of passing a blog id you can pass a service id and we'll post to the first blog of that service we find.
@return response object indicating success or fail.
@throws JinxException if required parameters are missing or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.blogs.postPhoto.html">flickr.blogs.postPhoto</a> | [
"Post",
"a",
"photo",
"to",
"a",
"blogging",
"service",
".",
"<br",
">",
"Authentication",
"<br",
">",
"This",
"method",
"requires",
"authentication",
"with",
"write",
"permission",
".",
"<br",
">",
"Note",
":",
"This",
"method",
"requires",
"an",
"HTTP",
"POST",
"request",
".",
"<br",
">",
"<br",
">",
"This",
"method",
"has",
"no",
"specific",
"response",
"-",
"It",
"returns",
"an",
"empty",
"success",
"response",
"if",
"it",
"completes",
"without",
"error",
".",
"<p",
">",
"The",
"blogId",
"and",
"serviceId",
"are",
"marked",
"optional",
"but",
"you",
"must",
"provide",
"one",
"of",
"them",
"so",
"that",
"Flickr",
"knows",
"where",
"you",
"want",
"to",
"post",
"the",
"photo",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/jeremybrooks/jinx/blob/ab7a4b7462d08bcbfd9b98bd3f5029771c20f6c6/src/main/java/net/jeremybrooks/jinx/api/BlogApi.java#L109-L128 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/binary/FactoryThresholdBinary.java | FactoryThresholdBinary.localSauvola | public static <T extends ImageGray<T>>
InputToBinary<T> localSauvola(ConfigLength width, boolean down, float k, Class<T> inputType) {
"""
@see ThresholdSauvola
@param width Width of square region.
@param down Should it threshold up or down.
@param k User specified threshold adjustment factor. Must be positive. Try 0.3
@param inputType Type of input image
@return Filter to binary
"""
if( BOverrideFactoryThresholdBinary.localSauvola != null )
return BOverrideFactoryThresholdBinary.localSauvola.handle(width, k, down, inputType);
InputToBinary<GrayF32> sauvola;
if( BoofConcurrency.USE_CONCURRENT ) {
sauvola = new ThresholdSauvola_MT(width, k, down);
} else {
sauvola = new ThresholdSauvola(width, k, down);
}
return new InputToBinarySwitch<>(sauvola,inputType);
} | java | public static <T extends ImageGray<T>>
InputToBinary<T> localSauvola(ConfigLength width, boolean down, float k, Class<T> inputType)
{
if( BOverrideFactoryThresholdBinary.localSauvola != null )
return BOverrideFactoryThresholdBinary.localSauvola.handle(width, k, down, inputType);
InputToBinary<GrayF32> sauvola;
if( BoofConcurrency.USE_CONCURRENT ) {
sauvola = new ThresholdSauvola_MT(width, k, down);
} else {
sauvola = new ThresholdSauvola(width, k, down);
}
return new InputToBinarySwitch<>(sauvola,inputType);
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"InputToBinary",
"<",
"T",
">",
"localSauvola",
"(",
"ConfigLength",
"width",
",",
"boolean",
"down",
",",
"float",
"k",
",",
"Class",
"<",
"T",
">",
"inputType",
")",
"{",
"if",
"(",
"BOverrideFactoryThresholdBinary",
".",
"localSauvola",
"!=",
"null",
")",
"return",
"BOverrideFactoryThresholdBinary",
".",
"localSauvola",
".",
"handle",
"(",
"width",
",",
"k",
",",
"down",
",",
"inputType",
")",
";",
"InputToBinary",
"<",
"GrayF32",
">",
"sauvola",
";",
"if",
"(",
"BoofConcurrency",
".",
"USE_CONCURRENT",
")",
"{",
"sauvola",
"=",
"new",
"ThresholdSauvola_MT",
"(",
"width",
",",
"k",
",",
"down",
")",
";",
"}",
"else",
"{",
"sauvola",
"=",
"new",
"ThresholdSauvola",
"(",
"width",
",",
"k",
",",
"down",
")",
";",
"}",
"return",
"new",
"InputToBinarySwitch",
"<>",
"(",
"sauvola",
",",
"inputType",
")",
";",
"}"
] | @see ThresholdSauvola
@param width Width of square region.
@param down Should it threshold up or down.
@param k User specified threshold adjustment factor. Must be positive. Try 0.3
@param inputType Type of input image
@return Filter to binary | [
"@see",
"ThresholdSauvola"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/binary/FactoryThresholdBinary.java#L68-L81 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/AnycastOutputHandler.java | AnycastOutputHandler.writtenStartedFlush | public final void writtenStartedFlush(AOStream stream, Item startedFlushItem) {
"""
Callback when the Item that records that flush has been started has been committed to persistent storage
@param stream The stream making this call
@param startedFlushItem The item written
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "writtenStartedFlush");
String key =
SIMPUtils.getRemoteGetKey(stream.getRemoteMEUuid(), stream.getGatheringTargetDestUuid());
StreamInfo sinfo = streamTable.get(key);
if ((sinfo != null) && sinfo.streamId.equals(stream.streamId))
{
synchronized (sinfo)
{
sinfo.item = (AOStartedFlushItem) startedFlushItem;
}
}
else
{
// this should not occur
// log error and throw exception
SIErrorException e = new SIErrorException(
nls.getFormattedMessage(
"INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] {
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler",
"1:2858:1.89.4.1" },
null));
// FFDC
FFDCFilter.processException(
e,
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler.writtenStartedFlush",
"1:2865:1.89.4.1",
this);
SibTr.exception(tc, e);
SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] {
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler",
"1:2872:1.89.4.1" });
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "writtenStartedFlush", e);
throw e;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "writtenStartedFlush");
} | java | public final void writtenStartedFlush(AOStream stream, Item startedFlushItem)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "writtenStartedFlush");
String key =
SIMPUtils.getRemoteGetKey(stream.getRemoteMEUuid(), stream.getGatheringTargetDestUuid());
StreamInfo sinfo = streamTable.get(key);
if ((sinfo != null) && sinfo.streamId.equals(stream.streamId))
{
synchronized (sinfo)
{
sinfo.item = (AOStartedFlushItem) startedFlushItem;
}
}
else
{
// this should not occur
// log error and throw exception
SIErrorException e = new SIErrorException(
nls.getFormattedMessage(
"INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] {
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler",
"1:2858:1.89.4.1" },
null));
// FFDC
FFDCFilter.processException(
e,
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler.writtenStartedFlush",
"1:2865:1.89.4.1",
this);
SibTr.exception(tc, e);
SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] {
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler",
"1:2872:1.89.4.1" });
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "writtenStartedFlush", e);
throw e;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "writtenStartedFlush");
} | [
"public",
"final",
"void",
"writtenStartedFlush",
"(",
"AOStream",
"stream",
",",
"Item",
"startedFlushItem",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"writtenStartedFlush\"",
")",
";",
"String",
"key",
"=",
"SIMPUtils",
".",
"getRemoteGetKey",
"(",
"stream",
".",
"getRemoteMEUuid",
"(",
")",
",",
"stream",
".",
"getGatheringTargetDestUuid",
"(",
")",
")",
";",
"StreamInfo",
"sinfo",
"=",
"streamTable",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"(",
"sinfo",
"!=",
"null",
")",
"&&",
"sinfo",
".",
"streamId",
".",
"equals",
"(",
"stream",
".",
"streamId",
")",
")",
"{",
"synchronized",
"(",
"sinfo",
")",
"{",
"sinfo",
".",
"item",
"=",
"(",
"AOStartedFlushItem",
")",
"startedFlushItem",
";",
"}",
"}",
"else",
"{",
"// this should not occur",
"// log error and throw exception",
"SIErrorException",
"e",
"=",
"new",
"SIErrorException",
"(",
"nls",
".",
"getFormattedMessage",
"(",
"\"INTERNAL_MESSAGING_ERROR_CWSIP0001\"",
",",
"new",
"Object",
"[",
"]",
"{",
"\"com.ibm.ws.sib.processor.impl.AnycastOutputHandler\"",
",",
"\"1:2858:1.89.4.1\"",
"}",
",",
"null",
")",
")",
";",
"// FFDC",
"FFDCFilter",
".",
"processException",
"(",
"e",
",",
"\"com.ibm.ws.sib.processor.impl.AnycastOutputHandler.writtenStartedFlush\"",
",",
"\"1:2865:1.89.4.1\"",
",",
"this",
")",
";",
"SibTr",
".",
"exception",
"(",
"tc",
",",
"e",
")",
";",
"SibTr",
".",
"error",
"(",
"tc",
",",
"\"INTERNAL_MESSAGING_ERROR_CWSIP0001\"",
",",
"new",
"Object",
"[",
"]",
"{",
"\"com.ibm.ws.sib.processor.impl.AnycastOutputHandler\"",
",",
"\"1:2872:1.89.4.1\"",
"}",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"writtenStartedFlush\"",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"writtenStartedFlush\"",
")",
";",
"}"
] | Callback when the Item that records that flush has been started has been committed to persistent storage
@param stream The stream making this call
@param startedFlushItem The item written | [
"Callback",
"when",
"the",
"Item",
"that",
"records",
"that",
"flush",
"has",
"been",
"started",
"has",
"been",
"committed",
"to",
"persistent",
"storage"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/AnycastOutputHandler.java#L2789-L2835 |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/DistributionBarHelper.java | DistributionBarHelper.getDistributionBarAsHTMLString | public static String getDistributionBarAsHTMLString(final Map<Status, Long> statusTotalCountMap) {
"""
Returns a string with details of status and count .
@param statusTotalCountMap
map with status and count
@return string of format "status1:count,status2:count"
"""
final StringBuilder htmlString = new StringBuilder();
final Map<Status, Long> statusMapWithNonZeroValues = getStatusMapWithNonZeroValues(statusTotalCountMap);
final Long totalValue = getTotalSizes(statusTotalCountMap);
if (statusMapWithNonZeroValues.size() <= 0) {
return getUnintialisedBar();
}
int partIndex = 1;
htmlString.append(getParentDivStart());
for (final Map.Entry<Status, Long> entry : statusMapWithNonZeroValues.entrySet()) {
if (entry.getValue() > 0) {
htmlString.append(getPart(partIndex, entry.getKey(), entry.getValue(), totalValue,
statusMapWithNonZeroValues.size()));
partIndex++;
}
}
htmlString.append(HTML_DIV_END);
return htmlString.toString();
} | java | public static String getDistributionBarAsHTMLString(final Map<Status, Long> statusTotalCountMap) {
final StringBuilder htmlString = new StringBuilder();
final Map<Status, Long> statusMapWithNonZeroValues = getStatusMapWithNonZeroValues(statusTotalCountMap);
final Long totalValue = getTotalSizes(statusTotalCountMap);
if (statusMapWithNonZeroValues.size() <= 0) {
return getUnintialisedBar();
}
int partIndex = 1;
htmlString.append(getParentDivStart());
for (final Map.Entry<Status, Long> entry : statusMapWithNonZeroValues.entrySet()) {
if (entry.getValue() > 0) {
htmlString.append(getPart(partIndex, entry.getKey(), entry.getValue(), totalValue,
statusMapWithNonZeroValues.size()));
partIndex++;
}
}
htmlString.append(HTML_DIV_END);
return htmlString.toString();
} | [
"public",
"static",
"String",
"getDistributionBarAsHTMLString",
"(",
"final",
"Map",
"<",
"Status",
",",
"Long",
">",
"statusTotalCountMap",
")",
"{",
"final",
"StringBuilder",
"htmlString",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"Map",
"<",
"Status",
",",
"Long",
">",
"statusMapWithNonZeroValues",
"=",
"getStatusMapWithNonZeroValues",
"(",
"statusTotalCountMap",
")",
";",
"final",
"Long",
"totalValue",
"=",
"getTotalSizes",
"(",
"statusTotalCountMap",
")",
";",
"if",
"(",
"statusMapWithNonZeroValues",
".",
"size",
"(",
")",
"<=",
"0",
")",
"{",
"return",
"getUnintialisedBar",
"(",
")",
";",
"}",
"int",
"partIndex",
"=",
"1",
";",
"htmlString",
".",
"append",
"(",
"getParentDivStart",
"(",
")",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"Status",
",",
"Long",
">",
"entry",
":",
"statusMapWithNonZeroValues",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
">",
"0",
")",
"{",
"htmlString",
".",
"append",
"(",
"getPart",
"(",
"partIndex",
",",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
",",
"totalValue",
",",
"statusMapWithNonZeroValues",
".",
"size",
"(",
")",
")",
")",
";",
"partIndex",
"++",
";",
"}",
"}",
"htmlString",
".",
"append",
"(",
"HTML_DIV_END",
")",
";",
"return",
"htmlString",
".",
"toString",
"(",
")",
";",
"}"
] | Returns a string with details of status and count .
@param statusTotalCountMap
map with status and count
@return string of format "status1:count,status2:count" | [
"Returns",
"a",
"string",
"with",
"details",
"of",
"status",
"and",
"count",
"."
] | train | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/DistributionBarHelper.java#L43-L61 |
grpc/grpc-java | api/src/main/java/io/grpc/CallOptions.java | CallOptions.withDeadlineAfter | public CallOptions withDeadlineAfter(long duration, TimeUnit unit) {
"""
Returns a new {@code CallOptions} with a deadline that is after the given {@code duration} from
now.
"""
return withDeadline(Deadline.after(duration, unit));
} | java | public CallOptions withDeadlineAfter(long duration, TimeUnit unit) {
return withDeadline(Deadline.after(duration, unit));
} | [
"public",
"CallOptions",
"withDeadlineAfter",
"(",
"long",
"duration",
",",
"TimeUnit",
"unit",
")",
"{",
"return",
"withDeadline",
"(",
"Deadline",
".",
"after",
"(",
"duration",
",",
"unit",
")",
")",
";",
"}"
] | Returns a new {@code CallOptions} with a deadline that is after the given {@code duration} from
now. | [
"Returns",
"a",
"new",
"{"
] | train | https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/CallOptions.java#L139-L141 |
querydsl/querydsl | querydsl-sql/src/main/java/com/querydsl/sql/RelationalPathBase.java | RelationalPathBase.eq | @Override
public BooleanExpression eq(T right) {
"""
Compares the two relational paths using primary key columns
@param right rhs of the comparison
@return this == right
"""
if (right instanceof RelationalPath) {
return primaryKeyOperation(Ops.EQ, primaryKey, ((RelationalPath) right).getPrimaryKey());
} else {
return super.eq(right);
}
} | java | @Override
public BooleanExpression eq(T right) {
if (right instanceof RelationalPath) {
return primaryKeyOperation(Ops.EQ, primaryKey, ((RelationalPath) right).getPrimaryKey());
} else {
return super.eq(right);
}
} | [
"@",
"Override",
"public",
"BooleanExpression",
"eq",
"(",
"T",
"right",
")",
"{",
"if",
"(",
"right",
"instanceof",
"RelationalPath",
")",
"{",
"return",
"primaryKeyOperation",
"(",
"Ops",
".",
"EQ",
",",
"primaryKey",
",",
"(",
"(",
"RelationalPath",
")",
"right",
")",
".",
"getPrimaryKey",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"super",
".",
"eq",
"(",
"right",
")",
";",
"}",
"}"
] | Compares the two relational paths using primary key columns
@param right rhs of the comparison
@return this == right | [
"Compares",
"the",
"two",
"relational",
"paths",
"using",
"primary",
"key",
"columns"
] | train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-sql/src/main/java/com/querydsl/sql/RelationalPathBase.java#L141-L148 |
drallgood/jpasskit | jpasskit/src/main/java/de/brendamour/jpasskit/signing/PKSigningInformationUtil.java | PKSigningInformationUtil.loadSigningInformationFromPKCS12AndIntermediateCertificate | public PKSigningInformation loadSigningInformationFromPKCS12AndIntermediateCertificate(InputStream keyStoreInputStream,
String keyStorePassword, InputStream appleWWDRCAFileInputStream) throws IOException, CertificateException {
"""
Load all signing information necessary for pass generation using two input streams for the key store and the Apple WWDRCA certificate.
The caller is responsible for closing the stream after this method returns successfully or fails.
@param keyStoreInputStream
<code>InputStream</code> of the key store
@param keyStorePassword
Password used to access the key store
@param appleWWDRCAFileInputStream
<code>InputStream</code> of the Apple WWDRCA certificate.
@return Signing information necessary to sign a pass.
@throws IOException
@throws IllegalStateException
@throws CertificateException
"""
KeyStore pkcs12KeyStore = loadPKCS12File(keyStoreInputStream, keyStorePassword);
X509Certificate appleWWDRCACert = loadDERCertificate(appleWWDRCAFileInputStream);
return loadSigningInformation(pkcs12KeyStore, keyStorePassword, appleWWDRCACert);
} | java | public PKSigningInformation loadSigningInformationFromPKCS12AndIntermediateCertificate(InputStream keyStoreInputStream,
String keyStorePassword, InputStream appleWWDRCAFileInputStream) throws IOException, CertificateException {
KeyStore pkcs12KeyStore = loadPKCS12File(keyStoreInputStream, keyStorePassword);
X509Certificate appleWWDRCACert = loadDERCertificate(appleWWDRCAFileInputStream);
return loadSigningInformation(pkcs12KeyStore, keyStorePassword, appleWWDRCACert);
} | [
"public",
"PKSigningInformation",
"loadSigningInformationFromPKCS12AndIntermediateCertificate",
"(",
"InputStream",
"keyStoreInputStream",
",",
"String",
"keyStorePassword",
",",
"InputStream",
"appleWWDRCAFileInputStream",
")",
"throws",
"IOException",
",",
"CertificateException",
"{",
"KeyStore",
"pkcs12KeyStore",
"=",
"loadPKCS12File",
"(",
"keyStoreInputStream",
",",
"keyStorePassword",
")",
";",
"X509Certificate",
"appleWWDRCACert",
"=",
"loadDERCertificate",
"(",
"appleWWDRCAFileInputStream",
")",
";",
"return",
"loadSigningInformation",
"(",
"pkcs12KeyStore",
",",
"keyStorePassword",
",",
"appleWWDRCACert",
")",
";",
"}"
] | Load all signing information necessary for pass generation using two input streams for the key store and the Apple WWDRCA certificate.
The caller is responsible for closing the stream after this method returns successfully or fails.
@param keyStoreInputStream
<code>InputStream</code> of the key store
@param keyStorePassword
Password used to access the key store
@param appleWWDRCAFileInputStream
<code>InputStream</code> of the Apple WWDRCA certificate.
@return Signing information necessary to sign a pass.
@throws IOException
@throws IllegalStateException
@throws CertificateException | [
"Load",
"all",
"signing",
"information",
"necessary",
"for",
"pass",
"generation",
"using",
"two",
"input",
"streams",
"for",
"the",
"key",
"store",
"and",
"the",
"Apple",
"WWDRCA",
"certificate",
"."
] | train | https://github.com/drallgood/jpasskit/blob/63bfa8abbdb85c2d7596c60eed41ed8e374cbd01/jpasskit/src/main/java/de/brendamour/jpasskit/signing/PKSigningInformationUtil.java#L97-L104 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/ConfigUtils.java | ConfigUtils.getLong | public static Long getLong(Config config, String path, Long def) {
"""
Return {@link Long} value at <code>path</code> if <code>config</code> has path. If not return <code>def</code>
@param config in which the path may be present
@param path key to look for in the config object
@return {@link Long} value at <code>path</code> if <code>config</code> has path. If not return <code>def</code>
"""
if (config.hasPath(path)) {
return Long.valueOf(config.getLong(path));
}
return def;
} | java | public static Long getLong(Config config, String path, Long def) {
if (config.hasPath(path)) {
return Long.valueOf(config.getLong(path));
}
return def;
} | [
"public",
"static",
"Long",
"getLong",
"(",
"Config",
"config",
",",
"String",
"path",
",",
"Long",
"def",
")",
"{",
"if",
"(",
"config",
".",
"hasPath",
"(",
"path",
")",
")",
"{",
"return",
"Long",
".",
"valueOf",
"(",
"config",
".",
"getLong",
"(",
"path",
")",
")",
";",
"}",
"return",
"def",
";",
"}"
] | Return {@link Long} value at <code>path</code> if <code>config</code> has path. If not return <code>def</code>
@param config in which the path may be present
@param path key to look for in the config object
@return {@link Long} value at <code>path</code> if <code>config</code> has path. If not return <code>def</code> | [
"Return",
"{",
"@link",
"Long",
"}",
"value",
"at",
"<code",
">",
"path<",
"/",
"code",
">",
"if",
"<code",
">",
"config<",
"/",
"code",
">",
"has",
"path",
".",
"If",
"not",
"return",
"<code",
">",
"def<",
"/",
"code",
">"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/ConfigUtils.java#L336-L341 |
cose-wg/COSE-JAVA | src/main/java/COSE/Attribute.java | Attribute.AddUnprotected | @Deprecated
public void AddUnprotected(CBORObject label, CBORObject value) throws CoseException {
"""
Set an attribute in the unprotected bucket of the COSE object
@param label value identifies the attribute in the map
@param value value to be associated with the label
@deprecated As of COSE 0.9.1, use addAttribute(HeaderKeys, byte[], Attribute.UNPROTECTED);
@exception CoseException COSE Package exception
"""
addAttribute(label, value, UNPROTECTED);
} | java | @Deprecated
public void AddUnprotected(CBORObject label, CBORObject value) throws CoseException {
addAttribute(label, value, UNPROTECTED);
} | [
"@",
"Deprecated",
"public",
"void",
"AddUnprotected",
"(",
"CBORObject",
"label",
",",
"CBORObject",
"value",
")",
"throws",
"CoseException",
"{",
"addAttribute",
"(",
"label",
",",
"value",
",",
"UNPROTECTED",
")",
";",
"}"
] | Set an attribute in the unprotected bucket of the COSE object
@param label value identifies the attribute in the map
@param value value to be associated with the label
@deprecated As of COSE 0.9.1, use addAttribute(HeaderKeys, byte[], Attribute.UNPROTECTED);
@exception CoseException COSE Package exception | [
"Set",
"an",
"attribute",
"in",
"the",
"unprotected",
"bucket",
"of",
"the",
"COSE",
"object"
] | train | https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/Attribute.java#L219-L222 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.cdn_webstorage_serviceName_traffic_POST | public OvhOrder cdn_webstorage_serviceName_traffic_POST(String serviceName, OvhOrderTrafficEnum bandwidth) throws IOException {
"""
Create order
REST: POST /order/cdn/webstorage/{serviceName}/traffic
@param bandwidth [required] Traffic in TB that will be added to the cdn.webstorage service
@param serviceName [required] The internal name of your CDN Static offer
"""
String qPath = "/order/cdn/webstorage/{serviceName}/traffic";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "bandwidth", bandwidth);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOrder.class);
} | java | public OvhOrder cdn_webstorage_serviceName_traffic_POST(String serviceName, OvhOrderTrafficEnum bandwidth) throws IOException {
String qPath = "/order/cdn/webstorage/{serviceName}/traffic";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "bandwidth", bandwidth);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOrder.class);
} | [
"public",
"OvhOrder",
"cdn_webstorage_serviceName_traffic_POST",
"(",
"String",
"serviceName",
",",
"OvhOrderTrafficEnum",
"bandwidth",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/cdn/webstorage/{serviceName}/traffic\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"bandwidth\"",
",",
"bandwidth",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] | Create order
REST: POST /order/cdn/webstorage/{serviceName}/traffic
@param bandwidth [required] Traffic in TB that will be added to the cdn.webstorage service
@param serviceName [required] The internal name of your CDN Static offer | [
"Create",
"order"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L5450-L5457 |
landawn/AbacusUtil | src/com/landawn/abacus/util/DateUtil.java | DateUtil.setMonths | public static <T extends java.util.Date> T setMonths(final T date, final int amount) {
"""
Copied from Apache Commons Lang under Apache License v2.
<br />
Sets the months field to a date returning a new object.
The original {@code Date} is unchanged.
@param date the date, not null
@param amount the amount to set
@return a new {@code Date} set with the specified value
@throws IllegalArgumentException if the date is null
@since 2.4
"""
return set(date, Calendar.MONTH, amount);
} | java | public static <T extends java.util.Date> T setMonths(final T date, final int amount) {
return set(date, Calendar.MONTH, amount);
} | [
"public",
"static",
"<",
"T",
"extends",
"java",
".",
"util",
".",
"Date",
">",
"T",
"setMonths",
"(",
"final",
"T",
"date",
",",
"final",
"int",
"amount",
")",
"{",
"return",
"set",
"(",
"date",
",",
"Calendar",
".",
"MONTH",
",",
"amount",
")",
";",
"}"
] | Copied from Apache Commons Lang under Apache License v2.
<br />
Sets the months field to a date returning a new object.
The original {@code Date} is unchanged.
@param date the date, not null
@param amount the amount to set
@return a new {@code Date} set with the specified value
@throws IllegalArgumentException if the date is null
@since 2.4 | [
"Copied",
"from",
"Apache",
"Commons",
"Lang",
"under",
"Apache",
"License",
"v2",
".",
"<br",
"/",
">"
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/DateUtil.java#L714-L716 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging.core/src/com/ibm/ejs/ras/TraceNLS.java | TraceNLS.getFormattedMessage | public String getFormattedMessage(String key, Object[] args, String defaultString) {
"""
Return the message obtained by looking up the localized text indicated by
the key in the ResourceBundle wrapped by this instance, then formatting
the message using the specified arguments as substitution parameters.
<p>
The message is formatted using the java.text.MessageFormat class.
Substitution parameters are handled according to the rules of that class.
Most noteably, that class does special formatting for native java Date and
Number objects.
<p>
If an error occurs in obtaining the localized text corresponding to this
key, then the defaultString is used as the message text. If all else fails,
this class will provide one of the default English messages to indicate
what occurred.
<p>
@param key
the key to use in the ResourceBundle lookup. Null is tolerated
@param args
substitution parameters that are inserted into the message
text. Null is tolerated
@param defaultString
text to use if the localized text cannot be found. Null is
tolerated
<p>
@return a non-null message that is localized and formatted as
appropriate.
"""
return resolver.getMessage(caller, null, ivBundleName, key, args, defaultString, true, null, false);
} | java | public String getFormattedMessage(String key, Object[] args, String defaultString) {
return resolver.getMessage(caller, null, ivBundleName, key, args, defaultString, true, null, false);
} | [
"public",
"String",
"getFormattedMessage",
"(",
"String",
"key",
",",
"Object",
"[",
"]",
"args",
",",
"String",
"defaultString",
")",
"{",
"return",
"resolver",
".",
"getMessage",
"(",
"caller",
",",
"null",
",",
"ivBundleName",
",",
"key",
",",
"args",
",",
"defaultString",
",",
"true",
",",
"null",
",",
"false",
")",
";",
"}"
] | Return the message obtained by looking up the localized text indicated by
the key in the ResourceBundle wrapped by this instance, then formatting
the message using the specified arguments as substitution parameters.
<p>
The message is formatted using the java.text.MessageFormat class.
Substitution parameters are handled according to the rules of that class.
Most noteably, that class does special formatting for native java Date and
Number objects.
<p>
If an error occurs in obtaining the localized text corresponding to this
key, then the defaultString is used as the message text. If all else fails,
this class will provide one of the default English messages to indicate
what occurred.
<p>
@param key
the key to use in the ResourceBundle lookup. Null is tolerated
@param args
substitution parameters that are inserted into the message
text. Null is tolerated
@param defaultString
text to use if the localized text cannot be found. Null is
tolerated
<p>
@return a non-null message that is localized and formatted as
appropriate. | [
"Return",
"the",
"message",
"obtained",
"by",
"looking",
"up",
"the",
"localized",
"text",
"indicated",
"by",
"the",
"key",
"in",
"the",
"ResourceBundle",
"wrapped",
"by",
"this",
"instance",
"then",
"formatting",
"the",
"message",
"using",
"the",
"specified",
"arguments",
"as",
"substitution",
"parameters",
".",
"<p",
">",
"The",
"message",
"is",
"formatted",
"using",
"the",
"java",
".",
"text",
".",
"MessageFormat",
"class",
".",
"Substitution",
"parameters",
"are",
"handled",
"according",
"to",
"the",
"rules",
"of",
"that",
"class",
".",
"Most",
"noteably",
"that",
"class",
"does",
"special",
"formatting",
"for",
"native",
"java",
"Date",
"and",
"Number",
"objects",
".",
"<p",
">",
"If",
"an",
"error",
"occurs",
"in",
"obtaining",
"the",
"localized",
"text",
"corresponding",
"to",
"this",
"key",
"then",
"the",
"defaultString",
"is",
"used",
"as",
"the",
"message",
"text",
".",
"If",
"all",
"else",
"fails",
"this",
"class",
"will",
"provide",
"one",
"of",
"the",
"default",
"English",
"messages",
"to",
"indicate",
"what",
"occurred",
".",
"<p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.core/src/com/ibm/ejs/ras/TraceNLS.java#L184-L186 |
cdk/cdk | legacy/src/main/java/org/openscience/cdk/tools/IonizationPotentialTool.java | IonizationPotentialTool.predictIP | public static double predictIP(IAtomContainer container, IAtom atom) throws CDKException {
"""
Method which is predict the Ionization Potential from given atom.
@param container The IAtomContainer where is contained the IAtom
@param atom The IAtom to prediction the IP
@return The value in eV
"""
double value = 0;
// at least one lone pair orbital is necessary to ionize
if (container.getConnectedLonePairsCount(atom) == 0) return value;
// control if the IAtom belongs in some family
if (familyHalogen(atom))
value = getDTHalogenF(getQSARs(container, atom));
else if (familyOxygen(atom))
value = getDTOxygenF(getQSARs(container, atom));
else if (familyNitrogen(atom)) value = getDTNitrogenF(getQSARs(container, atom));
return value;
} | java | public static double predictIP(IAtomContainer container, IAtom atom) throws CDKException {
double value = 0;
// at least one lone pair orbital is necessary to ionize
if (container.getConnectedLonePairsCount(atom) == 0) return value;
// control if the IAtom belongs in some family
if (familyHalogen(atom))
value = getDTHalogenF(getQSARs(container, atom));
else if (familyOxygen(atom))
value = getDTOxygenF(getQSARs(container, atom));
else if (familyNitrogen(atom)) value = getDTNitrogenF(getQSARs(container, atom));
return value;
} | [
"public",
"static",
"double",
"predictIP",
"(",
"IAtomContainer",
"container",
",",
"IAtom",
"atom",
")",
"throws",
"CDKException",
"{",
"double",
"value",
"=",
"0",
";",
"// at least one lone pair orbital is necessary to ionize",
"if",
"(",
"container",
".",
"getConnectedLonePairsCount",
"(",
"atom",
")",
"==",
"0",
")",
"return",
"value",
";",
"// control if the IAtom belongs in some family",
"if",
"(",
"familyHalogen",
"(",
"atom",
")",
")",
"value",
"=",
"getDTHalogenF",
"(",
"getQSARs",
"(",
"container",
",",
"atom",
")",
")",
";",
"else",
"if",
"(",
"familyOxygen",
"(",
"atom",
")",
")",
"value",
"=",
"getDTOxygenF",
"(",
"getQSARs",
"(",
"container",
",",
"atom",
")",
")",
";",
"else",
"if",
"(",
"familyNitrogen",
"(",
"atom",
")",
")",
"value",
"=",
"getDTNitrogenF",
"(",
"getQSARs",
"(",
"container",
",",
"atom",
")",
")",
";",
"return",
"value",
";",
"}"
] | Method which is predict the Ionization Potential from given atom.
@param container The IAtomContainer where is contained the IAtom
@param atom The IAtom to prediction the IP
@return The value in eV | [
"Method",
"which",
"is",
"predict",
"the",
"Ionization",
"Potential",
"from",
"given",
"atom",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/legacy/src/main/java/org/openscience/cdk/tools/IonizationPotentialTool.java#L70-L84 |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/KeyUtil.java | KeyUtil.generatePrivateKey | public static PrivateKey generatePrivateKey(String algorithm, KeySpec keySpec) {
"""
生成私钥,仅用于非对称加密<br>
算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyFactory
@param algorithm 算法
@param keySpec {@link KeySpec}
@return 私钥 {@link PrivateKey}
@since 3.1.1
"""
if (null == keySpec) {
return null;
}
algorithm = getAlgorithmAfterWith(algorithm);
try {
return getKeyFactory(algorithm).generatePrivate(keySpec);
} catch (Exception e) {
throw new CryptoException(e);
}
} | java | public static PrivateKey generatePrivateKey(String algorithm, KeySpec keySpec) {
if (null == keySpec) {
return null;
}
algorithm = getAlgorithmAfterWith(algorithm);
try {
return getKeyFactory(algorithm).generatePrivate(keySpec);
} catch (Exception e) {
throw new CryptoException(e);
}
} | [
"public",
"static",
"PrivateKey",
"generatePrivateKey",
"(",
"String",
"algorithm",
",",
"KeySpec",
"keySpec",
")",
"{",
"if",
"(",
"null",
"==",
"keySpec",
")",
"{",
"return",
"null",
";",
"}",
"algorithm",
"=",
"getAlgorithmAfterWith",
"(",
"algorithm",
")",
";",
"try",
"{",
"return",
"getKeyFactory",
"(",
"algorithm",
")",
".",
"generatePrivate",
"(",
"keySpec",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"CryptoException",
"(",
"e",
")",
";",
"}",
"}"
] | 生成私钥,仅用于非对称加密<br>
算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyFactory
@param algorithm 算法
@param keySpec {@link KeySpec}
@return 私钥 {@link PrivateKey}
@since 3.1.1 | [
"生成私钥,仅用于非对称加密<br",
">",
"算法见:https",
":",
"//",
"docs",
".",
"oracle",
".",
"com",
"/",
"javase",
"/",
"7",
"/",
"docs",
"/",
"technotes",
"/",
"guides",
"/",
"security",
"/",
"StandardNames",
".",
"html#KeyFactory"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/KeyUtil.java#L235-L245 |
Prototik/HoloEverywhere | library/src/org/holoeverywhere/widget/datetimepicker/DateTimePickerUtils.java | DateTimePickerUtils.getWeeksSinceEpochFromJulianDay | public static int getWeeksSinceEpochFromJulianDay(int julianDay, int firstDayOfWeek) {
"""
Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
adjusted for first day of week.
<p/>
This takes a julian day and the week start day and calculates which
week since {@link Time#EPOCH_JULIAN_DAY} that day occurs in, starting
at 0. *Do not* use this to compute the ISO week number for the year.
@param julianDay The julian day to calculate the week number for
@param firstDayOfWeek Which week day is the first day of the week,
see {@link Time#SUNDAY}
@return Weeks since the epoch
"""
int diff = Time.THURSDAY - firstDayOfWeek;
if (diff < 0) {
diff += 7;
}
int refDay = Time.EPOCH_JULIAN_DAY - diff;
return (julianDay - refDay) / 7;
} | java | public static int getWeeksSinceEpochFromJulianDay(int julianDay, int firstDayOfWeek) {
int diff = Time.THURSDAY - firstDayOfWeek;
if (diff < 0) {
diff += 7;
}
int refDay = Time.EPOCH_JULIAN_DAY - diff;
return (julianDay - refDay) / 7;
} | [
"public",
"static",
"int",
"getWeeksSinceEpochFromJulianDay",
"(",
"int",
"julianDay",
",",
"int",
"firstDayOfWeek",
")",
"{",
"int",
"diff",
"=",
"Time",
".",
"THURSDAY",
"-",
"firstDayOfWeek",
";",
"if",
"(",
"diff",
"<",
"0",
")",
"{",
"diff",
"+=",
"7",
";",
"}",
"int",
"refDay",
"=",
"Time",
".",
"EPOCH_JULIAN_DAY",
"-",
"diff",
";",
"return",
"(",
"julianDay",
"-",
"refDay",
")",
"/",
"7",
";",
"}"
] | Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
adjusted for first day of week.
<p/>
This takes a julian day and the week start day and calculates which
week since {@link Time#EPOCH_JULIAN_DAY} that day occurs in, starting
at 0. *Do not* use this to compute the ISO week number for the year.
@param julianDay The julian day to calculate the week number for
@param firstDayOfWeek Which week day is the first day of the week,
see {@link Time#SUNDAY}
@return Weeks since the epoch | [
"Returns",
"the",
"week",
"since",
"{",
"@link",
"Time#EPOCH_JULIAN_DAY",
"}",
"(",
"Jan",
"1",
"1970",
")",
"adjusted",
"for",
"first",
"day",
"of",
"week",
".",
"<p",
"/",
">",
"This",
"takes",
"a",
"julian",
"day",
"and",
"the",
"week",
"start",
"day",
"and",
"calculates",
"which",
"week",
"since",
"{",
"@link",
"Time#EPOCH_JULIAN_DAY",
"}",
"that",
"day",
"occurs",
"in",
"starting",
"at",
"0",
".",
"*",
"Do",
"not",
"*",
"use",
"this",
"to",
"compute",
"the",
"ISO",
"week",
"number",
"for",
"the",
"year",
"."
] | train | https://github.com/Prototik/HoloEverywhere/blob/b870abb5ab009a5a6dbab3fb855ec2854e35e125/library/src/org/holoeverywhere/widget/datetimepicker/DateTimePickerUtils.java#L113-L120 |
hawkular/hawkular-inventory | hawkular-inventory-api/src/main/java/org/hawkular/inventory/base/Fetcher.java | Fetcher.loadEntities | protected <T> Page<T> loadEntities(Pager pager, EntityConvertor<BE, E, T> conversionFunction) {
"""
Loads the entities given the pager and converts them using the provided conversion function to the desired type.
<p>Note that the conversion function accepts both the backend entity and the converted entity because both
of them are required anyway during the loading and thus the function can choose which one to use without any
additional conversion cost.
@param pager the pager specifying the page of the data to load
@param conversionFunction the conversion function to convert to the desired target type
@param <T> the desired target type of the elements of the returned page
@return the page of the results as specified by the pager
"""
return inCommittableTx(tx -> {
Function<BE, Pair<BE, E>> conversion =
(e) -> new Pair<>(e, tx.convert(e, context.entityClass));
Function<Pair<BE, E>, Boolean> filter = context.configuration.getResultFilter() == null ? null :
(p) -> context.configuration.getResultFilter().isApplicable(p.second);
Page<Pair<BE, E>> intermediate =
tx.<Pair<BE, E>>query(context.select().get(), pager, conversion, filter);
return new TransformingPage<Pair<BE, E>, T>(intermediate,
(p) -> conversionFunction.convert(p.first, p.second, tx)) {
@Override public void close() {
try {
tx.commit();
} catch (CommitFailureException e) {
throw new IllegalStateException("Failed to commit the read operation.", e);
}
super.close();
}
};
});
} | java | protected <T> Page<T> loadEntities(Pager pager, EntityConvertor<BE, E, T> conversionFunction) {
return inCommittableTx(tx -> {
Function<BE, Pair<BE, E>> conversion =
(e) -> new Pair<>(e, tx.convert(e, context.entityClass));
Function<Pair<BE, E>, Boolean> filter = context.configuration.getResultFilter() == null ? null :
(p) -> context.configuration.getResultFilter().isApplicable(p.second);
Page<Pair<BE, E>> intermediate =
tx.<Pair<BE, E>>query(context.select().get(), pager, conversion, filter);
return new TransformingPage<Pair<BE, E>, T>(intermediate,
(p) -> conversionFunction.convert(p.first, p.second, tx)) {
@Override public void close() {
try {
tx.commit();
} catch (CommitFailureException e) {
throw new IllegalStateException("Failed to commit the read operation.", e);
}
super.close();
}
};
});
} | [
"protected",
"<",
"T",
">",
"Page",
"<",
"T",
">",
"loadEntities",
"(",
"Pager",
"pager",
",",
"EntityConvertor",
"<",
"BE",
",",
"E",
",",
"T",
">",
"conversionFunction",
")",
"{",
"return",
"inCommittableTx",
"(",
"tx",
"->",
"{",
"Function",
"<",
"BE",
",",
"Pair",
"<",
"BE",
",",
"E",
">",
">",
"conversion",
"=",
"(",
"e",
")",
"-",
">",
"new",
"Pair",
"<>",
"(",
"e",
",",
"tx",
".",
"convert",
"(",
"e",
",",
"context",
".",
"entityClass",
")",
")",
";",
"Function",
"<",
"Pair",
"<",
"BE",
",",
"E",
">",
",",
"Boolean",
">",
"filter",
"=",
"context",
".",
"configuration",
".",
"getResultFilter",
"(",
")",
"==",
"null",
"?",
"null",
":",
"(",
"p",
")",
"-",
">",
"context",
".",
"configuration",
".",
"getResultFilter",
"(",
")",
".",
"isApplicable",
"(",
"p",
".",
"second",
")",
";",
"Page",
"<",
"Pair",
"<",
"BE",
",",
"E",
">",
">",
"intermediate",
"=",
"tx",
".",
"<",
"Pair",
"<",
"BE",
",",
"E",
">",
">",
"query",
"(",
"context",
".",
"select",
"(",
")",
".",
"get",
"(",
")",
",",
"pager",
",",
"conversion",
",",
"filter",
")",
";",
"return",
"new",
"TransformingPage",
"<",
"Pair",
"<",
"BE",
",",
"E",
">",
",",
"T",
">",
"(",
"intermediate",
",",
"(",
"p",
")",
"-",
">",
"conversionFunction",
".",
"convert",
"(",
"p",
".",
"first",
",",
"p",
".",
"second",
",",
"tx",
")",
")",
"{",
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"try",
"{",
"tx",
".",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"CommitFailureException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Failed to commit the read operation.\"",
",",
"e",
")",
";",
"}",
"super",
".",
"close",
"(",
")",
";",
"}",
"}",
";",
"}",
")",
";",
"}"
] | Loads the entities given the pager and converts them using the provided conversion function to the desired type.
<p>Note that the conversion function accepts both the backend entity and the converted entity because both
of them are required anyway during the loading and thus the function can choose which one to use without any
additional conversion cost.
@param pager the pager specifying the page of the data to load
@param conversionFunction the conversion function to convert to the desired target type
@param <T> the desired target type of the elements of the returned page
@return the page of the results as specified by the pager | [
"Loads",
"the",
"entities",
"given",
"the",
"pager",
"and",
"converts",
"them",
"using",
"the",
"provided",
"conversion",
"function",
"to",
"the",
"desired",
"type",
"."
] | train | https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/base/Fetcher.java#L170-L193 |
census-instrumentation/opencensus-java | api/src/main/java/io/opencensus/tags/TagContextBuilder.java | TagContextBuilder.putPropagating | public final TagContextBuilder putPropagating(TagKey key, TagValue value) {
"""
Adds an unlimited propagating tag to this {@code TagContextBuilder}.
<p>This is equivalent to calling {@code put(key, value,
TagMetadata.create(TagTtl.METADATA_UNLIMITED_PROPAGATION))}.
<p>Only call this method if you want propagating tags. If you want tags for breaking down
metrics, or there are sensitive messages in your tags, use {@link #putLocal(TagKey, TagValue)}
instead.
@param key the {@code TagKey} which will be set.
@param value the {@code TagValue} to set for the given key.
@return this
@since 0.21
"""
return put(key, value, METADATA_UNLIMITED_PROPAGATION);
} | java | public final TagContextBuilder putPropagating(TagKey key, TagValue value) {
return put(key, value, METADATA_UNLIMITED_PROPAGATION);
} | [
"public",
"final",
"TagContextBuilder",
"putPropagating",
"(",
"TagKey",
"key",
",",
"TagValue",
"value",
")",
"{",
"return",
"put",
"(",
"key",
",",
"value",
",",
"METADATA_UNLIMITED_PROPAGATION",
")",
";",
"}"
] | Adds an unlimited propagating tag to this {@code TagContextBuilder}.
<p>This is equivalent to calling {@code put(key, value,
TagMetadata.create(TagTtl.METADATA_UNLIMITED_PROPAGATION))}.
<p>Only call this method if you want propagating tags. If you want tags for breaking down
metrics, or there are sensitive messages in your tags, use {@link #putLocal(TagKey, TagValue)}
instead.
@param key the {@code TagKey} which will be set.
@param value the {@code TagValue} to set for the given key.
@return this
@since 0.21 | [
"Adds",
"an",
"unlimited",
"propagating",
"tag",
"to",
"this",
"{",
"@code",
"TagContextBuilder",
"}",
"."
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/api/src/main/java/io/opencensus/tags/TagContextBuilder.java#L97-L99 |
alibaba/otter | shared/arbitrate/src/main/java/com/alibaba/otter/shared/arbitrate/impl/zookeeper/ZooKeeperx.java | ZooKeeperx.createNoRetry | public String createNoRetry(final String path, final byte[] data, final CreateMode mode) throws KeeperException,
InterruptedException {
"""
add by ljh at 2012-09-13
<pre>
1. 使用zookeeper过程,针对出现ConnectionLoss异常,比如进行create/setData/delete,操作可能已经在zookeeper server上进行应用
2. 针对SelectStageListener进行processId创建时,会以最后一次创建的processId做为调度id. 如果进行retry,之前成功的processId就会被遗漏了
</pre>
@see org.apache.zookeeper.ZooKeeper#create(String path, byte[] path, List acl, CreateMode mode)
"""
return zookeeper.create(path, data, acl, mode);
} | java | public String createNoRetry(final String path, final byte[] data, final CreateMode mode) throws KeeperException,
InterruptedException {
return zookeeper.create(path, data, acl, mode);
} | [
"public",
"String",
"createNoRetry",
"(",
"final",
"String",
"path",
",",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"CreateMode",
"mode",
")",
"throws",
"KeeperException",
",",
"InterruptedException",
"{",
"return",
"zookeeper",
".",
"create",
"(",
"path",
",",
"data",
",",
"acl",
",",
"mode",
")",
";",
"}"
] | add by ljh at 2012-09-13
<pre>
1. 使用zookeeper过程,针对出现ConnectionLoss异常,比如进行create/setData/delete,操作可能已经在zookeeper server上进行应用
2. 针对SelectStageListener进行processId创建时,会以最后一次创建的processId做为调度id. 如果进行retry,之前成功的processId就会被遗漏了
</pre>
@see org.apache.zookeeper.ZooKeeper#create(String path, byte[] path, List acl, CreateMode mode) | [
"add",
"by",
"ljh",
"at",
"2012",
"-",
"09",
"-",
"13"
] | train | https://github.com/alibaba/otter/blob/c7b5f94a0dd162e01ddffaf3a63cade7d23fca55/shared/arbitrate/src/main/java/com/alibaba/otter/shared/arbitrate/impl/zookeeper/ZooKeeperx.java#L75-L78 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java | CssSkinGenerator.checkRootDirectoryNotOverlap | private void checkRootDirectoryNotOverlap(String dir, Set<String> skinRootDirectories) {
"""
Check if there are no directory which is contained in another root
directory,
@param dir
the root directory to check
@param skinRootDirectories
the root directories
"""
String rootDir = removeLocaleSuffixIfExist(dir);
for (Iterator<String> itSkinDir = skinRootDirectories.iterator(); itSkinDir.hasNext();) {
String skinDir = PathNormalizer.asDirPath(itSkinDir.next());
if (!skinDir.equals(dir)) {
skinDir = removeLocaleSuffixIfExist(skinDir);
if (skinDir.startsWith(rootDir)) {
throw new BundlingProcessException(
"There is a misconfiguration. It is not allowed to have a skin root directory containing another one.");
}
}
}
} | java | private void checkRootDirectoryNotOverlap(String dir, Set<String> skinRootDirectories) {
String rootDir = removeLocaleSuffixIfExist(dir);
for (Iterator<String> itSkinDir = skinRootDirectories.iterator(); itSkinDir.hasNext();) {
String skinDir = PathNormalizer.asDirPath(itSkinDir.next());
if (!skinDir.equals(dir)) {
skinDir = removeLocaleSuffixIfExist(skinDir);
if (skinDir.startsWith(rootDir)) {
throw new BundlingProcessException(
"There is a misconfiguration. It is not allowed to have a skin root directory containing another one.");
}
}
}
} | [
"private",
"void",
"checkRootDirectoryNotOverlap",
"(",
"String",
"dir",
",",
"Set",
"<",
"String",
">",
"skinRootDirectories",
")",
"{",
"String",
"rootDir",
"=",
"removeLocaleSuffixIfExist",
"(",
"dir",
")",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"itSkinDir",
"=",
"skinRootDirectories",
".",
"iterator",
"(",
")",
";",
"itSkinDir",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"skinDir",
"=",
"PathNormalizer",
".",
"asDirPath",
"(",
"itSkinDir",
".",
"next",
"(",
")",
")",
";",
"if",
"(",
"!",
"skinDir",
".",
"equals",
"(",
"dir",
")",
")",
"{",
"skinDir",
"=",
"removeLocaleSuffixIfExist",
"(",
"skinDir",
")",
";",
"if",
"(",
"skinDir",
".",
"startsWith",
"(",
"rootDir",
")",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"There is a misconfiguration. It is not allowed to have a skin root directory containing another one.\"",
")",
";",
"}",
"}",
"}",
"}"
] | Check if there are no directory which is contained in another root
directory,
@param dir
the root directory to check
@param skinRootDirectories
the root directories | [
"Check",
"if",
"there",
"are",
"no",
"directory",
"which",
"is",
"contained",
"in",
"another",
"root",
"directory"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L618-L631 |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newStatusUpdateRequest | public static Request newStatusUpdateRequest(Session session, String message, GraphPlace place,
List<GraphUser> tags, Callback callback) {
"""
Creates a new Request configured to post a status update to a user's feed.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param message
the text of the status update
@param place
an optional place to associate with the post
@param tags
an optional list of users to tag in the post
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute
"""
List<String> tagIds = null;
if (tags != null) {
tagIds = new ArrayList<String>(tags.size());
for (GraphUser tag: tags) {
tagIds.add(tag.getId());
}
}
String placeId = place == null ? null : place.getId();
return newStatusUpdateRequest(session, message, placeId, tagIds, callback);
} | java | public static Request newStatusUpdateRequest(Session session, String message, GraphPlace place,
List<GraphUser> tags, Callback callback) {
List<String> tagIds = null;
if (tags != null) {
tagIds = new ArrayList<String>(tags.size());
for (GraphUser tag: tags) {
tagIds.add(tag.getId());
}
}
String placeId = place == null ? null : place.getId();
return newStatusUpdateRequest(session, message, placeId, tagIds, callback);
} | [
"public",
"static",
"Request",
"newStatusUpdateRequest",
"(",
"Session",
"session",
",",
"String",
"message",
",",
"GraphPlace",
"place",
",",
"List",
"<",
"GraphUser",
">",
"tags",
",",
"Callback",
"callback",
")",
"{",
"List",
"<",
"String",
">",
"tagIds",
"=",
"null",
";",
"if",
"(",
"tags",
"!=",
"null",
")",
"{",
"tagIds",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"tags",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"GraphUser",
"tag",
":",
"tags",
")",
"{",
"tagIds",
".",
"add",
"(",
"tag",
".",
"getId",
"(",
")",
")",
";",
"}",
"}",
"String",
"placeId",
"=",
"place",
"==",
"null",
"?",
"null",
":",
"place",
".",
"getId",
"(",
")",
";",
"return",
"newStatusUpdateRequest",
"(",
"session",
",",
"message",
",",
"placeId",
",",
"tagIds",
",",
"callback",
")",
";",
"}"
] | Creates a new Request configured to post a status update to a user's feed.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param message
the text of the status update
@param place
an optional place to associate with the post
@param tags
an optional list of users to tag in the post
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"post",
"a",
"status",
"update",
"to",
"a",
"user",
"s",
"feed",
"."
] | train | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L492-L504 |
undertow-io/undertow | core/src/main/java/io/undertow/Handlers.java | Handlers.requestLimitingHandler | public static RequestLimitingHandler requestLimitingHandler(final int maxRequest, final int queueSize, HttpHandler next) {
"""
Returns a handler that limits the maximum number of requests that can run at a time.
@param maxRequest The maximum number of requests
@param queueSize The maximum number of queued requests
@param next The next handler
@return The handler
"""
return new RequestLimitingHandler(maxRequest, queueSize, next);
} | java | public static RequestLimitingHandler requestLimitingHandler(final int maxRequest, final int queueSize, HttpHandler next) {
return new RequestLimitingHandler(maxRequest, queueSize, next);
} | [
"public",
"static",
"RequestLimitingHandler",
"requestLimitingHandler",
"(",
"final",
"int",
"maxRequest",
",",
"final",
"int",
"queueSize",
",",
"HttpHandler",
"next",
")",
"{",
"return",
"new",
"RequestLimitingHandler",
"(",
"maxRequest",
",",
"queueSize",
",",
"next",
")",
";",
"}"
] | Returns a handler that limits the maximum number of requests that can run at a time.
@param maxRequest The maximum number of requests
@param queueSize The maximum number of queued requests
@param next The next handler
@return The handler | [
"Returns",
"a",
"handler",
"that",
"limits",
"the",
"maximum",
"number",
"of",
"requests",
"that",
"can",
"run",
"at",
"a",
"time",
"."
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/Handlers.java#L465-L467 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-default/src/main/java/org/xwiki/component/annotation/ComponentAnnotationLoader.java | ComponentAnnotationLoader.initialize | public void initialize(ComponentManager manager, ClassLoader classLoader) {
"""
Loads all components defined using annotations.
@param manager the component manager to use to dynamically register components
@param classLoader the classloader to use to look for the Component list declaration file (
{@code META-INF/components.txt})
"""
try {
// Find all declared components by retrieving the list defined in COMPONENT_LIST.
List<ComponentDeclaration> componentDeclarations = getDeclaredComponents(classLoader, COMPONENT_LIST);
// Find all the Component overrides and adds them to the bottom of the list as component declarations with
// the highest priority of 0. This is purely for backward compatibility since the override files is now
// deprecated.
List<ComponentDeclaration> componentOverrideDeclarations =
getDeclaredComponents(classLoader, COMPONENT_OVERRIDE_LIST);
for (ComponentDeclaration componentOverrideDeclaration : componentOverrideDeclarations) {
// Since the old way to declare an override was to define it in both a component.txt and a
// component-overrides.txt file we first need to remove the override component declaration stored in
// componentDeclarations.
componentDeclarations.remove(componentOverrideDeclaration);
// Add it to the end of the list with the highest priority.
componentDeclarations.add(new ComponentDeclaration(componentOverrideDeclaration
.getImplementationClassName(), 0));
}
initialize(manager, classLoader, componentDeclarations);
} catch (Exception e) {
// Make sure we make the calling code fail in order to fail fast and prevent the application to start
// if something is amiss.
throw new RuntimeException("Failed to get the list of components to load", e);
}
} | java | public void initialize(ComponentManager manager, ClassLoader classLoader)
{
try {
// Find all declared components by retrieving the list defined in COMPONENT_LIST.
List<ComponentDeclaration> componentDeclarations = getDeclaredComponents(classLoader, COMPONENT_LIST);
// Find all the Component overrides and adds them to the bottom of the list as component declarations with
// the highest priority of 0. This is purely for backward compatibility since the override files is now
// deprecated.
List<ComponentDeclaration> componentOverrideDeclarations =
getDeclaredComponents(classLoader, COMPONENT_OVERRIDE_LIST);
for (ComponentDeclaration componentOverrideDeclaration : componentOverrideDeclarations) {
// Since the old way to declare an override was to define it in both a component.txt and a
// component-overrides.txt file we first need to remove the override component declaration stored in
// componentDeclarations.
componentDeclarations.remove(componentOverrideDeclaration);
// Add it to the end of the list with the highest priority.
componentDeclarations.add(new ComponentDeclaration(componentOverrideDeclaration
.getImplementationClassName(), 0));
}
initialize(manager, classLoader, componentDeclarations);
} catch (Exception e) {
// Make sure we make the calling code fail in order to fail fast and prevent the application to start
// if something is amiss.
throw new RuntimeException("Failed to get the list of components to load", e);
}
} | [
"public",
"void",
"initialize",
"(",
"ComponentManager",
"manager",
",",
"ClassLoader",
"classLoader",
")",
"{",
"try",
"{",
"// Find all declared components by retrieving the list defined in COMPONENT_LIST.",
"List",
"<",
"ComponentDeclaration",
">",
"componentDeclarations",
"=",
"getDeclaredComponents",
"(",
"classLoader",
",",
"COMPONENT_LIST",
")",
";",
"// Find all the Component overrides and adds them to the bottom of the list as component declarations with",
"// the highest priority of 0. This is purely for backward compatibility since the override files is now",
"// deprecated.",
"List",
"<",
"ComponentDeclaration",
">",
"componentOverrideDeclarations",
"=",
"getDeclaredComponents",
"(",
"classLoader",
",",
"COMPONENT_OVERRIDE_LIST",
")",
";",
"for",
"(",
"ComponentDeclaration",
"componentOverrideDeclaration",
":",
"componentOverrideDeclarations",
")",
"{",
"// Since the old way to declare an override was to define it in both a component.txt and a",
"// component-overrides.txt file we first need to remove the override component declaration stored in",
"// componentDeclarations.",
"componentDeclarations",
".",
"remove",
"(",
"componentOverrideDeclaration",
")",
";",
"// Add it to the end of the list with the highest priority.",
"componentDeclarations",
".",
"add",
"(",
"new",
"ComponentDeclaration",
"(",
"componentOverrideDeclaration",
".",
"getImplementationClassName",
"(",
")",
",",
"0",
")",
")",
";",
"}",
"initialize",
"(",
"manager",
",",
"classLoader",
",",
"componentDeclarations",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Make sure we make the calling code fail in order to fail fast and prevent the application to start",
"// if something is amiss.",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to get the list of components to load\"",
",",
"e",
")",
";",
"}",
"}"
] | Loads all components defined using annotations.
@param manager the component manager to use to dynamically register components
@param classLoader the classloader to use to look for the Component list declaration file (
{@code META-INF/components.txt}) | [
"Loads",
"all",
"components",
"defined",
"using",
"annotations",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-default/src/main/java/org/xwiki/component/annotation/ComponentAnnotationLoader.java#L99-L126 |
perwendel/spark | src/main/java/spark/FilterImpl.java | FilterImpl.create | static FilterImpl create(final String path, final Filter filter) {
"""
Wraps the filter in FilterImpl
@param path the path
@param filter the filter
@return the wrapped route
"""
return create(path, DEFAULT_ACCEPT_TYPE, filter);
} | java | static FilterImpl create(final String path, final Filter filter) {
return create(path, DEFAULT_ACCEPT_TYPE, filter);
} | [
"static",
"FilterImpl",
"create",
"(",
"final",
"String",
"path",
",",
"final",
"Filter",
"filter",
")",
"{",
"return",
"create",
"(",
"path",
",",
"DEFAULT_ACCEPT_TYPE",
",",
"filter",
")",
";",
"}"
] | Wraps the filter in FilterImpl
@param path the path
@param filter the filter
@return the wrapped route | [
"Wraps",
"the",
"filter",
"in",
"FilterImpl"
] | train | https://github.com/perwendel/spark/blob/080fb1f9d6e580f6742e9589044c7420d3157b8b/src/main/java/spark/FilterImpl.java#L54-L56 |
apache/reef | lang/java/reef-bridge-client/src/main/java/org/apache/reef/bridge/client/YarnJobSubmissionClient.java | YarnJobSubmissionClient.logToken | private static void logToken(final Level logLevel, final String msgPrefix, final UserGroupInformation user) {
"""
Log all the tokens in the container for thr user.
@param logLevel - the log level.
@param msgPrefix - msg prefix for log.
@param user - the UserGroupInformation object.
"""
if (LOG.isLoggable(logLevel)) {
LOG.log(logLevel, "{0} number of tokens: [{1}].",
new Object[] {msgPrefix, user.getCredentials().numberOfTokens()});
for (final org.apache.hadoop.security.token.Token t : user.getCredentials().getAllTokens()) {
LOG.log(logLevel, "Token service: {0}, token kind: {1}.", new Object[] {t.getService(), t.getKind()});
}
}
} | java | private static void logToken(final Level logLevel, final String msgPrefix, final UserGroupInformation user) {
if (LOG.isLoggable(logLevel)) {
LOG.log(logLevel, "{0} number of tokens: [{1}].",
new Object[] {msgPrefix, user.getCredentials().numberOfTokens()});
for (final org.apache.hadoop.security.token.Token t : user.getCredentials().getAllTokens()) {
LOG.log(logLevel, "Token service: {0}, token kind: {1}.", new Object[] {t.getService(), t.getKind()});
}
}
} | [
"private",
"static",
"void",
"logToken",
"(",
"final",
"Level",
"logLevel",
",",
"final",
"String",
"msgPrefix",
",",
"final",
"UserGroupInformation",
"user",
")",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"logLevel",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"logLevel",
",",
"\"{0} number of tokens: [{1}].\"",
",",
"new",
"Object",
"[",
"]",
"{",
"msgPrefix",
",",
"user",
".",
"getCredentials",
"(",
")",
".",
"numberOfTokens",
"(",
")",
"}",
")",
";",
"for",
"(",
"final",
"org",
".",
"apache",
".",
"hadoop",
".",
"security",
".",
"token",
".",
"Token",
"t",
":",
"user",
".",
"getCredentials",
"(",
")",
".",
"getAllTokens",
"(",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"logLevel",
",",
"\"Token service: {0}, token kind: {1}.\"",
",",
"new",
"Object",
"[",
"]",
"{",
"t",
".",
"getService",
"(",
")",
",",
"t",
".",
"getKind",
"(",
")",
"}",
")",
";",
"}",
"}",
"}"
] | Log all the tokens in the container for thr user.
@param logLevel - the log level.
@param msgPrefix - msg prefix for log.
@param user - the UserGroupInformation object. | [
"Log",
"all",
"the",
"tokens",
"in",
"the",
"container",
"for",
"thr",
"user",
"."
] | train | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-bridge-client/src/main/java/org/apache/reef/bridge/client/YarnJobSubmissionClient.java#L229-L237 |
tvesalainen/util | util/src/main/java/org/vesalainen/code/PropertyDispatcher.java | PropertyDispatcher.getInstance | public static <T extends PropertyDispatcher> T getInstance(Class<T> cls, PropertySetterDispatcher dispatcher) {
"""
Creates a instance of a class PropertyDispatcher subclass.
@param <T> Type of PropertyDispatcher subclass
@param cls PropertyDispatcher subclass class
@param dispatcher
@return
"""
try
{
PropertyDispatcherClass annotation = cls.getAnnotation(PropertyDispatcherClass.class);
if (annotation == null)
{
throw new IllegalArgumentException("@"+PropertyDispatcherClass.class.getSimpleName()+" missing in cls");
}
Class<?> c = Class.forName(annotation.value());
if (dispatcher == null)
{
T t =(T) c.newInstance();
return t;
}
else
{
Constructor<?> constructor = c.getConstructor(PropertySetterDispatcher.class);
return (T) constructor.newInstance(dispatcher);
}
}
catch (InvocationTargetException | SecurityException | NoSuchMethodException | ClassNotFoundException | InstantiationException | IllegalAccessException ex)
{
throw new IllegalArgumentException(ex);
}
} | java | public static <T extends PropertyDispatcher> T getInstance(Class<T> cls, PropertySetterDispatcher dispatcher)
{
try
{
PropertyDispatcherClass annotation = cls.getAnnotation(PropertyDispatcherClass.class);
if (annotation == null)
{
throw new IllegalArgumentException("@"+PropertyDispatcherClass.class.getSimpleName()+" missing in cls");
}
Class<?> c = Class.forName(annotation.value());
if (dispatcher == null)
{
T t =(T) c.newInstance();
return t;
}
else
{
Constructor<?> constructor = c.getConstructor(PropertySetterDispatcher.class);
return (T) constructor.newInstance(dispatcher);
}
}
catch (InvocationTargetException | SecurityException | NoSuchMethodException | ClassNotFoundException | InstantiationException | IllegalAccessException ex)
{
throw new IllegalArgumentException(ex);
}
} | [
"public",
"static",
"<",
"T",
"extends",
"PropertyDispatcher",
">",
"T",
"getInstance",
"(",
"Class",
"<",
"T",
">",
"cls",
",",
"PropertySetterDispatcher",
"dispatcher",
")",
"{",
"try",
"{",
"PropertyDispatcherClass",
"annotation",
"=",
"cls",
".",
"getAnnotation",
"(",
"PropertyDispatcherClass",
".",
"class",
")",
";",
"if",
"(",
"annotation",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"@\"",
"+",
"PropertyDispatcherClass",
".",
"class",
".",
"getSimpleName",
"(",
")",
"+",
"\" missing in cls\"",
")",
";",
"}",
"Class",
"<",
"?",
">",
"c",
"=",
"Class",
".",
"forName",
"(",
"annotation",
".",
"value",
"(",
")",
")",
";",
"if",
"(",
"dispatcher",
"==",
"null",
")",
"{",
"T",
"t",
"=",
"(",
"T",
")",
"c",
".",
"newInstance",
"(",
")",
";",
"return",
"t",
";",
"}",
"else",
"{",
"Constructor",
"<",
"?",
">",
"constructor",
"=",
"c",
".",
"getConstructor",
"(",
"PropertySetterDispatcher",
".",
"class",
")",
";",
"return",
"(",
"T",
")",
"constructor",
".",
"newInstance",
"(",
"dispatcher",
")",
";",
"}",
"}",
"catch",
"(",
"InvocationTargetException",
"|",
"SecurityException",
"|",
"NoSuchMethodException",
"|",
"ClassNotFoundException",
"|",
"InstantiationException",
"|",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"ex",
")",
";",
"}",
"}"
] | Creates a instance of a class PropertyDispatcher subclass.
@param <T> Type of PropertyDispatcher subclass
@param cls PropertyDispatcher subclass class
@param dispatcher
@return | [
"Creates",
"a",
"instance",
"of",
"a",
"class",
"PropertyDispatcher",
"subclass",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/code/PropertyDispatcher.java#L196-L221 |
square/okhttp | okhttp/src/main/java/okhttp3/internal/connection/Transmitter.java | Transmitter.prepareToConnect | public void prepareToConnect(Request request) {
"""
Prepare to create a stream to carry {@code request}. This prefers to use the existing
connection if it exists.
"""
if (this.request != null) {
if (sameConnection(this.request.url(), request.url()) && exchangeFinder.hasRouteToTry()) {
return; // Already ready.
}
if (exchange != null) throw new IllegalStateException();
if (exchangeFinder != null) {
maybeReleaseConnection(null, true);
exchangeFinder = null;
}
}
this.request = request;
this.exchangeFinder = new ExchangeFinder(this, connectionPool, createAddress(request.url()),
call, eventListener);
} | java | public void prepareToConnect(Request request) {
if (this.request != null) {
if (sameConnection(this.request.url(), request.url()) && exchangeFinder.hasRouteToTry()) {
return; // Already ready.
}
if (exchange != null) throw new IllegalStateException();
if (exchangeFinder != null) {
maybeReleaseConnection(null, true);
exchangeFinder = null;
}
}
this.request = request;
this.exchangeFinder = new ExchangeFinder(this, connectionPool, createAddress(request.url()),
call, eventListener);
} | [
"public",
"void",
"prepareToConnect",
"(",
"Request",
"request",
")",
"{",
"if",
"(",
"this",
".",
"request",
"!=",
"null",
")",
"{",
"if",
"(",
"sameConnection",
"(",
"this",
".",
"request",
".",
"url",
"(",
")",
",",
"request",
".",
"url",
"(",
")",
")",
"&&",
"exchangeFinder",
".",
"hasRouteToTry",
"(",
")",
")",
"{",
"return",
";",
"// Already ready.",
"}",
"if",
"(",
"exchange",
"!=",
"null",
")",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"if",
"(",
"exchangeFinder",
"!=",
"null",
")",
"{",
"maybeReleaseConnection",
"(",
"null",
",",
"true",
")",
";",
"exchangeFinder",
"=",
"null",
";",
"}",
"}",
"this",
".",
"request",
"=",
"request",
";",
"this",
".",
"exchangeFinder",
"=",
"new",
"ExchangeFinder",
"(",
"this",
",",
"connectionPool",
",",
"createAddress",
"(",
"request",
".",
"url",
"(",
")",
")",
",",
"call",
",",
"eventListener",
")",
";",
"}"
] | Prepare to create a stream to carry {@code request}. This prefers to use the existing
connection if it exists. | [
"Prepare",
"to",
"create",
"a",
"stream",
"to",
"carry",
"{"
] | train | https://github.com/square/okhttp/blob/a8c65a822dd6cadd2de7d115bf94adf312e67868/okhttp/src/main/java/okhttp3/internal/connection/Transmitter.java#L124-L140 |
Subsets and Splits