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
|
---|---|---|---|---|---|---|---|---|---|---|
JOML-CI/JOML | src/org/joml/Vector4i.java | Vector4i.set | public Vector4i set(int index, ByteBuffer buffer) {
"""
Read this vector from the supplied {@link ByteBuffer} starting at the
specified absolute buffer position/index.
<p>
This method will not increment the position of the given ByteBuffer.
@param index
the absolute position into the ByteBuffer
@param buffer
values will be read in <code>x, y, z, w</code> order
@return this
"""
MemUtil.INSTANCE.get(this, index, buffer);
return this;
} | java | public Vector4i set(int index, ByteBuffer buffer) {
MemUtil.INSTANCE.get(this, index, buffer);
return this;
} | [
"public",
"Vector4i",
"set",
"(",
"int",
"index",
",",
"ByteBuffer",
"buffer",
")",
"{",
"MemUtil",
".",
"INSTANCE",
".",
"get",
"(",
"this",
",",
"index",
",",
"buffer",
")",
";",
"return",
"this",
";",
"}"
] | Read this vector from the supplied {@link ByteBuffer} starting at the
specified absolute buffer position/index.
<p>
This method will not increment the position of the given ByteBuffer.
@param index
the absolute position into the ByteBuffer
@param buffer
values will be read in <code>x, y, z, w</code> order
@return this | [
"Read",
"this",
"vector",
"from",
"the",
"supplied",
"{",
"@link",
"ByteBuffer",
"}",
"starting",
"at",
"the",
"specified",
"absolute",
"buffer",
"position",
"/",
"index",
".",
"<p",
">",
"This",
"method",
"will",
"not",
"increment",
"the",
"position",
"of",
"the",
"given",
"ByteBuffer",
"."
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Vector4i.java#L375-L378 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/search/bingimagesearch/src/main/java/com/microsoft/azure/cognitiveservices/search/imagesearch/implementation/BingImagesImpl.java | BingImagesImpl.searchWithServiceResponseAsync | public Observable<ServiceResponse<ImagesModel>> searchWithServiceResponseAsync(String query, SearchOptionalParameter searchOptionalParameter) {
"""
The Image Search API lets you send a search query to Bing and get back a list of relevant images. This section provides technical details about the query parameters and headers that you use to request images and the JSON response objects that contain them. For examples that show how to make requests, see [Searching the Web for Images](https://docs.microsoft.com/azure/cognitive-services/bing-image-search/search-the-web).
@param query The user's search query term. The term cannot be empty. The term may contain [Bing Advanced Operators](http://msdn.microsoft.com/library/ff795620.aspx). For example, to limit images to a specific domain, use the [site:](http://msdn.microsoft.com/library/ff795613.aspx) operator. To help improve relevance of an insights query (see [insightsToken](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#insightstoken)), you should always include the user's query term. Use this parameter only with the Image Search API.Do not specify this parameter when calling the Trending Images API.
@param searchOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ImagesModel object
"""
if (query == null) {
throw new IllegalArgumentException("Parameter query is required and cannot be null.");
}
final String acceptLanguage = searchOptionalParameter != null ? searchOptionalParameter.acceptLanguage() : null;
final String userAgent = searchOptionalParameter != null ? searchOptionalParameter.userAgent() : this.client.userAgent();
final String clientId = searchOptionalParameter != null ? searchOptionalParameter.clientId() : null;
final String clientIp = searchOptionalParameter != null ? searchOptionalParameter.clientIp() : null;
final String location = searchOptionalParameter != null ? searchOptionalParameter.location() : null;
final ImageAspect aspect = searchOptionalParameter != null ? searchOptionalParameter.aspect() : null;
final ImageColor color = searchOptionalParameter != null ? searchOptionalParameter.color() : null;
final String countryCode = searchOptionalParameter != null ? searchOptionalParameter.countryCode() : null;
final Integer count = searchOptionalParameter != null ? searchOptionalParameter.count() : null;
final Freshness freshness = searchOptionalParameter != null ? searchOptionalParameter.freshness() : null;
final Integer height = searchOptionalParameter != null ? searchOptionalParameter.height() : null;
final String id = searchOptionalParameter != null ? searchOptionalParameter.id() : null;
final ImageContent imageContent = searchOptionalParameter != null ? searchOptionalParameter.imageContent() : null;
final ImageType imageType = searchOptionalParameter != null ? searchOptionalParameter.imageType() : null;
final ImageLicense license = searchOptionalParameter != null ? searchOptionalParameter.license() : null;
final String market = searchOptionalParameter != null ? searchOptionalParameter.market() : null;
final Long maxFileSize = searchOptionalParameter != null ? searchOptionalParameter.maxFileSize() : null;
final Long maxHeight = searchOptionalParameter != null ? searchOptionalParameter.maxHeight() : null;
final Long maxWidth = searchOptionalParameter != null ? searchOptionalParameter.maxWidth() : null;
final Long minFileSize = searchOptionalParameter != null ? searchOptionalParameter.minFileSize() : null;
final Long minHeight = searchOptionalParameter != null ? searchOptionalParameter.minHeight() : null;
final Long minWidth = searchOptionalParameter != null ? searchOptionalParameter.minWidth() : null;
final Long offset = searchOptionalParameter != null ? searchOptionalParameter.offset() : null;
final SafeSearch safeSearch = searchOptionalParameter != null ? searchOptionalParameter.safeSearch() : null;
final ImageSize size = searchOptionalParameter != null ? searchOptionalParameter.size() : null;
final String setLang = searchOptionalParameter != null ? searchOptionalParameter.setLang() : null;
final Integer width = searchOptionalParameter != null ? searchOptionalParameter.width() : null;
return searchWithServiceResponseAsync(query, acceptLanguage, userAgent, clientId, clientIp, location, aspect, color, countryCode, count, freshness, height, id, imageContent, imageType, license, market, maxFileSize, maxHeight, maxWidth, minFileSize, minHeight, minWidth, offset, safeSearch, size, setLang, width);
} | java | public Observable<ServiceResponse<ImagesModel>> searchWithServiceResponseAsync(String query, SearchOptionalParameter searchOptionalParameter) {
if (query == null) {
throw new IllegalArgumentException("Parameter query is required and cannot be null.");
}
final String acceptLanguage = searchOptionalParameter != null ? searchOptionalParameter.acceptLanguage() : null;
final String userAgent = searchOptionalParameter != null ? searchOptionalParameter.userAgent() : this.client.userAgent();
final String clientId = searchOptionalParameter != null ? searchOptionalParameter.clientId() : null;
final String clientIp = searchOptionalParameter != null ? searchOptionalParameter.clientIp() : null;
final String location = searchOptionalParameter != null ? searchOptionalParameter.location() : null;
final ImageAspect aspect = searchOptionalParameter != null ? searchOptionalParameter.aspect() : null;
final ImageColor color = searchOptionalParameter != null ? searchOptionalParameter.color() : null;
final String countryCode = searchOptionalParameter != null ? searchOptionalParameter.countryCode() : null;
final Integer count = searchOptionalParameter != null ? searchOptionalParameter.count() : null;
final Freshness freshness = searchOptionalParameter != null ? searchOptionalParameter.freshness() : null;
final Integer height = searchOptionalParameter != null ? searchOptionalParameter.height() : null;
final String id = searchOptionalParameter != null ? searchOptionalParameter.id() : null;
final ImageContent imageContent = searchOptionalParameter != null ? searchOptionalParameter.imageContent() : null;
final ImageType imageType = searchOptionalParameter != null ? searchOptionalParameter.imageType() : null;
final ImageLicense license = searchOptionalParameter != null ? searchOptionalParameter.license() : null;
final String market = searchOptionalParameter != null ? searchOptionalParameter.market() : null;
final Long maxFileSize = searchOptionalParameter != null ? searchOptionalParameter.maxFileSize() : null;
final Long maxHeight = searchOptionalParameter != null ? searchOptionalParameter.maxHeight() : null;
final Long maxWidth = searchOptionalParameter != null ? searchOptionalParameter.maxWidth() : null;
final Long minFileSize = searchOptionalParameter != null ? searchOptionalParameter.minFileSize() : null;
final Long minHeight = searchOptionalParameter != null ? searchOptionalParameter.minHeight() : null;
final Long minWidth = searchOptionalParameter != null ? searchOptionalParameter.minWidth() : null;
final Long offset = searchOptionalParameter != null ? searchOptionalParameter.offset() : null;
final SafeSearch safeSearch = searchOptionalParameter != null ? searchOptionalParameter.safeSearch() : null;
final ImageSize size = searchOptionalParameter != null ? searchOptionalParameter.size() : null;
final String setLang = searchOptionalParameter != null ? searchOptionalParameter.setLang() : null;
final Integer width = searchOptionalParameter != null ? searchOptionalParameter.width() : null;
return searchWithServiceResponseAsync(query, acceptLanguage, userAgent, clientId, clientIp, location, aspect, color, countryCode, count, freshness, height, id, imageContent, imageType, license, market, maxFileSize, maxHeight, maxWidth, minFileSize, minHeight, minWidth, offset, safeSearch, size, setLang, width);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"ImagesModel",
">",
">",
"searchWithServiceResponseAsync",
"(",
"String",
"query",
",",
"SearchOptionalParameter",
"searchOptionalParameter",
")",
"{",
"if",
"(",
"query",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter query is required and cannot be null.\"",
")",
";",
"}",
"final",
"String",
"acceptLanguage",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"acceptLanguage",
"(",
")",
":",
"null",
";",
"final",
"String",
"userAgent",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"userAgent",
"(",
")",
":",
"this",
".",
"client",
".",
"userAgent",
"(",
")",
";",
"final",
"String",
"clientId",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"clientId",
"(",
")",
":",
"null",
";",
"final",
"String",
"clientIp",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"clientIp",
"(",
")",
":",
"null",
";",
"final",
"String",
"location",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"location",
"(",
")",
":",
"null",
";",
"final",
"ImageAspect",
"aspect",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"aspect",
"(",
")",
":",
"null",
";",
"final",
"ImageColor",
"color",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"color",
"(",
")",
":",
"null",
";",
"final",
"String",
"countryCode",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"countryCode",
"(",
")",
":",
"null",
";",
"final",
"Integer",
"count",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"count",
"(",
")",
":",
"null",
";",
"final",
"Freshness",
"freshness",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"freshness",
"(",
")",
":",
"null",
";",
"final",
"Integer",
"height",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"height",
"(",
")",
":",
"null",
";",
"final",
"String",
"id",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"id",
"(",
")",
":",
"null",
";",
"final",
"ImageContent",
"imageContent",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"imageContent",
"(",
")",
":",
"null",
";",
"final",
"ImageType",
"imageType",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"imageType",
"(",
")",
":",
"null",
";",
"final",
"ImageLicense",
"license",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"license",
"(",
")",
":",
"null",
";",
"final",
"String",
"market",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"market",
"(",
")",
":",
"null",
";",
"final",
"Long",
"maxFileSize",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"maxFileSize",
"(",
")",
":",
"null",
";",
"final",
"Long",
"maxHeight",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"maxHeight",
"(",
")",
":",
"null",
";",
"final",
"Long",
"maxWidth",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"maxWidth",
"(",
")",
":",
"null",
";",
"final",
"Long",
"minFileSize",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"minFileSize",
"(",
")",
":",
"null",
";",
"final",
"Long",
"minHeight",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"minHeight",
"(",
")",
":",
"null",
";",
"final",
"Long",
"minWidth",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"minWidth",
"(",
")",
":",
"null",
";",
"final",
"Long",
"offset",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"offset",
"(",
")",
":",
"null",
";",
"final",
"SafeSearch",
"safeSearch",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"safeSearch",
"(",
")",
":",
"null",
";",
"final",
"ImageSize",
"size",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"size",
"(",
")",
":",
"null",
";",
"final",
"String",
"setLang",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"setLang",
"(",
")",
":",
"null",
";",
"final",
"Integer",
"width",
"=",
"searchOptionalParameter",
"!=",
"null",
"?",
"searchOptionalParameter",
".",
"width",
"(",
")",
":",
"null",
";",
"return",
"searchWithServiceResponseAsync",
"(",
"query",
",",
"acceptLanguage",
",",
"userAgent",
",",
"clientId",
",",
"clientIp",
",",
"location",
",",
"aspect",
",",
"color",
",",
"countryCode",
",",
"count",
",",
"freshness",
",",
"height",
",",
"id",
",",
"imageContent",
",",
"imageType",
",",
"license",
",",
"market",
",",
"maxFileSize",
",",
"maxHeight",
",",
"maxWidth",
",",
"minFileSize",
",",
"minHeight",
",",
"minWidth",
",",
"offset",
",",
"safeSearch",
",",
"size",
",",
"setLang",
",",
"width",
")",
";",
"}"
] | The Image Search API lets you send a search query to Bing and get back a list of relevant images. This section provides technical details about the query parameters and headers that you use to request images and the JSON response objects that contain them. For examples that show how to make requests, see [Searching the Web for Images](https://docs.microsoft.com/azure/cognitive-services/bing-image-search/search-the-web).
@param query The user's search query term. The term cannot be empty. The term may contain [Bing Advanced Operators](http://msdn.microsoft.com/library/ff795620.aspx). For example, to limit images to a specific domain, use the [site:](http://msdn.microsoft.com/library/ff795613.aspx) operator. To help improve relevance of an insights query (see [insightsToken](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#insightstoken)), you should always include the user's query term. Use this parameter only with the Image Search API.Do not specify this parameter when calling the Trending Images API.
@param searchOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ImagesModel object | [
"The",
"Image",
"Search",
"API",
"lets",
"you",
"send",
"a",
"search",
"query",
"to",
"Bing",
"and",
"get",
"back",
"a",
"list",
"of",
"relevant",
"images",
".",
"This",
"section",
"provides",
"technical",
"details",
"about",
"the",
"query",
"parameters",
"and",
"headers",
"that",
"you",
"use",
"to",
"request",
"images",
"and",
"the",
"JSON",
"response",
"objects",
"that",
"contain",
"them",
".",
"For",
"examples",
"that",
"show",
"how",
"to",
"make",
"requests",
"see",
"[",
"Searching",
"the",
"Web",
"for",
"Images",
"]",
"(",
"https",
":",
"//",
"docs",
".",
"microsoft",
".",
"com",
"/",
"azure",
"/",
"cognitive",
"-",
"services",
"/",
"bing",
"-",
"image",
"-",
"search",
"/",
"search",
"-",
"the",
"-",
"web",
")",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/search/bingimagesearch/src/main/java/com/microsoft/azure/cognitiveservices/search/imagesearch/implementation/BingImagesImpl.java#L140-L173 |
tvesalainen/util | vfs/src/main/java/org/vesalainen/vfs/VirtualFileSystems.java | VirtualFileSystems.newFileSystem | public static final FileSystem newFileSystem(Path path, Map<String,?> env) throws IOException {
"""
Constructs a new FileSystem to access the contents of a file as a file system.
@param path
@param env
@return
@throws IOException
"""
return getDefault().provider().newFileSystem(path, env);
} | java | public static final FileSystem newFileSystem(Path path, Map<String,?> env) throws IOException
{
return getDefault().provider().newFileSystem(path, env);
} | [
"public",
"static",
"final",
"FileSystem",
"newFileSystem",
"(",
"Path",
"path",
",",
"Map",
"<",
"String",
",",
"?",
">",
"env",
")",
"throws",
"IOException",
"{",
"return",
"getDefault",
"(",
")",
".",
"provider",
"(",
")",
".",
"newFileSystem",
"(",
"path",
",",
"env",
")",
";",
"}"
] | Constructs a new FileSystem to access the contents of a file as a file system.
@param path
@param env
@return
@throws IOException | [
"Constructs",
"a",
"new",
"FileSystem",
"to",
"access",
"the",
"contents",
"of",
"a",
"file",
"as",
"a",
"file",
"system",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/vfs/src/main/java/org/vesalainen/vfs/VirtualFileSystems.java#L47-L50 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.broadcastTransaction | public TransactionBroadcast broadcastTransaction(final Transaction tx, final int minConnections) {
"""
<p>Given a transaction, sends it un-announced to one peer and then waits for it to be received back from other
peers. Once all connected peers have announced the transaction, the future available via the
{@link TransactionBroadcast#future()} method will be completed. If anything goes
wrong the exception will be thrown when get() is called, or you can receive it via a callback on the
{@link ListenableFuture}. This method returns immediately, so if you want it to block just call get() on the
result.</p>
<p>Note that if the PeerGroup is limited to only one connection (discovery is not activated) then the future
will complete as soon as the transaction was successfully written to that peer.</p>
<p>The transaction won't be sent until there are at least minConnections active connections available.
A good choice for proportion would be between 0.5 and 0.8 but if you want faster transmission during initial
bringup of the peer group you can lower it.</p>
<p>The returned {@link TransactionBroadcast} object can be used to get progress feedback,
which is calculated by watching the transaction propagate across the network and be announced by peers.</p>
"""
// If we don't have a record of where this tx came from already, set it to be ourselves so Peer doesn't end up
// redownloading it from the network redundantly.
if (tx.getConfidence().getSource().equals(TransactionConfidence.Source.UNKNOWN)) {
log.info("Transaction source unknown, setting to SELF: {}", tx.getTxId());
tx.getConfidence().setSource(TransactionConfidence.Source.SELF);
}
final TransactionBroadcast broadcast = new TransactionBroadcast(this, tx);
broadcast.setMinConnections(minConnections);
// Send the TX to the wallet once we have a successful broadcast.
Futures.addCallback(broadcast.future(), new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction transaction) {
runningBroadcasts.remove(broadcast);
// OK, now tell the wallet about the transaction. If the wallet created the transaction then
// it already knows and will ignore this. If it's a transaction we received from
// somebody else via a side channel and are now broadcasting, this will put it into the
// wallet now we know it's valid.
for (Wallet wallet : wallets) {
// Assumption here is there are no dependencies of the created transaction.
//
// We may end up with two threads trying to do this in parallel - the wallet will
// ignore whichever one loses the race.
try {
wallet.receivePending(transaction, null);
} catch (VerificationException e) {
throw new RuntimeException(e); // Cannot fail to verify a tx we created ourselves.
}
}
}
@Override
public void onFailure(Throwable throwable) {
// This can happen if we get a reject message from a peer.
runningBroadcasts.remove(broadcast);
}
}, MoreExecutors.directExecutor());
// Keep a reference to the TransactionBroadcast object. This is important because otherwise, the entire tree
// of objects we just created would become garbage if the user doesn't hold on to the returned future, and
// eventually be collected. This in turn could result in the transaction not being committed to the wallet
// at all.
runningBroadcasts.add(broadcast);
broadcast.broadcast();
return broadcast;
} | java | public TransactionBroadcast broadcastTransaction(final Transaction tx, final int minConnections) {
// If we don't have a record of where this tx came from already, set it to be ourselves so Peer doesn't end up
// redownloading it from the network redundantly.
if (tx.getConfidence().getSource().equals(TransactionConfidence.Source.UNKNOWN)) {
log.info("Transaction source unknown, setting to SELF: {}", tx.getTxId());
tx.getConfidence().setSource(TransactionConfidence.Source.SELF);
}
final TransactionBroadcast broadcast = new TransactionBroadcast(this, tx);
broadcast.setMinConnections(minConnections);
// Send the TX to the wallet once we have a successful broadcast.
Futures.addCallback(broadcast.future(), new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction transaction) {
runningBroadcasts.remove(broadcast);
// OK, now tell the wallet about the transaction. If the wallet created the transaction then
// it already knows and will ignore this. If it's a transaction we received from
// somebody else via a side channel and are now broadcasting, this will put it into the
// wallet now we know it's valid.
for (Wallet wallet : wallets) {
// Assumption here is there are no dependencies of the created transaction.
//
// We may end up with two threads trying to do this in parallel - the wallet will
// ignore whichever one loses the race.
try {
wallet.receivePending(transaction, null);
} catch (VerificationException e) {
throw new RuntimeException(e); // Cannot fail to verify a tx we created ourselves.
}
}
}
@Override
public void onFailure(Throwable throwable) {
// This can happen if we get a reject message from a peer.
runningBroadcasts.remove(broadcast);
}
}, MoreExecutors.directExecutor());
// Keep a reference to the TransactionBroadcast object. This is important because otherwise, the entire tree
// of objects we just created would become garbage if the user doesn't hold on to the returned future, and
// eventually be collected. This in turn could result in the transaction not being committed to the wallet
// at all.
runningBroadcasts.add(broadcast);
broadcast.broadcast();
return broadcast;
} | [
"public",
"TransactionBroadcast",
"broadcastTransaction",
"(",
"final",
"Transaction",
"tx",
",",
"final",
"int",
"minConnections",
")",
"{",
"// If we don't have a record of where this tx came from already, set it to be ourselves so Peer doesn't end up",
"// redownloading it from the network redundantly.",
"if",
"(",
"tx",
".",
"getConfidence",
"(",
")",
".",
"getSource",
"(",
")",
".",
"equals",
"(",
"TransactionConfidence",
".",
"Source",
".",
"UNKNOWN",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Transaction source unknown, setting to SELF: {}\"",
",",
"tx",
".",
"getTxId",
"(",
")",
")",
";",
"tx",
".",
"getConfidence",
"(",
")",
".",
"setSource",
"(",
"TransactionConfidence",
".",
"Source",
".",
"SELF",
")",
";",
"}",
"final",
"TransactionBroadcast",
"broadcast",
"=",
"new",
"TransactionBroadcast",
"(",
"this",
",",
"tx",
")",
";",
"broadcast",
".",
"setMinConnections",
"(",
"minConnections",
")",
";",
"// Send the TX to the wallet once we have a successful broadcast.",
"Futures",
".",
"addCallback",
"(",
"broadcast",
".",
"future",
"(",
")",
",",
"new",
"FutureCallback",
"<",
"Transaction",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onSuccess",
"(",
"Transaction",
"transaction",
")",
"{",
"runningBroadcasts",
".",
"remove",
"(",
"broadcast",
")",
";",
"// OK, now tell the wallet about the transaction. If the wallet created the transaction then",
"// it already knows and will ignore this. If it's a transaction we received from",
"// somebody else via a side channel and are now broadcasting, this will put it into the",
"// wallet now we know it's valid.",
"for",
"(",
"Wallet",
"wallet",
":",
"wallets",
")",
"{",
"// Assumption here is there are no dependencies of the created transaction.",
"//",
"// We may end up with two threads trying to do this in parallel - the wallet will",
"// ignore whichever one loses the race.",
"try",
"{",
"wallet",
".",
"receivePending",
"(",
"transaction",
",",
"null",
")",
";",
"}",
"catch",
"(",
"VerificationException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"// Cannot fail to verify a tx we created ourselves.",
"}",
"}",
"}",
"@",
"Override",
"public",
"void",
"onFailure",
"(",
"Throwable",
"throwable",
")",
"{",
"// This can happen if we get a reject message from a peer.",
"runningBroadcasts",
".",
"remove",
"(",
"broadcast",
")",
";",
"}",
"}",
",",
"MoreExecutors",
".",
"directExecutor",
"(",
")",
")",
";",
"// Keep a reference to the TransactionBroadcast object. This is important because otherwise, the entire tree",
"// of objects we just created would become garbage if the user doesn't hold on to the returned future, and",
"// eventually be collected. This in turn could result in the transaction not being committed to the wallet",
"// at all.",
"runningBroadcasts",
".",
"add",
"(",
"broadcast",
")",
";",
"broadcast",
".",
"broadcast",
"(",
")",
";",
"return",
"broadcast",
";",
"}"
] | <p>Given a transaction, sends it un-announced to one peer and then waits for it to be received back from other
peers. Once all connected peers have announced the transaction, the future available via the
{@link TransactionBroadcast#future()} method will be completed. If anything goes
wrong the exception will be thrown when get() is called, or you can receive it via a callback on the
{@link ListenableFuture}. This method returns immediately, so if you want it to block just call get() on the
result.</p>
<p>Note that if the PeerGroup is limited to only one connection (discovery is not activated) then the future
will complete as soon as the transaction was successfully written to that peer.</p>
<p>The transaction won't be sent until there are at least minConnections active connections available.
A good choice for proportion would be between 0.5 and 0.8 but if you want faster transmission during initial
bringup of the peer group you can lower it.</p>
<p>The returned {@link TransactionBroadcast} object can be used to get progress feedback,
which is calculated by watching the transaction propagate across the network and be announced by peers.</p> | [
"<p",
">",
"Given",
"a",
"transaction",
"sends",
"it",
"un",
"-",
"announced",
"to",
"one",
"peer",
"and",
"then",
"waits",
"for",
"it",
"to",
"be",
"received",
"back",
"from",
"other",
"peers",
".",
"Once",
"all",
"connected",
"peers",
"have",
"announced",
"the",
"transaction",
"the",
"future",
"available",
"via",
"the",
"{",
"@link",
"TransactionBroadcast#future",
"()",
"}",
"method",
"will",
"be",
"completed",
".",
"If",
"anything",
"goes",
"wrong",
"the",
"exception",
"will",
"be",
"thrown",
"when",
"get",
"()",
"is",
"called",
"or",
"you",
"can",
"receive",
"it",
"via",
"a",
"callback",
"on",
"the",
"{",
"@link",
"ListenableFuture",
"}",
".",
"This",
"method",
"returns",
"immediately",
"so",
"if",
"you",
"want",
"it",
"to",
"block",
"just",
"call",
"get",
"()",
"on",
"the",
"result",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L2042-L2086 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScannerSet.java | DataBlockScannerSet.verifiedByClient | synchronized void verifiedByClient(int namespaceId, Block block) {
"""
/*
A reader will try to indicate a block is verified and will add blocks to
the DataBlockScannerSet before they are finished (due to concurrent
readers).
fixed so a read verification can't add the block
"""
DataBlockScanner nsScanner = getNSScanner(namespaceId);
if (nsScanner != null) {
nsScanner.updateScanStatusUpdateOnly(block,
DataBlockScanner.ScanType.REMOTE_READ, true);
} else {
LOG.warn("No namespace scanner found for namespaceId: " + nsScanner);
}
} | java | synchronized void verifiedByClient(int namespaceId, Block block) {
DataBlockScanner nsScanner = getNSScanner(namespaceId);
if (nsScanner != null) {
nsScanner.updateScanStatusUpdateOnly(block,
DataBlockScanner.ScanType.REMOTE_READ, true);
} else {
LOG.warn("No namespace scanner found for namespaceId: " + nsScanner);
}
} | [
"synchronized",
"void",
"verifiedByClient",
"(",
"int",
"namespaceId",
",",
"Block",
"block",
")",
"{",
"DataBlockScanner",
"nsScanner",
"=",
"getNSScanner",
"(",
"namespaceId",
")",
";",
"if",
"(",
"nsScanner",
"!=",
"null",
")",
"{",
"nsScanner",
".",
"updateScanStatusUpdateOnly",
"(",
"block",
",",
"DataBlockScanner",
".",
"ScanType",
".",
"REMOTE_READ",
",",
"true",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"warn",
"(",
"\"No namespace scanner found for namespaceId: \"",
"+",
"nsScanner",
")",
";",
"}",
"}"
] | /*
A reader will try to indicate a block is verified and will add blocks to
the DataBlockScannerSet before they are finished (due to concurrent
readers).
fixed so a read verification can't add the block | [
"/",
"*",
"A",
"reader",
"will",
"try",
"to",
"indicate",
"a",
"block",
"is",
"verified",
"and",
"will",
"add",
"blocks",
"to",
"the",
"DataBlockScannerSet",
"before",
"they",
"are",
"finished",
"(",
"due",
"to",
"concurrent",
"readers",
")",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScannerSet.java#L371-L379 |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/AbstractDb.java | AbstractDb.execute | public int execute(String sql, Object... params) throws SQLException {
"""
执行非查询语句<br>
语句包括 插入、更新、删除
@param sql SQL
@param params 参数
@return 影响行数
@throws SQLException SQL执行异常
"""
Connection conn = null;
try {
conn = this.getConnection();
return SqlExecutor.execute(conn, sql, params);
} catch (SQLException e) {
throw e;
} finally {
this.closeConnection(conn);
}
} | java | public int execute(String sql, Object... params) throws SQLException {
Connection conn = null;
try {
conn = this.getConnection();
return SqlExecutor.execute(conn, sql, params);
} catch (SQLException e) {
throw e;
} finally {
this.closeConnection(conn);
}
} | [
"public",
"int",
"execute",
"(",
"String",
"sql",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
"{",
"Connection",
"conn",
"=",
"null",
";",
"try",
"{",
"conn",
"=",
"this",
".",
"getConnection",
"(",
")",
";",
"return",
"SqlExecutor",
".",
"execute",
"(",
"conn",
",",
"sql",
",",
"params",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"finally",
"{",
"this",
".",
"closeConnection",
"(",
"conn",
")",
";",
"}",
"}"
] | 执行非查询语句<br>
语句包括 插入、更新、删除
@param sql SQL
@param params 参数
@return 影响行数
@throws SQLException SQL执行异常 | [
"执行非查询语句<br",
">",
"语句包括",
"插入、更新、删除"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java#L165-L175 |
jnidzwetzki/bitfinex-v2-wss-api-java | src/main/java/com/github/jnidzwetzki/bitfinex/v2/SimpleBitfinexApiBroker.java | SimpleBitfinexApiBroker.authenticateAndWait | private void authenticateAndWait(final CountDownLatch latch) throws InterruptedException, BitfinexClientException {
"""
Execute the authentication and wait until the socket is ready
@throws InterruptedException
@throws BitfinexClientException
"""
if (authenticated) {
return;
}
sendCommand(new AuthCommand(configuration.getAuthNonceProducer()));
logger.debug("Waiting for connection ready events");
latch.await(10, TimeUnit.SECONDS);
if (!authenticated) {
throw new BitfinexClientException("Unable to perform authentication, permissions are: " + permissions);
}
} | java | private void authenticateAndWait(final CountDownLatch latch) throws InterruptedException, BitfinexClientException {
if (authenticated) {
return;
}
sendCommand(new AuthCommand(configuration.getAuthNonceProducer()));
logger.debug("Waiting for connection ready events");
latch.await(10, TimeUnit.SECONDS);
if (!authenticated) {
throw new BitfinexClientException("Unable to perform authentication, permissions are: " + permissions);
}
} | [
"private",
"void",
"authenticateAndWait",
"(",
"final",
"CountDownLatch",
"latch",
")",
"throws",
"InterruptedException",
",",
"BitfinexClientException",
"{",
"if",
"(",
"authenticated",
")",
"{",
"return",
";",
"}",
"sendCommand",
"(",
"new",
"AuthCommand",
"(",
"configuration",
".",
"getAuthNonceProducer",
"(",
")",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Waiting for connection ready events\"",
")",
";",
"latch",
".",
"await",
"(",
"10",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"if",
"(",
"!",
"authenticated",
")",
"{",
"throw",
"new",
"BitfinexClientException",
"(",
"\"Unable to perform authentication, permissions are: \"",
"+",
"permissions",
")",
";",
"}",
"}"
] | Execute the authentication and wait until the socket is ready
@throws InterruptedException
@throws BitfinexClientException | [
"Execute",
"the",
"authentication",
"and",
"wait",
"until",
"the",
"socket",
"is",
"ready"
] | train | https://github.com/jnidzwetzki/bitfinex-v2-wss-api-java/blob/2e6adf1eb6f8cd4c8722f1619f78ab2cc3c600ee/src/main/java/com/github/jnidzwetzki/bitfinex/v2/SimpleBitfinexApiBroker.java#L502-L513 |
danieldk/conllx-io | src/main/java/eu/danieldk/nlp/conllx/reader/CONLLReader.java | CONLLReader.constructSentence | private Sentence constructSentence(List<Token> tokens) throws IOException {
"""
Construct a sentence. If strictness is used and invariants do not hold, convert
the exception to an IOException.
"""
Sentence sentence;
try {
sentence = new SimpleSentence(tokens, strict);
} catch (IllegalArgumentException e) {
throw new IOException(e.getMessage());
}
return sentence;
} | java | private Sentence constructSentence(List<Token> tokens) throws IOException {
Sentence sentence;
try {
sentence = new SimpleSentence(tokens, strict);
} catch (IllegalArgumentException e) {
throw new IOException(e.getMessage());
}
return sentence;
} | [
"private",
"Sentence",
"constructSentence",
"(",
"List",
"<",
"Token",
">",
"tokens",
")",
"throws",
"IOException",
"{",
"Sentence",
"sentence",
";",
"try",
"{",
"sentence",
"=",
"new",
"SimpleSentence",
"(",
"tokens",
",",
"strict",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"sentence",
";",
"}"
] | Construct a sentence. If strictness is used and invariants do not hold, convert
the exception to an IOException. | [
"Construct",
"a",
"sentence",
".",
"If",
"strictness",
"is",
"used",
"and",
"invariants",
"do",
"not",
"hold",
"convert",
"the",
"exception",
"to",
"an",
"IOException",
"."
] | train | https://github.com/danieldk/conllx-io/blob/c1e6028bc3394f000b1efe231ae7e7f625e10d64/src/main/java/eu/danieldk/nlp/conllx/reader/CONLLReader.java#L115-L123 |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.pushProfile | @SuppressWarnings( {
"""
Push a profile update.
@param profile A {@link Map}, with keys as strings, and values as {@link String},
{@link Integer}, {@link Long}, {@link Boolean}, {@link Float}, {@link Double},
{@link java.util.Date}, or {@link Character}
""""unused", "WeakerAccess"})
public void pushProfile(final Map<String, Object> profile) {
if (profile == null || profile.isEmpty())
return;
postAsyncSafely("profilePush", new Runnable() {
@Override
public void run() {
_push(profile);
}
});
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public void pushProfile(final Map<String, Object> profile) {
if (profile == null || profile.isEmpty())
return;
postAsyncSafely("profilePush", new Runnable() {
@Override
public void run() {
_push(profile);
}
});
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"void",
"pushProfile",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"profile",
")",
"{",
"if",
"(",
"profile",
"==",
"null",
"||",
"profile",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"postAsyncSafely",
"(",
"\"profilePush\"",
",",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"_push",
"(",
"profile",
")",
";",
"}",
"}",
")",
";",
"}"
] | Push a profile update.
@param profile A {@link Map}, with keys as strings, and values as {@link String},
{@link Integer}, {@link Long}, {@link Boolean}, {@link Float}, {@link Double},
{@link java.util.Date}, or {@link Character} | [
"Push",
"a",
"profile",
"update",
"."
] | train | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L3130-L3141 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/dictionary/CustomDictionary.java | CustomDictionary.parseText | public static void parseText(String text, AhoCorasickDoubleArrayTrie.IHit<CoreDictionary.Attribute> processor) {
"""
解析一段文本(目前采用了BinTrie+DAT的混合储存形式,此方法可以统一两个数据结构)
@param text 文本
@param processor 处理器
"""
if (trie != null)
{
BaseSearcher searcher = CustomDictionary.getSearcher(text);
int offset;
Map.Entry<String, CoreDictionary.Attribute> entry;
while ((entry = searcher.next()) != null)
{
offset = searcher.getOffset();
processor.hit(offset, offset + entry.getKey().length(), entry.getValue());
}
}
DoubleArrayTrie<CoreDictionary.Attribute>.Searcher searcher = dat.getSearcher(text, 0);
while (searcher.next())
{
processor.hit(searcher.begin, searcher.begin + searcher.length, searcher.value);
}
} | java | public static void parseText(String text, AhoCorasickDoubleArrayTrie.IHit<CoreDictionary.Attribute> processor)
{
if (trie != null)
{
BaseSearcher searcher = CustomDictionary.getSearcher(text);
int offset;
Map.Entry<String, CoreDictionary.Attribute> entry;
while ((entry = searcher.next()) != null)
{
offset = searcher.getOffset();
processor.hit(offset, offset + entry.getKey().length(), entry.getValue());
}
}
DoubleArrayTrie<CoreDictionary.Attribute>.Searcher searcher = dat.getSearcher(text, 0);
while (searcher.next())
{
processor.hit(searcher.begin, searcher.begin + searcher.length, searcher.value);
}
} | [
"public",
"static",
"void",
"parseText",
"(",
"String",
"text",
",",
"AhoCorasickDoubleArrayTrie",
".",
"IHit",
"<",
"CoreDictionary",
".",
"Attribute",
">",
"processor",
")",
"{",
"if",
"(",
"trie",
"!=",
"null",
")",
"{",
"BaseSearcher",
"searcher",
"=",
"CustomDictionary",
".",
"getSearcher",
"(",
"text",
")",
";",
"int",
"offset",
";",
"Map",
".",
"Entry",
"<",
"String",
",",
"CoreDictionary",
".",
"Attribute",
">",
"entry",
";",
"while",
"(",
"(",
"entry",
"=",
"searcher",
".",
"next",
"(",
")",
")",
"!=",
"null",
")",
"{",
"offset",
"=",
"searcher",
".",
"getOffset",
"(",
")",
";",
"processor",
".",
"hit",
"(",
"offset",
",",
"offset",
"+",
"entry",
".",
"getKey",
"(",
")",
".",
"length",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"DoubleArrayTrie",
"<",
"CoreDictionary",
".",
"Attribute",
">",
".",
"Searcher",
"searcher",
"=",
"dat",
".",
"getSearcher",
"(",
"text",
",",
"0",
")",
";",
"while",
"(",
"searcher",
".",
"next",
"(",
")",
")",
"{",
"processor",
".",
"hit",
"(",
"searcher",
".",
"begin",
",",
"searcher",
".",
"begin",
"+",
"searcher",
".",
"length",
",",
"searcher",
".",
"value",
")",
";",
"}",
"}"
] | 解析一段文本(目前采用了BinTrie+DAT的混合储存形式,此方法可以统一两个数据结构)
@param text 文本
@param processor 处理器 | [
"解析一段文本(目前采用了BinTrie",
"+",
"DAT的混合储存形式,此方法可以统一两个数据结构)"
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/dictionary/CustomDictionary.java#L578-L596 |
sdl/odata | odata_client/src/main/java/com/sdl/odata/client/marshall/AtomEntityUnmarshaller.java | AtomEntityUnmarshaller.atomUnmarshall | public Object atomUnmarshall(String oDataEntityXml, String fullResponse, ODataClientQuery query)
throws UnsupportedEncodingException, ODataClientException {
"""
Unmarshalls an Atom XML form of on OData entity into the actual entity (DTO) object.
@param oDataEntityXml the Atom XML form of on OData entity
@return an entity (DTO) object
@throws java.io.UnsupportedEncodingException
@throws ODataClientException
"""
Object unmarshalledEntity;
// build a dummy request context which contains the Xml
ODataRequest request = buildODataRequestFromString(oDataEntityXml, query);
ODataRequestContext requestContext =
new ODataRequestContext(request, createODataUri(url, query.getEdmEntityName()), entityDataModel);
// unmarshall the OData request context into an entity
try {
unmarshalledEntity = getODataAtomParser(requestContext).getODataEntity();
} catch (ODataException | RuntimeException e) {
throw new ODataClientParserException(
format("Caught exception {0}: {1} when parsing response received from OData service",
e.getClass().getSimpleName(), e.getMessage()),
e, oDataEntityXml, fullResponse);
}
return unmarshalledEntity;
} | java | public Object atomUnmarshall(String oDataEntityXml, String fullResponse, ODataClientQuery query)
throws UnsupportedEncodingException, ODataClientException {
Object unmarshalledEntity;
// build a dummy request context which contains the Xml
ODataRequest request = buildODataRequestFromString(oDataEntityXml, query);
ODataRequestContext requestContext =
new ODataRequestContext(request, createODataUri(url, query.getEdmEntityName()), entityDataModel);
// unmarshall the OData request context into an entity
try {
unmarshalledEntity = getODataAtomParser(requestContext).getODataEntity();
} catch (ODataException | RuntimeException e) {
throw new ODataClientParserException(
format("Caught exception {0}: {1} when parsing response received from OData service",
e.getClass().getSimpleName(), e.getMessage()),
e, oDataEntityXml, fullResponse);
}
return unmarshalledEntity;
} | [
"public",
"Object",
"atomUnmarshall",
"(",
"String",
"oDataEntityXml",
",",
"String",
"fullResponse",
",",
"ODataClientQuery",
"query",
")",
"throws",
"UnsupportedEncodingException",
",",
"ODataClientException",
"{",
"Object",
"unmarshalledEntity",
";",
"// build a dummy request context which contains the Xml",
"ODataRequest",
"request",
"=",
"buildODataRequestFromString",
"(",
"oDataEntityXml",
",",
"query",
")",
";",
"ODataRequestContext",
"requestContext",
"=",
"new",
"ODataRequestContext",
"(",
"request",
",",
"createODataUri",
"(",
"url",
",",
"query",
".",
"getEdmEntityName",
"(",
")",
")",
",",
"entityDataModel",
")",
";",
"// unmarshall the OData request context into an entity",
"try",
"{",
"unmarshalledEntity",
"=",
"getODataAtomParser",
"(",
"requestContext",
")",
".",
"getODataEntity",
"(",
")",
";",
"}",
"catch",
"(",
"ODataException",
"|",
"RuntimeException",
"e",
")",
"{",
"throw",
"new",
"ODataClientParserException",
"(",
"format",
"(",
"\"Caught exception {0}: {1} when parsing response received from OData service\"",
",",
"e",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
",",
"e",
",",
"oDataEntityXml",
",",
"fullResponse",
")",
";",
"}",
"return",
"unmarshalledEntity",
";",
"}"
] | Unmarshalls an Atom XML form of on OData entity into the actual entity (DTO) object.
@param oDataEntityXml the Atom XML form of on OData entity
@return an entity (DTO) object
@throws java.io.UnsupportedEncodingException
@throws ODataClientException | [
"Unmarshalls",
"an",
"Atom",
"XML",
"form",
"of",
"on",
"OData",
"entity",
"into",
"the",
"actual",
"entity",
"(",
"DTO",
")",
"object",
"."
] | train | https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_client/src/main/java/com/sdl/odata/client/marshall/AtomEntityUnmarshaller.java#L147-L165 |
OpenLiberty/open-liberty | dev/com.ibm.ws.collector/src/com/ibm/ws/collector/Collector.java | Collector.configure | private void configure(Map<String, Object> configuration) throws IOException {
"""
/*
Process the configuration and create the relevant tasks
Target is also initialized using the information provided in the configuration
"""
List<TaskConfig> configList = new ArrayList<TaskConfig>();
configList.addAll(parseConfig(configuration));
for (TaskConfig taskConfig : configList) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Task config " + this, taskConfig);
}
if (taskConfig.getEnabled()) {
//Create the task, set the configuration and add it to the map if it's not already present.
Task task = new TaskImpl();
if (task != null) {
//Check if task already exist (by check if the source id is already in the taskMap)
//if not, we set the task with the new config and get appropriate handler based on the type of source
//else, we simply replace the config in the original task with the modified config
if (!taskMap.containsKey(taskConfig.sourceId())) {
task.setHandlerName(getHandlerName());
task.setConfig(taskConfig);
taskMap.putIfAbsent(taskConfig.sourceId(), task);
} else {
taskMap.get(taskConfig.sourceId()).setConfig(taskConfig);
}
}
}
}
} | java | private void configure(Map<String, Object> configuration) throws IOException {
List<TaskConfig> configList = new ArrayList<TaskConfig>();
configList.addAll(parseConfig(configuration));
for (TaskConfig taskConfig : configList) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Task config " + this, taskConfig);
}
if (taskConfig.getEnabled()) {
//Create the task, set the configuration and add it to the map if it's not already present.
Task task = new TaskImpl();
if (task != null) {
//Check if task already exist (by check if the source id is already in the taskMap)
//if not, we set the task with the new config and get appropriate handler based on the type of source
//else, we simply replace the config in the original task with the modified config
if (!taskMap.containsKey(taskConfig.sourceId())) {
task.setHandlerName(getHandlerName());
task.setConfig(taskConfig);
taskMap.putIfAbsent(taskConfig.sourceId(), task);
} else {
taskMap.get(taskConfig.sourceId()).setConfig(taskConfig);
}
}
}
}
} | [
"private",
"void",
"configure",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"configuration",
")",
"throws",
"IOException",
"{",
"List",
"<",
"TaskConfig",
">",
"configList",
"=",
"new",
"ArrayList",
"<",
"TaskConfig",
">",
"(",
")",
";",
"configList",
".",
"addAll",
"(",
"parseConfig",
"(",
"configuration",
")",
")",
";",
"for",
"(",
"TaskConfig",
"taskConfig",
":",
"configList",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Task config \"",
"+",
"this",
",",
"taskConfig",
")",
";",
"}",
"if",
"(",
"taskConfig",
".",
"getEnabled",
"(",
")",
")",
"{",
"//Create the task, set the configuration and add it to the map if it's not already present.",
"Task",
"task",
"=",
"new",
"TaskImpl",
"(",
")",
";",
"if",
"(",
"task",
"!=",
"null",
")",
"{",
"//Check if task already exist (by check if the source id is already in the taskMap)",
"//if not, we set the task with the new config and get appropriate handler based on the type of source",
"//else, we simply replace the config in the original task with the modified config",
"if",
"(",
"!",
"taskMap",
".",
"containsKey",
"(",
"taskConfig",
".",
"sourceId",
"(",
")",
")",
")",
"{",
"task",
".",
"setHandlerName",
"(",
"getHandlerName",
"(",
")",
")",
";",
"task",
".",
"setConfig",
"(",
"taskConfig",
")",
";",
"taskMap",
".",
"putIfAbsent",
"(",
"taskConfig",
".",
"sourceId",
"(",
")",
",",
"task",
")",
";",
"}",
"else",
"{",
"taskMap",
".",
"get",
"(",
"taskConfig",
".",
"sourceId",
"(",
")",
")",
".",
"setConfig",
"(",
"taskConfig",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | /*
Process the configuration and create the relevant tasks
Target is also initialized using the information provided in the configuration | [
"/",
"*",
"Process",
"the",
"configuration",
"and",
"create",
"the",
"relevant",
"tasks",
"Target",
"is",
"also",
"initialized",
"using",
"the",
"information",
"provided",
"in",
"the",
"configuration"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.collector/src/com/ibm/ws/collector/Collector.java#L178-L202 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/Scroller.java | Scroller.scrollToSide | @SuppressWarnings("deprecation")
public void scrollToSide(Side side, float scrollPosition, int stepCount) {
"""
Scrolls horizontally.
@param side the side to which to scroll; {@link Side#RIGHT} or {@link Side#LEFT}
@param scrollPosition the position to scroll to, from 0 to 1 where 1 is all the way. Example is: 0.55.
@param stepCount how many move steps to include in the scroll. Less steps results in a faster scroll
"""
WindowManager windowManager = (WindowManager)
inst.getTargetContext().getSystemService(Context.WINDOW_SERVICE);
int screenHeight = windowManager.getDefaultDisplay()
.getHeight();
int screenWidth = windowManager.getDefaultDisplay()
.getWidth();
float x = screenWidth * scrollPosition;
float y = screenHeight / 2.0f;
if (side == Side.LEFT)
drag(70, x, y, y, stepCount);
else if (side == Side.RIGHT)
drag(x, 0, y, y, stepCount);
} | java | @SuppressWarnings("deprecation")
public void scrollToSide(Side side, float scrollPosition, int stepCount) {
WindowManager windowManager = (WindowManager)
inst.getTargetContext().getSystemService(Context.WINDOW_SERVICE);
int screenHeight = windowManager.getDefaultDisplay()
.getHeight();
int screenWidth = windowManager.getDefaultDisplay()
.getWidth();
float x = screenWidth * scrollPosition;
float y = screenHeight / 2.0f;
if (side == Side.LEFT)
drag(70, x, y, y, stepCount);
else if (side == Side.RIGHT)
drag(x, 0, y, y, stepCount);
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"void",
"scrollToSide",
"(",
"Side",
"side",
",",
"float",
"scrollPosition",
",",
"int",
"stepCount",
")",
"{",
"WindowManager",
"windowManager",
"=",
"(",
"WindowManager",
")",
"inst",
".",
"getTargetContext",
"(",
")",
".",
"getSystemService",
"(",
"Context",
".",
"WINDOW_SERVICE",
")",
";",
"int",
"screenHeight",
"=",
"windowManager",
".",
"getDefaultDisplay",
"(",
")",
".",
"getHeight",
"(",
")",
";",
"int",
"screenWidth",
"=",
"windowManager",
".",
"getDefaultDisplay",
"(",
")",
".",
"getWidth",
"(",
")",
";",
"float",
"x",
"=",
"screenWidth",
"*",
"scrollPosition",
";",
"float",
"y",
"=",
"screenHeight",
"/",
"2.0f",
";",
"if",
"(",
"side",
"==",
"Side",
".",
"LEFT",
")",
"drag",
"(",
"70",
",",
"x",
",",
"y",
",",
"y",
",",
"stepCount",
")",
";",
"else",
"if",
"(",
"side",
"==",
"Side",
".",
"RIGHT",
")",
"drag",
"(",
"x",
",",
"0",
",",
"y",
",",
"y",
",",
"stepCount",
")",
";",
"}"
] | Scrolls horizontally.
@param side the side to which to scroll; {@link Side#RIGHT} or {@link Side#LEFT}
@param scrollPosition the position to scroll to, from 0 to 1 where 1 is all the way. Example is: 0.55.
@param stepCount how many move steps to include in the scroll. Less steps results in a faster scroll | [
"Scrolls",
"horizontally",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Scroller.java#L346-L361 |
mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/swing/TerminalEmulatorPalette.java | TerminalEmulatorPalette.get | public Color get(TextColor.ANSI color, boolean isForeground, boolean useBrightTones) {
"""
Returns the AWT color from this palette given an ANSI color and two hints for if we are looking for a background
color and if we want to use the bright version.
@param color Which ANSI color we want to extract
@param isForeground Is this color we extract going to be used as a background color?
@param useBrightTones If true, we should return the bright version of the color
@return AWT color extracted from this palette for the input parameters
"""
if(useBrightTones) {
switch(color) {
case BLACK:
return brightBlack;
case BLUE:
return brightBlue;
case CYAN:
return brightCyan;
case DEFAULT:
return isForeground ? defaultBrightColor : defaultBackgroundColor;
case GREEN:
return brightGreen;
case MAGENTA:
return brightMagenta;
case RED:
return brightRed;
case WHITE:
return brightWhite;
case YELLOW:
return brightYellow;
}
}
else {
switch(color) {
case BLACK:
return normalBlack;
case BLUE:
return normalBlue;
case CYAN:
return normalCyan;
case DEFAULT:
return isForeground ? defaultColor : defaultBackgroundColor;
case GREEN:
return normalGreen;
case MAGENTA:
return normalMagenta;
case RED:
return normalRed;
case WHITE:
return normalWhite;
case YELLOW:
return normalYellow;
}
}
throw new IllegalArgumentException("Unknown text color " + color);
} | java | public Color get(TextColor.ANSI color, boolean isForeground, boolean useBrightTones) {
if(useBrightTones) {
switch(color) {
case BLACK:
return brightBlack;
case BLUE:
return brightBlue;
case CYAN:
return brightCyan;
case DEFAULT:
return isForeground ? defaultBrightColor : defaultBackgroundColor;
case GREEN:
return brightGreen;
case MAGENTA:
return brightMagenta;
case RED:
return brightRed;
case WHITE:
return brightWhite;
case YELLOW:
return brightYellow;
}
}
else {
switch(color) {
case BLACK:
return normalBlack;
case BLUE:
return normalBlue;
case CYAN:
return normalCyan;
case DEFAULT:
return isForeground ? defaultColor : defaultBackgroundColor;
case GREEN:
return normalGreen;
case MAGENTA:
return normalMagenta;
case RED:
return normalRed;
case WHITE:
return normalWhite;
case YELLOW:
return normalYellow;
}
}
throw new IllegalArgumentException("Unknown text color " + color);
} | [
"public",
"Color",
"get",
"(",
"TextColor",
".",
"ANSI",
"color",
",",
"boolean",
"isForeground",
",",
"boolean",
"useBrightTones",
")",
"{",
"if",
"(",
"useBrightTones",
")",
"{",
"switch",
"(",
"color",
")",
"{",
"case",
"BLACK",
":",
"return",
"brightBlack",
";",
"case",
"BLUE",
":",
"return",
"brightBlue",
";",
"case",
"CYAN",
":",
"return",
"brightCyan",
";",
"case",
"DEFAULT",
":",
"return",
"isForeground",
"?",
"defaultBrightColor",
":",
"defaultBackgroundColor",
";",
"case",
"GREEN",
":",
"return",
"brightGreen",
";",
"case",
"MAGENTA",
":",
"return",
"brightMagenta",
";",
"case",
"RED",
":",
"return",
"brightRed",
";",
"case",
"WHITE",
":",
"return",
"brightWhite",
";",
"case",
"YELLOW",
":",
"return",
"brightYellow",
";",
"}",
"}",
"else",
"{",
"switch",
"(",
"color",
")",
"{",
"case",
"BLACK",
":",
"return",
"normalBlack",
";",
"case",
"BLUE",
":",
"return",
"normalBlue",
";",
"case",
"CYAN",
":",
"return",
"normalCyan",
";",
"case",
"DEFAULT",
":",
"return",
"isForeground",
"?",
"defaultColor",
":",
"defaultBackgroundColor",
";",
"case",
"GREEN",
":",
"return",
"normalGreen",
";",
"case",
"MAGENTA",
":",
"return",
"normalMagenta",
";",
"case",
"RED",
":",
"return",
"normalRed",
";",
"case",
"WHITE",
":",
"return",
"normalWhite",
";",
"case",
"YELLOW",
":",
"return",
"normalYellow",
";",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown text color \"",
"+",
"color",
")",
";",
"}"
] | Returns the AWT color from this palette given an ANSI color and two hints for if we are looking for a background
color and if we want to use the bright version.
@param color Which ANSI color we want to extract
@param isForeground Is this color we extract going to be used as a background color?
@param useBrightTones If true, we should return the bright version of the color
@return AWT color extracted from this palette for the input parameters | [
"Returns",
"the",
"AWT",
"color",
"from",
"this",
"palette",
"given",
"an",
"ANSI",
"color",
"and",
"two",
"hints",
"for",
"if",
"we",
"are",
"looking",
"for",
"a",
"background",
"color",
"and",
"if",
"we",
"want",
"to",
"use",
"the",
"bright",
"version",
"."
] | train | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/swing/TerminalEmulatorPalette.java#L284-L330 |
livetribe/livetribe-slp | core/src/main/java/org/livetribe/slp/spi/msg/BytesBlock.java | BytesBlock.readInt | protected static int readInt(byte[] bytes, int offset, int length) {
"""
Reads an integer from <code>bytes</code> in network byte order.
@param bytes The bytes from where the integer value is read
@param offset The offset in <code>bytes</code> from where to start reading the integer
@param length The number of bytes to read
@return The integer value read
"""
int result = 0;
for (int i = 0; i < length; ++i)
{
result <<= 8;
result += bytes[offset + i] & 0xFF;
}
return result;
} | java | protected static int readInt(byte[] bytes, int offset, int length)
{
int result = 0;
for (int i = 0; i < length; ++i)
{
result <<= 8;
result += bytes[offset + i] & 0xFF;
}
return result;
} | [
"protected",
"static",
"int",
"readInt",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"int",
"result",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"++",
"i",
")",
"{",
"result",
"<<=",
"8",
";",
"result",
"+=",
"bytes",
"[",
"offset",
"+",
"i",
"]",
"&",
"0xFF",
";",
"}",
"return",
"result",
";",
"}"
] | Reads an integer from <code>bytes</code> in network byte order.
@param bytes The bytes from where the integer value is read
@param offset The offset in <code>bytes</code> from where to start reading the integer
@param length The number of bytes to read
@return The integer value read | [
"Reads",
"an",
"integer",
"from",
"<code",
">",
"bytes<",
"/",
"code",
">",
"in",
"network",
"byte",
"order",
"."
] | train | https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/spi/msg/BytesBlock.java#L61-L70 |
marvinlabs/android-intents | library/src/main/java/com/marvinlabs/intents/ShareIntents.java | ShareIntents.newShareTextIntent | public static Intent newShareTextIntent(String subject, String message, String chooserDialogTitle) {
"""
Creates a chooser to share some data.
@param subject The subject to share (might be discarded, for instance if the user picks an SMS app)
@param message The message to share
@param chooserDialogTitle The title for the chooser dialog
@return the intent
"""
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, message);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
shareIntent.setType(MIME_TYPE_TEXT);
return Intent.createChooser(shareIntent, chooserDialogTitle);
} | java | public static Intent newShareTextIntent(String subject, String message, String chooserDialogTitle) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, message);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
shareIntent.setType(MIME_TYPE_TEXT);
return Intent.createChooser(shareIntent, chooserDialogTitle);
} | [
"public",
"static",
"Intent",
"newShareTextIntent",
"(",
"String",
"subject",
",",
"String",
"message",
",",
"String",
"chooserDialogTitle",
")",
"{",
"Intent",
"shareIntent",
"=",
"new",
"Intent",
"(",
"Intent",
".",
"ACTION_SEND",
")",
";",
"shareIntent",
".",
"putExtra",
"(",
"Intent",
".",
"EXTRA_TEXT",
",",
"message",
")",
";",
"shareIntent",
".",
"putExtra",
"(",
"Intent",
".",
"EXTRA_SUBJECT",
",",
"subject",
")",
";",
"shareIntent",
".",
"setType",
"(",
"MIME_TYPE_TEXT",
")",
";",
"return",
"Intent",
".",
"createChooser",
"(",
"shareIntent",
",",
"chooserDialogTitle",
")",
";",
"}"
] | Creates a chooser to share some data.
@param subject The subject to share (might be discarded, for instance if the user picks an SMS app)
@param message The message to share
@param chooserDialogTitle The title for the chooser dialog
@return the intent | [
"Creates",
"a",
"chooser",
"to",
"share",
"some",
"data",
"."
] | train | https://github.com/marvinlabs/android-intents/blob/33e79c825188b6a97601869522533cc825801f6e/library/src/main/java/com/marvinlabs/intents/ShareIntents.java#L36-L42 |
marvinlabs/android-slideshow-widget | library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java | SlideShowView.displaySlide | private void displaySlide(final int currentPosition, final int previousPosition) {
"""
Display the view for the given slide, launching the appropriate transitions if available
"""
Log.v("SlideShowView", "Displaying slide at position: " + currentPosition);
// Hide the progress indicator
hideProgressIndicator();
// Add the slide view to our hierarchy
final View inView = getSlideView(currentPosition);
inView.setVisibility(View.INVISIBLE);
addView(inView);
// Notify that the slide is about to be shown
notifyBeforeSlideShown(currentPosition);
// Transition between current and new slide
final TransitionFactory tf = getTransitionFactory();
final Animator inAnimator = tf.getInAnimator(inView, this, previousPosition, currentPosition);
if (inAnimator != null) {
inAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
inView.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
notifySlideShown(currentPosition);
}
});
inAnimator.start();
} else {
inView.setVisibility(View.VISIBLE);
notifySlideShown(currentPosition);
}
int childCount = getChildCount();
if (childCount > 1) {
notifyBeforeSlideHidden(previousPosition);
final View outView = getChildAt(0);
final Animator outAnimator = tf.getOutAnimator(outView, this, previousPosition, currentPosition);
if (outAnimator != null) {
outAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
outView.setVisibility(View.INVISIBLE);
notifySlideHidden(previousPosition);
recyclePreviousSlideView(previousPosition, outView);
}
});
outAnimator.start();
} else {
outView.setVisibility(View.INVISIBLE);
notifySlideHidden(previousPosition);
recyclePreviousSlideView(previousPosition, outView);
}
}
} | java | private void displaySlide(final int currentPosition, final int previousPosition) {
Log.v("SlideShowView", "Displaying slide at position: " + currentPosition);
// Hide the progress indicator
hideProgressIndicator();
// Add the slide view to our hierarchy
final View inView = getSlideView(currentPosition);
inView.setVisibility(View.INVISIBLE);
addView(inView);
// Notify that the slide is about to be shown
notifyBeforeSlideShown(currentPosition);
// Transition between current and new slide
final TransitionFactory tf = getTransitionFactory();
final Animator inAnimator = tf.getInAnimator(inView, this, previousPosition, currentPosition);
if (inAnimator != null) {
inAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
inView.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
notifySlideShown(currentPosition);
}
});
inAnimator.start();
} else {
inView.setVisibility(View.VISIBLE);
notifySlideShown(currentPosition);
}
int childCount = getChildCount();
if (childCount > 1) {
notifyBeforeSlideHidden(previousPosition);
final View outView = getChildAt(0);
final Animator outAnimator = tf.getOutAnimator(outView, this, previousPosition, currentPosition);
if (outAnimator != null) {
outAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
outView.setVisibility(View.INVISIBLE);
notifySlideHidden(previousPosition);
recyclePreviousSlideView(previousPosition, outView);
}
});
outAnimator.start();
} else {
outView.setVisibility(View.INVISIBLE);
notifySlideHidden(previousPosition);
recyclePreviousSlideView(previousPosition, outView);
}
}
} | [
"private",
"void",
"displaySlide",
"(",
"final",
"int",
"currentPosition",
",",
"final",
"int",
"previousPosition",
")",
"{",
"Log",
".",
"v",
"(",
"\"SlideShowView\"",
",",
"\"Displaying slide at position: \"",
"+",
"currentPosition",
")",
";",
"// Hide the progress indicator",
"hideProgressIndicator",
"(",
")",
";",
"// Add the slide view to our hierarchy",
"final",
"View",
"inView",
"=",
"getSlideView",
"(",
"currentPosition",
")",
";",
"inView",
".",
"setVisibility",
"(",
"View",
".",
"INVISIBLE",
")",
";",
"addView",
"(",
"inView",
")",
";",
"// Notify that the slide is about to be shown",
"notifyBeforeSlideShown",
"(",
"currentPosition",
")",
";",
"// Transition between current and new slide",
"final",
"TransitionFactory",
"tf",
"=",
"getTransitionFactory",
"(",
")",
";",
"final",
"Animator",
"inAnimator",
"=",
"tf",
".",
"getInAnimator",
"(",
"inView",
",",
"this",
",",
"previousPosition",
",",
"currentPosition",
")",
";",
"if",
"(",
"inAnimator",
"!=",
"null",
")",
"{",
"inAnimator",
".",
"addListener",
"(",
"new",
"AnimatorListenerAdapter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onAnimationStart",
"(",
"Animator",
"animation",
")",
"{",
"inView",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onAnimationEnd",
"(",
"Animator",
"animation",
")",
"{",
"notifySlideShown",
"(",
"currentPosition",
")",
";",
"}",
"}",
")",
";",
"inAnimator",
".",
"start",
"(",
")",
";",
"}",
"else",
"{",
"inView",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"notifySlideShown",
"(",
"currentPosition",
")",
";",
"}",
"int",
"childCount",
"=",
"getChildCount",
"(",
")",
";",
"if",
"(",
"childCount",
">",
"1",
")",
"{",
"notifyBeforeSlideHidden",
"(",
"previousPosition",
")",
";",
"final",
"View",
"outView",
"=",
"getChildAt",
"(",
"0",
")",
";",
"final",
"Animator",
"outAnimator",
"=",
"tf",
".",
"getOutAnimator",
"(",
"outView",
",",
"this",
",",
"previousPosition",
",",
"currentPosition",
")",
";",
"if",
"(",
"outAnimator",
"!=",
"null",
")",
"{",
"outAnimator",
".",
"addListener",
"(",
"new",
"AnimatorListenerAdapter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onAnimationEnd",
"(",
"Animator",
"animation",
")",
"{",
"outView",
".",
"setVisibility",
"(",
"View",
".",
"INVISIBLE",
")",
";",
"notifySlideHidden",
"(",
"previousPosition",
")",
";",
"recyclePreviousSlideView",
"(",
"previousPosition",
",",
"outView",
")",
";",
"}",
"}",
")",
";",
"outAnimator",
".",
"start",
"(",
")",
";",
"}",
"else",
"{",
"outView",
".",
"setVisibility",
"(",
"View",
".",
"INVISIBLE",
")",
";",
"notifySlideHidden",
"(",
"previousPosition",
")",
";",
"recyclePreviousSlideView",
"(",
"previousPosition",
",",
"outView",
")",
";",
"}",
"}",
"}"
] | Display the view for the given slide, launching the appropriate transitions if available | [
"Display",
"the",
"view",
"for",
"the",
"given",
"slide",
"launching",
"the",
"appropriate",
"transitions",
"if",
"available"
] | train | https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L590-L649 |
davetcc/tcMenu | tcMenuJavaApi/src/main/java/com/thecoderscorner/menu/domain/state/MenuTree.java | MenuTree.addOrUpdateItem | public void addOrUpdateItem(int parentId, MenuItem item) {
"""
This will either add or update an existing item, depending if the ID is already present.
@param parentId the parent where it should be placed / already exists
@param item the item to either add or update.
"""
synchronized (subMenuItems) {
getSubMenuById(parentId).ifPresent(subMenu-> {
if(getMenuItems(subMenu).stream().anyMatch(it-> it.getId() == item.getId())) {
replaceMenuById(asSubMenu(subMenu), item);
}
else {
addMenuItem(asSubMenu(subMenu), item);
}
});
}
} | java | public void addOrUpdateItem(int parentId, MenuItem item) {
synchronized (subMenuItems) {
getSubMenuById(parentId).ifPresent(subMenu-> {
if(getMenuItems(subMenu).stream().anyMatch(it-> it.getId() == item.getId())) {
replaceMenuById(asSubMenu(subMenu), item);
}
else {
addMenuItem(asSubMenu(subMenu), item);
}
});
}
} | [
"public",
"void",
"addOrUpdateItem",
"(",
"int",
"parentId",
",",
"MenuItem",
"item",
")",
"{",
"synchronized",
"(",
"subMenuItems",
")",
"{",
"getSubMenuById",
"(",
"parentId",
")",
".",
"ifPresent",
"(",
"subMenu",
"->",
"{",
"if",
"(",
"getMenuItems",
"(",
"subMenu",
")",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"it",
"->",
"it",
".",
"getId",
"(",
")",
"==",
"item",
".",
"getId",
"(",
")",
")",
")",
"{",
"replaceMenuById",
"(",
"asSubMenu",
"(",
"subMenu",
")",
",",
"item",
")",
";",
"}",
"else",
"{",
"addMenuItem",
"(",
"asSubMenu",
"(",
"subMenu",
")",
",",
"item",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | This will either add or update an existing item, depending if the ID is already present.
@param parentId the parent where it should be placed / already exists
@param item the item to either add or update. | [
"This",
"will",
"either",
"add",
"or",
"update",
"an",
"existing",
"item",
"depending",
"if",
"the",
"ID",
"is",
"already",
"present",
"."
] | train | https://github.com/davetcc/tcMenu/blob/61546e4b982b25ceaff384073fe9ec1fff55e64a/tcMenuJavaApi/src/main/java/com/thecoderscorner/menu/domain/state/MenuTree.java#L80-L91 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ULocale.java | ULocale.toUnicodeLocaleType | public static String toUnicodeLocaleType(String keyword, String value) {
"""
<strong>[icu]</strong> Converts the specified keyword value (legacy type, or BCP 47
Unicode locale extension type) to the well-formed BCP 47 Unicode locale
extension type for the specified keyword (category). For example, BCP 47
Unicode locale extension type "phonebk" is returned for the input
keyword value "phonebook", with the keyword "collation" (or "co").
<p>
When the specified keyword is not recognized, but the specified value
satisfies the syntax of the BCP 47 Unicode locale extension type,
or when the specified keyword allows 'variable' type and the specified
value satisfies the syntax, the lower-case version of the input value
will be returned. For example,
<code>toUnicodeLocaleType("Foo", "Bar")</code> returns "bar",
<code>toUnicodeLocaleType("variableTop", "00A4")</code> returns "00a4".
@param keyword the locale keyword (either legacy key such as
"collation" or BCP 47 Unicode locale extension
key such as "co").
@param value the locale keyword value (either legacy type
such as "phonebook" or BCP 47 Unicode locale extension
type such as "phonebk").
@return the well-formed BCP47 Unicode locale extension type,
or null if the locale keyword value cannot be mapped to
a well-formed BCP 47 Unicode locale extension type.
@see #toLegacyType(String, String)
"""
String bcpType = KeyTypeData.toBcpType(keyword, value, null, null);
if (bcpType == null && UnicodeLocaleExtension.isType(value)) {
// unknown keyword, but syntax is fine..
bcpType = AsciiUtil.toLowerString(value);
}
return bcpType;
} | java | public static String toUnicodeLocaleType(String keyword, String value) {
String bcpType = KeyTypeData.toBcpType(keyword, value, null, null);
if (bcpType == null && UnicodeLocaleExtension.isType(value)) {
// unknown keyword, but syntax is fine..
bcpType = AsciiUtil.toLowerString(value);
}
return bcpType;
} | [
"public",
"static",
"String",
"toUnicodeLocaleType",
"(",
"String",
"keyword",
",",
"String",
"value",
")",
"{",
"String",
"bcpType",
"=",
"KeyTypeData",
".",
"toBcpType",
"(",
"keyword",
",",
"value",
",",
"null",
",",
"null",
")",
";",
"if",
"(",
"bcpType",
"==",
"null",
"&&",
"UnicodeLocaleExtension",
".",
"isType",
"(",
"value",
")",
")",
"{",
"// unknown keyword, but syntax is fine..",
"bcpType",
"=",
"AsciiUtil",
".",
"toLowerString",
"(",
"value",
")",
";",
"}",
"return",
"bcpType",
";",
"}"
] | <strong>[icu]</strong> Converts the specified keyword value (legacy type, or BCP 47
Unicode locale extension type) to the well-formed BCP 47 Unicode locale
extension type for the specified keyword (category). For example, BCP 47
Unicode locale extension type "phonebk" is returned for the input
keyword value "phonebook", with the keyword "collation" (or "co").
<p>
When the specified keyword is not recognized, but the specified value
satisfies the syntax of the BCP 47 Unicode locale extension type,
or when the specified keyword allows 'variable' type and the specified
value satisfies the syntax, the lower-case version of the input value
will be returned. For example,
<code>toUnicodeLocaleType("Foo", "Bar")</code> returns "bar",
<code>toUnicodeLocaleType("variableTop", "00A4")</code> returns "00a4".
@param keyword the locale keyword (either legacy key such as
"collation" or BCP 47 Unicode locale extension
key such as "co").
@param value the locale keyword value (either legacy type
such as "phonebook" or BCP 47 Unicode locale extension
type such as "phonebk").
@return the well-formed BCP47 Unicode locale extension type,
or null if the locale keyword value cannot be mapped to
a well-formed BCP 47 Unicode locale extension type.
@see #toLegacyType(String, String) | [
"<strong",
">",
"[",
"icu",
"]",
"<",
"/",
"strong",
">",
"Converts",
"the",
"specified",
"keyword",
"value",
"(",
"legacy",
"type",
"or",
"BCP",
"47",
"Unicode",
"locale",
"extension",
"type",
")",
"to",
"the",
"well",
"-",
"formed",
"BCP",
"47",
"Unicode",
"locale",
"extension",
"type",
"for",
"the",
"specified",
"keyword",
"(",
"category",
")",
".",
"For",
"example",
"BCP",
"47",
"Unicode",
"locale",
"extension",
"type",
"phonebk",
"is",
"returned",
"for",
"the",
"input",
"keyword",
"value",
"phonebook",
"with",
"the",
"keyword",
"collation",
"(",
"or",
"co",
")",
".",
"<p",
">",
"When",
"the",
"specified",
"keyword",
"is",
"not",
"recognized",
"but",
"the",
"specified",
"value",
"satisfies",
"the",
"syntax",
"of",
"the",
"BCP",
"47",
"Unicode",
"locale",
"extension",
"type",
"or",
"when",
"the",
"specified",
"keyword",
"allows",
"variable",
"type",
"and",
"the",
"specified",
"value",
"satisfies",
"the",
"syntax",
"the",
"lower",
"-",
"case",
"version",
"of",
"the",
"input",
"value",
"will",
"be",
"returned",
".",
"For",
"example",
"<code",
">",
"toUnicodeLocaleType",
"(",
"Foo",
"Bar",
")",
"<",
"/",
"code",
">",
"returns",
"bar",
"<code",
">",
"toUnicodeLocaleType",
"(",
"variableTop",
"00A4",
")",
"<",
"/",
"code",
">",
"returns",
"00a4",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ULocale.java#L3353-L3360 |
apache/flink | flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java | NFACompiler.canProduceEmptyMatches | public static boolean canProduceEmptyMatches(final Pattern<?, ?> pattern) {
"""
Verifies if the provided pattern can possibly generate empty match. Example of patterns that can possibly
generate empty matches are: A*, A?, A* B? etc.
@param pattern pattern to check
@return true if empty match could potentially match the pattern, false otherwise
"""
NFAFactoryCompiler<?> compiler = new NFAFactoryCompiler<>(checkNotNull(pattern));
compiler.compileFactory();
State<?> startState = compiler.getStates().stream().filter(State::isStart).findFirst().orElseThrow(
() -> new IllegalStateException("Compiler produced no start state. It is a bug. File a jira."));
Set<State<?>> visitedStates = new HashSet<>();
final Stack<State<?>> statesToCheck = new Stack<>();
statesToCheck.push(startState);
while (!statesToCheck.isEmpty()) {
final State<?> currentState = statesToCheck.pop();
if (visitedStates.contains(currentState)) {
continue;
} else {
visitedStates.add(currentState);
}
for (StateTransition<?> transition : currentState.getStateTransitions()) {
if (transition.getAction() == StateTransitionAction.PROCEED) {
if (transition.getTargetState().isFinal()) {
return true;
} else {
statesToCheck.push(transition.getTargetState());
}
}
}
}
return false;
} | java | public static boolean canProduceEmptyMatches(final Pattern<?, ?> pattern) {
NFAFactoryCompiler<?> compiler = new NFAFactoryCompiler<>(checkNotNull(pattern));
compiler.compileFactory();
State<?> startState = compiler.getStates().stream().filter(State::isStart).findFirst().orElseThrow(
() -> new IllegalStateException("Compiler produced no start state. It is a bug. File a jira."));
Set<State<?>> visitedStates = new HashSet<>();
final Stack<State<?>> statesToCheck = new Stack<>();
statesToCheck.push(startState);
while (!statesToCheck.isEmpty()) {
final State<?> currentState = statesToCheck.pop();
if (visitedStates.contains(currentState)) {
continue;
} else {
visitedStates.add(currentState);
}
for (StateTransition<?> transition : currentState.getStateTransitions()) {
if (transition.getAction() == StateTransitionAction.PROCEED) {
if (transition.getTargetState().isFinal()) {
return true;
} else {
statesToCheck.push(transition.getTargetState());
}
}
}
}
return false;
} | [
"public",
"static",
"boolean",
"canProduceEmptyMatches",
"(",
"final",
"Pattern",
"<",
"?",
",",
"?",
">",
"pattern",
")",
"{",
"NFAFactoryCompiler",
"<",
"?",
">",
"compiler",
"=",
"new",
"NFAFactoryCompiler",
"<>",
"(",
"checkNotNull",
"(",
"pattern",
")",
")",
";",
"compiler",
".",
"compileFactory",
"(",
")",
";",
"State",
"<",
"?",
">",
"startState",
"=",
"compiler",
".",
"getStates",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"State",
"::",
"isStart",
")",
".",
"findFirst",
"(",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"IllegalStateException",
"(",
"\"Compiler produced no start state. It is a bug. File a jira.\"",
")",
")",
";",
"Set",
"<",
"State",
"<",
"?",
">",
">",
"visitedStates",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"final",
"Stack",
"<",
"State",
"<",
"?",
">",
">",
"statesToCheck",
"=",
"new",
"Stack",
"<>",
"(",
")",
";",
"statesToCheck",
".",
"push",
"(",
"startState",
")",
";",
"while",
"(",
"!",
"statesToCheck",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"State",
"<",
"?",
">",
"currentState",
"=",
"statesToCheck",
".",
"pop",
"(",
")",
";",
"if",
"(",
"visitedStates",
".",
"contains",
"(",
"currentState",
")",
")",
"{",
"continue",
";",
"}",
"else",
"{",
"visitedStates",
".",
"add",
"(",
"currentState",
")",
";",
"}",
"for",
"(",
"StateTransition",
"<",
"?",
">",
"transition",
":",
"currentState",
".",
"getStateTransitions",
"(",
")",
")",
"{",
"if",
"(",
"transition",
".",
"getAction",
"(",
")",
"==",
"StateTransitionAction",
".",
"PROCEED",
")",
"{",
"if",
"(",
"transition",
".",
"getTargetState",
"(",
")",
".",
"isFinal",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"statesToCheck",
".",
"push",
"(",
"transition",
".",
"getTargetState",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Verifies if the provided pattern can possibly generate empty match. Example of patterns that can possibly
generate empty matches are: A*, A?, A* B? etc.
@param pattern pattern to check
@return true if empty match could potentially match the pattern, false otherwise | [
"Verifies",
"if",
"the",
"provided",
"pattern",
"can",
"possibly",
"generate",
"empty",
"match",
".",
"Example",
"of",
"patterns",
"that",
"can",
"possibly",
"generate",
"empty",
"matches",
"are",
":",
"A",
"*",
"A?",
"A",
"*",
"B?",
"etc",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java#L89-L118 |
aol/cyclops | cyclops/src/main/java/cyclops/companion/Streams.java | Streams.streamToOptional | public final static <T> Optional<Seq<T>> streamToOptional(final Stream<T> stream) {
"""
Create an Optional containing a List materialized from a Stream
<pre>
{@code
Optional<Seq<Integer>> opt = Streams.streamToOptional(Stream.of(1,2,3));
//Optional[[1,2,3]]
}
</pre>
@param stream To convert into an Optional
@return Optional with a List of values
"""
final List<T> collected = stream.collect(java.util.stream.Collectors.toList());
if (collected.size() == 0)
return Optional.empty();
return Optional.of(Seq.fromIterable(collected));
} | java | public final static <T> Optional<Seq<T>> streamToOptional(final Stream<T> stream) {
final List<T> collected = stream.collect(java.util.stream.Collectors.toList());
if (collected.size() == 0)
return Optional.empty();
return Optional.of(Seq.fromIterable(collected));
} | [
"public",
"final",
"static",
"<",
"T",
">",
"Optional",
"<",
"Seq",
"<",
"T",
">",
">",
"streamToOptional",
"(",
"final",
"Stream",
"<",
"T",
">",
"stream",
")",
"{",
"final",
"List",
"<",
"T",
">",
"collected",
"=",
"stream",
".",
"collect",
"(",
"java",
".",
"util",
".",
"stream",
".",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"if",
"(",
"collected",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"return",
"Optional",
".",
"of",
"(",
"Seq",
".",
"fromIterable",
"(",
"collected",
")",
")",
";",
"}"
] | Create an Optional containing a List materialized from a Stream
<pre>
{@code
Optional<Seq<Integer>> opt = Streams.streamToOptional(Stream.of(1,2,3));
//Optional[[1,2,3]]
}
</pre>
@param stream To convert into an Optional
@return Optional with a List of values | [
"Create",
"an",
"Optional",
"containing",
"a",
"List",
"materialized",
"from",
"a",
"Stream"
] | train | https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L473-L479 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java | URLUtil.getURL | public static URL getURL(String path, Class<?> clazz) {
"""
获得URL
@param path 相对给定 class所在的路径
@param clazz 指定class
@return URL
@see ResourceUtil#getResource(String, Class)
"""
return ResourceUtil.getResource(path, clazz);
} | java | public static URL getURL(String path, Class<?> clazz) {
return ResourceUtil.getResource(path, clazz);
} | [
"public",
"static",
"URL",
"getURL",
"(",
"String",
"path",
",",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"return",
"ResourceUtil",
".",
"getResource",
"(",
"path",
",",
"clazz",
")",
";",
"}"
] | 获得URL
@param path 相对给定 class所在的路径
@param clazz 指定class
@return URL
@see ResourceUtil#getResource(String, Class) | [
"获得URL"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java#L145-L147 |
respoke/respoke-sdk-android | respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java | RespokeClient.postJoinGroupMembersError | private void postJoinGroupMembersError(final JoinGroupCompletionListener completionListener, final String errorMessage) {
"""
A convenience method for posting errors to a JoinGroupCompletionListener
@param completionListener The listener to notify
@param errorMessage The human-readable error message that occurred
"""
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
if (null != completionListener) {
completionListener.onError(errorMessage);
}
}
});
} | java | private void postJoinGroupMembersError(final JoinGroupCompletionListener completionListener, final String errorMessage) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
if (null != completionListener) {
completionListener.onError(errorMessage);
}
}
});
} | [
"private",
"void",
"postJoinGroupMembersError",
"(",
"final",
"JoinGroupCompletionListener",
"completionListener",
",",
"final",
"String",
"errorMessage",
")",
"{",
"new",
"Handler",
"(",
"Looper",
".",
"getMainLooper",
"(",
")",
")",
".",
"post",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"if",
"(",
"null",
"!=",
"completionListener",
")",
"{",
"completionListener",
".",
"onError",
"(",
"errorMessage",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | A convenience method for posting errors to a JoinGroupCompletionListener
@param completionListener The listener to notify
@param errorMessage The human-readable error message that occurred | [
"A",
"convenience",
"method",
"for",
"posting",
"errors",
"to",
"a",
"JoinGroupCompletionListener"
] | train | https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L1089-L1098 |
sematext/ActionGenerator | ag-player-es/src/main/java/com/sematext/ag/es/util/JSONUtils.java | JSONUtils.getElasticSearchBulkHeader | public static String getElasticSearchBulkHeader(SimpleDataEvent event, String index, String type) {
"""
Constructs ES bulk header for the document.
@param event
data event
@param index
index name
@param type
document type
@return ES bulk header
"""
StringBuilder builder = new StringBuilder();
builder.append("{\"index\":{\"_index\":\"");
builder.append(index);
builder.append("\",\"_type\":\"");
builder.append(type);
builder.append("\",\"_id\":\"");
builder.append(event.getId());
builder.append("\"}}");
return builder.toString();
} | java | public static String getElasticSearchBulkHeader(SimpleDataEvent event, String index, String type) {
StringBuilder builder = new StringBuilder();
builder.append("{\"index\":{\"_index\":\"");
builder.append(index);
builder.append("\",\"_type\":\"");
builder.append(type);
builder.append("\",\"_id\":\"");
builder.append(event.getId());
builder.append("\"}}");
return builder.toString();
} | [
"public",
"static",
"String",
"getElasticSearchBulkHeader",
"(",
"SimpleDataEvent",
"event",
",",
"String",
"index",
",",
"String",
"type",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"\"{\\\"index\\\":{\\\"_index\\\":\\\"\"",
")",
";",
"builder",
".",
"append",
"(",
"index",
")",
";",
"builder",
".",
"append",
"(",
"\"\\\",\\\"_type\\\":\\\"\"",
")",
";",
"builder",
".",
"append",
"(",
"type",
")",
";",
"builder",
".",
"append",
"(",
"\"\\\",\\\"_id\\\":\\\"\"",
")",
";",
"builder",
".",
"append",
"(",
"event",
".",
"getId",
"(",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"\\\"}}\"",
")",
";",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | Constructs ES bulk header for the document.
@param event
data event
@param index
index name
@param type
document type
@return ES bulk header | [
"Constructs",
"ES",
"bulk",
"header",
"for",
"the",
"document",
"."
] | train | https://github.com/sematext/ActionGenerator/blob/10f4a3e680f20d7d151f5d40e6758aeb072d474f/ag-player-es/src/main/java/com/sematext/ag/es/util/JSONUtils.java#L65-L75 |
zaproxy/zaproxy | src/org/zaproxy/zap/control/AddOn.java | AddOn.calculateExtensionRunRequirements | public AddOnRunRequirements calculateExtensionRunRequirements(String classname, Collection<AddOn> availableAddOns) {
"""
Calculates the requirements to run the extension with the given {@code classname}, in the current ZAP and Java versions
and with the given {@code availableAddOns}.
<p>
If the extension depends on other add-ons, those add-ons are checked if are also runnable.
<p>
<strong>Note:</strong> All the given {@code availableAddOns} are expected to be loadable in the currently running ZAP
version, that is, the method {@code AddOn.canLoadInCurrentVersion()}, returns {@code true}.
@param classname the classname of extension that will be checked
@param availableAddOns the add-ons available
@return the requirements to run the extension, and if not runnable the reason why it's not.
@since 2.4.0
@see AddOnRunRequirements#getExtensionRequirements()
"""
AddOnRunRequirements requirements = new AddOnRunRequirements(this);
for (ExtensionWithDeps extensionWithDeps : extensionsWithDeps) {
if (extensionWithDeps.getClassname().equals(classname)) {
calculateExtensionRunRequirements(extensionWithDeps, availableAddOns, requirements, this);
break;
}
}
return requirements;
} | java | public AddOnRunRequirements calculateExtensionRunRequirements(String classname, Collection<AddOn> availableAddOns) {
AddOnRunRequirements requirements = new AddOnRunRequirements(this);
for (ExtensionWithDeps extensionWithDeps : extensionsWithDeps) {
if (extensionWithDeps.getClassname().equals(classname)) {
calculateExtensionRunRequirements(extensionWithDeps, availableAddOns, requirements, this);
break;
}
}
return requirements;
} | [
"public",
"AddOnRunRequirements",
"calculateExtensionRunRequirements",
"(",
"String",
"classname",
",",
"Collection",
"<",
"AddOn",
">",
"availableAddOns",
")",
"{",
"AddOnRunRequirements",
"requirements",
"=",
"new",
"AddOnRunRequirements",
"(",
"this",
")",
";",
"for",
"(",
"ExtensionWithDeps",
"extensionWithDeps",
":",
"extensionsWithDeps",
")",
"{",
"if",
"(",
"extensionWithDeps",
".",
"getClassname",
"(",
")",
".",
"equals",
"(",
"classname",
")",
")",
"{",
"calculateExtensionRunRequirements",
"(",
"extensionWithDeps",
",",
"availableAddOns",
",",
"requirements",
",",
"this",
")",
";",
"break",
";",
"}",
"}",
"return",
"requirements",
";",
"}"
] | Calculates the requirements to run the extension with the given {@code classname}, in the current ZAP and Java versions
and with the given {@code availableAddOns}.
<p>
If the extension depends on other add-ons, those add-ons are checked if are also runnable.
<p>
<strong>Note:</strong> All the given {@code availableAddOns} are expected to be loadable in the currently running ZAP
version, that is, the method {@code AddOn.canLoadInCurrentVersion()}, returns {@code true}.
@param classname the classname of extension that will be checked
@param availableAddOns the add-ons available
@return the requirements to run the extension, and if not runnable the reason why it's not.
@since 2.4.0
@see AddOnRunRequirements#getExtensionRequirements() | [
"Calculates",
"the",
"requirements",
"to",
"run",
"the",
"extension",
"with",
"the",
"given",
"{",
"@code",
"classname",
"}",
"in",
"the",
"current",
"ZAP",
"and",
"Java",
"versions",
"and",
"with",
"the",
"given",
"{",
"@code",
"availableAddOns",
"}",
".",
"<p",
">",
"If",
"the",
"extension",
"depends",
"on",
"other",
"add",
"-",
"ons",
"those",
"add",
"-",
"ons",
"are",
"checked",
"if",
"are",
"also",
"runnable",
".",
"<p",
">",
"<strong",
">",
"Note",
":",
"<",
"/",
"strong",
">",
"All",
"the",
"given",
"{",
"@code",
"availableAddOns",
"}",
"are",
"expected",
"to",
"be",
"loadable",
"in",
"the",
"currently",
"running",
"ZAP",
"version",
"that",
"is",
"the",
"method",
"{",
"@code",
"AddOn",
".",
"canLoadInCurrentVersion",
"()",
"}",
"returns",
"{",
"@code",
"true",
"}",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/control/AddOn.java#L1372-L1381 |
groovy/groovy-core | src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.withDefault | public static <T> List<T> withDefault(List<T> self, Closure init) {
"""
An alias for <code>withLazyDefault</code> which decorates a list allowing
it to grow when called with index values outside the normal list bounds.
@param self a List
@param init a Closure with the target index as parameter which generates the default value
@return the decorated List
@see #withLazyDefault(java.util.List, groovy.lang.Closure)
@see #withEagerDefault(java.util.List, groovy.lang.Closure)
@since 1.8.7
"""
return withLazyDefault(self, init);
} | java | public static <T> List<T> withDefault(List<T> self, Closure init) {
return withLazyDefault(self, init);
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"withDefault",
"(",
"List",
"<",
"T",
">",
"self",
",",
"Closure",
"init",
")",
"{",
"return",
"withLazyDefault",
"(",
"self",
",",
"init",
")",
";",
"}"
] | An alias for <code>withLazyDefault</code> which decorates a list allowing
it to grow when called with index values outside the normal list bounds.
@param self a List
@param init a Closure with the target index as parameter which generates the default value
@return the decorated List
@see #withLazyDefault(java.util.List, groovy.lang.Closure)
@see #withEagerDefault(java.util.List, groovy.lang.Closure)
@since 1.8.7 | [
"An",
"alias",
"for",
"<code",
">",
"withLazyDefault<",
"/",
"code",
">",
"which",
"decorates",
"a",
"list",
"allowing",
"it",
"to",
"grow",
"when",
"called",
"with",
"index",
"values",
"outside",
"the",
"normal",
"list",
"bounds",
"."
] | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7764-L7766 |
xmlunit/xmlunit | xmlunit-legacy/src/main/java/org/custommonkey/xmlunit/XMLAssert.java | XMLAssert.assertXMLValid | public static void assertXMLValid(InputSource xml, String systemId)
throws SAXException, ConfigurationException {
"""
Assert that an InputSource containing XML contains valid XML:
the document must contain a DOCTYPE to be validated, but the
validation will use the systemId to obtain the DTD
@param xml
@param systemId
@throws SAXException
@throws ConfigurationException if validation could not be turned on
@see Validator
"""
assertXMLValid(new Validator(xml, systemId));
} | java | public static void assertXMLValid(InputSource xml, String systemId)
throws SAXException, ConfigurationException {
assertXMLValid(new Validator(xml, systemId));
} | [
"public",
"static",
"void",
"assertXMLValid",
"(",
"InputSource",
"xml",
",",
"String",
"systemId",
")",
"throws",
"SAXException",
",",
"ConfigurationException",
"{",
"assertXMLValid",
"(",
"new",
"Validator",
"(",
"xml",
",",
"systemId",
")",
")",
";",
"}"
] | Assert that an InputSource containing XML contains valid XML:
the document must contain a DOCTYPE to be validated, but the
validation will use the systemId to obtain the DTD
@param xml
@param systemId
@throws SAXException
@throws ConfigurationException if validation could not be turned on
@see Validator | [
"Assert",
"that",
"an",
"InputSource",
"containing",
"XML",
"contains",
"valid",
"XML",
":",
"the",
"document",
"must",
"contain",
"a",
"DOCTYPE",
"to",
"be",
"validated",
"but",
"the",
"validation",
"will",
"use",
"the",
"systemId",
"to",
"obtain",
"the",
"DTD"
] | train | https://github.com/xmlunit/xmlunit/blob/fe3d701d43f57ee83dcba336e4c1555619d3084b/xmlunit-legacy/src/main/java/org/custommonkey/xmlunit/XMLAssert.java#L1052-L1055 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/utils/SymmetryTools.java | SymmetryTools.fromAFP | public static MultipleAlignment fromAFP(AFPChain symm, Atom[] atoms)
throws StructureException {
"""
Converts a refined symmetry AFPChain alignment into the standard
representation of symmetry in a MultipleAlignment, that contains the
entire Atom array of the strcuture and the symmetric repeats are orgaized
in different rows in a single Block.
@param symm
AFPChain created with a symmetry algorithm and refined
@param atoms
Atom array of the entire structure
@return MultipleAlignment format of the symmetry
@throws StructureException
"""
if (!symm.getAlgorithmName().contains("symm")) {
throw new IllegalArgumentException(
"The input alignment is not a symmetry alignment.");
}
MultipleAlignmentEnsemble e = new MultipleAlignmentEnsembleImpl(symm,
atoms, atoms, false);
e.setAtomArrays(new ArrayList<Atom[]>());
StructureIdentifier name = null;
if (e.getStructureIdentifiers() != null) {
if (!e.getStructureIdentifiers().isEmpty())
name = e.getStructureIdentifiers().get(0);
} else
name = atoms[0].getGroup().getChain().getStructure()
.getStructureIdentifier();
e.setStructureIdentifiers(new ArrayList<StructureIdentifier>());
MultipleAlignment result = new MultipleAlignmentImpl();
BlockSet bs = new BlockSetImpl(result);
Block b = new BlockImpl(bs);
b.setAlignRes(new ArrayList<List<Integer>>());
int order = symm.getBlockNum();
for (int su = 0; su < order; su++) {
List<Integer> residues = e.getMultipleAlignment(0).getBlock(su)
.getAlignRes().get(0);
b.getAlignRes().add(residues);
e.getStructureIdentifiers().add(name);
e.getAtomArrays().add(atoms);
}
e.getMultipleAlignments().set(0, result);
result.setEnsemble(e);
CoreSuperimposer imposer = new CoreSuperimposer();
imposer.superimpose(result);
updateSymmetryScores(result);
return result;
} | java | public static MultipleAlignment fromAFP(AFPChain symm, Atom[] atoms)
throws StructureException {
if (!symm.getAlgorithmName().contains("symm")) {
throw new IllegalArgumentException(
"The input alignment is not a symmetry alignment.");
}
MultipleAlignmentEnsemble e = new MultipleAlignmentEnsembleImpl(symm,
atoms, atoms, false);
e.setAtomArrays(new ArrayList<Atom[]>());
StructureIdentifier name = null;
if (e.getStructureIdentifiers() != null) {
if (!e.getStructureIdentifiers().isEmpty())
name = e.getStructureIdentifiers().get(0);
} else
name = atoms[0].getGroup().getChain().getStructure()
.getStructureIdentifier();
e.setStructureIdentifiers(new ArrayList<StructureIdentifier>());
MultipleAlignment result = new MultipleAlignmentImpl();
BlockSet bs = new BlockSetImpl(result);
Block b = new BlockImpl(bs);
b.setAlignRes(new ArrayList<List<Integer>>());
int order = symm.getBlockNum();
for (int su = 0; su < order; su++) {
List<Integer> residues = e.getMultipleAlignment(0).getBlock(su)
.getAlignRes().get(0);
b.getAlignRes().add(residues);
e.getStructureIdentifiers().add(name);
e.getAtomArrays().add(atoms);
}
e.getMultipleAlignments().set(0, result);
result.setEnsemble(e);
CoreSuperimposer imposer = new CoreSuperimposer();
imposer.superimpose(result);
updateSymmetryScores(result);
return result;
} | [
"public",
"static",
"MultipleAlignment",
"fromAFP",
"(",
"AFPChain",
"symm",
",",
"Atom",
"[",
"]",
"atoms",
")",
"throws",
"StructureException",
"{",
"if",
"(",
"!",
"symm",
".",
"getAlgorithmName",
"(",
")",
".",
"contains",
"(",
"\"symm\"",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The input alignment is not a symmetry alignment.\"",
")",
";",
"}",
"MultipleAlignmentEnsemble",
"e",
"=",
"new",
"MultipleAlignmentEnsembleImpl",
"(",
"symm",
",",
"atoms",
",",
"atoms",
",",
"false",
")",
";",
"e",
".",
"setAtomArrays",
"(",
"new",
"ArrayList",
"<",
"Atom",
"[",
"]",
">",
"(",
")",
")",
";",
"StructureIdentifier",
"name",
"=",
"null",
";",
"if",
"(",
"e",
".",
"getStructureIdentifiers",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"e",
".",
"getStructureIdentifiers",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"name",
"=",
"e",
".",
"getStructureIdentifiers",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"}",
"else",
"name",
"=",
"atoms",
"[",
"0",
"]",
".",
"getGroup",
"(",
")",
".",
"getChain",
"(",
")",
".",
"getStructure",
"(",
")",
".",
"getStructureIdentifier",
"(",
")",
";",
"e",
".",
"setStructureIdentifiers",
"(",
"new",
"ArrayList",
"<",
"StructureIdentifier",
">",
"(",
")",
")",
";",
"MultipleAlignment",
"result",
"=",
"new",
"MultipleAlignmentImpl",
"(",
")",
";",
"BlockSet",
"bs",
"=",
"new",
"BlockSetImpl",
"(",
"result",
")",
";",
"Block",
"b",
"=",
"new",
"BlockImpl",
"(",
"bs",
")",
";",
"b",
".",
"setAlignRes",
"(",
"new",
"ArrayList",
"<",
"List",
"<",
"Integer",
">",
">",
"(",
")",
")",
";",
"int",
"order",
"=",
"symm",
".",
"getBlockNum",
"(",
")",
";",
"for",
"(",
"int",
"su",
"=",
"0",
";",
"su",
"<",
"order",
";",
"su",
"++",
")",
"{",
"List",
"<",
"Integer",
">",
"residues",
"=",
"e",
".",
"getMultipleAlignment",
"(",
"0",
")",
".",
"getBlock",
"(",
"su",
")",
".",
"getAlignRes",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"b",
".",
"getAlignRes",
"(",
")",
".",
"add",
"(",
"residues",
")",
";",
"e",
".",
"getStructureIdentifiers",
"(",
")",
".",
"add",
"(",
"name",
")",
";",
"e",
".",
"getAtomArrays",
"(",
")",
".",
"add",
"(",
"atoms",
")",
";",
"}",
"e",
".",
"getMultipleAlignments",
"(",
")",
".",
"set",
"(",
"0",
",",
"result",
")",
";",
"result",
".",
"setEnsemble",
"(",
"e",
")",
";",
"CoreSuperimposer",
"imposer",
"=",
"new",
"CoreSuperimposer",
"(",
")",
";",
"imposer",
".",
"superimpose",
"(",
"result",
")",
";",
"updateSymmetryScores",
"(",
"result",
")",
";",
"return",
"result",
";",
"}"
] | Converts a refined symmetry AFPChain alignment into the standard
representation of symmetry in a MultipleAlignment, that contains the
entire Atom array of the strcuture and the symmetric repeats are orgaized
in different rows in a single Block.
@param symm
AFPChain created with a symmetry algorithm and refined
@param atoms
Atom array of the entire structure
@return MultipleAlignment format of the symmetry
@throws StructureException | [
"Converts",
"a",
"refined",
"symmetry",
"AFPChain",
"alignment",
"into",
"the",
"standard",
"representation",
"of",
"symmetry",
"in",
"a",
"MultipleAlignment",
"that",
"contains",
"the",
"entire",
"Atom",
"array",
"of",
"the",
"strcuture",
"and",
"the",
"symmetric",
"repeats",
"are",
"orgaized",
"in",
"different",
"rows",
"in",
"a",
"single",
"Block",
"."
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/utils/SymmetryTools.java#L651-L693 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.createCertificateAsync | public Observable<CertificateOperation> createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map<String, String> tags) {
"""
Creates a new certificate.
If this is the first version, the certificate resource is created. This operation requires the certificates/create permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param certificateName The name of the certificate.
@param certificatePolicy The management policy for the certificate.
@param certificateAttributes The attributes of the certificate (optional).
@param tags Application specific metadata in the form of key-value pairs.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CertificateOperation object
"""
return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).map(new Func1<ServiceResponse<CertificateOperation>, CertificateOperation>() {
@Override
public CertificateOperation call(ServiceResponse<CertificateOperation> response) {
return response.body();
}
});
} | java | public Observable<CertificateOperation> createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map<String, String> tags) {
return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).map(new Func1<ServiceResponse<CertificateOperation>, CertificateOperation>() {
@Override
public CertificateOperation call(ServiceResponse<CertificateOperation> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"CertificateOperation",
">",
"createCertificateAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"certificateName",
",",
"CertificatePolicy",
"certificatePolicy",
",",
"CertificateAttributes",
"certificateAttributes",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"return",
"createCertificateWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"certificateName",
",",
"certificatePolicy",
",",
"certificateAttributes",
",",
"tags",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"CertificateOperation",
">",
",",
"CertificateOperation",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CertificateOperation",
"call",
"(",
"ServiceResponse",
"<",
"CertificateOperation",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates a new certificate.
If this is the first version, the certificate resource is created. This operation requires the certificates/create permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param certificateName The name of the certificate.
@param certificatePolicy The management policy for the certificate.
@param certificateAttributes The attributes of the certificate (optional).
@param tags Application specific metadata in the form of key-value pairs.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CertificateOperation object | [
"Creates",
"a",
"new",
"certificate",
".",
"If",
"this",
"is",
"the",
"first",
"version",
"the",
"certificate",
"resource",
"is",
"created",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"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#L6612-L6619 |
couchbase/couchbase-lite-java | src/main/java/com/couchbase/lite/MutableDictionary.java | MutableDictionary.setDate | @NonNull
@Override
public MutableDictionary setDate(@NonNull String key, Date value) {
"""
Set a Date object for the given key.
@param key The key
@param value The Date object.
@return The self object.
"""
return setValue(key, value);
} | java | @NonNull
@Override
public MutableDictionary setDate(@NonNull String key, Date value) {
return setValue(key, value);
} | [
"@",
"NonNull",
"@",
"Override",
"public",
"MutableDictionary",
"setDate",
"(",
"@",
"NonNull",
"String",
"key",
",",
"Date",
"value",
")",
"{",
"return",
"setValue",
"(",
"key",
",",
"value",
")",
";",
"}"
] | Set a Date object for the given key.
@param key The key
@param value The Date object.
@return The self object. | [
"Set",
"a",
"Date",
"object",
"for",
"the",
"given",
"key",
"."
] | train | https://github.com/couchbase/couchbase-lite-java/blob/cb72c44186456e6191a9ad0a7feb310011d0b081/src/main/java/com/couchbase/lite/MutableDictionary.java#L221-L225 |
jboss/jboss-el-api_spec | src/main/java/javax/el/ELProcessor.java | ELProcessor.defineFunction | public void defineFunction(String prefix, String function, Method method)
throws NoSuchMethodException {
"""
Define an EL function in the local function mapper.
@param prefix The namespace for the function or "" for no namesapce.
@param function The name of the function.
If empty (""), the method name is used as the function name.
@param method The <code>java.lang.reflect.Method</code> instance of
the method that implements the function.
@throws NullPointerException if any of the arguments is null.
@throws NoSuchMethodException if the method is not a static method
"""
if (prefix == null || function == null || method == null) {
throw new NullPointerException("Null argument for defineFunction");
}
if (! Modifier.isStatic(method.getModifiers())) {
throw new NoSuchMethodException("The method specified in defineFunction must be static: " + method);
}
if (function.equals("")) {
function = method.getName();
}
elManager.mapFunction(prefix, function, method);
} | java | public void defineFunction(String prefix, String function, Method method)
throws NoSuchMethodException {
if (prefix == null || function == null || method == null) {
throw new NullPointerException("Null argument for defineFunction");
}
if (! Modifier.isStatic(method.getModifiers())) {
throw new NoSuchMethodException("The method specified in defineFunction must be static: " + method);
}
if (function.equals("")) {
function = method.getName();
}
elManager.mapFunction(prefix, function, method);
} | [
"public",
"void",
"defineFunction",
"(",
"String",
"prefix",
",",
"String",
"function",
",",
"Method",
"method",
")",
"throws",
"NoSuchMethodException",
"{",
"if",
"(",
"prefix",
"==",
"null",
"||",
"function",
"==",
"null",
"||",
"method",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Null argument for defineFunction\"",
")",
";",
"}",
"if",
"(",
"!",
"Modifier",
".",
"isStatic",
"(",
"method",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"The method specified in defineFunction must be static: \"",
"+",
"method",
")",
";",
"}",
"if",
"(",
"function",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"function",
"=",
"method",
".",
"getName",
"(",
")",
";",
"}",
"elManager",
".",
"mapFunction",
"(",
"prefix",
",",
"function",
",",
"method",
")",
";",
"}"
] | Define an EL function in the local function mapper.
@param prefix The namespace for the function or "" for no namesapce.
@param function The name of the function.
If empty (""), the method name is used as the function name.
@param method The <code>java.lang.reflect.Method</code> instance of
the method that implements the function.
@throws NullPointerException if any of the arguments is null.
@throws NoSuchMethodException if the method is not a static method | [
"Define",
"an",
"EL",
"function",
"in",
"the",
"local",
"function",
"mapper",
"."
] | train | https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELProcessor.java#L257-L269 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/PatternPool.java | PatternPool.get | public static Pattern get(String regex, int flags) {
"""
先从Pattern池中查找正则对应的{@link Pattern},找不到则编译正则表达式并入池。
@param regex 正则表达式
@param flags 正则标识位集合 {@link Pattern}
@return {@link Pattern}
"""
final RegexWithFlag regexWithFlag = new RegexWithFlag(regex, flags);
Pattern pattern = POOL.get(regexWithFlag);
if (null == pattern) {
pattern = Pattern.compile(regex, flags);
POOL.put(regexWithFlag, pattern);
}
return pattern;
} | java | public static Pattern get(String regex, int flags) {
final RegexWithFlag regexWithFlag = new RegexWithFlag(regex, flags);
Pattern pattern = POOL.get(regexWithFlag);
if (null == pattern) {
pattern = Pattern.compile(regex, flags);
POOL.put(regexWithFlag, pattern);
}
return pattern;
} | [
"public",
"static",
"Pattern",
"get",
"(",
"String",
"regex",
",",
"int",
"flags",
")",
"{",
"final",
"RegexWithFlag",
"regexWithFlag",
"=",
"new",
"RegexWithFlag",
"(",
"regex",
",",
"flags",
")",
";",
"Pattern",
"pattern",
"=",
"POOL",
".",
"get",
"(",
"regexWithFlag",
")",
";",
"if",
"(",
"null",
"==",
"pattern",
")",
"{",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"regex",
",",
"flags",
")",
";",
"POOL",
".",
"put",
"(",
"regexWithFlag",
",",
"pattern",
")",
";",
"}",
"return",
"pattern",
";",
"}"
] | 先从Pattern池中查找正则对应的{@link Pattern},找不到则编译正则表达式并入池。
@param regex 正则表达式
@param flags 正则标识位集合 {@link Pattern}
@return {@link Pattern} | [
"先从Pattern池中查找正则对应的",
"{",
"@link",
"Pattern",
"}",
",找不到则编译正则表达式并入池。"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/PatternPool.java#L82-L91 |
indeedeng/util | urlparsing/src/main/java/com/indeed/util/urlparsing/ParseUtils.java | ParseUtils.parseSignedInt | public static int parseSignedInt(CharSequence s, final int start, final int end) throws NumberFormatException {
"""
Parses out an int value from the provided string, equivalent to Integer.parseInt(s.substring(start, end)),
but has significantly less overhead, no object creation and later garbage collection required.
@throws {@link NumberFormatException} if it encounters any character that is not [-0-9].
"""
if (s.charAt(start) == '-') {
// negative!
return -parseUnsignedInt(s, start + 1, end);
} else {
return parseUnsignedInt(s, start, end);
}
} | java | public static int parseSignedInt(CharSequence s, final int start, final int end) throws NumberFormatException {
if (s.charAt(start) == '-') {
// negative!
return -parseUnsignedInt(s, start + 1, end);
} else {
return parseUnsignedInt(s, start, end);
}
} | [
"public",
"static",
"int",
"parseSignedInt",
"(",
"CharSequence",
"s",
",",
"final",
"int",
"start",
",",
"final",
"int",
"end",
")",
"throws",
"NumberFormatException",
"{",
"if",
"(",
"s",
".",
"charAt",
"(",
"start",
")",
"==",
"'",
"'",
")",
"{",
"// negative!",
"return",
"-",
"parseUnsignedInt",
"(",
"s",
",",
"start",
"+",
"1",
",",
"end",
")",
";",
"}",
"else",
"{",
"return",
"parseUnsignedInt",
"(",
"s",
",",
"start",
",",
"end",
")",
";",
"}",
"}"
] | Parses out an int value from the provided string, equivalent to Integer.parseInt(s.substring(start, end)),
but has significantly less overhead, no object creation and later garbage collection required.
@throws {@link NumberFormatException} if it encounters any character that is not [-0-9]. | [
"Parses",
"out",
"an",
"int",
"value",
"from",
"the",
"provided",
"string",
"equivalent",
"to",
"Integer",
".",
"parseInt",
"(",
"s",
".",
"substring",
"(",
"start",
"end",
"))",
"but",
"has",
"significantly",
"less",
"overhead",
"no",
"object",
"creation",
"and",
"later",
"garbage",
"collection",
"required",
"."
] | train | https://github.com/indeedeng/util/blob/332008426cf14b57e7fc3e817d9423e3f84fb922/urlparsing/src/main/java/com/indeed/util/urlparsing/ParseUtils.java#L31-L38 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServersInner.java | ServersInner.updateAsync | public Observable<ServerInner> updateAsync(String resourceGroupName, String serverName, ServerUpdate parameters) {
"""
Updates an existing server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param parameters The required parameters for updating a server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServerInner object
"""
return updateWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1<ServiceResponse<ServerInner>, ServerInner>() {
@Override
public ServerInner call(ServiceResponse<ServerInner> response) {
return response.body();
}
});
} | java | public Observable<ServerInner> updateAsync(String resourceGroupName, String serverName, ServerUpdate parameters) {
return updateWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1<ServiceResponse<ServerInner>, ServerInner>() {
@Override
public ServerInner call(ServiceResponse<ServerInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ServerInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"ServerUpdate",
"parameters",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ServerInner",
">",
",",
"ServerInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ServerInner",
"call",
"(",
"ServiceResponse",
"<",
"ServerInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates an existing server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param parameters The required parameters for updating a server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServerInner object | [
"Updates",
"an",
"existing",
"server",
"."
] | 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/ServersInner.java#L393-L400 |
Stratio/deep-spark | deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java | Cells.getLong | public Long getLong(String nameSpace, String cellName) {
"""
Returns the {@code Long} value of the {@link Cell} (associated to {@code table}) whose name iscellName, or null
if this Cells object contains no cell whose name is cellName.
@param nameSpace the name of the owning table
@param cellName the name of the Cell we want to retrieve from this Cells object.
@return the {@code Long} value of the {@link Cell} (associated to {@code table}) whose name is cellName, or null
if this Cells object contains no cell whose name is cellName
"""
return getValue(nameSpace, cellName, Long.class);
} | java | public Long getLong(String nameSpace, String cellName) {
return getValue(nameSpace, cellName, Long.class);
} | [
"public",
"Long",
"getLong",
"(",
"String",
"nameSpace",
",",
"String",
"cellName",
")",
"{",
"return",
"getValue",
"(",
"nameSpace",
",",
"cellName",
",",
"Long",
".",
"class",
")",
";",
"}"
] | Returns the {@code Long} value of the {@link Cell} (associated to {@code table}) whose name iscellName, or null
if this Cells object contains no cell whose name is cellName.
@param nameSpace the name of the owning table
@param cellName the name of the Cell we want to retrieve from this Cells object.
@return the {@code Long} value of the {@link Cell} (associated to {@code table}) whose name is cellName, or null
if this Cells object contains no cell whose name is cellName | [
"Returns",
"the",
"{",
"@code",
"Long",
"}",
"value",
"of",
"the",
"{",
"@link",
"Cell",
"}",
"(",
"associated",
"to",
"{",
"@code",
"table",
"}",
")",
"whose",
"name",
"iscellName",
"or",
"null",
"if",
"this",
"Cells",
"object",
"contains",
"no",
"cell",
"whose",
"name",
"is",
"cellName",
"."
] | train | https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java#L1123-L1125 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureUtilities.java | FeatureUtilities.doVectorize | @SuppressWarnings("unchecked")
public static Collection<Polygon> doVectorize( GridCoverage2D src, Map<String, Object> args ) {
"""
Helper function to run the Vectorize operation with given parameters and
retrieve the vectors.
@param src the source {@link GridCoverage2D}.
@param args a {@code Map} of parameter names and values or <code>null</code>.
@return the generated vectors as JTS Polygons
"""
if (args == null) {
args = new HashMap<String, Object>();
}
ParameterBlockJAI pb = new ParameterBlockJAI("Vectorize");
pb.setSource("source0", src.getRenderedImage());
// Set any parameters that were passed in
for( Entry<String, Object> e : args.entrySet() ) {
pb.setParameter(e.getKey(), e.getValue());
}
// Get the desintation image: this is the unmodified source image data
// plus a property for the generated vectors
RenderedOp dest = JAI.create("Vectorize", pb);
// Get the vectors
Collection<Polygon> polygons = (Collection<Polygon>) dest.getProperty(VectorizeDescriptor.VECTOR_PROPERTY_NAME);
RegionMap regionParams = CoverageUtilities.getRegionParamsFromGridCoverage(src);
double xRes = regionParams.getXres();
double yRes = regionParams.getYres();
final AffineTransform mt2D = (AffineTransform) src.getGridGeometry().getGridToCRS2D(PixelOrientation.CENTER);
final AffineTransformation jtsTransformation = new AffineTransformation(mt2D.getScaleX(), mt2D.getShearX(),
mt2D.getTranslateX() - xRes / 2.0, mt2D.getShearY(), mt2D.getScaleY(), mt2D.getTranslateY() + yRes / 2.0);
for( Polygon polygon : polygons ) {
polygon.apply(jtsTransformation);
}
return polygons;
} | java | @SuppressWarnings("unchecked")
public static Collection<Polygon> doVectorize( GridCoverage2D src, Map<String, Object> args ) {
if (args == null) {
args = new HashMap<String, Object>();
}
ParameterBlockJAI pb = new ParameterBlockJAI("Vectorize");
pb.setSource("source0", src.getRenderedImage());
// Set any parameters that were passed in
for( Entry<String, Object> e : args.entrySet() ) {
pb.setParameter(e.getKey(), e.getValue());
}
// Get the desintation image: this is the unmodified source image data
// plus a property for the generated vectors
RenderedOp dest = JAI.create("Vectorize", pb);
// Get the vectors
Collection<Polygon> polygons = (Collection<Polygon>) dest.getProperty(VectorizeDescriptor.VECTOR_PROPERTY_NAME);
RegionMap regionParams = CoverageUtilities.getRegionParamsFromGridCoverage(src);
double xRes = regionParams.getXres();
double yRes = regionParams.getYres();
final AffineTransform mt2D = (AffineTransform) src.getGridGeometry().getGridToCRS2D(PixelOrientation.CENTER);
final AffineTransformation jtsTransformation = new AffineTransformation(mt2D.getScaleX(), mt2D.getShearX(),
mt2D.getTranslateX() - xRes / 2.0, mt2D.getShearY(), mt2D.getScaleY(), mt2D.getTranslateY() + yRes / 2.0);
for( Polygon polygon : polygons ) {
polygon.apply(jtsTransformation);
}
return polygons;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Collection",
"<",
"Polygon",
">",
"doVectorize",
"(",
"GridCoverage2D",
"src",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"args",
")",
"{",
"if",
"(",
"args",
"==",
"null",
")",
"{",
"args",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"}",
"ParameterBlockJAI",
"pb",
"=",
"new",
"ParameterBlockJAI",
"(",
"\"Vectorize\"",
")",
";",
"pb",
".",
"setSource",
"(",
"\"source0\"",
",",
"src",
".",
"getRenderedImage",
"(",
")",
")",
";",
"// Set any parameters that were passed in",
"for",
"(",
"Entry",
"<",
"String",
",",
"Object",
">",
"e",
":",
"args",
".",
"entrySet",
"(",
")",
")",
"{",
"pb",
".",
"setParameter",
"(",
"e",
".",
"getKey",
"(",
")",
",",
"e",
".",
"getValue",
"(",
")",
")",
";",
"}",
"// Get the desintation image: this is the unmodified source image data",
"// plus a property for the generated vectors",
"RenderedOp",
"dest",
"=",
"JAI",
".",
"create",
"(",
"\"Vectorize\"",
",",
"pb",
")",
";",
"// Get the vectors",
"Collection",
"<",
"Polygon",
">",
"polygons",
"=",
"(",
"Collection",
"<",
"Polygon",
">",
")",
"dest",
".",
"getProperty",
"(",
"VectorizeDescriptor",
".",
"VECTOR_PROPERTY_NAME",
")",
";",
"RegionMap",
"regionParams",
"=",
"CoverageUtilities",
".",
"getRegionParamsFromGridCoverage",
"(",
"src",
")",
";",
"double",
"xRes",
"=",
"regionParams",
".",
"getXres",
"(",
")",
";",
"double",
"yRes",
"=",
"regionParams",
".",
"getYres",
"(",
")",
";",
"final",
"AffineTransform",
"mt2D",
"=",
"(",
"AffineTransform",
")",
"src",
".",
"getGridGeometry",
"(",
")",
".",
"getGridToCRS2D",
"(",
"PixelOrientation",
".",
"CENTER",
")",
";",
"final",
"AffineTransformation",
"jtsTransformation",
"=",
"new",
"AffineTransformation",
"(",
"mt2D",
".",
"getScaleX",
"(",
")",
",",
"mt2D",
".",
"getShearX",
"(",
")",
",",
"mt2D",
".",
"getTranslateX",
"(",
")",
"-",
"xRes",
"/",
"2.0",
",",
"mt2D",
".",
"getShearY",
"(",
")",
",",
"mt2D",
".",
"getScaleY",
"(",
")",
",",
"mt2D",
".",
"getTranslateY",
"(",
")",
"+",
"yRes",
"/",
"2.0",
")",
";",
"for",
"(",
"Polygon",
"polygon",
":",
"polygons",
")",
"{",
"polygon",
".",
"apply",
"(",
"jtsTransformation",
")",
";",
"}",
"return",
"polygons",
";",
"}"
] | Helper function to run the Vectorize operation with given parameters and
retrieve the vectors.
@param src the source {@link GridCoverage2D}.
@param args a {@code Map} of parameter names and values or <code>null</code>.
@return the generated vectors as JTS Polygons | [
"Helper",
"function",
"to",
"run",
"the",
"Vectorize",
"operation",
"with",
"given",
"parameters",
"and",
"retrieve",
"the",
"vectors",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureUtilities.java#L729-L760 |
kubernetes-client/java | kubernetes/src/main/java/io/kubernetes/client/ApiClient.java | ApiClient.buildRequestBodyMultipart | public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) {
"""
Build a multipart (file uploading) request body with the given form parameters,
which could contain text fields and file fields.
@param formParams Form parameters in the form of Map
@return RequestBody
"""
MultipartBuilder mpBuilder = new MultipartBuilder().type(MultipartBuilder.FORM);
for (Entry<String, Object> param : formParams.entrySet()) {
if (param.getValue() instanceof File) {
File file = (File) param.getValue();
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\"");
MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file));
mpBuilder.addPart(partHeaders, RequestBody.create(mediaType, file));
} else {
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"");
mpBuilder.addPart(partHeaders, RequestBody.create(null, parameterToString(param.getValue())));
}
}
return mpBuilder.build();
} | java | public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) {
MultipartBuilder mpBuilder = new MultipartBuilder().type(MultipartBuilder.FORM);
for (Entry<String, Object> param : formParams.entrySet()) {
if (param.getValue() instanceof File) {
File file = (File) param.getValue();
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\"");
MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file));
mpBuilder.addPart(partHeaders, RequestBody.create(mediaType, file));
} else {
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"");
mpBuilder.addPart(partHeaders, RequestBody.create(null, parameterToString(param.getValue())));
}
}
return mpBuilder.build();
} | [
"public",
"RequestBody",
"buildRequestBodyMultipart",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"formParams",
")",
"{",
"MultipartBuilder",
"mpBuilder",
"=",
"new",
"MultipartBuilder",
"(",
")",
".",
"type",
"(",
"MultipartBuilder",
".",
"FORM",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"Object",
">",
"param",
":",
"formParams",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"param",
".",
"getValue",
"(",
")",
"instanceof",
"File",
")",
"{",
"File",
"file",
"=",
"(",
"File",
")",
"param",
".",
"getValue",
"(",
")",
";",
"Headers",
"partHeaders",
"=",
"Headers",
".",
"of",
"(",
"\"Content-Disposition\"",
",",
"\"form-data; name=\\\"\"",
"+",
"param",
".",
"getKey",
"(",
")",
"+",
"\"\\\"; filename=\\\"\"",
"+",
"file",
".",
"getName",
"(",
")",
"+",
"\"\\\"\"",
")",
";",
"MediaType",
"mediaType",
"=",
"MediaType",
".",
"parse",
"(",
"guessContentTypeFromFile",
"(",
"file",
")",
")",
";",
"mpBuilder",
".",
"addPart",
"(",
"partHeaders",
",",
"RequestBody",
".",
"create",
"(",
"mediaType",
",",
"file",
")",
")",
";",
"}",
"else",
"{",
"Headers",
"partHeaders",
"=",
"Headers",
".",
"of",
"(",
"\"Content-Disposition\"",
",",
"\"form-data; name=\\\"\"",
"+",
"param",
".",
"getKey",
"(",
")",
"+",
"\"\\\"\"",
")",
";",
"mpBuilder",
".",
"addPart",
"(",
"partHeaders",
",",
"RequestBody",
".",
"create",
"(",
"null",
",",
"parameterToString",
"(",
"param",
".",
"getValue",
"(",
")",
")",
")",
")",
";",
"}",
"}",
"return",
"mpBuilder",
".",
"build",
"(",
")",
";",
"}"
] | Build a multipart (file uploading) request body with the given form parameters,
which could contain text fields and file fields.
@param formParams Form parameters in the form of Map
@return RequestBody | [
"Build",
"a",
"multipart",
"(",
"file",
"uploading",
")",
"request",
"body",
"with",
"the",
"given",
"form",
"parameters",
"which",
"could",
"contain",
"text",
"fields",
"and",
"file",
"fields",
"."
] | train | https://github.com/kubernetes-client/java/blob/7413e98bd904f09d1ad00fb60e8c6ff787f3f560/kubernetes/src/main/java/io/kubernetes/client/ApiClient.java#L1072-L1086 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/lang/ServiceLoaderHelper.java | ServiceLoaderHelper.getAllSPIImplementations | @Nonnull
@ReturnsMutableCopy
public static <T> ICommonsList <T> getAllSPIImplementations (@Nonnull final Class <T> aSPIClass,
@Nonnull final ClassLoader aClassLoader) {
"""
Uses the {@link ServiceLoader} to load all SPI implementations of the
passed class
@param <T>
The implementation type to be loaded
@param aSPIClass
The SPI interface class. May not be <code>null</code>.
@param aClassLoader
The class loader to use for the SPI loader. May not be
<code>null</code>.
@return A list of all currently available plugins
"""
return getAllSPIImplementations (aSPIClass, aClassLoader, null);
} | java | @Nonnull
@ReturnsMutableCopy
public static <T> ICommonsList <T> getAllSPIImplementations (@Nonnull final Class <T> aSPIClass,
@Nonnull final ClassLoader aClassLoader)
{
return getAllSPIImplementations (aSPIClass, aClassLoader, null);
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"<",
"T",
">",
"ICommonsList",
"<",
"T",
">",
"getAllSPIImplementations",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"T",
">",
"aSPIClass",
",",
"@",
"Nonnull",
"final",
"ClassLoader",
"aClassLoader",
")",
"{",
"return",
"getAllSPIImplementations",
"(",
"aSPIClass",
",",
"aClassLoader",
",",
"null",
")",
";",
"}"
] | Uses the {@link ServiceLoader} to load all SPI implementations of the
passed class
@param <T>
The implementation type to be loaded
@param aSPIClass
The SPI interface class. May not be <code>null</code>.
@param aClassLoader
The class loader to use for the SPI loader. May not be
<code>null</code>.
@return A list of all currently available plugins | [
"Uses",
"the",
"{",
"@link",
"ServiceLoader",
"}",
"to",
"load",
"all",
"SPI",
"implementations",
"of",
"the",
"passed",
"class"
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/lang/ServiceLoaderHelper.java#L83-L89 |
podio/podio-java | src/main/java/com/podio/app/AppAPI.java | AppAPI.updateOrder | public void updateOrder(int spaceId, List<Integer> appIds) {
"""
Updates the order of the apps on the space. It should post all the apps
from the space in the order required.
@param spaceId
The id of the space the apps are on
@param appIds
The ids of the apps in the new order
"""
getResourceFactory().getApiResource("/app/space/" + spaceId + "/order")
.entity(appIds, MediaType.APPLICATION_JSON_TYPE).put();
} | java | public void updateOrder(int spaceId, List<Integer> appIds) {
getResourceFactory().getApiResource("/app/space/" + spaceId + "/order")
.entity(appIds, MediaType.APPLICATION_JSON_TYPE).put();
} | [
"public",
"void",
"updateOrder",
"(",
"int",
"spaceId",
",",
"List",
"<",
"Integer",
">",
"appIds",
")",
"{",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/app/space/\"",
"+",
"spaceId",
"+",
"\"/order\"",
")",
".",
"entity",
"(",
"appIds",
",",
"MediaType",
".",
"APPLICATION_JSON_TYPE",
")",
".",
"put",
"(",
")",
";",
"}"
] | Updates the order of the apps on the space. It should post all the apps
from the space in the order required.
@param spaceId
The id of the space the apps are on
@param appIds
The ids of the apps in the new order | [
"Updates",
"the",
"order",
"of",
"the",
"apps",
"on",
"the",
"space",
".",
"It",
"should",
"post",
"all",
"the",
"apps",
"from",
"the",
"space",
"in",
"the",
"order",
"required",
"."
] | train | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/app/AppAPI.java#L206-L209 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/xml/Ra10XmlGen.java | Ra10XmlGen.writeOutbound | private void writeOutbound(Definition def, Writer out, int indent) throws IOException {
"""
Output outbound xml part
@param def definition
@param out Writer
@param indent space number
@throws IOException ioException
"""
writeIndent(out, indent);
out.write("<managedconnectionfactory-class>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getMcfClass() + "</managedconnectionfactory-class>");
writeEol(out);
writeEol(out);
if (!def.getMcfDefs().get(0).isUseCciConnection())
{
writeIndent(out, indent);
out.write("<connectionfactory-interface>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getCfInterfaceClass() + "</connectionfactory-interface>");
writeEol(out);
writeIndent(out, indent);
out.write("<connectionfactory-impl-class>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getCfClass() + "</connectionfactory-impl-class>");
writeEol(out);
writeIndent(out, indent);
out.write("<connection-interface>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getConnInterfaceClass() + "</connection-interface>");
writeEol(out);
writeIndent(out, indent);
out.write("<connection-impl-class>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getConnImplClass() + "</connection-impl-class>");
writeEol(out);
}
else
{
writeIndent(out, indent);
out.write("<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>");
writeEol(out);
writeIndent(out, indent);
out.write("<connectionfactory-impl-class>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getCciConnFactoryClass() + "</connectionfactory-impl-class>");
writeEol(out);
writeIndent(out, indent);
out.write("<connection-interface>javax.resource.cci.Connection</connection-interface>");
writeEol(out);
writeIndent(out, indent);
out.write("<connection-impl-class>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getCciConnClass() + "</connection-impl-class>");
writeEol(out);
}
writeEol(out);
writeIndent(out, indent);
out.write("<transaction-support>" + def.getSupportTransaction() + "</transaction-support>");
writeEol(out);
writeConfigPropsXml(def.getMcfDefs().get(0).getMcfConfigProps(), out, indent);
writeIndent(out, indent);
out.write("<reauthentication-support>" + def.isSupportReauthen() + "</reauthentication-support>");
writeEol(out);
} | java | private void writeOutbound(Definition def, Writer out, int indent) throws IOException
{
writeIndent(out, indent);
out.write("<managedconnectionfactory-class>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getMcfClass() + "</managedconnectionfactory-class>");
writeEol(out);
writeEol(out);
if (!def.getMcfDefs().get(0).isUseCciConnection())
{
writeIndent(out, indent);
out.write("<connectionfactory-interface>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getCfInterfaceClass() + "</connectionfactory-interface>");
writeEol(out);
writeIndent(out, indent);
out.write("<connectionfactory-impl-class>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getCfClass() + "</connectionfactory-impl-class>");
writeEol(out);
writeIndent(out, indent);
out.write("<connection-interface>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getConnInterfaceClass() + "</connection-interface>");
writeEol(out);
writeIndent(out, indent);
out.write("<connection-impl-class>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getConnImplClass() + "</connection-impl-class>");
writeEol(out);
}
else
{
writeIndent(out, indent);
out.write("<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>");
writeEol(out);
writeIndent(out, indent);
out.write("<connectionfactory-impl-class>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getCciConnFactoryClass() + "</connectionfactory-impl-class>");
writeEol(out);
writeIndent(out, indent);
out.write("<connection-interface>javax.resource.cci.Connection</connection-interface>");
writeEol(out);
writeIndent(out, indent);
out.write("<connection-impl-class>" + def.getRaPackage() + "." +
def.getMcfDefs().get(0).getCciConnClass() + "</connection-impl-class>");
writeEol(out);
}
writeEol(out);
writeIndent(out, indent);
out.write("<transaction-support>" + def.getSupportTransaction() + "</transaction-support>");
writeEol(out);
writeConfigPropsXml(def.getMcfDefs().get(0).getMcfConfigProps(), out, indent);
writeIndent(out, indent);
out.write("<reauthentication-support>" + def.isSupportReauthen() + "</reauthentication-support>");
writeEol(out);
} | [
"private",
"void",
"writeOutbound",
"(",
"Definition",
"def",
",",
"Writer",
"out",
",",
"int",
"indent",
")",
"throws",
"IOException",
"{",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<managedconnectionfactory-class>\"",
"+",
"def",
".",
"getRaPackage",
"(",
")",
"+",
"\".\"",
"+",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getMcfClass",
"(",
")",
"+",
"\"</managedconnectionfactory-class>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"if",
"(",
"!",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"isUseCciConnection",
"(",
")",
")",
"{",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<connectionfactory-interface>\"",
"+",
"def",
".",
"getRaPackage",
"(",
")",
"+",
"\".\"",
"+",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getCfInterfaceClass",
"(",
")",
"+",
"\"</connectionfactory-interface>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<connectionfactory-impl-class>\"",
"+",
"def",
".",
"getRaPackage",
"(",
")",
"+",
"\".\"",
"+",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getCfClass",
"(",
")",
"+",
"\"</connectionfactory-impl-class>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<connection-interface>\"",
"+",
"def",
".",
"getRaPackage",
"(",
")",
"+",
"\".\"",
"+",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getConnInterfaceClass",
"(",
")",
"+",
"\"</connection-interface>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<connection-impl-class>\"",
"+",
"def",
".",
"getRaPackage",
"(",
")",
"+",
"\".\"",
"+",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getConnImplClass",
"(",
")",
"+",
"\"</connection-impl-class>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"}",
"else",
"{",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<connectionfactory-impl-class>\"",
"+",
"def",
".",
"getRaPackage",
"(",
")",
"+",
"\".\"",
"+",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getCciConnFactoryClass",
"(",
")",
"+",
"\"</connectionfactory-impl-class>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<connection-interface>javax.resource.cci.Connection</connection-interface>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<connection-impl-class>\"",
"+",
"def",
".",
"getRaPackage",
"(",
")",
"+",
"\".\"",
"+",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getCciConnClass",
"(",
")",
"+",
"\"</connection-impl-class>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"}",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<transaction-support>\"",
"+",
"def",
".",
"getSupportTransaction",
"(",
")",
"+",
"\"</transaction-support>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeConfigPropsXml",
"(",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getMcfConfigProps",
"(",
")",
",",
"out",
",",
"indent",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<reauthentication-support>\"",
"+",
"def",
".",
"isSupportReauthen",
"(",
")",
"+",
"\"</reauthentication-support>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"}"
] | Output outbound xml part
@param def definition
@param out Writer
@param indent space number
@throws IOException ioException | [
"Output",
"outbound",
"xml",
"part"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/xml/Ra10XmlGen.java#L117-L172 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachineScaleSetsInner.java | VirtualMachineScaleSetsInner.listSkusWithServiceResponseAsync | public Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>> listSkusWithServiceResponseAsync(final String resourceGroupName, final String vmScaleSetName) {
"""
Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU.
@param resourceGroupName The name of the resource group.
@param vmScaleSetName The name of the VM scale set.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<VirtualMachineScaleSetSkuInner> object
"""
return listSkusSinglePageAsync(resourceGroupName, vmScaleSetName)
.concatMap(new Func1<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>, Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>> call(ServiceResponse<Page<VirtualMachineScaleSetSkuInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listSkusNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>> listSkusWithServiceResponseAsync(final String resourceGroupName, final String vmScaleSetName) {
return listSkusSinglePageAsync(resourceGroupName, vmScaleSetName)
.concatMap(new Func1<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>, Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>> call(ServiceResponse<Page<VirtualMachineScaleSetSkuInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listSkusNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"VirtualMachineScaleSetSkuInner",
">",
">",
">",
"listSkusWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"vmScaleSetName",
")",
"{",
"return",
"listSkusSinglePageAsync",
"(",
"resourceGroupName",
",",
"vmScaleSetName",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"VirtualMachineScaleSetSkuInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"VirtualMachineScaleSetSkuInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"VirtualMachineScaleSetSkuInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"VirtualMachineScaleSetSkuInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listSkusNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU.
@param resourceGroupName The name of the resource group.
@param vmScaleSetName The name of the VM scale set.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<VirtualMachineScaleSetSkuInner> object | [
"Gets",
"a",
"list",
"of",
"SKUs",
"available",
"for",
"your",
"VM",
"scale",
"set",
"including",
"the",
"minimum",
"and",
"maximum",
"VM",
"instances",
"allowed",
"for",
"each",
"SKU",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachineScaleSetsInner.java#L1660-L1672 |
lecousin/java-framework-core | net.lecousin.core/src/main/java/net/lecousin/framework/util/ProcessUtil.java | ProcessUtil.consumeProcessConsole | public static void consumeProcessConsole(Process process, Listener<String> outputListener, Listener<String> errorListener) {
"""
Launch 2 threads to consume both output and error streams, and call the listeners for each line read.
"""
Application app = LCCore.getApplication();
ThreadFactory factory = app.getThreadFactory();
Thread t;
ConsoleConsumer cc;
cc = new ConsoleConsumer(process.getInputStream(), outputListener);
t = factory.newThread(cc);
t.setName("Process output console consumer");
cc.app = app;
cc.t = t;
t.start();
app.toInterruptOnShutdown(t);
cc = new ConsoleConsumer(process.getErrorStream(), errorListener);
t = factory.newThread(cc);
t.setName("Process error console consumer");
cc.app = app;
cc.t = t;
t.start();
app.toInterruptOnShutdown(t);
} | java | public static void consumeProcessConsole(Process process, Listener<String> outputListener, Listener<String> errorListener) {
Application app = LCCore.getApplication();
ThreadFactory factory = app.getThreadFactory();
Thread t;
ConsoleConsumer cc;
cc = new ConsoleConsumer(process.getInputStream(), outputListener);
t = factory.newThread(cc);
t.setName("Process output console consumer");
cc.app = app;
cc.t = t;
t.start();
app.toInterruptOnShutdown(t);
cc = new ConsoleConsumer(process.getErrorStream(), errorListener);
t = factory.newThread(cc);
t.setName("Process error console consumer");
cc.app = app;
cc.t = t;
t.start();
app.toInterruptOnShutdown(t);
} | [
"public",
"static",
"void",
"consumeProcessConsole",
"(",
"Process",
"process",
",",
"Listener",
"<",
"String",
">",
"outputListener",
",",
"Listener",
"<",
"String",
">",
"errorListener",
")",
"{",
"Application",
"app",
"=",
"LCCore",
".",
"getApplication",
"(",
")",
";",
"ThreadFactory",
"factory",
"=",
"app",
".",
"getThreadFactory",
"(",
")",
";",
"Thread",
"t",
";",
"ConsoleConsumer",
"cc",
";",
"cc",
"=",
"new",
"ConsoleConsumer",
"(",
"process",
".",
"getInputStream",
"(",
")",
",",
"outputListener",
")",
";",
"t",
"=",
"factory",
".",
"newThread",
"(",
"cc",
")",
";",
"t",
".",
"setName",
"(",
"\"Process output console consumer\"",
")",
";",
"cc",
".",
"app",
"=",
"app",
";",
"cc",
".",
"t",
"=",
"t",
";",
"t",
".",
"start",
"(",
")",
";",
"app",
".",
"toInterruptOnShutdown",
"(",
"t",
")",
";",
"cc",
"=",
"new",
"ConsoleConsumer",
"(",
"process",
".",
"getErrorStream",
"(",
")",
",",
"errorListener",
")",
";",
"t",
"=",
"factory",
".",
"newThread",
"(",
"cc",
")",
";",
"t",
".",
"setName",
"(",
"\"Process error console consumer\"",
")",
";",
"cc",
".",
"app",
"=",
"app",
";",
"cc",
".",
"t",
"=",
"t",
";",
"t",
".",
"start",
"(",
")",
";",
"app",
".",
"toInterruptOnShutdown",
"(",
"t",
")",
";",
"}"
] | Launch 2 threads to consume both output and error streams, and call the listeners for each line read. | [
"Launch",
"2",
"threads",
"to",
"consume",
"both",
"output",
"and",
"error",
"streams",
"and",
"call",
"the",
"listeners",
"for",
"each",
"line",
"read",
"."
] | train | https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/util/ProcessUtil.java#L37-L56 |
timols/java-gitlab-api | src/main/java/org/gitlab/api/GitlabAPI.java | GitlabAPI.deleteTag | public void deleteTag(GitlabProject project, String tagName) throws IOException {
"""
Delete tag in specific project
@param project
@param tagName
@throws IOException on gitlab api call error
"""
String tailUrl = GitlabProject.URL + "/" + project + GitlabTag.URL + "/" + tagName;
retrieve().method(DELETE).to(tailUrl, Void.class);
} | java | public void deleteTag(GitlabProject project, String tagName) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project + GitlabTag.URL + "/" + tagName;
retrieve().method(DELETE).to(tailUrl, Void.class);
} | [
"public",
"void",
"deleteTag",
"(",
"GitlabProject",
"project",
",",
"String",
"tagName",
")",
"throws",
"IOException",
"{",
"String",
"tailUrl",
"=",
"GitlabProject",
".",
"URL",
"+",
"\"/\"",
"+",
"project",
"+",
"GitlabTag",
".",
"URL",
"+",
"\"/\"",
"+",
"tagName",
";",
"retrieve",
"(",
")",
".",
"method",
"(",
"DELETE",
")",
".",
"to",
"(",
"tailUrl",
",",
"Void",
".",
"class",
")",
";",
"}"
] | Delete tag in specific project
@param project
@param tagName
@throws IOException on gitlab api call error | [
"Delete",
"tag",
"in",
"specific",
"project"
] | train | https://github.com/timols/java-gitlab-api/blob/f03eedf952cfbb40306be3bf9234dcf78fab029e/src/main/java/org/gitlab/api/GitlabAPI.java#L3439-L3442 |
IBM/ibm-cos-sdk-java | ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/s3/internal/crypto/S3CryptoModuleBase.java | S3CryptoModuleBase.newContentCryptoMaterial | private ContentCryptoMaterial newContentCryptoMaterial(
EncryptionMaterialsProvider kekMaterialProvider,
Provider provider, AmazonWebServiceRequest req) {
"""
Returns a non-null content encryption material generated with the given kek
material and security providers.
@throws SdkClientException if no encryption material can be found from
the given encryption material provider.
"""
EncryptionMaterials kekMaterials = kekMaterialProvider.getEncryptionMaterials();
if (kekMaterials == null)
throw new SdkClientException("No material available from the encryption material provider");
return buildContentCryptoMaterial(kekMaterials, provider, req);
} | java | private ContentCryptoMaterial newContentCryptoMaterial(
EncryptionMaterialsProvider kekMaterialProvider,
Provider provider, AmazonWebServiceRequest req) {
EncryptionMaterials kekMaterials = kekMaterialProvider.getEncryptionMaterials();
if (kekMaterials == null)
throw new SdkClientException("No material available from the encryption material provider");
return buildContentCryptoMaterial(kekMaterials, provider, req);
} | [
"private",
"ContentCryptoMaterial",
"newContentCryptoMaterial",
"(",
"EncryptionMaterialsProvider",
"kekMaterialProvider",
",",
"Provider",
"provider",
",",
"AmazonWebServiceRequest",
"req",
")",
"{",
"EncryptionMaterials",
"kekMaterials",
"=",
"kekMaterialProvider",
".",
"getEncryptionMaterials",
"(",
")",
";",
"if",
"(",
"kekMaterials",
"==",
"null",
")",
"throw",
"new",
"SdkClientException",
"(",
"\"No material available from the encryption material provider\"",
")",
";",
"return",
"buildContentCryptoMaterial",
"(",
"kekMaterials",
",",
"provider",
",",
"req",
")",
";",
"}"
] | Returns a non-null content encryption material generated with the given kek
material and security providers.
@throws SdkClientException if no encryption material can be found from
the given encryption material provider. | [
"Returns",
"a",
"non",
"-",
"null",
"content",
"encryption",
"material",
"generated",
"with",
"the",
"given",
"kek",
"material",
"and",
"security",
"providers",
"."
] | train | https://github.com/IBM/ibm-cos-sdk-java/blob/d0bb2dd754c328a05e7dba8dc42e28b271b6daf2/ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/s3/internal/crypto/S3CryptoModuleBase.java#L485-L492 |
CenturyLinkCloud/mdw | mdw-hub/src/com/centurylink/mdw/hub/servlet/SoapServlet.java | SoapServlet.createSoapFaultResponse | protected String createSoapFaultResponse(String message)
throws SOAPException, TransformerException {
"""
Original API (Defaults to using MessageFactory.newInstance(), i.e. SOAP
1.1)
@param message
@return Soap fault as string
@throws SOAPException
@throws TransformerException
"""
return createSoapFaultResponse(SOAPConstants.SOAP_1_1_PROTOCOL, null, message);
} | java | protected String createSoapFaultResponse(String message)
throws SOAPException, TransformerException {
return createSoapFaultResponse(SOAPConstants.SOAP_1_1_PROTOCOL, null, message);
} | [
"protected",
"String",
"createSoapFaultResponse",
"(",
"String",
"message",
")",
"throws",
"SOAPException",
",",
"TransformerException",
"{",
"return",
"createSoapFaultResponse",
"(",
"SOAPConstants",
".",
"SOAP_1_1_PROTOCOL",
",",
"null",
",",
"message",
")",
";",
"}"
] | Original API (Defaults to using MessageFactory.newInstance(), i.e. SOAP
1.1)
@param message
@return Soap fault as string
@throws SOAPException
@throws TransformerException | [
"Original",
"API",
"(",
"Defaults",
"to",
"using",
"MessageFactory",
".",
"newInstance",
"()",
"i",
".",
"e",
".",
"SOAP",
"1",
".",
"1",
")"
] | train | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-hub/src/com/centurylink/mdw/hub/servlet/SoapServlet.java#L376-L379 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/metadata/URLMatchingUtils.java | URLMatchingUtils.isPathNameMatch | public static boolean isPathNameMatch(String uri, String urlPattern) {
"""
Determine if the urlPattern is a path name match for the uri.
@param uri
@param urlPattern
@return
"""
if (urlPattern.startsWith("/") && urlPattern.endsWith("/*")) {
String s = urlPattern.substring(0, urlPattern.length() - 1);
/**
* First case,urlPattern
* /a/b/c/ matches /a/b/c/*
**/
if (s.equalsIgnoreCase(uri)) {
return true;
}
/**
* Second case
* /a/b/c matches /a/b/c/*
**/
if (uri.equalsIgnoreCase(s.substring(0, s.length() - 1))) {
return true;
}
/**
* Third case
* /a/b/c/d/e matches /a/b/c/*
**/
if (uri.startsWith(s)) {
return true;
}
}
return false;
} | java | public static boolean isPathNameMatch(String uri, String urlPattern) {
if (urlPattern.startsWith("/") && urlPattern.endsWith("/*")) {
String s = urlPattern.substring(0, urlPattern.length() - 1);
/**
* First case,urlPattern
* /a/b/c/ matches /a/b/c/*
**/
if (s.equalsIgnoreCase(uri)) {
return true;
}
/**
* Second case
* /a/b/c matches /a/b/c/*
**/
if (uri.equalsIgnoreCase(s.substring(0, s.length() - 1))) {
return true;
}
/**
* Third case
* /a/b/c/d/e matches /a/b/c/*
**/
if (uri.startsWith(s)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isPathNameMatch",
"(",
"String",
"uri",
",",
"String",
"urlPattern",
")",
"{",
"if",
"(",
"urlPattern",
".",
"startsWith",
"(",
"\"/\"",
")",
"&&",
"urlPattern",
".",
"endsWith",
"(",
"\"/*\"",
")",
")",
"{",
"String",
"s",
"=",
"urlPattern",
".",
"substring",
"(",
"0",
",",
"urlPattern",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"/**\n * First case,urlPattern\n * /a/b/c/ matches /a/b/c/*\n **/",
"if",
"(",
"s",
".",
"equalsIgnoreCase",
"(",
"uri",
")",
")",
"{",
"return",
"true",
";",
"}",
"/**\n * Second case\n * /a/b/c matches /a/b/c/*\n **/",
"if",
"(",
"uri",
".",
"equalsIgnoreCase",
"(",
"s",
".",
"substring",
"(",
"0",
",",
"s",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"/**\n * Third case\n * /a/b/c/d/e matches /a/b/c/*\n **/",
"if",
"(",
"uri",
".",
"startsWith",
"(",
"s",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Determine if the urlPattern is a path name match for the uri.
@param uri
@param urlPattern
@return | [
"Determine",
"if",
"the",
"urlPattern",
"is",
"a",
"path",
"name",
"match",
"for",
"the",
"uri",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/metadata/URLMatchingUtils.java#L85-L113 |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/util/SliceInput.java | SliceInput.readBytes | public int readBytes(GatheringByteChannel out, int length)
throws IOException {
"""
Transfers this buffer's data to the specified stream starting at the
current {@code position}.
@param length the maximum number of bytes to transfer
@return the actual number of bytes written out to the specified channel
@throws IndexOutOfBoundsException if {@code length} is greater than {@code this.available()}
@throws java.io.IOException if the specified channel threw an exception during I/O
"""
int readBytes = slice.getBytes(position, out, length);
position += readBytes;
return readBytes;
} | java | public int readBytes(GatheringByteChannel out, int length)
throws IOException
{
int readBytes = slice.getBytes(position, out, length);
position += readBytes;
return readBytes;
} | [
"public",
"int",
"readBytes",
"(",
"GatheringByteChannel",
"out",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"int",
"readBytes",
"=",
"slice",
".",
"getBytes",
"(",
"position",
",",
"out",
",",
"length",
")",
";",
"position",
"+=",
"readBytes",
";",
"return",
"readBytes",
";",
"}"
] | Transfers this buffer's data to the specified stream starting at the
current {@code position}.
@param length the maximum number of bytes to transfer
@return the actual number of bytes written out to the specified channel
@throws IndexOutOfBoundsException if {@code length} is greater than {@code this.available()}
@throws java.io.IOException if the specified channel threw an exception during I/O | [
"Transfers",
"this",
"buffer",
"s",
"data",
"to",
"the",
"specified",
"stream",
"starting",
"at",
"the",
"current",
"{",
"@code",
"position",
"}",
"."
] | train | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/util/SliceInput.java#L349-L355 |
joniles/mpxj | src/main/java/net/sf/mpxj/Task.java | Task.setBaselineStart | public void setBaselineStart(int baselineNumber, Date value) {
"""
Set a baseline value.
@param baselineNumber baseline index (1-10)
@param value baseline value
"""
set(selectField(TaskFieldLists.BASELINE_STARTS, baselineNumber), value);
} | java | public void setBaselineStart(int baselineNumber, Date value)
{
set(selectField(TaskFieldLists.BASELINE_STARTS, baselineNumber), value);
} | [
"public",
"void",
"setBaselineStart",
"(",
"int",
"baselineNumber",
",",
"Date",
"value",
")",
"{",
"set",
"(",
"selectField",
"(",
"TaskFieldLists",
".",
"BASELINE_STARTS",
",",
"baselineNumber",
")",
",",
"value",
")",
";",
"}"
] | Set a baseline value.
@param baselineNumber baseline index (1-10)
@param value baseline value | [
"Set",
"a",
"baseline",
"value",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4013-L4016 |
iipc/webarchive-commons | src/main/java/org/archive/format/text/charset/CharsetDetector.java | CharsetDetector.getCharsetFromMeta | protected String getCharsetFromMeta(byte buffer[],int len) throws IOException {
"""
Attempt to find a META tag in the HTML that hints at the character set
used to write the document.
@param resource
@return String character set found from META tags in the HTML
@throws IOException
"""
String charsetName = null;
// convert to UTF-8 String -- which hopefully will not mess up the
// characters we're interested in...
String sample = new String(buffer,0,len,DEFAULT_CHARSET);
String metaContentType = findMetaContentType(sample);
if(metaContentType != null) {
charsetName = contentTypeToCharset(metaContentType);
}
return charsetName;
} | java | protected String getCharsetFromMeta(byte buffer[],int len) throws IOException {
String charsetName = null;
// convert to UTF-8 String -- which hopefully will not mess up the
// characters we're interested in...
String sample = new String(buffer,0,len,DEFAULT_CHARSET);
String metaContentType = findMetaContentType(sample);
if(metaContentType != null) {
charsetName = contentTypeToCharset(metaContentType);
}
return charsetName;
} | [
"protected",
"String",
"getCharsetFromMeta",
"(",
"byte",
"buffer",
"[",
"]",
",",
"int",
"len",
")",
"throws",
"IOException",
"{",
"String",
"charsetName",
"=",
"null",
";",
"// convert to UTF-8 String -- which hopefully will not mess up the",
"// characters we're interested in...",
"String",
"sample",
"=",
"new",
"String",
"(",
"buffer",
",",
"0",
",",
"len",
",",
"DEFAULT_CHARSET",
")",
";",
"String",
"metaContentType",
"=",
"findMetaContentType",
"(",
"sample",
")",
";",
"if",
"(",
"metaContentType",
"!=",
"null",
")",
"{",
"charsetName",
"=",
"contentTypeToCharset",
"(",
"metaContentType",
")",
";",
"}",
"return",
"charsetName",
";",
"}"
] | Attempt to find a META tag in the HTML that hints at the character set
used to write the document.
@param resource
@return String character set found from META tags in the HTML
@throws IOException | [
"Attempt",
"to",
"find",
"a",
"META",
"tag",
"in",
"the",
"HTML",
"that",
"hints",
"at",
"the",
"character",
"set",
"used",
"to",
"write",
"the",
"document",
"."
] | train | https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/format/text/charset/CharsetDetector.java#L168-L179 |
line/centraldogma | client/java-armeria/src/main/java/com/linecorp/centraldogma/client/armeria/AbstractArmeriaCentralDogmaBuilder.java | AbstractArmeriaCentralDogmaBuilder.newClientBuilder | protected final ClientBuilder newClientBuilder(String uri, Consumer<ClientBuilder> customizer) {
"""
Returns a newly created {@link ClientBuilder} configured with the specified {@code customizer}
and then with the {@link ArmeriaClientConfigurator} specified with
{@link #clientConfigurator(ArmeriaClientConfigurator)}.
"""
final ClientBuilder builder = new ClientBuilder(uri);
customizer.accept(builder);
clientConfigurator.configure(builder);
builder.factory(clientFactory());
return builder;
} | java | protected final ClientBuilder newClientBuilder(String uri, Consumer<ClientBuilder> customizer) {
final ClientBuilder builder = new ClientBuilder(uri);
customizer.accept(builder);
clientConfigurator.configure(builder);
builder.factory(clientFactory());
return builder;
} | [
"protected",
"final",
"ClientBuilder",
"newClientBuilder",
"(",
"String",
"uri",
",",
"Consumer",
"<",
"ClientBuilder",
">",
"customizer",
")",
"{",
"final",
"ClientBuilder",
"builder",
"=",
"new",
"ClientBuilder",
"(",
"uri",
")",
";",
"customizer",
".",
"accept",
"(",
"builder",
")",
";",
"clientConfigurator",
".",
"configure",
"(",
"builder",
")",
";",
"builder",
".",
"factory",
"(",
"clientFactory",
"(",
")",
")",
";",
"return",
"builder",
";",
"}"
] | Returns a newly created {@link ClientBuilder} configured with the specified {@code customizer}
and then with the {@link ArmeriaClientConfigurator} specified with
{@link #clientConfigurator(ArmeriaClientConfigurator)}. | [
"Returns",
"a",
"newly",
"created",
"{"
] | train | https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/client/java-armeria/src/main/java/com/linecorp/centraldogma/client/armeria/AbstractArmeriaCentralDogmaBuilder.java#L203-L209 |
qiniu/android-sdk | library/src/main/java/com/qiniu/android/http/MultipartBody.java | MultipartBody.appendQuotedString | static StringBuilder appendQuotedString(StringBuilder target, String key) {
"""
Appends a quoted-string to a StringBuilder.
<p>RFC 2388 is rather vague about how one should escape special characters in form-data
parameters, and as it turns out Firefox and Chrome actually do rather different things, and
both say in their comments that they're not really sure what the right approach is. We go with
Chrome's behavior (which also experimentally seems to match what IE does), but if you actually
want to have a good chance of things working, please avoid double-quotes, newlines, percent
signs, and the like in your field names.
"""
target.append('"');
for (int i = 0, len = key.length(); i < len; i++) {
char ch = key.charAt(i);
switch (ch) {
case '\n':
target.append("%0A");
break;
case '\r':
target.append("%0D");
break;
case '"':
target.append("%22");
break;
default:
target.append(ch);
break;
}
}
target.append('"');
return target;
} | java | static StringBuilder appendQuotedString(StringBuilder target, String key) {
target.append('"');
for (int i = 0, len = key.length(); i < len; i++) {
char ch = key.charAt(i);
switch (ch) {
case '\n':
target.append("%0A");
break;
case '\r':
target.append("%0D");
break;
case '"':
target.append("%22");
break;
default:
target.append(ch);
break;
}
}
target.append('"');
return target;
} | [
"static",
"StringBuilder",
"appendQuotedString",
"(",
"StringBuilder",
"target",
",",
"String",
"key",
")",
"{",
"target",
".",
"append",
"(",
"'",
"'",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"len",
"=",
"key",
".",
"length",
"(",
")",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"char",
"ch",
"=",
"key",
".",
"charAt",
"(",
"i",
")",
";",
"switch",
"(",
"ch",
")",
"{",
"case",
"'",
"'",
":",
"target",
".",
"append",
"(",
"\"%0A\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"target",
".",
"append",
"(",
"\"%0D\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"target",
".",
"append",
"(",
"\"%22\"",
")",
";",
"break",
";",
"default",
":",
"target",
".",
"append",
"(",
"ch",
")",
";",
"break",
";",
"}",
"}",
"target",
".",
"append",
"(",
"'",
"'",
")",
";",
"return",
"target",
";",
"}"
] | Appends a quoted-string to a StringBuilder.
<p>RFC 2388 is rather vague about how one should escape special characters in form-data
parameters, and as it turns out Firefox and Chrome actually do rather different things, and
both say in their comments that they're not really sure what the right approach is. We go with
Chrome's behavior (which also experimentally seems to match what IE does), but if you actually
want to have a good chance of things working, please avoid double-quotes, newlines, percent
signs, and the like in your field names. | [
"Appends",
"a",
"quoted",
"-",
"string",
"to",
"a",
"StringBuilder",
"."
] | train | https://github.com/qiniu/android-sdk/blob/dbd2a01fb3bff7a5e75e8934bbf81713124d8466/library/src/main/java/com/qiniu/android/http/MultipartBody.java#L97-L118 |
joniles/mpxj | src/main/java/net/sf/mpxj/merlin/MerlinReader.java | MerlinReader.getNodeList | private NodeList getNodeList(String document, XPathExpression expression) throws Exception {
"""
Retrieve a node list based on an XPath expression.
@param document XML document to process
@param expression compiled XPath expression
@return node list
"""
Document doc = m_documentBuilder.parse(new InputSource(new StringReader(document)));
return (NodeList) expression.evaluate(doc, XPathConstants.NODESET);
} | java | private NodeList getNodeList(String document, XPathExpression expression) throws Exception
{
Document doc = m_documentBuilder.parse(new InputSource(new StringReader(document)));
return (NodeList) expression.evaluate(doc, XPathConstants.NODESET);
} | [
"private",
"NodeList",
"getNodeList",
"(",
"String",
"document",
",",
"XPathExpression",
"expression",
")",
"throws",
"Exception",
"{",
"Document",
"doc",
"=",
"m_documentBuilder",
".",
"parse",
"(",
"new",
"InputSource",
"(",
"new",
"StringReader",
"(",
"document",
")",
")",
")",
";",
"return",
"(",
"NodeList",
")",
"expression",
".",
"evaluate",
"(",
"doc",
",",
"XPathConstants",
".",
"NODESET",
")",
";",
"}"
] | Retrieve a node list based on an XPath expression.
@param document XML document to process
@param expression compiled XPath expression
@return node list | [
"Retrieve",
"a",
"node",
"list",
"based",
"on",
"an",
"XPath",
"expression",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/merlin/MerlinReader.java#L666-L670 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/locking/InMemoryLockMapImpl.java | InMemoryLockMapImpl.addReader | public boolean addReader(TransactionImpl tx, Object obj) {
"""
Add a reader lock entry for transaction tx on object obj
to the persistent storage.
"""
checkTimedOutLocks();
Identity oid = new Identity(obj,getBroker());
LockEntry reader = new LockEntry(oid.toString(),
tx.getGUID(),
System.currentTimeMillis(),
LockStrategyFactory.getIsolationLevel(obj),
LockEntry.LOCK_READ);
addReaderInternal(reader);
return true;
} | java | public boolean addReader(TransactionImpl tx, Object obj)
{
checkTimedOutLocks();
Identity oid = new Identity(obj,getBroker());
LockEntry reader = new LockEntry(oid.toString(),
tx.getGUID(),
System.currentTimeMillis(),
LockStrategyFactory.getIsolationLevel(obj),
LockEntry.LOCK_READ);
addReaderInternal(reader);
return true;
} | [
"public",
"boolean",
"addReader",
"(",
"TransactionImpl",
"tx",
",",
"Object",
"obj",
")",
"{",
"checkTimedOutLocks",
"(",
")",
";",
"Identity",
"oid",
"=",
"new",
"Identity",
"(",
"obj",
",",
"getBroker",
"(",
")",
")",
";",
"LockEntry",
"reader",
"=",
"new",
"LockEntry",
"(",
"oid",
".",
"toString",
"(",
")",
",",
"tx",
".",
"getGUID",
"(",
")",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
",",
"LockStrategyFactory",
".",
"getIsolationLevel",
"(",
"obj",
")",
",",
"LockEntry",
".",
"LOCK_READ",
")",
";",
"addReaderInternal",
"(",
"reader",
")",
";",
"return",
"true",
";",
"}"
] | Add a reader lock entry for transaction tx on object obj
to the persistent storage. | [
"Add",
"a",
"reader",
"lock",
"entry",
"for",
"transaction",
"tx",
"on",
"object",
"obj",
"to",
"the",
"persistent",
"storage",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/locking/InMemoryLockMapImpl.java#L132-L145 |
SonarSource/sonarqube | server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java | MyBatis.newScrollingSelectStatement | public PreparedStatement newScrollingSelectStatement(DbSession session, String sql) {
"""
Create a PreparedStatement for SELECT requests with scrolling of results
"""
int fetchSize = database.getDialect().getScrollDefaultFetchSize();
return newScrollingSelectStatement(session, sql, fetchSize);
} | java | public PreparedStatement newScrollingSelectStatement(DbSession session, String sql) {
int fetchSize = database.getDialect().getScrollDefaultFetchSize();
return newScrollingSelectStatement(session, sql, fetchSize);
} | [
"public",
"PreparedStatement",
"newScrollingSelectStatement",
"(",
"DbSession",
"session",
",",
"String",
"sql",
")",
"{",
"int",
"fetchSize",
"=",
"database",
".",
"getDialect",
"(",
")",
".",
"getScrollDefaultFetchSize",
"(",
")",
";",
"return",
"newScrollingSelectStatement",
"(",
"session",
",",
"sql",
",",
"fetchSize",
")",
";",
"}"
] | Create a PreparedStatement for SELECT requests with scrolling of results | [
"Create",
"a",
"PreparedStatement",
"for",
"SELECT",
"requests",
"with",
"scrolling",
"of",
"results"
] | train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java#L312-L315 |
PistoiaHELM/HELM2NotationToolkit | src/main/java/org/helm/notation2/tools/HELM2NotationUtils.java | HELM2NotationUtils.section2 | private static void section2(List<ConnectionNotation> connections, Map<String, String> mapIds) throws NotationException {
"""
method to add ConnectionNotation to the existent
@param connections ConnectionNotatoin
@param mapIds Map of old and new Ids
@throws NotationException if notation is not valid
"""
for (ConnectionNotation connection : connections) {
HELMEntity first = connection.getSourceId();
String idFirst = first.getId();
HELMEntity second = connection.getTargetId();
String idSecond = second.getId();
if (mapIds.containsKey(idFirst)) {
first = new ConnectionNotation(mapIds.get(idFirst)).getSourceId();
}
if (mapIds.containsKey(idSecond)) {
second = new ConnectionNotation(mapIds.get(idSecond)).getSourceId();
}
ConnectionNotation newConnection = new ConnectionNotation(first, second, connection.getSourceUnit(), connection.getrGroupSource(), connection.getTargetUnit(), connection.getrGroupTarget(),
connection.getAnnotation());
helm2notation.addConnection(newConnection);
}
} | java | private static void section2(List<ConnectionNotation> connections, Map<String, String> mapIds) throws NotationException {
for (ConnectionNotation connection : connections) {
HELMEntity first = connection.getSourceId();
String idFirst = first.getId();
HELMEntity second = connection.getTargetId();
String idSecond = second.getId();
if (mapIds.containsKey(idFirst)) {
first = new ConnectionNotation(mapIds.get(idFirst)).getSourceId();
}
if (mapIds.containsKey(idSecond)) {
second = new ConnectionNotation(mapIds.get(idSecond)).getSourceId();
}
ConnectionNotation newConnection = new ConnectionNotation(first, second, connection.getSourceUnit(), connection.getrGroupSource(), connection.getTargetUnit(), connection.getrGroupTarget(),
connection.getAnnotation());
helm2notation.addConnection(newConnection);
}
} | [
"private",
"static",
"void",
"section2",
"(",
"List",
"<",
"ConnectionNotation",
">",
"connections",
",",
"Map",
"<",
"String",
",",
"String",
">",
"mapIds",
")",
"throws",
"NotationException",
"{",
"for",
"(",
"ConnectionNotation",
"connection",
":",
"connections",
")",
"{",
"HELMEntity",
"first",
"=",
"connection",
".",
"getSourceId",
"(",
")",
";",
"String",
"idFirst",
"=",
"first",
".",
"getId",
"(",
")",
";",
"HELMEntity",
"second",
"=",
"connection",
".",
"getTargetId",
"(",
")",
";",
"String",
"idSecond",
"=",
"second",
".",
"getId",
"(",
")",
";",
"if",
"(",
"mapIds",
".",
"containsKey",
"(",
"idFirst",
")",
")",
"{",
"first",
"=",
"new",
"ConnectionNotation",
"(",
"mapIds",
".",
"get",
"(",
"idFirst",
")",
")",
".",
"getSourceId",
"(",
")",
";",
"}",
"if",
"(",
"mapIds",
".",
"containsKey",
"(",
"idSecond",
")",
")",
"{",
"second",
"=",
"new",
"ConnectionNotation",
"(",
"mapIds",
".",
"get",
"(",
"idSecond",
")",
")",
".",
"getSourceId",
"(",
")",
";",
"}",
"ConnectionNotation",
"newConnection",
"=",
"new",
"ConnectionNotation",
"(",
"first",
",",
"second",
",",
"connection",
".",
"getSourceUnit",
"(",
")",
",",
"connection",
".",
"getrGroupSource",
"(",
")",
",",
"connection",
".",
"getTargetUnit",
"(",
")",
",",
"connection",
".",
"getrGroupTarget",
"(",
")",
",",
"connection",
".",
"getAnnotation",
"(",
")",
")",
";",
"helm2notation",
".",
"addConnection",
"(",
"newConnection",
")",
";",
"}",
"}"
] | method to add ConnectionNotation to the existent
@param connections ConnectionNotatoin
@param mapIds Map of old and new Ids
@throws NotationException if notation is not valid | [
"method",
"to",
"add",
"ConnectionNotation",
"to",
"the",
"existent"
] | train | https://github.com/PistoiaHELM/HELM2NotationToolkit/blob/ac5bb01fd5b4082134a8ef226bbe2ff0f60fcd38/src/main/java/org/helm/notation2/tools/HELM2NotationUtils.java#L273-L296 |
lettuce-io/lettuce-core | src/main/java/io/lettuce/core/cluster/topology/TopologyComparators.java | TopologyComparators.isChanged | public static boolean isChanged(Partitions o1, Partitions o2) {
"""
Check if properties changed which are essential for cluster operations.
@param o1 the first object to be compared.
@param o2 the second object to be compared.
@return {@literal true} if {@code MASTER} or {@code SLAVE} flags changed or the responsible slots changed.
"""
if (o1.size() != o2.size()) {
return true;
}
for (RedisClusterNode base : o2) {
if (!essentiallyEqualsTo(base, o1.getPartitionByNodeId(base.getNodeId()))) {
return true;
}
}
return false;
} | java | public static boolean isChanged(Partitions o1, Partitions o2) {
if (o1.size() != o2.size()) {
return true;
}
for (RedisClusterNode base : o2) {
if (!essentiallyEqualsTo(base, o1.getPartitionByNodeId(base.getNodeId()))) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isChanged",
"(",
"Partitions",
"o1",
",",
"Partitions",
"o2",
")",
"{",
"if",
"(",
"o1",
".",
"size",
"(",
")",
"!=",
"o2",
".",
"size",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"for",
"(",
"RedisClusterNode",
"base",
":",
"o2",
")",
"{",
"if",
"(",
"!",
"essentiallyEqualsTo",
"(",
"base",
",",
"o1",
".",
"getPartitionByNodeId",
"(",
"base",
".",
"getNodeId",
"(",
")",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check if properties changed which are essential for cluster operations.
@param o1 the first object to be compared.
@param o2 the second object to be compared.
@return {@literal true} if {@code MASTER} or {@code SLAVE} flags changed or the responsible slots changed. | [
"Check",
"if",
"properties",
"changed",
"which",
"are",
"essential",
"for",
"cluster",
"operations",
"."
] | train | https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/cluster/topology/TopologyComparators.java#L121-L134 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/termofuse/TermOfUsePanel.java | TermOfUsePanel.newRightsAndDutiesPanel | protected Component newRightsAndDutiesPanel(final String id,
final IModel<RightsAndDutiesModelBean> model) {
"""
Factory method for creating the new {@link Component} for the rights and duties. This method
is invoked in the constructor from the derived classes and can be overridden so users can
provide their own version of a new {@link Component} for the rights and duties.
@param id
the id
@param model
the model
@return the new {@link Component} for the rights and duties
"""
return new RightsAndDutiesPanel(id, model);
} | java | protected Component newRightsAndDutiesPanel(final String id,
final IModel<RightsAndDutiesModelBean> model)
{
return new RightsAndDutiesPanel(id, model);
} | [
"protected",
"Component",
"newRightsAndDutiesPanel",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"RightsAndDutiesModelBean",
">",
"model",
")",
"{",
"return",
"new",
"RightsAndDutiesPanel",
"(",
"id",
",",
"model",
")",
";",
"}"
] | Factory method for creating the new {@link Component} for the rights and duties. This method
is invoked in the constructor from the derived classes and can be overridden so users can
provide their own version of a new {@link Component} for the rights and duties.
@param id
the id
@param model
the model
@return the new {@link Component} for the rights and duties | [
"Factory",
"method",
"for",
"creating",
"the",
"new",
"{",
"@link",
"Component",
"}",
"for",
"the",
"rights",
"and",
"duties",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"new",
"{",
"@link",
"Component",
"}",
"for",
"the",
"rights",
"and",
"duties",
"."
] | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/termofuse/TermOfUsePanel.java#L347-L351 |
webmetrics/browsermob-proxy | src/main/java/org/browsermob/proxy/jetty/html/TableForm.java | TableForm.addButton | public Input addButton(String tag,
String label) {
"""
Add a Submit Button.
@param tag The form name of the element
@param label The label for the Button
"""
if (buttons==null)
buttonsAtBottom();
Input e = new Input(Input.Submit,tag,label);
if (extendRow)
addField(null,e);
else
buttons.add(e);
return e;
} | java | public Input addButton(String tag,
String label)
{
if (buttons==null)
buttonsAtBottom();
Input e = new Input(Input.Submit,tag,label);
if (extendRow)
addField(null,e);
else
buttons.add(e);
return e;
} | [
"public",
"Input",
"addButton",
"(",
"String",
"tag",
",",
"String",
"label",
")",
"{",
"if",
"(",
"buttons",
"==",
"null",
")",
"buttonsAtBottom",
"(",
")",
";",
"Input",
"e",
"=",
"new",
"Input",
"(",
"Input",
".",
"Submit",
",",
"tag",
",",
"label",
")",
";",
"if",
"(",
"extendRow",
")",
"addField",
"(",
"null",
",",
"e",
")",
";",
"else",
"buttons",
".",
"add",
"(",
"e",
")",
";",
"return",
"e",
";",
"}"
] | Add a Submit Button.
@param tag The form name of the element
@param label The label for the Button | [
"Add",
"a",
"Submit",
"Button",
"."
] | train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/browsermob/proxy/jetty/html/TableForm.java#L263-L275 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java | SimpleDocTreeVisitor.visitUnknownBlockTag | @Override
public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
"""
{@inheritDoc} This implementation calls {@code defaultAction}.
@param node {@inheritDoc}
@param p {@inheritDoc}
@return the result of {@code defaultAction}
"""
return defaultAction(node, p);
} | java | @Override
public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
return defaultAction(node, p);
} | [
"@",
"Override",
"public",
"R",
"visitUnknownBlockTag",
"(",
"UnknownBlockTagTree",
"node",
",",
"P",
"p",
")",
"{",
"return",
"defaultAction",
"(",
"node",
",",
"p",
")",
";",
"}"
] | {@inheritDoc} This implementation calls {@code defaultAction}.
@param node {@inheritDoc}
@param p {@inheritDoc}
@return the result of {@code defaultAction} | [
"{",
"@inheritDoc",
"}",
"This",
"implementation",
"calls",
"{",
"@code",
"defaultAction",
"}",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java#L429-L432 |
kopihao/peasy-recyclerview | peasy-recyclerview/src/main/java/com/kopirealm/peasyrecyclerview/PeasyViewHolder.java | PeasyViewHolder.inflateView | public static View inflateView(LayoutInflater inflater, ViewGroup parent, int layoutId) {
"""
Static method to help inflate parent view with layoutId
@param inflater inflater
@param parent parent
@param layoutId layoutId
@return View
"""
return inflater.inflate(layoutId, parent, false);
} | java | public static View inflateView(LayoutInflater inflater, ViewGroup parent, int layoutId) {
return inflater.inflate(layoutId, parent, false);
} | [
"public",
"static",
"View",
"inflateView",
"(",
"LayoutInflater",
"inflater",
",",
"ViewGroup",
"parent",
",",
"int",
"layoutId",
")",
"{",
"return",
"inflater",
".",
"inflate",
"(",
"layoutId",
",",
"parent",
",",
"false",
")",
";",
"}"
] | Static method to help inflate parent view with layoutId
@param inflater inflater
@param parent parent
@param layoutId layoutId
@return View | [
"Static",
"method",
"to",
"help",
"inflate",
"parent",
"view",
"with",
"layoutId"
] | train | https://github.com/kopihao/peasy-recyclerview/blob/a26071849e5d5b5b1febe685f205558b49908f87/peasy-recyclerview/src/main/java/com/kopirealm/peasyrecyclerview/PeasyViewHolder.java#L25-L27 |
dkpro/dkpro-jwpl | de.tudarmstadt.ukp.wikipedia.revisionmachine/src/main/java/de/tudarmstadt/ukp/wikipedia/revisionmachine/difftool/consumer/dump/codec/TimedSQLEncoder.java | TimedSQLEncoder.encodeDiff | protected String encodeDiff(final Task<Diff> task, final Diff diff)
throws ConfigurationException, UnsupportedEncodingException,
DecodingException, EncodingException, SQLConsumerException {
"""
Encodes the diff.
@param task
Reference to the DiffTask
@param diff
Diff to encode
@return Base 64 encoded Diff
@throws ConfigurationException
if an error occurred while accessing the configuration
@throws UnsupportedEncodingException
if the character encoding is unsupported
@throws DecodingException
if the decoding failed
@throws EncodingException
if the encoding failed
@throws SQLConsumerException
if an error occurred while encoding the diff
"""
String encoding = super.encodeDiff(task, diff);
this.encodedSize += encoding.length();
return encoding;
} | java | protected String encodeDiff(final Task<Diff> task, final Diff diff)
throws ConfigurationException, UnsupportedEncodingException,
DecodingException, EncodingException, SQLConsumerException
{
String encoding = super.encodeDiff(task, diff);
this.encodedSize += encoding.length();
return encoding;
} | [
"protected",
"String",
"encodeDiff",
"(",
"final",
"Task",
"<",
"Diff",
">",
"task",
",",
"final",
"Diff",
"diff",
")",
"throws",
"ConfigurationException",
",",
"UnsupportedEncodingException",
",",
"DecodingException",
",",
"EncodingException",
",",
"SQLConsumerException",
"{",
"String",
"encoding",
"=",
"super",
".",
"encodeDiff",
"(",
"task",
",",
"diff",
")",
";",
"this",
".",
"encodedSize",
"+=",
"encoding",
".",
"length",
"(",
")",
";",
"return",
"encoding",
";",
"}"
] | Encodes the diff.
@param task
Reference to the DiffTask
@param diff
Diff to encode
@return Base 64 encoded Diff
@throws ConfigurationException
if an error occurred while accessing the configuration
@throws UnsupportedEncodingException
if the character encoding is unsupported
@throws DecodingException
if the decoding failed
@throws EncodingException
if the encoding failed
@throws SQLConsumerException
if an error occurred while encoding the diff | [
"Encodes",
"the",
"diff",
"."
] | train | https://github.com/dkpro/dkpro-jwpl/blob/0a0304b6a0aa13acc18838957994e06dd4613a58/de.tudarmstadt.ukp.wikipedia.revisionmachine/src/main/java/de/tudarmstadt/ukp/wikipedia/revisionmachine/difftool/consumer/dump/codec/TimedSQLEncoder.java#L121-L131 |
igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java | AgentSession.setStatus | public void setStatus(Presence.Mode presenceMode, int maxChats) throws XMPPException, SmackException, InterruptedException {
"""
Sets the agent's current status with the workgroup. The presence mode affects
how offers are routed to the agent. The possible presence modes with their
meanings are as follows:<ul>
<li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more chats
(equivalent to Presence.Mode.CHAT).
<li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be disturbed.
However, special case, or extreme urgency chats may still be offered to the agent.
<li>Presence.Mode.AWAY -- the agent is not available and should not
have a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY).</ul>
The max chats value is the maximum number of chats the agent is willing to have
routed to them at once. Some servers may be configured to only accept max chat
values in a certain range; for example, between two and five. In that case, the
maxChats value the agent sends may be adjusted by the server to a value within that
range.
@param presenceMode the presence mode of the agent.
@param maxChats the maximum number of chats the agent is willing to accept.
@throws XMPPException if an error occurs setting the agent status.
@throws SmackException
@throws InterruptedException
@throws IllegalStateException if the agent is not online with the workgroup.
"""
setStatus(presenceMode, maxChats, null);
} | java | public void setStatus(Presence.Mode presenceMode, int maxChats) throws XMPPException, SmackException, InterruptedException {
setStatus(presenceMode, maxChats, null);
} | [
"public",
"void",
"setStatus",
"(",
"Presence",
".",
"Mode",
"presenceMode",
",",
"int",
"maxChats",
")",
"throws",
"XMPPException",
",",
"SmackException",
",",
"InterruptedException",
"{",
"setStatus",
"(",
"presenceMode",
",",
"maxChats",
",",
"null",
")",
";",
"}"
] | Sets the agent's current status with the workgroup. The presence mode affects
how offers are routed to the agent. The possible presence modes with their
meanings are as follows:<ul>
<li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more chats
(equivalent to Presence.Mode.CHAT).
<li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be disturbed.
However, special case, or extreme urgency chats may still be offered to the agent.
<li>Presence.Mode.AWAY -- the agent is not available and should not
have a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY).</ul>
The max chats value is the maximum number of chats the agent is willing to have
routed to them at once. Some servers may be configured to only accept max chat
values in a certain range; for example, between two and five. In that case, the
maxChats value the agent sends may be adjusted by the server to a value within that
range.
@param presenceMode the presence mode of the agent.
@param maxChats the maximum number of chats the agent is willing to accept.
@throws XMPPException if an error occurs setting the agent status.
@throws SmackException
@throws InterruptedException
@throws IllegalStateException if the agent is not online with the workgroup. | [
"Sets",
"the",
"agent",
"s",
"current",
"status",
"with",
"the",
"workgroup",
".",
"The",
"presence",
"mode",
"affects",
"how",
"offers",
"are",
"routed",
"to",
"the",
"agent",
".",
"The",
"possible",
"presence",
"modes",
"with",
"their",
"meanings",
"are",
"as",
"follows",
":",
"<ul",
">"
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L389-L391 |
rnorth/visible-assertions | src/main/java/org/rnorth/visibleassertions/VisibleAssertions.java | VisibleAssertions.assertNull | public static void assertNull(String message, Object o) {
"""
Assert that a value is null.
<p>
If the assertion passes, a green tick will be shown. If the assertion fails, a red cross will be shown.
@param message message to display alongside the assertion outcome
@param o value to test
"""
if (o == null) {
pass(message);
} else {
fail(message, "'" + o + "' is not null");
}
} | java | public static void assertNull(String message, Object o) {
if (o == null) {
pass(message);
} else {
fail(message, "'" + o + "' is not null");
}
} | [
"public",
"static",
"void",
"assertNull",
"(",
"String",
"message",
",",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"pass",
"(",
"message",
")",
";",
"}",
"else",
"{",
"fail",
"(",
"message",
",",
"\"'\"",
"+",
"o",
"+",
"\"' is not null\"",
")",
";",
"}",
"}"
] | Assert that a value is null.
<p>
If the assertion passes, a green tick will be shown. If the assertion fails, a red cross will be shown.
@param message message to display alongside the assertion outcome
@param o value to test | [
"Assert",
"that",
"a",
"value",
"is",
"null",
".",
"<p",
">",
"If",
"the",
"assertion",
"passes",
"a",
"green",
"tick",
"will",
"be",
"shown",
".",
"If",
"the",
"assertion",
"fails",
"a",
"red",
"cross",
"will",
"be",
"shown",
"."
] | train | https://github.com/rnorth/visible-assertions/blob/6d7a7724db40ac0e9f87279553f814b790310b3b/src/main/java/org/rnorth/visibleassertions/VisibleAssertions.java#L279-L285 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/Matrices.java | Matrices.getRotationJAMA | public static Matrix getRotationJAMA(Matrix4d transform) {
"""
Convert a transformation matrix into a JAMA rotation matrix. Because the
JAMA matrix is a pre-multiplication matrix and the Vecmath matrix is a
post-multiplication one, the rotation matrix is transposed to ensure that
the transformation they produce is the same.
@param transform
Matrix4d with transposed rotation matrix
@return rotation matrix as JAMA object
"""
Matrix rot = new Matrix(3, 3);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
rot.set(j, i, transform.getElement(i, j)); // transposed
}
}
return rot;
} | java | public static Matrix getRotationJAMA(Matrix4d transform) {
Matrix rot = new Matrix(3, 3);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
rot.set(j, i, transform.getElement(i, j)); // transposed
}
}
return rot;
} | [
"public",
"static",
"Matrix",
"getRotationJAMA",
"(",
"Matrix4d",
"transform",
")",
"{",
"Matrix",
"rot",
"=",
"new",
"Matrix",
"(",
"3",
",",
"3",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"3",
";",
"j",
"++",
")",
"{",
"rot",
".",
"set",
"(",
"j",
",",
"i",
",",
"transform",
".",
"getElement",
"(",
"i",
",",
"j",
")",
")",
";",
"// transposed",
"}",
"}",
"return",
"rot",
";",
"}"
] | Convert a transformation matrix into a JAMA rotation matrix. Because the
JAMA matrix is a pre-multiplication matrix and the Vecmath matrix is a
post-multiplication one, the rotation matrix is transposed to ensure that
the transformation they produce is the same.
@param transform
Matrix4d with transposed rotation matrix
@return rotation matrix as JAMA object | [
"Convert",
"a",
"transformation",
"matrix",
"into",
"a",
"JAMA",
"rotation",
"matrix",
".",
"Because",
"the",
"JAMA",
"matrix",
"is",
"a",
"pre",
"-",
"multiplication",
"matrix",
"and",
"the",
"Vecmath",
"matrix",
"is",
"a",
"post",
"-",
"multiplication",
"one",
"the",
"rotation",
"matrix",
"is",
"transposed",
"to",
"ensure",
"that",
"the",
"transformation",
"they",
"produce",
"is",
"the",
"same",
"."
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/Matrices.java#L54-L63 |
codelibs/fess | src/main/java/org/codelibs/fess/mylasta/action/FessMessages.java | FessMessages.addConstraintsDigitsMessage | public FessMessages addConstraintsDigitsMessage(String property, String fraction, String integer) {
"""
Add the created action message for the key 'constraints.Digits.message' with parameters.
<pre>
message: {item} is numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected).
</pre>
@param property The property name for the message. (NotNull)
@param fraction The parameter fraction for message. (NotNull)
@param integer The parameter integer for message. (NotNull)
@return this. (NotNull)
"""
assertPropertyNotNull(property);
add(property, new UserMessage(CONSTRAINTS_Digits_MESSAGE, fraction, integer));
return this;
} | java | public FessMessages addConstraintsDigitsMessage(String property, String fraction, String integer) {
assertPropertyNotNull(property);
add(property, new UserMessage(CONSTRAINTS_Digits_MESSAGE, fraction, integer));
return this;
} | [
"public",
"FessMessages",
"addConstraintsDigitsMessage",
"(",
"String",
"property",
",",
"String",
"fraction",
",",
"String",
"integer",
")",
"{",
"assertPropertyNotNull",
"(",
"property",
")",
";",
"add",
"(",
"property",
",",
"new",
"UserMessage",
"(",
"CONSTRAINTS_Digits_MESSAGE",
",",
"fraction",
",",
"integer",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add the created action message for the key 'constraints.Digits.message' with parameters.
<pre>
message: {item} is numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected).
</pre>
@param property The property name for the message. (NotNull)
@param fraction The parameter fraction for message. (NotNull)
@param integer The parameter integer for message. (NotNull)
@return this. (NotNull) | [
"Add",
"the",
"created",
"action",
"message",
"for",
"the",
"key",
"constraints",
".",
"Digits",
".",
"message",
"with",
"parameters",
".",
"<pre",
">",
"message",
":",
"{",
"item",
"}",
"is",
"numeric",
"value",
"out",
"of",
"bounds",
"(",
"<",
";",
"{",
"integer",
"}",
"digits>",
";",
".",
"<",
";",
"{",
"fraction",
"}",
"digits>",
";",
"expected",
")",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/codelibs/fess/blob/e5e4b722549d32a4958dfd94965b21937bfe64cf/src/main/java/org/codelibs/fess/mylasta/action/FessMessages.java#L667-L671 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/VirtualNetworkTapsInner.java | VirtualNetworkTapsInner.getByResourceGroupAsync | public Observable<VirtualNetworkTapInner> getByResourceGroupAsync(String resourceGroupName, String tapName) {
"""
Gets information about the specified virtual network tap.
@param resourceGroupName The name of the resource group.
@param tapName The name of virtual network tap.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualNetworkTapInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, tapName).map(new Func1<ServiceResponse<VirtualNetworkTapInner>, VirtualNetworkTapInner>() {
@Override
public VirtualNetworkTapInner call(ServiceResponse<VirtualNetworkTapInner> response) {
return response.body();
}
});
} | java | public Observable<VirtualNetworkTapInner> getByResourceGroupAsync(String resourceGroupName, String tapName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, tapName).map(new Func1<ServiceResponse<VirtualNetworkTapInner>, VirtualNetworkTapInner>() {
@Override
public VirtualNetworkTapInner call(ServiceResponse<VirtualNetworkTapInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"VirtualNetworkTapInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"tapName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"tapName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"VirtualNetworkTapInner",
">",
",",
"VirtualNetworkTapInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"VirtualNetworkTapInner",
"call",
"(",
"ServiceResponse",
"<",
"VirtualNetworkTapInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets information about the specified virtual network tap.
@param resourceGroupName The name of the resource group.
@param tapName The name of virtual network tap.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualNetworkTapInner object | [
"Gets",
"information",
"about",
"the",
"specified",
"virtual",
"network",
"tap",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/VirtualNetworkTapsInner.java#L302-L309 |
DDTH/ddth-queue | ddth-queue-core/src/main/java/com/github/ddth/queue/impl/RabbitMqQueue.java | RabbitMqQueue.putToQueue | protected boolean putToQueue(IQueueMessage<ID, DATA> msg) {
"""
Puts a message to Kafka queue, partitioning message by
{@link IQueueMessage#qId()}
@param msg
@return
"""
try {
byte[] msgData = serialize(msg);
getProducerChannel().basicPublish("", queueName, null, msgData);
return true;
} catch (Exception e) {
throw e instanceof QueueException ? (QueueException) e : new QueueException(e);
}
} | java | protected boolean putToQueue(IQueueMessage<ID, DATA> msg) {
try {
byte[] msgData = serialize(msg);
getProducerChannel().basicPublish("", queueName, null, msgData);
return true;
} catch (Exception e) {
throw e instanceof QueueException ? (QueueException) e : new QueueException(e);
}
} | [
"protected",
"boolean",
"putToQueue",
"(",
"IQueueMessage",
"<",
"ID",
",",
"DATA",
">",
"msg",
")",
"{",
"try",
"{",
"byte",
"[",
"]",
"msgData",
"=",
"serialize",
"(",
"msg",
")",
";",
"getProducerChannel",
"(",
")",
".",
"basicPublish",
"(",
"\"\"",
",",
"queueName",
",",
"null",
",",
"msgData",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"e",
"instanceof",
"QueueException",
"?",
"(",
"QueueException",
")",
"e",
":",
"new",
"QueueException",
"(",
"e",
")",
";",
"}",
"}"
] | Puts a message to Kafka queue, partitioning message by
{@link IQueueMessage#qId()}
@param msg
@return | [
"Puts",
"a",
"message",
"to",
"Kafka",
"queue",
"partitioning",
"message",
"by",
"{",
"@link",
"IQueueMessage#qId",
"()",
"}"
] | train | https://github.com/DDTH/ddth-queue/blob/b20776850d23111d3d71fc8ed6023c590bc3621f/ddth-queue-core/src/main/java/com/github/ddth/queue/impl/RabbitMqQueue.java#L237-L245 |
alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/utils/disruptor/RingBuffer.java | RingBuffer.tryPublishEvent | public boolean tryPublishEvent(EventTranslatorVararg<E> translator, Object... args) {
"""
Allows a variable number of user supplied arguments
@see #publishEvent(EventTranslator)
@param translator The user specified translation for the event
@param args User supplied arguments.
@return true if the value was published, false if there was insufficient capacity.
"""
try {
final long sequence = sequencer.tryNext();
translateAndPublish(translator, sequence, args);
return true;
} catch (InsufficientCapacityException e) {
return false;
}
} | java | public boolean tryPublishEvent(EventTranslatorVararg<E> translator, Object... args) {
try {
final long sequence = sequencer.tryNext();
translateAndPublish(translator, sequence, args);
return true;
} catch (InsufficientCapacityException e) {
return false;
}
} | [
"public",
"boolean",
"tryPublishEvent",
"(",
"EventTranslatorVararg",
"<",
"E",
">",
"translator",
",",
"Object",
"...",
"args",
")",
"{",
"try",
"{",
"final",
"long",
"sequence",
"=",
"sequencer",
".",
"tryNext",
"(",
")",
";",
"translateAndPublish",
"(",
"translator",
",",
"sequence",
",",
"args",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"InsufficientCapacityException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Allows a variable number of user supplied arguments
@see #publishEvent(EventTranslator)
@param translator The user specified translation for the event
@param args User supplied arguments.
@return true if the value was published, false if there was insufficient capacity. | [
"Allows",
"a",
"variable",
"number",
"of",
"user",
"supplied",
"arguments"
] | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/utils/disruptor/RingBuffer.java#L499-L507 |
mikepenz/Android-Iconics | library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java | IconicsDrawable.iconOffsetYDp | @NonNull
public IconicsDrawable iconOffsetYDp(@Dimension(unit = DP) int sizeDp) {
"""
set the icon offset for Y as dp
@return The current IconicsDrawable for chaining.
"""
return iconOffsetYPx(Utils.convertDpToPx(mContext, sizeDp));
} | java | @NonNull
public IconicsDrawable iconOffsetYDp(@Dimension(unit = DP) int sizeDp) {
return iconOffsetYPx(Utils.convertDpToPx(mContext, sizeDp));
} | [
"@",
"NonNull",
"public",
"IconicsDrawable",
"iconOffsetYDp",
"(",
"@",
"Dimension",
"(",
"unit",
"=",
"DP",
")",
"int",
"sizeDp",
")",
"{",
"return",
"iconOffsetYPx",
"(",
"Utils",
".",
"convertDpToPx",
"(",
"mContext",
",",
"sizeDp",
")",
")",
";",
"}"
] | set the icon offset for Y as dp
@return The current IconicsDrawable for chaining. | [
"set",
"the",
"icon",
"offset",
"for",
"Y",
"as",
"dp"
] | train | https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L558-L561 |
kuujo/vertigo | core/src/main/java/net/kuujo/vertigo/Vertigo.java | Vertigo.undeployNetwork | public Vertigo undeployNetwork(String cluster, JsonObject network) {
"""
Undeploys a network from the given cluster from a json configuration.<p>
The JSON configuration will immediately be converted to a {@link NetworkConfig} prior
to undeploying the network. In order to undeploy the entire network, the configuration
should be the same as the deployed configuration. Vertigo will use configuration
components to determine whether two configurations are identical. If the given
configuration is not identical to the running configuration, any components or
connections in the json configuration that are present in the running network
will be closed and removed from the running network.
@param cluster The cluster from which to undeploy the network.
@param network The JSON configuration to undeploy. For the configuration format see
the project documentation.
@return The Vertigo instance.
"""
return undeployNetwork(cluster, network, null);
} | java | public Vertigo undeployNetwork(String cluster, JsonObject network) {
return undeployNetwork(cluster, network, null);
} | [
"public",
"Vertigo",
"undeployNetwork",
"(",
"String",
"cluster",
",",
"JsonObject",
"network",
")",
"{",
"return",
"undeployNetwork",
"(",
"cluster",
",",
"network",
",",
"null",
")",
";",
"}"
] | Undeploys a network from the given cluster from a json configuration.<p>
The JSON configuration will immediately be converted to a {@link NetworkConfig} prior
to undeploying the network. In order to undeploy the entire network, the configuration
should be the same as the deployed configuration. Vertigo will use configuration
components to determine whether two configurations are identical. If the given
configuration is not identical to the running configuration, any components or
connections in the json configuration that are present in the running network
will be closed and removed from the running network.
@param cluster The cluster from which to undeploy the network.
@param network The JSON configuration to undeploy. For the configuration format see
the project documentation.
@return The Vertigo instance. | [
"Undeploys",
"a",
"network",
"from",
"the",
"given",
"cluster",
"from",
"a",
"json",
"configuration",
".",
"<p",
">"
] | train | https://github.com/kuujo/vertigo/blob/c5869dbc5fff89eb5262e83f7a81719b01a5ba6f/core/src/main/java/net/kuujo/vertigo/Vertigo.java#L645-L647 |
infinispan/infinispan | object-filter/src/main/java/org/infinispan/objectfilter/impl/util/IntervalTree.java | IntervalTree.compareIntervals | private int compareIntervals(Interval<K> i1, Interval<K> i2) {
"""
Compare two Intervals.
@return a negative integer, zero, or a positive integer depending if Interval i1 is to the left of i2, overlaps
with it, or is to the right of i2.
"""
int res1 = compare(i1.up, i2.low);
if (res1 < 0 || res1 <= 0 && (!i1.includeUpper || !i2.includeLower)) {
return -1;
}
int res2 = compare(i2.up, i1.low);
if (res2 < 0 || res2 <= 0 && (!i2.includeUpper || !i1.includeLower)) {
return 1;
}
return 0;
} | java | private int compareIntervals(Interval<K> i1, Interval<K> i2) {
int res1 = compare(i1.up, i2.low);
if (res1 < 0 || res1 <= 0 && (!i1.includeUpper || !i2.includeLower)) {
return -1;
}
int res2 = compare(i2.up, i1.low);
if (res2 < 0 || res2 <= 0 && (!i2.includeUpper || !i1.includeLower)) {
return 1;
}
return 0;
} | [
"private",
"int",
"compareIntervals",
"(",
"Interval",
"<",
"K",
">",
"i1",
",",
"Interval",
"<",
"K",
">",
"i2",
")",
"{",
"int",
"res1",
"=",
"compare",
"(",
"i1",
".",
"up",
",",
"i2",
".",
"low",
")",
";",
"if",
"(",
"res1",
"<",
"0",
"||",
"res1",
"<=",
"0",
"&&",
"(",
"!",
"i1",
".",
"includeUpper",
"||",
"!",
"i2",
".",
"includeLower",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"int",
"res2",
"=",
"compare",
"(",
"i2",
".",
"up",
",",
"i1",
".",
"low",
")",
";",
"if",
"(",
"res2",
"<",
"0",
"||",
"res2",
"<=",
"0",
"&&",
"(",
"!",
"i2",
".",
"includeUpper",
"||",
"!",
"i1",
".",
"includeLower",
")",
")",
"{",
"return",
"1",
";",
"}",
"return",
"0",
";",
"}"
] | Compare two Intervals.
@return a negative integer, zero, or a positive integer depending if Interval i1 is to the left of i2, overlaps
with it, or is to the right of i2. | [
"Compare",
"two",
"Intervals",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/object-filter/src/main/java/org/infinispan/objectfilter/impl/util/IntervalTree.java#L102-L112 |
netplex/json-smart-v2 | json-smart/src/main/java/net/minidev/json/parser/JSONParserByteArray.java | JSONParserByteArray.parse | public <T> T parse(byte[] in, JsonReaderI<T> mapper) throws ParseException {
"""
use to return Primitive Type, or String, Or JsonObject or JsonArray
generated by a ContainerFactory
"""
this.base = mapper.base;
this.in = in;
this.len = in.length;
return parse(mapper);
} | java | public <T> T parse(byte[] in, JsonReaderI<T> mapper) throws ParseException {
this.base = mapper.base;
this.in = in;
this.len = in.length;
return parse(mapper);
} | [
"public",
"<",
"T",
">",
"T",
"parse",
"(",
"byte",
"[",
"]",
"in",
",",
"JsonReaderI",
"<",
"T",
">",
"mapper",
")",
"throws",
"ParseException",
"{",
"this",
".",
"base",
"=",
"mapper",
".",
"base",
";",
"this",
".",
"in",
"=",
"in",
";",
"this",
".",
"len",
"=",
"in",
".",
"length",
";",
"return",
"parse",
"(",
"mapper",
")",
";",
"}"
] | use to return Primitive Type, or String, Or JsonObject or JsonArray
generated by a ContainerFactory | [
"use",
"to",
"return",
"Primitive",
"Type",
"or",
"String",
"Or",
"JsonObject",
"or",
"JsonArray",
"generated",
"by",
"a",
"ContainerFactory"
] | train | https://github.com/netplex/json-smart-v2/blob/bfb3daef039e22a7bbff5f76bf14ea23330cd70e/json-smart/src/main/java/net/minidev/json/parser/JSONParserByteArray.java#L54-L59 |
alkacon/opencms-core | src/org/opencms/file/CmsObject.java | CmsObject.moveResource | public void moveResource(String source, String destination) throws CmsException {
"""
Moves a resource to the given destination.<p>
A move operation in OpenCms is always a copy (as sibling) followed by a delete,
this is a result of the online/offline structure of the
OpenCms VFS. This way you can see the deleted files/folders in the offline
project, and you will be unable to undelete them.<p>
@param source the name of the resource to move (full current site relative path)
@param destination the destination resource name (full current site relative path)
@throws CmsException if something goes wrong
@see #renameResource(String, String)
"""
CmsResource resource = readResource(source, CmsResourceFilter.IGNORE_EXPIRATION);
getResourceType(resource).moveResource(this, m_securityManager, resource, destination);
} | java | public void moveResource(String source, String destination) throws CmsException {
CmsResource resource = readResource(source, CmsResourceFilter.IGNORE_EXPIRATION);
getResourceType(resource).moveResource(this, m_securityManager, resource, destination);
} | [
"public",
"void",
"moveResource",
"(",
"String",
"source",
",",
"String",
"destination",
")",
"throws",
"CmsException",
"{",
"CmsResource",
"resource",
"=",
"readResource",
"(",
"source",
",",
"CmsResourceFilter",
".",
"IGNORE_EXPIRATION",
")",
";",
"getResourceType",
"(",
"resource",
")",
".",
"moveResource",
"(",
"this",
",",
"m_securityManager",
",",
"resource",
",",
"destination",
")",
";",
"}"
] | Moves a resource to the given destination.<p>
A move operation in OpenCms is always a copy (as sibling) followed by a delete,
this is a result of the online/offline structure of the
OpenCms VFS. This way you can see the deleted files/folders in the offline
project, and you will be unable to undelete them.<p>
@param source the name of the resource to move (full current site relative path)
@param destination the destination resource name (full current site relative path)
@throws CmsException if something goes wrong
@see #renameResource(String, String) | [
"Moves",
"a",
"resource",
"to",
"the",
"given",
"destination",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/CmsObject.java#L2241-L2245 |
languagetool-org/languagetool | languagetool-office-extension/src/main/java/org/languagetool/openoffice/ResultCache.java | ResultCache.removeRange | void removeRange(int firstParagraph, int lastParagraph) {
"""
Remove all cache entries between firstParagraph and lastParagraph
"""
for(int i = 0; i < entries.size(); i++) {
if(entries.get(i).numberOfParagraph >= firstParagraph && entries.get(i).numberOfParagraph <= lastParagraph) {
entries.remove(i);
i--;
}
}
} | java | void removeRange(int firstParagraph, int lastParagraph) {
for(int i = 0; i < entries.size(); i++) {
if(entries.get(i).numberOfParagraph >= firstParagraph && entries.get(i).numberOfParagraph <= lastParagraph) {
entries.remove(i);
i--;
}
}
} | [
"void",
"removeRange",
"(",
"int",
"firstParagraph",
",",
"int",
"lastParagraph",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"entries",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"entries",
".",
"get",
"(",
"i",
")",
".",
"numberOfParagraph",
">=",
"firstParagraph",
"&&",
"entries",
".",
"get",
"(",
"i",
")",
".",
"numberOfParagraph",
"<=",
"lastParagraph",
")",
"{",
"entries",
".",
"remove",
"(",
"i",
")",
";",
"i",
"--",
";",
"}",
"}",
"}"
] | Remove all cache entries between firstParagraph and lastParagraph | [
"Remove",
"all",
"cache",
"entries",
"between",
"firstParagraph",
"and",
"lastParagraph"
] | train | https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-office-extension/src/main/java/org/languagetool/openoffice/ResultCache.java#L67-L74 |
jboss/jboss-jsp-api_spec | src/main/java/javax/servlet/jsp/tagext/TagSupport.java | TagSupport.findAncestorWithClass | public static final Tag findAncestorWithClass(Tag from, Class klass) {
"""
Find the instance of a given class type that is closest to a given
instance.
This method uses the getParent method from the Tag
interface.
This method is used for coordination among cooperating tags.
<p>
The current version of the specification only provides one formal
way of indicating the observable type of a tag handler: its
tag handler implementation class, described in the tag-class
subelement of the tag element. This is extended in an
informal manner by allowing the tag library author to
indicate in the description subelement an observable type.
The type should be a subtype of the tag handler implementation
class or void.
This addititional constraint can be exploited by a
specialized container that knows about that specific tag library,
as in the case of the JSP standard tag library.
<p>
When a tag library author provides information on the
observable type of a tag handler, client programmatic code
should adhere to that constraint. Specifically, the Class
passed to findAncestorWithClass should be a subtype of the
observable type.
@param from The instance from where to start looking.
@param klass The subclass of Tag or interface to be matched
@return the nearest ancestor that implements the interface
or is an instance of the class specified
"""
boolean isInterface = false;
if (from == null ||
klass == null ||
(!Tag.class.isAssignableFrom(klass) &&
!(isInterface = klass.isInterface()))) {
return null;
}
for (;;) {
Tag tag = from.getParent();
if (tag == null) {
return null;
}
if ((isInterface && klass.isInstance(tag)) ||
klass.isAssignableFrom(tag.getClass()))
return tag;
else
from = tag;
}
} | java | public static final Tag findAncestorWithClass(Tag from, Class klass) {
boolean isInterface = false;
if (from == null ||
klass == null ||
(!Tag.class.isAssignableFrom(klass) &&
!(isInterface = klass.isInterface()))) {
return null;
}
for (;;) {
Tag tag = from.getParent();
if (tag == null) {
return null;
}
if ((isInterface && klass.isInstance(tag)) ||
klass.isAssignableFrom(tag.getClass()))
return tag;
else
from = tag;
}
} | [
"public",
"static",
"final",
"Tag",
"findAncestorWithClass",
"(",
"Tag",
"from",
",",
"Class",
"klass",
")",
"{",
"boolean",
"isInterface",
"=",
"false",
";",
"if",
"(",
"from",
"==",
"null",
"||",
"klass",
"==",
"null",
"||",
"(",
"!",
"Tag",
".",
"class",
".",
"isAssignableFrom",
"(",
"klass",
")",
"&&",
"!",
"(",
"isInterface",
"=",
"klass",
".",
"isInterface",
"(",
")",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
";",
";",
")",
"{",
"Tag",
"tag",
"=",
"from",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"tag",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"(",
"isInterface",
"&&",
"klass",
".",
"isInstance",
"(",
"tag",
")",
")",
"||",
"klass",
".",
"isAssignableFrom",
"(",
"tag",
".",
"getClass",
"(",
")",
")",
")",
"return",
"tag",
";",
"else",
"from",
"=",
"tag",
";",
"}",
"}"
] | Find the instance of a given class type that is closest to a given
instance.
This method uses the getParent method from the Tag
interface.
This method is used for coordination among cooperating tags.
<p>
The current version of the specification only provides one formal
way of indicating the observable type of a tag handler: its
tag handler implementation class, described in the tag-class
subelement of the tag element. This is extended in an
informal manner by allowing the tag library author to
indicate in the description subelement an observable type.
The type should be a subtype of the tag handler implementation
class or void.
This addititional constraint can be exploited by a
specialized container that knows about that specific tag library,
as in the case of the JSP standard tag library.
<p>
When a tag library author provides information on the
observable type of a tag handler, client programmatic code
should adhere to that constraint. Specifically, the Class
passed to findAncestorWithClass should be a subtype of the
observable type.
@param from The instance from where to start looking.
@param klass The subclass of Tag or interface to be matched
@return the nearest ancestor that implements the interface
or is an instance of the class specified | [
"Find",
"the",
"instance",
"of",
"a",
"given",
"class",
"type",
"that",
"is",
"closest",
"to",
"a",
"given",
"instance",
".",
"This",
"method",
"uses",
"the",
"getParent",
"method",
"from",
"the",
"Tag",
"interface",
".",
"This",
"method",
"is",
"used",
"for",
"coordination",
"among",
"cooperating",
"tags",
"."
] | train | https://github.com/jboss/jboss-jsp-api_spec/blob/da53166619f33a5134dc3315a3264990cc1f541f/src/main/java/javax/servlet/jsp/tagext/TagSupport.java#L113-L136 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.fastNormP | public static double fastNormP(DMatrixRMaj A , double p ) {
"""
An unsafe but faster version of {@link #normP} that calls routines which are faster
but more prone to overflow/underflow problems.
@param A Vector or matrix whose norm is to be computed.
@param p The p value of the p-norm.
@return The computed norm.
"""
if( p == 1 ) {
return normP1(A);
} else if( p == 2 ) {
return fastNormP2(A);
} else if( Double.isInfinite(p)) {
return normPInf(A);
}
if( MatrixFeatures_DDRM.isVector(A) ) {
return fastElementP(A,p);
} else {
throw new IllegalArgumentException("Doesn't support induced norms yet.");
}
} | java | public static double fastNormP(DMatrixRMaj A , double p ) {
if( p == 1 ) {
return normP1(A);
} else if( p == 2 ) {
return fastNormP2(A);
} else if( Double.isInfinite(p)) {
return normPInf(A);
}
if( MatrixFeatures_DDRM.isVector(A) ) {
return fastElementP(A,p);
} else {
throw new IllegalArgumentException("Doesn't support induced norms yet.");
}
} | [
"public",
"static",
"double",
"fastNormP",
"(",
"DMatrixRMaj",
"A",
",",
"double",
"p",
")",
"{",
"if",
"(",
"p",
"==",
"1",
")",
"{",
"return",
"normP1",
"(",
"A",
")",
";",
"}",
"else",
"if",
"(",
"p",
"==",
"2",
")",
"{",
"return",
"fastNormP2",
"(",
"A",
")",
";",
"}",
"else",
"if",
"(",
"Double",
".",
"isInfinite",
"(",
"p",
")",
")",
"{",
"return",
"normPInf",
"(",
"A",
")",
";",
"}",
"if",
"(",
"MatrixFeatures_DDRM",
".",
"isVector",
"(",
"A",
")",
")",
"{",
"return",
"fastElementP",
"(",
"A",
",",
"p",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Doesn't support induced norms yet.\"",
")",
";",
"}",
"}"
] | An unsafe but faster version of {@link #normP} that calls routines which are faster
but more prone to overflow/underflow problems.
@param A Vector or matrix whose norm is to be computed.
@param p The p value of the p-norm.
@return The computed norm. | [
"An",
"unsafe",
"but",
"faster",
"version",
"of",
"{",
"@link",
"#normP",
"}",
"that",
"calls",
"routines",
"which",
"are",
"faster",
"but",
"more",
"prone",
"to",
"overflow",
"/",
"underflow",
"problems",
"."
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L308-L321 |
JOML-CI/JOML | src/org/joml/Matrix3d.java | Matrix3d.scaling | public Matrix3d scaling(double x, double y, double z) {
"""
Set this matrix to be a simple scale matrix.
@param x
the scale in x
@param y
the scale in y
@param z
the scale in z
@return this
"""
m00 = x;
m01 = 0.0;
m02 = 0.0;
m10 = 0.0;
m11 = y;
m12 = 0.0;
m20 = 0.0;
m21 = 0.0;
m22 = z;
return this;
} | java | public Matrix3d scaling(double x, double y, double z) {
m00 = x;
m01 = 0.0;
m02 = 0.0;
m10 = 0.0;
m11 = y;
m12 = 0.0;
m20 = 0.0;
m21 = 0.0;
m22 = z;
return this;
} | [
"public",
"Matrix3d",
"scaling",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
")",
"{",
"m00",
"=",
"x",
";",
"m01",
"=",
"0.0",
";",
"m02",
"=",
"0.0",
";",
"m10",
"=",
"0.0",
";",
"m11",
"=",
"y",
";",
"m12",
"=",
"0.0",
";",
"m20",
"=",
"0.0",
";",
"m21",
"=",
"0.0",
";",
"m22",
"=",
"z",
";",
"return",
"this",
";",
"}"
] | Set this matrix to be a simple scale matrix.
@param x
the scale in x
@param y
the scale in y
@param z
the scale in z
@return this | [
"Set",
"this",
"matrix",
"to",
"be",
"a",
"simple",
"scale",
"matrix",
"."
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix3d.java#L1357-L1368 |
alkacon/opencms-core | src/org/opencms/xml/containerpage/CmsXmlContainerPageHandler.java | CmsXmlContainerPageHandler.validateNames | protected void validateNames(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContent content)
throws CmsXmlException {
"""
Validates container names, so that they are unique in the page.<p>
@param cms the cms context
@param value the value to validate
@param content the container page to validate
@throws CmsXmlException if there are duplicated names
"""
// get the current name
Locale locale = value.getLocale();
String namePath = CmsXmlUtils.concatXpath(value.getPath(), CmsXmlContainerPage.XmlNode.Name.name());
String name = content.getValue(namePath, locale).getStringValue(cms);
// iterate over all containers
Iterator<I_CmsXmlContentValue> itValues = content.getValues(
CmsXmlContainerPage.XmlNode.Containers.name(),
locale).iterator();
while (itValues.hasNext()) {
I_CmsXmlContentValue itValue = itValues.next();
if (itValue.getPath().equals(value.getPath())) {
// skip current container
continue;
}
// get container name
namePath = CmsXmlUtils.concatXpath(itValue.getPath(), CmsXmlContainerPage.XmlNode.Name.name());
String itName = content.getValue(namePath, locale).getStringValue(cms);
// validate
if (name.equals(itName)) {
throw new CmsXmlException(Messages.get().container(Messages.ERR_DUPLICATE_NAME_1, name));
}
}
} | java | protected void validateNames(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContent content)
throws CmsXmlException {
// get the current name
Locale locale = value.getLocale();
String namePath = CmsXmlUtils.concatXpath(value.getPath(), CmsXmlContainerPage.XmlNode.Name.name());
String name = content.getValue(namePath, locale).getStringValue(cms);
// iterate over all containers
Iterator<I_CmsXmlContentValue> itValues = content.getValues(
CmsXmlContainerPage.XmlNode.Containers.name(),
locale).iterator();
while (itValues.hasNext()) {
I_CmsXmlContentValue itValue = itValues.next();
if (itValue.getPath().equals(value.getPath())) {
// skip current container
continue;
}
// get container name
namePath = CmsXmlUtils.concatXpath(itValue.getPath(), CmsXmlContainerPage.XmlNode.Name.name());
String itName = content.getValue(namePath, locale).getStringValue(cms);
// validate
if (name.equals(itName)) {
throw new CmsXmlException(Messages.get().container(Messages.ERR_DUPLICATE_NAME_1, name));
}
}
} | [
"protected",
"void",
"validateNames",
"(",
"CmsObject",
"cms",
",",
"I_CmsXmlContentValue",
"value",
",",
"CmsXmlContent",
"content",
")",
"throws",
"CmsXmlException",
"{",
"// get the current name",
"Locale",
"locale",
"=",
"value",
".",
"getLocale",
"(",
")",
";",
"String",
"namePath",
"=",
"CmsXmlUtils",
".",
"concatXpath",
"(",
"value",
".",
"getPath",
"(",
")",
",",
"CmsXmlContainerPage",
".",
"XmlNode",
".",
"Name",
".",
"name",
"(",
")",
")",
";",
"String",
"name",
"=",
"content",
".",
"getValue",
"(",
"namePath",
",",
"locale",
")",
".",
"getStringValue",
"(",
"cms",
")",
";",
"// iterate over all containers",
"Iterator",
"<",
"I_CmsXmlContentValue",
">",
"itValues",
"=",
"content",
".",
"getValues",
"(",
"CmsXmlContainerPage",
".",
"XmlNode",
".",
"Containers",
".",
"name",
"(",
")",
",",
"locale",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"itValues",
".",
"hasNext",
"(",
")",
")",
"{",
"I_CmsXmlContentValue",
"itValue",
"=",
"itValues",
".",
"next",
"(",
")",
";",
"if",
"(",
"itValue",
".",
"getPath",
"(",
")",
".",
"equals",
"(",
"value",
".",
"getPath",
"(",
")",
")",
")",
"{",
"// skip current container",
"continue",
";",
"}",
"// get container name",
"namePath",
"=",
"CmsXmlUtils",
".",
"concatXpath",
"(",
"itValue",
".",
"getPath",
"(",
")",
",",
"CmsXmlContainerPage",
".",
"XmlNode",
".",
"Name",
".",
"name",
"(",
")",
")",
";",
"String",
"itName",
"=",
"content",
".",
"getValue",
"(",
"namePath",
",",
"locale",
")",
".",
"getStringValue",
"(",
"cms",
")",
";",
"// validate",
"if",
"(",
"name",
".",
"equals",
"(",
"itName",
")",
")",
"{",
"throw",
"new",
"CmsXmlException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_DUPLICATE_NAME_1",
",",
"name",
")",
")",
";",
"}",
"}",
"}"
] | Validates container names, so that they are unique in the page.<p>
@param cms the cms context
@param value the value to validate
@param content the container page to validate
@throws CmsXmlException if there are duplicated names | [
"Validates",
"container",
"names",
"so",
"that",
"they",
"are",
"unique",
"in",
"the",
"page",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/containerpage/CmsXmlContainerPageHandler.java#L147-L172 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/util/GraphUtils.java | GraphUtils.toDot | public static <D, N extends DottableNode<D, N>> String toDot(Collection<? extends N> nodes, String name, String header) {
"""
Debugging: dot representation of a set of connected nodes. The resulting
dot representation will use {@code Node.toString} to display node labels
and {@code Node.printDependency} to display edge labels. The resulting
representation is also customizable with a graph name and a header.
"""
StringBuilder buf = new StringBuilder();
buf.append(String.format("digraph %s {\n", name));
buf.append(String.format("label = %s;\n", DotVisitor.wrap(header)));
DotVisitor<D, N> dotVisitor = new DotVisitor<>();
dotVisitor.visit(nodes, buf);
buf.append("}\n");
return buf.toString();
} | java | public static <D, N extends DottableNode<D, N>> String toDot(Collection<? extends N> nodes, String name, String header) {
StringBuilder buf = new StringBuilder();
buf.append(String.format("digraph %s {\n", name));
buf.append(String.format("label = %s;\n", DotVisitor.wrap(header)));
DotVisitor<D, N> dotVisitor = new DotVisitor<>();
dotVisitor.visit(nodes, buf);
buf.append("}\n");
return buf.toString();
} | [
"public",
"static",
"<",
"D",
",",
"N",
"extends",
"DottableNode",
"<",
"D",
",",
"N",
">",
">",
"String",
"toDot",
"(",
"Collection",
"<",
"?",
"extends",
"N",
">",
"nodes",
",",
"String",
"name",
",",
"String",
"header",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buf",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"digraph %s {\\n\"",
",",
"name",
")",
")",
";",
"buf",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"label = %s;\\n\"",
",",
"DotVisitor",
".",
"wrap",
"(",
"header",
")",
")",
")",
";",
"DotVisitor",
"<",
"D",
",",
"N",
">",
"dotVisitor",
"=",
"new",
"DotVisitor",
"<>",
"(",
")",
";",
"dotVisitor",
".",
"visit",
"(",
"nodes",
",",
"buf",
")",
";",
"buf",
".",
"append",
"(",
"\"}\\n\"",
")",
";",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Debugging: dot representation of a set of connected nodes. The resulting
dot representation will use {@code Node.toString} to display node labels
and {@code Node.printDependency} to display edge labels. The resulting
representation is also customizable with a graph name and a header. | [
"Debugging",
":",
"dot",
"representation",
"of",
"a",
"set",
"of",
"connected",
"nodes",
".",
"The",
"resulting",
"dot",
"representation",
"will",
"use",
"{"
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/util/GraphUtils.java#L222-L230 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java | Shape.setElementWiseStride | public static void setElementWiseStride(IntBuffer buffer, int elementWiseStride) {
"""
Get the element wise stride for the
shape info buffer
@param buffer the buffer to get the element
wise stride from
@return the element wise stride for the buffer
"""
int length2 = shapeInfoLength(buffer.get(0));
// if (1 > 0) throw new RuntimeException("setElementWiseStride called: [" + elementWiseStride + "], buffer: " + bufferToString(buffer));
buffer.put(length2 - 2, elementWiseStride);
} | java | public static void setElementWiseStride(IntBuffer buffer, int elementWiseStride) {
int length2 = shapeInfoLength(buffer.get(0));
// if (1 > 0) throw new RuntimeException("setElementWiseStride called: [" + elementWiseStride + "], buffer: " + bufferToString(buffer));
buffer.put(length2 - 2, elementWiseStride);
} | [
"public",
"static",
"void",
"setElementWiseStride",
"(",
"IntBuffer",
"buffer",
",",
"int",
"elementWiseStride",
")",
"{",
"int",
"length2",
"=",
"shapeInfoLength",
"(",
"buffer",
".",
"get",
"(",
"0",
")",
")",
";",
"// if (1 > 0) throw new RuntimeException(\"setElementWiseStride called: [\" + elementWiseStride + \"], buffer: \" + bufferToString(buffer));",
"buffer",
".",
"put",
"(",
"length2",
"-",
"2",
",",
"elementWiseStride",
")",
";",
"}"
] | Get the element wise stride for the
shape info buffer
@param buffer the buffer to get the element
wise stride from
@return the element wise stride for the buffer | [
"Get",
"the",
"element",
"wise",
"stride",
"for",
"the",
"shape",
"info",
"buffer"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java#L3073-L3077 |
UrielCh/ovh-java-sdk | ovh-java-sdk-packxdsl/src/main/java/net/minidev/ovh/api/ApiOvhPackxdsl.java | ApiOvhPackxdsl.packName_voipLine_options_customShippingAddress_POST | public Long packName_voipLine_options_customShippingAddress_POST(String packName, String address, String cityName, String firstName, String lastName, String zipCode) throws IOException {
"""
Create a new shippingId to be used for voipLine service creation
REST: POST /pack/xdsl/{packName}/voipLine/options/customShippingAddress
@param address [required] Address, including street name
@param lastName [required] Last name
@param firstName [required] First name
@param cityName [required] City name
@param zipCode [required] Zip code
@param packName [required] The internal name of your pack
"""
String qPath = "/pack/xdsl/{packName}/voipLine/options/customShippingAddress";
StringBuilder sb = path(qPath, packName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "address", address);
addBody(o, "cityName", cityName);
addBody(o, "firstName", firstName);
addBody(o, "lastName", lastName);
addBody(o, "zipCode", zipCode);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, Long.class);
} | java | public Long packName_voipLine_options_customShippingAddress_POST(String packName, String address, String cityName, String firstName, String lastName, String zipCode) throws IOException {
String qPath = "/pack/xdsl/{packName}/voipLine/options/customShippingAddress";
StringBuilder sb = path(qPath, packName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "address", address);
addBody(o, "cityName", cityName);
addBody(o, "firstName", firstName);
addBody(o, "lastName", lastName);
addBody(o, "zipCode", zipCode);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, Long.class);
} | [
"public",
"Long",
"packName_voipLine_options_customShippingAddress_POST",
"(",
"String",
"packName",
",",
"String",
"address",
",",
"String",
"cityName",
",",
"String",
"firstName",
",",
"String",
"lastName",
",",
"String",
"zipCode",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/pack/xdsl/{packName}/voipLine/options/customShippingAddress\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"packName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"address\"",
",",
"address",
")",
";",
"addBody",
"(",
"o",
",",
"\"cityName\"",
",",
"cityName",
")",
";",
"addBody",
"(",
"o",
",",
"\"firstName\"",
",",
"firstName",
")",
";",
"addBody",
"(",
"o",
",",
"\"lastName\"",
",",
"lastName",
")",
";",
"addBody",
"(",
"o",
",",
"\"zipCode\"",
",",
"zipCode",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"Long",
".",
"class",
")",
";",
"}"
] | Create a new shippingId to be used for voipLine service creation
REST: POST /pack/xdsl/{packName}/voipLine/options/customShippingAddress
@param address [required] Address, including street name
@param lastName [required] Last name
@param firstName [required] First name
@param cityName [required] City name
@param zipCode [required] Zip code
@param packName [required] The internal name of your pack | [
"Create",
"a",
"new",
"shippingId",
"to",
"be",
"used",
"for",
"voipLine",
"service",
"creation"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-packxdsl/src/main/java/net/minidev/ovh/api/ApiOvhPackxdsl.java#L320-L331 |
redkale/redkale | src/org/redkale/asm/ClassReader.java | ClassReader.createLabel | private Label createLabel(int offset, Label[] labels) {
"""
Creates a label without the Label.DEBUG flag set, for the given offset.
The label is created with a call to {@link #readLabel} and its
Label.DEBUG flag is cleared.
@param offset
a bytecode offset in a method.
@param labels
the already created labels, indexed by their offset.
@return a Label without the Label.DEBUG flag set.
"""
Label label = readLabel(offset, labels);
label.status &= ~Label.DEBUG;
return label;
} | java | private Label createLabel(int offset, Label[] labels) {
Label label = readLabel(offset, labels);
label.status &= ~Label.DEBUG;
return label;
} | [
"private",
"Label",
"createLabel",
"(",
"int",
"offset",
",",
"Label",
"[",
"]",
"labels",
")",
"{",
"Label",
"label",
"=",
"readLabel",
"(",
"offset",
",",
"labels",
")",
";",
"label",
".",
"status",
"&=",
"~",
"Label",
".",
"DEBUG",
";",
"return",
"label",
";",
"}"
] | Creates a label without the Label.DEBUG flag set, for the given offset.
The label is created with a call to {@link #readLabel} and its
Label.DEBUG flag is cleared.
@param offset
a bytecode offset in a method.
@param labels
the already created labels, indexed by their offset.
@return a Label without the Label.DEBUG flag set. | [
"Creates",
"a",
"label",
"without",
"the",
"Label",
".",
"DEBUG",
"flag",
"set",
"for",
"the",
"given",
"offset",
".",
"The",
"label",
"is",
"created",
"with",
"a",
"call",
"to",
"{",
"@link",
"#readLabel",
"}",
"and",
"its",
"Label",
".",
"DEBUG",
"flag",
"is",
"cleared",
"."
] | train | https://github.com/redkale/redkale/blob/ea5169b5c5ea7412fd762331c0c497165832e901/src/org/redkale/asm/ClassReader.java#L2401-L2405 |
HubSpot/Singularity | SingularityExecutor/src/main/java/com/hubspot/singularity/executor/SingularityExecutor.java | SingularityExecutor.reregistered | @Override
public void reregistered(ExecutorDriver executorDriver, Protos.SlaveInfo slaveInfo) {
"""
Invoked when the executor re-registers with a restarted slave.
"""
LOG.debug("Re-registered with Mesos slave {}", slaveInfo.getId().getValue());
LOG.info("Re-registered with Mesos slave {}", MesosUtils.formatForLogging(slaveInfo));
} | java | @Override
public void reregistered(ExecutorDriver executorDriver, Protos.SlaveInfo slaveInfo) {
LOG.debug("Re-registered with Mesos slave {}", slaveInfo.getId().getValue());
LOG.info("Re-registered with Mesos slave {}", MesosUtils.formatForLogging(slaveInfo));
} | [
"@",
"Override",
"public",
"void",
"reregistered",
"(",
"ExecutorDriver",
"executorDriver",
",",
"Protos",
".",
"SlaveInfo",
"slaveInfo",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Re-registered with Mesos slave {}\"",
",",
"slaveInfo",
".",
"getId",
"(",
")",
".",
"getValue",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Re-registered with Mesos slave {}\"",
",",
"MesosUtils",
".",
"formatForLogging",
"(",
"slaveInfo",
")",
")",
";",
"}"
] | Invoked when the executor re-registers with a restarted slave. | [
"Invoked",
"when",
"the",
"executor",
"re",
"-",
"registers",
"with",
"a",
"restarted",
"slave",
"."
] | train | https://github.com/HubSpot/Singularity/blob/384a8c16a10aa076af5ca45c8dfcedab9e5122c8/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/SingularityExecutor.java#L51-L55 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/mps/task_device_log.java | task_device_log.get_nitro_bulk_response | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception {
"""
<pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre>
"""
task_device_log_responses result = (task_device_log_responses) service.get_payload_formatter().string_to_resource(task_device_log_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.task_device_log_response_array);
}
task_device_log[] result_task_device_log = new task_device_log[result.task_device_log_response_array.length];
for(int i = 0; i < result.task_device_log_response_array.length; i++)
{
result_task_device_log[i] = result.task_device_log_response_array[i].task_device_log[0];
}
return result_task_device_log;
} | java | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception
{
task_device_log_responses result = (task_device_log_responses) service.get_payload_formatter().string_to_resource(task_device_log_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.task_device_log_response_array);
}
task_device_log[] result_task_device_log = new task_device_log[result.task_device_log_response_array.length];
for(int i = 0; i < result.task_device_log_response_array.length; i++)
{
result_task_device_log[i] = result.task_device_log_response_array[i].task_device_log[0];
}
return result_task_device_log;
} | [
"protected",
"base_resource",
"[",
"]",
"get_nitro_bulk_response",
"(",
"nitro_service",
"service",
",",
"String",
"response",
")",
"throws",
"Exception",
"{",
"task_device_log_responses",
"result",
"=",
"(",
"task_device_log_responses",
")",
"service",
".",
"get_payload_formatter",
"(",
")",
".",
"string_to_resource",
"(",
"task_device_log_responses",
".",
"class",
",",
"response",
")",
";",
"if",
"(",
"result",
".",
"errorcode",
"!=",
"0",
")",
"{",
"if",
"(",
"result",
".",
"errorcode",
"==",
"SESSION_NOT_EXISTS",
")",
"service",
".",
"clear_session",
"(",
")",
";",
"throw",
"new",
"nitro_exception",
"(",
"result",
".",
"message",
",",
"result",
".",
"errorcode",
",",
"(",
"base_response",
"[",
"]",
")",
"result",
".",
"task_device_log_response_array",
")",
";",
"}",
"task_device_log",
"[",
"]",
"result_task_device_log",
"=",
"new",
"task_device_log",
"[",
"result",
".",
"task_device_log_response_array",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"task_device_log_response_array",
".",
"length",
";",
"i",
"++",
")",
"{",
"result_task_device_log",
"[",
"i",
"]",
"=",
"result",
".",
"task_device_log_response_array",
"[",
"i",
"]",
".",
"task_device_log",
"[",
"0",
"]",
";",
"}",
"return",
"result_task_device_log",
";",
"}"
] | <pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre> | [
"<pre",
">",
"Converts",
"API",
"response",
"of",
"bulk",
"operation",
"into",
"object",
"and",
"returns",
"the",
"object",
"array",
"in",
"case",
"of",
"get",
"request",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/task_device_log.java#L269-L286 |
apereo/cas | support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/web/response/callback/OAuth20AuthorizationCodeAuthorizationResponseBuilder.java | OAuth20AuthorizationCodeAuthorizationResponseBuilder.buildCallbackViewViaRedirectUri | protected ModelAndView buildCallbackViewViaRedirectUri(final J2EContext context, final String clientId,
final Authentication authentication, final OAuthCode code) {
"""
Build callback view via redirect uri model and view.
@param context the context
@param clientId the client id
@param authentication the authentication
@param code the code
@return the model and view
"""
val attributes = authentication.getAttributes();
val state = attributes.get(OAuth20Constants.STATE).get(0).toString();
val nonce = attributes.get(OAuth20Constants.NONCE).get(0).toString();
val redirectUri = context.getRequestParameter(OAuth20Constants.REDIRECT_URI);
LOGGER.debug("Authorize request verification successful for client [{}] with redirect uri [{}]", clientId, redirectUri);
var callbackUrl = redirectUri;
callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.CODE, code.getId());
if (StringUtils.isNotBlank(state)) {
callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.STATE, state);
}
if (StringUtils.isNotBlank(nonce)) {
callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.NONCE, nonce);
}
LOGGER.debug("Redirecting to URL [{}]", callbackUrl);
val params = new LinkedHashMap<String, String>();
params.put(OAuth20Constants.CODE, code.getId());
params.put(OAuth20Constants.STATE, state);
params.put(OAuth20Constants.NONCE, nonce);
params.put(OAuth20Constants.CLIENT_ID, clientId);
return buildResponseModelAndView(context, servicesManager, clientId, callbackUrl, params);
} | java | protected ModelAndView buildCallbackViewViaRedirectUri(final J2EContext context, final String clientId,
final Authentication authentication, final OAuthCode code) {
val attributes = authentication.getAttributes();
val state = attributes.get(OAuth20Constants.STATE).get(0).toString();
val nonce = attributes.get(OAuth20Constants.NONCE).get(0).toString();
val redirectUri = context.getRequestParameter(OAuth20Constants.REDIRECT_URI);
LOGGER.debug("Authorize request verification successful for client [{}] with redirect uri [{}]", clientId, redirectUri);
var callbackUrl = redirectUri;
callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.CODE, code.getId());
if (StringUtils.isNotBlank(state)) {
callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.STATE, state);
}
if (StringUtils.isNotBlank(nonce)) {
callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.NONCE, nonce);
}
LOGGER.debug("Redirecting to URL [{}]", callbackUrl);
val params = new LinkedHashMap<String, String>();
params.put(OAuth20Constants.CODE, code.getId());
params.put(OAuth20Constants.STATE, state);
params.put(OAuth20Constants.NONCE, nonce);
params.put(OAuth20Constants.CLIENT_ID, clientId);
return buildResponseModelAndView(context, servicesManager, clientId, callbackUrl, params);
} | [
"protected",
"ModelAndView",
"buildCallbackViewViaRedirectUri",
"(",
"final",
"J2EContext",
"context",
",",
"final",
"String",
"clientId",
",",
"final",
"Authentication",
"authentication",
",",
"final",
"OAuthCode",
"code",
")",
"{",
"val",
"attributes",
"=",
"authentication",
".",
"getAttributes",
"(",
")",
";",
"val",
"state",
"=",
"attributes",
".",
"get",
"(",
"OAuth20Constants",
".",
"STATE",
")",
".",
"get",
"(",
"0",
")",
".",
"toString",
"(",
")",
";",
"val",
"nonce",
"=",
"attributes",
".",
"get",
"(",
"OAuth20Constants",
".",
"NONCE",
")",
".",
"get",
"(",
"0",
")",
".",
"toString",
"(",
")",
";",
"val",
"redirectUri",
"=",
"context",
".",
"getRequestParameter",
"(",
"OAuth20Constants",
".",
"REDIRECT_URI",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Authorize request verification successful for client [{}] with redirect uri [{}]\"",
",",
"clientId",
",",
"redirectUri",
")",
";",
"var",
"callbackUrl",
"=",
"redirectUri",
";",
"callbackUrl",
"=",
"CommonHelper",
".",
"addParameter",
"(",
"callbackUrl",
",",
"OAuth20Constants",
".",
"CODE",
",",
"code",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"state",
")",
")",
"{",
"callbackUrl",
"=",
"CommonHelper",
".",
"addParameter",
"(",
"callbackUrl",
",",
"OAuth20Constants",
".",
"STATE",
",",
"state",
")",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"nonce",
")",
")",
"{",
"callbackUrl",
"=",
"CommonHelper",
".",
"addParameter",
"(",
"callbackUrl",
",",
"OAuth20Constants",
".",
"NONCE",
",",
"nonce",
")",
";",
"}",
"LOGGER",
".",
"debug",
"(",
"\"Redirecting to URL [{}]\"",
",",
"callbackUrl",
")",
";",
"val",
"params",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"params",
".",
"put",
"(",
"OAuth20Constants",
".",
"CODE",
",",
"code",
".",
"getId",
"(",
")",
")",
";",
"params",
".",
"put",
"(",
"OAuth20Constants",
".",
"STATE",
",",
"state",
")",
";",
"params",
".",
"put",
"(",
"OAuth20Constants",
".",
"NONCE",
",",
"nonce",
")",
";",
"params",
".",
"put",
"(",
"OAuth20Constants",
".",
"CLIENT_ID",
",",
"clientId",
")",
";",
"return",
"buildResponseModelAndView",
"(",
"context",
",",
"servicesManager",
",",
"clientId",
",",
"callbackUrl",
",",
"params",
")",
";",
"}"
] | Build callback view via redirect uri model and view.
@param context the context
@param clientId the client id
@param authentication the authentication
@param code the code
@return the model and view | [
"Build",
"callback",
"view",
"via",
"redirect",
"uri",
"model",
"and",
"view",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/web/response/callback/OAuth20AuthorizationCodeAuthorizationResponseBuilder.java#L68-L92 |
LearnLib/automatalib | commons/smartcollections/src/main/java/net/automatalib/commons/smartcollections/ArrayUtil.java | ArrayUtil.computeNewCapacity | public static int computeNewCapacity(int length, int requiredCapacity, int nextCapacityHint) {
"""
Computes the size of an array that is required to hold {@code requiredCapacity} number of elements.
<p>
This method first tries to increase the size of the array by a factor of 1.5 to prevent a sequence of successive
increases by 1. It then evaluates the {@code nextCapacityHint} parameter as well as the {@code requiredCapacity}
parameter to determine the next size.
@param length
the current length of the array
@param requiredCapacity
the immediately required capacity
@param nextCapacityHint
a hint for future capacity requirements that may not be required as of now
@return the size of an array that is guaranteed to hold {@code requiredCapacity} number of elements.
"""
if (requiredCapacity < length) {
return length;
}
int newCapacity = (length * 3) / 2 + 1;
if (newCapacity < nextCapacityHint) {
newCapacity = nextCapacityHint;
}
if (newCapacity < requiredCapacity) {
newCapacity = requiredCapacity;
}
return newCapacity;
} | java | public static int computeNewCapacity(int length, int requiredCapacity, int nextCapacityHint) {
if (requiredCapacity < length) {
return length;
}
int newCapacity = (length * 3) / 2 + 1;
if (newCapacity < nextCapacityHint) {
newCapacity = nextCapacityHint;
}
if (newCapacity < requiredCapacity) {
newCapacity = requiredCapacity;
}
return newCapacity;
} | [
"public",
"static",
"int",
"computeNewCapacity",
"(",
"int",
"length",
",",
"int",
"requiredCapacity",
",",
"int",
"nextCapacityHint",
")",
"{",
"if",
"(",
"requiredCapacity",
"<",
"length",
")",
"{",
"return",
"length",
";",
"}",
"int",
"newCapacity",
"=",
"(",
"length",
"*",
"3",
")",
"/",
"2",
"+",
"1",
";",
"if",
"(",
"newCapacity",
"<",
"nextCapacityHint",
")",
"{",
"newCapacity",
"=",
"nextCapacityHint",
";",
"}",
"if",
"(",
"newCapacity",
"<",
"requiredCapacity",
")",
"{",
"newCapacity",
"=",
"requiredCapacity",
";",
"}",
"return",
"newCapacity",
";",
"}"
] | Computes the size of an array that is required to hold {@code requiredCapacity} number of elements.
<p>
This method first tries to increase the size of the array by a factor of 1.5 to prevent a sequence of successive
increases by 1. It then evaluates the {@code nextCapacityHint} parameter as well as the {@code requiredCapacity}
parameter to determine the next size.
@param length
the current length of the array
@param requiredCapacity
the immediately required capacity
@param nextCapacityHint
a hint for future capacity requirements that may not be required as of now
@return the size of an array that is guaranteed to hold {@code requiredCapacity} number of elements. | [
"Computes",
"the",
"size",
"of",
"an",
"array",
"that",
"is",
"required",
"to",
"hold",
"{",
"@code",
"requiredCapacity",
"}",
"number",
"of",
"elements",
".",
"<p",
">",
"This",
"method",
"first",
"tries",
"to",
"increase",
"the",
"size",
"of",
"the",
"array",
"by",
"a",
"factor",
"of",
"1",
".",
"5",
"to",
"prevent",
"a",
"sequence",
"of",
"successive",
"increases",
"by",
"1",
".",
"It",
"then",
"evaluates",
"the",
"{",
"@code",
"nextCapacityHint",
"}",
"parameter",
"as",
"well",
"as",
"the",
"{",
"@code",
"requiredCapacity",
"}",
"parameter",
"to",
"determine",
"the",
"next",
"size",
"."
] | train | https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/commons/smartcollections/src/main/java/net/automatalib/commons/smartcollections/ArrayUtil.java#L61-L77 |
eclipse/hawkbit | hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RolloutStatusCache.java | RolloutStatusCache.putRolloutStatus | public void putRolloutStatus(final Map<Long, List<TotalTargetCountActionStatus>> put) {
"""
Put map of {@link TotalTargetCountActionStatus} for multiple
{@link Rollout}s into cache.
@param put
map of cached entries
"""
final Cache cache = cacheManager.getCache(CACHE_RO_NAME);
putIntoCache(put, cache);
} | java | public void putRolloutStatus(final Map<Long, List<TotalTargetCountActionStatus>> put) {
final Cache cache = cacheManager.getCache(CACHE_RO_NAME);
putIntoCache(put, cache);
} | [
"public",
"void",
"putRolloutStatus",
"(",
"final",
"Map",
"<",
"Long",
",",
"List",
"<",
"TotalTargetCountActionStatus",
">",
">",
"put",
")",
"{",
"final",
"Cache",
"cache",
"=",
"cacheManager",
".",
"getCache",
"(",
"CACHE_RO_NAME",
")",
";",
"putIntoCache",
"(",
"put",
",",
"cache",
")",
";",
"}"
] | Put map of {@link TotalTargetCountActionStatus} for multiple
{@link Rollout}s into cache.
@param put
map of cached entries | [
"Put",
"map",
"of",
"{",
"@link",
"TotalTargetCountActionStatus",
"}",
"for",
"multiple",
"{",
"@link",
"Rollout",
"}",
"s",
"into",
"cache",
"."
] | train | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RolloutStatusCache.java#L130-L133 |
the-fascinator/plugin-roles-internal | src/main/java/com/googlecode/fascinator/roles/internal/InternalRoles.java | InternalRoles.removeRole | @Override
public void removeRole(String username, String oldrole) throws RolesException {
"""
Remove a role from a user.
@param username
The username of the user.
@param oldrole
The role to remove from the user.
@throws RolesException
if there was an error during removal.
"""
List<String> users_with_role = new ArrayList<String>();
if (user_list.containsKey(username)) {
List<String> roles_of_user = user_list.get(username);
if (roles_of_user.contains(oldrole)) {
// Update our user list
roles_of_user.remove(oldrole);
user_list.put(username, roles_of_user);
// Update our roles list
if (role_list.containsKey(oldrole))
users_with_role = role_list.get(oldrole);
users_with_role.remove(username);
if (users_with_role.size() < 1) {
role_list.remove(oldrole);
} else {
role_list.put(oldrole, users_with_role);
}
// Don't forget to update our file_store
String roles = StringUtils.join(roles_of_user.toArray(new String[0]), ",");
file_store.setProperty(username, roles);
// And commit the file_store to disk
try {
saveRoles();
} catch (IOException e) {
throw new RolesException(e);
}
} else {
throw new RolesException("User '" + username + "' does not have the role '" + oldrole + "'!");
}
} else {
throw new RolesException("User '" + username + "' does not exist!");
}
} | java | @Override
public void removeRole(String username, String oldrole) throws RolesException {
List<String> users_with_role = new ArrayList<String>();
if (user_list.containsKey(username)) {
List<String> roles_of_user = user_list.get(username);
if (roles_of_user.contains(oldrole)) {
// Update our user list
roles_of_user.remove(oldrole);
user_list.put(username, roles_of_user);
// Update our roles list
if (role_list.containsKey(oldrole))
users_with_role = role_list.get(oldrole);
users_with_role.remove(username);
if (users_with_role.size() < 1) {
role_list.remove(oldrole);
} else {
role_list.put(oldrole, users_with_role);
}
// Don't forget to update our file_store
String roles = StringUtils.join(roles_of_user.toArray(new String[0]), ",");
file_store.setProperty(username, roles);
// And commit the file_store to disk
try {
saveRoles();
} catch (IOException e) {
throw new RolesException(e);
}
} else {
throw new RolesException("User '" + username + "' does not have the role '" + oldrole + "'!");
}
} else {
throw new RolesException("User '" + username + "' does not exist!");
}
} | [
"@",
"Override",
"public",
"void",
"removeRole",
"(",
"String",
"username",
",",
"String",
"oldrole",
")",
"throws",
"RolesException",
"{",
"List",
"<",
"String",
">",
"users_with_role",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"user_list",
".",
"containsKey",
"(",
"username",
")",
")",
"{",
"List",
"<",
"String",
">",
"roles_of_user",
"=",
"user_list",
".",
"get",
"(",
"username",
")",
";",
"if",
"(",
"roles_of_user",
".",
"contains",
"(",
"oldrole",
")",
")",
"{",
"// Update our user list",
"roles_of_user",
".",
"remove",
"(",
"oldrole",
")",
";",
"user_list",
".",
"put",
"(",
"username",
",",
"roles_of_user",
")",
";",
"// Update our roles list",
"if",
"(",
"role_list",
".",
"containsKey",
"(",
"oldrole",
")",
")",
"users_with_role",
"=",
"role_list",
".",
"get",
"(",
"oldrole",
")",
";",
"users_with_role",
".",
"remove",
"(",
"username",
")",
";",
"if",
"(",
"users_with_role",
".",
"size",
"(",
")",
"<",
"1",
")",
"{",
"role_list",
".",
"remove",
"(",
"oldrole",
")",
";",
"}",
"else",
"{",
"role_list",
".",
"put",
"(",
"oldrole",
",",
"users_with_role",
")",
";",
"}",
"// Don't forget to update our file_store",
"String",
"roles",
"=",
"StringUtils",
".",
"join",
"(",
"roles_of_user",
".",
"toArray",
"(",
"new",
"String",
"[",
"0",
"]",
")",
",",
"\",\"",
")",
";",
"file_store",
".",
"setProperty",
"(",
"username",
",",
"roles",
")",
";",
"// And commit the file_store to disk",
"try",
"{",
"saveRoles",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RolesException",
"(",
"e",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"RolesException",
"(",
"\"User '\"",
"+",
"username",
"+",
"\"' does not have the role '\"",
"+",
"oldrole",
"+",
"\"'!\"",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"RolesException",
"(",
"\"User '\"",
"+",
"username",
"+",
"\"' does not exist!\"",
")",
";",
"}",
"}"
] | Remove a role from a user.
@param username
The username of the user.
@param oldrole
The role to remove from the user.
@throws RolesException
if there was an error during removal. | [
"Remove",
"a",
"role",
"from",
"a",
"user",
"."
] | train | https://github.com/the-fascinator/plugin-roles-internal/blob/5f75f802a92ef907acf030692d462aec4b4d3aae/src/main/java/com/googlecode/fascinator/roles/internal/InternalRoles.java#L337-L373 |
httl/httl | httl/src/main/java/httl/Engine.java | Engine.getResource | public Resource getResource(String name, Locale locale) throws IOException {
"""
Get template resource.
@param name - template name
@param locale - template locale
@return template resource
@throws IOException - If an I/O error occurs
@see #getEngine()
"""
return getResource(name, locale, null);
} | java | public Resource getResource(String name, Locale locale) throws IOException {
return getResource(name, locale, null);
} | [
"public",
"Resource",
"getResource",
"(",
"String",
"name",
",",
"Locale",
"locale",
")",
"throws",
"IOException",
"{",
"return",
"getResource",
"(",
"name",
",",
"locale",
",",
"null",
")",
";",
"}"
] | Get template resource.
@param name - template name
@param locale - template locale
@return template resource
@throws IOException - If an I/O error occurs
@see #getEngine() | [
"Get",
"template",
"resource",
"."
] | train | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Engine.java#L282-L284 |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/JSONzip.java | JSONzip.logchar | static void logchar(int integer, int width) {
"""
Write a character or its code to the console.
@param integer The charcode to be written to the log.
@param width The width of the charcode in bits.
"""
if (integer > ' ' && integer <= '}') {
log("'" + (char) integer + "':" + width + " ");
} else {
log(integer, width);
}
} | java | static void logchar(int integer, int width) {
if (integer > ' ' && integer <= '}') {
log("'" + (char) integer + "':" + width + " ");
} else {
log(integer, width);
}
} | [
"static",
"void",
"logchar",
"(",
"int",
"integer",
",",
"int",
"width",
")",
"{",
"if",
"(",
"integer",
">",
"'",
"'",
"&&",
"integer",
"<=",
"'",
"'",
")",
"{",
"log",
"(",
"\"'\"",
"+",
"(",
"char",
")",
"integer",
"+",
"\"':\"",
"+",
"width",
"+",
"\" \"",
")",
";",
"}",
"else",
"{",
"log",
"(",
"integer",
",",
"width",
")",
";",
"}",
"}"
] | Write a character or its code to the console.
@param integer The charcode to be written to the log.
@param width The width of the charcode in bits. | [
"Write",
"a",
"character",
"or",
"its",
"code",
"to",
"the",
"console",
"."
] | train | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/JSONzip.java#L231-L237 |
TestFX/Monocle | src/main/java/com/sun/glass/ui/monocle/LinuxInput.java | LinuxInput.codeToString | static String codeToString(String type, short code) {
"""
Convert an event code to its equivalent string, given its type string.
The type string is needed because event codes are context sensitive. For
example, the code 1 is "SYN_CONFIG" for an EV_SYN event but "KEY_ESC" for
an EV_KEY event. This method is inefficient and is for debugging use
only.
"""
int i = type.indexOf("_");
if (i >= 0) {
String prefix = type.substring(i + 1);
String altPrefix = prefix.equals("KEY") ? "BTN" : prefix;
for (Field field : LinuxInput.class.getDeclaredFields()) {
String name = field.getName();
try {
if ((name.startsWith(prefix) || name.startsWith(altPrefix))
&& field.getType() == Short.TYPE
&& field.getShort(null) == code) {
return field.getName();
}
} catch (IllegalAccessException e) {
}
}
}
return new Formatter().format("0x%04x", code & 0xffff).out().toString();
} | java | static String codeToString(String type, short code) {
int i = type.indexOf("_");
if (i >= 0) {
String prefix = type.substring(i + 1);
String altPrefix = prefix.equals("KEY") ? "BTN" : prefix;
for (Field field : LinuxInput.class.getDeclaredFields()) {
String name = field.getName();
try {
if ((name.startsWith(prefix) || name.startsWith(altPrefix))
&& field.getType() == Short.TYPE
&& field.getShort(null) == code) {
return field.getName();
}
} catch (IllegalAccessException e) {
}
}
}
return new Formatter().format("0x%04x", code & 0xffff).out().toString();
} | [
"static",
"String",
"codeToString",
"(",
"String",
"type",
",",
"short",
"code",
")",
"{",
"int",
"i",
"=",
"type",
".",
"indexOf",
"(",
"\"_\"",
")",
";",
"if",
"(",
"i",
">=",
"0",
")",
"{",
"String",
"prefix",
"=",
"type",
".",
"substring",
"(",
"i",
"+",
"1",
")",
";",
"String",
"altPrefix",
"=",
"prefix",
".",
"equals",
"(",
"\"KEY\"",
")",
"?",
"\"BTN\"",
":",
"prefix",
";",
"for",
"(",
"Field",
"field",
":",
"LinuxInput",
".",
"class",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"String",
"name",
"=",
"field",
".",
"getName",
"(",
")",
";",
"try",
"{",
"if",
"(",
"(",
"name",
".",
"startsWith",
"(",
"prefix",
")",
"||",
"name",
".",
"startsWith",
"(",
"altPrefix",
")",
")",
"&&",
"field",
".",
"getType",
"(",
")",
"==",
"Short",
".",
"TYPE",
"&&",
"field",
".",
"getShort",
"(",
"null",
")",
"==",
"code",
")",
"{",
"return",
"field",
".",
"getName",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"}",
"}",
"}",
"return",
"new",
"Formatter",
"(",
")",
".",
"format",
"(",
"\"0x%04x\"",
",",
"code",
"&",
"0xffff",
")",
".",
"out",
"(",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Convert an event code to its equivalent string, given its type string.
The type string is needed because event codes are context sensitive. For
example, the code 1 is "SYN_CONFIG" for an EV_SYN event but "KEY_ESC" for
an EV_KEY event. This method is inefficient and is for debugging use
only. | [
"Convert",
"an",
"event",
"code",
"to",
"its",
"equivalent",
"string",
"given",
"its",
"type",
"string",
".",
"The",
"type",
"string",
"is",
"needed",
"because",
"event",
"codes",
"are",
"context",
"sensitive",
".",
"For",
"example",
"the",
"code",
"1",
"is",
"SYN_CONFIG",
"for",
"an",
"EV_SYN",
"event",
"but",
"KEY_ESC",
"for",
"an",
"EV_KEY",
"event",
".",
"This",
"method",
"is",
"inefficient",
"and",
"is",
"for",
"debugging",
"use",
"only",
"."
] | train | https://github.com/TestFX/Monocle/blob/267ccba8889cab244bf8c562dbaa0345a612874c/src/main/java/com/sun/glass/ui/monocle/LinuxInput.java#L759-L777 |
radkovo/jStyleParser | src/main/java/cz/vutbr/web/csskit/antlr4/CSSErrorStrategy.java | CSSErrorStrategy.consumeUntilGreedy | protected void consumeUntilGreedy(Parser recognizer, IntervalSet set, CSSLexerState.RecoveryMode mode) {
"""
Consumes token until lexer state is function-balanced and
token from follow is matched. Matched token is also consumed
"""
CSSToken t;
do {
Token next = recognizer.getInputStream().LT(1);
if (next instanceof CSSToken) {
t = (CSSToken) recognizer.getInputStream().LT(1);
if (t.getType() == Token.EOF) {
logger.trace("token eof ");
break;
}
} else
break; /* not a CSSToken, probably EOF */
logger.trace("Skipped greedy: {}", t.getText());
// consume token even if it will match
recognizer.consume();
}
while (!(t.getLexerState().isBalanced(mode, null, t) && set.contains(t.getType())));
} | java | protected void consumeUntilGreedy(Parser recognizer, IntervalSet set, CSSLexerState.RecoveryMode mode) {
CSSToken t;
do {
Token next = recognizer.getInputStream().LT(1);
if (next instanceof CSSToken) {
t = (CSSToken) recognizer.getInputStream().LT(1);
if (t.getType() == Token.EOF) {
logger.trace("token eof ");
break;
}
} else
break; /* not a CSSToken, probably EOF */
logger.trace("Skipped greedy: {}", t.getText());
// consume token even if it will match
recognizer.consume();
}
while (!(t.getLexerState().isBalanced(mode, null, t) && set.contains(t.getType())));
} | [
"protected",
"void",
"consumeUntilGreedy",
"(",
"Parser",
"recognizer",
",",
"IntervalSet",
"set",
",",
"CSSLexerState",
".",
"RecoveryMode",
"mode",
")",
"{",
"CSSToken",
"t",
";",
"do",
"{",
"Token",
"next",
"=",
"recognizer",
".",
"getInputStream",
"(",
")",
".",
"LT",
"(",
"1",
")",
";",
"if",
"(",
"next",
"instanceof",
"CSSToken",
")",
"{",
"t",
"=",
"(",
"CSSToken",
")",
"recognizer",
".",
"getInputStream",
"(",
")",
".",
"LT",
"(",
"1",
")",
";",
"if",
"(",
"t",
".",
"getType",
"(",
")",
"==",
"Token",
".",
"EOF",
")",
"{",
"logger",
".",
"trace",
"(",
"\"token eof \"",
")",
";",
"break",
";",
"}",
"}",
"else",
"break",
";",
"/* not a CSSToken, probably EOF */",
"logger",
".",
"trace",
"(",
"\"Skipped greedy: {}\"",
",",
"t",
".",
"getText",
"(",
")",
")",
";",
"// consume token even if it will match",
"recognizer",
".",
"consume",
"(",
")",
";",
"}",
"while",
"(",
"!",
"(",
"t",
".",
"getLexerState",
"(",
")",
".",
"isBalanced",
"(",
"mode",
",",
"null",
",",
"t",
")",
"&&",
"set",
".",
"contains",
"(",
"t",
".",
"getType",
"(",
")",
")",
")",
")",
";",
"}"
] | Consumes token until lexer state is function-balanced and
token from follow is matched. Matched token is also consumed | [
"Consumes",
"token",
"until",
"lexer",
"state",
"is",
"function",
"-",
"balanced",
"and",
"token",
"from",
"follow",
"is",
"matched",
".",
"Matched",
"token",
"is",
"also",
"consumed"
] | train | https://github.com/radkovo/jStyleParser/blob/8ab049ac6866aa52c4d7deee25c9e294e7191957/src/main/java/cz/vutbr/web/csskit/antlr4/CSSErrorStrategy.java#L72-L89 |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.prependArg | public Signature prependArg(String name, Class<?> type) {
"""
Prepend an argument (name + type) to the signature.
@param name the name of the argument
@param type the type of the argument
@return a new signature with the added arguments
"""
String[] newArgNames = new String[argNames.length + 1];
System.arraycopy(argNames, 0, newArgNames, 1, argNames.length);
newArgNames[0] = name;
MethodType newMethodType = methodType.insertParameterTypes(0, type);
return new Signature(newMethodType, newArgNames);
} | java | public Signature prependArg(String name, Class<?> type) {
String[] newArgNames = new String[argNames.length + 1];
System.arraycopy(argNames, 0, newArgNames, 1, argNames.length);
newArgNames[0] = name;
MethodType newMethodType = methodType.insertParameterTypes(0, type);
return new Signature(newMethodType, newArgNames);
} | [
"public",
"Signature",
"prependArg",
"(",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"String",
"[",
"]",
"newArgNames",
"=",
"new",
"String",
"[",
"argNames",
".",
"length",
"+",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"argNames",
",",
"0",
",",
"newArgNames",
",",
"1",
",",
"argNames",
".",
"length",
")",
";",
"newArgNames",
"[",
"0",
"]",
"=",
"name",
";",
"MethodType",
"newMethodType",
"=",
"methodType",
".",
"insertParameterTypes",
"(",
"0",
",",
"type",
")",
";",
"return",
"new",
"Signature",
"(",
"newMethodType",
",",
"newArgNames",
")",
";",
"}"
] | Prepend an argument (name + type) to the signature.
@param name the name of the argument
@param type the type of the argument
@return a new signature with the added arguments | [
"Prepend",
"an",
"argument",
"(",
"name",
"+",
"type",
")",
"to",
"the",
"signature",
"."
] | train | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L219-L225 |
census-instrumentation/opencensus-java | api/src/main/java/io/opencensus/trace/SpanId.java | SpanId.fromBytes | public static SpanId fromBytes(byte[] src, int srcOffset) {
"""
Returns a {@code SpanId} whose representation is copied from the {@code src} beginning at the
{@code srcOffset} offset.
@param src the buffer where the representation of the {@code SpanId} is copied.
@param srcOffset the offset in the buffer where the representation of the {@code SpanId}
begins.
@return a {@code SpanId} whose representation is copied from the buffer.
@throws NullPointerException if {@code src} is null.
@throws IndexOutOfBoundsException if {@code srcOffset+SpanId.SIZE} is greater than {@code
src.length}.
@since 0.5
"""
Utils.checkNotNull(src, "src");
return new SpanId(BigendianEncoding.longFromByteArray(src, srcOffset));
} | java | public static SpanId fromBytes(byte[] src, int srcOffset) {
Utils.checkNotNull(src, "src");
return new SpanId(BigendianEncoding.longFromByteArray(src, srcOffset));
} | [
"public",
"static",
"SpanId",
"fromBytes",
"(",
"byte",
"[",
"]",
"src",
",",
"int",
"srcOffset",
")",
"{",
"Utils",
".",
"checkNotNull",
"(",
"src",
",",
"\"src\"",
")",
";",
"return",
"new",
"SpanId",
"(",
"BigendianEncoding",
".",
"longFromByteArray",
"(",
"src",
",",
"srcOffset",
")",
")",
";",
"}"
] | Returns a {@code SpanId} whose representation is copied from the {@code src} beginning at the
{@code srcOffset} offset.
@param src the buffer where the representation of the {@code SpanId} is copied.
@param srcOffset the offset in the buffer where the representation of the {@code SpanId}
begins.
@return a {@code SpanId} whose representation is copied from the buffer.
@throws NullPointerException if {@code src} is null.
@throws IndexOutOfBoundsException if {@code srcOffset+SpanId.SIZE} is greater than {@code
src.length}.
@since 0.5 | [
"Returns",
"a",
"{",
"@code",
"SpanId",
"}",
"whose",
"representation",
"is",
"copied",
"from",
"the",
"{",
"@code",
"src",
"}",
"beginning",
"at",
"the",
"{",
"@code",
"srcOffset",
"}",
"offset",
"."
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/api/src/main/java/io/opencensus/trace/SpanId.java#L85-L88 |
kiegroup/droolsjbpm-integration | kie-server-parent/kie-server-remote/kie-server-client/src/main/java/org/kie/server/client/KieServicesFactory.java | KieServicesFactory.newJMSConfiguration | public static KieServicesConfiguration newJMSConfiguration( InitialContext context, String username, String password ) {
"""
Creates a new configuration object for JMS based service
@param context a context to look up for the JMS request and response queues
@param username user name
@param password user password
@return configuration instance
"""
return new KieServicesConfigurationImpl( context, username, password );
} | java | public static KieServicesConfiguration newJMSConfiguration( InitialContext context, String username, String password ) {
return new KieServicesConfigurationImpl( context, username, password );
} | [
"public",
"static",
"KieServicesConfiguration",
"newJMSConfiguration",
"(",
"InitialContext",
"context",
",",
"String",
"username",
",",
"String",
"password",
")",
"{",
"return",
"new",
"KieServicesConfigurationImpl",
"(",
"context",
",",
"username",
",",
"password",
")",
";",
"}"
] | Creates a new configuration object for JMS based service
@param context a context to look up for the JMS request and response queues
@param username user name
@param password user password
@return configuration instance | [
"Creates",
"a",
"new",
"configuration",
"object",
"for",
"JMS",
"based",
"service"
] | train | https://github.com/kiegroup/droolsjbpm-integration/blob/6c26200ab03855dbb92b56ca0c6363cdec0eaf2c/kie-server-parent/kie-server-remote/kie-server-client/src/main/java/org/kie/server/client/KieServicesFactory.java#L91-L93 |
VoltDB/voltdb | src/frontend/org/voltdb/importer/ImporterStatsCollector.java | ImporterStatsCollector.reportFailure | public void reportFailure(String importerName, String procName, boolean decrementPending) {
"""
Use this when the insert fails even before the request is queued by the InternalConnectionHandler
"""
StatsInfo statsInfo = getStatsInfo(importerName, procName);
if (decrementPending) {
statsInfo.m_pendingCount.decrementAndGet();
}
statsInfo.m_failureCount.incrementAndGet();
} | java | public void reportFailure(String importerName, String procName, boolean decrementPending) {
StatsInfo statsInfo = getStatsInfo(importerName, procName);
if (decrementPending) {
statsInfo.m_pendingCount.decrementAndGet();
}
statsInfo.m_failureCount.incrementAndGet();
} | [
"public",
"void",
"reportFailure",
"(",
"String",
"importerName",
",",
"String",
"procName",
",",
"boolean",
"decrementPending",
")",
"{",
"StatsInfo",
"statsInfo",
"=",
"getStatsInfo",
"(",
"importerName",
",",
"procName",
")",
";",
"if",
"(",
"decrementPending",
")",
"{",
"statsInfo",
".",
"m_pendingCount",
".",
"decrementAndGet",
"(",
")",
";",
"}",
"statsInfo",
".",
"m_failureCount",
".",
"incrementAndGet",
"(",
")",
";",
"}"
] | Use this when the insert fails even before the request is queued by the InternalConnectionHandler | [
"Use",
"this",
"when",
"the",
"insert",
"fails",
"even",
"before",
"the",
"request",
"is",
"queued",
"by",
"the",
"InternalConnectionHandler"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/importer/ImporterStatsCollector.java#L85-L91 |
netheosgithub/pcs_api | java/src/main/java/net/netheos/pcsapi/providers/cloudme/CloudMe.java | CloudMe.rawCreateFolder | private CMFolder rawCreateFolder( CMFolder cmParentFolder, String name ) {
"""
Issue request to create a folder with given parent folder and name.
<p/>
No checks are performed before request.
@param cmParentFolder folder of the container
@param name base name of the folder to be created
@return the new CloudMe folder
"""
StringBuilder innerXml = new StringBuilder();
innerXml.append( "<folder id='" ).append( cmParentFolder.getId() ).append( "'/>" );
innerXml.append( "<childFolder>" ).append( XmlUtils.escape( name ) ).append( "</childFolder>" );
HttpPost request = buildSoapRequest( "newFolder", innerXml.toString() );
CResponse response = retryStrategy.invokeRetry( getApiRequestInvoker( request, null ) );
Document dom = response.asDom();
String newFolderId = dom.getElementsByTagNameNS( "*", "newFolderId" ).item( 0 ).getTextContent();
return cmParentFolder.addChild( newFolderId, name );
} | java | private CMFolder rawCreateFolder( CMFolder cmParentFolder, String name )
{
StringBuilder innerXml = new StringBuilder();
innerXml.append( "<folder id='" ).append( cmParentFolder.getId() ).append( "'/>" );
innerXml.append( "<childFolder>" ).append( XmlUtils.escape( name ) ).append( "</childFolder>" );
HttpPost request = buildSoapRequest( "newFolder", innerXml.toString() );
CResponse response = retryStrategy.invokeRetry( getApiRequestInvoker( request, null ) );
Document dom = response.asDom();
String newFolderId = dom.getElementsByTagNameNS( "*", "newFolderId" ).item( 0 ).getTextContent();
return cmParentFolder.addChild( newFolderId, name );
} | [
"private",
"CMFolder",
"rawCreateFolder",
"(",
"CMFolder",
"cmParentFolder",
",",
"String",
"name",
")",
"{",
"StringBuilder",
"innerXml",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"innerXml",
".",
"append",
"(",
"\"<folder id='\"",
")",
".",
"append",
"(",
"cmParentFolder",
".",
"getId",
"(",
")",
")",
".",
"append",
"(",
"\"'/>\"",
")",
";",
"innerXml",
".",
"append",
"(",
"\"<childFolder>\"",
")",
".",
"append",
"(",
"XmlUtils",
".",
"escape",
"(",
"name",
")",
")",
".",
"append",
"(",
"\"</childFolder>\"",
")",
";",
"HttpPost",
"request",
"=",
"buildSoapRequest",
"(",
"\"newFolder\"",
",",
"innerXml",
".",
"toString",
"(",
")",
")",
";",
"CResponse",
"response",
"=",
"retryStrategy",
".",
"invokeRetry",
"(",
"getApiRequestInvoker",
"(",
"request",
",",
"null",
")",
")",
";",
"Document",
"dom",
"=",
"response",
".",
"asDom",
"(",
")",
";",
"String",
"newFolderId",
"=",
"dom",
".",
"getElementsByTagNameNS",
"(",
"\"*\"",
",",
"\"newFolderId\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
";",
"return",
"cmParentFolder",
".",
"addChild",
"(",
"newFolderId",
",",
"name",
")",
";",
"}"
] | Issue request to create a folder with given parent folder and name.
<p/>
No checks are performed before request.
@param cmParentFolder folder of the container
@param name base name of the folder to be created
@return the new CloudMe folder | [
"Issue",
"request",
"to",
"create",
"a",
"folder",
"with",
"given",
"parent",
"folder",
"and",
"name",
".",
"<p",
"/",
">",
"No",
"checks",
"are",
"performed",
"before",
"request",
"."
] | train | https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/providers/cloudme/CloudMe.java#L476-L489 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF4.java | CommonOps_DDF4.elementDiv | public static void elementDiv( DMatrix4 a , DMatrix4 b) {
"""
<p>Performs an element by element division operation:<br>
<br>
a<sub>i</sub> = a<sub>i</sub> / b<sub>i</sub> <br>
</p>
@param a The left vector in the division operation. Modified.
@param b The right vector in the division operation. Not modified.
"""
a.a1 /= b.a1;
a.a2 /= b.a2;
a.a3 /= b.a3;
a.a4 /= b.a4;
} | java | public static void elementDiv( DMatrix4 a , DMatrix4 b) {
a.a1 /= b.a1;
a.a2 /= b.a2;
a.a3 /= b.a3;
a.a4 /= b.a4;
} | [
"public",
"static",
"void",
"elementDiv",
"(",
"DMatrix4",
"a",
",",
"DMatrix4",
"b",
")",
"{",
"a",
".",
"a1",
"/=",
"b",
".",
"a1",
";",
"a",
".",
"a2",
"/=",
"b",
".",
"a2",
";",
"a",
".",
"a3",
"/=",
"b",
".",
"a3",
";",
"a",
".",
"a4",
"/=",
"b",
".",
"a4",
";",
"}"
] | <p>Performs an element by element division operation:<br>
<br>
a<sub>i</sub> = a<sub>i</sub> / b<sub>i</sub> <br>
</p>
@param a The left vector in the division operation. Modified.
@param b The right vector in the division operation. Not modified. | [
"<p",
">",
"Performs",
"an",
"element",
"by",
"element",
"division",
"operation",
":",
"<br",
">",
"<br",
">",
"a<sub",
">",
"i<",
"/",
"sub",
">",
"=",
"a<sub",
">",
"i<",
"/",
"sub",
">",
"/",
"b<sub",
">",
"i<",
"/",
"sub",
">",
"<br",
">",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF4.java#L1369-L1374 |
mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java | MercatorProjection.latitudeToTileY | public static int latitudeToTileY(double latitude, byte zoomLevel) {
"""
Converts a latitude coordinate (in degrees) to a tile Y number at a certain zoom level.
@param latitude the latitude coordinate that should be converted.
@param zoomLevel the zoom level at which the coordinate should be converted.
@return the tile Y number of the latitude value.
"""
return pixelYToTileY(latitudeToPixelY(latitude, zoomLevel, DUMMY_TILE_SIZE), zoomLevel, DUMMY_TILE_SIZE);
} | java | public static int latitudeToTileY(double latitude, byte zoomLevel) {
return pixelYToTileY(latitudeToPixelY(latitude, zoomLevel, DUMMY_TILE_SIZE), zoomLevel, DUMMY_TILE_SIZE);
} | [
"public",
"static",
"int",
"latitudeToTileY",
"(",
"double",
"latitude",
",",
"byte",
"zoomLevel",
")",
"{",
"return",
"pixelYToTileY",
"(",
"latitudeToPixelY",
"(",
"latitude",
",",
"zoomLevel",
",",
"DUMMY_TILE_SIZE",
")",
",",
"zoomLevel",
",",
"DUMMY_TILE_SIZE",
")",
";",
"}"
] | Converts a latitude coordinate (in degrees) to a tile Y number at a certain zoom level.
@param latitude the latitude coordinate that should be converted.
@param zoomLevel the zoom level at which the coordinate should be converted.
@return the tile Y number of the latitude value. | [
"Converts",
"a",
"latitude",
"coordinate",
"(",
"in",
"degrees",
")",
"to",
"a",
"tile",
"Y",
"number",
"at",
"a",
"certain",
"zoom",
"level",
"."
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java#L242-L244 |
olavloite/spanner-jdbc | src/main/java/nl/topicus/jdbc/CloudSpannerConnectionPoolDataSource.java | CloudSpannerConnectionPoolDataSource.getPooledConnection | @Override
public CloudSpannerPooledConnection getPooledConnection(String user, String password)
throws SQLException {
"""
Gets a connection which may be pooled by the app server or middleware implementation of
DataSource.
@throws java.sql.SQLException Occurs when the physical database connection cannot be
established.
"""
return new CloudSpannerPooledConnection(getConnection(user, password), defaultAutoCommit);
} | java | @Override
public CloudSpannerPooledConnection getPooledConnection(String user, String password)
throws SQLException {
return new CloudSpannerPooledConnection(getConnection(user, password), defaultAutoCommit);
} | [
"@",
"Override",
"public",
"CloudSpannerPooledConnection",
"getPooledConnection",
"(",
"String",
"user",
",",
"String",
"password",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"CloudSpannerPooledConnection",
"(",
"getConnection",
"(",
"user",
",",
"password",
")",
",",
"defaultAutoCommit",
")",
";",
"}"
] | Gets a connection which may be pooled by the app server or middleware implementation of
DataSource.
@throws java.sql.SQLException Occurs when the physical database connection cannot be
established. | [
"Gets",
"a",
"connection",
"which",
"may",
"be",
"pooled",
"by",
"the",
"app",
"server",
"or",
"middleware",
"implementation",
"of",
"DataSource",
"."
] | train | https://github.com/olavloite/spanner-jdbc/blob/b65a5185300580b143866e57501a1ea606b59aa5/src/main/java/nl/topicus/jdbc/CloudSpannerConnectionPoolDataSource.java#L65-L69 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.