repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
aws/aws-sdk-java | aws-java-sdk-pinpoint/src/main/java/com/amazonaws/services/pinpoint/model/SegmentDimensions.java | SegmentDimensions.withUserAttributes | public SegmentDimensions withUserAttributes(java.util.Map<String, AttributeDimension> userAttributes) {
"""
Custom segment user attributes.
@param userAttributes
Custom segment user attributes.
@return Returns a reference to this object so that method calls can be chained together.
"""
setUserAttributes(userAttributes);
return this;
} | java | public SegmentDimensions withUserAttributes(java.util.Map<String, AttributeDimension> userAttributes) {
setUserAttributes(userAttributes);
return this;
} | [
"public",
"SegmentDimensions",
"withUserAttributes",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"AttributeDimension",
">",
"userAttributes",
")",
"{",
"setUserAttributes",
"(",
"userAttributes",
")",
";",
"return",
"this",
";",
"}"
] | Custom segment user attributes.
@param userAttributes
Custom segment user attributes.
@return Returns a reference to this object so that method calls can be chained together. | [
"Custom",
"segment",
"user",
"attributes",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-pinpoint/src/main/java/com/amazonaws/services/pinpoint/model/SegmentDimensions.java#L283-L286 |
hawkular/hawkular-agent | hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java | JBossASClient.createRequest | public static ModelNode createRequest(String operation, Address address) {
"""
Convienence method that builds a partial operation request node.
@param operation the operation to be requested
@param address identifies the target resource
@return the partial operation request node - caller should fill this in further to complete the node
"""
return createRequest(operation, address, null);
} | java | public static ModelNode createRequest(String operation, Address address) {
return createRequest(operation, address, null);
} | [
"public",
"static",
"ModelNode",
"createRequest",
"(",
"String",
"operation",
",",
"Address",
"address",
")",
"{",
"return",
"createRequest",
"(",
"operation",
",",
"address",
",",
"null",
")",
";",
"}"
] | Convienence method that builds a partial operation request node.
@param operation the operation to be requested
@param address identifies the target resource
@return the partial operation request node - caller should fill this in further to complete the node | [
"Convienence",
"method",
"that",
"builds",
"a",
"partial",
"operation",
"request",
"node",
"."
] | train | https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java#L125-L127 |
Polidea/RxAndroidBle | rxandroidble/src/main/java/com/polidea/rxandroidble2/helpers/ValueInterpreter.java | ValueInterpreter.getStringValue | public static String getStringValue(@NonNull byte[] value, @IntRange(from = 0) int offset) {
"""
Return the string value interpreted from the passed byte array.
@param offset Offset at which the string value can be found.
@return The value at a given offset
"""
if (offset > value.length) {
RxBleLog.w("Passed offset that exceeds the length of the byte array - returning null");
return null;
}
byte[] strBytes = new byte[value.length - offset];
for (int i = 0; i != (value.length - offset); ++i) {
strBytes[i] = value[offset + i];
}
return new String(strBytes);
} | java | public static String getStringValue(@NonNull byte[] value, @IntRange(from = 0) int offset) {
if (offset > value.length) {
RxBleLog.w("Passed offset that exceeds the length of the byte array - returning null");
return null;
}
byte[] strBytes = new byte[value.length - offset];
for (int i = 0; i != (value.length - offset); ++i) {
strBytes[i] = value[offset + i];
}
return new String(strBytes);
} | [
"public",
"static",
"String",
"getStringValue",
"(",
"@",
"NonNull",
"byte",
"[",
"]",
"value",
",",
"@",
"IntRange",
"(",
"from",
"=",
"0",
")",
"int",
"offset",
")",
"{",
"if",
"(",
"offset",
">",
"value",
".",
"length",
")",
"{",
"RxBleLog",
".",
"w",
"(",
"\"Passed offset that exceeds the length of the byte array - returning null\"",
")",
";",
"return",
"null",
";",
"}",
"byte",
"[",
"]",
"strBytes",
"=",
"new",
"byte",
"[",
"value",
".",
"length",
"-",
"offset",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"!=",
"(",
"value",
".",
"length",
"-",
"offset",
")",
";",
"++",
"i",
")",
"{",
"strBytes",
"[",
"i",
"]",
"=",
"value",
"[",
"offset",
"+",
"i",
"]",
";",
"}",
"return",
"new",
"String",
"(",
"strBytes",
")",
";",
"}"
] | Return the string value interpreted from the passed byte array.
@param offset Offset at which the string value can be found.
@return The value at a given offset | [
"Return",
"the",
"string",
"value",
"interpreted",
"from",
"the",
"passed",
"byte",
"array",
"."
] | train | https://github.com/Polidea/RxAndroidBle/blob/c6e4a9753c834d710e255306bb290e9244cdbc10/rxandroidble/src/main/java/com/polidea/rxandroidble2/helpers/ValueInterpreter.java#L163-L173 |
dkpro/dkpro-jwpl | de.tudarmstadt.ukp.wikipedia.revisionmachine/src/main/java/de/tudarmstadt/ukp/wikipedia/revisionmachine/common/logging/messages/consumer/ConsumerLogMessages.java | ConsumerLogMessages.logException | public static void logException(final Logger logger, final Exception e) {
"""
Logs an exception.
@param logger
reference to the logger
@param e
reference to the exception
"""
logger.logException(Level.ERROR, "Unexpected Exception", e);
} | java | public static void logException(final Logger logger, final Exception e)
{
logger.logException(Level.ERROR, "Unexpected Exception", e);
} | [
"public",
"static",
"void",
"logException",
"(",
"final",
"Logger",
"logger",
",",
"final",
"Exception",
"e",
")",
"{",
"logger",
".",
"logException",
"(",
"Level",
".",
"ERROR",
",",
"\"Unexpected Exception\"",
",",
"e",
")",
";",
"}"
] | Logs an exception.
@param logger
reference to the logger
@param e
reference to the exception | [
"Logs",
"an",
"exception",
"."
] | train | https://github.com/dkpro/dkpro-jwpl/blob/0a0304b6a0aa13acc18838957994e06dd4613a58/de.tudarmstadt.ukp.wikipedia.revisionmachine/src/main/java/de/tudarmstadt/ukp/wikipedia/revisionmachine/common/logging/messages/consumer/ConsumerLogMessages.java#L67-L70 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java | AbstractExecutableMemberWriter.getErasureAnchor | protected String getErasureAnchor(ExecutableElement executableElement) {
"""
For backward compatibility, include an anchor using the erasures of the
parameters. NOTE: We won't need this method anymore after we fix
see tags so that they use the type instead of the erasure.
@param executableElement the ExecutableElement to anchor to.
@return the 1.4.x style anchor for the executable element.
"""
final StringBuilder buf = new StringBuilder(name(executableElement) + "(");
List<? extends VariableElement> parameters = executableElement.getParameters();
boolean foundTypeVariable = false;
for (int i = 0; i < parameters.size(); i++) {
if (i > 0) {
buf.append(",");
}
TypeMirror t = parameters.get(i).asType();
SimpleTypeVisitor9<Boolean, Void> stv = new SimpleTypeVisitor9<Boolean, Void>() {
boolean foundTypeVariable = false;
@Override
public Boolean visitArray(ArrayType t, Void p) {
visit(t.getComponentType());
buf.append(utils.getDimension(t));
return foundTypeVariable;
}
@Override
public Boolean visitTypeVariable(TypeVariable t, Void p) {
buf.append(utils.asTypeElement(t).getQualifiedName());
foundTypeVariable = true;
return foundTypeVariable;
}
@Override
public Boolean visitDeclared(DeclaredType t, Void p) {
buf.append(utils.getQualifiedTypeName(t));
return foundTypeVariable;
}
@Override
protected Boolean defaultAction(TypeMirror e, Void p) {
buf.append(e);
return foundTypeVariable;
}
};
boolean isTypeVariable = stv.visit(t);
if (!foundTypeVariable) {
foundTypeVariable = isTypeVariable;
}
}
buf.append(")");
return foundTypeVariable ? writer.getName(buf.toString()) : null;
} | java | protected String getErasureAnchor(ExecutableElement executableElement) {
final StringBuilder buf = new StringBuilder(name(executableElement) + "(");
List<? extends VariableElement> parameters = executableElement.getParameters();
boolean foundTypeVariable = false;
for (int i = 0; i < parameters.size(); i++) {
if (i > 0) {
buf.append(",");
}
TypeMirror t = parameters.get(i).asType();
SimpleTypeVisitor9<Boolean, Void> stv = new SimpleTypeVisitor9<Boolean, Void>() {
boolean foundTypeVariable = false;
@Override
public Boolean visitArray(ArrayType t, Void p) {
visit(t.getComponentType());
buf.append(utils.getDimension(t));
return foundTypeVariable;
}
@Override
public Boolean visitTypeVariable(TypeVariable t, Void p) {
buf.append(utils.asTypeElement(t).getQualifiedName());
foundTypeVariable = true;
return foundTypeVariable;
}
@Override
public Boolean visitDeclared(DeclaredType t, Void p) {
buf.append(utils.getQualifiedTypeName(t));
return foundTypeVariable;
}
@Override
protected Boolean defaultAction(TypeMirror e, Void p) {
buf.append(e);
return foundTypeVariable;
}
};
boolean isTypeVariable = stv.visit(t);
if (!foundTypeVariable) {
foundTypeVariable = isTypeVariable;
}
}
buf.append(")");
return foundTypeVariable ? writer.getName(buf.toString()) : null;
} | [
"protected",
"String",
"getErasureAnchor",
"(",
"ExecutableElement",
"executableElement",
")",
"{",
"final",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"name",
"(",
"executableElement",
")",
"+",
"\"(\"",
")",
";",
"List",
"<",
"?",
"extends",
"VariableElement",
">",
"parameters",
"=",
"executableElement",
".",
"getParameters",
"(",
")",
";",
"boolean",
"foundTypeVariable",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"parameters",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"buf",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"TypeMirror",
"t",
"=",
"parameters",
".",
"get",
"(",
"i",
")",
".",
"asType",
"(",
")",
";",
"SimpleTypeVisitor9",
"<",
"Boolean",
",",
"Void",
">",
"stv",
"=",
"new",
"SimpleTypeVisitor9",
"<",
"Boolean",
",",
"Void",
">",
"(",
")",
"{",
"boolean",
"foundTypeVariable",
"=",
"false",
";",
"@",
"Override",
"public",
"Boolean",
"visitArray",
"(",
"ArrayType",
"t",
",",
"Void",
"p",
")",
"{",
"visit",
"(",
"t",
".",
"getComponentType",
"(",
")",
")",
";",
"buf",
".",
"append",
"(",
"utils",
".",
"getDimension",
"(",
"t",
")",
")",
";",
"return",
"foundTypeVariable",
";",
"}",
"@",
"Override",
"public",
"Boolean",
"visitTypeVariable",
"(",
"TypeVariable",
"t",
",",
"Void",
"p",
")",
"{",
"buf",
".",
"append",
"(",
"utils",
".",
"asTypeElement",
"(",
"t",
")",
".",
"getQualifiedName",
"(",
")",
")",
";",
"foundTypeVariable",
"=",
"true",
";",
"return",
"foundTypeVariable",
";",
"}",
"@",
"Override",
"public",
"Boolean",
"visitDeclared",
"(",
"DeclaredType",
"t",
",",
"Void",
"p",
")",
"{",
"buf",
".",
"append",
"(",
"utils",
".",
"getQualifiedTypeName",
"(",
"t",
")",
")",
";",
"return",
"foundTypeVariable",
";",
"}",
"@",
"Override",
"protected",
"Boolean",
"defaultAction",
"(",
"TypeMirror",
"e",
",",
"Void",
"p",
")",
"{",
"buf",
".",
"append",
"(",
"e",
")",
";",
"return",
"foundTypeVariable",
";",
"}",
"}",
";",
"boolean",
"isTypeVariable",
"=",
"stv",
".",
"visit",
"(",
"t",
")",
";",
"if",
"(",
"!",
"foundTypeVariable",
")",
"{",
"foundTypeVariable",
"=",
"isTypeVariable",
";",
"}",
"}",
"buf",
".",
"append",
"(",
"\")\"",
")",
";",
"return",
"foundTypeVariable",
"?",
"writer",
".",
"getName",
"(",
"buf",
".",
"toString",
"(",
")",
")",
":",
"null",
";",
"}"
] | For backward compatibility, include an anchor using the erasures of the
parameters. NOTE: We won't need this method anymore after we fix
see tags so that they use the type instead of the erasure.
@param executableElement the ExecutableElement to anchor to.
@return the 1.4.x style anchor for the executable element. | [
"For",
"backward",
"compatibility",
"include",
"an",
"anchor",
"using",
"the",
"erasures",
"of",
"the",
"parameters",
".",
"NOTE",
":",
"We",
"won",
"t",
"need",
"this",
"method",
"anymore",
"after",
"we",
"fix",
"see",
"tags",
"so",
"that",
"they",
"use",
"the",
"type",
"instead",
"of",
"the",
"erasure",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java#L304-L350 |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/BlockLeaf.java | BlockLeaf.writeCheckpointFull | void writeCheckpointFull(OutputStream os, int rowHead)
throws IOException {
"""
Writes the block to the checkpoint stream.
Because of timing, the requested rowHead might be for an older
checkpoint of the block, if new rows have arrived since the request.
<pre><code>
b16 - inline blob length (blobTail)
<n> - inline blob data
b16 - row data length (block_size - row_head)
<m> - row data
</code></pre>
@param rowHead the requested row head
"""
BitsUtil.writeInt16(os, _blobTail);
os.write(_buffer, 0, _blobTail);
rowHead = Math.max(rowHead, _rowHead);
int rowLength = _buffer.length - rowHead;
BitsUtil.writeInt16(os, rowLength);
os.write(_buffer, rowHead, rowLength);
} | java | void writeCheckpointFull(OutputStream os, int rowHead)
throws IOException
{
BitsUtil.writeInt16(os, _blobTail);
os.write(_buffer, 0, _blobTail);
rowHead = Math.max(rowHead, _rowHead);
int rowLength = _buffer.length - rowHead;
BitsUtil.writeInt16(os, rowLength);
os.write(_buffer, rowHead, rowLength);
} | [
"void",
"writeCheckpointFull",
"(",
"OutputStream",
"os",
",",
"int",
"rowHead",
")",
"throws",
"IOException",
"{",
"BitsUtil",
".",
"writeInt16",
"(",
"os",
",",
"_blobTail",
")",
";",
"os",
".",
"write",
"(",
"_buffer",
",",
"0",
",",
"_blobTail",
")",
";",
"rowHead",
"=",
"Math",
".",
"max",
"(",
"rowHead",
",",
"_rowHead",
")",
";",
"int",
"rowLength",
"=",
"_buffer",
".",
"length",
"-",
"rowHead",
";",
"BitsUtil",
".",
"writeInt16",
"(",
"os",
",",
"rowLength",
")",
";",
"os",
".",
"write",
"(",
"_buffer",
",",
"rowHead",
",",
"rowLength",
")",
";",
"}"
] | Writes the block to the checkpoint stream.
Because of timing, the requested rowHead might be for an older
checkpoint of the block, if new rows have arrived since the request.
<pre><code>
b16 - inline blob length (blobTail)
<n> - inline blob data
b16 - row data length (block_size - row_head)
<m> - row data
</code></pre>
@param rowHead the requested row head | [
"Writes",
"the",
"block",
"to",
"the",
"checkpoint",
"stream",
"."
] | train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/BlockLeaf.java#L698-L710 |
hypercube1024/firefly | firefly-db/src/main/java/com/firefly/db/init/ScriptUtils.java | ScriptUtils.readScript | public static String readScript(LineNumberReader lineNumberReader, String commentPrefix, String separator)
throws IOException {
"""
Read a script from the provided {@code LineNumberReader}, using the
supplied comment prefix and statement separator, and build a
{@code String} containing the lines.
<p>
Lines <em>beginning</em> with the comment prefix are excluded from the
results; however, line comments anywhere else — for example, within
a statement — will be included in the results.
@param lineNumberReader the {@code LineNumberReader} containing the script to be
processed
@param commentPrefix the prefix that identifies comments in the SQL script —
typically "--"
@param separator the statement separator in the SQL script — typically
";"
@return a {@code String} containing the script lines
@throws IOException in case of I/O errors
"""
String currentStatement = lineNumberReader.readLine();
StringBuilder scriptBuilder = new StringBuilder();
while (currentStatement != null) {
if (commentPrefix != null && !currentStatement.startsWith(commentPrefix)) {
if (scriptBuilder.length() > 0) {
scriptBuilder.append('\n');
}
scriptBuilder.append(currentStatement);
}
currentStatement = lineNumberReader.readLine();
}
appendSeparatorToScriptIfNecessary(scriptBuilder, separator);
return scriptBuilder.toString();
} | java | public static String readScript(LineNumberReader lineNumberReader, String commentPrefix, String separator)
throws IOException {
String currentStatement = lineNumberReader.readLine();
StringBuilder scriptBuilder = new StringBuilder();
while (currentStatement != null) {
if (commentPrefix != null && !currentStatement.startsWith(commentPrefix)) {
if (scriptBuilder.length() > 0) {
scriptBuilder.append('\n');
}
scriptBuilder.append(currentStatement);
}
currentStatement = lineNumberReader.readLine();
}
appendSeparatorToScriptIfNecessary(scriptBuilder, separator);
return scriptBuilder.toString();
} | [
"public",
"static",
"String",
"readScript",
"(",
"LineNumberReader",
"lineNumberReader",
",",
"String",
"commentPrefix",
",",
"String",
"separator",
")",
"throws",
"IOException",
"{",
"String",
"currentStatement",
"=",
"lineNumberReader",
".",
"readLine",
"(",
")",
";",
"StringBuilder",
"scriptBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"currentStatement",
"!=",
"null",
")",
"{",
"if",
"(",
"commentPrefix",
"!=",
"null",
"&&",
"!",
"currentStatement",
".",
"startsWith",
"(",
"commentPrefix",
")",
")",
"{",
"if",
"(",
"scriptBuilder",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"scriptBuilder",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"scriptBuilder",
".",
"append",
"(",
"currentStatement",
")",
";",
"}",
"currentStatement",
"=",
"lineNumberReader",
".",
"readLine",
"(",
")",
";",
"}",
"appendSeparatorToScriptIfNecessary",
"(",
"scriptBuilder",
",",
"separator",
")",
";",
"return",
"scriptBuilder",
".",
"toString",
"(",
")",
";",
"}"
] | Read a script from the provided {@code LineNumberReader}, using the
supplied comment prefix and statement separator, and build a
{@code String} containing the lines.
<p>
Lines <em>beginning</em> with the comment prefix are excluded from the
results; however, line comments anywhere else — for example, within
a statement — will be included in the results.
@param lineNumberReader the {@code LineNumberReader} containing the script to be
processed
@param commentPrefix the prefix that identifies comments in the SQL script —
typically "--"
@param separator the statement separator in the SQL script — typically
";"
@return a {@code String} containing the script lines
@throws IOException in case of I/O errors | [
"Read",
"a",
"script",
"from",
"the",
"provided",
"{",
"@code",
"LineNumberReader",
"}",
"using",
"the",
"supplied",
"comment",
"prefix",
"and",
"statement",
"separator",
"and",
"build",
"a",
"{",
"@code",
"String",
"}",
"containing",
"the",
"lines",
".",
"<p",
">",
"Lines",
"<em",
">",
"beginning<",
"/",
"em",
">",
"with",
"the",
"comment",
"prefix",
"are",
"excluded",
"from",
"the",
"results",
";",
"however",
"line",
"comments",
"anywhere",
"else",
"&mdash",
";",
"for",
"example",
"within",
"a",
"statement",
"&mdash",
";",
"will",
"be",
"included",
"in",
"the",
"results",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-db/src/main/java/com/firefly/db/init/ScriptUtils.java#L295-L311 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java | VirtualNetworkGatewaysInner.getByResourceGroupAsync | public Observable<VirtualNetworkGatewayInner> getByResourceGroupAsync(String resourceGroupName, String virtualNetworkGatewayName) {
"""
Gets the specified virtual network gateway by resource group.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualNetworkGatewayInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).map(new Func1<ServiceResponse<VirtualNetworkGatewayInner>, VirtualNetworkGatewayInner>() {
@Override
public VirtualNetworkGatewayInner call(ServiceResponse<VirtualNetworkGatewayInner> response) {
return response.body();
}
});
} | java | public Observable<VirtualNetworkGatewayInner> getByResourceGroupAsync(String resourceGroupName, String virtualNetworkGatewayName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).map(new Func1<ServiceResponse<VirtualNetworkGatewayInner>, VirtualNetworkGatewayInner>() {
@Override
public VirtualNetworkGatewayInner call(ServiceResponse<VirtualNetworkGatewayInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"VirtualNetworkGatewayInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"VirtualNetworkGatewayInner",
">",
",",
"VirtualNetworkGatewayInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"VirtualNetworkGatewayInner",
"call",
"(",
"ServiceResponse",
"<",
"VirtualNetworkGatewayInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the specified virtual network gateway by resource group.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualNetworkGatewayInner object | [
"Gets",
"the",
"specified",
"virtual",
"network",
"gateway",
"by",
"resource",
"group",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java#L401-L408 |
micronaut-projects/micronaut-core | inject/src/main/java/io/micronaut/context/env/PropertySourcePropertyResolver.java | PropertySourcePropertyResolver.addPropertySource | public PropertySourcePropertyResolver addPropertySource(String name, @Nullable Map<String, ? super Object> values) {
"""
Add a property source for the given map.
@param name The name of the property source
@param values The values
@return This environment
"""
if (CollectionUtils.isNotEmpty(values)) {
return addPropertySource(PropertySource.of(name, values));
}
return this;
} | java | public PropertySourcePropertyResolver addPropertySource(String name, @Nullable Map<String, ? super Object> values) {
if (CollectionUtils.isNotEmpty(values)) {
return addPropertySource(PropertySource.of(name, values));
}
return this;
} | [
"public",
"PropertySourcePropertyResolver",
"addPropertySource",
"(",
"String",
"name",
",",
"@",
"Nullable",
"Map",
"<",
"String",
",",
"?",
"super",
"Object",
">",
"values",
")",
"{",
"if",
"(",
"CollectionUtils",
".",
"isNotEmpty",
"(",
"values",
")",
")",
"{",
"return",
"addPropertySource",
"(",
"PropertySource",
".",
"of",
"(",
"name",
",",
"values",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Add a property source for the given map.
@param name The name of the property source
@param values The values
@return This environment | [
"Add",
"a",
"property",
"source",
"for",
"the",
"given",
"map",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/inject/src/main/java/io/micronaut/context/env/PropertySourcePropertyResolver.java#L119-L124 |
digipost/sdp-shared | api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java | Wss4jInterceptor.checkResults | protected void checkResults(final List<WSSecurityEngineResult> results, final List<Integer> validationActions) throws Wss4jSecurityValidationException {
"""
Checks whether the received headers match the configured validation actions. Subclasses could override this method
for custom verification behavior.
@param results the results of the validation function
@param validationActions the decoded validation actions
@throws Wss4jSecurityValidationException if the results are deemed invalid
"""
if (!handler.checkReceiverResultsAnyOrder(results, validationActions)) {
throw new Wss4jSecurityValidationException("Security processing failed (actions mismatch)");
}
} | java | protected void checkResults(final List<WSSecurityEngineResult> results, final List<Integer> validationActions) throws Wss4jSecurityValidationException {
if (!handler.checkReceiverResultsAnyOrder(results, validationActions)) {
throw new Wss4jSecurityValidationException("Security processing failed (actions mismatch)");
}
} | [
"protected",
"void",
"checkResults",
"(",
"final",
"List",
"<",
"WSSecurityEngineResult",
">",
"results",
",",
"final",
"List",
"<",
"Integer",
">",
"validationActions",
")",
"throws",
"Wss4jSecurityValidationException",
"{",
"if",
"(",
"!",
"handler",
".",
"checkReceiverResultsAnyOrder",
"(",
"results",
",",
"validationActions",
")",
")",
"{",
"throw",
"new",
"Wss4jSecurityValidationException",
"(",
"\"Security processing failed (actions mismatch)\"",
")",
";",
"}",
"}"
] | Checks whether the received headers match the configured validation actions. Subclasses could override this method
for custom verification behavior.
@param results the results of the validation function
@param validationActions the decoded validation actions
@throws Wss4jSecurityValidationException if the results are deemed invalid | [
"Checks",
"whether",
"the",
"received",
"headers",
"match",
"the",
"configured",
"validation",
"actions",
".",
"Subclasses",
"could",
"override",
"this",
"method",
"for",
"custom",
"verification",
"behavior",
"."
] | train | https://github.com/digipost/sdp-shared/blob/c34920a993b65ff0908dab9d9c92140ded7312bc/api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java#L409-L413 |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java | IntegerExtensions.shiftLeft | @Pure
@Inline(value="($1 << $2)", constantExpression=true)
@Deprecated
public static int shiftLeft(int a, int distance) {
"""
The binary <code>signed left shift</code> operator. This is the equivalent to the java <code><<</code> operator.
Fills in a zero as the least significant bit.
@param a
an integer.
@param distance
the number of times to shift.
@return <code>a<<distance</code>
@deprecated use {@link #operator_doubleLessThan(int, int)} instead
"""
return a << distance;
} | java | @Pure
@Inline(value="($1 << $2)", constantExpression=true)
@Deprecated
public static int shiftLeft(int a, int distance) {
return a << distance;
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"($1 << $2)\"",
",",
"constantExpression",
"=",
"true",
")",
"@",
"Deprecated",
"public",
"static",
"int",
"shiftLeft",
"(",
"int",
"a",
",",
"int",
"distance",
")",
"{",
"return",
"a",
"<<",
"distance",
";",
"}"
] | The binary <code>signed left shift</code> operator. This is the equivalent to the java <code><<</code> operator.
Fills in a zero as the least significant bit.
@param a
an integer.
@param distance
the number of times to shift.
@return <code>a<<distance</code>
@deprecated use {@link #operator_doubleLessThan(int, int)} instead | [
"The",
"binary",
"<code",
">",
"signed",
"left",
"shift<",
"/",
"code",
">",
"operator",
".",
"This",
"is",
"the",
"equivalent",
"to",
"the",
"java",
"<code",
">",
"<",
";",
"<",
";",
"<",
"/",
"code",
">",
"operator",
".",
"Fills",
"in",
"a",
"zero",
"as",
"the",
"least",
"significant",
"bit",
"."
] | train | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java#L136-L141 |
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.deleteIterationAsync | public Observable<Void> deleteIterationAsync(UUID projectId, UUID iterationId) {
"""
Delete a specific iteration of a project.
@param projectId The project id
@param iterationId The iteration id
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return deleteIterationWithServiceResponseAsync(projectId, iterationId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> deleteIterationAsync(UUID projectId, UUID iterationId) {
return deleteIterationWithServiceResponseAsync(projectId, iterationId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"deleteIterationAsync",
"(",
"UUID",
"projectId",
",",
"UUID",
"iterationId",
")",
"{",
"return",
"deleteIterationWithServiceResponseAsync",
"(",
"projectId",
",",
"iterationId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Delete a specific iteration of a project.
@param projectId The project id
@param iterationId The iteration id
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Delete",
"a",
"specific",
"iteration",
"of",
"a",
"project",
"."
] | 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#L1906-L1913 |
to2mbn/JMCCC | jmccc/src/main/java/org/to2mbn/jmccc/internal/org/json/JSONObject.java | JSONObject.optBigDecimal | public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) {
"""
Get an optional BigDecimal associated with a key, or the defaultValue if
there is no such key or if its value is not a number. If the value is a
string, an attempt will be made to evaluate it as a number.
@param key A key string.
@param defaultValue The default.
@return An object which is the value.
"""
try {
return this.getBigDecimal(key);
} catch (Exception e) {
return defaultValue;
}
} | java | public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) {
try {
return this.getBigDecimal(key);
} catch (Exception e) {
return defaultValue;
}
} | [
"public",
"BigDecimal",
"optBigDecimal",
"(",
"String",
"key",
",",
"BigDecimal",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"this",
".",
"getBigDecimal",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] | Get an optional BigDecimal associated with a key, or the defaultValue if
there is no such key or if its value is not a number. If the value is a
string, an attempt will be made to evaluate it as a number.
@param key A key string.
@param defaultValue The default.
@return An object which is the value. | [
"Get",
"an",
"optional",
"BigDecimal",
"associated",
"with",
"a",
"key",
"or",
"the",
"defaultValue",
"if",
"there",
"is",
"no",
"such",
"key",
"or",
"if",
"its",
"value",
"is",
"not",
"a",
"number",
".",
"If",
"the",
"value",
"is",
"a",
"string",
"an",
"attempt",
"will",
"be",
"made",
"to",
"evaluate",
"it",
"as",
"a",
"number",
"."
] | train | https://github.com/to2mbn/JMCCC/blob/17e5b1b56ff18255cfd60976dca1a24598946647/jmccc/src/main/java/org/to2mbn/jmccc/internal/org/json/JSONObject.java#L863-L869 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache.monitor/src/com/ibm/ws/cache/stat/internal/CacheStatsModule.java | CacheStatsModule.updateCacheSizes | public void updateCacheSizes(long max, long current) {
"""
Updates statistics using two supplied arguments - maxInMemoryCacheSize and currentInMemoryCacheSize.
@param max
Maximum # of entries that can be stored in memory
@param current
Current # of in memory cache entries
"""
final String methodName = "updateCacheSizes()";
if (tc.isDebugEnabled() && null != _maxInMemoryCacheEntryCount && null != _inMemoryCacheEntryCount) {
if (max != _maxInMemoryCacheEntryCount.getCount() && _inMemoryCacheEntryCount.getCount() != current)
Tr.debug(tc, methodName + " cacheName=" + _sCacheName + " max=" + max + " current=" + current + " enable=" + this._enable, this);
}
if (_enable) {
if (_maxInMemoryCacheEntryCount != null)
_maxInMemoryCacheEntryCount.setCount(max);
if (_inMemoryCacheEntryCount != null)
_inMemoryCacheEntryCount.setCount(current);
}
} | java | public void updateCacheSizes(long max, long current) {
final String methodName = "updateCacheSizes()";
if (tc.isDebugEnabled() && null != _maxInMemoryCacheEntryCount && null != _inMemoryCacheEntryCount) {
if (max != _maxInMemoryCacheEntryCount.getCount() && _inMemoryCacheEntryCount.getCount() != current)
Tr.debug(tc, methodName + " cacheName=" + _sCacheName + " max=" + max + " current=" + current + " enable=" + this._enable, this);
}
if (_enable) {
if (_maxInMemoryCacheEntryCount != null)
_maxInMemoryCacheEntryCount.setCount(max);
if (_inMemoryCacheEntryCount != null)
_inMemoryCacheEntryCount.setCount(current);
}
} | [
"public",
"void",
"updateCacheSizes",
"(",
"long",
"max",
",",
"long",
"current",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"updateCacheSizes()\"",
";",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
"&&",
"null",
"!=",
"_maxInMemoryCacheEntryCount",
"&&",
"null",
"!=",
"_inMemoryCacheEntryCount",
")",
"{",
"if",
"(",
"max",
"!=",
"_maxInMemoryCacheEntryCount",
".",
"getCount",
"(",
")",
"&&",
"_inMemoryCacheEntryCount",
".",
"getCount",
"(",
")",
"!=",
"current",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"methodName",
"+",
"\" cacheName=\"",
"+",
"_sCacheName",
"+",
"\" max=\"",
"+",
"max",
"+",
"\" current=\"",
"+",
"current",
"+",
"\" enable=\"",
"+",
"this",
".",
"_enable",
",",
"this",
")",
";",
"}",
"if",
"(",
"_enable",
")",
"{",
"if",
"(",
"_maxInMemoryCacheEntryCount",
"!=",
"null",
")",
"_maxInMemoryCacheEntryCount",
".",
"setCount",
"(",
"max",
")",
";",
"if",
"(",
"_inMemoryCacheEntryCount",
"!=",
"null",
")",
"_inMemoryCacheEntryCount",
".",
"setCount",
"(",
"current",
")",
";",
"}",
"}"
] | Updates statistics using two supplied arguments - maxInMemoryCacheSize and currentInMemoryCacheSize.
@param max
Maximum # of entries that can be stored in memory
@param current
Current # of in memory cache entries | [
"Updates",
"statistics",
"using",
"two",
"supplied",
"arguments",
"-",
"maxInMemoryCacheSize",
"and",
"currentInMemoryCacheSize",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache.monitor/src/com/ibm/ws/cache/stat/internal/CacheStatsModule.java#L635-L651 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jpa.container.core/src/com/ibm/ws/jpa/management/JPAExEntityManager.java | JPAExEntityManager.parentHasSameExPc | private static final boolean parentHasSameExPc(JPAPuId parentPuIds[], JPAPuId puId) {
"""
Returns true if the caller and callee have declared the same @ PersistneceContext
in their components.
"""
for (JPAPuId parentPuId : parentPuIds)
{
if (parentPuId.equals(puId))
{
return true;
}
}
return false;
} | java | private static final boolean parentHasSameExPc(JPAPuId parentPuIds[], JPAPuId puId)
{
for (JPAPuId parentPuId : parentPuIds)
{
if (parentPuId.equals(puId))
{
return true;
}
}
return false;
} | [
"private",
"static",
"final",
"boolean",
"parentHasSameExPc",
"(",
"JPAPuId",
"parentPuIds",
"[",
"]",
",",
"JPAPuId",
"puId",
")",
"{",
"for",
"(",
"JPAPuId",
"parentPuId",
":",
"parentPuIds",
")",
"{",
"if",
"(",
"parentPuId",
".",
"equals",
"(",
"puId",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if the caller and callee have declared the same @ PersistneceContext
in their components. | [
"Returns",
"true",
"if",
"the",
"caller",
"and",
"callee",
"have",
"declared",
"the",
"same"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jpa.container.core/src/com/ibm/ws/jpa/management/JPAExEntityManager.java#L762-L772 |
Polidea/RxAndroidBle | rxandroidble/src/main/java/com/polidea/rxandroidble2/helpers/ValueInterpreter.java | ValueInterpreter.getFloatValue | public static Float getFloatValue(@NonNull byte[] value, @FloatFormatType int formatType, @IntRange(from = 0) int offset) {
"""
Return the float value interpreted from the passed byte array.
@param value The byte array from which to interpret value.
@param formatType The format type used to interpret the value.
@param offset Offset at which the float value can be found.
@return The value at a given offset or null if the requested offset exceeds the value size.
"""
if ((offset + getTypeLen(formatType)) > value.length) {
RxBleLog.w(
"Float formatType (0x%x) is longer than remaining bytes (%d) - returning null", formatType, value.length - offset
);
return null;
}
switch (formatType) {
case FORMAT_SFLOAT:
return bytesToFloat(value[offset], value[offset + 1]);
case FORMAT_FLOAT:
return bytesToFloat(value[offset], value[offset + 1],
value[offset + 2], value[offset + 3]);
default:
RxBleLog.w("Passed an invalid float formatType (0x%x) - returning null", formatType);
return null;
}
} | java | public static Float getFloatValue(@NonNull byte[] value, @FloatFormatType int formatType, @IntRange(from = 0) int offset) {
if ((offset + getTypeLen(formatType)) > value.length) {
RxBleLog.w(
"Float formatType (0x%x) is longer than remaining bytes (%d) - returning null", formatType, value.length - offset
);
return null;
}
switch (formatType) {
case FORMAT_SFLOAT:
return bytesToFloat(value[offset], value[offset + 1]);
case FORMAT_FLOAT:
return bytesToFloat(value[offset], value[offset + 1],
value[offset + 2], value[offset + 3]);
default:
RxBleLog.w("Passed an invalid float formatType (0x%x) - returning null", formatType);
return null;
}
} | [
"public",
"static",
"Float",
"getFloatValue",
"(",
"@",
"NonNull",
"byte",
"[",
"]",
"value",
",",
"@",
"FloatFormatType",
"int",
"formatType",
",",
"@",
"IntRange",
"(",
"from",
"=",
"0",
")",
"int",
"offset",
")",
"{",
"if",
"(",
"(",
"offset",
"+",
"getTypeLen",
"(",
"formatType",
")",
")",
">",
"value",
".",
"length",
")",
"{",
"RxBleLog",
".",
"w",
"(",
"\"Float formatType (0x%x) is longer than remaining bytes (%d) - returning null\"",
",",
"formatType",
",",
"value",
".",
"length",
"-",
"offset",
")",
";",
"return",
"null",
";",
"}",
"switch",
"(",
"formatType",
")",
"{",
"case",
"FORMAT_SFLOAT",
":",
"return",
"bytesToFloat",
"(",
"value",
"[",
"offset",
"]",
",",
"value",
"[",
"offset",
"+",
"1",
"]",
")",
";",
"case",
"FORMAT_FLOAT",
":",
"return",
"bytesToFloat",
"(",
"value",
"[",
"offset",
"]",
",",
"value",
"[",
"offset",
"+",
"1",
"]",
",",
"value",
"[",
"offset",
"+",
"2",
"]",
",",
"value",
"[",
"offset",
"+",
"3",
"]",
")",
";",
"default",
":",
"RxBleLog",
".",
"w",
"(",
"\"Passed an invalid float formatType (0x%x) - returning null\"",
",",
"formatType",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Return the float value interpreted from the passed byte array.
@param value The byte array from which to interpret value.
@param formatType The format type used to interpret the value.
@param offset Offset at which the float value can be found.
@return The value at a given offset or null if the requested offset exceeds the value size. | [
"Return",
"the",
"float",
"value",
"interpreted",
"from",
"the",
"passed",
"byte",
"array",
"."
] | train | https://github.com/Polidea/RxAndroidBle/blob/c6e4a9753c834d710e255306bb290e9244cdbc10/rxandroidble/src/main/java/com/polidea/rxandroidble2/helpers/ValueInterpreter.java#L136-L155 |
apache/groovy | subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovydoc.java | Groovydoc.setPackagenames | public void setPackagenames(String packages) {
"""
Set the package names to be processed.
@param packages a comma separated list of packages specs
(may be wildcarded).
"""
StringTokenizer tok = new StringTokenizer(packages, ",");
while (tok.hasMoreTokens()) {
String packageName = tok.nextToken();
packageNames.add(packageName);
}
} | java | public void setPackagenames(String packages) {
StringTokenizer tok = new StringTokenizer(packages, ",");
while (tok.hasMoreTokens()) {
String packageName = tok.nextToken();
packageNames.add(packageName);
}
} | [
"public",
"void",
"setPackagenames",
"(",
"String",
"packages",
")",
"{",
"StringTokenizer",
"tok",
"=",
"new",
"StringTokenizer",
"(",
"packages",
",",
"\",\"",
")",
";",
"while",
"(",
"tok",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"packageName",
"=",
"tok",
".",
"nextToken",
"(",
")",
";",
"packageNames",
".",
"add",
"(",
"packageName",
")",
";",
"}",
"}"
] | Set the package names to be processed.
@param packages a comma separated list of packages specs
(may be wildcarded). | [
"Set",
"the",
"package",
"names",
"to",
"be",
"processed",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovydoc.java#L183-L189 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProjectConfig.java | FrameworkProjectConfig.mergeProjectProperties | public void mergeProjectProperties(final Properties properties, final Set<String> removePrefixes) {
"""
Update the project properties file by setting updating the given properties, and removing
any properties that have a prefix in the removePrefixes set
@param properties new properties to put in the file
@param removePrefixes prefixes of properties to remove from the file
"""
generateProjectPropertiesFile(getName(), propertyFile, true, properties, true, removePrefixes, false);
loadProperties();
} | java | public void mergeProjectProperties(final Properties properties, final Set<String> removePrefixes) {
generateProjectPropertiesFile(getName(), propertyFile, true, properties, true, removePrefixes, false);
loadProperties();
} | [
"public",
"void",
"mergeProjectProperties",
"(",
"final",
"Properties",
"properties",
",",
"final",
"Set",
"<",
"String",
">",
"removePrefixes",
")",
"{",
"generateProjectPropertiesFile",
"(",
"getName",
"(",
")",
",",
"propertyFile",
",",
"true",
",",
"properties",
",",
"true",
",",
"removePrefixes",
",",
"false",
")",
";",
"loadProperties",
"(",
")",
";",
"}"
] | Update the project properties file by setting updating the given properties, and removing
any properties that have a prefix in the removePrefixes set
@param properties new properties to put in the file
@param removePrefixes prefixes of properties to remove from the file | [
"Update",
"the",
"project",
"properties",
"file",
"by",
"setting",
"updating",
"the",
"given",
"properties",
"and",
"removing",
"any",
"properties",
"that",
"have",
"a",
"prefix",
"in",
"the",
"removePrefixes",
"set"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProjectConfig.java#L128-L131 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/mps/backup_policy.java | backup_policy.update | public static backup_policy update(nitro_service client, backup_policy resource) throws Exception {
"""
<pre>
Use this operation to modify the number of previous backups to retain.
</pre>
"""
resource.validate("modify");
return ((backup_policy[]) resource.update_resource(client))[0];
} | java | public static backup_policy update(nitro_service client, backup_policy resource) throws Exception
{
resource.validate("modify");
return ((backup_policy[]) resource.update_resource(client))[0];
} | [
"public",
"static",
"backup_policy",
"update",
"(",
"nitro_service",
"client",
",",
"backup_policy",
"resource",
")",
"throws",
"Exception",
"{",
"resource",
".",
"validate",
"(",
"\"modify\"",
")",
";",
"return",
"(",
"(",
"backup_policy",
"[",
"]",
")",
"resource",
".",
"update_resource",
"(",
"client",
")",
")",
"[",
"0",
"]",
";",
"}"
] | <pre>
Use this operation to modify the number of previous backups to retain.
</pre> | [
"<pre",
">",
"Use",
"this",
"operation",
"to",
"modify",
"the",
"number",
"of",
"previous",
"backups",
"to",
"retain",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/backup_policy.java#L115-L119 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/TransparentDataEncryptionsInner.java | TransparentDataEncryptionsInner.createOrUpdateAsync | public Observable<TransparentDataEncryptionInner> createOrUpdateAsync(String resourceGroupName, String serverName, String databaseName) {
"""
Creates or updates a database's transparent data encryption configuration.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database for which setting the transparent data encryption applies.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the TransparentDataEncryptionInner object
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName).map(new Func1<ServiceResponse<TransparentDataEncryptionInner>, TransparentDataEncryptionInner>() {
@Override
public TransparentDataEncryptionInner call(ServiceResponse<TransparentDataEncryptionInner> response) {
return response.body();
}
});
} | java | public Observable<TransparentDataEncryptionInner> createOrUpdateAsync(String resourceGroupName, String serverName, String databaseName) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName).map(new Func1<ServiceResponse<TransparentDataEncryptionInner>, TransparentDataEncryptionInner>() {
@Override
public TransparentDataEncryptionInner call(ServiceResponse<TransparentDataEncryptionInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"TransparentDataEncryptionInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"databaseName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"TransparentDataEncryptionInner",
">",
",",
"TransparentDataEncryptionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"TransparentDataEncryptionInner",
"call",
"(",
"ServiceResponse",
"<",
"TransparentDataEncryptionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates or updates a database's transparent data encryption configuration.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database for which setting the transparent data encryption applies.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the TransparentDataEncryptionInner object | [
"Creates",
"or",
"updates",
"a",
"database",
"s",
"transparent",
"data",
"encryption",
"configuration",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/TransparentDataEncryptionsInner.java#L105-L112 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/reflect/TypeUtility.java | TypeUtility.beginStringConversion | public static void beginStringConversion(Builder methodBuilder, ModelProperty property) {
"""
generate begin string to translate in code to used in content value or parameter need to be converted in string through String.valueOf
@param methodBuilder
the method builder
@param property
the property
"""
TypeName modelType = typeName(property.getElement().asType());
beginStringConversion(methodBuilder, modelType);
} | java | public static void beginStringConversion(Builder methodBuilder, ModelProperty property) {
TypeName modelType = typeName(property.getElement().asType());
beginStringConversion(methodBuilder, modelType);
} | [
"public",
"static",
"void",
"beginStringConversion",
"(",
"Builder",
"methodBuilder",
",",
"ModelProperty",
"property",
")",
"{",
"TypeName",
"modelType",
"=",
"typeName",
"(",
"property",
".",
"getElement",
"(",
")",
".",
"asType",
"(",
")",
")",
";",
"beginStringConversion",
"(",
"methodBuilder",
",",
"modelType",
")",
";",
"}"
] | generate begin string to translate in code to used in content value or parameter need to be converted in string through String.valueOf
@param methodBuilder
the method builder
@param property
the property | [
"generate",
"begin",
"string",
"to",
"translate",
"in",
"code",
"to",
"used",
"in",
"content",
"value",
"or",
"parameter",
"need",
"to",
"be",
"converted",
"in",
"string",
"through",
"String",
".",
"valueOf"
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/reflect/TypeUtility.java#L376-L380 |
Jasig/uPortal | uPortal-layout/uPortal-layout-impl/src/main/java/org/apereo/portal/layout/dlm/ParameterEditManager.java | ParameterEditManager.applyAndUpdateParmEditSet | static void applyAndUpdateParmEditSet(Document plf, Document ilf, IntegrationResult result) {
"""
Get the parm edit set if any from the plf and process each edit command removing any that
fail from the set so that the set is self cleaning.
@throws Exception
"""
Element pSet = null;
try {
pSet = getParmEditSet(plf, null, false);
} catch (Exception e) {
LOG.error("Exception occurred while getting user's DLM " + "paramter-edit-set.", e);
}
if (pSet == null) return;
NodeList edits = pSet.getChildNodes();
for (int i = edits.getLength() - 1; i >= 0; i--) {
if (applyEdit((Element) edits.item(i), ilf) == false) {
pSet.removeChild(edits.item(i));
result.setChangedPLF(true);
} else {
result.setChangedILF(true);
}
}
if (pSet.getChildNodes().getLength() == 0) {
plf.getDocumentElement().removeChild(pSet);
result.setChangedPLF(true);
}
} | java | static void applyAndUpdateParmEditSet(Document plf, Document ilf, IntegrationResult result) {
Element pSet = null;
try {
pSet = getParmEditSet(plf, null, false);
} catch (Exception e) {
LOG.error("Exception occurred while getting user's DLM " + "paramter-edit-set.", e);
}
if (pSet == null) return;
NodeList edits = pSet.getChildNodes();
for (int i = edits.getLength() - 1; i >= 0; i--) {
if (applyEdit((Element) edits.item(i), ilf) == false) {
pSet.removeChild(edits.item(i));
result.setChangedPLF(true);
} else {
result.setChangedILF(true);
}
}
if (pSet.getChildNodes().getLength() == 0) {
plf.getDocumentElement().removeChild(pSet);
result.setChangedPLF(true);
}
} | [
"static",
"void",
"applyAndUpdateParmEditSet",
"(",
"Document",
"plf",
",",
"Document",
"ilf",
",",
"IntegrationResult",
"result",
")",
"{",
"Element",
"pSet",
"=",
"null",
";",
"try",
"{",
"pSet",
"=",
"getParmEditSet",
"(",
"plf",
",",
"null",
",",
"false",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Exception occurred while getting user's DLM \"",
"+",
"\"paramter-edit-set.\"",
",",
"e",
")",
";",
"}",
"if",
"(",
"pSet",
"==",
"null",
")",
"return",
";",
"NodeList",
"edits",
"=",
"pSet",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"edits",
".",
"getLength",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"applyEdit",
"(",
"(",
"Element",
")",
"edits",
".",
"item",
"(",
"i",
")",
",",
"ilf",
")",
"==",
"false",
")",
"{",
"pSet",
".",
"removeChild",
"(",
"edits",
".",
"item",
"(",
"i",
")",
")",
";",
"result",
".",
"setChangedPLF",
"(",
"true",
")",
";",
"}",
"else",
"{",
"result",
".",
"setChangedILF",
"(",
"true",
")",
";",
"}",
"}",
"if",
"(",
"pSet",
".",
"getChildNodes",
"(",
")",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"{",
"plf",
".",
"getDocumentElement",
"(",
")",
".",
"removeChild",
"(",
"pSet",
")",
";",
"result",
".",
"setChangedPLF",
"(",
"true",
")",
";",
"}",
"}"
] | Get the parm edit set if any from the plf and process each edit command removing any that
fail from the set so that the set is self cleaning.
@throws Exception | [
"Get",
"the",
"parm",
"edit",
"set",
"if",
"any",
"from",
"the",
"plf",
"and",
"process",
"each",
"edit",
"command",
"removing",
"any",
"that",
"fail",
"from",
"the",
"set",
"so",
"that",
"the",
"set",
"is",
"self",
"cleaning",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-layout/uPortal-layout-impl/src/main/java/org/apereo/portal/layout/dlm/ParameterEditManager.java#L59-L85 |
mojohaus/webstart | webstart-maven-plugin/src/main/java/org/codehaus/mojo/webstart/sign/SignConfig.java | SignConfig.createSignRequest | public JarSignerRequest createSignRequest( File jarToSign, File signedJar )
throws MojoExecutionException {
"""
Creates a jarsigner request to do a sign operation.
@param jarToSign the location of the jar to sign
@param signedJar the optional location of the signed jar to produce (if not set, will use the original location)
@return the jarsigner request
@throws MojoExecutionException if something wrong occurs
"""
JarSignerSignRequest request = new JarSignerSignRequest();
request.setAlias( getAlias() );
request.setKeystore( getKeystore() );
request.setSigfile( getSigfile() );
request.setStoretype( getStoretype() );
request.setWorkingDirectory( workDirectory );
request.setMaxMemory( getMaxMemory() );
request.setVerbose( isVerbose() );
request.setArchive( jarToSign );
request.setSignedjar( signedJar );
request.setTsaLocation( getTsaLocation() );
request.setProviderArg( getProviderArg() );
request.setProviderClass( getProviderClass() );
// Special handling for passwords through the Maven Security Dispatcher
request.setKeypass( decrypt( keypass ) );
request.setStorepass( decrypt( storepass ) );
if ( !arguments.isEmpty() )
{
request.setArguments( arguments.toArray( new String[arguments.size()] ) );
}
return request;
} | java | public JarSignerRequest createSignRequest( File jarToSign, File signedJar )
throws MojoExecutionException
{
JarSignerSignRequest request = new JarSignerSignRequest();
request.setAlias( getAlias() );
request.setKeystore( getKeystore() );
request.setSigfile( getSigfile() );
request.setStoretype( getStoretype() );
request.setWorkingDirectory( workDirectory );
request.setMaxMemory( getMaxMemory() );
request.setVerbose( isVerbose() );
request.setArchive( jarToSign );
request.setSignedjar( signedJar );
request.setTsaLocation( getTsaLocation() );
request.setProviderArg( getProviderArg() );
request.setProviderClass( getProviderClass() );
// Special handling for passwords through the Maven Security Dispatcher
request.setKeypass( decrypt( keypass ) );
request.setStorepass( decrypt( storepass ) );
if ( !arguments.isEmpty() )
{
request.setArguments( arguments.toArray( new String[arguments.size()] ) );
}
return request;
} | [
"public",
"JarSignerRequest",
"createSignRequest",
"(",
"File",
"jarToSign",
",",
"File",
"signedJar",
")",
"throws",
"MojoExecutionException",
"{",
"JarSignerSignRequest",
"request",
"=",
"new",
"JarSignerSignRequest",
"(",
")",
";",
"request",
".",
"setAlias",
"(",
"getAlias",
"(",
")",
")",
";",
"request",
".",
"setKeystore",
"(",
"getKeystore",
"(",
")",
")",
";",
"request",
".",
"setSigfile",
"(",
"getSigfile",
"(",
")",
")",
";",
"request",
".",
"setStoretype",
"(",
"getStoretype",
"(",
")",
")",
";",
"request",
".",
"setWorkingDirectory",
"(",
"workDirectory",
")",
";",
"request",
".",
"setMaxMemory",
"(",
"getMaxMemory",
"(",
")",
")",
";",
"request",
".",
"setVerbose",
"(",
"isVerbose",
"(",
")",
")",
";",
"request",
".",
"setArchive",
"(",
"jarToSign",
")",
";",
"request",
".",
"setSignedjar",
"(",
"signedJar",
")",
";",
"request",
".",
"setTsaLocation",
"(",
"getTsaLocation",
"(",
")",
")",
";",
"request",
".",
"setProviderArg",
"(",
"getProviderArg",
"(",
")",
")",
";",
"request",
".",
"setProviderClass",
"(",
"getProviderClass",
"(",
")",
")",
";",
"// Special handling for passwords through the Maven Security Dispatcher",
"request",
".",
"setKeypass",
"(",
"decrypt",
"(",
"keypass",
")",
")",
";",
"request",
".",
"setStorepass",
"(",
"decrypt",
"(",
"storepass",
")",
")",
";",
"if",
"(",
"!",
"arguments",
".",
"isEmpty",
"(",
")",
")",
"{",
"request",
".",
"setArguments",
"(",
"arguments",
".",
"toArray",
"(",
"new",
"String",
"[",
"arguments",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}",
"return",
"request",
";",
"}"
] | Creates a jarsigner request to do a sign operation.
@param jarToSign the location of the jar to sign
@param signedJar the optional location of the signed jar to produce (if not set, will use the original location)
@return the jarsigner request
@throws MojoExecutionException if something wrong occurs | [
"Creates",
"a",
"jarsigner",
"request",
"to",
"do",
"a",
"sign",
"operation",
"."
] | train | https://github.com/mojohaus/webstart/blob/38fdd1d21f063f21716cfcd61ebeabd963487576/webstart-maven-plugin/src/main/java/org/codehaus/mojo/webstart/sign/SignConfig.java#L318-L345 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/FilesImpl.java | FilesImpl.listFromComputeNodeNext | public PagedList<NodeFile> listFromComputeNodeNext(final String nextPageLink, final FileListFromComputeNodeNextOptions fileListFromComputeNodeNextOptions) {
"""
Lists all of the files in task directories on the specified compute node.
@param nextPageLink The NextLink from the previous successful call to List operation.
@param fileListFromComputeNodeNextOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@throws BatchErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the PagedList<NodeFile> object if successful.
"""
ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders> response = listFromComputeNodeNextSinglePageAsync(nextPageLink, fileListFromComputeNodeNextOptions).toBlocking().single();
return new PagedList<NodeFile>(response.body()) {
@Override
public Page<NodeFile> nextPage(String nextPageLink) {
return listFromComputeNodeNextSinglePageAsync(nextPageLink, fileListFromComputeNodeNextOptions).toBlocking().single().body();
}
};
} | java | public PagedList<NodeFile> listFromComputeNodeNext(final String nextPageLink, final FileListFromComputeNodeNextOptions fileListFromComputeNodeNextOptions) {
ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders> response = listFromComputeNodeNextSinglePageAsync(nextPageLink, fileListFromComputeNodeNextOptions).toBlocking().single();
return new PagedList<NodeFile>(response.body()) {
@Override
public Page<NodeFile> nextPage(String nextPageLink) {
return listFromComputeNodeNextSinglePageAsync(nextPageLink, fileListFromComputeNodeNextOptions).toBlocking().single().body();
}
};
} | [
"public",
"PagedList",
"<",
"NodeFile",
">",
"listFromComputeNodeNext",
"(",
"final",
"String",
"nextPageLink",
",",
"final",
"FileListFromComputeNodeNextOptions",
"fileListFromComputeNodeNextOptions",
")",
"{",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"NodeFile",
">",
",",
"FileListFromComputeNodeHeaders",
">",
"response",
"=",
"listFromComputeNodeNextSinglePageAsync",
"(",
"nextPageLink",
",",
"fileListFromComputeNodeNextOptions",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
";",
"return",
"new",
"PagedList",
"<",
"NodeFile",
">",
"(",
"response",
".",
"body",
"(",
")",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"NodeFile",
">",
"nextPage",
"(",
"String",
"nextPageLink",
")",
"{",
"return",
"listFromComputeNodeNextSinglePageAsync",
"(",
"nextPageLink",
",",
"fileListFromComputeNodeNextOptions",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}",
"}",
";",
"}"
] | Lists all of the files in task directories on the specified compute node.
@param nextPageLink The NextLink from the previous successful call to List operation.
@param fileListFromComputeNodeNextOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@throws BatchErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the PagedList<NodeFile> object if successful. | [
"Lists",
"all",
"of",
"the",
"files",
"in",
"task",
"directories",
"on",
"the",
"specified",
"compute",
"node",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/FilesImpl.java#L2588-L2596 |
arakelian/more-commons | src/main/java/com/arakelian/core/utils/DateUtils.java | DateUtils.toZonedDateTimeUtc | private static ZonedDateTime toZonedDateTimeUtc(final long epochValue, final EpochUnits units) {
"""
Returns a <code>ZonedDateTime</code> from the given epoch value.
@param epoch
value in milliseconds
@return a <code>ZonedDateTime</code> or null if the date is not valid
"""
Preconditions.checkArgument(units != null, "units must be non-null");
final Instant instant = units.toInstant(epochValue);
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC);
} | java | private static ZonedDateTime toZonedDateTimeUtc(final long epochValue, final EpochUnits units) {
Preconditions.checkArgument(units != null, "units must be non-null");
final Instant instant = units.toInstant(epochValue);
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC);
} | [
"private",
"static",
"ZonedDateTime",
"toZonedDateTimeUtc",
"(",
"final",
"long",
"epochValue",
",",
"final",
"EpochUnits",
"units",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"units",
"!=",
"null",
",",
"\"units must be non-null\"",
")",
";",
"final",
"Instant",
"instant",
"=",
"units",
".",
"toInstant",
"(",
"epochValue",
")",
";",
"return",
"ZonedDateTime",
".",
"ofInstant",
"(",
"instant",
",",
"ZoneOffset",
".",
"UTC",
")",
";",
"}"
] | Returns a <code>ZonedDateTime</code> from the given epoch value.
@param epoch
value in milliseconds
@return a <code>ZonedDateTime</code> or null if the date is not valid | [
"Returns",
"a",
"<code",
">",
"ZonedDateTime<",
"/",
"code",
">",
"from",
"the",
"given",
"epoch",
"value",
"."
] | train | https://github.com/arakelian/more-commons/blob/83c607044f64a7f6c005a67866c0ef7cb68d6e29/src/main/java/com/arakelian/core/utils/DateUtils.java#L640-L644 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.hosting_web_serviceName_upgrade_duration_POST | public OvhOrder hosting_web_serviceName_upgrade_duration_POST(String serviceName, String duration, net.minidev.ovh.api.hosting.web.OvhOfferEnum offer, Boolean waiveRetractationPeriod) throws IOException {
"""
Create order
REST: POST /order/hosting/web/{serviceName}/upgrade/{duration}
@param offer [required] New offers for your hosting account
@param waiveRetractationPeriod [required] Indicates that order will be processed with waiving retractation period
@param serviceName [required] The internal name of your hosting
@param duration [required] Duration
"""
String qPath = "/order/hosting/web/{serviceName}/upgrade/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "offer", offer);
addBody(o, "waiveRetractationPeriod", waiveRetractationPeriod);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOrder.class);
} | java | public OvhOrder hosting_web_serviceName_upgrade_duration_POST(String serviceName, String duration, net.minidev.ovh.api.hosting.web.OvhOfferEnum offer, Boolean waiveRetractationPeriod) throws IOException {
String qPath = "/order/hosting/web/{serviceName}/upgrade/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "offer", offer);
addBody(o, "waiveRetractationPeriod", waiveRetractationPeriod);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOrder.class);
} | [
"public",
"OvhOrder",
"hosting_web_serviceName_upgrade_duration_POST",
"(",
"String",
"serviceName",
",",
"String",
"duration",
",",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"hosting",
".",
"web",
".",
"OvhOfferEnum",
"offer",
",",
"Boolean",
"waiveRetractationPeriod",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/hosting/web/{serviceName}/upgrade/{duration}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"duration",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"offer\"",
",",
"offer",
")",
";",
"addBody",
"(",
"o",
",",
"\"waiveRetractationPeriod\"",
",",
"waiveRetractationPeriod",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] | Create order
REST: POST /order/hosting/web/{serviceName}/upgrade/{duration}
@param offer [required] New offers for your hosting account
@param waiveRetractationPeriod [required] Indicates that order will be processed with waiving retractation period
@param serviceName [required] The internal name of your hosting
@param duration [required] Duration | [
"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#L4962-L4970 |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/segment/SegmentServiceImpl.java | SegmentServiceImpl.readMetaContinuation | private boolean readMetaContinuation(ReadStream is, int crc)
throws IOException {
"""
Continuation segment for the metadata.
Additional segments when the table/segment metadata doesn't fit.
"""
long value = BitsUtil.readLong(is);
crc = Crc32Caucho.generate(crc, value);
int crcFile = BitsUtil.readInt(is);
if (crcFile != crc) {
log.fine("meta-segment crc mismatch");
return false;
}
long address = value & ~0xffff;
int length = (int) ((value & 0xffff) << 16);
if (length != _segmentMeta[0].size()) {
throw new IllegalStateException();
}
SegmentExtent extent = new SegmentExtent(0, address, length);
_metaExtents.add(extent);
_metaAddress = address;
_metaOffset = address;
_metaTail = address + length;
// false continues to the next segment
return false;
} | java | private boolean readMetaContinuation(ReadStream is, int crc)
throws IOException
{
long value = BitsUtil.readLong(is);
crc = Crc32Caucho.generate(crc, value);
int crcFile = BitsUtil.readInt(is);
if (crcFile != crc) {
log.fine("meta-segment crc mismatch");
return false;
}
long address = value & ~0xffff;
int length = (int) ((value & 0xffff) << 16);
if (length != _segmentMeta[0].size()) {
throw new IllegalStateException();
}
SegmentExtent extent = new SegmentExtent(0, address, length);
_metaExtents.add(extent);
_metaAddress = address;
_metaOffset = address;
_metaTail = address + length;
// false continues to the next segment
return false;
} | [
"private",
"boolean",
"readMetaContinuation",
"(",
"ReadStream",
"is",
",",
"int",
"crc",
")",
"throws",
"IOException",
"{",
"long",
"value",
"=",
"BitsUtil",
".",
"readLong",
"(",
"is",
")",
";",
"crc",
"=",
"Crc32Caucho",
".",
"generate",
"(",
"crc",
",",
"value",
")",
";",
"int",
"crcFile",
"=",
"BitsUtil",
".",
"readInt",
"(",
"is",
")",
";",
"if",
"(",
"crcFile",
"!=",
"crc",
")",
"{",
"log",
".",
"fine",
"(",
"\"meta-segment crc mismatch\"",
")",
";",
"return",
"false",
";",
"}",
"long",
"address",
"=",
"value",
"&",
"~",
"0xffff",
";",
"int",
"length",
"=",
"(",
"int",
")",
"(",
"(",
"value",
"&",
"0xffff",
")",
"<<",
"16",
")",
";",
"if",
"(",
"length",
"!=",
"_segmentMeta",
"[",
"0",
"]",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"}",
"SegmentExtent",
"extent",
"=",
"new",
"SegmentExtent",
"(",
"0",
",",
"address",
",",
"length",
")",
";",
"_metaExtents",
".",
"add",
"(",
"extent",
")",
";",
"_metaAddress",
"=",
"address",
";",
"_metaOffset",
"=",
"address",
";",
"_metaTail",
"=",
"address",
"+",
"length",
";",
"// false continues to the next segment",
"return",
"false",
";",
"}"
] | Continuation segment for the metadata.
Additional segments when the table/segment metadata doesn't fit. | [
"Continuation",
"segment",
"for",
"the",
"metadata",
"."
] | train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/SegmentServiceImpl.java#L853-L884 |
stratosphere/stratosphere | stratosphere-core/src/main/java/eu/stratosphere/api/common/operators/DualInputSemanticProperties.java | DualInputSemanticProperties.addForwardedField1 | public void addForwardedField1(int sourceField, FieldSet destinationFields) {
"""
Adds, to the existing information, a field that is forwarded directly
from the source record(s) in the first input to multiple fields in
the destination record(s).
@param sourceField the position in the source record(s)
@param destinationFields the position in the destination record(s)
"""
FieldSet fs;
if((fs = this.forwardedFields1.get(sourceField)) != null) {
fs.addAll(destinationFields);
} else {
fs = new FieldSet(destinationFields);
this.forwardedFields1.put(sourceField, fs);
}
} | java | public void addForwardedField1(int sourceField, FieldSet destinationFields) {
FieldSet fs;
if((fs = this.forwardedFields1.get(sourceField)) != null) {
fs.addAll(destinationFields);
} else {
fs = new FieldSet(destinationFields);
this.forwardedFields1.put(sourceField, fs);
}
} | [
"public",
"void",
"addForwardedField1",
"(",
"int",
"sourceField",
",",
"FieldSet",
"destinationFields",
")",
"{",
"FieldSet",
"fs",
";",
"if",
"(",
"(",
"fs",
"=",
"this",
".",
"forwardedFields1",
".",
"get",
"(",
"sourceField",
")",
")",
"!=",
"null",
")",
"{",
"fs",
".",
"addAll",
"(",
"destinationFields",
")",
";",
"}",
"else",
"{",
"fs",
"=",
"new",
"FieldSet",
"(",
"destinationFields",
")",
";",
"this",
".",
"forwardedFields1",
".",
"put",
"(",
"sourceField",
",",
"fs",
")",
";",
"}",
"}"
] | Adds, to the existing information, a field that is forwarded directly
from the source record(s) in the first input to multiple fields in
the destination record(s).
@param sourceField the position in the source record(s)
@param destinationFields the position in the destination record(s) | [
"Adds",
"to",
"the",
"existing",
"information",
"a",
"field",
"that",
"is",
"forwarded",
"directly",
"from",
"the",
"source",
"record",
"(",
"s",
")",
"in",
"the",
"first",
"input",
"to",
"multiple",
"fields",
"in",
"the",
"destination",
"record",
"(",
"s",
")",
"."
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-core/src/main/java/eu/stratosphere/api/common/operators/DualInputSemanticProperties.java#L83-L91 |
trajano/caliper | caliper/src/main/java/com/google/caliper/runner/StreamService.java | StreamService.readItem | StreamItem readItem(long timeout, TimeUnit unit) throws InterruptedException {
"""
Reads a {@link StreamItem} from one of the streams waiting for one to become available if
necessary.
"""
checkState(isRunning(), "Cannot read items from a %s StreamService", state());
StreamItem line = outputQueue.poll(timeout, unit);
if (line == EOF_ITEM) {
closeStream();
}
return (line == null) ? TIMEOUT_ITEM : line;
} | java | StreamItem readItem(long timeout, TimeUnit unit) throws InterruptedException {
checkState(isRunning(), "Cannot read items from a %s StreamService", state());
StreamItem line = outputQueue.poll(timeout, unit);
if (line == EOF_ITEM) {
closeStream();
}
return (line == null) ? TIMEOUT_ITEM : line;
} | [
"StreamItem",
"readItem",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"checkState",
"(",
"isRunning",
"(",
")",
",",
"\"Cannot read items from a %s StreamService\"",
",",
"state",
"(",
")",
")",
";",
"StreamItem",
"line",
"=",
"outputQueue",
".",
"poll",
"(",
"timeout",
",",
"unit",
")",
";",
"if",
"(",
"line",
"==",
"EOF_ITEM",
")",
"{",
"closeStream",
"(",
")",
";",
"}",
"return",
"(",
"line",
"==",
"null",
")",
"?",
"TIMEOUT_ITEM",
":",
"line",
";",
"}"
] | Reads a {@link StreamItem} from one of the streams waiting for one to become available if
necessary. | [
"Reads",
"a",
"{"
] | train | https://github.com/trajano/caliper/blob/a8bcfd84fa9d7b893b3edfadc3b13240ae5cd658/caliper/src/main/java/com/google/caliper/runner/StreamService.java#L196-L203 |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java | EsMarshalling.unmarshallPlanVersionSummary | public static PlanVersionSummaryBean unmarshallPlanVersionSummary(Map<String, Object> source) {
"""
Unmarshals the given map source into a bean.
@param source the source
@return the plan version summary
"""
if (source == null) {
return null;
}
PlanVersionSummaryBean bean = new PlanVersionSummaryBean();
bean.setDescription(asString(source.get("planDescription")));
bean.setId(asString(source.get("planId")));
bean.setName(asString(source.get("planName")));
bean.setOrganizationId(asString(source.get("organizationId")));
bean.setOrganizationName(asString(source.get("organizationName")));
bean.setStatus(asEnum(source.get("status"), PlanStatus.class));
bean.setVersion(asString(source.get("version")));
postMarshall(bean);
return bean;
} | java | public static PlanVersionSummaryBean unmarshallPlanVersionSummary(Map<String, Object> source) {
if (source == null) {
return null;
}
PlanVersionSummaryBean bean = new PlanVersionSummaryBean();
bean.setDescription(asString(source.get("planDescription")));
bean.setId(asString(source.get("planId")));
bean.setName(asString(source.get("planName")));
bean.setOrganizationId(asString(source.get("organizationId")));
bean.setOrganizationName(asString(source.get("organizationName")));
bean.setStatus(asEnum(source.get("status"), PlanStatus.class));
bean.setVersion(asString(source.get("version")));
postMarshall(bean);
return bean;
} | [
"public",
"static",
"PlanVersionSummaryBean",
"unmarshallPlanVersionSummary",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"PlanVersionSummaryBean",
"bean",
"=",
"new",
"PlanVersionSummaryBean",
"(",
")",
";",
"bean",
".",
"setDescription",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"planDescription\"",
")",
")",
")",
";",
"bean",
".",
"setId",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"planId\"",
")",
")",
")",
";",
"bean",
".",
"setName",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"planName\"",
")",
")",
")",
";",
"bean",
".",
"setOrganizationId",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"organizationId\"",
")",
")",
")",
";",
"bean",
".",
"setOrganizationName",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"organizationName\"",
")",
")",
")",
";",
"bean",
".",
"setStatus",
"(",
"asEnum",
"(",
"source",
".",
"get",
"(",
"\"status\"",
")",
",",
"PlanStatus",
".",
"class",
")",
")",
";",
"bean",
".",
"setVersion",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"version\"",
")",
")",
")",
";",
"postMarshall",
"(",
"bean",
")",
";",
"return",
"bean",
";",
"}"
] | Unmarshals the given map source into a bean.
@param source the source
@return the plan version summary | [
"Unmarshals",
"the",
"given",
"map",
"source",
"into",
"a",
"bean",
"."
] | train | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java#L885-L899 |
aws/aws-sdk-java | aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java | AmazonS3Client.postProcessS3Object | private void postProcessS3Object(final S3Object s3Object, final boolean skipClientSideValidation,
final ProgressListener listener) {
"""
Post processing the {@link S3Object} downloaded from S3. It includes wrapping the data with wrapper input streams,
doing client side validation if possible etc.
"""
InputStream is = s3Object.getObjectContent();
HttpRequestBase httpRequest = s3Object.getObjectContent().getHttpRequest();
// Hold a reference to this client while the InputStream is still
// around - otherwise a finalizer in the HttpClient may reset the
// underlying TCP connection out from under us.
is = new ServiceClientHolderInputStream(is, this);
// used trigger a tranfer complete event when the stream is entirely consumed
ProgressInputStream progressInputStream =
new ProgressInputStream(is, listener) {
@Override protected void onEOF() {
publishProgress(getListener(), ProgressEventType.TRANSFER_COMPLETED_EVENT);
}
};
is = progressInputStream;
// The Etag header contains a server-side MD5 of the object. If
// we're downloading the whole object, by default we wrap the
// stream in a validator that calculates an MD5 of the downloaded
// bytes and complains if what we received doesn't match the Etag.
if (!skipClientSideValidation) {
byte[] serverSideHash = BinaryUtils.fromHex(s3Object.getObjectMetadata().getETag());
try {
// No content length check is performed when the
// MD5 check is enabled, since a correct MD5 check would
// imply a correct content length.
MessageDigest digest = MessageDigest.getInstance("MD5");
is = new DigestValidationInputStream(is, digest, serverSideHash);
} catch (NoSuchAlgorithmException e) {
log.warn("No MD5 digest algorithm available. Unable to calculate "
+ "checksum and verify data integrity.", e);
}
} else {
// Ensures the data received from S3 has the same length as the
// expected content-length
is = new LengthCheckInputStream(is,
s3Object.getObjectMetadata().getContentLength(), // expected length
INCLUDE_SKIPPED_BYTES); // bytes received from S3 are all included even if skipped
}
S3AbortableInputStream abortableInputStream =
new S3AbortableInputStream(is, httpRequest, s3Object.getObjectMetadata().getContentLength());
s3Object.setObjectContent(new S3ObjectInputStream(abortableInputStream, httpRequest, false));
} | java | private void postProcessS3Object(final S3Object s3Object, final boolean skipClientSideValidation,
final ProgressListener listener) {
InputStream is = s3Object.getObjectContent();
HttpRequestBase httpRequest = s3Object.getObjectContent().getHttpRequest();
// Hold a reference to this client while the InputStream is still
// around - otherwise a finalizer in the HttpClient may reset the
// underlying TCP connection out from under us.
is = new ServiceClientHolderInputStream(is, this);
// used trigger a tranfer complete event when the stream is entirely consumed
ProgressInputStream progressInputStream =
new ProgressInputStream(is, listener) {
@Override protected void onEOF() {
publishProgress(getListener(), ProgressEventType.TRANSFER_COMPLETED_EVENT);
}
};
is = progressInputStream;
// The Etag header contains a server-side MD5 of the object. If
// we're downloading the whole object, by default we wrap the
// stream in a validator that calculates an MD5 of the downloaded
// bytes and complains if what we received doesn't match the Etag.
if (!skipClientSideValidation) {
byte[] serverSideHash = BinaryUtils.fromHex(s3Object.getObjectMetadata().getETag());
try {
// No content length check is performed when the
// MD5 check is enabled, since a correct MD5 check would
// imply a correct content length.
MessageDigest digest = MessageDigest.getInstance("MD5");
is = new DigestValidationInputStream(is, digest, serverSideHash);
} catch (NoSuchAlgorithmException e) {
log.warn("No MD5 digest algorithm available. Unable to calculate "
+ "checksum and verify data integrity.", e);
}
} else {
// Ensures the data received from S3 has the same length as the
// expected content-length
is = new LengthCheckInputStream(is,
s3Object.getObjectMetadata().getContentLength(), // expected length
INCLUDE_SKIPPED_BYTES); // bytes received from S3 are all included even if skipped
}
S3AbortableInputStream abortableInputStream =
new S3AbortableInputStream(is, httpRequest, s3Object.getObjectMetadata().getContentLength());
s3Object.setObjectContent(new S3ObjectInputStream(abortableInputStream, httpRequest, false));
} | [
"private",
"void",
"postProcessS3Object",
"(",
"final",
"S3Object",
"s3Object",
",",
"final",
"boolean",
"skipClientSideValidation",
",",
"final",
"ProgressListener",
"listener",
")",
"{",
"InputStream",
"is",
"=",
"s3Object",
".",
"getObjectContent",
"(",
")",
";",
"HttpRequestBase",
"httpRequest",
"=",
"s3Object",
".",
"getObjectContent",
"(",
")",
".",
"getHttpRequest",
"(",
")",
";",
"// Hold a reference to this client while the InputStream is still",
"// around - otherwise a finalizer in the HttpClient may reset the",
"// underlying TCP connection out from under us.",
"is",
"=",
"new",
"ServiceClientHolderInputStream",
"(",
"is",
",",
"this",
")",
";",
"// used trigger a tranfer complete event when the stream is entirely consumed",
"ProgressInputStream",
"progressInputStream",
"=",
"new",
"ProgressInputStream",
"(",
"is",
",",
"listener",
")",
"{",
"@",
"Override",
"protected",
"void",
"onEOF",
"(",
")",
"{",
"publishProgress",
"(",
"getListener",
"(",
")",
",",
"ProgressEventType",
".",
"TRANSFER_COMPLETED_EVENT",
")",
";",
"}",
"}",
";",
"is",
"=",
"progressInputStream",
";",
"// The Etag header contains a server-side MD5 of the object. If",
"// we're downloading the whole object, by default we wrap the",
"// stream in a validator that calculates an MD5 of the downloaded",
"// bytes and complains if what we received doesn't match the Etag.",
"if",
"(",
"!",
"skipClientSideValidation",
")",
"{",
"byte",
"[",
"]",
"serverSideHash",
"=",
"BinaryUtils",
".",
"fromHex",
"(",
"s3Object",
".",
"getObjectMetadata",
"(",
")",
".",
"getETag",
"(",
")",
")",
";",
"try",
"{",
"// No content length check is performed when the",
"// MD5 check is enabled, since a correct MD5 check would",
"// imply a correct content length.",
"MessageDigest",
"digest",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"MD5\"",
")",
";",
"is",
"=",
"new",
"DigestValidationInputStream",
"(",
"is",
",",
"digest",
",",
"serverSideHash",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"No MD5 digest algorithm available. Unable to calculate \"",
"+",
"\"checksum and verify data integrity.\"",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"// Ensures the data received from S3 has the same length as the",
"// expected content-length",
"is",
"=",
"new",
"LengthCheckInputStream",
"(",
"is",
",",
"s3Object",
".",
"getObjectMetadata",
"(",
")",
".",
"getContentLength",
"(",
")",
",",
"// expected length",
"INCLUDE_SKIPPED_BYTES",
")",
";",
"// bytes received from S3 are all included even if skipped",
"}",
"S3AbortableInputStream",
"abortableInputStream",
"=",
"new",
"S3AbortableInputStream",
"(",
"is",
",",
"httpRequest",
",",
"s3Object",
".",
"getObjectMetadata",
"(",
")",
".",
"getContentLength",
"(",
")",
")",
";",
"s3Object",
".",
"setObjectContent",
"(",
"new",
"S3ObjectInputStream",
"(",
"abortableInputStream",
",",
"httpRequest",
",",
"false",
")",
")",
";",
"}"
] | Post processing the {@link S3Object} downloaded from S3. It includes wrapping the data with wrapper input streams,
doing client side validation if possible etc. | [
"Post",
"processing",
"the",
"{"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java#L1502-L1546 |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/search/SearchBuilders.java | SearchBuilders.geoDistance | public static GeoDistanceConditionBuilder geoDistance(String field,
double longitude,
double latitude,
String maxDistance) {
"""
Returns a new {@link GeoDistanceConditionBuilder} with the specified field reference point.
@param field the name of the field to be matched
@param longitude The longitude of the reference point.
@param latitude The latitude of the reference point.
@param maxDistance The max allowed distance.
@return a new geo distance condition builder
"""
return new GeoDistanceConditionBuilder(field, latitude, longitude, maxDistance);
} | java | public static GeoDistanceConditionBuilder geoDistance(String field,
double longitude,
double latitude,
String maxDistance) {
return new GeoDistanceConditionBuilder(field, latitude, longitude, maxDistance);
} | [
"public",
"static",
"GeoDistanceConditionBuilder",
"geoDistance",
"(",
"String",
"field",
",",
"double",
"longitude",
",",
"double",
"latitude",
",",
"String",
"maxDistance",
")",
"{",
"return",
"new",
"GeoDistanceConditionBuilder",
"(",
"field",
",",
"latitude",
",",
"longitude",
",",
"maxDistance",
")",
";",
"}"
] | Returns a new {@link GeoDistanceConditionBuilder} with the specified field reference point.
@param field the name of the field to be matched
@param longitude The longitude of the reference point.
@param latitude The latitude of the reference point.
@param maxDistance The max allowed distance.
@return a new geo distance condition builder | [
"Returns",
"a",
"new",
"{",
"@link",
"GeoDistanceConditionBuilder",
"}",
"with",
"the",
"specified",
"field",
"reference",
"point",
"."
] | train | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/search/SearchBuilders.java#L236-L241 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java | MapUtil.getStr | public static String getStr(Map<?, ?> map, Object key) {
"""
获取Map指定key的值,并转换为字符串
@param map Map
@param key 键
@return 值
@since 4.0.6
"""
return get(map, key, String.class);
} | java | public static String getStr(Map<?, ?> map, Object key) {
return get(map, key, String.class);
} | [
"public",
"static",
"String",
"getStr",
"(",
"Map",
"<",
"?",
",",
"?",
">",
"map",
",",
"Object",
"key",
")",
"{",
"return",
"get",
"(",
"map",
",",
"key",
",",
"String",
".",
"class",
")",
";",
"}"
] | 获取Map指定key的值,并转换为字符串
@param map Map
@param key 键
@return 值
@since 4.0.6 | [
"获取Map指定key的值,并转换为字符串"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java#L756-L758 |
XDean/Java-EX | src/main/java/xdean/jex/util/reflect/GenericUtil.java | GenericUtil.getActualType | private static Type getActualType(Map<TypeVariable<?>, Type> map, Type type) {
"""
Get actual type by the type map.
@param map
@param type
@return The actual type. Return itself if it's already the most explicit type.
"""
return TypeVisitor.of(type, b -> b
.onClass(c -> c)
.onTypeVariable(tv -> map.containsKey(tv) ? getActualType(map, map.get(tv)) : tv)
.onParameterizedType(pt -> TypeVisitor.of(pt.getRawType(), bb -> bb
.onClass(c -> createParameterizedType(c, pt.getOwnerType(),
Arrays.stream(pt.getActualTypeArguments()).map(t -> getActualType(map, t)).toArray(Type[]::new)))
.result()))
.onWildcardType(wt -> createWildcardType(
Arrays.stream(wt.getUpperBounds()).map(t -> getActualType(map, t)).toArray(Type[]::new),
Arrays.stream(wt.getLowerBounds()).map(t -> getActualType(map, t)).toArray(Type[]::new)))
.onGenericArrayType(gat -> createGenericArrayType(getActualType(map, gat.getGenericComponentType())))
.result(type));
} | java | private static Type getActualType(Map<TypeVariable<?>, Type> map, Type type) {
return TypeVisitor.of(type, b -> b
.onClass(c -> c)
.onTypeVariable(tv -> map.containsKey(tv) ? getActualType(map, map.get(tv)) : tv)
.onParameterizedType(pt -> TypeVisitor.of(pt.getRawType(), bb -> bb
.onClass(c -> createParameterizedType(c, pt.getOwnerType(),
Arrays.stream(pt.getActualTypeArguments()).map(t -> getActualType(map, t)).toArray(Type[]::new)))
.result()))
.onWildcardType(wt -> createWildcardType(
Arrays.stream(wt.getUpperBounds()).map(t -> getActualType(map, t)).toArray(Type[]::new),
Arrays.stream(wt.getLowerBounds()).map(t -> getActualType(map, t)).toArray(Type[]::new)))
.onGenericArrayType(gat -> createGenericArrayType(getActualType(map, gat.getGenericComponentType())))
.result(type));
} | [
"private",
"static",
"Type",
"getActualType",
"(",
"Map",
"<",
"TypeVariable",
"<",
"?",
">",
",",
"Type",
">",
"map",
",",
"Type",
"type",
")",
"{",
"return",
"TypeVisitor",
".",
"of",
"(",
"type",
",",
"b",
"->",
"b",
".",
"onClass",
"(",
"c",
"->",
"c",
")",
".",
"onTypeVariable",
"(",
"tv",
"->",
"map",
".",
"containsKey",
"(",
"tv",
")",
"?",
"getActualType",
"(",
"map",
",",
"map",
".",
"get",
"(",
"tv",
")",
")",
":",
"tv",
")",
".",
"onParameterizedType",
"(",
"pt",
"->",
"TypeVisitor",
".",
"of",
"(",
"pt",
".",
"getRawType",
"(",
")",
",",
"bb",
"->",
"bb",
".",
"onClass",
"(",
"c",
"->",
"createParameterizedType",
"(",
"c",
",",
"pt",
".",
"getOwnerType",
"(",
")",
",",
"Arrays",
".",
"stream",
"(",
"pt",
".",
"getActualTypeArguments",
"(",
")",
")",
".",
"map",
"(",
"t",
"->",
"getActualType",
"(",
"map",
",",
"t",
")",
")",
".",
"toArray",
"(",
"Type",
"[",
"]",
"::",
"new",
")",
")",
")",
".",
"result",
"(",
")",
")",
")",
".",
"onWildcardType",
"(",
"wt",
"->",
"createWildcardType",
"(",
"Arrays",
".",
"stream",
"(",
"wt",
".",
"getUpperBounds",
"(",
")",
")",
".",
"map",
"(",
"t",
"->",
"getActualType",
"(",
"map",
",",
"t",
")",
")",
".",
"toArray",
"(",
"Type",
"[",
"]",
"::",
"new",
")",
",",
"Arrays",
".",
"stream",
"(",
"wt",
".",
"getLowerBounds",
"(",
")",
")",
".",
"map",
"(",
"t",
"->",
"getActualType",
"(",
"map",
",",
"t",
")",
")",
".",
"toArray",
"(",
"Type",
"[",
"]",
"::",
"new",
")",
")",
")",
".",
"onGenericArrayType",
"(",
"gat",
"->",
"createGenericArrayType",
"(",
"getActualType",
"(",
"map",
",",
"gat",
".",
"getGenericComponentType",
"(",
")",
")",
")",
")",
".",
"result",
"(",
"type",
")",
")",
";",
"}"
] | Get actual type by the type map.
@param map
@param type
@return The actual type. Return itself if it's already the most explicit type. | [
"Get",
"actual",
"type",
"by",
"the",
"type",
"map",
"."
] | train | https://github.com/XDean/Java-EX/blob/9208ba71c5b2af9f9bd979d01fab2ff5e433b3e7/src/main/java/xdean/jex/util/reflect/GenericUtil.java#L132-L145 |
landawn/AbacusUtil | src/com/landawn/abacus/util/CSVUtil.java | CSVUtil.exportCSV | public static long exportCSV(final Writer out, final ResultSet rs) throws UncheckedSQLException, UncheckedIOException {
"""
Exports the data from database to CVS. Title will be added at the first line and columns will be quoted.
@param out
@param rs
@return
"""
return exportCSV(out, rs, 0, Long.MAX_VALUE, true, true);
} | java | public static long exportCSV(final Writer out, final ResultSet rs) throws UncheckedSQLException, UncheckedIOException {
return exportCSV(out, rs, 0, Long.MAX_VALUE, true, true);
} | [
"public",
"static",
"long",
"exportCSV",
"(",
"final",
"Writer",
"out",
",",
"final",
"ResultSet",
"rs",
")",
"throws",
"UncheckedSQLException",
",",
"UncheckedIOException",
"{",
"return",
"exportCSV",
"(",
"out",
",",
"rs",
",",
"0",
",",
"Long",
".",
"MAX_VALUE",
",",
"true",
",",
"true",
")",
";",
"}"
] | Exports the data from database to CVS. Title will be added at the first line and columns will be quoted.
@param out
@param rs
@return | [
"Exports",
"the",
"data",
"from",
"database",
"to",
"CVS",
".",
"Title",
"will",
"be",
"added",
"at",
"the",
"first",
"line",
"and",
"columns",
"will",
"be",
"quoted",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/CSVUtil.java#L922-L924 |
osglworks/java-tool | src/main/java/org/osgl/Lang.java | F3.orElse | public F3<P1, P2, P3, R> orElse(final Func3<? super P1, ? super P2, ? super P3, ? extends R> fallback) {
"""
Returns a composed function that when applied, try to apply this function first, in case
a {@link NotAppliedException} is captured apply to the fallback function specified. This
method helps to implement partial function
@param fallback
the function to applied if this function doesn't apply to the parameter(s)
@return the composed function
"""
final F3<P1, P2, P3, R> me = this;
return new F3<P1, P2, P3, R>() {
@Override
public R apply(P1 p1, P2 p2, P3 p3) {
try {
return me.apply(p1, p2, p3);
} catch (RuntimeException e) {
return fallback.apply(p1, p2, p3);
}
}
};
} | java | public F3<P1, P2, P3, R> orElse(final Func3<? super P1, ? super P2, ? super P3, ? extends R> fallback) {
final F3<P1, P2, P3, R> me = this;
return new F3<P1, P2, P3, R>() {
@Override
public R apply(P1 p1, P2 p2, P3 p3) {
try {
return me.apply(p1, p2, p3);
} catch (RuntimeException e) {
return fallback.apply(p1, p2, p3);
}
}
};
} | [
"public",
"F3",
"<",
"P1",
",",
"P2",
",",
"P3",
",",
"R",
">",
"orElse",
"(",
"final",
"Func3",
"<",
"?",
"super",
"P1",
",",
"?",
"super",
"P2",
",",
"?",
"super",
"P3",
",",
"?",
"extends",
"R",
">",
"fallback",
")",
"{",
"final",
"F3",
"<",
"P1",
",",
"P2",
",",
"P3",
",",
"R",
">",
"me",
"=",
"this",
";",
"return",
"new",
"F3",
"<",
"P1",
",",
"P2",
",",
"P3",
",",
"R",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"R",
"apply",
"(",
"P1",
"p1",
",",
"P2",
"p2",
",",
"P3",
"p3",
")",
"{",
"try",
"{",
"return",
"me",
".",
"apply",
"(",
"p1",
",",
"p2",
",",
"p3",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"return",
"fallback",
".",
"apply",
"(",
"p1",
",",
"p2",
",",
"p3",
")",
";",
"}",
"}",
"}",
";",
"}"
] | Returns a composed function that when applied, try to apply this function first, in case
a {@link NotAppliedException} is captured apply to the fallback function specified. This
method helps to implement partial function
@param fallback
the function to applied if this function doesn't apply to the parameter(s)
@return the composed function | [
"Returns",
"a",
"composed",
"function",
"that",
"when",
"applied",
"try",
"to",
"apply",
"this",
"function",
"first",
"in",
"case",
"a",
"{",
"@link",
"NotAppliedException",
"}",
"is",
"captured",
"apply",
"to",
"the",
"fallback",
"function",
"specified",
".",
"This",
"method",
"helps",
"to",
"implement",
"partial",
"function"
] | train | https://github.com/osglworks/java-tool/blob/8b6eee2bccb067eb32e6a7bc4a4dfef7a7d9008b/src/main/java/org/osgl/Lang.java#L1308-L1320 |
apache/incubator-shardingsphere | sharding-jdbc/sharding-jdbc-core/src/main/java/org/apache/shardingsphere/shardingjdbc/jdbc/adapter/AbstractConnectionAdapter.java | AbstractConnectionAdapter.getConnection | public final Connection getConnection(final String dataSourceName) throws SQLException {
"""
Get database connection.
@param dataSourceName data source name
@return database connection
@throws SQLException SQL exception
"""
return getConnections(ConnectionMode.MEMORY_STRICTLY, dataSourceName, 1).get(0);
} | java | public final Connection getConnection(final String dataSourceName) throws SQLException {
return getConnections(ConnectionMode.MEMORY_STRICTLY, dataSourceName, 1).get(0);
} | [
"public",
"final",
"Connection",
"getConnection",
"(",
"final",
"String",
"dataSourceName",
")",
"throws",
"SQLException",
"{",
"return",
"getConnections",
"(",
"ConnectionMode",
".",
"MEMORY_STRICTLY",
",",
"dataSourceName",
",",
"1",
")",
".",
"get",
"(",
"0",
")",
";",
"}"
] | Get database connection.
@param dataSourceName data source name
@return database connection
@throws SQLException SQL exception | [
"Get",
"database",
"connection",
"."
] | train | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-jdbc/sharding-jdbc-core/src/main/java/org/apache/shardingsphere/shardingjdbc/jdbc/adapter/AbstractConnectionAdapter.java#L95-L97 |
networknt/light-4j | client/src/main/java/com/networknt/client/Http2Client.java | Http2Client.addAuthTokenTrace | public void addAuthTokenTrace(ClientRequest request, String token, String traceabilityId) {
"""
Add Authorization Code grant token the caller app gets from OAuth2 server and add traceabilityId
This is the method called from client like web server that want to have traceabilityId pass through.
@param request the http request
@param token the bearer token
@param traceabilityId the traceability id
"""
if(token != null && !token.startsWith("Bearer ")) {
if(token.toUpperCase().startsWith("BEARER ")) {
// other cases of Bearer
token = "Bearer " + token.substring(7);
} else {
token = "Bearer " + token;
}
}
request.getRequestHeaders().put(Headers.AUTHORIZATION, token);
request.getRequestHeaders().put(HttpStringConstants.TRACEABILITY_ID, traceabilityId);
} | java | public void addAuthTokenTrace(ClientRequest request, String token, String traceabilityId) {
if(token != null && !token.startsWith("Bearer ")) {
if(token.toUpperCase().startsWith("BEARER ")) {
// other cases of Bearer
token = "Bearer " + token.substring(7);
} else {
token = "Bearer " + token;
}
}
request.getRequestHeaders().put(Headers.AUTHORIZATION, token);
request.getRequestHeaders().put(HttpStringConstants.TRACEABILITY_ID, traceabilityId);
} | [
"public",
"void",
"addAuthTokenTrace",
"(",
"ClientRequest",
"request",
",",
"String",
"token",
",",
"String",
"traceabilityId",
")",
"{",
"if",
"(",
"token",
"!=",
"null",
"&&",
"!",
"token",
".",
"startsWith",
"(",
"\"Bearer \"",
")",
")",
"{",
"if",
"(",
"token",
".",
"toUpperCase",
"(",
")",
".",
"startsWith",
"(",
"\"BEARER \"",
")",
")",
"{",
"// other cases of Bearer",
"token",
"=",
"\"Bearer \"",
"+",
"token",
".",
"substring",
"(",
"7",
")",
";",
"}",
"else",
"{",
"token",
"=",
"\"Bearer \"",
"+",
"token",
";",
"}",
"}",
"request",
".",
"getRequestHeaders",
"(",
")",
".",
"put",
"(",
"Headers",
".",
"AUTHORIZATION",
",",
"token",
")",
";",
"request",
".",
"getRequestHeaders",
"(",
")",
".",
"put",
"(",
"HttpStringConstants",
".",
"TRACEABILITY_ID",
",",
"traceabilityId",
")",
";",
"}"
] | Add Authorization Code grant token the caller app gets from OAuth2 server and add traceabilityId
This is the method called from client like web server that want to have traceabilityId pass through.
@param request the http request
@param token the bearer token
@param traceabilityId the traceability id | [
"Add",
"Authorization",
"Code",
"grant",
"token",
"the",
"caller",
"app",
"gets",
"from",
"OAuth2",
"server",
"and",
"add",
"traceabilityId"
] | train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/Http2Client.java#L294-L305 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java | ExceptionSoftening.visitCode | @Override
public void visitCode(Code obj) {
"""
overrides the visitor to look for methods that catch checked exceptions and
rethrow runtime exceptions
@param obj the context object of the currently parsed code block
"""
try {
Method method = getMethod();
if (method.isSynthetic()) {
return;
}
isBooleanMethod = Type.BOOLEAN.equals(method.getReturnType());
if (isBooleanMethod || prescreen(method)) {
catchHandlerPCs = collectExceptions(obj.getExceptionTable());
if (!catchHandlerPCs.isEmpty()) {
stack.resetForMethodEntry(this);
catchInfos = new ArrayList<>();
lvt = method.getLocalVariableTable();
constrainingInfo = null;
hasValidFalseReturn = false;
catchFalseReturnPC = -1;
super.visitCode(obj);
if (!hasValidFalseReturn && (catchFalseReturnPC >= 0) && !method.getName().startsWith("is")) {
bugReporter.reportBug(new BugInstance(this, BugType.EXS_EXCEPTION_SOFTENING_RETURN_FALSE.name(),
NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this,
catchFalseReturnPC));
}
}
}
} finally {
catchInfos = null;
catchHandlerPCs = null;
lvt = null;
constrainingInfo = null;
}
} | java | @Override
public void visitCode(Code obj) {
try {
Method method = getMethod();
if (method.isSynthetic()) {
return;
}
isBooleanMethod = Type.BOOLEAN.equals(method.getReturnType());
if (isBooleanMethod || prescreen(method)) {
catchHandlerPCs = collectExceptions(obj.getExceptionTable());
if (!catchHandlerPCs.isEmpty()) {
stack.resetForMethodEntry(this);
catchInfos = new ArrayList<>();
lvt = method.getLocalVariableTable();
constrainingInfo = null;
hasValidFalseReturn = false;
catchFalseReturnPC = -1;
super.visitCode(obj);
if (!hasValidFalseReturn && (catchFalseReturnPC >= 0) && !method.getName().startsWith("is")) {
bugReporter.reportBug(new BugInstance(this, BugType.EXS_EXCEPTION_SOFTENING_RETURN_FALSE.name(),
NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this,
catchFalseReturnPC));
}
}
}
} finally {
catchInfos = null;
catchHandlerPCs = null;
lvt = null;
constrainingInfo = null;
}
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"try",
"{",
"Method",
"method",
"=",
"getMethod",
"(",
")",
";",
"if",
"(",
"method",
".",
"isSynthetic",
"(",
")",
")",
"{",
"return",
";",
"}",
"isBooleanMethod",
"=",
"Type",
".",
"BOOLEAN",
".",
"equals",
"(",
"method",
".",
"getReturnType",
"(",
")",
")",
";",
"if",
"(",
"isBooleanMethod",
"||",
"prescreen",
"(",
"method",
")",
")",
"{",
"catchHandlerPCs",
"=",
"collectExceptions",
"(",
"obj",
".",
"getExceptionTable",
"(",
")",
")",
";",
"if",
"(",
"!",
"catchHandlerPCs",
".",
"isEmpty",
"(",
")",
")",
"{",
"stack",
".",
"resetForMethodEntry",
"(",
"this",
")",
";",
"catchInfos",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"lvt",
"=",
"method",
".",
"getLocalVariableTable",
"(",
")",
";",
"constrainingInfo",
"=",
"null",
";",
"hasValidFalseReturn",
"=",
"false",
";",
"catchFalseReturnPC",
"=",
"-",
"1",
";",
"super",
".",
"visitCode",
"(",
"obj",
")",
";",
"if",
"(",
"!",
"hasValidFalseReturn",
"&&",
"(",
"catchFalseReturnPC",
">=",
"0",
")",
"&&",
"!",
"method",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"\"is\"",
")",
")",
"{",
"bugReporter",
".",
"reportBug",
"(",
"new",
"BugInstance",
"(",
"this",
",",
"BugType",
".",
"EXS_EXCEPTION_SOFTENING_RETURN_FALSE",
".",
"name",
"(",
")",
",",
"NORMAL_PRIORITY",
")",
".",
"addClass",
"(",
"this",
")",
".",
"addMethod",
"(",
"this",
")",
".",
"addSourceLine",
"(",
"this",
",",
"catchFalseReturnPC",
")",
")",
";",
"}",
"}",
"}",
"}",
"finally",
"{",
"catchInfos",
"=",
"null",
";",
"catchHandlerPCs",
"=",
"null",
";",
"lvt",
"=",
"null",
";",
"constrainingInfo",
"=",
"null",
";",
"}",
"}"
] | overrides the visitor to look for methods that catch checked exceptions and
rethrow runtime exceptions
@param obj the context object of the currently parsed code block | [
"overrides",
"the",
"visitor",
"to",
"look",
"for",
"methods",
"that",
"catch",
"checked",
"exceptions",
"and",
"rethrow",
"runtime",
"exceptions"
] | train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java#L120-L153 |
epierce/cas-server-extension-token | src/main/java/edu/clayton/cas/support/token/util/Crypto.java | Crypto.encryptWithKey | public static String encryptWithKey(String string, String key)
throws NoSuchPaddingException,
NoSuchAlgorithmException,
InvalidKeyException,
BadPaddingException,
IllegalBlockSizeException,
InvalidAlgorithmParameterException {
"""
Returns a {@link Base64} encoded encrypted string.
@param string The string to encrypt.
@param key The key to use for encryption.
@return The encrypted encoded string.
@throws NoSuchPaddingException
@throws NoSuchAlgorithmException
@throws InvalidKeyException
@throws BadPaddingException
@throws IllegalBlockSizeException
"""
String encryptedString;
byte[] encryptedStringData;
//Create a random initialization vector
SecureRandom random = new SecureRandom();
byte[] randBytes = new byte[16];
random.nextBytes(randBytes);
IvParameterSpec iv = new IvParameterSpec(randBytes);
SecretKeySpec skey = new SecretKeySpec(key.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skey, iv);
byte[] ivBytes = iv.getIV();
byte[] inputBytes = string.getBytes();
byte[] plaintext = new byte[ivBytes.length + inputBytes.length];
System.arraycopy(ivBytes, 0, plaintext, 0, ivBytes.length);
System.arraycopy(inputBytes, 0, plaintext, ivBytes.length, inputBytes.length);
encryptedStringData = cipher.doFinal(plaintext);
encryptedString = Base64.encodeBase64String(encryptedStringData);
return encryptedString;
} | java | public static String encryptWithKey(String string, String key)
throws NoSuchPaddingException,
NoSuchAlgorithmException,
InvalidKeyException,
BadPaddingException,
IllegalBlockSizeException,
InvalidAlgorithmParameterException
{
String encryptedString;
byte[] encryptedStringData;
//Create a random initialization vector
SecureRandom random = new SecureRandom();
byte[] randBytes = new byte[16];
random.nextBytes(randBytes);
IvParameterSpec iv = new IvParameterSpec(randBytes);
SecretKeySpec skey = new SecretKeySpec(key.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skey, iv);
byte[] ivBytes = iv.getIV();
byte[] inputBytes = string.getBytes();
byte[] plaintext = new byte[ivBytes.length + inputBytes.length];
System.arraycopy(ivBytes, 0, plaintext, 0, ivBytes.length);
System.arraycopy(inputBytes, 0, plaintext, ivBytes.length, inputBytes.length);
encryptedStringData = cipher.doFinal(plaintext);
encryptedString = Base64.encodeBase64String(encryptedStringData);
return encryptedString;
} | [
"public",
"static",
"String",
"encryptWithKey",
"(",
"String",
"string",
",",
"String",
"key",
")",
"throws",
"NoSuchPaddingException",
",",
"NoSuchAlgorithmException",
",",
"InvalidKeyException",
",",
"BadPaddingException",
",",
"IllegalBlockSizeException",
",",
"InvalidAlgorithmParameterException",
"{",
"String",
"encryptedString",
";",
"byte",
"[",
"]",
"encryptedStringData",
";",
"//Create a random initialization vector",
"SecureRandom",
"random",
"=",
"new",
"SecureRandom",
"(",
")",
";",
"byte",
"[",
"]",
"randBytes",
"=",
"new",
"byte",
"[",
"16",
"]",
";",
"random",
".",
"nextBytes",
"(",
"randBytes",
")",
";",
"IvParameterSpec",
"iv",
"=",
"new",
"IvParameterSpec",
"(",
"randBytes",
")",
";",
"SecretKeySpec",
"skey",
"=",
"new",
"SecretKeySpec",
"(",
"key",
".",
"getBytes",
"(",
")",
",",
"\"AES\"",
")",
";",
"Cipher",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"\"AES/CBC/PKCS5Padding\"",
")",
";",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"ENCRYPT_MODE",
",",
"skey",
",",
"iv",
")",
";",
"byte",
"[",
"]",
"ivBytes",
"=",
"iv",
".",
"getIV",
"(",
")",
";",
"byte",
"[",
"]",
"inputBytes",
"=",
"string",
".",
"getBytes",
"(",
")",
";",
"byte",
"[",
"]",
"plaintext",
"=",
"new",
"byte",
"[",
"ivBytes",
".",
"length",
"+",
"inputBytes",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"ivBytes",
",",
"0",
",",
"plaintext",
",",
"0",
",",
"ivBytes",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"inputBytes",
",",
"0",
",",
"plaintext",
",",
"ivBytes",
".",
"length",
",",
"inputBytes",
".",
"length",
")",
";",
"encryptedStringData",
"=",
"cipher",
".",
"doFinal",
"(",
"plaintext",
")",
";",
"encryptedString",
"=",
"Base64",
".",
"encodeBase64String",
"(",
"encryptedStringData",
")",
";",
"return",
"encryptedString",
";",
"}"
] | Returns a {@link Base64} encoded encrypted string.
@param string The string to encrypt.
@param key The key to use for encryption.
@return The encrypted encoded string.
@throws NoSuchPaddingException
@throws NoSuchAlgorithmException
@throws InvalidKeyException
@throws BadPaddingException
@throws IllegalBlockSizeException | [
"Returns",
"a",
"{",
"@link",
"Base64",
"}",
"encoded",
"encrypted",
"string",
"."
] | train | https://github.com/epierce/cas-server-extension-token/blob/b63399e6b516a25f624d09161466db87fcec974b/src/main/java/edu/clayton/cas/support/token/util/Crypto.java#L89-L122 |
alipay/sofa-rpc | extension-impl/remoting-bolt/src/main/java/com/alipay/sofa/rpc/transport/bolt/BoltClientTransport.java | BoltClientTransport.doInvokeSync | protected SofaResponse doInvokeSync(SofaRequest request, InvokeContext invokeContext, int timeoutMillis)
throws RemotingException, InterruptedException {
"""
同步调用
@param request 请求对象
@param invokeContext 调用上下文
@param timeoutMillis 超时时间(毫秒)
@return 返回对象
@throws RemotingException 远程调用异常
@throws InterruptedException 中断异常
@since 5.2.0
"""
return (SofaResponse) RPC_CLIENT.invokeSync(url, request, invokeContext, timeoutMillis);
} | java | protected SofaResponse doInvokeSync(SofaRequest request, InvokeContext invokeContext, int timeoutMillis)
throws RemotingException, InterruptedException {
return (SofaResponse) RPC_CLIENT.invokeSync(url, request, invokeContext, timeoutMillis);
} | [
"protected",
"SofaResponse",
"doInvokeSync",
"(",
"SofaRequest",
"request",
",",
"InvokeContext",
"invokeContext",
",",
"int",
"timeoutMillis",
")",
"throws",
"RemotingException",
",",
"InterruptedException",
"{",
"return",
"(",
"SofaResponse",
")",
"RPC_CLIENT",
".",
"invokeSync",
"(",
"url",
",",
"request",
",",
"invokeContext",
",",
"timeoutMillis",
")",
";",
"}"
] | 同步调用
@param request 请求对象
@param invokeContext 调用上下文
@param timeoutMillis 超时时间(毫秒)
@return 返回对象
@throws RemotingException 远程调用异常
@throws InterruptedException 中断异常
@since 5.2.0 | [
"同步调用"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/extension-impl/remoting-bolt/src/main/java/com/alipay/sofa/rpc/transport/bolt/BoltClientTransport.java#L273-L276 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/script/el/tokens/ExpressionToken.java | ExpressionToken.listLookup | protected final Object listLookup(List list, int index) {
"""
Get the value in a {@link List} at <code>index</code>.
@param list the List
@param index the index
@return the value returned from <code>list.get(index)</code>
"""
LOGGER.trace("get value in List index " + index);
return list.get(index);
} | java | protected final Object listLookup(List list, int index) {
LOGGER.trace("get value in List index " + index);
return list.get(index);
} | [
"protected",
"final",
"Object",
"listLookup",
"(",
"List",
"list",
",",
"int",
"index",
")",
"{",
"LOGGER",
".",
"trace",
"(",
"\"get value in List index \"",
"+",
"index",
")",
";",
"return",
"list",
".",
"get",
"(",
"index",
")",
";",
"}"
] | Get the value in a {@link List} at <code>index</code>.
@param list the List
@param index the index
@return the value returned from <code>list.get(index)</code> | [
"Get",
"the",
"value",
"in",
"a",
"{"
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/script/el/tokens/ExpressionToken.java#L72-L75 |
exoplatform/jcr | exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/GroupHandlerImpl.java | GroupHandlerImpl.removeGroup | private Group removeGroup(Session session, Group group, boolean broadcast) throws Exception {
"""
Removes group and all related membership entities. Throws exception if children exist.
"""
if (group == null)
{
throw new OrganizationServiceException("Can not remove group, since it is null");
}
Node groupNode = utils.getGroupNode(session, group);
// need to minus one because of child "jos:memberships" node
long childrenCount = ((ExtendedNode)groupNode).getNodesLazily(1).getSize() - 1;
if (childrenCount > 0)
{
throw new OrganizationServiceException("Can not remove group till children exist");
}
if (broadcast)
{
preDelete(group);
}
removeMemberships(groupNode, broadcast);
groupNode.remove();
session.save();
removeFromCache(group.getId());
removeAllRelatedFromCache(group.getId());
if (broadcast)
{
postDelete(group);
}
return group;
} | java | private Group removeGroup(Session session, Group group, boolean broadcast) throws Exception
{
if (group == null)
{
throw new OrganizationServiceException("Can not remove group, since it is null");
}
Node groupNode = utils.getGroupNode(session, group);
// need to minus one because of child "jos:memberships" node
long childrenCount = ((ExtendedNode)groupNode).getNodesLazily(1).getSize() - 1;
if (childrenCount > 0)
{
throw new OrganizationServiceException("Can not remove group till children exist");
}
if (broadcast)
{
preDelete(group);
}
removeMemberships(groupNode, broadcast);
groupNode.remove();
session.save();
removeFromCache(group.getId());
removeAllRelatedFromCache(group.getId());
if (broadcast)
{
postDelete(group);
}
return group;
} | [
"private",
"Group",
"removeGroup",
"(",
"Session",
"session",
",",
"Group",
"group",
",",
"boolean",
"broadcast",
")",
"throws",
"Exception",
"{",
"if",
"(",
"group",
"==",
"null",
")",
"{",
"throw",
"new",
"OrganizationServiceException",
"(",
"\"Can not remove group, since it is null\"",
")",
";",
"}",
"Node",
"groupNode",
"=",
"utils",
".",
"getGroupNode",
"(",
"session",
",",
"group",
")",
";",
"// need to minus one because of child \"jos:memberships\" node",
"long",
"childrenCount",
"=",
"(",
"(",
"ExtendedNode",
")",
"groupNode",
")",
".",
"getNodesLazily",
"(",
"1",
")",
".",
"getSize",
"(",
")",
"-",
"1",
";",
"if",
"(",
"childrenCount",
">",
"0",
")",
"{",
"throw",
"new",
"OrganizationServiceException",
"(",
"\"Can not remove group till children exist\"",
")",
";",
"}",
"if",
"(",
"broadcast",
")",
"{",
"preDelete",
"(",
"group",
")",
";",
"}",
"removeMemberships",
"(",
"groupNode",
",",
"broadcast",
")",
";",
"groupNode",
".",
"remove",
"(",
")",
";",
"session",
".",
"save",
"(",
")",
";",
"removeFromCache",
"(",
"group",
".",
"getId",
"(",
")",
")",
";",
"removeAllRelatedFromCache",
"(",
"group",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"broadcast",
")",
"{",
"postDelete",
"(",
"group",
")",
";",
"}",
"return",
"group",
";",
"}"
] | Removes group and all related membership entities. Throws exception if children exist. | [
"Removes",
"group",
"and",
"all",
"related",
"membership",
"entities",
".",
"Throws",
"exception",
"if",
"children",
"exist",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/GroupHandlerImpl.java#L358-L393 |
cybazeitalia/emaze-dysfunctional | src/main/java/net/emaze/dysfunctional/Spies.java | Spies.spy1st | public static <T> Consumer<T> spy1st(Consumer<T> consumer, Box<T> param) {
"""
Proxies a binary consumer spying for first parameter.
@param <T> the consumer parameter type
@param consumer the consumer that will be spied
@param param a box that will be containing the spied parameter
@return the proxied consumer
"""
return spy(consumer, param);
} | java | public static <T> Consumer<T> spy1st(Consumer<T> consumer, Box<T> param) {
return spy(consumer, param);
} | [
"public",
"static",
"<",
"T",
">",
"Consumer",
"<",
"T",
">",
"spy1st",
"(",
"Consumer",
"<",
"T",
">",
"consumer",
",",
"Box",
"<",
"T",
">",
"param",
")",
"{",
"return",
"spy",
"(",
"consumer",
",",
"param",
")",
";",
"}"
] | Proxies a binary consumer spying for first parameter.
@param <T> the consumer parameter type
@param consumer the consumer that will be spied
@param param a box that will be containing the spied parameter
@return the proxied consumer | [
"Proxies",
"a",
"binary",
"consumer",
"spying",
"for",
"first",
"parameter",
"."
] | train | https://github.com/cybazeitalia/emaze-dysfunctional/blob/98115a436e35335c5e8831f9fdc12f6d93d524be/src/main/java/net/emaze/dysfunctional/Spies.java#L387-L389 |
alkacon/opencms-core | src/org/opencms/db/CmsDriverManager.java | CmsDriverManager.writeHistoryProject | public void writeHistoryProject(CmsDbContext dbc, int publishTag, long publishDate) throws CmsDataAccessException {
"""
Creates an historical entry of the current project.<p>
@param dbc the current database context
@param publishTag the version
@param publishDate the date of publishing
@throws CmsDataAccessException if operation was not successful
"""
getHistoryDriver(dbc).writeProject(dbc, publishTag, publishDate);
} | java | public void writeHistoryProject(CmsDbContext dbc, int publishTag, long publishDate) throws CmsDataAccessException {
getHistoryDriver(dbc).writeProject(dbc, publishTag, publishDate);
} | [
"public",
"void",
"writeHistoryProject",
"(",
"CmsDbContext",
"dbc",
",",
"int",
"publishTag",
",",
"long",
"publishDate",
")",
"throws",
"CmsDataAccessException",
"{",
"getHistoryDriver",
"(",
"dbc",
")",
".",
"writeProject",
"(",
"dbc",
",",
"publishTag",
",",
"publishDate",
")",
";",
"}"
] | Creates an historical entry of the current project.<p>
@param dbc the current database context
@param publishTag the version
@param publishDate the date of publishing
@throws CmsDataAccessException if operation was not successful | [
"Creates",
"an",
"historical",
"entry",
"of",
"the",
"current",
"project",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L9870-L9873 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/validator/CommonsValidatorGenerator.java | CommonsValidatorGenerator.getJavascriptBegin | protected String getJavascriptBegin(String jsFormName, String methods) {
"""
Returns the opening script element and some initial javascript.
"""
StringBuffer sb = new StringBuffer();
String name = jsFormName.replace('/', '_'); // remove any '/' characters
name = jsFormName.substring(0, 1).toUpperCase()
+ jsFormName.substring(1, jsFormName.length());
sb.append("\n var bCancel = false; \n\n");
sb.append(" function validate" + name + "(form) { \n");
sb.append(" if (bCancel) { \n");
sb.append(" return true; \n");
sb.append(" } else { \n");
// Always return true if there aren't any Javascript validation methods
if ((methods == null) || (methods.length() == 0)) {
sb.append(" return true; \n");
} else {
sb.append(" var formValidationResult; \n");
sb.append(" formValidationResult = " + methods + "; \n");
if (methods.indexOf("&&") >= 0) {
sb.append(" return (formValidationResult); \n");
} else {
// Making Sure that Bitwise operator works:
sb.append(" return (formValidationResult == 1); \n");
}
}
sb.append(" } \n");
sb.append(" } \n\n");
return sb.toString();
} | java | protected String getJavascriptBegin(String jsFormName, String methods) {
StringBuffer sb = new StringBuffer();
String name = jsFormName.replace('/', '_'); // remove any '/' characters
name = jsFormName.substring(0, 1).toUpperCase()
+ jsFormName.substring(1, jsFormName.length());
sb.append("\n var bCancel = false; \n\n");
sb.append(" function validate" + name + "(form) { \n");
sb.append(" if (bCancel) { \n");
sb.append(" return true; \n");
sb.append(" } else { \n");
// Always return true if there aren't any Javascript validation methods
if ((methods == null) || (methods.length() == 0)) {
sb.append(" return true; \n");
} else {
sb.append(" var formValidationResult; \n");
sb.append(" formValidationResult = " + methods + "; \n");
if (methods.indexOf("&&") >= 0) {
sb.append(" return (formValidationResult); \n");
} else {
// Making Sure that Bitwise operator works:
sb.append(" return (formValidationResult == 1); \n");
}
}
sb.append(" } \n");
sb.append(" } \n\n");
return sb.toString();
} | [
"protected",
"String",
"getJavascriptBegin",
"(",
"String",
"jsFormName",
",",
"String",
"methods",
")",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"String",
"name",
"=",
"jsFormName",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"// remove any '/' characters",
"name",
"=",
"jsFormName",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"jsFormName",
".",
"substring",
"(",
"1",
",",
"jsFormName",
".",
"length",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"\\n var bCancel = false; \\n\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\" function validate\"",
"+",
"name",
"+",
"\"(form) { \\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\" if (bCancel) { \\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\" return true; \\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\" } else { \\n\"",
")",
";",
"// Always return true if there aren't any Javascript validation methods",
"if",
"(",
"(",
"methods",
"==",
"null",
")",
"||",
"(",
"methods",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\" return true; \\n\"",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\" var formValidationResult; \\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\" formValidationResult = \"",
"+",
"methods",
"+",
"\"; \\n\"",
")",
";",
"if",
"(",
"methods",
".",
"indexOf",
"(",
"\"&&\"",
")",
">=",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\" return (formValidationResult); \\n\"",
")",
";",
"}",
"else",
"{",
"// Making Sure that Bitwise operator works:",
"sb",
".",
"append",
"(",
"\" return (formValidationResult == 1); \\n\"",
")",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"\" } \\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\" } \\n\\n\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Returns the opening script element and some initial javascript. | [
"Returns",
"the",
"opening",
"script",
"element",
"and",
"some",
"initial",
"javascript",
"."
] | 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/validator/CommonsValidatorGenerator.java#L282-L312 |
mapbox/mapbox-navigation-android | libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/map/NavigationMapboxMap.java | NavigationMapboxMap.saveStateWith | public void saveStateWith(String key, Bundle outState) {
"""
Can be used to store the current state of the map in
{@link android.support.v4.app.FragmentActivity#onSaveInstanceState(Bundle, PersistableBundle)}.
<p>
This method uses {@link NavigationMapboxMapInstanceState}, stored with the provided key. This key
can also later be used to extract the {@link NavigationMapboxMapInstanceState}.
@param key used to store the state
@param outState to store state variables
"""
settings.updateCurrentPadding(mapPaddingAdjustor.retrieveCurrentPadding());
settings.updateShouldUseDefaultPadding(mapPaddingAdjustor.isUsingDefault());
settings.updateCameraTrackingMode(mapCamera.getCameraTrackingMode());
settings.updateLocationFpsEnabled(locationFpsDelegate.isEnabled());
NavigationMapboxMapInstanceState instanceState = new NavigationMapboxMapInstanceState(settings);
outState.putParcelable(key, instanceState);
} | java | public void saveStateWith(String key, Bundle outState) {
settings.updateCurrentPadding(mapPaddingAdjustor.retrieveCurrentPadding());
settings.updateShouldUseDefaultPadding(mapPaddingAdjustor.isUsingDefault());
settings.updateCameraTrackingMode(mapCamera.getCameraTrackingMode());
settings.updateLocationFpsEnabled(locationFpsDelegate.isEnabled());
NavigationMapboxMapInstanceState instanceState = new NavigationMapboxMapInstanceState(settings);
outState.putParcelable(key, instanceState);
} | [
"public",
"void",
"saveStateWith",
"(",
"String",
"key",
",",
"Bundle",
"outState",
")",
"{",
"settings",
".",
"updateCurrentPadding",
"(",
"mapPaddingAdjustor",
".",
"retrieveCurrentPadding",
"(",
")",
")",
";",
"settings",
".",
"updateShouldUseDefaultPadding",
"(",
"mapPaddingAdjustor",
".",
"isUsingDefault",
"(",
")",
")",
";",
"settings",
".",
"updateCameraTrackingMode",
"(",
"mapCamera",
".",
"getCameraTrackingMode",
"(",
")",
")",
";",
"settings",
".",
"updateLocationFpsEnabled",
"(",
"locationFpsDelegate",
".",
"isEnabled",
"(",
")",
")",
";",
"NavigationMapboxMapInstanceState",
"instanceState",
"=",
"new",
"NavigationMapboxMapInstanceState",
"(",
"settings",
")",
";",
"outState",
".",
"putParcelable",
"(",
"key",
",",
"instanceState",
")",
";",
"}"
] | Can be used to store the current state of the map in
{@link android.support.v4.app.FragmentActivity#onSaveInstanceState(Bundle, PersistableBundle)}.
<p>
This method uses {@link NavigationMapboxMapInstanceState}, stored with the provided key. This key
can also later be used to extract the {@link NavigationMapboxMapInstanceState}.
@param key used to store the state
@param outState to store state variables | [
"Can",
"be",
"used",
"to",
"store",
"the",
"current",
"state",
"of",
"the",
"map",
"in",
"{",
"@link",
"android",
".",
"support",
".",
"v4",
".",
"app",
".",
"FragmentActivity#onSaveInstanceState",
"(",
"Bundle",
"PersistableBundle",
")",
"}",
".",
"<p",
">",
"This",
"method",
"uses",
"{",
"@link",
"NavigationMapboxMapInstanceState",
"}",
"stored",
"with",
"the",
"provided",
"key",
".",
"This",
"key",
"can",
"also",
"later",
"be",
"used",
"to",
"extract",
"the",
"{",
"@link",
"NavigationMapboxMapInstanceState",
"}",
"."
] | train | https://github.com/mapbox/mapbox-navigation-android/blob/375a89c017d360b9defc2c90d0c03468165162ec/libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/map/NavigationMapboxMap.java#L295-L302 |
Pixplicity/EasyPrefs | library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java | Prefs.getStringSet | @SuppressWarnings("WeakerAccess")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static Set<String> getStringSet(final String key, final Set<String> defValue) {
"""
Retrieves a Set of Strings as stored by {@link #putStringSet(String, Set)}. On Honeycomb and
later this will call the native implementation in SharedPreferences, on older SDKs this will
call {@link #getOrderedStringSet(String, Set)}.
<strong>Note that the native implementation of {@link SharedPreferences#getStringSet(String,
Set)} does not reliably preserve the order of the Strings in the Set.</strong>
@param key The name of the preference to retrieve.
@param defValue Value to return if this preference does not exist.
@return Returns the preference values if they exist, or defValues otherwise.
@throws ClassCastException if there is a preference with this name that is not a Set.
@see android.content.SharedPreferences#getStringSet(String, java.util.Set)
@see #getOrderedStringSet(String, Set)
"""
SharedPreferences prefs = getPreferences();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return prefs.getStringSet(key, defValue);
} else {
// Workaround for pre-HC's missing getStringSet
return getOrderedStringSet(key, defValue);
}
} | java | @SuppressWarnings("WeakerAccess")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static Set<String> getStringSet(final String key, final Set<String> defValue) {
SharedPreferences prefs = getPreferences();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return prefs.getStringSet(key, defValue);
} else {
// Workaround for pre-HC's missing getStringSet
return getOrderedStringSet(key, defValue);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"public",
"static",
"Set",
"<",
"String",
">",
"getStringSet",
"(",
"final",
"String",
"key",
",",
"final",
"Set",
"<",
"String",
">",
"defValue",
")",
"{",
"SharedPreferences",
"prefs",
"=",
"getPreferences",
"(",
")",
";",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"{",
"return",
"prefs",
".",
"getStringSet",
"(",
"key",
",",
"defValue",
")",
";",
"}",
"else",
"{",
"// Workaround for pre-HC's missing getStringSet",
"return",
"getOrderedStringSet",
"(",
"key",
",",
"defValue",
")",
";",
"}",
"}"
] | Retrieves a Set of Strings as stored by {@link #putStringSet(String, Set)}. On Honeycomb and
later this will call the native implementation in SharedPreferences, on older SDKs this will
call {@link #getOrderedStringSet(String, Set)}.
<strong>Note that the native implementation of {@link SharedPreferences#getStringSet(String,
Set)} does not reliably preserve the order of the Strings in the Set.</strong>
@param key The name of the preference to retrieve.
@param defValue Value to return if this preference does not exist.
@return Returns the preference values if they exist, or defValues otherwise.
@throws ClassCastException if there is a preference with this name that is not a Set.
@see android.content.SharedPreferences#getStringSet(String, java.util.Set)
@see #getOrderedStringSet(String, Set) | [
"Retrieves",
"a",
"Set",
"of",
"Strings",
"as",
"stored",
"by",
"{",
"@link",
"#putStringSet",
"(",
"String",
"Set",
")",
"}",
".",
"On",
"Honeycomb",
"and",
"later",
"this",
"will",
"call",
"the",
"native",
"implementation",
"in",
"SharedPreferences",
"on",
"older",
"SDKs",
"this",
"will",
"call",
"{",
"@link",
"#getOrderedStringSet",
"(",
"String",
"Set",
")",
"}",
".",
"<strong",
">",
"Note",
"that",
"the",
"native",
"implementation",
"of",
"{",
"@link",
"SharedPreferences#getStringSet",
"(",
"String",
"Set",
")",
"}",
"does",
"not",
"reliably",
"preserve",
"the",
"order",
"of",
"the",
"Strings",
"in",
"the",
"Set",
".",
"<",
"/",
"strong",
">"
] | train | https://github.com/Pixplicity/EasyPrefs/blob/0ca13a403bf099019a13d68b38edcf55fca5a653/library/src/main/java/com/pixplicity/easyprefs/library/Prefs.java#L230-L240 |
EdwardRaff/JSAT | JSAT/src/jsat/linear/Matrix.java | Matrix.getColumn | public Vec getColumn(int j) {
"""
Creates a vector that has a copy of the values in column <i>j</i> of this
matrix. Altering it will not effect the values in <i>this</i> matrix
@param j the column to copy
@return a clone of the column as a {@link Vec}
"""
if(j < 0 || j >= cols())
throw new ArithmeticException("Column was not a valid value " + j + " not in [0," + (cols()-1) + "]");
DenseVector c = new DenseVector(rows());
for(int i =0; i < rows(); i++)
c.set(i, get(i, j));
return c;
} | java | public Vec getColumn(int j)
{
if(j < 0 || j >= cols())
throw new ArithmeticException("Column was not a valid value " + j + " not in [0," + (cols()-1) + "]");
DenseVector c = new DenseVector(rows());
for(int i =0; i < rows(); i++)
c.set(i, get(i, j));
return c;
} | [
"public",
"Vec",
"getColumn",
"(",
"int",
"j",
")",
"{",
"if",
"(",
"j",
"<",
"0",
"||",
"j",
">=",
"cols",
"(",
")",
")",
"throw",
"new",
"ArithmeticException",
"(",
"\"Column was not a valid value \"",
"+",
"j",
"+",
"\" not in [0,\"",
"+",
"(",
"cols",
"(",
")",
"-",
"1",
")",
"+",
"\"]\"",
")",
";",
"DenseVector",
"c",
"=",
"new",
"DenseVector",
"(",
"rows",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
"(",
")",
";",
"i",
"++",
")",
"c",
".",
"set",
"(",
"i",
",",
"get",
"(",
"i",
",",
"j",
")",
")",
";",
"return",
"c",
";",
"}"
] | Creates a vector that has a copy of the values in column <i>j</i> of this
matrix. Altering it will not effect the values in <i>this</i> matrix
@param j the column to copy
@return a clone of the column as a {@link Vec} | [
"Creates",
"a",
"vector",
"that",
"has",
"a",
"copy",
"of",
"the",
"values",
"in",
"column",
"<i",
">",
"j<",
"/",
"i",
">",
"of",
"this",
"matrix",
".",
"Altering",
"it",
"will",
"not",
"effect",
"the",
"values",
"in",
"<i",
">",
"this<",
"/",
"i",
">",
"matrix"
] | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/linear/Matrix.java#L610-L618 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.getMarkerAnchor | public Content getMarkerAnchor(String anchorName, Content anchorContent) {
"""
Get the marker anchor which will be added to the documentation tree.
@param anchorName the anchor name attribute
@param anchorContent the content that should be added to the anchor
@return a content tree for the marker anchor
"""
if (anchorContent == null)
anchorContent = new Comment(" ");
Content markerAnchor = HtmlTree.A_NAME(anchorName, anchorContent);
return markerAnchor;
} | java | public Content getMarkerAnchor(String anchorName, Content anchorContent) {
if (anchorContent == null)
anchorContent = new Comment(" ");
Content markerAnchor = HtmlTree.A_NAME(anchorName, anchorContent);
return markerAnchor;
} | [
"public",
"Content",
"getMarkerAnchor",
"(",
"String",
"anchorName",
",",
"Content",
"anchorContent",
")",
"{",
"if",
"(",
"anchorContent",
"==",
"null",
")",
"anchorContent",
"=",
"new",
"Comment",
"(",
"\" \"",
")",
";",
"Content",
"markerAnchor",
"=",
"HtmlTree",
".",
"A_NAME",
"(",
"anchorName",
",",
"anchorContent",
")",
";",
"return",
"markerAnchor",
";",
"}"
] | Get the marker anchor which will be added to the documentation tree.
@param anchorName the anchor name attribute
@param anchorContent the content that should be added to the anchor
@return a content tree for the marker anchor | [
"Get",
"the",
"marker",
"anchor",
"which",
"will",
"be",
"added",
"to",
"the",
"documentation",
"tree",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L902-L907 |
wildfly/wildfly-core | protocol/src/main/java/org/jboss/as/protocol/mgmt/AbstractMessageHandler.java | AbstractMessageHandler.handleMessage | @Override
public void handleMessage(final Channel channel, final DataInput input, final ManagementProtocolHeader header) throws IOException {
"""
Handle a message.
@param channel the channel
@param input the message
@param header the management protocol header
@throws IOException
"""
final byte type = header.getType();
if(type == ManagementProtocol.TYPE_RESPONSE) {
// Handle response to local requests
final ManagementResponseHeader response = (ManagementResponseHeader) header;
final ActiveRequest<?, ?> request = requests.remove(response.getResponseId());
if(request == null) {
ProtocolLogger.CONNECTION_LOGGER.noSuchRequest(response.getResponseId(), channel);
safeWriteErrorResponse(channel, header, ProtocolLogger.ROOT_LOGGER.responseHandlerNotFound(response.getResponseId()));
} else if(response.getError() != null) {
request.handleFailed(response);
} else {
handleRequest(channel, input, header, request);
}
} else {
// Handle requests (or other messages)
try {
final ManagementRequestHeader requestHeader = validateRequest(header);
final ManagementRequestHandler<?, ?> handler = getRequestHandler(requestHeader);
if(handler == null) {
safeWriteErrorResponse(channel, header, ProtocolLogger.ROOT_LOGGER.responseHandlerNotFound(requestHeader.getBatchId()));
} else {
handleMessage(channel, input, requestHeader, handler);
}
} catch (Exception e) {
safeWriteErrorResponse(channel, header, e);
}
}
} | java | @Override
public void handleMessage(final Channel channel, final DataInput input, final ManagementProtocolHeader header) throws IOException {
final byte type = header.getType();
if(type == ManagementProtocol.TYPE_RESPONSE) {
// Handle response to local requests
final ManagementResponseHeader response = (ManagementResponseHeader) header;
final ActiveRequest<?, ?> request = requests.remove(response.getResponseId());
if(request == null) {
ProtocolLogger.CONNECTION_LOGGER.noSuchRequest(response.getResponseId(), channel);
safeWriteErrorResponse(channel, header, ProtocolLogger.ROOT_LOGGER.responseHandlerNotFound(response.getResponseId()));
} else if(response.getError() != null) {
request.handleFailed(response);
} else {
handleRequest(channel, input, header, request);
}
} else {
// Handle requests (or other messages)
try {
final ManagementRequestHeader requestHeader = validateRequest(header);
final ManagementRequestHandler<?, ?> handler = getRequestHandler(requestHeader);
if(handler == null) {
safeWriteErrorResponse(channel, header, ProtocolLogger.ROOT_LOGGER.responseHandlerNotFound(requestHeader.getBatchId()));
} else {
handleMessage(channel, input, requestHeader, handler);
}
} catch (Exception e) {
safeWriteErrorResponse(channel, header, e);
}
}
} | [
"@",
"Override",
"public",
"void",
"handleMessage",
"(",
"final",
"Channel",
"channel",
",",
"final",
"DataInput",
"input",
",",
"final",
"ManagementProtocolHeader",
"header",
")",
"throws",
"IOException",
"{",
"final",
"byte",
"type",
"=",
"header",
".",
"getType",
"(",
")",
";",
"if",
"(",
"type",
"==",
"ManagementProtocol",
".",
"TYPE_RESPONSE",
")",
"{",
"// Handle response to local requests",
"final",
"ManagementResponseHeader",
"response",
"=",
"(",
"ManagementResponseHeader",
")",
"header",
";",
"final",
"ActiveRequest",
"<",
"?",
",",
"?",
">",
"request",
"=",
"requests",
".",
"remove",
"(",
"response",
".",
"getResponseId",
"(",
")",
")",
";",
"if",
"(",
"request",
"==",
"null",
")",
"{",
"ProtocolLogger",
".",
"CONNECTION_LOGGER",
".",
"noSuchRequest",
"(",
"response",
".",
"getResponseId",
"(",
")",
",",
"channel",
")",
";",
"safeWriteErrorResponse",
"(",
"channel",
",",
"header",
",",
"ProtocolLogger",
".",
"ROOT_LOGGER",
".",
"responseHandlerNotFound",
"(",
"response",
".",
"getResponseId",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"response",
".",
"getError",
"(",
")",
"!=",
"null",
")",
"{",
"request",
".",
"handleFailed",
"(",
"response",
")",
";",
"}",
"else",
"{",
"handleRequest",
"(",
"channel",
",",
"input",
",",
"header",
",",
"request",
")",
";",
"}",
"}",
"else",
"{",
"// Handle requests (or other messages)",
"try",
"{",
"final",
"ManagementRequestHeader",
"requestHeader",
"=",
"validateRequest",
"(",
"header",
")",
";",
"final",
"ManagementRequestHandler",
"<",
"?",
",",
"?",
">",
"handler",
"=",
"getRequestHandler",
"(",
"requestHeader",
")",
";",
"if",
"(",
"handler",
"==",
"null",
")",
"{",
"safeWriteErrorResponse",
"(",
"channel",
",",
"header",
",",
"ProtocolLogger",
".",
"ROOT_LOGGER",
".",
"responseHandlerNotFound",
"(",
"requestHeader",
".",
"getBatchId",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"handleMessage",
"(",
"channel",
",",
"input",
",",
"requestHeader",
",",
"handler",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"safeWriteErrorResponse",
"(",
"channel",
",",
"header",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Handle a message.
@param channel the channel
@param input the message
@param header the management protocol header
@throws IOException | [
"Handle",
"a",
"message",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/protocol/src/main/java/org/jboss/as/protocol/mgmt/AbstractMessageHandler.java#L221-L250 |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java | SqlExecutor.queryAndClosePs | public static <T> T queryAndClosePs(PreparedStatement ps, RsHandler<T> rsh, Object... params) throws SQLException {
"""
执行查询语句并关闭PreparedStatement
@param <T> 处理结果类型
@param ps PreparedStatement
@param rsh 结果集处理对象
@param params 参数
@return 结果对象
@throws SQLException SQL执行异常
"""
try {
return query(ps, rsh, params);
} finally {
DbUtil.close(ps);
}
} | java | public static <T> T queryAndClosePs(PreparedStatement ps, RsHandler<T> rsh, Object... params) throws SQLException {
try {
return query(ps, rsh, params);
} finally {
DbUtil.close(ps);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"queryAndClosePs",
"(",
"PreparedStatement",
"ps",
",",
"RsHandler",
"<",
"T",
">",
"rsh",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"return",
"query",
"(",
"ps",
",",
"rsh",
",",
"params",
")",
";",
"}",
"finally",
"{",
"DbUtil",
".",
"close",
"(",
"ps",
")",
";",
"}",
"}"
] | 执行查询语句并关闭PreparedStatement
@param <T> 处理结果类型
@param ps PreparedStatement
@param rsh 结果集处理对象
@param params 参数
@return 结果对象
@throws SQLException SQL执行异常 | [
"执行查询语句并关闭PreparedStatement"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java#L327-L333 |
landawn/AbacusUtil | src/com/landawn/abacus/util/StringUtil.java | StringUtil.replaceAll | public static String replaceAll(final String str, final String target, final String replacement) {
"""
<p>
Replaces all occurrences of a String within another String.
</p>
<p>
A {@code null} reference passed to this method is a no-op.
</p>
<pre>
N.replaceAll(null, *, *) = null
N.replaceAll("", *, *) = ""
N.replaceAll("any", null, *) = "any"
N.replaceAll("any", *, null) = "any"
N.replaceAll("any", "", *) = "any"
N.replaceAll("aba", "a", null) = "aba"
N.replaceAll("aba", "a", "") = "b"
N.replaceAll("aba", "a", "z") = "zbz"
</pre>
@see #replaceAll(String text, String searchString, String replacement,
int max)
@param str
text to search and replace in, may be null
@param target
the String to search for, may be null
@param replacement
the String to replace it with, may be null
@return the text with any replacements processed, {@code null} if null
String input
"""
return replaceAll(str, 0, target, replacement);
} | java | public static String replaceAll(final String str, final String target, final String replacement) {
return replaceAll(str, 0, target, replacement);
} | [
"public",
"static",
"String",
"replaceAll",
"(",
"final",
"String",
"str",
",",
"final",
"String",
"target",
",",
"final",
"String",
"replacement",
")",
"{",
"return",
"replaceAll",
"(",
"str",
",",
"0",
",",
"target",
",",
"replacement",
")",
";",
"}"
] | <p>
Replaces all occurrences of a String within another String.
</p>
<p>
A {@code null} reference passed to this method is a no-op.
</p>
<pre>
N.replaceAll(null, *, *) = null
N.replaceAll("", *, *) = ""
N.replaceAll("any", null, *) = "any"
N.replaceAll("any", *, null) = "any"
N.replaceAll("any", "", *) = "any"
N.replaceAll("aba", "a", null) = "aba"
N.replaceAll("aba", "a", "") = "b"
N.replaceAll("aba", "a", "z") = "zbz"
</pre>
@see #replaceAll(String text, String searchString, String replacement,
int max)
@param str
text to search and replace in, may be null
@param target
the String to search for, may be null
@param replacement
the String to replace it with, may be null
@return the text with any replacements processed, {@code null} if null
String input | [
"<p",
">",
"Replaces",
"all",
"occurrences",
"of",
"a",
"String",
"within",
"another",
"String",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/StringUtil.java#L985-L987 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/commands/ServerDumpPackager.java | ServerDumpPackager.packageServerDumps | private ReturnCode packageServerDumps(File packageFile, List<String> javaDumps) {
"""
Creates an archive containing the server dumps, server configurations.
@param packageFile
@return
"""
DumpProcessor processor = new DumpProcessor(serverName, packageFile, bootProps, javaDumps);
return processor.execute();
} | java | private ReturnCode packageServerDumps(File packageFile, List<String> javaDumps) {
DumpProcessor processor = new DumpProcessor(serverName, packageFile, bootProps, javaDumps);
return processor.execute();
} | [
"private",
"ReturnCode",
"packageServerDumps",
"(",
"File",
"packageFile",
",",
"List",
"<",
"String",
">",
"javaDumps",
")",
"{",
"DumpProcessor",
"processor",
"=",
"new",
"DumpProcessor",
"(",
"serverName",
",",
"packageFile",
",",
"bootProps",
",",
"javaDumps",
")",
";",
"return",
"processor",
".",
"execute",
"(",
")",
";",
"}"
] | Creates an archive containing the server dumps, server configurations.
@param packageFile
@return | [
"Creates",
"an",
"archive",
"containing",
"the",
"server",
"dumps",
"server",
"configurations",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/commands/ServerDumpPackager.java#L354-L357 |
jmapper-framework/jmapper-core | JMapper Framework/src/main/java/com/googlecode/jmapper/config/Error.java | Error.attributeAbsent | public static void attributeAbsent(Class<?> aClass,Attribute aField) {
"""
Thrown if the attribute doesn't exist in aClass.
@param aClass class that not contains aField
@param aField the missing field
"""
throw new XmlMappingAttributeDoesNotExistException(MSG.INSTANCE.message(xmlMappingAttributeDoesNotExistException2,aField.getName(),aClass.getSimpleName(),"API"));
} | java | public static void attributeAbsent(Class<?> aClass,Attribute aField){
throw new XmlMappingAttributeDoesNotExistException(MSG.INSTANCE.message(xmlMappingAttributeDoesNotExistException2,aField.getName(),aClass.getSimpleName(),"API"));
} | [
"public",
"static",
"void",
"attributeAbsent",
"(",
"Class",
"<",
"?",
">",
"aClass",
",",
"Attribute",
"aField",
")",
"{",
"throw",
"new",
"XmlMappingAttributeDoesNotExistException",
"(",
"MSG",
".",
"INSTANCE",
".",
"message",
"(",
"xmlMappingAttributeDoesNotExistException2",
",",
"aField",
".",
"getName",
"(",
")",
",",
"aClass",
".",
"getSimpleName",
"(",
")",
",",
"\"API\"",
")",
")",
";",
"}"
] | Thrown if the attribute doesn't exist in aClass.
@param aClass class that not contains aField
@param aField the missing field | [
"Thrown",
"if",
"the",
"attribute",
"doesn",
"t",
"exist",
"in",
"aClass",
"."
] | train | https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/config/Error.java#L499-L501 |
deeplearning4j/deeplearning4j | datavec/datavec-arrow/src/main/java/org/datavec/arrow/ArrowConverter.java | ArrowConverter.ndarrayVectorOf | public static VarBinaryVector ndarrayVectorOf(BufferAllocator allocator,String name,int length) {
"""
Create an ndarray vector that stores structs
of {@link INDArray}
based on the {@link org.apache.arrow.flatbuf.Tensor}
format
@param allocator the allocator to use
@param name the name of the vector
@param length the number of vectors to store
@return
"""
VarBinaryVector ret = new VarBinaryVector(name,allocator);
ret.allocateNewSafe();
ret.setValueCount(length);
return ret;
} | java | public static VarBinaryVector ndarrayVectorOf(BufferAllocator allocator,String name,int length) {
VarBinaryVector ret = new VarBinaryVector(name,allocator);
ret.allocateNewSafe();
ret.setValueCount(length);
return ret;
} | [
"public",
"static",
"VarBinaryVector",
"ndarrayVectorOf",
"(",
"BufferAllocator",
"allocator",
",",
"String",
"name",
",",
"int",
"length",
")",
"{",
"VarBinaryVector",
"ret",
"=",
"new",
"VarBinaryVector",
"(",
"name",
",",
"allocator",
")",
";",
"ret",
".",
"allocateNewSafe",
"(",
")",
";",
"ret",
".",
"setValueCount",
"(",
"length",
")",
";",
"return",
"ret",
";",
"}"
] | Create an ndarray vector that stores structs
of {@link INDArray}
based on the {@link org.apache.arrow.flatbuf.Tensor}
format
@param allocator the allocator to use
@param name the name of the vector
@param length the number of vectors to store
@return | [
"Create",
"an",
"ndarray",
"vector",
"that",
"stores",
"structs",
"of",
"{"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-arrow/src/main/java/org/datavec/arrow/ArrowConverter.java#L943-L948 |
dbracewell/mango | src/main/java/com/davidbracewell/conversion/Val.java | Val.asMap | public <K, V> Map<K, V> asMap(@NonNull Class<?> mapClass, @NonNull Class<K> keyClass, @NonNull Class<V> valueClass) {
"""
Converts the object to a map
@param <K> the type parameter
@param <V> the type parameter
@param mapClass The map class
@param keyClass The key class
@param valueClass The value class
@return the object as a map
"""
return convert(toConvert, mapClass, keyClass, valueClass);
} | java | public <K, V> Map<K, V> asMap(@NonNull Class<?> mapClass, @NonNull Class<K> keyClass, @NonNull Class<V> valueClass) {
return convert(toConvert, mapClass, keyClass, valueClass);
} | [
"public",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"asMap",
"(",
"@",
"NonNull",
"Class",
"<",
"?",
">",
"mapClass",
",",
"@",
"NonNull",
"Class",
"<",
"K",
">",
"keyClass",
",",
"@",
"NonNull",
"Class",
"<",
"V",
">",
"valueClass",
")",
"{",
"return",
"convert",
"(",
"toConvert",
",",
"mapClass",
",",
"keyClass",
",",
"valueClass",
")",
";",
"}"
] | Converts the object to a map
@param <K> the type parameter
@param <V> the type parameter
@param mapClass The map class
@param keyClass The key class
@param valueClass The value class
@return the object as a map | [
"Converts",
"the",
"object",
"to",
"a",
"map"
] | train | https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Val.java#L130-L132 |
grantland/android-autofittextview | library/src/main/java/me/grantland/widget/AutofitHelper.java | AutofitHelper.setMaxTextSize | public AutofitHelper setMaxTextSize(int unit, float size) {
"""
Set the maximum text size to a given unit and value. See TypedValue for the possible
dimension units.
@param unit The desired dimension unit.
@param size The desired size in the given units.
@attr ref android.R.styleable#TextView_textSize
"""
Context context = mTextView.getContext();
Resources r = Resources.getSystem();
if (context != null) {
r = context.getResources();
}
setRawMaxTextSize(TypedValue.applyDimension(unit, size, r.getDisplayMetrics()));
return this;
} | java | public AutofitHelper setMaxTextSize(int unit, float size) {
Context context = mTextView.getContext();
Resources r = Resources.getSystem();
if (context != null) {
r = context.getResources();
}
setRawMaxTextSize(TypedValue.applyDimension(unit, size, r.getDisplayMetrics()));
return this;
} | [
"public",
"AutofitHelper",
"setMaxTextSize",
"(",
"int",
"unit",
",",
"float",
"size",
")",
"{",
"Context",
"context",
"=",
"mTextView",
".",
"getContext",
"(",
")",
";",
"Resources",
"r",
"=",
"Resources",
".",
"getSystem",
"(",
")",
";",
"if",
"(",
"context",
"!=",
"null",
")",
"{",
"r",
"=",
"context",
".",
"getResources",
"(",
")",
";",
"}",
"setRawMaxTextSize",
"(",
"TypedValue",
".",
"applyDimension",
"(",
"unit",
",",
"size",
",",
"r",
".",
"getDisplayMetrics",
"(",
")",
")",
")",
";",
"return",
"this",
";",
"}"
] | Set the maximum text size to a given unit and value. See TypedValue for the possible
dimension units.
@param unit The desired dimension unit.
@param size The desired size in the given units.
@attr ref android.R.styleable#TextView_textSize | [
"Set",
"the",
"maximum",
"text",
"size",
"to",
"a",
"given",
"unit",
"and",
"value",
".",
"See",
"TypedValue",
"for",
"the",
"possible",
"dimension",
"units",
"."
] | train | https://github.com/grantland/android-autofittextview/blob/5c565aa5c3ed62aaa31140440bb526e7435e7947/library/src/main/java/me/grantland/widget/AutofitHelper.java#L381-L391 |
citrusframework/citrus | modules/citrus-jms/src/main/java/com/consol/citrus/jms/endpoint/resolver/DynamicDestinationNameResolver.java | DynamicDestinationNameResolver.resolveEndpointUri | public String resolveEndpointUri(Message message, String defaultName) {
"""
Get the endpoint uri according to message header entry with fallback default uri.
"""
Map<String, Object> headers = message.getHeaders();
String destinationName;
if (headers.containsKey(DESTINATION_HEADER_NAME)) {
destinationName = headers.get(DESTINATION_HEADER_NAME).toString();
} else if (StringUtils.hasText(defaultName)) {
destinationName = defaultName;
} else {
destinationName = defaultDestinationName;
}
if (destinationName == null) {
throw new CitrusRuntimeException("Unable to resolve dynamic destination name! Neither header entry '" +
DESTINATION_HEADER_NAME + "' nor default destination name is set");
}
return destinationName;
} | java | public String resolveEndpointUri(Message message, String defaultName) {
Map<String, Object> headers = message.getHeaders();
String destinationName;
if (headers.containsKey(DESTINATION_HEADER_NAME)) {
destinationName = headers.get(DESTINATION_HEADER_NAME).toString();
} else if (StringUtils.hasText(defaultName)) {
destinationName = defaultName;
} else {
destinationName = defaultDestinationName;
}
if (destinationName == null) {
throw new CitrusRuntimeException("Unable to resolve dynamic destination name! Neither header entry '" +
DESTINATION_HEADER_NAME + "' nor default destination name is set");
}
return destinationName;
} | [
"public",
"String",
"resolveEndpointUri",
"(",
"Message",
"message",
",",
"String",
"defaultName",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"headers",
"=",
"message",
".",
"getHeaders",
"(",
")",
";",
"String",
"destinationName",
";",
"if",
"(",
"headers",
".",
"containsKey",
"(",
"DESTINATION_HEADER_NAME",
")",
")",
"{",
"destinationName",
"=",
"headers",
".",
"get",
"(",
"DESTINATION_HEADER_NAME",
")",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"StringUtils",
".",
"hasText",
"(",
"defaultName",
")",
")",
"{",
"destinationName",
"=",
"defaultName",
";",
"}",
"else",
"{",
"destinationName",
"=",
"defaultDestinationName",
";",
"}",
"if",
"(",
"destinationName",
"==",
"null",
")",
"{",
"throw",
"new",
"CitrusRuntimeException",
"(",
"\"Unable to resolve dynamic destination name! Neither header entry '\"",
"+",
"DESTINATION_HEADER_NAME",
"+",
"\"' nor default destination name is set\"",
")",
";",
"}",
"return",
"destinationName",
";",
"}"
] | Get the endpoint uri according to message header entry with fallback default uri. | [
"Get",
"the",
"endpoint",
"uri",
"according",
"to",
"message",
"header",
"entry",
"with",
"fallback",
"default",
"uri",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-jms/src/main/java/com/consol/citrus/jms/endpoint/resolver/DynamicDestinationNameResolver.java#L42-L60 |
eurekaclinical/eurekaclinical-common | src/main/java/org/eurekaclinical/common/resource/AbstractResource.java | AbstractResource.getAny | @GET
@Path("/ {
"""
Gets the object with the given unique identifier.
@param inId the unique identifier. Cannot be <code>null</code>.
@param req the HTTP servlet request.
@return the object with the given unique identifier. Guaranteed not
<code>null</code>.
@throws HttpStatusException if there is no object with the given
unique identifier, or if the user is not authorized to access the
object.
"""id}")
@Produces(MediaType.APPLICATION_JSON)
public C getAny(@PathParam("id") Long inId, @Context HttpServletRequest req) {
E entity = this.dao.retrieve(inId);
if (entity == null) {
throw new HttpStatusException(Response.Status.NOT_FOUND);
} else if (isAuthorizedEntity(entity, req) && (!isRestricted() || req.isUserInRole("admin"))) {
return toComm(entity, req);
} else {
throw new HttpStatusException(Response.Status.NOT_FOUND);
}
} | java | @GET
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
public C getAny(@PathParam("id") Long inId, @Context HttpServletRequest req) {
E entity = this.dao.retrieve(inId);
if (entity == null) {
throw new HttpStatusException(Response.Status.NOT_FOUND);
} else if (isAuthorizedEntity(entity, req) && (!isRestricted() || req.isUserInRole("admin"))) {
return toComm(entity, req);
} else {
throw new HttpStatusException(Response.Status.NOT_FOUND);
}
} | [
"@",
"GET",
"@",
"Path",
"(",
"\"/{id}\"",
")",
"@",
"Produces",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"public",
"C",
"getAny",
"(",
"@",
"PathParam",
"(",
"\"id\"",
")",
"Long",
"inId",
",",
"@",
"Context",
"HttpServletRequest",
"req",
")",
"{",
"E",
"entity",
"=",
"this",
".",
"dao",
".",
"retrieve",
"(",
"inId",
")",
";",
"if",
"(",
"entity",
"==",
"null",
")",
"{",
"throw",
"new",
"HttpStatusException",
"(",
"Response",
".",
"Status",
".",
"NOT_FOUND",
")",
";",
"}",
"else",
"if",
"(",
"isAuthorizedEntity",
"(",
"entity",
",",
"req",
")",
"&&",
"(",
"!",
"isRestricted",
"(",
")",
"||",
"req",
".",
"isUserInRole",
"(",
"\"admin\"",
")",
")",
")",
"{",
"return",
"toComm",
"(",
"entity",
",",
"req",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"HttpStatusException",
"(",
"Response",
".",
"Status",
".",
"NOT_FOUND",
")",
";",
"}",
"}"
] | Gets the object with the given unique identifier.
@param inId the unique identifier. Cannot be <code>null</code>.
@param req the HTTP servlet request.
@return the object with the given unique identifier. Guaranteed not
<code>null</code>.
@throws HttpStatusException if there is no object with the given
unique identifier, or if the user is not authorized to access the
object. | [
"Gets",
"the",
"object",
"with",
"the",
"given",
"unique",
"identifier",
"."
] | train | https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/resource/AbstractResource.java#L137-L149 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientCustomImpl.java | KeyVaultClientCustomImpl.listCertificateVersionsAsync | public ServiceFuture<List<CertificateItem>> listCertificateVersionsAsync(final String vaultBaseUrl,
final String certificateName, final ListOperationCallback<CertificateItem> serviceCallback) {
"""
List the versions of a certificate.
@param vaultBaseUrl
The vault name, e.g. https://myvault.vault.azure.net
@param certificateName
The name of the certificate
@param serviceCallback
the async ServiceCallback to handle successful and failed
responses.
@return the {@link ServiceFuture} object
"""
return getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback);
} | java | public ServiceFuture<List<CertificateItem>> listCertificateVersionsAsync(final String vaultBaseUrl,
final String certificateName, final ListOperationCallback<CertificateItem> serviceCallback) {
return getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"List",
"<",
"CertificateItem",
">",
">",
"listCertificateVersionsAsync",
"(",
"final",
"String",
"vaultBaseUrl",
",",
"final",
"String",
"certificateName",
",",
"final",
"ListOperationCallback",
"<",
"CertificateItem",
">",
"serviceCallback",
")",
"{",
"return",
"getCertificateVersionsAsync",
"(",
"vaultBaseUrl",
",",
"certificateName",
",",
"serviceCallback",
")",
";",
"}"
] | List the versions of a certificate.
@param vaultBaseUrl
The vault name, e.g. https://myvault.vault.azure.net
@param certificateName
The name of the certificate
@param serviceCallback
the async ServiceCallback to handle successful and failed
responses.
@return the {@link ServiceFuture} object | [
"List",
"the",
"versions",
"of",
"a",
"certificate",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientCustomImpl.java#L1561-L1564 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jmx.connector.client.rest/src/com/ibm/ws/jmx/connector/converter/JSONConverter.java | JSONConverter.writeString | public void writeString(OutputStream out, String value) throws IOException {
"""
Encode a String value as JSON. An array is used to wrap the value:
[ String ]
@param out The stream to write JSON to
@param value The String value to encode.
@throws IOException If an I/O error occurs
@see #readString(InputStream)
"""
writeStartArray(out);
writeStringInternal(out, value);
writeEndArray(out);
} | java | public void writeString(OutputStream out, String value) throws IOException {
writeStartArray(out);
writeStringInternal(out, value);
writeEndArray(out);
} | [
"public",
"void",
"writeString",
"(",
"OutputStream",
"out",
",",
"String",
"value",
")",
"throws",
"IOException",
"{",
"writeStartArray",
"(",
"out",
")",
";",
"writeStringInternal",
"(",
"out",
",",
"value",
")",
";",
"writeEndArray",
"(",
"out",
")",
";",
"}"
] | Encode a String value as JSON. An array is used to wrap the value:
[ String ]
@param out The stream to write JSON to
@param value The String value to encode.
@throws IOException If an I/O error occurs
@see #readString(InputStream) | [
"Encode",
"a",
"String",
"value",
"as",
"JSON",
".",
"An",
"array",
"is",
"used",
"to",
"wrap",
"the",
"value",
":",
"[",
"String",
"]"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jmx.connector.client.rest/src/com/ibm/ws/jmx/connector/converter/JSONConverter.java#L746-L750 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/ns/ns_ssl_certkey_policy.java | ns_ssl_certkey_policy.do_poll | public static ns_ssl_certkey_policy do_poll(nitro_service client, ns_ssl_certkey_policy resource) throws Exception {
"""
<pre>
Use this operation to poll all SSL certificates from all NetScalers and update the database.
</pre>
"""
return ((ns_ssl_certkey_policy[]) resource.perform_operation(client, "do_poll"))[0];
} | java | public static ns_ssl_certkey_policy do_poll(nitro_service client, ns_ssl_certkey_policy resource) throws Exception
{
return ((ns_ssl_certkey_policy[]) resource.perform_operation(client, "do_poll"))[0];
} | [
"public",
"static",
"ns_ssl_certkey_policy",
"do_poll",
"(",
"nitro_service",
"client",
",",
"ns_ssl_certkey_policy",
"resource",
")",
"throws",
"Exception",
"{",
"return",
"(",
"(",
"ns_ssl_certkey_policy",
"[",
"]",
")",
"resource",
".",
"perform_operation",
"(",
"client",
",",
"\"do_poll\"",
")",
")",
"[",
"0",
"]",
";",
"}"
] | <pre>
Use this operation to poll all SSL certificates from all NetScalers and update the database.
</pre> | [
"<pre",
">",
"Use",
"this",
"operation",
"to",
"poll",
"all",
"SSL",
"certificates",
"from",
"all",
"NetScalers",
"and",
"update",
"the",
"database",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/ns/ns_ssl_certkey_policy.java#L106-L109 |
atteo/classindex | classindex/src/main/java/org/atteo/classindex/ClassIndex.java | ClassIndex.getPackageClasses | public static Iterable<Class<?>> getPackageClasses(String packageName) {
"""
Retrieves a list of classes from given package.
<p/>
<p>
The package must be annotated with {@link IndexSubclasses} for the classes inside
to be indexed at compile-time by {@link org.atteo.classindex.processor.ClassIndexProcessor}.
</p>
@param packageName name of the package to search classes for
@return list of classes from package
"""
return getPackageClasses(packageName, Thread.currentThread().getContextClassLoader());
} | java | public static Iterable<Class<?>> getPackageClasses(String packageName) {
return getPackageClasses(packageName, Thread.currentThread().getContextClassLoader());
} | [
"public",
"static",
"Iterable",
"<",
"Class",
"<",
"?",
">",
">",
"getPackageClasses",
"(",
"String",
"packageName",
")",
"{",
"return",
"getPackageClasses",
"(",
"packageName",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
")",
";",
"}"
] | Retrieves a list of classes from given package.
<p/>
<p>
The package must be annotated with {@link IndexSubclasses} for the classes inside
to be indexed at compile-time by {@link org.atteo.classindex.processor.ClassIndexProcessor}.
</p>
@param packageName name of the package to search classes for
@return list of classes from package | [
"Retrieves",
"a",
"list",
"of",
"classes",
"from",
"given",
"package",
".",
"<p",
"/",
">",
"<p",
">",
"The",
"package",
"must",
"be",
"annotated",
"with",
"{",
"@link",
"IndexSubclasses",
"}",
"for",
"the",
"classes",
"inside",
"to",
"be",
"indexed",
"at",
"compile",
"-",
"time",
"by",
"{",
"@link",
"org",
".",
"atteo",
".",
"classindex",
".",
"processor",
".",
"ClassIndexProcessor",
"}",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/atteo/classindex/blob/ad76c6bd8b4e84c594d94e48f466a095ffe2306a/classindex/src/main/java/org/atteo/classindex/ClassIndex.java#L173-L175 |
Azure/azure-sdk-for-java | datalakeanalytics/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakeanalytics/v2015_10_01_preview/implementation/AccountsInner.java | AccountsInner.getStorageAccount | public StorageAccountInfoInner getStorageAccount(String resourceGroupName, String accountName, String storageAccountName) {
"""
Gets the specified Azure Storage account linked to the given Data Lake Analytics account.
@param resourceGroupName The name of the Azure resource group that contains the Data Lake Analytics account.
@param accountName The name of the Data Lake Analytics account from which to retrieve Azure storage account details.
@param storageAccountName The name of the Azure Storage account for which to retrieve the details.
@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 StorageAccountInfoInner object if successful.
"""
return getStorageAccountWithServiceResponseAsync(resourceGroupName, accountName, storageAccountName).toBlocking().single().body();
} | java | public StorageAccountInfoInner getStorageAccount(String resourceGroupName, String accountName, String storageAccountName) {
return getStorageAccountWithServiceResponseAsync(resourceGroupName, accountName, storageAccountName).toBlocking().single().body();
} | [
"public",
"StorageAccountInfoInner",
"getStorageAccount",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"storageAccountName",
")",
"{",
"return",
"getStorageAccountWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"storageAccountName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Gets the specified Azure Storage account linked to the given Data Lake Analytics account.
@param resourceGroupName The name of the Azure resource group that contains the Data Lake Analytics account.
@param accountName The name of the Data Lake Analytics account from which to retrieve Azure storage account details.
@param storageAccountName The name of the Azure Storage account for which to retrieve the details.
@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 StorageAccountInfoInner object if successful. | [
"Gets",
"the",
"specified",
"Azure",
"Storage",
"account",
"linked",
"to",
"the",
"given",
"Data",
"Lake",
"Analytics",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datalakeanalytics/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakeanalytics/v2015_10_01_preview/implementation/AccountsInner.java#L192-L194 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/text/DateFormat.java | DateFormat.getDateTimeInstance | public final static DateFormat getDateTimeInstance(int dateStyle,
int timeStyle) {
"""
Gets the date/time formatter with the given date and time
formatting styles for the default locale.
@param dateStyle the given date formatting style. For example,
SHORT for "M/d/yy" in the US locale.
@param timeStyle the given time formatting style. For example,
SHORT for "h:mm a" in the US locale.
@return a date/time formatter.
"""
return get(timeStyle, dateStyle, 3, Locale.getDefault(Locale.Category.FORMAT));
} | java | public final static DateFormat getDateTimeInstance(int dateStyle,
int timeStyle)
{
return get(timeStyle, dateStyle, 3, Locale.getDefault(Locale.Category.FORMAT));
} | [
"public",
"final",
"static",
"DateFormat",
"getDateTimeInstance",
"(",
"int",
"dateStyle",
",",
"int",
"timeStyle",
")",
"{",
"return",
"get",
"(",
"timeStyle",
",",
"dateStyle",
",",
"3",
",",
"Locale",
".",
"getDefault",
"(",
"Locale",
".",
"Category",
".",
"FORMAT",
")",
")",
";",
"}"
] | Gets the date/time formatter with the given date and time
formatting styles for the default locale.
@param dateStyle the given date formatting style. For example,
SHORT for "M/d/yy" in the US locale.
@param timeStyle the given time formatting style. For example,
SHORT for "h:mm a" in the US locale.
@return a date/time formatter. | [
"Gets",
"the",
"date",
"/",
"time",
"formatter",
"with",
"the",
"given",
"date",
"and",
"time",
"formatting",
"styles",
"for",
"the",
"default",
"locale",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/text/DateFormat.java#L532-L536 |
networknt/light-4j | config/src/main/java/com/networknt/config/CentralizedManagement.java | CentralizedManagement.convertMapToObj | private static Object convertMapToObj(Map<String, Object> map, Class clazz) {
"""
Method used to convert map to object based on the reference class provided
"""
ObjectMapper mapper = new ObjectMapper();
Object obj = mapper.convertValue(map, clazz);
return obj;
} | java | private static Object convertMapToObj(Map<String, Object> map, Class clazz) {
ObjectMapper mapper = new ObjectMapper();
Object obj = mapper.convertValue(map, clazz);
return obj;
} | [
"private",
"static",
"Object",
"convertMapToObj",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
",",
"Class",
"clazz",
")",
"{",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"Object",
"obj",
"=",
"mapper",
".",
"convertValue",
"(",
"map",
",",
"clazz",
")",
";",
"return",
"obj",
";",
"}"
] | Method used to convert map to object based on the reference class provided | [
"Method",
"used",
"to",
"convert",
"map",
"to",
"object",
"based",
"on",
"the",
"reference",
"class",
"provided"
] | train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/config/src/main/java/com/networknt/config/CentralizedManagement.java#L81-L85 |
liferay/com-liferay-commerce | commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceAddressPersistenceImpl.java | CommerceAddressPersistenceImpl.findAll | @Override
public List<CommerceAddress> findAll(int start, int end) {
"""
Returns a range of all the commerce addresses.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceAddressModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of commerce addresses
@param end the upper bound of the range of commerce addresses (not inclusive)
@return the range of commerce addresses
"""
return findAll(start, end, null);
} | java | @Override
public List<CommerceAddress> findAll(int start, int end) {
return findAll(start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceAddress",
">",
"findAll",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findAll",
"(",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the commerce addresses.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceAddressModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of commerce addresses
@param end the upper bound of the range of commerce addresses (not inclusive)
@return the range of commerce addresses | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"addresses",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceAddressPersistenceImpl.java#L4215-L4218 |
Azure/azure-sdk-for-java | eventgrid/resource-manager/v2019_01_01/src/main/java/com/microsoft/azure/management/eventgrid/v2019_01_01/implementation/TopicsInner.java | TopicsInner.listSharedAccessKeys | public TopicSharedAccessKeysInner listSharedAccessKeys(String resourceGroupName, String topicName) {
"""
List keys for a topic.
List the two keys used to publish to a topic.
@param resourceGroupName The name of the resource group within the user's subscription.
@param topicName Name of the topic
@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 TopicSharedAccessKeysInner object if successful.
"""
return listSharedAccessKeysWithServiceResponseAsync(resourceGroupName, topicName).toBlocking().single().body();
} | java | public TopicSharedAccessKeysInner listSharedAccessKeys(String resourceGroupName, String topicName) {
return listSharedAccessKeysWithServiceResponseAsync(resourceGroupName, topicName).toBlocking().single().body();
} | [
"public",
"TopicSharedAccessKeysInner",
"listSharedAccessKeys",
"(",
"String",
"resourceGroupName",
",",
"String",
"topicName",
")",
"{",
"return",
"listSharedAccessKeysWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"topicName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | List keys for a topic.
List the two keys used to publish to a topic.
@param resourceGroupName The name of the resource group within the user's subscription.
@param topicName Name of the topic
@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 TopicSharedAccessKeysInner object if successful. | [
"List",
"keys",
"for",
"a",
"topic",
".",
"List",
"the",
"two",
"keys",
"used",
"to",
"publish",
"to",
"a",
"topic",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/resource-manager/v2019_01_01/src/main/java/com/microsoft/azure/management/eventgrid/v2019_01_01/implementation/TopicsInner.java#L1076-L1078 |
comapi/comapi-sdk-android | COMAPI/foundation/src/main/java/com/comapi/internal/network/InternalService.java | InternalService.uploadContent | public Observable<ComapiResult<UploadContentResponse>> uploadContent(@NonNull final String folder, @NonNull final ContentData data) {
"""
Upload content data.
@param folder Folder name to put the file in.
@param data Content data.
@return Observable emitting details of uploaded content.
"""
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueUploadContent(folder, data);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doUploadContent(token, folder, data.getName(), data);
}
} | java | public Observable<ComapiResult<UploadContentResponse>> uploadContent(@NonNull final String folder, @NonNull final ContentData data) {
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueUploadContent(folder, data);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doUploadContent(token, folder, data.getName(), data);
}
} | [
"public",
"Observable",
"<",
"ComapiResult",
"<",
"UploadContentResponse",
">",
">",
"uploadContent",
"(",
"@",
"NonNull",
"final",
"String",
"folder",
",",
"@",
"NonNull",
"final",
"ContentData",
"data",
")",
"{",
"final",
"String",
"token",
"=",
"getToken",
"(",
")",
";",
"if",
"(",
"sessionController",
".",
"isCreatingSession",
"(",
")",
")",
"{",
"return",
"getTaskQueue",
"(",
")",
".",
"queueUploadContent",
"(",
"folder",
",",
"data",
")",
";",
"}",
"else",
"if",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"token",
")",
")",
"{",
"return",
"Observable",
".",
"error",
"(",
"getSessionStateErrorDescription",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"doUploadContent",
"(",
"token",
",",
"folder",
",",
"data",
".",
"getName",
"(",
")",
",",
"data",
")",
";",
"}",
"}"
] | Upload content data.
@param folder Folder name to put the file in.
@param data Content data.
@return Observable emitting details of uploaded content. | [
"Upload",
"content",
"data",
"."
] | train | https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/InternalService.java#L763-L774 |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java | FileSystem.zipFile | public static void zipFile(File input, File output) throws IOException {
"""
Create a zip file from the given input file.
@param input the name of the file to compress.
@param output the name of the ZIP file to create.
@throws IOException when ziiping is failing.
@since 6.2
"""
try (FileOutputStream fos = new FileOutputStream(output)) {
zipFile(input, fos);
}
} | java | public static void zipFile(File input, File output) throws IOException {
try (FileOutputStream fos = new FileOutputStream(output)) {
zipFile(input, fos);
}
} | [
"public",
"static",
"void",
"zipFile",
"(",
"File",
"input",
",",
"File",
"output",
")",
"throws",
"IOException",
"{",
"try",
"(",
"FileOutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"output",
")",
")",
"{",
"zipFile",
"(",
"input",
",",
"fos",
")",
";",
"}",
"}"
] | Create a zip file from the given input file.
@param input the name of the file to compress.
@param output the name of the ZIP file to create.
@throws IOException when ziiping is failing.
@since 6.2 | [
"Create",
"a",
"zip",
"file",
"from",
"the",
"given",
"input",
"file",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java#L2923-L2927 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java | CoverageUtilities.doubleArray2WritableRaster | public static WritableRaster doubleArray2WritableRaster( double[] array, int width, int height ) {
"""
Transforms an array of values into a {@link WritableRaster}.
@param array the values to transform.
@param divide the factor by which to divide the values.
@param width the width of the resulting image.
@param height the height of the resulting image.
@return the raster.
"""
WritableRaster writableRaster = createWritableRaster(width, height, null, null, null);
int index = 0;;
for( int x = 0; x < width; x++ ) {
for( int y = 0; y < height; y++ ) {
writableRaster.setSample(x, y, 0, array[index++]);
}
}
return writableRaster;
} | java | public static WritableRaster doubleArray2WritableRaster( double[] array, int width, int height ) {
WritableRaster writableRaster = createWritableRaster(width, height, null, null, null);
int index = 0;;
for( int x = 0; x < width; x++ ) {
for( int y = 0; y < height; y++ ) {
writableRaster.setSample(x, y, 0, array[index++]);
}
}
return writableRaster;
} | [
"public",
"static",
"WritableRaster",
"doubleArray2WritableRaster",
"(",
"double",
"[",
"]",
"array",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"WritableRaster",
"writableRaster",
"=",
"createWritableRaster",
"(",
"width",
",",
"height",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"int",
"index",
"=",
"0",
";",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"width",
";",
"x",
"++",
")",
"{",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"height",
";",
"y",
"++",
")",
"{",
"writableRaster",
".",
"setSample",
"(",
"x",
",",
"y",
",",
"0",
",",
"array",
"[",
"index",
"++",
"]",
")",
";",
"}",
"}",
"return",
"writableRaster",
";",
"}"
] | Transforms an array of values into a {@link WritableRaster}.
@param array the values to transform.
@param divide the factor by which to divide the values.
@param width the width of the resulting image.
@param height the height of the resulting image.
@return the raster. | [
"Transforms",
"an",
"array",
"of",
"values",
"into",
"a",
"{",
"@link",
"WritableRaster",
"}",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L1133-L1142 |
EdwardRaff/JSAT | JSAT/src/jsat/distributions/Normal.java | Normal.logPdf | public static double logPdf(double x, double mu, double sigma) {
"""
Computes the log probability of a given value
@param x the value to the get log(pdf) of
@param mu the mean of the distribution
@param sigma the standard deviation of the distribution
@return the log probability
"""
return -0.5*log(2*PI) - log(sigma) + -pow(x-mu,2)/(2*sigma*sigma);
} | java | public static double logPdf(double x, double mu, double sigma)
{
return -0.5*log(2*PI) - log(sigma) + -pow(x-mu,2)/(2*sigma*sigma);
} | [
"public",
"static",
"double",
"logPdf",
"(",
"double",
"x",
",",
"double",
"mu",
",",
"double",
"sigma",
")",
"{",
"return",
"-",
"0.5",
"*",
"log",
"(",
"2",
"*",
"PI",
")",
"-",
"log",
"(",
"sigma",
")",
"+",
"-",
"pow",
"(",
"x",
"-",
"mu",
",",
"2",
")",
"/",
"(",
"2",
"*",
"sigma",
"*",
"sigma",
")",
";",
"}"
] | Computes the log probability of a given value
@param x the value to the get log(pdf) of
@param mu the mean of the distribution
@param sigma the standard deviation of the distribution
@return the log probability | [
"Computes",
"the",
"log",
"probability",
"of",
"a",
"given",
"value"
] | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/Normal.java#L152-L155 |
facebook/fresco | samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java | DefaultZoomableController.limitTranslation | private boolean limitTranslation(Matrix transform, @LimitFlag int limitTypes) {
"""
Limits the translation so that there are no empty spaces on the sides if possible.
<p> The image is attempted to be centered within the view bounds if the transformed image is
smaller. There will be no empty spaces within the view bounds if the transformed image is
bigger. This applies to each dimension (horizontal and vertical) independently.
@param limitTypes whether to limit translation along the specific axis.
@return whether limiting has been applied or not
"""
if (!shouldLimit(limitTypes, LIMIT_TRANSLATION_X | LIMIT_TRANSLATION_Y)) {
return false;
}
RectF b = mTempRect;
b.set(mImageBounds);
transform.mapRect(b);
float offsetLeft = shouldLimit(limitTypes, LIMIT_TRANSLATION_X) ?
getOffset(b.left, b.right, mViewBounds.left, mViewBounds.right, mImageBounds.centerX()) : 0;
float offsetTop = shouldLimit(limitTypes, LIMIT_TRANSLATION_Y) ?
getOffset(b.top, b.bottom, mViewBounds.top, mViewBounds.bottom, mImageBounds.centerY()) : 0;
if (offsetLeft != 0 || offsetTop != 0) {
transform.postTranslate(offsetLeft, offsetTop);
return true;
}
return false;
} | java | private boolean limitTranslation(Matrix transform, @LimitFlag int limitTypes) {
if (!shouldLimit(limitTypes, LIMIT_TRANSLATION_X | LIMIT_TRANSLATION_Y)) {
return false;
}
RectF b = mTempRect;
b.set(mImageBounds);
transform.mapRect(b);
float offsetLeft = shouldLimit(limitTypes, LIMIT_TRANSLATION_X) ?
getOffset(b.left, b.right, mViewBounds.left, mViewBounds.right, mImageBounds.centerX()) : 0;
float offsetTop = shouldLimit(limitTypes, LIMIT_TRANSLATION_Y) ?
getOffset(b.top, b.bottom, mViewBounds.top, mViewBounds.bottom, mImageBounds.centerY()) : 0;
if (offsetLeft != 0 || offsetTop != 0) {
transform.postTranslate(offsetLeft, offsetTop);
return true;
}
return false;
} | [
"private",
"boolean",
"limitTranslation",
"(",
"Matrix",
"transform",
",",
"@",
"LimitFlag",
"int",
"limitTypes",
")",
"{",
"if",
"(",
"!",
"shouldLimit",
"(",
"limitTypes",
",",
"LIMIT_TRANSLATION_X",
"|",
"LIMIT_TRANSLATION_Y",
")",
")",
"{",
"return",
"false",
";",
"}",
"RectF",
"b",
"=",
"mTempRect",
";",
"b",
".",
"set",
"(",
"mImageBounds",
")",
";",
"transform",
".",
"mapRect",
"(",
"b",
")",
";",
"float",
"offsetLeft",
"=",
"shouldLimit",
"(",
"limitTypes",
",",
"LIMIT_TRANSLATION_X",
")",
"?",
"getOffset",
"(",
"b",
".",
"left",
",",
"b",
".",
"right",
",",
"mViewBounds",
".",
"left",
",",
"mViewBounds",
".",
"right",
",",
"mImageBounds",
".",
"centerX",
"(",
")",
")",
":",
"0",
";",
"float",
"offsetTop",
"=",
"shouldLimit",
"(",
"limitTypes",
",",
"LIMIT_TRANSLATION_Y",
")",
"?",
"getOffset",
"(",
"b",
".",
"top",
",",
"b",
".",
"bottom",
",",
"mViewBounds",
".",
"top",
",",
"mViewBounds",
".",
"bottom",
",",
"mImageBounds",
".",
"centerY",
"(",
")",
")",
":",
"0",
";",
"if",
"(",
"offsetLeft",
"!=",
"0",
"||",
"offsetTop",
"!=",
"0",
")",
"{",
"transform",
".",
"postTranslate",
"(",
"offsetLeft",
",",
"offsetTop",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Limits the translation so that there are no empty spaces on the sides if possible.
<p> The image is attempted to be centered within the view bounds if the transformed image is
smaller. There will be no empty spaces within the view bounds if the transformed image is
bigger. This applies to each dimension (horizontal and vertical) independently.
@param limitTypes whether to limit translation along the specific axis.
@return whether limiting has been applied or not | [
"Limits",
"the",
"translation",
"so",
"that",
"there",
"are",
"no",
"empty",
"spaces",
"on",
"the",
"sides",
"if",
"possible",
"."
] | train | https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L523-L539 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/coll/CollationBuilder.java | CollationBuilder.insertNodeBetween | private int insertNodeBetween(int index, int nextIndex, long node) {
"""
Inserts a new node into the list, between list-adjacent items.
The node's previous and next indexes must not be set yet.
@return the new node's index
"""
assert(previousIndexFromNode(node) == 0);
assert(nextIndexFromNode(node) == 0);
assert(nextIndexFromNode(nodes.elementAti(index)) == nextIndex);
// Append the new node and link it to the existing nodes.
int newIndex = nodes.size();
node |= nodeFromPreviousIndex(index) | nodeFromNextIndex(nextIndex);
nodes.addElement(node);
// nodes[index].nextIndex = newIndex
node = nodes.elementAti(index);
nodes.setElementAt(changeNodeNextIndex(node, newIndex), index);
// nodes[nextIndex].previousIndex = newIndex
if(nextIndex != 0) {
node = nodes.elementAti(nextIndex);
nodes.setElementAt(changeNodePreviousIndex(node, newIndex), nextIndex);
}
return newIndex;
} | java | private int insertNodeBetween(int index, int nextIndex, long node) {
assert(previousIndexFromNode(node) == 0);
assert(nextIndexFromNode(node) == 0);
assert(nextIndexFromNode(nodes.elementAti(index)) == nextIndex);
// Append the new node and link it to the existing nodes.
int newIndex = nodes.size();
node |= nodeFromPreviousIndex(index) | nodeFromNextIndex(nextIndex);
nodes.addElement(node);
// nodes[index].nextIndex = newIndex
node = nodes.elementAti(index);
nodes.setElementAt(changeNodeNextIndex(node, newIndex), index);
// nodes[nextIndex].previousIndex = newIndex
if(nextIndex != 0) {
node = nodes.elementAti(nextIndex);
nodes.setElementAt(changeNodePreviousIndex(node, newIndex), nextIndex);
}
return newIndex;
} | [
"private",
"int",
"insertNodeBetween",
"(",
"int",
"index",
",",
"int",
"nextIndex",
",",
"long",
"node",
")",
"{",
"assert",
"(",
"previousIndexFromNode",
"(",
"node",
")",
"==",
"0",
")",
";",
"assert",
"(",
"nextIndexFromNode",
"(",
"node",
")",
"==",
"0",
")",
";",
"assert",
"(",
"nextIndexFromNode",
"(",
"nodes",
".",
"elementAti",
"(",
"index",
")",
")",
"==",
"nextIndex",
")",
";",
"// Append the new node and link it to the existing nodes.",
"int",
"newIndex",
"=",
"nodes",
".",
"size",
"(",
")",
";",
"node",
"|=",
"nodeFromPreviousIndex",
"(",
"index",
")",
"|",
"nodeFromNextIndex",
"(",
"nextIndex",
")",
";",
"nodes",
".",
"addElement",
"(",
"node",
")",
";",
"// nodes[index].nextIndex = newIndex",
"node",
"=",
"nodes",
".",
"elementAti",
"(",
"index",
")",
";",
"nodes",
".",
"setElementAt",
"(",
"changeNodeNextIndex",
"(",
"node",
",",
"newIndex",
")",
",",
"index",
")",
";",
"// nodes[nextIndex].previousIndex = newIndex",
"if",
"(",
"nextIndex",
"!=",
"0",
")",
"{",
"node",
"=",
"nodes",
".",
"elementAti",
"(",
"nextIndex",
")",
";",
"nodes",
".",
"setElementAt",
"(",
"changeNodePreviousIndex",
"(",
"node",
",",
"newIndex",
")",
",",
"nextIndex",
")",
";",
"}",
"return",
"newIndex",
";",
"}"
] | Inserts a new node into the list, between list-adjacent items.
The node's previous and next indexes must not be set yet.
@return the new node's index | [
"Inserts",
"a",
"new",
"node",
"into",
"the",
"list",
"between",
"list",
"-",
"adjacent",
"items",
".",
"The",
"node",
"s",
"previous",
"and",
"next",
"indexes",
"must",
"not",
"be",
"set",
"yet",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/coll/CollationBuilder.java#L728-L745 |
lessthanoptimal/BoofCV | main/boofcv-types/src/main/java/boofcv/alg/InputSanityCheck.java | InputSanityCheck.checkReshape | public static void checkReshape(ImageBase<?> imgA, ImageBase<?> imgB) {
"""
Throws exception if two images are the same instance. Otherwise reshapes B to match A
"""
if( imgA == imgB )
throw new IllegalArgumentException("Image's can't be the same instance");
imgB.reshape(imgA.width,imgA.height);
} | java | public static void checkReshape(ImageBase<?> imgA, ImageBase<?> imgB) {
if( imgA == imgB )
throw new IllegalArgumentException("Image's can't be the same instance");
imgB.reshape(imgA.width,imgA.height);
} | [
"public",
"static",
"void",
"checkReshape",
"(",
"ImageBase",
"<",
"?",
">",
"imgA",
",",
"ImageBase",
"<",
"?",
">",
"imgB",
")",
"{",
"if",
"(",
"imgA",
"==",
"imgB",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Image's can't be the same instance\"",
")",
";",
"imgB",
".",
"reshape",
"(",
"imgA",
".",
"width",
",",
"imgA",
".",
"height",
")",
";",
"}"
] | Throws exception if two images are the same instance. Otherwise reshapes B to match A | [
"Throws",
"exception",
"if",
"two",
"images",
"are",
"the",
"same",
"instance",
".",
"Otherwise",
"reshapes",
"B",
"to",
"match",
"A"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/alg/InputSanityCheck.java#L84-L88 |
citrusframework/citrus | modules/citrus-core/src/main/java/com/consol/citrus/util/BooleanExpressionParser.java | BooleanExpressionParser.evaluateExpressionStack | private static String evaluateExpressionStack(final Deque<String> operators, final Deque<String> values) {
"""
This method takes stacks of operators and values and evaluates possible expressions
This is done by popping one operator and two values, applying the operator to the values and pushing the result back onto the value stack
@param operators Operators to apply
@param values Values
@return The final result popped of the values stack
"""
while (!operators.isEmpty()) {
values.push(getBooleanResultAsString(operators.pop(), values.pop(), values.pop()));
}
return replaceIntegerStringByBooleanRepresentation(values.pop());
} | java | private static String evaluateExpressionStack(final Deque<String> operators, final Deque<String> values) {
while (!operators.isEmpty()) {
values.push(getBooleanResultAsString(operators.pop(), values.pop(), values.pop()));
}
return replaceIntegerStringByBooleanRepresentation(values.pop());
} | [
"private",
"static",
"String",
"evaluateExpressionStack",
"(",
"final",
"Deque",
"<",
"String",
">",
"operators",
",",
"final",
"Deque",
"<",
"String",
">",
"values",
")",
"{",
"while",
"(",
"!",
"operators",
".",
"isEmpty",
"(",
")",
")",
"{",
"values",
".",
"push",
"(",
"getBooleanResultAsString",
"(",
"operators",
".",
"pop",
"(",
")",
",",
"values",
".",
"pop",
"(",
")",
",",
"values",
".",
"pop",
"(",
")",
")",
")",
";",
"}",
"return",
"replaceIntegerStringByBooleanRepresentation",
"(",
"values",
".",
"pop",
"(",
")",
")",
";",
"}"
] | This method takes stacks of operators and values and evaluates possible expressions
This is done by popping one operator and two values, applying the operator to the values and pushing the result back onto the value stack
@param operators Operators to apply
@param values Values
@return The final result popped of the values stack | [
"This",
"method",
"takes",
"stacks",
"of",
"operators",
"and",
"values",
"and",
"evaluates",
"possible",
"expressions",
"This",
"is",
"done",
"by",
"popping",
"one",
"operator",
"and",
"two",
"values",
"applying",
"the",
"operator",
"to",
"the",
"values",
"and",
"pushing",
"the",
"result",
"back",
"onto",
"the",
"value",
"stack"
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-core/src/main/java/com/consol/citrus/util/BooleanExpressionParser.java#L147-L152 |
Coveros/selenified | src/main/java/com/coveros/selenified/element/check/wait/WaitForEquals.java | WaitForEquals.clazz | public void clazz(String expectedClass, double seconds) {
"""
Waits for the element's class equals the provided expected class. If
the element isn't present, this will constitute a failure, same as a
mismatch. The provided wait time will be used and if the element doesn't
have the desired match count at that time, it will fail, and log
the issue with a screenshot for traceability and added debugging support.
@param expectedClass - the full expected class value
@param seconds - how many seconds to wait for
"""
double end = System.currentTimeMillis() + (seconds * 1000);
try {
elementPresent(seconds);
while (!(expectedClass == null ? element.get().attribute(CLASS) == null : expectedClass.equals(element.get().attribute(CLASS))) && System.currentTimeMillis() < end) ;
double timeTook = Math.min((seconds * 1000) - (end - System.currentTimeMillis()), seconds * 1000) / 1000;
checkClazz(expectedClass, seconds, timeTook);
} catch (TimeoutException e) {
checkClazz(expectedClass, seconds, seconds);
}
} | java | public void clazz(String expectedClass, double seconds) {
double end = System.currentTimeMillis() + (seconds * 1000);
try {
elementPresent(seconds);
while (!(expectedClass == null ? element.get().attribute(CLASS) == null : expectedClass.equals(element.get().attribute(CLASS))) && System.currentTimeMillis() < end) ;
double timeTook = Math.min((seconds * 1000) - (end - System.currentTimeMillis()), seconds * 1000) / 1000;
checkClazz(expectedClass, seconds, timeTook);
} catch (TimeoutException e) {
checkClazz(expectedClass, seconds, seconds);
}
} | [
"public",
"void",
"clazz",
"(",
"String",
"expectedClass",
",",
"double",
"seconds",
")",
"{",
"double",
"end",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"(",
"seconds",
"*",
"1000",
")",
";",
"try",
"{",
"elementPresent",
"(",
"seconds",
")",
";",
"while",
"(",
"!",
"(",
"expectedClass",
"==",
"null",
"?",
"element",
".",
"get",
"(",
")",
".",
"attribute",
"(",
"CLASS",
")",
"==",
"null",
":",
"expectedClass",
".",
"equals",
"(",
"element",
".",
"get",
"(",
")",
".",
"attribute",
"(",
"CLASS",
")",
")",
")",
"&&",
"System",
".",
"currentTimeMillis",
"(",
")",
"<",
"end",
")",
";",
"double",
"timeTook",
"=",
"Math",
".",
"min",
"(",
"(",
"seconds",
"*",
"1000",
")",
"-",
"(",
"end",
"-",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
",",
"seconds",
"*",
"1000",
")",
"/",
"1000",
";",
"checkClazz",
"(",
"expectedClass",
",",
"seconds",
",",
"timeTook",
")",
";",
"}",
"catch",
"(",
"TimeoutException",
"e",
")",
"{",
"checkClazz",
"(",
"expectedClass",
",",
"seconds",
",",
"seconds",
")",
";",
"}",
"}"
] | Waits for the element's class equals the provided expected class. If
the element isn't present, this will constitute a failure, same as a
mismatch. The provided wait time will be used and if the element doesn't
have the desired match count at that time, it will fail, and log
the issue with a screenshot for traceability and added debugging support.
@param expectedClass - the full expected class value
@param seconds - how many seconds to wait for | [
"Waits",
"for",
"the",
"element",
"s",
"class",
"equals",
"the",
"provided",
"expected",
"class",
".",
"If",
"the",
"element",
"isn",
"t",
"present",
"this",
"will",
"constitute",
"a",
"failure",
"same",
"as",
"a",
"mismatch",
".",
"The",
"provided",
"wait",
"time",
"will",
"be",
"used",
"and",
"if",
"the",
"element",
"doesn",
"t",
"have",
"the",
"desired",
"match",
"count",
"at",
"that",
"time",
"it",
"will",
"fail",
"and",
"log",
"the",
"issue",
"with",
"a",
"screenshot",
"for",
"traceability",
"and",
"added",
"debugging",
"support",
"."
] | train | https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/element/check/wait/WaitForEquals.java#L313-L323 |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/LeaderAppender.java | LeaderAppender.updateHeartbeatTime | private void updateHeartbeatTime(MemberState member, Throwable error) {
"""
Sets a commit time or fails the commit if a quorum of successful responses cannot be achieved.
"""
if (heartbeatFuture == null) {
return;
}
if (error != null && member.getHeartbeatStartTime() == heartbeatTime) {
int votingMemberSize = context.getClusterState().getActiveMemberStates().size() + (context.getCluster().member().type() == Member.Type.ACTIVE ? 1 : 0);
int quorumSize = (int) Math.floor(votingMemberSize / 2) + 1;
// If a quorum of successful responses cannot be achieved, fail this heartbeat. Ensure that only
// ACTIVE members are considered. A member could have been transitioned to another state while the
// heartbeat was being sent.
if (member.getMember().type() == Member.Type.ACTIVE && ++heartbeatFailures > votingMemberSize - quorumSize) {
heartbeatFuture.completeExceptionally(new InternalException("Failed to reach consensus"));
completeHeartbeat();
}
} else {
member.setHeartbeatTime(System.currentTimeMillis());
// Sort the list of commit times. Use the quorum index to get the last time the majority of the cluster
// was contacted. If the current heartbeatFuture's time is less than the commit time then trigger the
// commit future and reset it to the next commit future.
if (heartbeatTime <= heartbeatTime()) {
heartbeatFuture.complete(null);
completeHeartbeat();
}
}
} | java | private void updateHeartbeatTime(MemberState member, Throwable error) {
if (heartbeatFuture == null) {
return;
}
if (error != null && member.getHeartbeatStartTime() == heartbeatTime) {
int votingMemberSize = context.getClusterState().getActiveMemberStates().size() + (context.getCluster().member().type() == Member.Type.ACTIVE ? 1 : 0);
int quorumSize = (int) Math.floor(votingMemberSize / 2) + 1;
// If a quorum of successful responses cannot be achieved, fail this heartbeat. Ensure that only
// ACTIVE members are considered. A member could have been transitioned to another state while the
// heartbeat was being sent.
if (member.getMember().type() == Member.Type.ACTIVE && ++heartbeatFailures > votingMemberSize - quorumSize) {
heartbeatFuture.completeExceptionally(new InternalException("Failed to reach consensus"));
completeHeartbeat();
}
} else {
member.setHeartbeatTime(System.currentTimeMillis());
// Sort the list of commit times. Use the quorum index to get the last time the majority of the cluster
// was contacted. If the current heartbeatFuture's time is less than the commit time then trigger the
// commit future and reset it to the next commit future.
if (heartbeatTime <= heartbeatTime()) {
heartbeatFuture.complete(null);
completeHeartbeat();
}
}
} | [
"private",
"void",
"updateHeartbeatTime",
"(",
"MemberState",
"member",
",",
"Throwable",
"error",
")",
"{",
"if",
"(",
"heartbeatFuture",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"error",
"!=",
"null",
"&&",
"member",
".",
"getHeartbeatStartTime",
"(",
")",
"==",
"heartbeatTime",
")",
"{",
"int",
"votingMemberSize",
"=",
"context",
".",
"getClusterState",
"(",
")",
".",
"getActiveMemberStates",
"(",
")",
".",
"size",
"(",
")",
"+",
"(",
"context",
".",
"getCluster",
"(",
")",
".",
"member",
"(",
")",
".",
"type",
"(",
")",
"==",
"Member",
".",
"Type",
".",
"ACTIVE",
"?",
"1",
":",
"0",
")",
";",
"int",
"quorumSize",
"=",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"votingMemberSize",
"/",
"2",
")",
"+",
"1",
";",
"// If a quorum of successful responses cannot be achieved, fail this heartbeat. Ensure that only",
"// ACTIVE members are considered. A member could have been transitioned to another state while the",
"// heartbeat was being sent.",
"if",
"(",
"member",
".",
"getMember",
"(",
")",
".",
"type",
"(",
")",
"==",
"Member",
".",
"Type",
".",
"ACTIVE",
"&&",
"++",
"heartbeatFailures",
">",
"votingMemberSize",
"-",
"quorumSize",
")",
"{",
"heartbeatFuture",
".",
"completeExceptionally",
"(",
"new",
"InternalException",
"(",
"\"Failed to reach consensus\"",
")",
")",
";",
"completeHeartbeat",
"(",
")",
";",
"}",
"}",
"else",
"{",
"member",
".",
"setHeartbeatTime",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"// Sort the list of commit times. Use the quorum index to get the last time the majority of the cluster",
"// was contacted. If the current heartbeatFuture's time is less than the commit time then trigger the",
"// commit future and reset it to the next commit future.",
"if",
"(",
"heartbeatTime",
"<=",
"heartbeatTime",
"(",
")",
")",
"{",
"heartbeatFuture",
".",
"complete",
"(",
"null",
")",
";",
"completeHeartbeat",
"(",
")",
";",
"}",
"}",
"}"
] | Sets a commit time or fails the commit if a quorum of successful responses cannot be achieved. | [
"Sets",
"a",
"commit",
"time",
"or",
"fails",
"the",
"commit",
"if",
"a",
"quorum",
"of",
"successful",
"responses",
"cannot",
"be",
"achieved",
"."
] | train | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/LeaderAppender.java#L243-L269 |
phax/peppol-directory | peppol-directory-indexer/src/main/java/com/helger/pd/indexer/storage/PDStorageManager.java | PDStorageManager.searchAllDocuments | public void searchAllDocuments (@Nonnull final Query aQuery,
@CheckForSigned final int nMaxResultCount,
@Nonnull final Consumer <? super PDStoredBusinessEntity> aConsumer) throws IOException {
"""
Search all documents matching the passed query and pass the result on to
the provided {@link Consumer}.
@param aQuery
Query to execute. May not be <code>null</code>-
@param nMaxResultCount
Maximum number of results. Values ≤ 0 mean all.
@param aConsumer
The consumer of the {@link PDStoredBusinessEntity} objects.
@throws IOException
On Lucene error
@see #searchAtomic(Query, Collector)
@see #getAllDocuments(Query,int)
"""
ValueEnforcer.notNull (aQuery, "Query");
ValueEnforcer.notNull (aConsumer, "Consumer");
final ObjIntConsumer <Document> aConverter = (aDoc,
nDocID) -> aConsumer.accept (PDStoredBusinessEntity.create (aDoc));
if (nMaxResultCount <= 0)
{
// Search all
final Collector aCollector = new AllDocumentsCollector (m_aLucene, aConverter);
searchAtomic (aQuery, aCollector);
}
else
{
// Search top docs only
final TopScoreDocCollector aCollector = TopScoreDocCollector.create (nMaxResultCount, Integer.MAX_VALUE);
searchAtomic (aQuery, aCollector);
for (final ScoreDoc aScoreDoc : aCollector.topDocs ().scoreDocs)
{
final Document aDoc = m_aLucene.getDocument (aScoreDoc.doc);
if (aDoc == null)
throw new IllegalStateException ("Failed to resolve Lucene Document with ID " + aScoreDoc.doc);
// Pass to Consumer
aConsumer.accept (PDStoredBusinessEntity.create (aDoc));
}
}
} | java | public void searchAllDocuments (@Nonnull final Query aQuery,
@CheckForSigned final int nMaxResultCount,
@Nonnull final Consumer <? super PDStoredBusinessEntity> aConsumer) throws IOException
{
ValueEnforcer.notNull (aQuery, "Query");
ValueEnforcer.notNull (aConsumer, "Consumer");
final ObjIntConsumer <Document> aConverter = (aDoc,
nDocID) -> aConsumer.accept (PDStoredBusinessEntity.create (aDoc));
if (nMaxResultCount <= 0)
{
// Search all
final Collector aCollector = new AllDocumentsCollector (m_aLucene, aConverter);
searchAtomic (aQuery, aCollector);
}
else
{
// Search top docs only
final TopScoreDocCollector aCollector = TopScoreDocCollector.create (nMaxResultCount, Integer.MAX_VALUE);
searchAtomic (aQuery, aCollector);
for (final ScoreDoc aScoreDoc : aCollector.topDocs ().scoreDocs)
{
final Document aDoc = m_aLucene.getDocument (aScoreDoc.doc);
if (aDoc == null)
throw new IllegalStateException ("Failed to resolve Lucene Document with ID " + aScoreDoc.doc);
// Pass to Consumer
aConsumer.accept (PDStoredBusinessEntity.create (aDoc));
}
}
} | [
"public",
"void",
"searchAllDocuments",
"(",
"@",
"Nonnull",
"final",
"Query",
"aQuery",
",",
"@",
"CheckForSigned",
"final",
"int",
"nMaxResultCount",
",",
"@",
"Nonnull",
"final",
"Consumer",
"<",
"?",
"super",
"PDStoredBusinessEntity",
">",
"aConsumer",
")",
"throws",
"IOException",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aQuery",
",",
"\"Query\"",
")",
";",
"ValueEnforcer",
".",
"notNull",
"(",
"aConsumer",
",",
"\"Consumer\"",
")",
";",
"final",
"ObjIntConsumer",
"<",
"Document",
">",
"aConverter",
"=",
"(",
"aDoc",
",",
"nDocID",
")",
"->",
"aConsumer",
".",
"accept",
"(",
"PDStoredBusinessEntity",
".",
"create",
"(",
"aDoc",
")",
")",
";",
"if",
"(",
"nMaxResultCount",
"<=",
"0",
")",
"{",
"// Search all",
"final",
"Collector",
"aCollector",
"=",
"new",
"AllDocumentsCollector",
"(",
"m_aLucene",
",",
"aConverter",
")",
";",
"searchAtomic",
"(",
"aQuery",
",",
"aCollector",
")",
";",
"}",
"else",
"{",
"// Search top docs only",
"final",
"TopScoreDocCollector",
"aCollector",
"=",
"TopScoreDocCollector",
".",
"create",
"(",
"nMaxResultCount",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"searchAtomic",
"(",
"aQuery",
",",
"aCollector",
")",
";",
"for",
"(",
"final",
"ScoreDoc",
"aScoreDoc",
":",
"aCollector",
".",
"topDocs",
"(",
")",
".",
"scoreDocs",
")",
"{",
"final",
"Document",
"aDoc",
"=",
"m_aLucene",
".",
"getDocument",
"(",
"aScoreDoc",
".",
"doc",
")",
";",
"if",
"(",
"aDoc",
"==",
"null",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Failed to resolve Lucene Document with ID \"",
"+",
"aScoreDoc",
".",
"doc",
")",
";",
"// Pass to Consumer",
"aConsumer",
".",
"accept",
"(",
"PDStoredBusinessEntity",
".",
"create",
"(",
"aDoc",
")",
")",
";",
"}",
"}",
"}"
] | Search all documents matching the passed query and pass the result on to
the provided {@link Consumer}.
@param aQuery
Query to execute. May not be <code>null</code>-
@param nMaxResultCount
Maximum number of results. Values ≤ 0 mean all.
@param aConsumer
The consumer of the {@link PDStoredBusinessEntity} objects.
@throws IOException
On Lucene error
@see #searchAtomic(Query, Collector)
@see #getAllDocuments(Query,int) | [
"Search",
"all",
"documents",
"matching",
"the",
"passed",
"query",
"and",
"pass",
"the",
"result",
"on",
"to",
"the",
"provided",
"{",
"@link",
"Consumer",
"}",
"."
] | train | https://github.com/phax/peppol-directory/blob/98da26da29fb7178371d6b029516cbf01be223fb/peppol-directory-indexer/src/main/java/com/helger/pd/indexer/storage/PDStorageManager.java#L457-L486 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribeSiftCommon.java | DescribeSiftCommon.normalizeDescriptor | public static void normalizeDescriptor(TupleDesc_F64 descriptor , double maxDescriptorElementValue ) {
"""
Adjusts the descriptor. This adds lighting invariance and reduces the affects of none-affine changes
in lighting.
1) Apply L2 normalization
2) Clip using max descriptor value
3) Apply L2 normalization again
"""
// normalize descriptor to unit length
UtilFeature.normalizeL2(descriptor);
// clip the values
for (int i = 0; i < descriptor.size(); i++) {
double value = descriptor.value[i];
if( value > maxDescriptorElementValue ) {
descriptor.value[i] = maxDescriptorElementValue;
}
}
// normalize again
UtilFeature.normalizeL2(descriptor);
} | java | public static void normalizeDescriptor(TupleDesc_F64 descriptor , double maxDescriptorElementValue ) {
// normalize descriptor to unit length
UtilFeature.normalizeL2(descriptor);
// clip the values
for (int i = 0; i < descriptor.size(); i++) {
double value = descriptor.value[i];
if( value > maxDescriptorElementValue ) {
descriptor.value[i] = maxDescriptorElementValue;
}
}
// normalize again
UtilFeature.normalizeL2(descriptor);
} | [
"public",
"static",
"void",
"normalizeDescriptor",
"(",
"TupleDesc_F64",
"descriptor",
",",
"double",
"maxDescriptorElementValue",
")",
"{",
"// normalize descriptor to unit length",
"UtilFeature",
".",
"normalizeL2",
"(",
"descriptor",
")",
";",
"// clip the values",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"descriptor",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"double",
"value",
"=",
"descriptor",
".",
"value",
"[",
"i",
"]",
";",
"if",
"(",
"value",
">",
"maxDescriptorElementValue",
")",
"{",
"descriptor",
".",
"value",
"[",
"i",
"]",
"=",
"maxDescriptorElementValue",
";",
"}",
"}",
"// normalize again",
"UtilFeature",
".",
"normalizeL2",
"(",
"descriptor",
")",
";",
"}"
] | Adjusts the descriptor. This adds lighting invariance and reduces the affects of none-affine changes
in lighting.
1) Apply L2 normalization
2) Clip using max descriptor value
3) Apply L2 normalization again | [
"Adjusts",
"the",
"descriptor",
".",
"This",
"adds",
"lighting",
"invariance",
"and",
"reduces",
"the",
"affects",
"of",
"none",
"-",
"affine",
"changes",
"in",
"lighting",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribeSiftCommon.java#L84-L98 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.createKey | public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) {
"""
Creates a new key, stores it, then returns key parameters and attributes to the client.
The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. It requires the keys/create permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param keyName The name for the new key. The system will generate the version name for the new key.
@param kty The type of key to create. For valid values, see JsonWebKeyType. Possible values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct'
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the KeyBundle object if successful.
"""
return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty).toBlocking().single().body();
} | java | public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) {
return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty).toBlocking().single().body();
} | [
"public",
"KeyBundle",
"createKey",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"keyName",
",",
"JsonWebKeyType",
"kty",
")",
"{",
"return",
"createKeyWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"keyName",
",",
"kty",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates a new key, stores it, then returns key parameters and attributes to the client.
The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. It requires the keys/create permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param keyName The name for the new key. The system will generate the version name for the new key.
@param kty The type of key to create. For valid values, see JsonWebKeyType. Possible values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct'
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the KeyBundle object if successful. | [
"Creates",
"a",
"new",
"key",
"stores",
"it",
"then",
"returns",
"key",
"parameters",
"and",
"attributes",
"to",
"the",
"client",
".",
"The",
"create",
"key",
"operation",
"can",
"be",
"used",
"to",
"create",
"any",
"key",
"type",
"in",
"Azure",
"Key",
"Vault",
".",
"If",
"the",
"named",
"key",
"already",
"exists",
"Azure",
"Key",
"Vault",
"creates",
"a",
"new",
"version",
"of",
"the",
"key",
".",
"It",
"requires",
"the",
"keys",
"/",
"create",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L651-L653 |
cloudant/java-cloudant | cloudant-client/src/main/java/com/cloudant/client/internal/DatabaseURIHelper.java | DatabaseURIHelper.attachmentUri | public URI attachmentUri(String documentId, String revId, String attachmentId) {
"""
Returns URI for Attachment having {@code attachmentId} for {@code documentId}
and {@code revId}.
"""
return this.documentId(documentId).revId(revId).attachmentId(attachmentId).build();
} | java | public URI attachmentUri(String documentId, String revId, String attachmentId) {
return this.documentId(documentId).revId(revId).attachmentId(attachmentId).build();
} | [
"public",
"URI",
"attachmentUri",
"(",
"String",
"documentId",
",",
"String",
"revId",
",",
"String",
"attachmentId",
")",
"{",
"return",
"this",
".",
"documentId",
"(",
"documentId",
")",
".",
"revId",
"(",
"revId",
")",
".",
"attachmentId",
"(",
"attachmentId",
")",
".",
"build",
"(",
")",
";",
"}"
] | Returns URI for Attachment having {@code attachmentId} for {@code documentId}
and {@code revId}. | [
"Returns",
"URI",
"for",
"Attachment",
"having",
"{"
] | train | https://github.com/cloudant/java-cloudant/blob/42c438654945361bded2cc0827afc046d535b31b/cloudant-client/src/main/java/com/cloudant/client/internal/DatabaseURIHelper.java#L156-L158 |
apache/flink | flink-metrics/flink-metrics-core/src/main/java/org/apache/flink/metrics/MetricConfig.java | MetricConfig.getInteger | public int getInteger(String key, int defaultValue) {
"""
Searches for the property with the specified key in this property list.
If the key is not found in this property list, the default property list,
and its defaults, recursively, are then checked. The method returns the
default value argument if the property is not found.
@param key the hashtable key.
@param defaultValue a default value.
@return the value in this property list with the specified key value parsed as an int.
"""
String argument = getProperty(key, null);
return argument == null
? defaultValue
: Integer.parseInt(argument);
} | java | public int getInteger(String key, int defaultValue) {
String argument = getProperty(key, null);
return argument == null
? defaultValue
: Integer.parseInt(argument);
} | [
"public",
"int",
"getInteger",
"(",
"String",
"key",
",",
"int",
"defaultValue",
")",
"{",
"String",
"argument",
"=",
"getProperty",
"(",
"key",
",",
"null",
")",
";",
"return",
"argument",
"==",
"null",
"?",
"defaultValue",
":",
"Integer",
".",
"parseInt",
"(",
"argument",
")",
";",
"}"
] | Searches for the property with the specified key in this property list.
If the key is not found in this property list, the default property list,
and its defaults, recursively, are then checked. The method returns the
default value argument if the property is not found.
@param key the hashtable key.
@param defaultValue a default value.
@return the value in this property list with the specified key value parsed as an int. | [
"Searches",
"for",
"the",
"property",
"with",
"the",
"specified",
"key",
"in",
"this",
"property",
"list",
".",
"If",
"the",
"key",
"is",
"not",
"found",
"in",
"this",
"property",
"list",
"the",
"default",
"property",
"list",
"and",
"its",
"defaults",
"recursively",
"are",
"then",
"checked",
".",
"The",
"method",
"returns",
"the",
"default",
"value",
"argument",
"if",
"the",
"property",
"is",
"not",
"found",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-metrics/flink-metrics-core/src/main/java/org/apache/flink/metrics/MetricConfig.java#L42-L47 |
aoindustries/semanticcms-openfile-servlet | src/main/java/com/semanticcms/openfile/servlet/OpenFile.java | OpenFile.addFileOpener | public static void addFileOpener(ServletContext servletContext, FileOpener fileOpener, String ... extensions) {
"""
Registers a file opener.
@param extensions The simple extensions, in lowercase, not including the dot, such as "dia"
"""
synchronized(fileOpenersLock) {
@SuppressWarnings("unchecked")
Map<String,FileOpener> fileOpeners = (Map<String,FileOpener>)servletContext.getAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME);
if(fileOpeners == null) {
fileOpeners = new HashMap<>();
servletContext.setAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME, fileOpeners);
}
for(String extension : extensions) {
if(fileOpeners.containsKey(extension)) throw new IllegalStateException("File opener already registered: " + extension);
fileOpeners.put(extension, fileOpener);
}
}
} | java | public static void addFileOpener(ServletContext servletContext, FileOpener fileOpener, String ... extensions) {
synchronized(fileOpenersLock) {
@SuppressWarnings("unchecked")
Map<String,FileOpener> fileOpeners = (Map<String,FileOpener>)servletContext.getAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME);
if(fileOpeners == null) {
fileOpeners = new HashMap<>();
servletContext.setAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME, fileOpeners);
}
for(String extension : extensions) {
if(fileOpeners.containsKey(extension)) throw new IllegalStateException("File opener already registered: " + extension);
fileOpeners.put(extension, fileOpener);
}
}
} | [
"public",
"static",
"void",
"addFileOpener",
"(",
"ServletContext",
"servletContext",
",",
"FileOpener",
"fileOpener",
",",
"String",
"...",
"extensions",
")",
"{",
"synchronized",
"(",
"fileOpenersLock",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Map",
"<",
"String",
",",
"FileOpener",
">",
"fileOpeners",
"=",
"(",
"Map",
"<",
"String",
",",
"FileOpener",
">",
")",
"servletContext",
".",
"getAttribute",
"(",
"FILE_OPENERS_REQUEST_ATTRIBUTE_NAME",
")",
";",
"if",
"(",
"fileOpeners",
"==",
"null",
")",
"{",
"fileOpeners",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"servletContext",
".",
"setAttribute",
"(",
"FILE_OPENERS_REQUEST_ATTRIBUTE_NAME",
",",
"fileOpeners",
")",
";",
"}",
"for",
"(",
"String",
"extension",
":",
"extensions",
")",
"{",
"if",
"(",
"fileOpeners",
".",
"containsKey",
"(",
"extension",
")",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"File opener already registered: \"",
"+",
"extension",
")",
";",
"fileOpeners",
".",
"put",
"(",
"extension",
",",
"fileOpener",
")",
";",
"}",
"}",
"}"
] | Registers a file opener.
@param extensions The simple extensions, in lowercase, not including the dot, such as "dia" | [
"Registers",
"a",
"file",
"opener",
"."
] | train | https://github.com/aoindustries/semanticcms-openfile-servlet/blob/d22b2580b57708311949ac1088e3275355774921/src/main/java/com/semanticcms/openfile/servlet/OpenFile.java#L115-L128 |
eclipse/hawkbit | hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpAuthenticationMessageHandler.java | AmqpAuthenticationMessageHandler.checkIfArtifactIsAssignedToTarget | private void checkIfArtifactIsAssignedToTarget(final DmfTenantSecurityToken secruityToken, final String sha1Hash) {
"""
check action for this download purposes, the method will throw an
EntityNotFoundException in case the controller is not allowed to download
this file because it's not assigned to an action and not assigned to this
controller. Otherwise no controllerId is set = anonymous download
@param secruityToken
the security token which holds the target ID to check on
@param sha1Hash
of the artifact to verify if the given target is allowed to
download it
"""
if (secruityToken.getControllerId() != null) {
checkByControllerId(sha1Hash, secruityToken.getControllerId());
} else if (secruityToken.getTargetId() != null) {
checkByTargetId(sha1Hash, secruityToken.getTargetId());
} else {
LOG.info("anonymous download no authentication check for artifact {}", sha1Hash);
}
} | java | private void checkIfArtifactIsAssignedToTarget(final DmfTenantSecurityToken secruityToken, final String sha1Hash) {
if (secruityToken.getControllerId() != null) {
checkByControllerId(sha1Hash, secruityToken.getControllerId());
} else if (secruityToken.getTargetId() != null) {
checkByTargetId(sha1Hash, secruityToken.getTargetId());
} else {
LOG.info("anonymous download no authentication check for artifact {}", sha1Hash);
}
} | [
"private",
"void",
"checkIfArtifactIsAssignedToTarget",
"(",
"final",
"DmfTenantSecurityToken",
"secruityToken",
",",
"final",
"String",
"sha1Hash",
")",
"{",
"if",
"(",
"secruityToken",
".",
"getControllerId",
"(",
")",
"!=",
"null",
")",
"{",
"checkByControllerId",
"(",
"sha1Hash",
",",
"secruityToken",
".",
"getControllerId",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"secruityToken",
".",
"getTargetId",
"(",
")",
"!=",
"null",
")",
"{",
"checkByTargetId",
"(",
"sha1Hash",
",",
"secruityToken",
".",
"getTargetId",
"(",
")",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"info",
"(",
"\"anonymous download no authentication check for artifact {}\"",
",",
"sha1Hash",
")",
";",
"}",
"}"
] | check action for this download purposes, the method will throw an
EntityNotFoundException in case the controller is not allowed to download
this file because it's not assigned to an action and not assigned to this
controller. Otherwise no controllerId is set = anonymous download
@param secruityToken
the security token which holds the target ID to check on
@param sha1Hash
of the artifact to verify if the given target is allowed to
download it | [
"check",
"action",
"for",
"this",
"download",
"purposes",
"the",
"method",
"will",
"throw",
"an",
"EntityNotFoundException",
"in",
"case",
"the",
"controller",
"is",
"not",
"allowed",
"to",
"download",
"this",
"file",
"because",
"it",
"s",
"not",
"assigned",
"to",
"an",
"action",
"and",
"not",
"assigned",
"to",
"this",
"controller",
".",
"Otherwise",
"no",
"controllerId",
"is",
"set",
"=",
"anonymous",
"download"
] | train | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpAuthenticationMessageHandler.java#L128-L138 |
salesforce/Argus | ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/resources/ManagementResources.java | ManagementResources.reinstateUser | @PUT
@Path("/reinstateuser")
@Produces(MediaType.APPLICATION_JSON)
@Description("Reinstates a suspended user.")
public Response reinstateUser(@Context HttpServletRequest req,
@FormParam("username") String userName,
@FormParam("subsystem") SubSystem subSystem) {
"""
Reinstates the specified sub system to the user.
@param req The HTTP request.
@param userName The user whom the sub system to be reinstated. Cannot be null or empty.
@param subSystem The subsystem to be reinstated. Cannot be null.
@return Response object indicating whether the operation was successful or not.
@throws IllegalArgumentException Throws IllegalArgument exception when the input is not valid.
@throws WebApplicationException Throws this exception if the user does not exist or the user is not authorized to carry out this operation.
"""
if (userName == null || userName.isEmpty()) {
throw new IllegalArgumentException("User name cannot be null or empty.");
}
if (subSystem == null) {
throw new IllegalArgumentException("Subsystem cannot be null.");
}
validatePrivilegedUser(req);
PrincipalUser user = userService.findUserByUsername(userName);
if (user == null) {
throw new WebApplicationException("User does not exist.", Status.BAD_REQUEST);
}
managementService.reinstateUser(user, subSystem);
return Response.status(Status.OK).build();
} | java | @PUT
@Path("/reinstateuser")
@Produces(MediaType.APPLICATION_JSON)
@Description("Reinstates a suspended user.")
public Response reinstateUser(@Context HttpServletRequest req,
@FormParam("username") String userName,
@FormParam("subsystem") SubSystem subSystem) {
if (userName == null || userName.isEmpty()) {
throw new IllegalArgumentException("User name cannot be null or empty.");
}
if (subSystem == null) {
throw new IllegalArgumentException("Subsystem cannot be null.");
}
validatePrivilegedUser(req);
PrincipalUser user = userService.findUserByUsername(userName);
if (user == null) {
throw new WebApplicationException("User does not exist.", Status.BAD_REQUEST);
}
managementService.reinstateUser(user, subSystem);
return Response.status(Status.OK).build();
} | [
"@",
"PUT",
"@",
"Path",
"(",
"\"/reinstateuser\"",
")",
"@",
"Produces",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"@",
"Description",
"(",
"\"Reinstates a suspended user.\"",
")",
"public",
"Response",
"reinstateUser",
"(",
"@",
"Context",
"HttpServletRequest",
"req",
",",
"@",
"FormParam",
"(",
"\"username\"",
")",
"String",
"userName",
",",
"@",
"FormParam",
"(",
"\"subsystem\"",
")",
"SubSystem",
"subSystem",
")",
"{",
"if",
"(",
"userName",
"==",
"null",
"||",
"userName",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"User name cannot be null or empty.\"",
")",
";",
"}",
"if",
"(",
"subSystem",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Subsystem cannot be null.\"",
")",
";",
"}",
"validatePrivilegedUser",
"(",
"req",
")",
";",
"PrincipalUser",
"user",
"=",
"userService",
".",
"findUserByUsername",
"(",
"userName",
")",
";",
"if",
"(",
"user",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"\"User does not exist.\"",
",",
"Status",
".",
"BAD_REQUEST",
")",
";",
"}",
"managementService",
".",
"reinstateUser",
"(",
"user",
",",
"subSystem",
")",
";",
"return",
"Response",
".",
"status",
"(",
"Status",
".",
"OK",
")",
".",
"build",
"(",
")",
";",
"}"
] | Reinstates the specified sub system to the user.
@param req The HTTP request.
@param userName The user whom the sub system to be reinstated. Cannot be null or empty.
@param subSystem The subsystem to be reinstated. Cannot be null.
@return Response object indicating whether the operation was successful or not.
@throws IllegalArgumentException Throws IllegalArgument exception when the input is not valid.
@throws WebApplicationException Throws this exception if the user does not exist or the user is not authorized to carry out this operation. | [
"Reinstates",
"the",
"specified",
"sub",
"system",
"to",
"the",
"user",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/resources/ManagementResources.java#L155-L177 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Transaction.java | Transaction.addInput | public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script) {
"""
Creates and adds an input to this transaction, with no checking that it's valid.
@return the newly created input.
"""
return addInput(new TransactionInput(params, this, script.getProgram(), new TransactionOutPoint(params, outputIndex, spendTxHash)));
} | java | public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script) {
return addInput(new TransactionInput(params, this, script.getProgram(), new TransactionOutPoint(params, outputIndex, spendTxHash)));
} | [
"public",
"TransactionInput",
"addInput",
"(",
"Sha256Hash",
"spendTxHash",
",",
"long",
"outputIndex",
",",
"Script",
"script",
")",
"{",
"return",
"addInput",
"(",
"new",
"TransactionInput",
"(",
"params",
",",
"this",
",",
"script",
".",
"getProgram",
"(",
")",
",",
"new",
"TransactionOutPoint",
"(",
"params",
",",
"outputIndex",
",",
"spendTxHash",
")",
")",
")",
";",
"}"
] | Creates and adds an input to this transaction, with no checking that it's valid.
@return the newly created input. | [
"Creates",
"and",
"adds",
"an",
"input",
"to",
"this",
"transaction",
"with",
"no",
"checking",
"that",
"it",
"s",
"valid",
"."
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Transaction.java#L947-L949 |
gosu-lang/gosu-lang | gosu-core-api/src/main/java/gw/util/GosuStringUtil.java | GosuStringUtil.startsWithAny | public static boolean startsWithAny(String string, String[] searchStrings) {
"""
<p>Check if a String starts with any of an array of specified strings.</p>
<pre>
GosuStringUtil.startsWithAny(null, null) = false
GosuStringUtil.startsWithAny(null, new String[] {"abc"}) = false
GosuStringUtil.startsWithAny("abcxyz", null) = false
GosuStringUtil.startsWithAny("abcxyz", new String[] {""}) = false
GosuStringUtil.startsWithAny("abcxyz", new String[] {"abc"}) = true
GosuStringUtil.startsWithAny("abcxyz", new String[] {null, "xyz", "abc"}) = true
</pre>
@param string the String to check, may be null
@param searchStrings the Strings to find, may be null or empty
@return <code>true</code> if the String starts with any of the the prefixes, case insensitive, or
both <code>null</code>
@since 3.0
"""
if (isEmpty(string) || searchStrings == null) {
return false;
}
for (int i = 0; i < searchStrings.length; i++) {
String searchString = searchStrings[i];
if ( GosuStringUtil.startsWith(string, searchString)) {
return true;
}
}
return false;
} | java | public static boolean startsWithAny(String string, String[] searchStrings) {
if (isEmpty(string) || searchStrings == null) {
return false;
}
for (int i = 0; i < searchStrings.length; i++) {
String searchString = searchStrings[i];
if ( GosuStringUtil.startsWith(string, searchString)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"startsWithAny",
"(",
"String",
"string",
",",
"String",
"[",
"]",
"searchStrings",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"string",
")",
"||",
"searchStrings",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"searchStrings",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"searchString",
"=",
"searchStrings",
"[",
"i",
"]",
";",
"if",
"(",
"GosuStringUtil",
".",
"startsWith",
"(",
"string",
",",
"searchString",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | <p>Check if a String starts with any of an array of specified strings.</p>
<pre>
GosuStringUtil.startsWithAny(null, null) = false
GosuStringUtil.startsWithAny(null, new String[] {"abc"}) = false
GosuStringUtil.startsWithAny("abcxyz", null) = false
GosuStringUtil.startsWithAny("abcxyz", new String[] {""}) = false
GosuStringUtil.startsWithAny("abcxyz", new String[] {"abc"}) = true
GosuStringUtil.startsWithAny("abcxyz", new String[] {null, "xyz", "abc"}) = true
</pre>
@param string the String to check, may be null
@param searchStrings the Strings to find, may be null or empty
@return <code>true</code> if the String starts with any of the the prefixes, case insensitive, or
both <code>null</code>
@since 3.0 | [
"<p",
">",
"Check",
"if",
"a",
"String",
"starts",
"with",
"any",
"of",
"an",
"array",
"of",
"specified",
"strings",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/util/GosuStringUtil.java#L5838-L5849 |
apache/incubator-atlas | repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipDefStoreV1.java | AtlasRelationshipDefStoreV1.preUpdateCheck | public static void preUpdateCheck(AtlasRelationshipDef newRelationshipDef, AtlasRelationshipDef existingRelationshipDef) throws AtlasBaseException {
"""
Check ends are the same and relationshipCategory is the same.
We do this by comparing 2 relationshipDefs to avoid exposing the AtlasVertex to unit testing.
@param newRelationshipDef
@param existingRelationshipDef
@throws AtlasBaseException
"""
// do not allow renames of the Def.
String existingName = existingRelationshipDef.getName();
String newName = newRelationshipDef.getName();
if (!existingName.equals(newName)) {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_NAME_UPDATE,
newRelationshipDef.getGuid(),existingName, newName);
}
RelationshipCategory existingRelationshipCategory = existingRelationshipDef.getRelationshipCategory();
RelationshipCategory newRelationshipCategory = newRelationshipDef.getRelationshipCategory();
if ( !existingRelationshipCategory.equals(newRelationshipCategory)){
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_CATEGORY_UPDATE,
newRelationshipDef.getName(),newRelationshipCategory.name(),
existingRelationshipCategory.name() );
}
AtlasRelationshipEndDef existingEnd1 = existingRelationshipDef.getEndDef1();
AtlasRelationshipEndDef newEnd1 = newRelationshipDef.getEndDef1();
if ( !newEnd1.equals(existingEnd1) ) {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END1_UPDATE,
newRelationshipDef.getName(), newEnd1.toString(), existingEnd1.toString());
}
AtlasRelationshipEndDef existingEnd2 = existingRelationshipDef.getEndDef2();
AtlasRelationshipEndDef newEnd2 = newRelationshipDef.getEndDef2();
if ( !newEnd2.equals(existingEnd2) ) {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END2_UPDATE,
newRelationshipDef.getName(), newEnd2.toString(), existingEnd2.toString());
}
} | java | public static void preUpdateCheck(AtlasRelationshipDef newRelationshipDef, AtlasRelationshipDef existingRelationshipDef) throws AtlasBaseException {
// do not allow renames of the Def.
String existingName = existingRelationshipDef.getName();
String newName = newRelationshipDef.getName();
if (!existingName.equals(newName)) {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_NAME_UPDATE,
newRelationshipDef.getGuid(),existingName, newName);
}
RelationshipCategory existingRelationshipCategory = existingRelationshipDef.getRelationshipCategory();
RelationshipCategory newRelationshipCategory = newRelationshipDef.getRelationshipCategory();
if ( !existingRelationshipCategory.equals(newRelationshipCategory)){
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_CATEGORY_UPDATE,
newRelationshipDef.getName(),newRelationshipCategory.name(),
existingRelationshipCategory.name() );
}
AtlasRelationshipEndDef existingEnd1 = existingRelationshipDef.getEndDef1();
AtlasRelationshipEndDef newEnd1 = newRelationshipDef.getEndDef1();
if ( !newEnd1.equals(existingEnd1) ) {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END1_UPDATE,
newRelationshipDef.getName(), newEnd1.toString(), existingEnd1.toString());
}
AtlasRelationshipEndDef existingEnd2 = existingRelationshipDef.getEndDef2();
AtlasRelationshipEndDef newEnd2 = newRelationshipDef.getEndDef2();
if ( !newEnd2.equals(existingEnd2) ) {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END2_UPDATE,
newRelationshipDef.getName(), newEnd2.toString(), existingEnd2.toString());
}
} | [
"public",
"static",
"void",
"preUpdateCheck",
"(",
"AtlasRelationshipDef",
"newRelationshipDef",
",",
"AtlasRelationshipDef",
"existingRelationshipDef",
")",
"throws",
"AtlasBaseException",
"{",
"// do not allow renames of the Def.",
"String",
"existingName",
"=",
"existingRelationshipDef",
".",
"getName",
"(",
")",
";",
"String",
"newName",
"=",
"newRelationshipDef",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"existingName",
".",
"equals",
"(",
"newName",
")",
")",
"{",
"throw",
"new",
"AtlasBaseException",
"(",
"AtlasErrorCode",
".",
"RELATIONSHIPDEF_INVALID_NAME_UPDATE",
",",
"newRelationshipDef",
".",
"getGuid",
"(",
")",
",",
"existingName",
",",
"newName",
")",
";",
"}",
"RelationshipCategory",
"existingRelationshipCategory",
"=",
"existingRelationshipDef",
".",
"getRelationshipCategory",
"(",
")",
";",
"RelationshipCategory",
"newRelationshipCategory",
"=",
"newRelationshipDef",
".",
"getRelationshipCategory",
"(",
")",
";",
"if",
"(",
"!",
"existingRelationshipCategory",
".",
"equals",
"(",
"newRelationshipCategory",
")",
")",
"{",
"throw",
"new",
"AtlasBaseException",
"(",
"AtlasErrorCode",
".",
"RELATIONSHIPDEF_INVALID_CATEGORY_UPDATE",
",",
"newRelationshipDef",
".",
"getName",
"(",
")",
",",
"newRelationshipCategory",
".",
"name",
"(",
")",
",",
"existingRelationshipCategory",
".",
"name",
"(",
")",
")",
";",
"}",
"AtlasRelationshipEndDef",
"existingEnd1",
"=",
"existingRelationshipDef",
".",
"getEndDef1",
"(",
")",
";",
"AtlasRelationshipEndDef",
"newEnd1",
"=",
"newRelationshipDef",
".",
"getEndDef1",
"(",
")",
";",
"if",
"(",
"!",
"newEnd1",
".",
"equals",
"(",
"existingEnd1",
")",
")",
"{",
"throw",
"new",
"AtlasBaseException",
"(",
"AtlasErrorCode",
".",
"RELATIONSHIPDEF_INVALID_END1_UPDATE",
",",
"newRelationshipDef",
".",
"getName",
"(",
")",
",",
"newEnd1",
".",
"toString",
"(",
")",
",",
"existingEnd1",
".",
"toString",
"(",
")",
")",
";",
"}",
"AtlasRelationshipEndDef",
"existingEnd2",
"=",
"existingRelationshipDef",
".",
"getEndDef2",
"(",
")",
";",
"AtlasRelationshipEndDef",
"newEnd2",
"=",
"newRelationshipDef",
".",
"getEndDef2",
"(",
")",
";",
"if",
"(",
"!",
"newEnd2",
".",
"equals",
"(",
"existingEnd2",
")",
")",
"{",
"throw",
"new",
"AtlasBaseException",
"(",
"AtlasErrorCode",
".",
"RELATIONSHIPDEF_INVALID_END2_UPDATE",
",",
"newRelationshipDef",
".",
"getName",
"(",
")",
",",
"newEnd2",
".",
"toString",
"(",
")",
",",
"existingEnd2",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Check ends are the same and relationshipCategory is the same.
We do this by comparing 2 relationshipDefs to avoid exposing the AtlasVertex to unit testing.
@param newRelationshipDef
@param existingRelationshipDef
@throws AtlasBaseException | [
"Check",
"ends",
"are",
"the",
"same",
"and",
"relationshipCategory",
"is",
"the",
"same",
"."
] | train | https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipDefStoreV1.java#L442-L476 |
apereo/cas | core/cas-server-core-web-api/src/main/java/org/apereo/cas/services/web/view/AbstractCasView.java | AbstractCasView.prepareCasResponseAttributesForViewModel | protected void prepareCasResponseAttributesForViewModel(final Map<String, Object> model) {
"""
Prepare cas response attributes for view model.
@param model the model
"""
val service = authenticationRequestServiceSelectionStrategies.resolveService(getServiceFrom(model));
val registeredService = this.servicesManager.findServiceBy(service);
val principalAttributes = getCasPrincipalAttributes(model, registeredService);
val attributes = new HashMap<String, Object>(principalAttributes);
LOGGER.trace("Processed principal attributes from the output model to be [{}]", principalAttributes.keySet());
val protocolAttributes = getCasProtocolAuthenticationAttributes(model, registeredService);
attributes.putAll(protocolAttributes);
LOGGER.debug("Final collection of attributes for the response are [{}].", attributes.keySet());
putCasResponseAttributesIntoModel(model, attributes, registeredService, this.attributesRenderer);
} | java | protected void prepareCasResponseAttributesForViewModel(final Map<String, Object> model) {
val service = authenticationRequestServiceSelectionStrategies.resolveService(getServiceFrom(model));
val registeredService = this.servicesManager.findServiceBy(service);
val principalAttributes = getCasPrincipalAttributes(model, registeredService);
val attributes = new HashMap<String, Object>(principalAttributes);
LOGGER.trace("Processed principal attributes from the output model to be [{}]", principalAttributes.keySet());
val protocolAttributes = getCasProtocolAuthenticationAttributes(model, registeredService);
attributes.putAll(protocolAttributes);
LOGGER.debug("Final collection of attributes for the response are [{}].", attributes.keySet());
putCasResponseAttributesIntoModel(model, attributes, registeredService, this.attributesRenderer);
} | [
"protected",
"void",
"prepareCasResponseAttributesForViewModel",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"model",
")",
"{",
"val",
"service",
"=",
"authenticationRequestServiceSelectionStrategies",
".",
"resolveService",
"(",
"getServiceFrom",
"(",
"model",
")",
")",
";",
"val",
"registeredService",
"=",
"this",
".",
"servicesManager",
".",
"findServiceBy",
"(",
"service",
")",
";",
"val",
"principalAttributes",
"=",
"getCasPrincipalAttributes",
"(",
"model",
",",
"registeredService",
")",
";",
"val",
"attributes",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
"principalAttributes",
")",
";",
"LOGGER",
".",
"trace",
"(",
"\"Processed principal attributes from the output model to be [{}]\"",
",",
"principalAttributes",
".",
"keySet",
"(",
")",
")",
";",
"val",
"protocolAttributes",
"=",
"getCasProtocolAuthenticationAttributes",
"(",
"model",
",",
"registeredService",
")",
";",
"attributes",
".",
"putAll",
"(",
"protocolAttributes",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Final collection of attributes for the response are [{}].\"",
",",
"attributes",
".",
"keySet",
"(",
")",
")",
";",
"putCasResponseAttributesIntoModel",
"(",
"model",
",",
"attributes",
",",
"registeredService",
",",
"this",
".",
"attributesRenderer",
")",
";",
"}"
] | Prepare cas response attributes for view model.
@param model the model | [
"Prepare",
"cas",
"response",
"attributes",
"for",
"view",
"model",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-web-api/src/main/java/org/apereo/cas/services/web/view/AbstractCasView.java#L232-L245 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.deleteClosedListAsync | public Observable<OperationStatus> deleteClosedListAsync(UUID appId, String versionId, UUID clEntityId) {
"""
Deletes a closed list model from the application.
@param appId The application ID.
@param versionId The version ID.
@param clEntityId The closed list model ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object
"""
return deleteClosedListWithServiceResponseAsync(appId, versionId, clEntityId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | java | public Observable<OperationStatus> deleteClosedListAsync(UUID appId, String versionId, UUID clEntityId) {
return deleteClosedListWithServiceResponseAsync(appId, versionId, clEntityId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"OperationStatus",
">",
"deleteClosedListAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"clEntityId",
")",
"{",
"return",
"deleteClosedListWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"clEntityId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OperationStatus",
">",
",",
"OperationStatus",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OperationStatus",
"call",
"(",
"ServiceResponse",
"<",
"OperationStatus",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Deletes a closed list model from the application.
@param appId The application ID.
@param versionId The version ID.
@param clEntityId The closed list model ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object | [
"Deletes",
"a",
"closed",
"list",
"model",
"from",
"the",
"application",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L4625-L4632 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/Assert.java | Assert.isFalse | public static void isFalse(boolean expression, String errorMsgTemplate, Object... params) throws IllegalArgumentException {
"""
断言是否为假,如果为 {@code true} 抛出 {@code IllegalArgumentException} 异常<br>
<pre class="code">
Assert.isFalse(i < 0, "The value must be greater than zero");
</pre>
@param expression 波尔值
@param errorMsgTemplate 错误抛出异常附带的消息模板,变量用{}代替
@param params 参数列表
@throws IllegalArgumentException if expression is {@code false}
"""
if (expression) {
throw new IllegalArgumentException(StrUtil.format(errorMsgTemplate, params));
}
} | java | public static void isFalse(boolean expression, String errorMsgTemplate, Object... params) throws IllegalArgumentException {
if (expression) {
throw new IllegalArgumentException(StrUtil.format(errorMsgTemplate, params));
}
} | [
"public",
"static",
"void",
"isFalse",
"(",
"boolean",
"expression",
",",
"String",
"errorMsgTemplate",
",",
"Object",
"...",
"params",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"expression",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"StrUtil",
".",
"format",
"(",
"errorMsgTemplate",
",",
"params",
")",
")",
";",
"}",
"}"
] | 断言是否为假,如果为 {@code true} 抛出 {@code IllegalArgumentException} 异常<br>
<pre class="code">
Assert.isFalse(i < 0, "The value must be greater than zero");
</pre>
@param expression 波尔值
@param errorMsgTemplate 错误抛出异常附带的消息模板,变量用{}代替
@param params 参数列表
@throws IllegalArgumentException if expression is {@code false} | [
"断言是否为假,如果为",
"{",
"@code",
"true",
"}",
"抛出",
"{",
"@code",
"IllegalArgumentException",
"}",
"异常<br",
">"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Assert.java#L63-L67 |
algolia/instantsearch-android | ui/src/main/java/com/algolia/instantsearch/ui/databinding/BindingHelper.java | BindingHelper.setVariantForView | @Nullable
public static String setVariantForView(@NonNull View view, @Nullable String variant) {
"""
Associates programmatically a view with a variant.
@param view any existing view.
@return the previous variant for this view, if any.
"""
String previousVariant = null;
String previousAttribute = null;
for (Map.Entry<String, HashMap<Integer, String>> entry : bindings.entrySet()) {
if (entry.getValue().containsKey(view.getId())) {
previousVariant = entry.getKey();
previousAttribute = entry.getValue().get(view.getId());
bindings.remove(previousVariant);
break;
}
}
mapAttribute(previousAttribute, view.getId(), variant, view.getClass().getSimpleName());
return previousVariant;
} | java | @Nullable
public static String setVariantForView(@NonNull View view, @Nullable String variant) {
String previousVariant = null;
String previousAttribute = null;
for (Map.Entry<String, HashMap<Integer, String>> entry : bindings.entrySet()) {
if (entry.getValue().containsKey(view.getId())) {
previousVariant = entry.getKey();
previousAttribute = entry.getValue().get(view.getId());
bindings.remove(previousVariant);
break;
}
}
mapAttribute(previousAttribute, view.getId(), variant, view.getClass().getSimpleName());
return previousVariant;
} | [
"@",
"Nullable",
"public",
"static",
"String",
"setVariantForView",
"(",
"@",
"NonNull",
"View",
"view",
",",
"@",
"Nullable",
"String",
"variant",
")",
"{",
"String",
"previousVariant",
"=",
"null",
";",
"String",
"previousAttribute",
"=",
"null",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"HashMap",
"<",
"Integer",
",",
"String",
">",
">",
"entry",
":",
"bindings",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"containsKey",
"(",
"view",
".",
"getId",
"(",
")",
")",
")",
"{",
"previousVariant",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"previousAttribute",
"=",
"entry",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"view",
".",
"getId",
"(",
")",
")",
";",
"bindings",
".",
"remove",
"(",
"previousVariant",
")",
";",
"break",
";",
"}",
"}",
"mapAttribute",
"(",
"previousAttribute",
",",
"view",
".",
"getId",
"(",
")",
",",
"variant",
",",
"view",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"return",
"previousVariant",
";",
"}"
] | Associates programmatically a view with a variant.
@param view any existing view.
@return the previous variant for this view, if any. | [
"Associates",
"programmatically",
"a",
"view",
"with",
"a",
"variant",
"."
] | train | https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/databinding/BindingHelper.java#L119-L133 |
Kickflip/kickflip-android-sdk | sdk/src/main/java/io/kickflip/sdk/av/FFmpegMuxer.java | FFmpegMuxer.packageH264Keyframe | private void packageH264Keyframe(ByteBuffer encodedData, MediaCodec.BufferInfo bufferInfo) {
"""
Adds the SPS + PPS data to the ByteBuffer containing a h264 keyframe
@param encodedData
@param bufferInfo
"""
mH264Keyframe.position(mH264MetaSize);
mH264Keyframe.put(encodedData); // BufferOverflow
} | java | private void packageH264Keyframe(ByteBuffer encodedData, MediaCodec.BufferInfo bufferInfo) {
mH264Keyframe.position(mH264MetaSize);
mH264Keyframe.put(encodedData); // BufferOverflow
} | [
"private",
"void",
"packageH264Keyframe",
"(",
"ByteBuffer",
"encodedData",
",",
"MediaCodec",
".",
"BufferInfo",
"bufferInfo",
")",
"{",
"mH264Keyframe",
".",
"position",
"(",
"mH264MetaSize",
")",
";",
"mH264Keyframe",
".",
"put",
"(",
"encodedData",
")",
";",
"// BufferOverflow",
"}"
] | Adds the SPS + PPS data to the ByteBuffer containing a h264 keyframe
@param encodedData
@param bufferInfo | [
"Adds",
"the",
"SPS",
"+",
"PPS",
"data",
"to",
"the",
"ByteBuffer",
"containing",
"a",
"h264",
"keyframe"
] | train | https://github.com/Kickflip/kickflip-android-sdk/blob/af3aae5f1128d7376e67aefe11a3a1a3844be734/sdk/src/main/java/io/kickflip/sdk/av/FFmpegMuxer.java#L313-L316 |
glyptodon/guacamole-client | extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java | ModeledUser.setUnrestrictedAttributes | private void setUnrestrictedAttributes(Map<String, String> attributes) {
"""
Stores all unrestricted (unprivileged) attributes within the underlying
user model, pulling the values of those attributes from the given Map.
@param attributes
The Map to pull all unrestricted attributes from.
"""
// Translate full name attribute
getModel().setFullName(TextField.parse(attributes.get(User.Attribute.FULL_NAME)));
// Translate email address attribute
getModel().setEmailAddress(TextField.parse(attributes.get(User.Attribute.EMAIL_ADDRESS)));
// Translate organization attribute
getModel().setOrganization(TextField.parse(attributes.get(User.Attribute.ORGANIZATION)));
// Translate role attribute
getModel().setOrganizationalRole(TextField.parse(attributes.get(User.Attribute.ORGANIZATIONAL_ROLE)));
} | java | private void setUnrestrictedAttributes(Map<String, String> attributes) {
// Translate full name attribute
getModel().setFullName(TextField.parse(attributes.get(User.Attribute.FULL_NAME)));
// Translate email address attribute
getModel().setEmailAddress(TextField.parse(attributes.get(User.Attribute.EMAIL_ADDRESS)));
// Translate organization attribute
getModel().setOrganization(TextField.parse(attributes.get(User.Attribute.ORGANIZATION)));
// Translate role attribute
getModel().setOrganizationalRole(TextField.parse(attributes.get(User.Attribute.ORGANIZATIONAL_ROLE)));
} | [
"private",
"void",
"setUnrestrictedAttributes",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"attributes",
")",
"{",
"// Translate full name attribute",
"getModel",
"(",
")",
".",
"setFullName",
"(",
"TextField",
".",
"parse",
"(",
"attributes",
".",
"get",
"(",
"User",
".",
"Attribute",
".",
"FULL_NAME",
")",
")",
")",
";",
"// Translate email address attribute",
"getModel",
"(",
")",
".",
"setEmailAddress",
"(",
"TextField",
".",
"parse",
"(",
"attributes",
".",
"get",
"(",
"User",
".",
"Attribute",
".",
"EMAIL_ADDRESS",
")",
")",
")",
";",
"// Translate organization attribute",
"getModel",
"(",
")",
".",
"setOrganization",
"(",
"TextField",
".",
"parse",
"(",
"attributes",
".",
"get",
"(",
"User",
".",
"Attribute",
".",
"ORGANIZATION",
")",
")",
")",
";",
"// Translate role attribute",
"getModel",
"(",
")",
".",
"setOrganizationalRole",
"(",
"TextField",
".",
"parse",
"(",
"attributes",
".",
"get",
"(",
"User",
".",
"Attribute",
".",
"ORGANIZATIONAL_ROLE",
")",
")",
")",
";",
"}"
] | Stores all unrestricted (unprivileged) attributes within the underlying
user model, pulling the values of those attributes from the given Map.
@param attributes
The Map to pull all unrestricted attributes from. | [
"Stores",
"all",
"unrestricted",
"(",
"unprivileged",
")",
"attributes",
"within",
"the",
"underlying",
"user",
"model",
"pulling",
"the",
"values",
"of",
"those",
"attributes",
"from",
"the",
"given",
"Map",
"."
] | train | https://github.com/glyptodon/guacamole-client/blob/ea1b10e9d1e3f1fa640dff2ca64d61b44bf1ace9/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java#L467-L481 |
google/closure-compiler | src/com/google/javascript/jscomp/NodeUtil.java | NodeUtil.referencesThis | static boolean referencesThis(Node n) {
"""
Returns true if the shallow scope contains references to 'this' keyword
"""
if (n.isFunction()) {
return referencesThis(NodeUtil.getFunctionParameters(n))
|| referencesThis(NodeUtil.getFunctionBody(n));
} else {
return has(n, Node::isThis, MATCH_ANYTHING_BUT_NON_ARROW_FUNCTION);
}
} | java | static boolean referencesThis(Node n) {
if (n.isFunction()) {
return referencesThis(NodeUtil.getFunctionParameters(n))
|| referencesThis(NodeUtil.getFunctionBody(n));
} else {
return has(n, Node::isThis, MATCH_ANYTHING_BUT_NON_ARROW_FUNCTION);
}
} | [
"static",
"boolean",
"referencesThis",
"(",
"Node",
"n",
")",
"{",
"if",
"(",
"n",
".",
"isFunction",
"(",
")",
")",
"{",
"return",
"referencesThis",
"(",
"NodeUtil",
".",
"getFunctionParameters",
"(",
"n",
")",
")",
"||",
"referencesThis",
"(",
"NodeUtil",
".",
"getFunctionBody",
"(",
"n",
")",
")",
";",
"}",
"else",
"{",
"return",
"has",
"(",
"n",
",",
"Node",
"::",
"isThis",
",",
"MATCH_ANYTHING_BUT_NON_ARROW_FUNCTION",
")",
";",
"}",
"}"
] | Returns true if the shallow scope contains references to 'this' keyword | [
"Returns",
"true",
"if",
"the",
"shallow",
"scope",
"contains",
"references",
"to",
"this",
"keyword"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2344-L2351 |
mgledi/DRUMS | src/main/java/com/unister/semweb/drums/api/DRUMSInstantiator.java | DRUMSInstantiator.openTable | public static <Data extends AbstractKVStorable> DRUMS<Data> openTable(AccessMode accessMode,
DRUMSParameterSet<Data> gp) throws IOException {
"""
Opens an existing table.
@param accessMode
the AccessMode, how to access the DRUMS
@param gp
pointer to the {@link DRUMSParameterSet} used by the {@link DRUMS} to open
@return the table
@throws IOException
"""
AbstractHashFunction hashFunction;
try {
hashFunction = readHashFunction(gp);
} catch (ClassNotFoundException e) {
throw new IOException("Could not load HashFunction from " + gp.DATABASE_DIRECTORY, e);
}
return new DRUMS<Data>(hashFunction, accessMode, gp);
} | java | public static <Data extends AbstractKVStorable> DRUMS<Data> openTable(AccessMode accessMode,
DRUMSParameterSet<Data> gp) throws IOException {
AbstractHashFunction hashFunction;
try {
hashFunction = readHashFunction(gp);
} catch (ClassNotFoundException e) {
throw new IOException("Could not load HashFunction from " + gp.DATABASE_DIRECTORY, e);
}
return new DRUMS<Data>(hashFunction, accessMode, gp);
} | [
"public",
"static",
"<",
"Data",
"extends",
"AbstractKVStorable",
">",
"DRUMS",
"<",
"Data",
">",
"openTable",
"(",
"AccessMode",
"accessMode",
",",
"DRUMSParameterSet",
"<",
"Data",
">",
"gp",
")",
"throws",
"IOException",
"{",
"AbstractHashFunction",
"hashFunction",
";",
"try",
"{",
"hashFunction",
"=",
"readHashFunction",
"(",
"gp",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not load HashFunction from \"",
"+",
"gp",
".",
"DATABASE_DIRECTORY",
",",
"e",
")",
";",
"}",
"return",
"new",
"DRUMS",
"<",
"Data",
">",
"(",
"hashFunction",
",",
"accessMode",
",",
"gp",
")",
";",
"}"
] | Opens an existing table.
@param accessMode
the AccessMode, how to access the DRUMS
@param gp
pointer to the {@link DRUMSParameterSet} used by the {@link DRUMS} to open
@return the table
@throws IOException | [
"Opens",
"an",
"existing",
"table",
"."
] | train | https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/api/DRUMSInstantiator.java#L103-L112 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildsInner.java | BuildsInner.updateAsync | public Observable<BuildInner> updateAsync(String resourceGroupName, String registryName, String buildId) {
"""
Patch the build properties.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param buildId The build ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return updateWithServiceResponseAsync(resourceGroupName, registryName, buildId).map(new Func1<ServiceResponse<BuildInner>, BuildInner>() {
@Override
public BuildInner call(ServiceResponse<BuildInner> response) {
return response.body();
}
});
} | java | public Observable<BuildInner> updateAsync(String resourceGroupName, String registryName, String buildId) {
return updateWithServiceResponseAsync(resourceGroupName, registryName, buildId).map(new Func1<ServiceResponse<BuildInner>, BuildInner>() {
@Override
public BuildInner call(ServiceResponse<BuildInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"BuildInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"String",
"buildId",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"buildId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"BuildInner",
">",
",",
"BuildInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"BuildInner",
"call",
"(",
"ServiceResponse",
"<",
"BuildInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Patch the build properties.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param buildId The build ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Patch",
"the",
"build",
"properties",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildsInner.java#L480-L487 |
m-m-m/util | contenttype/src/main/java/net/sf/mmm/util/contenttype/base/AbstractContentTypeManager.java | AbstractContentTypeManager.addContentType | protected void addContentType(ContentType contentType) throws DuplicateObjectException {
"""
This method registers the given {@code contentType} in this {@link ContentTypeManager}.
@see #getContentType(String)
@param contentType is the {@link ContentType} to add.
@throws DuplicateObjectException if a {@link ContentType} with the same {@link ContentType#getId() ID} has already
been registered.
"""
String id = contentType.getId();
if (this.id2contentTypeMap.containsKey(id)) {
throw new DuplicateObjectException(contentType, id);
}
this.id2contentTypeMap.put(id, contentType);
} | java | protected void addContentType(ContentType contentType) throws DuplicateObjectException {
String id = contentType.getId();
if (this.id2contentTypeMap.containsKey(id)) {
throw new DuplicateObjectException(contentType, id);
}
this.id2contentTypeMap.put(id, contentType);
} | [
"protected",
"void",
"addContentType",
"(",
"ContentType",
"contentType",
")",
"throws",
"DuplicateObjectException",
"{",
"String",
"id",
"=",
"contentType",
".",
"getId",
"(",
")",
";",
"if",
"(",
"this",
".",
"id2contentTypeMap",
".",
"containsKey",
"(",
"id",
")",
")",
"{",
"throw",
"new",
"DuplicateObjectException",
"(",
"contentType",
",",
"id",
")",
";",
"}",
"this",
".",
"id2contentTypeMap",
".",
"put",
"(",
"id",
",",
"contentType",
")",
";",
"}"
] | This method registers the given {@code contentType} in this {@link ContentTypeManager}.
@see #getContentType(String)
@param contentType is the {@link ContentType} to add.
@throws DuplicateObjectException if a {@link ContentType} with the same {@link ContentType#getId() ID} has already
been registered. | [
"This",
"method",
"registers",
"the",
"given",
"{",
"@code",
"contentType",
"}",
"in",
"this",
"{",
"@link",
"ContentTypeManager",
"}",
"."
] | train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/contenttype/src/main/java/net/sf/mmm/util/contenttype/base/AbstractContentTypeManager.java#L46-L53 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.