repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 201 | func_name stringlengths 4 126 | whole_func_string stringlengths 75 3.57k | language stringclasses 1
value | func_code_string stringlengths 75 3.57k | func_code_tokens listlengths 21 599 | func_documentation_string stringlengths 61 1.95k | func_documentation_tokens listlengths 1 478 | split_name stringclasses 1
value | func_code_url stringlengths 111 308 |
|---|---|---|---|---|---|---|---|---|---|---|
twitter/scalding | scalding-serialization/src/main/java/com/twitter/scalding/serialization/Undeprecated.java | Undeprecated.getAsciiBytes | @SuppressWarnings("deprecation")
public static void getAsciiBytes(String element, int charStart, int charLen, byte[] bytes, int byteOffset) {
element.getBytes(charStart, charLen, bytes, byteOffset);
} | java | @SuppressWarnings("deprecation")
public static void getAsciiBytes(String element, int charStart, int charLen, byte[] bytes, int byteOffset) {
element.getBytes(charStart, charLen, bytes, byteOffset);
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"void",
"getAsciiBytes",
"(",
"String",
"element",
",",
"int",
"charStart",
",",
"int",
"charLen",
",",
"byte",
"[",
"]",
"bytes",
",",
"int",
"byteOffset",
")",
"{",
"element",
".",
... | This method is faster for ASCII data, but unsafe otherwise
it is used by our macros AFTER checking that the string is ASCII
following a pattern seen in Kryo, which benchmarking showed helped.
Scala cannot supress warnings like this so we do it here | [
"This",
"method",
"is",
"faster",
"for",
"ASCII",
"data",
"but",
"unsafe",
"otherwise",
"it",
"is",
"used",
"by",
"our",
"macros",
"AFTER",
"checking",
"that",
"the",
"string",
"is",
"ASCII",
"following",
"a",
"pattern",
"seen",
"in",
"Kryo",
"which",
"ben... | train | https://github.com/twitter/scalding/blob/428b5507279655676e507d52c669c3cbc7812dc0/scalding-serialization/src/main/java/com/twitter/scalding/serialization/Undeprecated.java#L25-L28 |
ksclarke/vertx-pairtree | src/main/java/info/freelibrary/pairtree/PairtreeFactory.java | PairtreeFactory.getPrefixedPairtree | public Pairtree getPrefixedPairtree(final String aPrefix, final File aDirectory) throws PairtreeException {
return new FsPairtree(aPrefix, myVertx, getDirPath(aDirectory));
} | java | public Pairtree getPrefixedPairtree(final String aPrefix, final File aDirectory) throws PairtreeException {
return new FsPairtree(aPrefix, myVertx, getDirPath(aDirectory));
} | [
"public",
"Pairtree",
"getPrefixedPairtree",
"(",
"final",
"String",
"aPrefix",
",",
"final",
"File",
"aDirectory",
")",
"throws",
"PairtreeException",
"{",
"return",
"new",
"FsPairtree",
"(",
"aPrefix",
",",
"myVertx",
",",
"getDirPath",
"(",
"aDirectory",
")",
... | Gets a file system based Pairtree using the supplied directory as the Pairtree root and the supplied prefix as
the Pairtree prefix.
@param aPrefix A Pairtree prefix
@param aDirectory A directory to use for the Pairtree root
@return A Pairtree root
@throws PairtreeException If there is trouble creating the Pairtree | [
"Gets",
"a",
"file",
"system",
"based",
"Pairtree",
"using",
"the",
"supplied",
"directory",
"as",
"the",
"Pairtree",
"root",
"and",
"the",
"supplied",
"prefix",
"as",
"the",
"Pairtree",
"prefix",
"."
] | train | https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/PairtreeFactory.java#L83-L85 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/DateTimeFormatter.java | DateTimeFormatter.printTo | public void printTo(Appendable appendable, ReadablePartial partial) throws IOException {
InternalPrinter printer = requirePrinter();
if (partial == null) {
throw new IllegalArgumentException("The partial must not be null");
}
printer.printTo(appendable, partial, iLocale);
} | java | public void printTo(Appendable appendable, ReadablePartial partial) throws IOException {
InternalPrinter printer = requirePrinter();
if (partial == null) {
throw new IllegalArgumentException("The partial must not be null");
}
printer.printTo(appendable, partial, iLocale);
} | [
"public",
"void",
"printTo",
"(",
"Appendable",
"appendable",
",",
"ReadablePartial",
"partial",
")",
"throws",
"IOException",
"{",
"InternalPrinter",
"printer",
"=",
"requirePrinter",
"(",
")",
";",
"if",
"(",
"partial",
"==",
"null",
")",
"{",
"throw",
"new"... | Prints a ReadablePartial.
<p>
Neither the override chronology nor the override zone are used
by this method.
@param appendable the destination to format to, not null
@param partial partial to format
@since 2.0 | [
"Prints",
"a",
"ReadablePartial",
".",
"<p",
">",
"Neither",
"the",
"override",
"chronology",
"nor",
"the",
"override",
"zone",
"are",
"used",
"by",
"this",
"method",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatter.java#L650-L656 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/Channel.java | Channel.sendInstantiationProposal | public Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest,
Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
checkChannelState();
if (null == instantiateProposalRequest) {
throw new InvalidArgumentException("InstantiateProposalRequest is null");
}
instantiateProposalRequest.setSubmitted();
checkPeers(peers);
try {
TransactionContext transactionContext = getTransactionContext(instantiateProposalRequest.getUserContext());
transactionContext.setProposalWaitTime(instantiateProposalRequest.getProposalWaitTime());
InstantiateProposalBuilder instantiateProposalbuilder = InstantiateProposalBuilder.newBuilder();
instantiateProposalbuilder.context(transactionContext);
instantiateProposalbuilder.argss(instantiateProposalRequest.getArgs());
instantiateProposalbuilder.chaincodeName(instantiateProposalRequest.getChaincodeName());
instantiateProposalbuilder.chaincodeType(instantiateProposalRequest.getChaincodeLanguage());
instantiateProposalbuilder.chaincodePath(instantiateProposalRequest.getChaincodePath());
instantiateProposalbuilder.chaincodeVersion(instantiateProposalRequest.getChaincodeVersion());
instantiateProposalbuilder.chaincodEndorsementPolicy(instantiateProposalRequest.getChaincodeEndorsementPolicy());
instantiateProposalbuilder.chaincodeCollectionConfiguration(instantiateProposalRequest.getChaincodeCollectionConfiguration());
instantiateProposalbuilder.setTransientMap(instantiateProposalRequest.getTransientMap());
FabricProposal.Proposal instantiateProposal = instantiateProposalbuilder.build();
SignedProposal signedProposal = getSignedProposal(transactionContext, instantiateProposal);
return sendProposalToPeers(peers, signedProposal, transactionContext);
} catch (Exception e) {
throw new ProposalException(e);
}
} | java | public Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest,
Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
checkChannelState();
if (null == instantiateProposalRequest) {
throw new InvalidArgumentException("InstantiateProposalRequest is null");
}
instantiateProposalRequest.setSubmitted();
checkPeers(peers);
try {
TransactionContext transactionContext = getTransactionContext(instantiateProposalRequest.getUserContext());
transactionContext.setProposalWaitTime(instantiateProposalRequest.getProposalWaitTime());
InstantiateProposalBuilder instantiateProposalbuilder = InstantiateProposalBuilder.newBuilder();
instantiateProposalbuilder.context(transactionContext);
instantiateProposalbuilder.argss(instantiateProposalRequest.getArgs());
instantiateProposalbuilder.chaincodeName(instantiateProposalRequest.getChaincodeName());
instantiateProposalbuilder.chaincodeType(instantiateProposalRequest.getChaincodeLanguage());
instantiateProposalbuilder.chaincodePath(instantiateProposalRequest.getChaincodePath());
instantiateProposalbuilder.chaincodeVersion(instantiateProposalRequest.getChaincodeVersion());
instantiateProposalbuilder.chaincodEndorsementPolicy(instantiateProposalRequest.getChaincodeEndorsementPolicy());
instantiateProposalbuilder.chaincodeCollectionConfiguration(instantiateProposalRequest.getChaincodeCollectionConfiguration());
instantiateProposalbuilder.setTransientMap(instantiateProposalRequest.getTransientMap());
FabricProposal.Proposal instantiateProposal = instantiateProposalbuilder.build();
SignedProposal signedProposal = getSignedProposal(transactionContext, instantiateProposal);
return sendProposalToPeers(peers, signedProposal, transactionContext);
} catch (Exception e) {
throw new ProposalException(e);
}
} | [
"public",
"Collection",
"<",
"ProposalResponse",
">",
"sendInstantiationProposal",
"(",
"InstantiateProposalRequest",
"instantiateProposalRequest",
",",
"Collection",
"<",
"Peer",
">",
"peers",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"check... | Send instantiate request to the channel. Chaincode is created and initialized.
@param instantiateProposalRequest
@param peers
@return responses from peers.
@throws InvalidArgumentException
@throws ProposalException
@deprecated See new lifecycle chaincode management. {@link LifecycleInstallChaincodeRequest} | [
"Send",
"instantiate",
"request",
"to",
"the",
"channel",
".",
"Chaincode",
"is",
"created",
"and",
"initialized",
"."
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2445-L2477 |
killbill/killbill | profiles/killbill/src/main/java/org/killbill/billing/server/log/obfuscators/Obfuscator.java | Obfuscator.obfuscateConfidentialData | @VisibleForTesting
String obfuscateConfidentialData(final CharSequence confidentialSequence, @Nullable final CharSequence unmasked) {
final int maskedLength = unmasked == null ? confidentialSequence.length() : confidentialSequence.length() - unmasked.length();
return new String(new char[maskedLength]).replace('\0', PAD_CHAR);
} | java | @VisibleForTesting
String obfuscateConfidentialData(final CharSequence confidentialSequence, @Nullable final CharSequence unmasked) {
final int maskedLength = unmasked == null ? confidentialSequence.length() : confidentialSequence.length() - unmasked.length();
return new String(new char[maskedLength]).replace('\0', PAD_CHAR);
} | [
"@",
"VisibleForTesting",
"String",
"obfuscateConfidentialData",
"(",
"final",
"CharSequence",
"confidentialSequence",
",",
"@",
"Nullable",
"final",
"CharSequence",
"unmasked",
")",
"{",
"final",
"int",
"maskedLength",
"=",
"unmasked",
"==",
"null",
"?",
"confidentia... | Get a mask string for masking the given `confidentialSequence`.
@param confidentialSequence the string to be obfuscated
@param unmasked the section of `confidentialSequence` to be left unmasked
@return a mask string | [
"Get",
"a",
"mask",
"string",
"for",
"masking",
"the",
"given",
"confidentialSequence",
"."
] | train | https://github.com/killbill/killbill/blob/6457b485fb32a182c76197a83f428123331f1380/profiles/killbill/src/main/java/org/killbill/billing/server/log/obfuscators/Obfuscator.java#L101-L105 |
atomix/atomix | protocols/raft/src/main/java/io/atomix/protocols/raft/roles/PassiveRole.java | PassiveRole.completeAppend | protected boolean completeAppend(boolean succeeded, long lastLogIndex, CompletableFuture<AppendResponse> future) {
future.complete(logResponse(AppendResponse.builder()
.withStatus(RaftResponse.Status.OK)
.withTerm(raft.getTerm())
.withSucceeded(succeeded)
.withLastLogIndex(lastLogIndex)
.build()));
return succeeded;
} | java | protected boolean completeAppend(boolean succeeded, long lastLogIndex, CompletableFuture<AppendResponse> future) {
future.complete(logResponse(AppendResponse.builder()
.withStatus(RaftResponse.Status.OK)
.withTerm(raft.getTerm())
.withSucceeded(succeeded)
.withLastLogIndex(lastLogIndex)
.build()));
return succeeded;
} | [
"protected",
"boolean",
"completeAppend",
"(",
"boolean",
"succeeded",
",",
"long",
"lastLogIndex",
",",
"CompletableFuture",
"<",
"AppendResponse",
">",
"future",
")",
"{",
"future",
".",
"complete",
"(",
"logResponse",
"(",
"AppendResponse",
".",
"builder",
"(",... | Returns a successful append response.
@param succeeded whether the append succeeded
@param lastLogIndex the last log index
@param future the append response future
@return the append response status | [
"Returns",
"a",
"successful",
"append",
"response",
"."
] | train | https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/roles/PassiveRole.java#L362-L370 |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java | AuthenticationAPIClient.passwordlessWithSMS | @SuppressWarnings("WeakerAccess")
public ParameterizableRequest<Void, AuthenticationException> passwordlessWithSMS(@NonNull String phoneNumber, @NonNull PasswordlessType passwordlessType) {
return passwordlessWithSMS(phoneNumber, passwordlessType, SMS_CONNECTION);
} | java | @SuppressWarnings("WeakerAccess")
public ParameterizableRequest<Void, AuthenticationException> passwordlessWithSMS(@NonNull String phoneNumber, @NonNull PasswordlessType passwordlessType) {
return passwordlessWithSMS(phoneNumber, passwordlessType, SMS_CONNECTION);
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"public",
"ParameterizableRequest",
"<",
"Void",
",",
"AuthenticationException",
">",
"passwordlessWithSMS",
"(",
"@",
"NonNull",
"String",
"phoneNumber",
",",
"@",
"NonNull",
"PasswordlessType",
"passwordlessType",
... | Start a passwordless flow with a <a href="https://auth0.com/docs/api/authentication#get-code-or-link">SMS</a>
By default it will try to authenticate using the "sms" connection.
Requires your Application to have the <b>Resource Owner</b> Legacy Grant Type enabled. See <a href="https://auth0.com/docs/clients/client-grant-types">Client Grant Types</a> to learn how to enable it.
Example usage:
<pre>
{@code
client.passwordlessWithSms("{phone number}", PasswordlessType.CODE)
.start(new BaseCallback<Void>() {
{@literal}Override
public void onSuccess(Void payload) {}
{@literal}Override
public void onFailure(AuthenticationException error) {}
});
}
</pre>
@param phoneNumber where an SMS with a verification code will be sent
@param passwordlessType indicate whether the SMS should contain a code, link or magic link (android {@literal &} iOS)
@return a request to configure and start | [
"Start",
"a",
"passwordless",
"flow",
"with",
"a",
"<a",
"href",
"=",
"https",
":",
"//",
"auth0",
".",
"com",
"/",
"docs",
"/",
"api",
"/",
"authentication#get",
"-",
"code",
"-",
"or",
"-",
"link",
">",
"SMS<",
"/",
"a",
">",
"By",
"default",
"it... | train | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java#L946-L949 |
jbundle/jbundle | base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XBaseGridScreen.java | XBaseGridScreen.printControlStartForm | public void printControlStartForm(PrintWriter out, int iPrintOptions)
{
super.printControlStartForm(out, iPrintOptions);
BasePanel scrHeading = ((BaseGridScreen)this.getScreenField()).getReportHeading();
if (scrHeading != null)
{
out.println(Utility.startTag(XMLTags.HEADING));
scrHeading.printControl(out, iPrintOptions | HtmlConstants.HEADING_SCREEN);
out.println(Utility.endTag(XMLTags.HEADING));
}
Record record = ((BaseGridScreen)this.getScreenField()).getMainRecord();
if (record == null)
return;
String strRecordName = record.getTableNames(false);
if ((strRecordName == null) || (strRecordName.length() == 0))
strRecordName = "Record";
out.println(Utility.startTag(XMLTags.DETAIL + " name=\"" + strRecordName + "\""));
this.printHeadingFootingControls(out, iPrintOptions | HtmlConstants.HEADING_SCREEN);
} | java | public void printControlStartForm(PrintWriter out, int iPrintOptions)
{
super.printControlStartForm(out, iPrintOptions);
BasePanel scrHeading = ((BaseGridScreen)this.getScreenField()).getReportHeading();
if (scrHeading != null)
{
out.println(Utility.startTag(XMLTags.HEADING));
scrHeading.printControl(out, iPrintOptions | HtmlConstants.HEADING_SCREEN);
out.println(Utility.endTag(XMLTags.HEADING));
}
Record record = ((BaseGridScreen)this.getScreenField()).getMainRecord();
if (record == null)
return;
String strRecordName = record.getTableNames(false);
if ((strRecordName == null) || (strRecordName.length() == 0))
strRecordName = "Record";
out.println(Utility.startTag(XMLTags.DETAIL + " name=\"" + strRecordName + "\""));
this.printHeadingFootingControls(out, iPrintOptions | HtmlConstants.HEADING_SCREEN);
} | [
"public",
"void",
"printControlStartForm",
"(",
"PrintWriter",
"out",
",",
"int",
"iPrintOptions",
")",
"{",
"super",
".",
"printControlStartForm",
"(",
"out",
",",
"iPrintOptions",
")",
";",
"BasePanel",
"scrHeading",
"=",
"(",
"(",
"BaseGridScreen",
")",
"this... | Display the start form in input format.
@param out The out stream.
@param iPrintOptions The view specific attributes. | [
"Display",
"the",
"start",
"form",
"in",
"input",
"format",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XBaseGridScreen.java#L91-L111 |
gallandarakhneorg/afc | core/maths/mathgraph/src/main/java/org/arakhne/afc/math/graph/astar/AStar.java | AStar.solve | protected GP solve(AStarNode<ST, PT> startPoint, PT endPoint) {
final List<AStarNode<ST, PT>> closeList;
fireAlgorithmStart(startPoint, endPoint);
// Run A*
closeList = findPath(startPoint, endPoint);
if (closeList == null || closeList.isEmpty()) {
return null;
}
fireAlgorithmEnd(closeList);
// Create the path
return createPath(startPoint, endPoint, closeList);
} | java | protected GP solve(AStarNode<ST, PT> startPoint, PT endPoint) {
final List<AStarNode<ST, PT>> closeList;
fireAlgorithmStart(startPoint, endPoint);
// Run A*
closeList = findPath(startPoint, endPoint);
if (closeList == null || closeList.isEmpty()) {
return null;
}
fireAlgorithmEnd(closeList);
// Create the path
return createPath(startPoint, endPoint, closeList);
} | [
"protected",
"GP",
"solve",
"(",
"AStarNode",
"<",
"ST",
",",
"PT",
">",
"startPoint",
",",
"PT",
"endPoint",
")",
"{",
"final",
"List",
"<",
"AStarNode",
"<",
"ST",
",",
"PT",
">",
">",
"closeList",
";",
"fireAlgorithmStart",
"(",
"startPoint",
",",
"... | Run the A* algorithm assuming that the graph is oriented is
an orientation tool was passed to the constructor.
<p>The orientation of the graph may also be overridden by the implementations
of the {@link AStarNode A* nodes}.
@param startPoint is the starting point.
@param endPoint is the point to reach.
@return the found path, or <code>null</code> if none found. | [
"Run",
"the",
"A",
"*",
"algorithm",
"assuming",
"that",
"the",
"graph",
"is",
"oriented",
"is",
"an",
"orientation",
"tool",
"was",
"passed",
"to",
"the",
"constructor",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgraph/src/main/java/org/arakhne/afc/math/graph/astar/AStar.java#L433-L448 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-integrations/valkyrie-rcp-jideoss/src/main/java/org/valkyriercp/component/SearchableInterceptor.java | SearchableInterceptor.processComponent | @Override
public void processComponent(String propertyName, JComponent component) {
if (component instanceof JComboBox) {
this.installSearchable((JComboBox) component);
} else if (component instanceof JList) {
this.installSearchable((JList) component);
} else if (component instanceof JTable) {
this.installSearchable((JTable) component);
} else if (component instanceof JTextComponent) {
this.installSearchable((JTextComponent) component);
}
} | java | @Override
public void processComponent(String propertyName, JComponent component) {
if (component instanceof JComboBox) {
this.installSearchable((JComboBox) component);
} else if (component instanceof JList) {
this.installSearchable((JList) component);
} else if (component instanceof JTable) {
this.installSearchable((JTable) component);
} else if (component instanceof JTextComponent) {
this.installSearchable((JTextComponent) component);
}
} | [
"@",
"Override",
"public",
"void",
"processComponent",
"(",
"String",
"propertyName",
",",
"JComponent",
"component",
")",
"{",
"if",
"(",
"component",
"instanceof",
"JComboBox",
")",
"{",
"this",
".",
"installSearchable",
"(",
"(",
"JComboBox",
")",
"component"... | Installs a <code>Searchable</code> into the given component.
@param propertyName
the property name.
@param component
the target component. | [
"Installs",
"a",
"<code",
">",
"Searchable<",
"/",
"code",
">",
"into",
"the",
"given",
"component",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-integrations/valkyrie-rcp-jideoss/src/main/java/org/valkyriercp/component/SearchableInterceptor.java#L116-L128 |
zxing/zxing | core/src/main/java/com/google/zxing/oned/ITFReader.java | ITFReader.validateQuietZone | private void validateQuietZone(BitArray row, int startPattern) throws NotFoundException {
int quietCount = this.narrowLineWidth * 10; // expect to find this many pixels of quiet zone
// if there are not so many pixel at all let's try as many as possible
quietCount = quietCount < startPattern ? quietCount : startPattern;
for (int i = startPattern - 1; quietCount > 0 && i >= 0; i--) {
if (row.get(i)) {
break;
}
quietCount--;
}
if (quietCount != 0) {
// Unable to find the necessary number of quiet zone pixels.
throw NotFoundException.getNotFoundInstance();
}
} | java | private void validateQuietZone(BitArray row, int startPattern) throws NotFoundException {
int quietCount = this.narrowLineWidth * 10; // expect to find this many pixels of quiet zone
// if there are not so many pixel at all let's try as many as possible
quietCount = quietCount < startPattern ? quietCount : startPattern;
for (int i = startPattern - 1; quietCount > 0 && i >= 0; i--) {
if (row.get(i)) {
break;
}
quietCount--;
}
if (quietCount != 0) {
// Unable to find the necessary number of quiet zone pixels.
throw NotFoundException.getNotFoundInstance();
}
} | [
"private",
"void",
"validateQuietZone",
"(",
"BitArray",
"row",
",",
"int",
"startPattern",
")",
"throws",
"NotFoundException",
"{",
"int",
"quietCount",
"=",
"this",
".",
"narrowLineWidth",
"*",
"10",
";",
"// expect to find this many pixels of quiet zone",
"// if ther... | The start & end patterns must be pre/post fixed by a quiet zone. This
zone must be at least 10 times the width of a narrow line. Scan back until
we either get to the start of the barcode or match the necessary number of
quiet zone pixels.
Note: Its assumed the row is reversed when using this method to find
quiet zone after the end pattern.
ref: http://www.barcode-1.net/i25code.html
@param row bit array representing the scanned barcode.
@param startPattern index into row of the start or end pattern.
@throws NotFoundException if the quiet zone cannot be found | [
"The",
"start",
"&",
"end",
"patterns",
"must",
"be",
"pre",
"/",
"post",
"fixed",
"by",
"a",
"quiet",
"zone",
".",
"This",
"zone",
"must",
"be",
"at",
"least",
"10",
"times",
"the",
"width",
"of",
"a",
"narrow",
"line",
".",
"Scan",
"back",
"until",... | train | https://github.com/zxing/zxing/blob/653ac2a3beb11481eff82e7d5f2bab8a745f7fac/core/src/main/java/com/google/zxing/oned/ITFReader.java#L228-L245 |
dropbox/dropbox-sdk-java | src/main/java/com/dropbox/core/v1/DbxClientV1.java | DbxClientV1.getMetadataWithChildren | public DbxEntry./*@Nullable*/WithChildren getMetadataWithChildren(String path, boolean includeMediaInfo)
throws DbxException
{
return getMetadataWithChildrenBase(path, includeMediaInfo, DbxEntry.WithChildren.ReaderMaybeDeleted);
} | java | public DbxEntry./*@Nullable*/WithChildren getMetadataWithChildren(String path, boolean includeMediaInfo)
throws DbxException
{
return getMetadataWithChildrenBase(path, includeMediaInfo, DbxEntry.WithChildren.ReaderMaybeDeleted);
} | [
"public",
"DbxEntry",
".",
"/*@Nullable*/",
"WithChildren",
"getMetadataWithChildren",
"(",
"String",
"path",
",",
"boolean",
"includeMediaInfo",
")",
"throws",
"DbxException",
"{",
"return",
"getMetadataWithChildrenBase",
"(",
"path",
",",
"includeMediaInfo",
",",
"Dbx... | Get the metadata for a given path; if the path refers to a folder,
get all the children's metadata as well.
<pre>
DbxClientV1 dbxClient = ...
DbxEntry entry = dbxClient.getMetadata("/Photos");
if (entry == null) {
System.out.println("No file or folder at that path.");
} else {
System.out.print(entry.toStringMultiline());
}
</pre>
@param path
The path (starting with "/") to the file or folder (see {@link DbxPathV1}).
@param includeMediaInfo
If {@code true}, then if the return value is a {@link DbxEntry.File}, it might have
its {@code photoInfo} and {@code mediaInfo} fields filled in.
@return If there is no file or folder at the given path, return {@code null}.
Otherwise, return the metadata for that path and the metadata for all its immediate
children (if it's a folder). | [
"Get",
"the",
"metadata",
"for",
"a",
"given",
"path",
";",
"if",
"the",
"path",
"refers",
"to",
"a",
"folder",
"get",
"all",
"the",
"children",
"s",
"metadata",
"as",
"well",
"."
] | train | https://github.com/dropbox/dropbox-sdk-java/blob/d86157005fad6233c18b4b0f10f00b8d9d56ae92/src/main/java/com/dropbox/core/v1/DbxClientV1.java#L174-L178 |
Azure/azure-sdk-for-java | cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/CollectionsInner.java | CollectionsInner.listMetrics | public List<MetricInner> listMetrics(String resourceGroupName, String accountName, String databaseRid, String collectionRid, String filter) {
return listMetricsWithServiceResponseAsync(resourceGroupName, accountName, databaseRid, collectionRid, filter).toBlocking().single().body();
} | java | public List<MetricInner> listMetrics(String resourceGroupName, String accountName, String databaseRid, String collectionRid, String filter) {
return listMetricsWithServiceResponseAsync(resourceGroupName, accountName, databaseRid, collectionRid, filter).toBlocking().single().body();
} | [
"public",
"List",
"<",
"MetricInner",
">",
"listMetrics",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"databaseRid",
",",
"String",
"collectionRid",
",",
"String",
"filter",
")",
"{",
"return",
"listMetricsWithServiceResponseAsync"... | Retrieves the metrics determined by the given filter for the given database account and collection.
@param resourceGroupName Name of an Azure resource group.
@param accountName Cosmos DB database account name.
@param databaseRid Cosmos DB database rid.
@param collectionRid Cosmos DB collection rid.
@param filter An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and timeGrain. The supported operator is eq.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<MetricInner> object if successful. | [
"Retrieves",
"the",
"metrics",
"determined",
"by",
"the",
"given",
"filter",
"for",
"the",
"given",
"database",
"account",
"and",
"collection",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/CollectionsInner.java#L82-L84 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nearestneighbors-parent/deeplearning4j-nearestneighbors-client/src/main/java/org/deeplearning4j/nearestneighbor/client/NearestNeighborsClient.java | NearestNeighborsClient.knnNew | public NearestNeighborsResults knnNew(int k, INDArray arr) throws Exception {
Base64NDArrayBody base64NDArrayBody =
Base64NDArrayBody.builder().k(k).ndarray(Nd4jBase64.base64String(arr)).build();
HttpRequestWithBody req = Unirest.post(url + "/knnnew");
req.header("accept", "application/json")
.header("Content-Type", "application/json").body(base64NDArrayBody);
addAuthHeader(req);
NearestNeighborsResults ret = req.asObject(NearestNeighborsResults.class).getBody();
return ret;
} | java | public NearestNeighborsResults knnNew(int k, INDArray arr) throws Exception {
Base64NDArrayBody base64NDArrayBody =
Base64NDArrayBody.builder().k(k).ndarray(Nd4jBase64.base64String(arr)).build();
HttpRequestWithBody req = Unirest.post(url + "/knnnew");
req.header("accept", "application/json")
.header("Content-Type", "application/json").body(base64NDArrayBody);
addAuthHeader(req);
NearestNeighborsResults ret = req.asObject(NearestNeighborsResults.class).getBody();
return ret;
} | [
"public",
"NearestNeighborsResults",
"knnNew",
"(",
"int",
"k",
",",
"INDArray",
"arr",
")",
"throws",
"Exception",
"{",
"Base64NDArrayBody",
"base64NDArrayBody",
"=",
"Base64NDArrayBody",
".",
"builder",
"(",
")",
".",
"k",
"(",
"k",
")",
".",
"ndarray",
"(",... | Run a k nearest neighbors search
on a NEW data point
@param k the number of results
to retrieve
@param arr the array to run the search on.
Note that this must be a row vector
@return
@throws Exception | [
"Run",
"a",
"k",
"nearest",
"neighbors",
"search",
"on",
"a",
"NEW",
"data",
"point"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nearestneighbors-parent/deeplearning4j-nearestneighbors-client/src/main/java/org/deeplearning4j/nearestneighbor/client/NearestNeighborsClient.java#L111-L123 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ULocale.java | ULocale.getDisplayNameWithDialect | public static String getDisplayNameWithDialect(String localeID, ULocale displayLocale) {
return getDisplayNameWithDialectInternal(new ULocale(localeID), displayLocale);
} | java | public static String getDisplayNameWithDialect(String localeID, ULocale displayLocale) {
return getDisplayNameWithDialectInternal(new ULocale(localeID), displayLocale);
} | [
"public",
"static",
"String",
"getDisplayNameWithDialect",
"(",
"String",
"localeID",
",",
"ULocale",
"displayLocale",
")",
"{",
"return",
"getDisplayNameWithDialectInternal",
"(",
"new",
"ULocale",
"(",
"localeID",
")",
",",
"displayLocale",
")",
";",
"}"
] | <strong>[icu]</strong> Returns the locale ID localized for display in the provided locale.
If a dialect name is present in the locale data, then it is returned.
This is a cover for the ICU4C API.
@param localeID the locale whose name is to be displayed.
@param displayLocale the locale in which to display the locale name.
@return the localized locale name. | [
"<strong",
">",
"[",
"icu",
"]",
"<",
"/",
"strong",
">",
"Returns",
"the",
"locale",
"ID",
"localized",
"for",
"display",
"in",
"the",
"provided",
"locale",
".",
"If",
"a",
"dialect",
"name",
"is",
"present",
"in",
"the",
"locale",
"data",
"then",
"it... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ULocale.java#L1838-L1840 |
couchbase/couchbase-lite-java-core | src/main/java/com/couchbase/lite/Manager.java | Manager.registerEncryptionKey | @InterfaceAudience.Public
public boolean registerEncryptionKey(Object keyOrPassword, String databaseName) {
if (databaseName == null)
return false;
if (keyOrPassword != null) {
encryptionKeys.put(databaseName, keyOrPassword);
} else
encryptionKeys.remove(databaseName);
return true;
} | java | @InterfaceAudience.Public
public boolean registerEncryptionKey(Object keyOrPassword, String databaseName) {
if (databaseName == null)
return false;
if (keyOrPassword != null) {
encryptionKeys.put(databaseName, keyOrPassword);
} else
encryptionKeys.remove(databaseName);
return true;
} | [
"@",
"InterfaceAudience",
".",
"Public",
"public",
"boolean",
"registerEncryptionKey",
"(",
"Object",
"keyOrPassword",
",",
"String",
"databaseName",
")",
"{",
"if",
"(",
"databaseName",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"keyOrPassword",
"!="... | This method has been superseded by {@link #openDatabase(String, DatabaseOptions)}.
Registers an encryption key for a database. This must be called _before_ opening an encrypted
database, or before creating a database that's to be encrypted.
If the key is incorrect (or no key is given for an encrypted database), the subsequent call
to open the database will fail with an error with code 401.
To use this API, the database storage engine must support encryption, and the
ManagerOptions.EnableStorageEncryption property must be set to true. Otherwise opening
the database will fail with an error.
@param keyOrPassword The encryption key in the form of an String (a password) or an
byte[] object exactly 32 bytes in length (a raw AES key.)
If a string is given, it will be internally converted to a raw key
using 64,000 rounds of PBKDF2 hashing.
A null value is legal, and clears a previously-registered key.
@param databaseName The name of the database.
@return True if the key can be used, False if it's not in a legal form
(e.g. key as a byte[] is not 32 bytes in length.) | [
"This",
"method",
"has",
"been",
"superseded",
"by",
"{",
"@link",
"#openDatabase",
"(",
"String",
"DatabaseOptions",
")",
"}",
"."
] | train | https://github.com/couchbase/couchbase-lite-java-core/blob/3b275642e2d2f231fd155ad9def9c5e9eff3118e/src/main/java/com/couchbase/lite/Manager.java#L366-L375 |
PunchThrough/bean-sdk-android | sdk/src/main/java/com/punchthrough/bean/sdk/Bean.java | Bean.setPin | public void setPin(int pin, boolean active) {
Buffer buffer = new Buffer();
buffer.writeIntLe(pin);
buffer.writeByte(active ? 1 : 0);
sendMessage(BeanMessageID.BT_SET_PIN, buffer);
} | java | public void setPin(int pin, boolean active) {
Buffer buffer = new Buffer();
buffer.writeIntLe(pin);
buffer.writeByte(active ? 1 : 0);
sendMessage(BeanMessageID.BT_SET_PIN, buffer);
} | [
"public",
"void",
"setPin",
"(",
"int",
"pin",
",",
"boolean",
"active",
")",
"{",
"Buffer",
"buffer",
"=",
"new",
"Buffer",
"(",
")",
";",
"buffer",
".",
"writeIntLe",
"(",
"pin",
")",
";",
"buffer",
".",
"writeByte",
"(",
"active",
"?",
"1",
":",
... | Set the Bean's security code.
@param pin the 6 digit pin as a number, e.g. <code>123456</code>
@param active true to enable authenticated mode, false to disable the current pin | [
"Set",
"the",
"Bean",
"s",
"security",
"code",
"."
] | train | https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/Bean.java#L986-L991 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/util/CmsDomUtil.java | CmsDomUtil.getAncestor | public static Element getAncestor(Element element, Tag tag) {
if ((element == null) || (tag == null)) {
return null;
}
if (element.getTagName().equalsIgnoreCase(tag.name())) {
return element;
}
if (element.getTagName().equalsIgnoreCase(Tag.body.name())) {
return null;
}
return getAncestor(element.getParentElement(), tag);
} | java | public static Element getAncestor(Element element, Tag tag) {
if ((element == null) || (tag == null)) {
return null;
}
if (element.getTagName().equalsIgnoreCase(tag.name())) {
return element;
}
if (element.getTagName().equalsIgnoreCase(Tag.body.name())) {
return null;
}
return getAncestor(element.getParentElement(), tag);
} | [
"public",
"static",
"Element",
"getAncestor",
"(",
"Element",
"element",
",",
"Tag",
"tag",
")",
"{",
"if",
"(",
"(",
"element",
"==",
"null",
")",
"||",
"(",
"tag",
"==",
"null",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"element",
"."... | Returns the given element or it's closest ancestor with the given tag name.<p>
Returns <code>null</code> if no appropriate element was found.<p>
@param element the element
@param tag the tag name
@return the matching element | [
"Returns",
"the",
"given",
"element",
"or",
"it",
"s",
"closest",
"ancestor",
"with",
"the",
"given",
"tag",
"name",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/util/CmsDomUtil.java#L1161-L1173 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java | TypeUtils.getTypeArguments | public static Map<TypeVariable<?>, Type> getTypeArguments(final Type type, final Class<?> toClass) {
return getTypeArguments(type, toClass, null);
} | java | public static Map<TypeVariable<?>, Type> getTypeArguments(final Type type, final Class<?> toClass) {
return getTypeArguments(type, toClass, null);
} | [
"public",
"static",
"Map",
"<",
"TypeVariable",
"<",
"?",
">",
",",
"Type",
">",
"getTypeArguments",
"(",
"final",
"Type",
"type",
",",
"final",
"Class",
"<",
"?",
">",
"toClass",
")",
"{",
"return",
"getTypeArguments",
"(",
"type",
",",
"toClass",
",",
... | <p>Gets the type arguments of a class/interface based on a subtype. For
instance, this method will determine that both of the parameters for the
interface {@link Map} are {@link Object} for the subtype
{@link java.util.Properties Properties} even though the subtype does not
directly implement the {@code Map} interface.</p>
<p>This method returns {@code null} if {@code type} is not assignable to
{@code toClass}. It returns an empty map if none of the classes or
interfaces in its inheritance hierarchy specify any type arguments.</p>
<p>A side effect of this method is that it also retrieves the type
arguments for the classes and interfaces that are part of the hierarchy
between {@code type} and {@code toClass}. So with the above
example, this method will also determine that the type arguments for
{@link java.util.Hashtable Hashtable} are also both {@code Object}.
In cases where the interface specified by {@code toClass} is
(indirectly) implemented more than once (e.g. where {@code toClass}
specifies the interface {@link java.lang.Iterable Iterable} and
{@code type} specifies a parameterized type that implements both
{@link java.util.Set Set} and {@link java.util.Collection Collection}),
this method will look at the inheritance hierarchy of only one of the
implementations/subclasses; the first interface encountered that isn't a
subinterface to one of the others in the {@code type} to
{@code toClass} hierarchy.</p>
@param type the type from which to determine the type parameters of
{@code toClass}
@param toClass the class whose type parameters are to be determined based
on the subtype {@code type}
@return a {@code Map} of the type assignments for the type variables in
each type in the inheritance hierarchy from {@code type} to
{@code toClass} inclusive. | [
"<p",
">",
"Gets",
"the",
"type",
"arguments",
"of",
"a",
"class",
"/",
"interface",
"based",
"on",
"a",
"subtype",
".",
"For",
"instance",
"this",
"method",
"will",
"determine",
"that",
"both",
"of",
"the",
"parameters",
"for",
"the",
"interface",
"{",
... | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java#L789-L791 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksClient.java | CloudTasksClient.setIamPolicy | public final Policy setIamPolicy(QueueName resource, Policy policy) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(resource == null ? null : resource.toString())
.setPolicy(policy)
.build();
return setIamPolicy(request);
} | java | public final Policy setIamPolicy(QueueName resource, Policy policy) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(resource == null ? null : resource.toString())
.setPolicy(policy)
.build();
return setIamPolicy(request);
} | [
"public",
"final",
"Policy",
"setIamPolicy",
"(",
"QueueName",
"resource",
",",
"Policy",
"policy",
")",
"{",
"SetIamPolicyRequest",
"request",
"=",
"SetIamPolicyRequest",
".",
"newBuilder",
"(",
")",
".",
"setResource",
"(",
"resource",
"==",
"null",
"?",
"null... | Sets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. Replaces any
existing policy.
<p>Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level
permissions are required to use the Cloud Console.
<p>Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission
on the specified resource parent:
<p>* `cloudtasks.queues.setIamPolicy`
<p>Sample code:
<pre><code>
try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
QueueName resource = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
Policy policy = Policy.newBuilder().build();
Policy response = cloudTasksClient.setIamPolicy(resource, policy);
}
</code></pre>
@param resource REQUIRED: The resource for which the policy is being specified. `resource` is
usually specified as a path. For example, a Project resource is specified as
`projects/{project}`.
@param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the
policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
Platform services (such as Projects) might reject them.
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Sets",
"the",
"access",
"control",
"policy",
"for",
"a",
"[",
"Queue",
"]",
"[",
"google",
".",
"cloud",
".",
"tasks",
".",
"v2",
".",
"Queue",
"]",
".",
"Replaces",
"any",
"existing",
"policy",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksClient.java#L1273-L1281 |
auth0/auth0-java | src/main/java/com/auth0/client/mgmt/filter/QueryFilter.java | QueryFilter.withQuery | public QueryFilter withQuery(String query) {
try {
String encodedQuery = urlEncode(query);
parameters.put(KEY_QUERY, encodedQuery);
return this;
} catch (UnsupportedEncodingException ex) {
//"Every implementation of the Java platform is required to support the following standard charsets [...]: UTF-8"
//cf. https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html
throw new IllegalStateException("UTF-8 encoding not supported by current Java platform implementation.", ex);
}
} | java | public QueryFilter withQuery(String query) {
try {
String encodedQuery = urlEncode(query);
parameters.put(KEY_QUERY, encodedQuery);
return this;
} catch (UnsupportedEncodingException ex) {
//"Every implementation of the Java platform is required to support the following standard charsets [...]: UTF-8"
//cf. https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html
throw new IllegalStateException("UTF-8 encoding not supported by current Java platform implementation.", ex);
}
} | [
"public",
"QueryFilter",
"withQuery",
"(",
"String",
"query",
")",
"{",
"try",
"{",
"String",
"encodedQuery",
"=",
"urlEncode",
"(",
"query",
")",
";",
"parameters",
".",
"put",
"(",
"KEY_QUERY",
",",
"encodedQuery",
")",
";",
"return",
"this",
";",
"}",
... | Filter by a query
@param query the query expression to use
@return this filter instance | [
"Filter",
"by",
"a",
"query"
] | train | https://github.com/auth0/auth0-java/blob/b7bc099ee9c6cde5a87c4ecfebc6d811aeb1027c/src/main/java/com/auth0/client/mgmt/filter/QueryFilter.java#L16-L26 |
reactor/reactor-netty | src/main/java/reactor/netty/udp/UdpClient.java | UdpClient.doOnConnected | public final UdpClient doOnConnected(Consumer<? super Connection> doOnConnected) {
Objects.requireNonNull(doOnConnected, "doOnConnected");
return new UdpClientDoOn(this, null, doOnConnected, null);
} | java | public final UdpClient doOnConnected(Consumer<? super Connection> doOnConnected) {
Objects.requireNonNull(doOnConnected, "doOnConnected");
return new UdpClientDoOn(this, null, doOnConnected, null);
} | [
"public",
"final",
"UdpClient",
"doOnConnected",
"(",
"Consumer",
"<",
"?",
"super",
"Connection",
">",
"doOnConnected",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"doOnConnected",
",",
"\"doOnConnected\"",
")",
";",
"return",
"new",
"UdpClientDoOn",
"(",
... | Setup a callback called when {@link io.netty.channel.Channel} is
connected.
@param doOnConnected a consumer observing client started event
@return a new {@link UdpClient} | [
"Setup",
"a",
"callback",
"called",
"when",
"{",
"@link",
"io",
".",
"netty",
".",
"channel",
".",
"Channel",
"}",
"is",
"connected",
"."
] | train | https://github.com/reactor/reactor-netty/blob/4ed14316e1d7fca3cecd18d6caa5f2251e159e49/src/main/java/reactor/netty/udp/UdpClient.java#L193-L196 |
samskivert/samskivert | src/main/java/com/samskivert/util/RandomUtil.java | RandomUtil.pickRandom | public static <T> T pickRandom (List<T> values, T skip)
{
return pickRandom(values, skip, rand);
} | java | public static <T> T pickRandom (List<T> values, T skip)
{
return pickRandom(values, skip, rand);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"pickRandom",
"(",
"List",
"<",
"T",
">",
"values",
",",
"T",
"skip",
")",
"{",
"return",
"pickRandom",
"(",
"values",
",",
"skip",
",",
"rand",
")",
";",
"}"
] | Picks a random object from the supplied List. The specified skip object will be skipped when
selecting a random value. The skipped object must exist exactly once in the List.
@return a randomly selected item. | [
"Picks",
"a",
"random",
"object",
"from",
"the",
"supplied",
"List",
".",
"The",
"specified",
"skip",
"object",
"will",
"be",
"skipped",
"when",
"selecting",
"a",
"random",
"value",
".",
"The",
"skipped",
"object",
"must",
"exist",
"exactly",
"once",
"in",
... | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/RandomUtil.java#L350-L353 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/transformer/TransformerIdentityImpl.java | TransformerIdentityImpl.startPrefixMapping | public void startPrefixMapping(String prefix, String uri)
throws SAXException
{
flushStartDoc();
m_resultContentHandler.startPrefixMapping(prefix, uri);
} | java | public void startPrefixMapping(String prefix, String uri)
throws SAXException
{
flushStartDoc();
m_resultContentHandler.startPrefixMapping(prefix, uri);
} | [
"public",
"void",
"startPrefixMapping",
"(",
"String",
"prefix",
",",
"String",
"uri",
")",
"throws",
"SAXException",
"{",
"flushStartDoc",
"(",
")",
";",
"m_resultContentHandler",
".",
"startPrefixMapping",
"(",
"prefix",
",",
"uri",
")",
";",
"}"
] | Receive notification of the start of a Namespace mapping.
<p>By default, do nothing. Application writers may override this
method in a subclass to take specific actions at the start of
each Namespace prefix scope (such as storing the prefix mapping).</p>
@param prefix The Namespace prefix being declared.
@param uri The Namespace URI mapped to the prefix.
@throws org.xml.sax.SAXException Any SAX exception, possibly
wrapping another exception.
@see org.xml.sax.ContentHandler#startPrefixMapping
@throws SAXException | [
"Receive",
"notification",
"of",
"the",
"start",
"of",
"a",
"Namespace",
"mapping",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/transformer/TransformerIdentityImpl.java#L981-L986 |
alkacon/opencms-core | src/org/opencms/xml/content/CmsDefaultXmlContentHandler.java | CmsDefaultXmlContentHandler.initHeadIncludes | protected void initHeadIncludes(Element root, CmsXmlContentDefinition contentDefinition) {
Iterator<Element> itInclude = CmsXmlGenericWrapper.elementIterator(root, APPINFO_HEAD_INCLUDE);
while (itInclude.hasNext()) {
Element element = itInclude.next();
String type = element.attributeValue(APPINFO_ATTR_TYPE);
String uri = element.attributeValue(APPINFO_ATTR_URI);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(uri)) {
if (ATTRIBUTE_INCLUDE_TYPE_CSS.equals(type)) {
m_cssHeadIncludes.add(uri);
} else if (ATTRIBUTE_INCLUDE_TYPE_JAVASCRIPT.equals(type)) {
m_jsHeadIncludes.add(uri);
}
}
}
} | java | protected void initHeadIncludes(Element root, CmsXmlContentDefinition contentDefinition) {
Iterator<Element> itInclude = CmsXmlGenericWrapper.elementIterator(root, APPINFO_HEAD_INCLUDE);
while (itInclude.hasNext()) {
Element element = itInclude.next();
String type = element.attributeValue(APPINFO_ATTR_TYPE);
String uri = element.attributeValue(APPINFO_ATTR_URI);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(uri)) {
if (ATTRIBUTE_INCLUDE_TYPE_CSS.equals(type)) {
m_cssHeadIncludes.add(uri);
} else if (ATTRIBUTE_INCLUDE_TYPE_JAVASCRIPT.equals(type)) {
m_jsHeadIncludes.add(uri);
}
}
}
} | [
"protected",
"void",
"initHeadIncludes",
"(",
"Element",
"root",
",",
"CmsXmlContentDefinition",
"contentDefinition",
")",
"{",
"Iterator",
"<",
"Element",
">",
"itInclude",
"=",
"CmsXmlGenericWrapper",
".",
"elementIterator",
"(",
"root",
",",
"APPINFO_HEAD_INCLUDE",
... | Initializes the head includes for this content handler.<p>
@param root the "headincludes" element from the appinfo node of the XML content definition
@param contentDefinition the content definition the head-includes belong to | [
"Initializes",
"the",
"head",
"includes",
"for",
"this",
"content",
"handler",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/content/CmsDefaultXmlContentHandler.java#L2660-L2675 |
GenesysPureEngage/provisioning-client-java | src/main/java/com/genesys/provisioning/ImportApi.java | ImportApi.validateFile | public void validateFile(String fileName, String fileContents) throws ProvisioningApiException {
RequestBody requestBody = new MultipartBuilder()
.type(MultipartBuilder.FORM)
.addPart(
Headers.of("Content-Disposition", "form-data; name=\"csvfile\"; filename=\""+fileName+"\""),
RequestBody.create(MediaType.parse("text/csv"), fileContents))
.build();
Request request = new Request.Builder()
.url(this.client.getBasePath()+"/import-users/validate-csv")
.post(requestBody)
.build();
try {
Response response = this.client.getHttpClient().newCall(request).execute();
} catch(IOException e) {
throw new ProvisioningApiException("Error validating file", e);
}
} | java | public void validateFile(String fileName, String fileContents) throws ProvisioningApiException {
RequestBody requestBody = new MultipartBuilder()
.type(MultipartBuilder.FORM)
.addPart(
Headers.of("Content-Disposition", "form-data; name=\"csvfile\"; filename=\""+fileName+"\""),
RequestBody.create(MediaType.parse("text/csv"), fileContents))
.build();
Request request = new Request.Builder()
.url(this.client.getBasePath()+"/import-users/validate-csv")
.post(requestBody)
.build();
try {
Response response = this.client.getHttpClient().newCall(request).execute();
} catch(IOException e) {
throw new ProvisioningApiException("Error validating file", e);
}
} | [
"public",
"void",
"validateFile",
"(",
"String",
"fileName",
",",
"String",
"fileContents",
")",
"throws",
"ProvisioningApiException",
"{",
"RequestBody",
"requestBody",
"=",
"new",
"MultipartBuilder",
"(",
")",
".",
"type",
"(",
"MultipartBuilder",
".",
"FORM",
"... | Validate the import file.
Performs pre-validation on the specified CSV/XLS file.
@param fileName The name of the CSV/XLS file to validate.
@param fileContents The contents of the CSV/XLS file to validate.
@throws ProvisioningApiException if the call is unsuccessful. | [
"Validate",
"the",
"import",
"file",
".",
"Performs",
"pre",
"-",
"validation",
"on",
"the",
"specified",
"CSV",
"/",
"XLS",
"file",
"."
] | train | https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/provisioning/ImportApi.java#L87-L106 |
czyzby/gdx-lml | kiwi/src/main/java/com/github/czyzby/kiwi/util/gdx/reflection/Reflection.java | Reflection.getAnnotation | public static <Type extends Annotation> Type getAnnotation(final Field field, final Class<Type> annotationType) {
if (isAnnotationPresent(field, annotationType)) {
return field.getDeclaredAnnotation(annotationType).getAnnotation(annotationType);
}
return null;
} | java | public static <Type extends Annotation> Type getAnnotation(final Field field, final Class<Type> annotationType) {
if (isAnnotationPresent(field, annotationType)) {
return field.getDeclaredAnnotation(annotationType).getAnnotation(annotationType);
}
return null;
} | [
"public",
"static",
"<",
"Type",
"extends",
"Annotation",
">",
"Type",
"getAnnotation",
"(",
"final",
"Field",
"field",
",",
"final",
"Class",
"<",
"Type",
">",
"annotationType",
")",
"{",
"if",
"(",
"isAnnotationPresent",
"(",
"field",
",",
"annotationType",
... | Utility method that allows to extract actual annotation from field, bypassing LibGDX annotation wrapper. Returns
null if annotation is not present.
@param field might be annotated.
@param annotationType class of the annotation.
@return an instance of the annotation if the field is annotated or null if not.
@param <Type> type of annotation. | [
"Utility",
"method",
"that",
"allows",
"to",
"extract",
"actual",
"annotation",
"from",
"field",
"bypassing",
"LibGDX",
"annotation",
"wrapper",
".",
"Returns",
"null",
"if",
"annotation",
"is",
"not",
"present",
"."
] | train | https://github.com/czyzby/gdx-lml/blob/7623b322e6afe49ad4dd636c80c230150a1cfa4e/kiwi/src/main/java/com/github/czyzby/kiwi/util/gdx/reflection/Reflection.java#L68-L73 |
ACRA/acra | acra-mail/src/main/java/org/acra/sender/EmailIntentSender.java | EmailIntentSender.createAttachmentFromString | @Nullable
protected Uri createAttachmentFromString(@NonNull Context context, @NonNull String name, @NonNull String content) {
final File cache = new File(context.getCacheDir(), name);
try {
IOUtils.writeStringToFile(cache, content);
return AcraContentProvider.getUriForFile(context, cache);
} catch (IOException ignored) {
}
return null;
} | java | @Nullable
protected Uri createAttachmentFromString(@NonNull Context context, @NonNull String name, @NonNull String content) {
final File cache = new File(context.getCacheDir(), name);
try {
IOUtils.writeStringToFile(cache, content);
return AcraContentProvider.getUriForFile(context, cache);
} catch (IOException ignored) {
}
return null;
} | [
"@",
"Nullable",
"protected",
"Uri",
"createAttachmentFromString",
"(",
"@",
"NonNull",
"Context",
"context",
",",
"@",
"NonNull",
"String",
"name",
",",
"@",
"NonNull",
"String",
"content",
")",
"{",
"final",
"File",
"cache",
"=",
"new",
"File",
"(",
"conte... | Creates a temporary file with the given content and name, to be used as an email attachment
@param context a context
@param name the name
@param content the content
@return a content uri for the file | [
"Creates",
"a",
"temporary",
"file",
"with",
"the",
"given",
"content",
"and",
"name",
"to",
"be",
"used",
"as",
"an",
"email",
"attachment"
] | train | https://github.com/ACRA/acra/blob/bfa3235ab110328c5ab2f792ddf8ee87be4a32d1/acra-mail/src/main/java/org/acra/sender/EmailIntentSender.java#L248-L257 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/CmsListItemWidget.java | CmsListItemWidget.ensureOpenCloseAdditionalInfo | protected void ensureOpenCloseAdditionalInfo() {
if (m_openClose == null) {
m_openClose = new CmsPushButton(I_CmsButton.TRIANGLE_RIGHT, I_CmsButton.TRIANGLE_DOWN);
m_openClose.setButtonStyle(ButtonStyle.FONT_ICON, null);
m_openClose.setSize(Size.small);
m_titleBox.insert(m_openClose, 0);
m_openClose.addClickHandler(new ClickHandler() {
/**
* @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
*/
public void onClick(ClickEvent event) {
setAdditionalInfoVisible(!getElement().getClassName().contains(CmsListItemWidget.OPENCLASS));
CmsDomUtil.resizeAncestor(CmsListItemWidget.this);
}
});
}
} | java | protected void ensureOpenCloseAdditionalInfo() {
if (m_openClose == null) {
m_openClose = new CmsPushButton(I_CmsButton.TRIANGLE_RIGHT, I_CmsButton.TRIANGLE_DOWN);
m_openClose.setButtonStyle(ButtonStyle.FONT_ICON, null);
m_openClose.setSize(Size.small);
m_titleBox.insert(m_openClose, 0);
m_openClose.addClickHandler(new ClickHandler() {
/**
* @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
*/
public void onClick(ClickEvent event) {
setAdditionalInfoVisible(!getElement().getClassName().contains(CmsListItemWidget.OPENCLASS));
CmsDomUtil.resizeAncestor(CmsListItemWidget.this);
}
});
}
} | [
"protected",
"void",
"ensureOpenCloseAdditionalInfo",
"(",
")",
"{",
"if",
"(",
"m_openClose",
"==",
"null",
")",
"{",
"m_openClose",
"=",
"new",
"CmsPushButton",
"(",
"I_CmsButton",
".",
"TRIANGLE_RIGHT",
",",
"I_CmsButton",
".",
"TRIANGLE_DOWN",
")",
";",
"m_o... | Ensures the open close button for the additional info list is present.<p> | [
"Ensures",
"the",
"open",
"close",
"button",
"for",
"the",
"additional",
"info",
"list",
"is",
"present",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/CmsListItemWidget.java#L1071-L1090 |
Azure/azure-sdk-for-java | sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/ManagedInstancesInner.java | ManagedInstancesInner.createOrUpdateAsync | public Observable<ManagedInstanceInner> createOrUpdateAsync(String resourceGroupName, String managedInstanceName, ManagedInstanceInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, parameters).map(new Func1<ServiceResponse<ManagedInstanceInner>, ManagedInstanceInner>() {
@Override
public ManagedInstanceInner call(ServiceResponse<ManagedInstanceInner> response) {
return response.body();
}
});
} | java | public Observable<ManagedInstanceInner> createOrUpdateAsync(String resourceGroupName, String managedInstanceName, ManagedInstanceInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, parameters).map(new Func1<ServiceResponse<ManagedInstanceInner>, ManagedInstanceInner>() {
@Override
public ManagedInstanceInner call(ServiceResponse<ManagedInstanceInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ManagedInstanceInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"managedInstanceName",
",",
"ManagedInstanceInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGr... | Creates or updates a managed instance.
@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 managedInstanceName The name of the managed instance.
@param parameters The requested managed instance resource state.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"or",
"updates",
"a",
"managed",
"instance",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/ManagedInstancesInner.java#L461-L468 |
duracloud/management-console | account-management-monitor/src/main/java/org/duracloud/account/monitor/duplication/DuplicationMonitor.java | DuplicationMonitor.monitorDuplication | public DuplicationReport monitorDuplication() {
log.info("starting duplication monitor");
DuplicationReport report = new DuplicationReport();
for (String host : dupHosts.keySet()) {
DuplicationInfo info = new DuplicationInfo(host);
try {
// Connect to storage providers
ContentStoreManager storeManager = getStoreManager(host);
ContentStore primary = storeManager.getPrimaryContentStore();
String primaryStoreId = primary.getStoreId();
List<ContentStore> secondaryList =
getSecondaryStores(storeManager, primaryStoreId);
// Get primary space listing and count
List<String> primarySpaces = getSpaces(host, primary);
countSpaces(host, info, primary, primarySpaces, true);
// Get space listing and space counts for secondary providers
for (ContentStore secondary : secondaryList) {
List<String> secondarySpaces = getSpaces(host, secondary);
if (primarySpaces.size() != secondarySpaces.size()) {
info.addIssue("The spaces listings do not match " +
"between primary and secondary " +
"provider: " +
secondary.getStorageProviderType());
}
// Determine item count for secondary provider spaces
countSpaces(host, info, secondary, secondarySpaces, false);
}
// Compare the space counts between providers
compareSpaces(primaryStoreId, info);
} catch (Exception e) {
String error = e.getClass() + " exception encountered while " +
"running dup monitor for host " + host +
". Exception message: " + e.getMessage();
log.error(error);
info.addIssue(error);
} finally {
report.addDupInfo(host, info);
}
}
return report;
} | java | public DuplicationReport monitorDuplication() {
log.info("starting duplication monitor");
DuplicationReport report = new DuplicationReport();
for (String host : dupHosts.keySet()) {
DuplicationInfo info = new DuplicationInfo(host);
try {
// Connect to storage providers
ContentStoreManager storeManager = getStoreManager(host);
ContentStore primary = storeManager.getPrimaryContentStore();
String primaryStoreId = primary.getStoreId();
List<ContentStore> secondaryList =
getSecondaryStores(storeManager, primaryStoreId);
// Get primary space listing and count
List<String> primarySpaces = getSpaces(host, primary);
countSpaces(host, info, primary, primarySpaces, true);
// Get space listing and space counts for secondary providers
for (ContentStore secondary : secondaryList) {
List<String> secondarySpaces = getSpaces(host, secondary);
if (primarySpaces.size() != secondarySpaces.size()) {
info.addIssue("The spaces listings do not match " +
"between primary and secondary " +
"provider: " +
secondary.getStorageProviderType());
}
// Determine item count for secondary provider spaces
countSpaces(host, info, secondary, secondarySpaces, false);
}
// Compare the space counts between providers
compareSpaces(primaryStoreId, info);
} catch (Exception e) {
String error = e.getClass() + " exception encountered while " +
"running dup monitor for host " + host +
". Exception message: " + e.getMessage();
log.error(error);
info.addIssue(error);
} finally {
report.addDupInfo(host, info);
}
}
return report;
} | [
"public",
"DuplicationReport",
"monitorDuplication",
"(",
")",
"{",
"log",
".",
"info",
"(",
"\"starting duplication monitor\"",
")",
";",
"DuplicationReport",
"report",
"=",
"new",
"DuplicationReport",
"(",
")",
";",
"for",
"(",
"String",
"host",
":",
"dupHosts",... | This method performs the duplication checks. These checks compare
the number of content items in identically named spaces.
@return DuplicationReport report | [
"This",
"method",
"performs",
"the",
"duplication",
"checks",
".",
"These",
"checks",
"compare",
"the",
"number",
"of",
"content",
"items",
"in",
"identically",
"named",
"spaces",
"."
] | train | https://github.com/duracloud/management-console/blob/7331015c01f9ac5cc5c0aa8ae9a2a1a77e9f4ac6/account-management-monitor/src/main/java/org/duracloud/account/monitor/duplication/DuplicationMonitor.java#L57-L102 |
OpenLiberty/open-liberty | dev/com.ibm.jbatch.container/src/com/ibm/jbatch/container/ws/JoblogUtil.java | JoblogUtil.logToJobLogAndTraceOnly | @Trivial
public static void logToJobLogAndTraceOnly(Level level, String msg, Object[] params, Logger traceLogger){
String formattedMsg = getFormattedMessage(msg, params, "Job event.");
logRawMsgToJobLogAndTraceOnly(level, formattedMsg, traceLogger);
} | java | @Trivial
public static void logToJobLogAndTraceOnly(Level level, String msg, Object[] params, Logger traceLogger){
String formattedMsg = getFormattedMessage(msg, params, "Job event.");
logRawMsgToJobLogAndTraceOnly(level, formattedMsg, traceLogger);
} | [
"@",
"Trivial",
"public",
"static",
"void",
"logToJobLogAndTraceOnly",
"(",
"Level",
"level",
",",
"String",
"msg",
",",
"Object",
"[",
"]",
"params",
",",
"Logger",
"traceLogger",
")",
"{",
"String",
"formattedMsg",
"=",
"getFormattedMessage",
"(",
"msg",
","... | Logs the message to joblog and trace.
If level > FINE, this method will reduce the level to FINE while logging to trace
to prevent the message to be logged in console.log and messages.log file
Joblog messages will be logged as per original logging level
Use this method when you don't want a very verbose stack in messages.log and console.log
@param level Original logging level the message was logged at by the code writing the log msg.
@param msgKey Message key.
@param params Message params (fillins)
@param traceLogger Logger to use to attempt to log message to trace.log (whether it will or not
depends on config) | [
"Logs",
"the",
"message",
"to",
"joblog",
"and",
"trace",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.jbatch.container/src/com/ibm/jbatch/container/ws/JoblogUtil.java#L50-L54 |
seam/faces | impl/src/main/java/org/jboss/seam/faces/view/SeamViewHandler.java | SeamViewHandler.getViewDeclarationLanguage | @Override
public ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext context, String viewId) {
ViewDeclarationLanguage vdl = delegate.getViewDeclarationLanguage(context, viewId);
if (vdl != null) {
return new SeamViewDeclarationLanguage(vdl);
} else {
return null;
}
} | java | @Override
public ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext context, String viewId) {
ViewDeclarationLanguage vdl = delegate.getViewDeclarationLanguage(context, viewId);
if (vdl != null) {
return new SeamViewDeclarationLanguage(vdl);
} else {
return null;
}
} | [
"@",
"Override",
"public",
"ViewDeclarationLanguage",
"getViewDeclarationLanguage",
"(",
"FacesContext",
"context",
",",
"String",
"viewId",
")",
"{",
"ViewDeclarationLanguage",
"vdl",
"=",
"delegate",
".",
"getViewDeclarationLanguage",
"(",
"context",
",",
"viewId",
")... | If non-null, wrap the {@link ViewDeclarationLanguage} returned by the delegate in a new
{@link SeamViewDeclarationLanguage} instance. | [
"If",
"non",
"-",
"null",
"wrap",
"the",
"{"
] | train | https://github.com/seam/faces/blob/2fdedbc7070318c2c58bfffb8a26f1ea1d0ee1e3/impl/src/main/java/org/jboss/seam/faces/view/SeamViewHandler.java#L42-L50 |
apereo/cas | support/cas-server-support-saml-mdui/src/main/java/org/apereo/cas/support/saml/mdui/web/flow/SamlMetadataUIParserAction.java | SamlMetadataUIParserAction.loadSamlMetadataIntoRequestContext | protected void loadSamlMetadataIntoRequestContext(final RequestContext requestContext, final String entityId, final RegisteredService registeredService) {
LOGGER.debug("Locating SAML MDUI for entity [{}]", entityId);
val mdui = MetadataUIUtils.locateMetadataUserInterfaceForEntityId(
this.metadataAdapter, entityId, registeredService, WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext));
LOGGER.debug("Located SAML MDUI for entity [{}] as [{}]", entityId, mdui);
WebUtils.putServiceUserInterfaceMetadata(requestContext, mdui);
} | java | protected void loadSamlMetadataIntoRequestContext(final RequestContext requestContext, final String entityId, final RegisteredService registeredService) {
LOGGER.debug("Locating SAML MDUI for entity [{}]", entityId);
val mdui = MetadataUIUtils.locateMetadataUserInterfaceForEntityId(
this.metadataAdapter, entityId, registeredService, WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext));
LOGGER.debug("Located SAML MDUI for entity [{}] as [{}]", entityId, mdui);
WebUtils.putServiceUserInterfaceMetadata(requestContext, mdui);
} | [
"protected",
"void",
"loadSamlMetadataIntoRequestContext",
"(",
"final",
"RequestContext",
"requestContext",
",",
"final",
"String",
"entityId",
",",
"final",
"RegisteredService",
"registeredService",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Locating SAML MDUI for entity [... | Load saml metadata into request context.
@param requestContext the request context
@param entityId the entity id
@param registeredService the registered service | [
"Load",
"saml",
"metadata",
"into",
"request",
"context",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-saml-mdui/src/main/java/org/apereo/cas/support/saml/mdui/web/flow/SamlMetadataUIParserAction.java#L75-L81 |
beihaifeiwu/dolphin | dolphin-common/src/main/java/com/freetmp/common/annotation/AnnotationUtils.java | AnnotationUtils.isAnnotationDeclaredLocally | public static boolean isAnnotationDeclaredLocally(Class<? extends Annotation> annotationType, Class<?> clazz) {
Assert.notNull(annotationType, "Annotation type must not be null");
Assert.notNull(clazz, "Class must not be null");
boolean declaredLocally = false;
try {
for (Annotation ann : clazz.getDeclaredAnnotations()) {
if (ann.annotationType().equals(annotationType)) {
declaredLocally = true;
break;
}
}
}
catch (Exception ex) {
// Assuming nested Class values not resolvable within annotation attributes...
logIntrospectionFailure(clazz, ex);
}
return declaredLocally;
} | java | public static boolean isAnnotationDeclaredLocally(Class<? extends Annotation> annotationType, Class<?> clazz) {
Assert.notNull(annotationType, "Annotation type must not be null");
Assert.notNull(clazz, "Class must not be null");
boolean declaredLocally = false;
try {
for (Annotation ann : clazz.getDeclaredAnnotations()) {
if (ann.annotationType().equals(annotationType)) {
declaredLocally = true;
break;
}
}
}
catch (Exception ex) {
// Assuming nested Class values not resolvable within annotation attributes...
logIntrospectionFailure(clazz, ex);
}
return declaredLocally;
} | [
"public",
"static",
"boolean",
"isAnnotationDeclaredLocally",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationType",
",",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"Assert",
".",
"notNull",
"(",
"annotationType",
",",
"\"Annotation type must not ... | Determine whether an annotation for the specified {@code annotationType} is
declared locally on the supplied {@code clazz}. The supplied {@link Class}
may represent any type.
<p>Note: This method does <strong>not</strong> determine if the annotation is
{@linkplain java.lang.annotation.Inherited inherited}. For greater clarity
regarding inherited annotations, consider using
{@link #isAnnotationInherited(Class, Class)} instead.
@param annotationType the Class object corresponding to the annotation type
@param clazz the Class object corresponding to the class on which to check for the annotation
@return {@code true} if an annotation for the specified {@code annotationType}
is declared locally on the supplied {@code clazz}
@see Class#getDeclaredAnnotations()
@see #isAnnotationInherited(Class, Class) | [
"Determine",
"whether",
"an",
"annotation",
"for",
"the",
"specified",
"{"
] | train | https://github.com/beihaifeiwu/dolphin/blob/b100579cc6986dce5eba5593ebb5fbae7bad9d1a/dolphin-common/src/main/java/com/freetmp/common/annotation/AnnotationUtils.java#L471-L488 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesUpdateImpl.java | DoublesUpdateImpl.getRequiredItemCapacity | static int getRequiredItemCapacity(final int k, final long newN) {
final int numLevelsNeeded = Util.computeNumLevelsNeeded(k, newN);
if (numLevelsNeeded == 0) {
// don't need any levels yet, and might have small base buffer; this can happen during a merge
return 2 * k;
}
// from here on we need a full-size base buffer and at least one level
assert newN >= (2L * k);
assert numLevelsNeeded > 0;
final int spaceNeeded = (2 + numLevelsNeeded) * k;
return spaceNeeded;
} | java | static int getRequiredItemCapacity(final int k, final long newN) {
final int numLevelsNeeded = Util.computeNumLevelsNeeded(k, newN);
if (numLevelsNeeded == 0) {
// don't need any levels yet, and might have small base buffer; this can happen during a merge
return 2 * k;
}
// from here on we need a full-size base buffer and at least one level
assert newN >= (2L * k);
assert numLevelsNeeded > 0;
final int spaceNeeded = (2 + numLevelsNeeded) * k;
return spaceNeeded;
} | [
"static",
"int",
"getRequiredItemCapacity",
"(",
"final",
"int",
"k",
",",
"final",
"long",
"newN",
")",
"{",
"final",
"int",
"numLevelsNeeded",
"=",
"Util",
".",
"computeNumLevelsNeeded",
"(",
"k",
",",
"newN",
")",
";",
"if",
"(",
"numLevelsNeeded",
"==",
... | This only increases the size and does not touch or move any data. | [
"This",
"only",
"increases",
"the",
"size",
"and",
"does",
"not",
"touch",
"or",
"move",
"any",
"data",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesUpdateImpl.java#L27-L38 |
camunda/camunda-xml-model | src/main/java/org/camunda/bpm/model/xml/impl/ModelImpl.java | ModelImpl.declareAlternativeNamespace | public void declareAlternativeNamespace(String alternativeNs, String actualNs) {
if(actualNsToAlternative.containsKey(actualNs) || alternativeNsToActual.containsKey(alternativeNs)){
throw new IllegalArgumentException("Cannot register two alternatives for one namespace! Actual Ns: " + actualNs + " second alternative: " + alternativeNs);
}
actualNsToAlternative.put(actualNs, alternativeNs);
alternativeNsToActual.put(alternativeNs, actualNs);
} | java | public void declareAlternativeNamespace(String alternativeNs, String actualNs) {
if(actualNsToAlternative.containsKey(actualNs) || alternativeNsToActual.containsKey(alternativeNs)){
throw new IllegalArgumentException("Cannot register two alternatives for one namespace! Actual Ns: " + actualNs + " second alternative: " + alternativeNs);
}
actualNsToAlternative.put(actualNs, alternativeNs);
alternativeNsToActual.put(alternativeNs, actualNs);
} | [
"public",
"void",
"declareAlternativeNamespace",
"(",
"String",
"alternativeNs",
",",
"String",
"actualNs",
")",
"{",
"if",
"(",
"actualNsToAlternative",
".",
"containsKey",
"(",
"actualNs",
")",
"||",
"alternativeNsToActual",
".",
"containsKey",
"(",
"alternativeNs",... | Declares an alternative namespace for an actual so that during lookup of elements/attributes both will be considered.
This can be used if a newer namespaces replaces an older one but XML files with the old one should still be parseable.
@param alternativeNs
@param actualNs
@throws IllegalArgumentException if the alternative is already used or if the actual namespace has an alternative | [
"Declares",
"an",
"alternative",
"namespace",
"for",
"an",
"actual",
"so",
"that",
"during",
"lookup",
"of",
"elements",
"/",
"attributes",
"both",
"will",
"be",
"considered",
".",
"This",
"can",
"be",
"used",
"if",
"a",
"newer",
"namespaces",
"replaces",
"a... | train | https://github.com/camunda/camunda-xml-model/blob/85b3f879e26d063f71c94cfd21ac17d9ff6baf4d/src/main/java/org/camunda/bpm/model/xml/impl/ModelImpl.java#L60-L66 |
tango-controls/JTango | server/src/main/java/org/tango/server/servant/DeviceImpl.java | DeviceImpl.read_attribute_history_5 | @Override
public DevAttrHistory_5 read_attribute_history_5(final String attributeName, final int maxSize) throws DevFailed {
MDC.setContextMap(contextMap);
xlogger.entry();
checkInitialization();
deviceMonitoring.startRequest("read_attribute_history_5");
DevAttrHistory_5 result = null;
try {
final AttributeImpl attr = AttributeGetterSetter.getAttribute(attributeName, attributeList);
if (attr.getBehavior() instanceof ForwardedAttribute) {
final ForwardedAttribute fwdAttr = (ForwardedAttribute) attr.getBehavior();
result = fwdAttr.getAttributeHistory(maxSize);
} else {
if (!attr.isPolled()) {
throw DevFailedUtils.newDevFailed(ExceptionMessages.ATTR_NOT_POLLED, attr.getName()
+ " is not polled");
}
result = attr.getHistory().getAttrHistory5(maxSize);
}
} catch (final Exception e) {
deviceMonitoring.addError();
if (e instanceof DevFailed) {
throw (DevFailed) e;
} else {
// with CORBA, the stack trace is not visible by the client if
// not inserted in DevFailed.
throw DevFailedUtils.newDevFailed(e);
}
}
return result;
} | java | @Override
public DevAttrHistory_5 read_attribute_history_5(final String attributeName, final int maxSize) throws DevFailed {
MDC.setContextMap(contextMap);
xlogger.entry();
checkInitialization();
deviceMonitoring.startRequest("read_attribute_history_5");
DevAttrHistory_5 result = null;
try {
final AttributeImpl attr = AttributeGetterSetter.getAttribute(attributeName, attributeList);
if (attr.getBehavior() instanceof ForwardedAttribute) {
final ForwardedAttribute fwdAttr = (ForwardedAttribute) attr.getBehavior();
result = fwdAttr.getAttributeHistory(maxSize);
} else {
if (!attr.isPolled()) {
throw DevFailedUtils.newDevFailed(ExceptionMessages.ATTR_NOT_POLLED, attr.getName()
+ " is not polled");
}
result = attr.getHistory().getAttrHistory5(maxSize);
}
} catch (final Exception e) {
deviceMonitoring.addError();
if (e instanceof DevFailed) {
throw (DevFailed) e;
} else {
// with CORBA, the stack trace is not visible by the client if
// not inserted in DevFailed.
throw DevFailedUtils.newDevFailed(e);
}
}
return result;
} | [
"@",
"Override",
"public",
"DevAttrHistory_5",
"read_attribute_history_5",
"(",
"final",
"String",
"attributeName",
",",
"final",
"int",
"maxSize",
")",
"throws",
"DevFailed",
"{",
"MDC",
".",
"setContextMap",
"(",
"contextMap",
")",
";",
"xlogger",
".",
"entry",
... | read an attribute history. IDL 5 version. The history is filled only be
attribute polling
@param attributeName The attribute to retrieve
@param maxSize The history maximum size returned
@throws DevFailed | [
"read",
"an",
"attribute",
"history",
".",
"IDL",
"5",
"version",
".",
"The",
"history",
"is",
"filled",
"only",
"be",
"attribute",
"polling"
] | train | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/servant/DeviceImpl.java#L2540-L2571 |
rholder/moar-concurrent | src/main/java/com/github/rholder/moar/concurrent/StrategicExecutors.java | StrategicExecutors.newBalancingThreadPoolExecutor | public static BalancingThreadPoolExecutor newBalancingThreadPoolExecutor(ThreadPoolExecutor tpe,
float targetUtilization,
float smoothingWeight,
int balanceAfter) {
ThreadProfiler tp = new MXBeanThreadProfiler();
return new BalancingThreadPoolExecutor(tpe, tp, targetUtilization, smoothingWeight, balanceAfter);
} | java | public static BalancingThreadPoolExecutor newBalancingThreadPoolExecutor(ThreadPoolExecutor tpe,
float targetUtilization,
float smoothingWeight,
int balanceAfter) {
ThreadProfiler tp = new MXBeanThreadProfiler();
return new BalancingThreadPoolExecutor(tpe, tp, targetUtilization, smoothingWeight, balanceAfter);
} | [
"public",
"static",
"BalancingThreadPoolExecutor",
"newBalancingThreadPoolExecutor",
"(",
"ThreadPoolExecutor",
"tpe",
",",
"float",
"targetUtilization",
",",
"float",
"smoothingWeight",
",",
"int",
"balanceAfter",
")",
"{",
"ThreadProfiler",
"tp",
"=",
"new",
"MXBeanThre... | Return a {@link BalancingThreadPoolExecutor} with the given
{@link ThreadPoolExecutor}, target utilization, smoothing weight, and
balance after values.
@param tpe the underlying executor to use for this instance
@param targetUtilization a float between 0.0 and 1.0 representing the
percentage of the total CPU time to be used by
this pool
@param smoothingWeight smooth out the averages of the CPU and wait time
over time such that tasks aren't too heavily
skewed with old or spiking data
@param balanceAfter balance the thread pool after this many tasks
have run | [
"Return",
"a",
"{",
"@link",
"BalancingThreadPoolExecutor",
"}",
"with",
"the",
"given",
"{",
"@link",
"ThreadPoolExecutor",
"}",
"target",
"utilization",
"smoothing",
"weight",
"and",
"balance",
"after",
"values",
"."
] | train | https://github.com/rholder/moar-concurrent/blob/c28facbf02e628cc37266c051c23d4a7654b4eba/src/main/java/com/github/rholder/moar/concurrent/StrategicExecutors.java#L90-L96 |
liferay/com-liferay-commerce | commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CPDefinitionInventoryPersistenceImpl.java | CPDefinitionInventoryPersistenceImpl.removeByUUID_G | @Override
public CPDefinitionInventory removeByUUID_G(String uuid, long groupId)
throws NoSuchCPDefinitionInventoryException {
CPDefinitionInventory cpDefinitionInventory = findByUUID_G(uuid, groupId);
return remove(cpDefinitionInventory);
} | java | @Override
public CPDefinitionInventory removeByUUID_G(String uuid, long groupId)
throws NoSuchCPDefinitionInventoryException {
CPDefinitionInventory cpDefinitionInventory = findByUUID_G(uuid, groupId);
return remove(cpDefinitionInventory);
} | [
"@",
"Override",
"public",
"CPDefinitionInventory",
"removeByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"NoSuchCPDefinitionInventoryException",
"{",
"CPDefinitionInventory",
"cpDefinitionInventory",
"=",
"findByUUID_G",
"(",
"uuid",
",",
"group... | Removes the cp definition inventory where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the cp definition inventory that was removed | [
"Removes",
"the",
"cp",
"definition",
"inventory",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CPDefinitionInventoryPersistenceImpl.java#L816-L822 |
couchbase/couchbase-lite-java-core | src/main/java/com/couchbase/lite/replicator/PusherInternal.java | PusherInternal.findCommonAncestor | private static int findCommonAncestor(RevisionInternal rev, List<String> possibleRevIDs) {
if (possibleRevIDs == null || possibleRevIDs.size() == 0) {
return 0;
}
List<String> history = Database.parseCouchDBRevisionHistory(rev.getProperties());
//rev is missing _revisions property
assert (history != null);
boolean changed = history.retainAll(possibleRevIDs);
String ancestorID = history.size() == 0 ? null : history.get(0);
if (ancestorID == null) {
return 0;
}
int generation = RevisionUtils.parseRevIDNumber(ancestorID);
return generation;
} | java | private static int findCommonAncestor(RevisionInternal rev, List<String> possibleRevIDs) {
if (possibleRevIDs == null || possibleRevIDs.size() == 0) {
return 0;
}
List<String> history = Database.parseCouchDBRevisionHistory(rev.getProperties());
//rev is missing _revisions property
assert (history != null);
boolean changed = history.retainAll(possibleRevIDs);
String ancestorID = history.size() == 0 ? null : history.get(0);
if (ancestorID == null) {
return 0;
}
int generation = RevisionUtils.parseRevIDNumber(ancestorID);
return generation;
} | [
"private",
"static",
"int",
"findCommonAncestor",
"(",
"RevisionInternal",
"rev",
",",
"List",
"<",
"String",
">",
"possibleRevIDs",
")",
"{",
"if",
"(",
"possibleRevIDs",
"==",
"null",
"||",
"possibleRevIDs",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"r... | Given a revision and an array of revIDs, finds the latest common ancestor revID
and returns its generation #. If there is none, returns 0.
<p/>
int CBLFindCommonAncestor(CBL_Revision* rev, NSArray* possibleRevIDs) in CBLRestPusher.m | [
"Given",
"a",
"revision",
"and",
"an",
"array",
"of",
"revIDs",
"finds",
"the",
"latest",
"common",
"ancestor",
"revID",
"and",
"returns",
"its",
"generation",
"#",
".",
"If",
"there",
"is",
"none",
"returns",
"0",
".",
"<p",
"/",
">",
"int",
"CBLFindCom... | train | https://github.com/couchbase/couchbase-lite-java-core/blob/3b275642e2d2f231fd155ad9def9c5e9eff3118e/src/main/java/com/couchbase/lite/replicator/PusherInternal.java#L670-L689 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/collection/MDAG/MDAG.java | MDAG.getStringsWithSubstring | public HashSet<String> getStringsWithSubstring(String str)
{
HashSet<String> strHashSet = new HashSet<String>();
if (sourceNode != null) //if the MDAG hasn't been simplified
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", sourceNode.getOutgoingTransitions());
else
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", simplifiedSourceNode);
return strHashSet;
} | java | public HashSet<String> getStringsWithSubstring(String str)
{
HashSet<String> strHashSet = new HashSet<String>();
if (sourceNode != null) //if the MDAG hasn't been simplified
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", sourceNode.getOutgoingTransitions());
else
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", simplifiedSourceNode);
return strHashSet;
} | [
"public",
"HashSet",
"<",
"String",
">",
"getStringsWithSubstring",
"(",
"String",
"str",
")",
"{",
"HashSet",
"<",
"String",
">",
"strHashSet",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"sourceNode",
"!=",
"null",
")",
"//if t... | 返回包含字串的key<br>
Retrieves all the Strings in the MDAG that contain a given String.
@param str a String that is contained in all the desired Strings
@return a HashSet containing all the Strings present in the MDAG that begin with {@code prefixString} | [
"返回包含字串的key<br",
">",
"Retrieves",
"all",
"the",
"Strings",
"in",
"the",
"MDAG",
"that",
"contain",
"a",
"given",
"String",
"."
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/collection/MDAG/MDAG.java#L976-L986 |
amazon-archives/aws-sdk-java-resources | aws-resources-core/src/main/java/com/amazonaws/resources/internal/ReflectionUtils.java | ReflectionUtils.findAccessor | private static Method findAccessor(Object target, String propertyName) {
propertyName = propertyName.substring(0, 1).toUpperCase()
+ propertyName.substring(1);
try {
return target.getClass().getMethod("get" + propertyName);
} catch (NoSuchMethodException nsme) {
}
try {
return target.getClass().getMethod("is" + propertyName);
} catch (NoSuchMethodException nsme) {
}
LogFactory.getLog(ReflectionUtils.class).warn(
"No accessor for property '"
+ propertyName + "' " + "found in class "
+ target.getClass().getName());
return null;
} | java | private static Method findAccessor(Object target, String propertyName) {
propertyName = propertyName.substring(0, 1).toUpperCase()
+ propertyName.substring(1);
try {
return target.getClass().getMethod("get" + propertyName);
} catch (NoSuchMethodException nsme) {
}
try {
return target.getClass().getMethod("is" + propertyName);
} catch (NoSuchMethodException nsme) {
}
LogFactory.getLog(ReflectionUtils.class).warn(
"No accessor for property '"
+ propertyName + "' " + "found in class "
+ target.getClass().getName());
return null;
} | [
"private",
"static",
"Method",
"findAccessor",
"(",
"Object",
"target",
",",
"String",
"propertyName",
")",
"{",
"propertyName",
"=",
"propertyName",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"propertyName",
".",
"substrin... | Returns the accessor method for the specified member property.
For example, if the member property is "Foo", this method looks
for a "getFoo()" method and an "isFoo()" method.
If no accessor is found, this method throws an IllegalStateException.
@param target the object to reflect on
@param propertyName the name of the property to search for
@return the accessor method
@throws IllegalStateException if no matching method is found | [
"Returns",
"the",
"accessor",
"method",
"for",
"the",
"specified",
"member",
"property",
".",
"For",
"example",
"if",
"the",
"member",
"property",
"is",
"Foo",
"this",
"method",
"looks",
"for",
"a",
"getFoo",
"()",
"method",
"and",
"an",
"isFoo",
"()",
"me... | train | https://github.com/amazon-archives/aws-sdk-java-resources/blob/0f4fef2615d9687997b70a36eed1d62dd42df035/aws-resources-core/src/main/java/com/amazonaws/resources/internal/ReflectionUtils.java#L464-L485 |
Talend/tesb-rt-se | sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProtocolHeaderCodec.java | FlowIdProtocolHeaderCodec.writeFlowId | public static void writeFlowId(Message message, String flowId) {
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
headers.put(FLOWID_HTTP_HEADER_NAME, Collections.singletonList(flowId));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + FLOWID_HTTP_HEADER_NAME + "' set to: " + flowId);
}
} | java | public static void writeFlowId(Message message, String flowId) {
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
headers.put(FLOWID_HTTP_HEADER_NAME, Collections.singletonList(flowId));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + FLOWID_HTTP_HEADER_NAME + "' set to: " + flowId);
}
} | [
"public",
"static",
"void",
"writeFlowId",
"(",
"Message",
"message",
",",
"String",
"flowId",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
"=",
"getOrCreateProtocolHeader",
"(",
"message",
")",
";",
"headers",
".",
"put... | Write flow id.
@param message the message
@param flowId the flow id | [
"Write",
"flow",
"id",
"."
] | train | https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProtocolHeaderCodec.java#L77-L83 |
haifengl/smile | demo/src/main/java/smile/demo/util/ParameterParser.java | ParameterParser.addParameter | public void addParameter(String name, ParameterType type) {
parameters.put(name, new Parameter(name, type));
} | java | public void addParameter(String name, ParameterType type) {
parameters.put(name, new Parameter(name, type));
} | [
"public",
"void",
"addParameter",
"(",
"String",
"name",
",",
"ParameterType",
"type",
")",
"{",
"parameters",
".",
"put",
"(",
"name",
",",
"new",
"Parameter",
"(",
"name",
",",
"type",
")",
")",
";",
"}"
] | Add a (optional) parameter.
@param name the name of parameter.
@param type the type of parameter. | [
"Add",
"a",
"(",
"optional",
")",
"parameter",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/demo/src/main/java/smile/demo/util/ParameterParser.java#L93-L95 |
apache/incubator-shardingsphere | sharding-transaction/sharding-transaction-2pc/sharding-transaction-xa/sharding-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionFactory.java | XAConnectionFactory.createXAConnection | public static XAConnection createXAConnection(final DatabaseType databaseType, final XADataSource xaDataSource, final Connection connection) {
switch (databaseType) {
case MySQL:
return new MySQLXAConnectionWrapper().wrap(xaDataSource, connection);
case PostgreSQL:
return new PostgreSQLXAConnectionWrapper().wrap(xaDataSource, connection);
case H2:
return new H2XAConnectionWrapper().wrap(xaDataSource, connection);
default:
throw new UnsupportedOperationException(String.format("Cannot support database type: `%s`", databaseType));
}
} | java | public static XAConnection createXAConnection(final DatabaseType databaseType, final XADataSource xaDataSource, final Connection connection) {
switch (databaseType) {
case MySQL:
return new MySQLXAConnectionWrapper().wrap(xaDataSource, connection);
case PostgreSQL:
return new PostgreSQLXAConnectionWrapper().wrap(xaDataSource, connection);
case H2:
return new H2XAConnectionWrapper().wrap(xaDataSource, connection);
default:
throw new UnsupportedOperationException(String.format("Cannot support database type: `%s`", databaseType));
}
} | [
"public",
"static",
"XAConnection",
"createXAConnection",
"(",
"final",
"DatabaseType",
"databaseType",
",",
"final",
"XADataSource",
"xaDataSource",
",",
"final",
"Connection",
"connection",
")",
"{",
"switch",
"(",
"databaseType",
")",
"{",
"case",
"MySQL",
":",
... | Create XA connection from normal connection.
@param databaseType database type
@param connection normal connection
@param xaDataSource XA data source
@return XA connection | [
"Create",
"XA",
"connection",
"from",
"normal",
"connection",
"."
] | train | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-transaction/sharding-transaction-2pc/sharding-transaction-xa/sharding-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionFactory.java#L47-L58 |
umano/AndroidSlidingUpPanel | library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java | ViewDragHelper.checkTouchSlop | private boolean checkTouchSlop(View child, float dx, float dy) {
if (child == null) {
return false;
}
final boolean checkHorizontal = mCallback.getViewHorizontalDragRange(child) > 0;
final boolean checkVertical = mCallback.getViewVerticalDragRange(child) > 0;
if (checkHorizontal && checkVertical) {
return dx * dx + dy * dy > mTouchSlop * mTouchSlop;
} else if (checkHorizontal) {
return Math.abs(dx) > mTouchSlop;
} else if (checkVertical) {
return Math.abs(dy) > mTouchSlop;
}
return false;
} | java | private boolean checkTouchSlop(View child, float dx, float dy) {
if (child == null) {
return false;
}
final boolean checkHorizontal = mCallback.getViewHorizontalDragRange(child) > 0;
final boolean checkVertical = mCallback.getViewVerticalDragRange(child) > 0;
if (checkHorizontal && checkVertical) {
return dx * dx + dy * dy > mTouchSlop * mTouchSlop;
} else if (checkHorizontal) {
return Math.abs(dx) > mTouchSlop;
} else if (checkVertical) {
return Math.abs(dy) > mTouchSlop;
}
return false;
} | [
"private",
"boolean",
"checkTouchSlop",
"(",
"View",
"child",
",",
"float",
"dx",
",",
"float",
"dy",
")",
"{",
"if",
"(",
"child",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"final",
"boolean",
"checkHorizontal",
"=",
"mCallback",
".",
"getVie... | Check if we've crossed a reasonable touch slop for the given child view.
If the child cannot be dragged along the horizontal or vertical axis, motion
along that axis will not count toward the slop check.
@param child Child to check
@param dx Motion since initial position along X axis
@param dy Motion since initial position along Y axis
@return true if the touch slop has been crossed | [
"Check",
"if",
"we",
"ve",
"crossed",
"a",
"reasonable",
"touch",
"slop",
"for",
"the",
"given",
"child",
"view",
".",
"If",
"the",
"child",
"cannot",
"be",
"dragged",
"along",
"the",
"horizontal",
"or",
"vertical",
"axis",
"motion",
"along",
"that",
"axis... | train | https://github.com/umano/AndroidSlidingUpPanel/blob/45a460435b07e764138a700328836cafc1ed5c42/library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java#L1293-L1308 |
ReactiveX/RxJavaAsyncUtil | src/main/java/rx/util/async/Async.java | Async.toAsyncThrowing | public static <T1, T2, T3, R> Func3<T1, T2, T3, Observable<R>> toAsyncThrowing(ThrowingFunc3<? super T1, ? super T2, ? super T3, ? extends R> func) {
return toAsyncThrowing(func, Schedulers.computation());
} | java | public static <T1, T2, T3, R> Func3<T1, T2, T3, Observable<R>> toAsyncThrowing(ThrowingFunc3<? super T1, ? super T2, ? super T3, ? extends R> func) {
return toAsyncThrowing(func, Schedulers.computation());
} | [
"public",
"static",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"R",
">",
"Func3",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"Observable",
"<",
"R",
">",
">",
"toAsyncThrowing",
"(",
"ThrowingFunc3",
"<",
"?",
"super",
"T1",
",",
"?",
"super",
"T2",
",",
... | Convert a synchronous function call into an asynchronous function call through an Observable.
<p>
<img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toAsync.png" alt="">
@param <T1> the first parameter type
@param <T2> the second parameter type
@param <T3> the third parameter type
@param <R> the result type
@param func the function to convert
@return a function that returns an Observable that executes the {@code func} and emits its returned value
@see <a href="https://github.com/ReactiveX/RxJava/wiki/Async-Operators#wiki-toasync-or-asyncaction-or-asyncfunc">RxJava Wiki: toAsync()</a>
@see <a href="http://msdn.microsoft.com/en-us/library/hh229450.aspx">MSDN: Observable.ToAsync</a> | [
"Convert",
"a",
"synchronous",
"function",
"call",
"into",
"an",
"asynchronous",
"function",
"call",
"through",
"an",
"Observable",
".",
"<p",
">",
"<img",
"width",
"=",
"640",
"src",
"=",
"https",
":",
"//",
"raw",
".",
"github",
".",
"com",
"/",
"wiki"... | train | https://github.com/ReactiveX/RxJavaAsyncUtil/blob/6294e1da30e639df79f76399906229314c14e74d/src/main/java/rx/util/async/Async.java#L326-L328 |
Azure/azure-sdk-for-java | compute/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java | DisksInner.createOrUpdate | public DiskInner createOrUpdate(String resourceGroupName, String diskName, DiskInner disk) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, diskName, disk).toBlocking().last().body();
} | java | public DiskInner createOrUpdate(String resourceGroupName, String diskName, DiskInner disk) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, diskName, disk).toBlocking().last().body();
} | [
"public",
"DiskInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"diskName",
",",
"DiskInner",
"disk",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"diskName",
",",
"disk",
")",
".",
"toBlockin... | Creates or updates a disk.
@param resourceGroupName The name of the resource group.
@param diskName The name of the managed disk that is being created. The name can't be changed after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters.
@param disk Disk object supplied in the body of the Put disk operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DiskInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"disk",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java#L144-L146 |
alipay/sofa-hessian | src/main/java/com/caucho/hessian/io/Hessian2Output.java | Hessian2Output.writeListBegin | public boolean writeListBegin(int length, String type)
throws IOException
{
flushIfFull();
if (length < 0) {
if (type != null) {
_buffer[_offset++] = (byte) BC_LIST_VARIABLE;
writeType(type);
}
else
_buffer[_offset++] = (byte) BC_LIST_VARIABLE_UNTYPED;
return true;
}
else if (length <= LIST_DIRECT_MAX) {
if (type != null) {
_buffer[_offset++] = (byte) (BC_LIST_DIRECT + length);
writeType(type);
}
else {
_buffer[_offset++] = (byte) (BC_LIST_DIRECT_UNTYPED + length);
}
return false;
}
else {
if (type != null) {
_buffer[_offset++] = (byte) BC_LIST_FIXED;
writeType(type);
}
else {
_buffer[_offset++] = (byte) BC_LIST_FIXED_UNTYPED;
}
writeInt(length);
return false;
}
} | java | public boolean writeListBegin(int length, String type)
throws IOException
{
flushIfFull();
if (length < 0) {
if (type != null) {
_buffer[_offset++] = (byte) BC_LIST_VARIABLE;
writeType(type);
}
else
_buffer[_offset++] = (byte) BC_LIST_VARIABLE_UNTYPED;
return true;
}
else if (length <= LIST_DIRECT_MAX) {
if (type != null) {
_buffer[_offset++] = (byte) (BC_LIST_DIRECT + length);
writeType(type);
}
else {
_buffer[_offset++] = (byte) (BC_LIST_DIRECT_UNTYPED + length);
}
return false;
}
else {
if (type != null) {
_buffer[_offset++] = (byte) BC_LIST_FIXED;
writeType(type);
}
else {
_buffer[_offset++] = (byte) BC_LIST_FIXED_UNTYPED;
}
writeInt(length);
return false;
}
} | [
"public",
"boolean",
"writeListBegin",
"(",
"int",
"length",
",",
"String",
"type",
")",
"throws",
"IOException",
"{",
"flushIfFull",
"(",
")",
";",
"if",
"(",
"length",
"<",
"0",
")",
"{",
"if",
"(",
"type",
"!=",
"null",
")",
"{",
"_buffer",
"[",
"... | Writes the list header to the stream. List writers will call
<code>writeListBegin</code> followed by the list contents and then
call <code>writeListEnd</code>.
<code><pre>
list ::= V type value* Z
::= v type int value*
</pre></code>
@return true for variable lists, false for fixed lists | [
"Writes",
"the",
"list",
"header",
"to",
"the",
"stream",
".",
"List",
"writers",
"will",
"call",
"<code",
">",
"writeListBegin<",
"/",
"code",
">",
"followed",
"by",
"the",
"list",
"contents",
"and",
"then",
"call",
"<code",
">",
"writeListEnd<",
"/",
"co... | train | https://github.com/alipay/sofa-hessian/blob/89e4f5af28602101dab7b498995018871616357b/src/main/java/com/caucho/hessian/io/Hessian2Output.java#L477-L516 |
JodaOrg/joda-time | src/main/java/org/joda/time/Instant.java | Instant.withDurationAdded | public Instant withDurationAdded(ReadableDuration durationToAdd, int scalar) {
if (durationToAdd == null || scalar == 0) {
return this;
}
return withDurationAdded(durationToAdd.getMillis(), scalar);
} | java | public Instant withDurationAdded(ReadableDuration durationToAdd, int scalar) {
if (durationToAdd == null || scalar == 0) {
return this;
}
return withDurationAdded(durationToAdd.getMillis(), scalar);
} | [
"public",
"Instant",
"withDurationAdded",
"(",
"ReadableDuration",
"durationToAdd",
",",
"int",
"scalar",
")",
"{",
"if",
"(",
"durationToAdd",
"==",
"null",
"||",
"scalar",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"return",
"withDurationAdded",
"(",
... | Gets a copy of this instant with the specified duration added.
<p>
If the addition is zero, then <code>this</code> is returned.
@param durationToAdd the duration to add to this one, null means zero
@param scalar the amount of times to add, such as -1 to subtract once
@return a copy of this instant with the duration added
@throws ArithmeticException if the new instant exceeds the capacity of a long | [
"Gets",
"a",
"copy",
"of",
"this",
"instant",
"with",
"the",
"specified",
"duration",
"added",
".",
"<p",
">",
"If",
"the",
"addition",
"is",
"zero",
"then",
"<code",
">",
"this<",
"/",
"code",
">",
"is",
"returned",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Instant.java#L220-L225 |
apache/incubator-druid | sql/src/main/java/org/apache/druid/sql/calcite/planner/Calcites.java | Calcites.jodaToCalciteTimestampString | public static TimestampString jodaToCalciteTimestampString(final DateTime dateTime, final DateTimeZone timeZone)
{
// The replaceAll is because Calcite doesn't like trailing zeroes in its fractional seconds part.
String timestampString = TRAILING_ZEROS
.matcher(CALCITE_TIMESTAMP_PRINTER.print(dateTime.withZone(timeZone)))
.replaceAll("");
return new TimestampString(timestampString);
} | java | public static TimestampString jodaToCalciteTimestampString(final DateTime dateTime, final DateTimeZone timeZone)
{
// The replaceAll is because Calcite doesn't like trailing zeroes in its fractional seconds part.
String timestampString = TRAILING_ZEROS
.matcher(CALCITE_TIMESTAMP_PRINTER.print(dateTime.withZone(timeZone)))
.replaceAll("");
return new TimestampString(timestampString);
} | [
"public",
"static",
"TimestampString",
"jodaToCalciteTimestampString",
"(",
"final",
"DateTime",
"dateTime",
",",
"final",
"DateTimeZone",
"timeZone",
")",
"{",
"// The replaceAll is because Calcite doesn't like trailing zeroes in its fractional seconds part.",
"String",
"timestampSt... | Calcite expects TIMESTAMP literals to be represented by TimestampStrings in the local time zone.
@param dateTime joda timestamp
@param timeZone session time zone
@return Calcite style Calendar, appropriate for literals | [
"Calcite",
"expects",
"TIMESTAMP",
"literals",
"to",
"be",
"represented",
"by",
"TimestampStrings",
"in",
"the",
"local",
"time",
"zone",
"."
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/sql/src/main/java/org/apache/druid/sql/calcite/planner/Calcites.java#L251-L258 |
Azure/azure-sdk-for-java | datamigration/resource-manager/v2018_03_31_preview/src/main/java/com/microsoft/azure/management/datamigration/v2018_03_31_preview/implementation/TasksInner.java | TasksInner.listWithServiceResponseAsync | public Observable<ServiceResponse<Page<ProjectTaskInner>>> listWithServiceResponseAsync(final String groupName, final String serviceName, final String projectName, final String taskType) {
return listSinglePageAsync(groupName, serviceName, projectName, taskType)
.concatMap(new Func1<ServiceResponse<Page<ProjectTaskInner>>, Observable<ServiceResponse<Page<ProjectTaskInner>>>>() {
@Override
public Observable<ServiceResponse<Page<ProjectTaskInner>>> call(ServiceResponse<Page<ProjectTaskInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<ProjectTaskInner>>> listWithServiceResponseAsync(final String groupName, final String serviceName, final String projectName, final String taskType) {
return listSinglePageAsync(groupName, serviceName, projectName, taskType)
.concatMap(new Func1<ServiceResponse<Page<ProjectTaskInner>>, Observable<ServiceResponse<Page<ProjectTaskInner>>>>() {
@Override
public Observable<ServiceResponse<Page<ProjectTaskInner>>> call(ServiceResponse<Page<ProjectTaskInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"ProjectTaskInner",
">",
">",
">",
"listWithServiceResponseAsync",
"(",
"final",
"String",
"groupName",
",",
"final",
"String",
"serviceName",
",",
"final",
"String",
"projectName",
",",
"final",
"S... | Get tasks in a service.
The services resource is the top-level resource that represents the Data Migration Service. This method returns a list of tasks owned by a service resource. Some tasks may have a status of Unknown, which indicates that an error occurred while querying the status of that task.
@param groupName Name of the resource group
@param serviceName Name of the service
@param projectName Name of the project
@param taskType Filter tasks by task type
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ProjectTaskInner> object | [
"Get",
"tasks",
"in",
"a",
"service",
".",
"The",
"services",
"resource",
"is",
"the",
"top",
"-",
"level",
"resource",
"that",
"represents",
"the",
"Data",
"Migration",
"Service",
".",
"This",
"method",
"returns",
"a",
"list",
"of",
"tasks",
"owned",
"by"... | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datamigration/resource-manager/v2018_03_31_preview/src/main/java/com/microsoft/azure/management/datamigration/v2018_03_31_preview/implementation/TasksInner.java#L305-L317 |
jOOQ/jOOL | jOOL-java-8/src/main/java/org/jooq/lambda/Agg.java | Agg.maxAllBy | public static <T, U extends Comparable<? super U>> Collector<T, ?, Seq<T>> maxAllBy(Function<? super T, ? extends U> function) {
return maxAllBy(function, naturalOrder());
} | java | public static <T, U extends Comparable<? super U>> Collector<T, ?, Seq<T>> maxAllBy(Function<? super T, ? extends U> function) {
return maxAllBy(function, naturalOrder());
} | [
"public",
"static",
"<",
"T",
",",
"U",
"extends",
"Comparable",
"<",
"?",
"super",
"U",
">",
">",
"Collector",
"<",
"T",
",",
"?",
",",
"Seq",
"<",
"T",
">",
">",
"maxAllBy",
"(",
"Function",
"<",
"?",
"super",
"T",
",",
"?",
"extends",
"U",
"... | Get a {@link Collector} that calculates the <code>MAX()</code> function, producing multiple results. | [
"Get",
"a",
"{"
] | train | https://github.com/jOOQ/jOOL/blob/889d87c85ca57bafd4eddd78e0f7ae2804d2ee86/jOOL-java-8/src/main/java/org/jooq/lambda/Agg.java#L357-L359 |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java | DetectCircleGrid.pruneIncorrectSize | static void pruneIncorrectSize(List<List<EllipsesIntoClusters.Node>> clusters, int N) {
// prune clusters which can't be a member calibration target
for (int i = clusters.size()-1; i >= 0; i--) {
if( clusters.get(i).size() != N ) {
clusters.remove(i);
}
}
} | java | static void pruneIncorrectSize(List<List<EllipsesIntoClusters.Node>> clusters, int N) {
// prune clusters which can't be a member calibration target
for (int i = clusters.size()-1; i >= 0; i--) {
if( clusters.get(i).size() != N ) {
clusters.remove(i);
}
}
} | [
"static",
"void",
"pruneIncorrectSize",
"(",
"List",
"<",
"List",
"<",
"EllipsesIntoClusters",
".",
"Node",
">",
">",
"clusters",
",",
"int",
"N",
")",
"{",
"// prune clusters which can't be a member calibration target",
"for",
"(",
"int",
"i",
"=",
"clusters",
".... | Prune clusters which do not have the expected number of elements | [
"Prune",
"clusters",
"which",
"do",
"not",
"have",
"the",
"expected",
"number",
"of",
"elements"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java#L260-L267 |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/resultset/rowprotocol/TextRowProtocol.java | TextRowProtocol.getInternalLocalDate | public LocalDate getInternalLocalDate(ColumnInformation columnInfo, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
if (length == 0) {
lastValueNull |= BIT_LAST_FIELD_NULL;
return null;
}
String raw = new String(buf, pos, length, StandardCharsets.UTF_8);
switch (columnInfo.getColumnType().getSqlType()) {
case Types.DATE:
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.CHAR:
if (raw.startsWith("0000-00-00")) {
return null;
}
try {
return LocalDate
.parse(raw, DateTimeFormatter.ISO_LOCAL_DATE.withZone(timeZone.toZoneId()));
} catch (DateTimeParseException dateParserEx) {
throw new SQLException(
raw + " cannot be parse as LocalDate (format is \"yyyy-MM-dd\" for data type \""
+ columnInfo.getColumnType() + "\")");
}
case Types.TIMESTAMP:
ZonedDateTime zonedDateTime = getInternalZonedDateTime(columnInfo, LocalDate.class,
timeZone);
return zonedDateTime == null ? null
: zonedDateTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalDate();
default:
throw new SQLException(
"Cannot read LocalDate using a " + columnInfo.getColumnType().getJavaTypeName()
+ " field");
}
} | java | public LocalDate getInternalLocalDate(ColumnInformation columnInfo, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
if (length == 0) {
lastValueNull |= BIT_LAST_FIELD_NULL;
return null;
}
String raw = new String(buf, pos, length, StandardCharsets.UTF_8);
switch (columnInfo.getColumnType().getSqlType()) {
case Types.DATE:
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.CHAR:
if (raw.startsWith("0000-00-00")) {
return null;
}
try {
return LocalDate
.parse(raw, DateTimeFormatter.ISO_LOCAL_DATE.withZone(timeZone.toZoneId()));
} catch (DateTimeParseException dateParserEx) {
throw new SQLException(
raw + " cannot be parse as LocalDate (format is \"yyyy-MM-dd\" for data type \""
+ columnInfo.getColumnType() + "\")");
}
case Types.TIMESTAMP:
ZonedDateTime zonedDateTime = getInternalZonedDateTime(columnInfo, LocalDate.class,
timeZone);
return zonedDateTime == null ? null
: zonedDateTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalDate();
default:
throw new SQLException(
"Cannot read LocalDate using a " + columnInfo.getColumnType().getJavaTypeName()
+ " field");
}
} | [
"public",
"LocalDate",
"getInternalLocalDate",
"(",
"ColumnInformation",
"columnInfo",
",",
"TimeZone",
"timeZone",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"lastValueWasNull",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"length",
"==",
"0... | Get LocalDate format from raw text format.
@param columnInfo column information
@param timeZone time zone
@return LocalDate value
@throws SQLException if column type doesn't permit conversion | [
"Get",
"LocalDate",
"format",
"from",
"raw",
"text",
"format",
"."
] | train | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/resultset/rowprotocol/TextRowProtocol.java#L1071-L1112 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java | ArrayUtil.resize | public static <T> T[] resize(T[] buffer, int newSize) {
return resize(buffer, newSize, buffer.getClass().getComponentType());
} | java | public static <T> T[] resize(T[] buffer, int newSize) {
return resize(buffer, newSize, buffer.getClass().getComponentType());
} | [
"public",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"resize",
"(",
"T",
"[",
"]",
"buffer",
",",
"int",
"newSize",
")",
"{",
"return",
"resize",
"(",
"buffer",
",",
"newSize",
",",
"buffer",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")... | 生成一个新的重新设置大小的数组<br>
新数组的类型为原数组的类型,调整大小后拷贝原数组到新数组下。扩大则占位前N个位置,缩小则截断
@param <T> 数组元素类型
@param buffer 原数组
@param newSize 新的数组大小
@return 调整后的新数组 | [
"生成一个新的重新设置大小的数组<br",
">",
"新数组的类型为原数组的类型,调整大小后拷贝原数组到新数组下。扩大则占位前N个位置,缩小则截断"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java#L523-L525 |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/core/ImportSupport.java | ImportSupport.doStartTag | @Override
public int doStartTag() throws JspException {
// Sanity check
if (context != null
&& (!context.startsWith("/") || !url.startsWith("/"))) {
throw new JspTagException(
Resources.getMessage("IMPORT_BAD_RELATIVE"));
}
// reset parameter-related state
urlWithParams = null;
params = new ParamSupport.ParamManager();
// check the URL
if (url == null || url.equals("")) {
throw new NullAttributeException("import", "url");
}
// Record whether our URL is absolute or relative
isAbsoluteUrl = UrlUtil.isAbsoluteUrl(url);
try {
// If we need to expose a Reader, we've got to do it right away
if (varReader != null) {
r = acquireReader();
pageContext.setAttribute(varReader, r);
}
} catch (IOException ex) {
throw new JspTagException(ex.toString(), ex);
}
return EVAL_BODY_INCLUDE;
} | java | @Override
public int doStartTag() throws JspException {
// Sanity check
if (context != null
&& (!context.startsWith("/") || !url.startsWith("/"))) {
throw new JspTagException(
Resources.getMessage("IMPORT_BAD_RELATIVE"));
}
// reset parameter-related state
urlWithParams = null;
params = new ParamSupport.ParamManager();
// check the URL
if (url == null || url.equals("")) {
throw new NullAttributeException("import", "url");
}
// Record whether our URL is absolute or relative
isAbsoluteUrl = UrlUtil.isAbsoluteUrl(url);
try {
// If we need to expose a Reader, we've got to do it right away
if (varReader != null) {
r = acquireReader();
pageContext.setAttribute(varReader, r);
}
} catch (IOException ex) {
throw new JspTagException(ex.toString(), ex);
}
return EVAL_BODY_INCLUDE;
} | [
"@",
"Override",
"public",
"int",
"doStartTag",
"(",
")",
"throws",
"JspException",
"{",
"// Sanity check",
"if",
"(",
"context",
"!=",
"null",
"&&",
"(",
"!",
"context",
".",
"startsWith",
"(",
"\"/\"",
")",
"||",
"!",
"url",
".",
"startsWith",
"(",
"\"... | determines what kind of import and variable exposure to perform | [
"determines",
"what",
"kind",
"of",
"import",
"and",
"variable",
"exposure",
"to",
"perform"
] | train | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/core/ImportSupport.java#L109-L141 |
JRebirth/JRebirth | org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java | ClassUtility.findProperty | public static Field findProperty(final Class<?> sourceClass, final String itemName, final Class<?> searchedClass) {
Field found = null;
if (itemName != null && !itemName.trim().isEmpty()) {
try {
found = sourceClass.getField(ClassUtility.underscoreToCamelCase(itemName));
} catch (NoSuchFieldException | SecurityException e) {
found = null;
}
}
if (found == null) {
Field f = null;
for (int i = 0; found == null && i < sourceClass.getFields().length; i++) {
f = sourceClass.getFields()[i];
if (f.getClass().equals(searchedClass)) {
found = f;
}
}
}
return found;
} | java | public static Field findProperty(final Class<?> sourceClass, final String itemName, final Class<?> searchedClass) {
Field found = null;
if (itemName != null && !itemName.trim().isEmpty()) {
try {
found = sourceClass.getField(ClassUtility.underscoreToCamelCase(itemName));
} catch (NoSuchFieldException | SecurityException e) {
found = null;
}
}
if (found == null) {
Field f = null;
for (int i = 0; found == null && i < sourceClass.getFields().length; i++) {
f = sourceClass.getFields()[i];
if (f.getClass().equals(searchedClass)) {
found = f;
}
}
}
return found;
} | [
"public",
"static",
"Field",
"findProperty",
"(",
"final",
"Class",
"<",
"?",
">",
"sourceClass",
",",
"final",
"String",
"itemName",
",",
"final",
"Class",
"<",
"?",
">",
"searchedClass",
")",
"{",
"Field",
"found",
"=",
"null",
";",
"if",
"(",
"itemNam... | Retrieve a field according to the item name first, then according to searched class.
@param sourceClass the class to inspect
@param itemName the item name to find (LIKE_THIS)
@param searchedClass the property class to find if item name query has failed
@return the source class field that match provided criterion | [
"Retrieve",
"a",
"field",
"according",
"to",
"the",
"item",
"name",
"first",
"then",
"according",
"to",
"searched",
"class",
"."
] | train | https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java#L329-L350 |
samskivert/samskivert | src/main/java/com/samskivert/net/cddb/CDDB.java | CDDB.lscat | public String[] lscat()
throws IOException, CDDBException
{
// sanity check
if (_sock == null) {
throw new CDDBException(500, "Not connected");
}
// make the request
Response rsp = request("cddb lscat");
// anything other than an OK response earns an exception
if (rsp.code != 210) {
throw new CDDBException(rsp.code, rsp.message);
}
ArrayList<String> list = new ArrayList<String>();
String input;
while (!(input = _in.readLine()).equals(CDDBProtocol.TERMINATOR)) {
list.add(input);
}
String[] categories = new String[list.size()];
list.toArray(categories);
return categories;
} | java | public String[] lscat()
throws IOException, CDDBException
{
// sanity check
if (_sock == null) {
throw new CDDBException(500, "Not connected");
}
// make the request
Response rsp = request("cddb lscat");
// anything other than an OK response earns an exception
if (rsp.code != 210) {
throw new CDDBException(rsp.code, rsp.message);
}
ArrayList<String> list = new ArrayList<String>();
String input;
while (!(input = _in.readLine()).equals(CDDBProtocol.TERMINATOR)) {
list.add(input);
}
String[] categories = new String[list.size()];
list.toArray(categories);
return categories;
} | [
"public",
"String",
"[",
"]",
"lscat",
"(",
")",
"throws",
"IOException",
",",
"CDDBException",
"{",
"// sanity check",
"if",
"(",
"_sock",
"==",
"null",
")",
"{",
"throw",
"new",
"CDDBException",
"(",
"500",
",",
"\"Not connected\"",
")",
";",
"}",
"// ma... | Fetches and returns the list of categories supported by the server.
@throws IOException if a problem occurs chatting to the server.
@throws CDDBException if the server responds with an error. | [
"Fetches",
"and",
"returns",
"the",
"list",
"of",
"categories",
"supported",
"by",
"the",
"server",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/net/cddb/CDDB.java#L227-L252 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractIndirectionHandler.java | AbstractIndirectionHandler.getBroker | protected TemporaryBrokerWrapper getBroker() throws PBFactoryException
{
PersistenceBrokerInternal broker;
boolean needsClose = false;
if (getBrokerKey() == null)
{
/*
arminw:
if no PBKey is set we throw an exception, because we don't
know which PB (connection) should be used.
*/
throw new OJBRuntimeException("Can't find associated PBKey. Need PBKey to obtain a valid" +
"PersistenceBroker instance from intern resources.");
}
// first try to use the current threaded broker to avoid blocking
broker = PersistenceBrokerThreadMapping.currentPersistenceBroker(getBrokerKey());
// current broker not found, create a intern new one
if ((broker == null) || broker.isClosed())
{
broker = (PersistenceBrokerInternal) PersistenceBrokerFactory.createPersistenceBroker(getBrokerKey());
/** Specifies whether we obtained a fresh broker which we have to close after we used it */
needsClose = true;
}
return new TemporaryBrokerWrapper(broker, needsClose);
} | java | protected TemporaryBrokerWrapper getBroker() throws PBFactoryException
{
PersistenceBrokerInternal broker;
boolean needsClose = false;
if (getBrokerKey() == null)
{
/*
arminw:
if no PBKey is set we throw an exception, because we don't
know which PB (connection) should be used.
*/
throw new OJBRuntimeException("Can't find associated PBKey. Need PBKey to obtain a valid" +
"PersistenceBroker instance from intern resources.");
}
// first try to use the current threaded broker to avoid blocking
broker = PersistenceBrokerThreadMapping.currentPersistenceBroker(getBrokerKey());
// current broker not found, create a intern new one
if ((broker == null) || broker.isClosed())
{
broker = (PersistenceBrokerInternal) PersistenceBrokerFactory.createPersistenceBroker(getBrokerKey());
/** Specifies whether we obtained a fresh broker which we have to close after we used it */
needsClose = true;
}
return new TemporaryBrokerWrapper(broker, needsClose);
} | [
"protected",
"TemporaryBrokerWrapper",
"getBroker",
"(",
")",
"throws",
"PBFactoryException",
"{",
"PersistenceBrokerInternal",
"broker",
";",
"boolean",
"needsClose",
"=",
"false",
";",
"if",
"(",
"getBrokerKey",
"(",
")",
"==",
"null",
")",
"{",
"/*\r\n ... | Gets the persistence broker used by this indirection handler.
If no PBKey is available a runtime exception will be thrown.
@return a PersistenceBroker | [
"Gets",
"the",
"persistence",
"broker",
"used",
"by",
"this",
"indirection",
"handler",
".",
"If",
"no",
"PBKey",
"is",
"available",
"a",
"runtime",
"exception",
"will",
"be",
"thrown",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractIndirectionHandler.java#L180-L205 |
Hygieia/Hygieia | collectors/build/jenkins/src/main/java/com/capitalone/dashboard/collector/DefaultHudsonClient.java | DefaultHudsonClient.joinURL | public static String joinURL(String base, String[] paths) {
StringBuilder result = new StringBuilder(base);
Arrays.stream(paths).map(path -> path.replaceFirst("^(\\/)+", "")).forEach(p -> {
if (result.lastIndexOf("/") != result.length() - 1) {
result.append('/');
}
result.append(p);
});
return result.toString();
} | java | public static String joinURL(String base, String[] paths) {
StringBuilder result = new StringBuilder(base);
Arrays.stream(paths).map(path -> path.replaceFirst("^(\\/)+", "")).forEach(p -> {
if (result.lastIndexOf("/") != result.length() - 1) {
result.append('/');
}
result.append(p);
});
return result.toString();
} | [
"public",
"static",
"String",
"joinURL",
"(",
"String",
"base",
",",
"String",
"[",
"]",
"paths",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"base",
")",
";",
"Arrays",
".",
"stream",
"(",
"paths",
")",
".",
"map",
"(",
"pat... | join a base url to another path or paths - this will handle trailing or non-trailing /'s | [
"join",
"a",
"base",
"url",
"to",
"another",
"path",
"or",
"paths",
"-",
"this",
"will",
"handle",
"trailing",
"or",
"non",
"-",
"trailing",
"/",
"s"
] | train | https://github.com/Hygieia/Hygieia/blob/d8b67a590da2744acf59bcd99d9b34ef1bb84890/collectors/build/jenkins/src/main/java/com/capitalone/dashboard/collector/DefaultHudsonClient.java#L691-L700 |
Azure/azure-sdk-for-java | servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClient.java | ManagementClient.subscriptionExists | public Boolean subscriptionExists(String topicPath, String subscriptionName) throws ServiceBusException, InterruptedException {
return Utils.completeFuture(this.asyncClient.subscriptionExistsAsync(topicPath, subscriptionName));
} | java | public Boolean subscriptionExists(String topicPath, String subscriptionName) throws ServiceBusException, InterruptedException {
return Utils.completeFuture(this.asyncClient.subscriptionExistsAsync(topicPath, subscriptionName));
} | [
"public",
"Boolean",
"subscriptionExists",
"(",
"String",
"topicPath",
",",
"String",
"subscriptionName",
")",
"throws",
"ServiceBusException",
",",
"InterruptedException",
"{",
"return",
"Utils",
".",
"completeFuture",
"(",
"this",
".",
"asyncClient",
".",
"subscript... | Checks whether a given subscription exists or not.
@param topicPath - Path of the topic
@param subscriptionName - Name of the subscription.
@return - True if the entity exists. False otherwise.
@throws IllegalArgumentException - path is not null / empty / too long / invalid.
@throws TimeoutException - The operation times out. The timeout period is initiated through ClientSettings.operationTimeout
@throws AuthorizationFailedException - No sufficient permission to perform this operation. Please check ClientSettings.tokenProvider has correct details.
@throws ServerBusyException - The server is busy. You should wait before you retry the operation.
@throws ServiceBusException - An internal error or an unexpected exception occurred.
@throws InterruptedException if the current thread was interrupted | [
"Checks",
"whether",
"a",
"given",
"subscription",
"exists",
"or",
"not",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClient.java#L535-L537 |
pmlopes/yoke | framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java | YokeRequest.destroySession | public void destroySession() {
JsonObject session = get("session");
if (session == null) {
return;
}
String sessionId = session.getString("id");
// remove from the context
put("session", null);
if (sessionId == null) {
return;
}
store.destroy(sessionId, new Handler<Object>() {
@Override
public void handle(Object error) {
if (error != null) {
// TODO: better handling of errors
System.err.println(error);
}
}
});
} | java | public void destroySession() {
JsonObject session = get("session");
if (session == null) {
return;
}
String sessionId = session.getString("id");
// remove from the context
put("session", null);
if (sessionId == null) {
return;
}
store.destroy(sessionId, new Handler<Object>() {
@Override
public void handle(Object error) {
if (error != null) {
// TODO: better handling of errors
System.err.println(error);
}
}
});
} | [
"public",
"void",
"destroySession",
"(",
")",
"{",
"JsonObject",
"session",
"=",
"get",
"(",
"\"session\"",
")",
";",
"if",
"(",
"session",
"==",
"null",
")",
"{",
"return",
";",
"}",
"String",
"sessionId",
"=",
"session",
".",
"getString",
"(",
"\"id\""... | Destroys a session from the request context and also from the storage engine. | [
"Destroys",
"a",
"session",
"from",
"the",
"request",
"context",
"and",
"also",
"from",
"the",
"storage",
"engine",
"."
] | train | https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L317-L340 |
zeroturnaround/maven-jrebel-plugin | src/main/java/org/zeroturnaround/javarebel/maven/GenerateRebelMojo.java | GenerateRebelMojo.getPluginSetting | private String getPluginSetting(MavenProject project, String pluginId, String optionName, String defaultValue) {
Xpp3Dom dom = getPluginConfigurationDom(project, pluginId);
if (dom != null && dom.getChild(optionName) != null) {
return getValue(project, dom.getChild(optionName));
}
return defaultValue;
} | java | private String getPluginSetting(MavenProject project, String pluginId, String optionName, String defaultValue) {
Xpp3Dom dom = getPluginConfigurationDom(project, pluginId);
if (dom != null && dom.getChild(optionName) != null) {
return getValue(project, dom.getChild(optionName));
}
return defaultValue;
} | [
"private",
"String",
"getPluginSetting",
"(",
"MavenProject",
"project",
",",
"String",
"pluginId",
",",
"String",
"optionName",
",",
"String",
"defaultValue",
")",
"{",
"Xpp3Dom",
"dom",
"=",
"getPluginConfigurationDom",
"(",
"project",
",",
"pluginId",
")",
";",... | Search for a configuration setting of an other plugin.
@param project the current maven project to get the configuration from.
@param pluginId the group id and artifact id of the plugin to search for
@param optionName the option to get from the configuration
@param defaultValue the default value if the configuration was not found
@return the value of the option configured in the plugin configuration | [
"Search",
"for",
"a",
"configuration",
"setting",
"of",
"an",
"other",
"plugin",
"."
] | train | https://github.com/zeroturnaround/maven-jrebel-plugin/blob/6a0d12529a13ae6b2b772658a714398147c091ca/src/main/java/org/zeroturnaround/javarebel/maven/GenerateRebelMojo.java#L760-L766 |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/ObjectUtils.java | ObjectUtils.caseInsensitiveValueOf | public static <E extends Enum<?>> E caseInsensitiveValueOf(E[] enumValues, String constant) {
for (E candidate : enumValues) {
if (candidate.toString().equalsIgnoreCase(constant)) {
return candidate;
}
}
throw new IllegalArgumentException(String.format("constant [%s] does not exist in enum type %s", constant,
enumValues.getClass().getComponentType().getName()));
} | java | public static <E extends Enum<?>> E caseInsensitiveValueOf(E[] enumValues, String constant) {
for (E candidate : enumValues) {
if (candidate.toString().equalsIgnoreCase(constant)) {
return candidate;
}
}
throw new IllegalArgumentException(String.format("constant [%s] does not exist in enum type %s", constant,
enumValues.getClass().getComponentType().getName()));
} | [
"public",
"static",
"<",
"E",
"extends",
"Enum",
"<",
"?",
">",
">",
"E",
"caseInsensitiveValueOf",
"(",
"E",
"[",
"]",
"enumValues",
",",
"String",
"constant",
")",
"{",
"for",
"(",
"E",
"candidate",
":",
"enumValues",
")",
"{",
"if",
"(",
"candidate"... | Case insensitive alternative to {@link Enum#valueOf(Class, String)}.
@param <E> the concrete Enum type
@param enumValues the array of all Enum constants in question, usually per
Enum.values()
@param constant the constant to get the enum value of
@throws IllegalArgumentException if the given constant is not found in the given array of enum
values. Use {@link #containsConstant(Enum[], String)} as a
guard to avoid this exception. | [
"Case",
"insensitive",
"alternative",
"to",
"{",
"@link",
"Enum#valueOf",
"(",
"Class",
"String",
")",
"}",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ObjectUtils.java#L187-L195 |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/LongExtensions.java | LongExtensions.operator_equals | @Pure
@Inline(value="($1 == $2)", constantExpression=true)
public static boolean operator_equals(long a, double b) {
return a == b;
} | java | @Pure
@Inline(value="($1 == $2)", constantExpression=true)
public static boolean operator_equals(long a, double b) {
return a == b;
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"($1 == $2)\"",
",",
"constantExpression",
"=",
"true",
")",
"public",
"static",
"boolean",
"operator_equals",
"(",
"long",
"a",
",",
"double",
"b",
")",
"{",
"return",
"a",
"==",
"b",
";",
"}"
] | The binary <code>equals</code> operator. This is the equivalent to the Java <code>==</code> operator.
@param a a long.
@param b a double.
@return <code>a==b</code>
@since 2.3 | [
"The",
"binary",
"<code",
">",
"equals<",
"/",
"code",
">",
"operator",
".",
"This",
"is",
"the",
"equivalent",
"to",
"the",
"Java",
"<code",
">",
"==",
"<",
"/",
"code",
">",
"operator",
"."
] | train | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/LongExtensions.java#L376-L380 |
qos-ch/slf4j | slf4j-ext/src/main/java/org/slf4j/profiler/SpacePadder.java | SpacePadder.spacePad | final static public void spacePad(StringBuilder sbuf, int length) {
while (length >= 32) {
sbuf.append(SPACES[5]);
length -= 32;
}
for (int i = 4; i >= 0; i--) {
if ((length & (1 << i)) != 0) {
sbuf.append(SPACES[i]);
}
}
} | java | final static public void spacePad(StringBuilder sbuf, int length) {
while (length >= 32) {
sbuf.append(SPACES[5]);
length -= 32;
}
for (int i = 4; i >= 0; i--) {
if ((length & (1 << i)) != 0) {
sbuf.append(SPACES[i]);
}
}
} | [
"final",
"static",
"public",
"void",
"spacePad",
"(",
"StringBuilder",
"sbuf",
",",
"int",
"length",
")",
"{",
"while",
"(",
"length",
">=",
"32",
")",
"{",
"sbuf",
".",
"append",
"(",
"SPACES",
"[",
"5",
"]",
")",
";",
"length",
"-=",
"32",
";",
"... | Fast space padding method.
@param sbuf the buffer to pad
@param length the target size of the buffer after padding | [
"Fast",
"space",
"padding",
"method",
"."
] | train | https://github.com/qos-ch/slf4j/blob/905443f39fadd88a8dd2c467e44affd8cb072a4d/slf4j-ext/src/main/java/org/slf4j/profiler/SpacePadder.java#L115-L126 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/RepositoryFileApi.java | RepositoryFileApi.getFileV3 | @Deprecated
protected RepositoryFile getFileV3(String filePath, Integer projectId, String ref) throws GitLabApiException {
Form form = new Form();
addFormParam(form, "file_path", filePath, true);
addFormParam(form, "ref", ref, true);
Response response = get(Response.Status.OK, form.asMap(), "projects", projectId, "repository", "files");
return (response.readEntity(RepositoryFile.class));
} | java | @Deprecated
protected RepositoryFile getFileV3(String filePath, Integer projectId, String ref) throws GitLabApiException {
Form form = new Form();
addFormParam(form, "file_path", filePath, true);
addFormParam(form, "ref", ref, true);
Response response = get(Response.Status.OK, form.asMap(), "projects", projectId, "repository", "files");
return (response.readEntity(RepositoryFile.class));
} | [
"@",
"Deprecated",
"protected",
"RepositoryFile",
"getFileV3",
"(",
"String",
"filePath",
",",
"Integer",
"projectId",
",",
"String",
"ref",
")",
"throws",
"GitLabApiException",
"{",
"Form",
"form",
"=",
"new",
"Form",
"(",
")",
";",
"addFormParam",
"(",
"form... | Get file from repository. Allows you to receive information about file in repository like name, size, content.
Note that file content is Base64 encoded.
<pre><code>GitLab Endpoint: GET /projects/:id/repository/files</code></pre>
@param filePath (required) - Full path to new file. Ex. lib/class.rb
@param projectId (required) - the project ID
@param ref (required) - The name of branch, tag or commit
@return a RepositoryFile instance with the file info
@throws GitLabApiException if any exception occurs
@deprecated Will be removed in version 5.0 | [
"Get",
"file",
"from",
"repository",
".",
"Allows",
"you",
"to",
"receive",
"information",
"about",
"file",
"in",
"repository",
"like",
"name",
"size",
"content",
".",
"Note",
"that",
"file",
"content",
"is",
"Base64",
"encoded",
"."
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/RepositoryFileApi.java#L179-L186 |
ldapchai/ldapchai | src/main/java/com/novell/ldapchai/provider/ChaiConfiguration.java | ChaiConfiguration.newConfiguration | public static ChaiConfiguration newConfiguration( final String ldapURL, final String bindDN, final String bindPassword )
{
return new ChaiConfigurationBuilder( ldapURL, bindDN, bindPassword ).build();
} | java | public static ChaiConfiguration newConfiguration( final String ldapURL, final String bindDN, final String bindPassword )
{
return new ChaiConfigurationBuilder( ldapURL, bindDN, bindPassword ).build();
} | [
"public",
"static",
"ChaiConfiguration",
"newConfiguration",
"(",
"final",
"String",
"ldapURL",
",",
"final",
"String",
"bindDN",
",",
"final",
"String",
"bindPassword",
")",
"{",
"return",
"new",
"ChaiConfigurationBuilder",
"(",
"ldapURL",
",",
"bindDN",
",",
"bi... | Construct a default {@code ChaiConfiguration}.
@param bindDN ldap bind DN, in ldap fully qualified syntax. Also used as the DN of the returned ChaiUser.
@param bindPassword password for the bind DN.
@param ldapURL ldap server and port in url format, example: <i>ldap://127.0.0.1:389</i>
@return a new configuration instance. | [
"Construct",
"a",
"default",
"{",
"@code",
"ChaiConfiguration",
"}",
"."
] | train | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/provider/ChaiConfiguration.java#L81-L84 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/util/sort/SorterFactory.java | SorterFactory.createSorterElseDefault | public static <T extends Sorter> T createSorterElseDefault(final SortType type, final T defaultSorter) {
try {
return createSorter(type);
}
catch (IllegalArgumentException ignore) {
return defaultSorter;
}
} | java | public static <T extends Sorter> T createSorterElseDefault(final SortType type, final T defaultSorter) {
try {
return createSorter(type);
}
catch (IllegalArgumentException ignore) {
return defaultSorter;
}
} | [
"public",
"static",
"<",
"T",
"extends",
"Sorter",
">",
"T",
"createSorterElseDefault",
"(",
"final",
"SortType",
"type",
",",
"final",
"T",
"defaultSorter",
")",
"{",
"try",
"{",
"return",
"createSorter",
"(",
"type",
")",
";",
"}",
"catch",
"(",
"Illegal... | Creates an instance of the Sorter interface implementing the sorting algorithm based on the SortType,
otherwise returns the provided default Sorter implementation if a Sorter based on the specified SortType
is not available.
@param <T> the Class type of the actual Sorter implementation based on the SortType.
@param type the type of sorting algorithm Sorter implementation to create.
@param defaultSorter the default Sorter implementation to use if a Sorter based on the specified SortType
is not available.
@return a Sorter implementation subclass that implements the sorting algorithm based on the SortType,
or the provided default Sorter implementation if the Sorter based on the SortType is not available.
@see #createSorter(SortType)
@see org.cp.elements.util.sort.Sorter
@see org.cp.elements.util.sort.SortType | [
"Creates",
"an",
"instance",
"of",
"the",
"Sorter",
"interface",
"implementing",
"the",
"sorting",
"algorithm",
"based",
"on",
"the",
"SortType",
"otherwise",
"returns",
"the",
"provided",
"default",
"Sorter",
"implementation",
"if",
"a",
"Sorter",
"based",
"on",
... | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/sort/SorterFactory.java#L97-L104 |
code4everything/util | src/main/java/com/zhazhapan/util/encryption/JavaEncrypt.java | JavaEncrypt.messageDigest | private static String messageDigest(String key, String string, int scale) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance(key);
md.update(string.getBytes());
BigInteger bigInteger = new BigInteger(md.digest());
return bigInteger.toString(scale);
} | java | private static String messageDigest(String key, String string, int scale) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance(key);
md.update(string.getBytes());
BigInteger bigInteger = new BigInteger(md.digest());
return bigInteger.toString(scale);
} | [
"private",
"static",
"String",
"messageDigest",
"(",
"String",
"key",
",",
"String",
"string",
",",
"int",
"scale",
")",
"throws",
"NoSuchAlgorithmException",
"{",
"MessageDigest",
"md",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"key",
")",
";",
"md",
"."... | 消息摘要算法,单向加密
@param key {@link String}
@param string {@link String}
@param scale {@link Integer}
@return {@link String}
@throws NoSuchAlgorithmException 异常 | [
"消息摘要算法,单向加密"
] | train | https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/encryption/JavaEncrypt.java#L348-L353 |
aspectran/aspectran | core/src/main/java/com/aspectran/core/util/ReflectionUtils.java | ReflectionUtils.getTypeDifferenceWeight | public static float getTypeDifferenceWeight(Class<?>[] paramTypes, Object[] destArgs) {
if (paramTypes.length != destArgs.length) {
return Float.MAX_VALUE;
}
float weight = 0.0f;
for (int i = 0; i < paramTypes.length; i++) {
Class<?> srcClass = paramTypes[i];
Object destArg = destArgs[i];
weight += getTypeDifferenceWeight(srcClass, destArg);
if (weight == Float.MAX_VALUE) {
break;
}
}
return weight;
} | java | public static float getTypeDifferenceWeight(Class<?>[] paramTypes, Object[] destArgs) {
if (paramTypes.length != destArgs.length) {
return Float.MAX_VALUE;
}
float weight = 0.0f;
for (int i = 0; i < paramTypes.length; i++) {
Class<?> srcClass = paramTypes[i];
Object destArg = destArgs[i];
weight += getTypeDifferenceWeight(srcClass, destArg);
if (weight == Float.MAX_VALUE) {
break;
}
}
return weight;
} | [
"public",
"static",
"float",
"getTypeDifferenceWeight",
"(",
"Class",
"<",
"?",
">",
"[",
"]",
"paramTypes",
",",
"Object",
"[",
"]",
"destArgs",
")",
"{",
"if",
"(",
"paramTypes",
".",
"length",
"!=",
"destArgs",
".",
"length",
")",
"{",
"return",
"Floa... | Algorithm that judges the match between the declared parameter types of
a candidate method and a specific list of arguments that this method is
supposed to be invoked with.
@param paramTypes the parameter types to match
@param destArgs the arguments to match
@return the accumulated weight for all arguments | [
"Algorithm",
"that",
"judges",
"the",
"match",
"between",
"the",
"declared",
"parameter",
"types",
"of",
"a",
"candidate",
"method",
"and",
"a",
"specific",
"list",
"of",
"arguments",
"that",
"this",
"method",
"is",
"supposed",
"to",
"be",
"invoked",
"with",
... | train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ReflectionUtils.java#L93-L108 |
pravega/pravega | controller/src/main/java/io/pravega/controller/store/stream/PersistentStreamBase.java | PersistentStreamBase.sealActiveTxn | private CompletableFuture<SimpleEntry<TxnStatus, Integer>> sealActiveTxn(final int epoch,
final UUID txId,
final boolean commit,
final Optional<Version> version) {
return getActiveTx(epoch, txId).thenCompose(data -> {
ActiveTxnRecord txnRecord = data.getObject();
Version dataVersion = version.orElseGet(data::getVersion);
TxnStatus status = txnRecord.getTxnStatus();
switch (status) {
case OPEN:
return sealActiveTx(epoch, txId, commit, txnRecord, dataVersion).thenApply(y ->
new SimpleEntry<>(commit ? TxnStatus.COMMITTING : TxnStatus.ABORTING, epoch));
case COMMITTING:
case COMMITTED:
if (commit) {
return CompletableFuture.completedFuture(new SimpleEntry<>(status, epoch));
} else {
throw StoreException.create(StoreException.Type.ILLEGAL_STATE,
"Stream: " + getName() + " Transaction: " + txId.toString() +
" State: " + status.name());
}
case ABORTING:
case ABORTED:
if (commit) {
throw StoreException.create(StoreException.Type.ILLEGAL_STATE,
"Stream: " + getName() + " Transaction: " + txId.toString() + " State: " +
status.name());
} else {
return CompletableFuture.completedFuture(new SimpleEntry<>(status, epoch));
}
default:
throw StoreException.create(StoreException.Type.DATA_NOT_FOUND,
"Stream: " + getName() + " Transaction: " + txId.toString());
}
});
} | java | private CompletableFuture<SimpleEntry<TxnStatus, Integer>> sealActiveTxn(final int epoch,
final UUID txId,
final boolean commit,
final Optional<Version> version) {
return getActiveTx(epoch, txId).thenCompose(data -> {
ActiveTxnRecord txnRecord = data.getObject();
Version dataVersion = version.orElseGet(data::getVersion);
TxnStatus status = txnRecord.getTxnStatus();
switch (status) {
case OPEN:
return sealActiveTx(epoch, txId, commit, txnRecord, dataVersion).thenApply(y ->
new SimpleEntry<>(commit ? TxnStatus.COMMITTING : TxnStatus.ABORTING, epoch));
case COMMITTING:
case COMMITTED:
if (commit) {
return CompletableFuture.completedFuture(new SimpleEntry<>(status, epoch));
} else {
throw StoreException.create(StoreException.Type.ILLEGAL_STATE,
"Stream: " + getName() + " Transaction: " + txId.toString() +
" State: " + status.name());
}
case ABORTING:
case ABORTED:
if (commit) {
throw StoreException.create(StoreException.Type.ILLEGAL_STATE,
"Stream: " + getName() + " Transaction: " + txId.toString() + " State: " +
status.name());
} else {
return CompletableFuture.completedFuture(new SimpleEntry<>(status, epoch));
}
default:
throw StoreException.create(StoreException.Type.DATA_NOT_FOUND,
"Stream: " + getName() + " Transaction: " + txId.toString());
}
});
} | [
"private",
"CompletableFuture",
"<",
"SimpleEntry",
"<",
"TxnStatus",
",",
"Integer",
">",
">",
"sealActiveTxn",
"(",
"final",
"int",
"epoch",
",",
"final",
"UUID",
"txId",
",",
"final",
"boolean",
"commit",
",",
"final",
"Optional",
"<",
"Version",
">",
"ve... | Seal a transaction in OPEN/COMMITTING_TXN/ABORTING state. This method does CAS on the transaction VersionedMetadata node if
the transaction is in OPEN state, optionally checking version of transaction VersionedMetadata node, if required.
@param epoch transaction epoch.
@param txId transaction identifier.
@param commit boolean indicating whether to commit or abort the transaction.
@param version optional expected version of transaction node to validate before updating it.
@return a pair containing transaction status and its epoch. | [
"Seal",
"a",
"transaction",
"in",
"OPEN",
"/",
"COMMITTING_TXN",
"/",
"ABORTING",
"state",
".",
"This",
"method",
"does",
"CAS",
"on",
"the",
"transaction",
"VersionedMetadata",
"node",
"if",
"the",
"transaction",
"is",
"in",
"OPEN",
"state",
"optionally",
"ch... | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/controller/src/main/java/io/pravega/controller/store/stream/PersistentStreamBase.java#L1106-L1141 |
beangle/beangle3 | commons/core/src/main/java/org/beangle/commons/collection/MapConverter.java | MapConverter.getLong | public Long getLong(Map<String, Object> data, String name) {
return get(data, name, Long.class);
} | java | public Long getLong(Map<String, Object> data, String name) {
return get(data, name, Long.class);
} | [
"public",
"Long",
"getLong",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"data",
",",
"String",
"name",
")",
"{",
"return",
"get",
"(",
"data",
",",
"name",
",",
"Long",
".",
"class",
")",
";",
"}"
] | <p>
getLong.
</p>
@param data a {@link java.util.Map} object.
@param name a {@link java.lang.String} object.
@return a {@link java.lang.Long} object. | [
"<p",
">",
"getLong",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/collection/MapConverter.java#L273-L275 |
io7m/jaffirm | com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Postconditions.java | Postconditions.checkPostconditionL | public static long checkPostconditionL(
final long value,
final boolean condition,
final LongFunction<String> describer)
{
return innerCheckL(value, condition, describer);
} | java | public static long checkPostconditionL(
final long value,
final boolean condition,
final LongFunction<String> describer)
{
return innerCheckL(value, condition, describer);
} | [
"public",
"static",
"long",
"checkPostconditionL",
"(",
"final",
"long",
"value",
",",
"final",
"boolean",
"condition",
",",
"final",
"LongFunction",
"<",
"String",
">",
"describer",
")",
"{",
"return",
"innerCheckL",
"(",
"value",
",",
"condition",
",",
"desc... | A {@code long} specialized version of {@link #checkPostcondition(Object,
Predicate, Function)}
@param condition The predicate
@param value The value
@param describer The describer of the predicate
@return value
@throws PostconditionViolationException If the predicate is false | [
"A",
"{",
"@code",
"long",
"}",
"specialized",
"version",
"of",
"{",
"@link",
"#checkPostcondition",
"(",
"Object",
"Predicate",
"Function",
")",
"}"
] | train | https://github.com/io7m/jaffirm/blob/c97d246242d381e48832838737418cfe4cb57b4d/com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Postconditions.java#L476-L482 |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.fillEDBObjectWithEngineeringObjectInformation | private void fillEDBObjectWithEngineeringObjectInformation(EDBObject object, OpenEngSBModel model)
throws IllegalAccessException {
if (!new AdvancedModelWrapper(model).isEngineeringObject()) {
return;
}
for (Field field : model.getClass().getDeclaredFields()) {
OpenEngSBForeignKey annotation = field.getAnnotation(OpenEngSBForeignKey.class);
if (annotation == null) {
continue;
}
String value = (String) FieldUtils.readField(field, model, true);
if (value == null) {
continue;
}
value = String.format("%s/%s", ContextHolder.get().getCurrentContextId(), value);
String key = getEOReferenceStringFromAnnotation(annotation);
object.put(key, new EDBObjectEntry(key, value, String.class));
}
} | java | private void fillEDBObjectWithEngineeringObjectInformation(EDBObject object, OpenEngSBModel model)
throws IllegalAccessException {
if (!new AdvancedModelWrapper(model).isEngineeringObject()) {
return;
}
for (Field field : model.getClass().getDeclaredFields()) {
OpenEngSBForeignKey annotation = field.getAnnotation(OpenEngSBForeignKey.class);
if (annotation == null) {
continue;
}
String value = (String) FieldUtils.readField(field, model, true);
if (value == null) {
continue;
}
value = String.format("%s/%s", ContextHolder.get().getCurrentContextId(), value);
String key = getEOReferenceStringFromAnnotation(annotation);
object.put(key, new EDBObjectEntry(key, value, String.class));
}
} | [
"private",
"void",
"fillEDBObjectWithEngineeringObjectInformation",
"(",
"EDBObject",
"object",
",",
"OpenEngSBModel",
"model",
")",
"throws",
"IllegalAccessException",
"{",
"if",
"(",
"!",
"new",
"AdvancedModelWrapper",
"(",
"model",
")",
".",
"isEngineeringObject",
"(... | Adds to the EDBObject special entries which mark that a model is referring to other models through
OpenEngSBForeignKey annotations | [
"Adds",
"to",
"the",
"EDBObject",
"special",
"entries",
"which",
"mark",
"that",
"a",
"model",
"is",
"referring",
"to",
"other",
"models",
"through",
"OpenEngSBForeignKey",
"annotations"
] | train | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L465-L483 |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.findBestMethodOnTarget | public Method findBestMethodOnTarget( String methodName,
Object... arguments ) throws NoSuchMethodException, SecurityException {
Class<?>[] argumentClasses = buildArgumentClasses(arguments);
return findBestMethodWithSignature(methodName, argumentClasses);
} | java | public Method findBestMethodOnTarget( String methodName,
Object... arguments ) throws NoSuchMethodException, SecurityException {
Class<?>[] argumentClasses = buildArgumentClasses(arguments);
return findBestMethodWithSignature(methodName, argumentClasses);
} | [
"public",
"Method",
"findBestMethodOnTarget",
"(",
"String",
"methodName",
",",
"Object",
"...",
"arguments",
")",
"throws",
"NoSuchMethodException",
",",
"SecurityException",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"argumentClasses",
"=",
"buildArgumentClasses",
"("... | Find the best method on the target class that matches the signature specified with the specified name and the list of
arguments. This method first attempts to find the method with the specified arguments; if no such method is found, a
NoSuchMethodException is thrown.
<P>
This method is unable to find methods with signatures that include both primitive arguments <i>and</i> arguments that are
instances of <code>Number</code> or its subclasses.
@param methodName the name of the method that is to be invoked.
@param arguments the array of Object instances that correspond to the arguments passed to the method.
@return the Method object that references the method that satisfies the requirements, or null if no satisfactory method
could be found.
@throws NoSuchMethodException if a matching method is not found.
@throws SecurityException if access to the information is denied. | [
"Find",
"the",
"best",
"method",
"on",
"the",
"target",
"class",
"that",
"matches",
"the",
"signature",
"specified",
"with",
"the",
"specified",
"name",
"and",
"the",
"list",
"of",
"arguments",
".",
"This",
"method",
"first",
"attempts",
"to",
"find",
"the",... | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L674-L678 |
groovy/groovy-core | src/main/org/codehaus/groovy/ast/decompiled/DecompiledClassNode.java | DecompiledClassNode.getFullModifiers | private static int getFullModifiers(ClassStub data, AsmReferenceResolver resolver) {
String className = data.className;
int bound = className.length();
while (bound > 0) {
int idx = className.lastIndexOf('$', bound);
if (idx > 0) {
ClassNode outerClass = resolver.resolveClassNullable(className.substring(0, idx));
if (outerClass instanceof DecompiledClassNode) {
Integer outerModifiers = ((DecompiledClassNode) outerClass).classData.innerClassModifiers.get(className.substring(idx + 1));
if (outerModifiers != null) {
return data.accessModifiers | outerModifiers;
}
}
}
bound = idx - 1;
}
return data.accessModifiers;
} | java | private static int getFullModifiers(ClassStub data, AsmReferenceResolver resolver) {
String className = data.className;
int bound = className.length();
while (bound > 0) {
int idx = className.lastIndexOf('$', bound);
if (idx > 0) {
ClassNode outerClass = resolver.resolveClassNullable(className.substring(0, idx));
if (outerClass instanceof DecompiledClassNode) {
Integer outerModifiers = ((DecompiledClassNode) outerClass).classData.innerClassModifiers.get(className.substring(idx + 1));
if (outerModifiers != null) {
return data.accessModifiers | outerModifiers;
}
}
}
bound = idx - 1;
}
return data.accessModifiers;
} | [
"private",
"static",
"int",
"getFullModifiers",
"(",
"ClassStub",
"data",
",",
"AsmReferenceResolver",
"resolver",
")",
"{",
"String",
"className",
"=",
"data",
".",
"className",
";",
"int",
"bound",
"=",
"className",
".",
"length",
"(",
")",
";",
"while",
"... | Static inner classes don't have "static" part in their own modifiers. Their containing classes have to be inspected
whether they have an inner class with the same name that's static. '$' separator convention is used to search
for parent classes. | [
"Static",
"inner",
"classes",
"don",
"t",
"have",
"static",
"part",
"in",
"their",
"own",
"modifiers",
".",
"Their",
"containing",
"classes",
"have",
"to",
"be",
"inspected",
"whether",
"they",
"have",
"an",
"inner",
"class",
"with",
"the",
"same",
"name",
... | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/ast/decompiled/DecompiledClassNode.java#L51-L68 |
alkacon/opencms-core | src-modules/org/opencms/workplace/commons/CmsLock.java | CmsLock.performDialogOperation | @Override
protected boolean performDialogOperation() throws CmsException {
//on multi resource operation display "please wait" screen
if (isMultiOperation() && !DIALOG_WAIT.equals(getParamAction())) {
return false;
}
// determine action to perform (lock, unlock, change lock)
int dialogAction = getDialogAction(getCms());
// now perform the operation on the resource(s)
Iterator<String> i = getResourceList().iterator();
while (i.hasNext()) {
String resName = i.next();
try {
performSingleResourceOperation(resName, dialogAction);
} catch (CmsException e) {
// collect exceptions to create a detailed output
addMultiOperationException(e);
}
}
// generate the error message for exception
String message;
if (dialogAction == TYPE_LOCK) {
message = Messages.ERR_LOCK_MULTI_0;
} else {
message = Messages.ERR_UNLOCK_MULTI_0;
}
checkMultiOperationException(Messages.get(), message);
return true;
} | java | @Override
protected boolean performDialogOperation() throws CmsException {
//on multi resource operation display "please wait" screen
if (isMultiOperation() && !DIALOG_WAIT.equals(getParamAction())) {
return false;
}
// determine action to perform (lock, unlock, change lock)
int dialogAction = getDialogAction(getCms());
// now perform the operation on the resource(s)
Iterator<String> i = getResourceList().iterator();
while (i.hasNext()) {
String resName = i.next();
try {
performSingleResourceOperation(resName, dialogAction);
} catch (CmsException e) {
// collect exceptions to create a detailed output
addMultiOperationException(e);
}
}
// generate the error message for exception
String message;
if (dialogAction == TYPE_LOCK) {
message = Messages.ERR_LOCK_MULTI_0;
} else {
message = Messages.ERR_UNLOCK_MULTI_0;
}
checkMultiOperationException(Messages.get(), message);
return true;
} | [
"@",
"Override",
"protected",
"boolean",
"performDialogOperation",
"(",
")",
"throws",
"CmsException",
"{",
"//on multi resource operation display \"please wait\" screen",
"if",
"(",
"isMultiOperation",
"(",
")",
"&&",
"!",
"DIALOG_WAIT",
".",
"equals",
"(",
"getParamActi... | Performs the lock/unlock/steal lock operation.<p>
@return true, if the operation was performed, otherwise false
@throws CmsException if operation is not successful | [
"Performs",
"the",
"lock",
"/",
"unlock",
"/",
"steal",
"lock",
"operation",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/commons/CmsLock.java#L935-L966 |
jenkinsci/jenkins | core/src/main/java/hudson/security/TokenBasedRememberMeServices2.java | TokenBasedRememberMeServices2.secureCookie | private void secureCookie(Cookie cookie, HttpServletRequest request){
// if we can mark the cookie HTTP only, do so to protect this cookie even in case of XSS vulnerability.
if (SET_HTTP_ONLY!=null) {
try {
SET_HTTP_ONLY.invoke(cookie,true);
} catch (IllegalAccessException | InvocationTargetException e) {
// ignore
}
}
// if the user is running Jenkins over HTTPS, we also want to prevent the cookie from leaking in HTTP.
// whether the login is done over HTTPS or not would be a good enough approximation of whether Jenkins runs in
// HTTPS or not, so use that.
cookie.setSecure(request.isSecure());
} | java | private void secureCookie(Cookie cookie, HttpServletRequest request){
// if we can mark the cookie HTTP only, do so to protect this cookie even in case of XSS vulnerability.
if (SET_HTTP_ONLY!=null) {
try {
SET_HTTP_ONLY.invoke(cookie,true);
} catch (IllegalAccessException | InvocationTargetException e) {
// ignore
}
}
// if the user is running Jenkins over HTTPS, we also want to prevent the cookie from leaking in HTTP.
// whether the login is done over HTTPS or not would be a good enough approximation of whether Jenkins runs in
// HTTPS or not, so use that.
cookie.setSecure(request.isSecure());
} | [
"private",
"void",
"secureCookie",
"(",
"Cookie",
"cookie",
",",
"HttpServletRequest",
"request",
")",
"{",
"// if we can mark the cookie HTTP only, do so to protect this cookie even in case of XSS vulnerability.",
"if",
"(",
"SET_HTTP_ONLY",
"!=",
"null",
")",
"{",
"try",
"{... | Force always the http-only flag and depending on the request, put also the secure flag. | [
"Force",
"always",
"the",
"http",
"-",
"only",
"flag",
"and",
"depending",
"on",
"the",
"request",
"put",
"also",
"the",
"secure",
"flag",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/security/TokenBasedRememberMeServices2.java#L309-L323 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLDataSomeValuesFromImpl_CustomFieldSerializer.java | OWLDataSomeValuesFromImpl_CustomFieldSerializer.serializeInstance | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLDataSomeValuesFromImpl instance) throws SerializationException {
serialize(streamWriter, instance);
} | java | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLDataSomeValuesFromImpl instance) throws SerializationException {
serialize(streamWriter, instance);
} | [
"@",
"Override",
"public",
"void",
"serializeInstance",
"(",
"SerializationStreamWriter",
"streamWriter",
",",
"OWLDataSomeValuesFromImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"serialize",
"(",
"streamWriter",
",",
"instance",
")",
";",
"}"
] | Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful | [
"Serializes",
"the",
"content",
"of",
"the",
"object",
"into",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamWriter",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLDataSomeValuesFromImpl_CustomFieldSerializer.java#L72-L75 |
Jasig/spring-portlet-contrib | spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/upload/CommonsPortlet2MultipartResolver.java | CommonsPortlet2MultipartResolver.parseRequest | protected MultipartParsingResult parseRequest(ResourceRequest request) throws MultipartException {
String encoding = determineEncoding(request);
FileUpload fileUpload = prepareFileUpload(encoding);
try {
@SuppressWarnings("unchecked")
List<FileItem> fileItems = ((Portlet2FileUpload) fileUpload).parseRequest(request);
return parseFileItems(fileItems, encoding);
} catch (FileUploadBase.SizeLimitExceededException ex) {
throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
} catch (FileUploadException ex) {
throw new MultipartException("Could not parse multipart portlet request", ex);
}
} | java | protected MultipartParsingResult parseRequest(ResourceRequest request) throws MultipartException {
String encoding = determineEncoding(request);
FileUpload fileUpload = prepareFileUpload(encoding);
try {
@SuppressWarnings("unchecked")
List<FileItem> fileItems = ((Portlet2FileUpload) fileUpload).parseRequest(request);
return parseFileItems(fileItems, encoding);
} catch (FileUploadBase.SizeLimitExceededException ex) {
throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
} catch (FileUploadException ex) {
throw new MultipartException("Could not parse multipart portlet request", ex);
}
} | [
"protected",
"MultipartParsingResult",
"parseRequest",
"(",
"ResourceRequest",
"request",
")",
"throws",
"MultipartException",
"{",
"String",
"encoding",
"=",
"determineEncoding",
"(",
"request",
")",
";",
"FileUpload",
"fileUpload",
"=",
"prepareFileUpload",
"(",
"enco... | <p>parseRequest.</p>
@param request a {@link javax.portlet.ResourceRequest} object.
@return a MultipartParsingResult object.
@throws org.springframework.web.multipart.MultipartException if any. | [
"<p",
">",
"parseRequest",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/upload/CommonsPortlet2MultipartResolver.java#L122-L134 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/CFEndPointSerializer.java | CFEndPointSerializer.determineType | static private StringBuilder determineType(String name, Object o) {
String value = null;
if (o instanceof String || o instanceof StringBuffer || o instanceof java.nio.CharBuffer || o instanceof Integer || o instanceof Long || o instanceof Byte
|| o instanceof Double || o instanceof Float || o instanceof Short || o instanceof BigInteger || o instanceof java.math.BigDecimal) {
value = o.toString();
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Skipping class: " + o.getClass());
}
return null;
}
// type="class" name="o"
StringBuilder buffer = new StringBuilder(48);
buffer.append(name);
buffer.append("type=\"");
// charbuffer is abstract so we might get HeapCharBuffer here, force it
// to the generic layer in the XML output
if (o instanceof java.nio.CharBuffer) {
buffer.append("java.nio.CharBuffer");
} else {
buffer.append(o.getClass().getName());
}
buffer.append("\" ");
buffer.append(name);
buffer.append("=\"");
buffer.append(value);
buffer.append("\"");
return buffer;
} | java | static private StringBuilder determineType(String name, Object o) {
String value = null;
if (o instanceof String || o instanceof StringBuffer || o instanceof java.nio.CharBuffer || o instanceof Integer || o instanceof Long || o instanceof Byte
|| o instanceof Double || o instanceof Float || o instanceof Short || o instanceof BigInteger || o instanceof java.math.BigDecimal) {
value = o.toString();
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Skipping class: " + o.getClass());
}
return null;
}
// type="class" name="o"
StringBuilder buffer = new StringBuilder(48);
buffer.append(name);
buffer.append("type=\"");
// charbuffer is abstract so we might get HeapCharBuffer here, force it
// to the generic layer in the XML output
if (o instanceof java.nio.CharBuffer) {
buffer.append("java.nio.CharBuffer");
} else {
buffer.append(o.getClass().getName());
}
buffer.append("\" ");
buffer.append(name);
buffer.append("=\"");
buffer.append(value);
buffer.append("\"");
return buffer;
} | [
"static",
"private",
"StringBuilder",
"determineType",
"(",
"String",
"name",
",",
"Object",
"o",
")",
"{",
"String",
"value",
"=",
"null",
";",
"if",
"(",
"o",
"instanceof",
"String",
"||",
"o",
"instanceof",
"StringBuffer",
"||",
"o",
"instanceof",
"java",... | Determine the type of the Object passed in and add the XML format
for the result.
@param type
@param name
@param o
@return StringBuilder | [
"Determine",
"the",
"type",
"of",
"the",
"Object",
"passed",
"in",
"and",
"add",
"the",
"XML",
"format",
"for",
"the",
"result",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/CFEndPointSerializer.java#L48-L77 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/requeststate/NameService.java | NameService.nameObject | public synchronized void nameObject(String namePrefix, INameable object)
{
String name = namePrefix + Integer.toString(_nextValue++);
object.setObjectName(name);
} | java | public synchronized void nameObject(String namePrefix, INameable object)
{
String name = namePrefix + Integer.toString(_nextValue++);
object.setObjectName(name);
} | [
"public",
"synchronized",
"void",
"nameObject",
"(",
"String",
"namePrefix",
",",
"INameable",
"object",
")",
"{",
"String",
"name",
"=",
"namePrefix",
"+",
"Integer",
".",
"toString",
"(",
"_nextValue",
"++",
")",
";",
"object",
".",
"setObjectName",
"(",
"... | This method will create a unique name for an INameable object. The name
will be unque within the session. This will throw an IllegalStateException
if INameable.setObjectName has previously been called on object.
@param namePrefix The prefix of the generated name.
@param object the INameable object.
@throws IllegalStateException if this method is called more than once for an object | [
"This",
"method",
"will",
"create",
"a",
"unique",
"name",
"for",
"an",
"INameable",
"object",
".",
"The",
"name",
"will",
"be",
"unque",
"within",
"the",
"session",
".",
"This",
"will",
"throw",
"an",
"IllegalStateException",
"if",
"INameable",
".",
"setObj... | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/requeststate/NameService.java#L160-L164 |
zxing/zxing | core/src/main/java/com/google/zxing/common/BitMatrix.java | BitMatrix.getRow | public BitArray getRow(int y, BitArray row) {
if (row == null || row.getSize() < width) {
row = new BitArray(width);
} else {
row.clear();
}
int offset = y * rowSize;
for (int x = 0; x < rowSize; x++) {
row.setBulk(x * 32, bits[offset + x]);
}
return row;
} | java | public BitArray getRow(int y, BitArray row) {
if (row == null || row.getSize() < width) {
row = new BitArray(width);
} else {
row.clear();
}
int offset = y * rowSize;
for (int x = 0; x < rowSize; x++) {
row.setBulk(x * 32, bits[offset + x]);
}
return row;
} | [
"public",
"BitArray",
"getRow",
"(",
"int",
"y",
",",
"BitArray",
"row",
")",
"{",
"if",
"(",
"row",
"==",
"null",
"||",
"row",
".",
"getSize",
"(",
")",
"<",
"width",
")",
"{",
"row",
"=",
"new",
"BitArray",
"(",
"width",
")",
";",
"}",
"else",
... | A fast method to retrieve one row of data from the matrix as a BitArray.
@param y The row to retrieve
@param row An optional caller-allocated BitArray, will be allocated if null or too small
@return The resulting BitArray - this reference should always be used even when passing
your own row | [
"A",
"fast",
"method",
"to",
"retrieve",
"one",
"row",
"of",
"data",
"from",
"the",
"matrix",
"as",
"a",
"BitArray",
"."
] | train | https://github.com/zxing/zxing/blob/653ac2a3beb11481eff82e7d5f2bab8a745f7fac/core/src/main/java/com/google/zxing/common/BitMatrix.java#L259-L270 |
Berico-Technologies/CLAVIN | src/main/java/com/bericotech/clavin/GeoParserFactory.java | GeoParserFactory.getDefault | public static GeoParser getDefault(String pathToLuceneIndex, LocationExtractor extractor, int maxHitDepth,
int maxContentWindow, boolean fuzzy) throws ClavinException {
// instantiate new LuceneGazetteer
Gazetteer gazetteer = new LuceneGazetteer(new File(pathToLuceneIndex));
return new GeoParser(extractor, gazetteer, maxHitDepth, maxContentWindow, fuzzy);
} | java | public static GeoParser getDefault(String pathToLuceneIndex, LocationExtractor extractor, int maxHitDepth,
int maxContentWindow, boolean fuzzy) throws ClavinException {
// instantiate new LuceneGazetteer
Gazetteer gazetteer = new LuceneGazetteer(new File(pathToLuceneIndex));
return new GeoParser(extractor, gazetteer, maxHitDepth, maxContentWindow, fuzzy);
} | [
"public",
"static",
"GeoParser",
"getDefault",
"(",
"String",
"pathToLuceneIndex",
",",
"LocationExtractor",
"extractor",
",",
"int",
"maxHitDepth",
",",
"int",
"maxContentWindow",
",",
"boolean",
"fuzzy",
")",
"throws",
"ClavinException",
"{",
"// instantiate new Lucen... | Get a GeoParser with defined values for maxHitDepth and
maxContentWindow, fuzzy matching explicitly turned on or off,
and a specific LocationExtractor to use.
@param pathToLuceneIndex Path to the local Lucene index.
@param extractor A specific implementation of LocationExtractor to be used
@param maxHitDepth Number of candidate matches to consider
@param maxContentWindow How much context to consider when resolving
@param fuzzy Should fuzzy matching be used?
@return GeoParser
@throws ClavinException If the index cannot be created. | [
"Get",
"a",
"GeoParser",
"with",
"defined",
"values",
"for",
"maxHitDepth",
"and",
"maxContentWindow",
"fuzzy",
"matching",
"explicitly",
"turned",
"on",
"or",
"off",
"and",
"a",
"specific",
"LocationExtractor",
"to",
"use",
"."
] | train | https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/GeoParserFactory.java#L118-L123 |
geomajas/geomajas-project-client-gwt | common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java | HtmlBuilder.openTagClassHtmlContent | public static String openTagClassHtmlContent(String tag, String clazz, String... content) {
return openTagHtmlContent(tag, clazz, null, content);
} | java | public static String openTagClassHtmlContent(String tag, String clazz, String... content) {
return openTagHtmlContent(tag, clazz, null, content);
} | [
"public",
"static",
"String",
"openTagClassHtmlContent",
"(",
"String",
"tag",
",",
"String",
"clazz",
",",
"String",
"...",
"content",
")",
"{",
"return",
"openTagHtmlContent",
"(",
"tag",
",",
"clazz",
",",
"null",
",",
"content",
")",
";",
"}"
] | Build a String containing a HTML opening tag with given CSS class and concatenates the given HTML content.
@param tag String name of HTML tag
@param clazz CSS class of the tag
@param content content string
@return HTML tag element as string | [
"Build",
"a",
"String",
"containing",
"a",
"HTML",
"opening",
"tag",
"with",
"given",
"CSS",
"class",
"and",
"concatenates",
"the",
"given",
"HTML",
"content",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java#L350-L352 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/core/util/MimeTypeUtil.java | MimeTypeUtil.getMimeType | public static MimeType getMimeType(String name, Property property) {
MimeType result = null;
try {
Binary binary = property != null ? property.getBinary() : null;
if (binary != null) {
try {
InputStream input = binary.getStream();
try {
MediaType mediaType = getMediaType(input, name);
if (mediaType != null) {
try {
result = getMimeTypes().forName(mediaType.toString());
} catch (MimeTypeException e1) {
// detection not successful
}
}
} finally {
try {
input.close();
} catch (IOException ioex) {
LOG.error(ioex.toString());
}
}
} finally {
binary.dispose();
}
}
} catch (RepositoryException rex) {
LOG.error(rex.toString());
}
return result;
} | java | public static MimeType getMimeType(String name, Property property) {
MimeType result = null;
try {
Binary binary = property != null ? property.getBinary() : null;
if (binary != null) {
try {
InputStream input = binary.getStream();
try {
MediaType mediaType = getMediaType(input, name);
if (mediaType != null) {
try {
result = getMimeTypes().forName(mediaType.toString());
} catch (MimeTypeException e1) {
// detection not successful
}
}
} finally {
try {
input.close();
} catch (IOException ioex) {
LOG.error(ioex.toString());
}
}
} finally {
binary.dispose();
}
}
} catch (RepositoryException rex) {
LOG.error(rex.toString());
}
return result;
} | [
"public",
"static",
"MimeType",
"getMimeType",
"(",
"String",
"name",
",",
"Property",
"property",
")",
"{",
"MimeType",
"result",
"=",
"null",
";",
"try",
"{",
"Binary",
"binary",
"=",
"property",
"!=",
"null",
"?",
"property",
".",
"getBinary",
"(",
")",... | Detects the mime type of a binary property in the context of the nodes name.
@param name the name of the node which defines the binary resource (probably a file name)
@param property the binary property (for stream parsing)
@return he detected mime type or 'null' if the detection was not successful | [
"Detects",
"the",
"mime",
"type",
"of",
"a",
"binary",
"property",
"in",
"the",
"context",
"of",
"the",
"nodes",
"name",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/util/MimeTypeUtil.java#L139-L170 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/processor/XSLTElementDef.java | XSLTElementDef.equalsMayBeNullOrZeroLen | private static boolean equalsMayBeNullOrZeroLen(String s1, String s2)
{
int len1 = (s1 == null) ? 0 : s1.length();
int len2 = (s2 == null) ? 0 : s2.length();
return (len1 != len2) ? false
: (len1 == 0) ? true
: s1.equals(s2);
} | java | private static boolean equalsMayBeNullOrZeroLen(String s1, String s2)
{
int len1 = (s1 == null) ? 0 : s1.length();
int len2 = (s2 == null) ? 0 : s2.length();
return (len1 != len2) ? false
: (len1 == 0) ? true
: s1.equals(s2);
} | [
"private",
"static",
"boolean",
"equalsMayBeNullOrZeroLen",
"(",
"String",
"s1",
",",
"String",
"s2",
")",
"{",
"int",
"len1",
"=",
"(",
"s1",
"==",
"null",
")",
"?",
"0",
":",
"s1",
".",
"length",
"(",
")",
";",
"int",
"len2",
"=",
"(",
"s2",
"=="... | Tell if the two string refs are equal,
equality being defined as:
1) Both strings are null.
2) One string is null and the other is empty.
3) Both strings are non-null, and equal.
@param s1 A reference to the first string, or null.
@param s2 A reference to the second string, or null.
@return true if Both strings are null, or if
one string is null and the other is empty, or if
both strings are non-null, and equal because
s1.equals(s2) returns true. | [
"Tell",
"if",
"the",
"two",
"string",
"refs",
"are",
"equal",
"equality",
"being",
"defined",
"as",
":",
"1",
")",
"Both",
"strings",
"are",
"null",
".",
"2",
")",
"One",
"string",
"is",
"null",
"and",
"the",
"other",
"is",
"empty",
".",
"3",
")",
... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/processor/XSLTElementDef.java#L326-L335 |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d1/dfx/AbstractRectangularShape1dfx.java | AbstractRectangularShape1dfx.heightProperty | @Pure
public DoubleProperty heightProperty() {
if (this.height == null) {
this.height = new SimpleDoubleProperty(this, MathFXAttributeNames.HEIGHT);
this.height.bind(Bindings.subtract(maxYProperty(), minYProperty()));
}
return this.height;
} | java | @Pure
public DoubleProperty heightProperty() {
if (this.height == null) {
this.height = new SimpleDoubleProperty(this, MathFXAttributeNames.HEIGHT);
this.height.bind(Bindings.subtract(maxYProperty(), minYProperty()));
}
return this.height;
} | [
"@",
"Pure",
"public",
"DoubleProperty",
"heightProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"height",
"==",
"null",
")",
"{",
"this",
".",
"height",
"=",
"new",
"SimpleDoubleProperty",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"HEIGHT",
")",
";"... | Replies the property that is the height of the box.
@return the height property. | [
"Replies",
"the",
"property",
"that",
"is",
"the",
"height",
"of",
"the",
"box",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d1/dfx/AbstractRectangularShape1dfx.java#L292-L299 |
infinispan/infinispan | commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java | MarshallUtil.marshallIntCollection | public static void marshallIntCollection(Collection<Integer> collection, ObjectOutput out) throws IOException {
final int size = collection == null ? NULL_VALUE : collection.size();
marshallSize(out, size);
if (size <= 0) {
return;
}
for (Integer integer : collection) {
out.writeInt(integer);
}
} | java | public static void marshallIntCollection(Collection<Integer> collection, ObjectOutput out) throws IOException {
final int size = collection == null ? NULL_VALUE : collection.size();
marshallSize(out, size);
if (size <= 0) {
return;
}
for (Integer integer : collection) {
out.writeInt(integer);
}
} | [
"public",
"static",
"void",
"marshallIntCollection",
"(",
"Collection",
"<",
"Integer",
">",
"collection",
",",
"ObjectOutput",
"out",
")",
"throws",
"IOException",
"{",
"final",
"int",
"size",
"=",
"collection",
"==",
"null",
"?",
"NULL_VALUE",
":",
"collection... | Marshalls a collection of integers.
@param collection the collection to marshall.
@param out the {@link ObjectOutput} to write to.
@throws IOException if an error occurs. | [
"Marshalls",
"a",
"collection",
"of",
"integers",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L469-L478 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java | FieldUtils.readStaticField | public static Object readStaticField(final Field field, final boolean forceAccess) throws IllegalAccessException {
Validate.isTrue(field != null, "The field must not be null");
Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field '%s' is not static", field.getName());
return readField(field, (Object) null, forceAccess);
} | java | public static Object readStaticField(final Field field, final boolean forceAccess) throws IllegalAccessException {
Validate.isTrue(field != null, "The field must not be null");
Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field '%s' is not static", field.getName());
return readField(field, (Object) null, forceAccess);
} | [
"public",
"static",
"Object",
"readStaticField",
"(",
"final",
"Field",
"field",
",",
"final",
"boolean",
"forceAccess",
")",
"throws",
"IllegalAccessException",
"{",
"Validate",
".",
"isTrue",
"(",
"field",
"!=",
"null",
",",
"\"The field must not be null\"",
")",
... | Reads a static {@link Field}.
@param field
to read
@param forceAccess
whether to break scope restrictions using the
{@link java.lang.reflect.AccessibleObject#setAccessible(boolean)} method.
@return the field value
@throws IllegalArgumentException
if the field is {@code null} or not {@code static}
@throws IllegalAccessException
if the field is not made accessible | [
"Reads",
"a",
"static",
"{",
"@link",
"Field",
"}",
"."
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java#L296-L300 |
tdomzal/junit-docker-rule | src/main/java/pl/domzal/junit/docker/rule/WaitForContainer.java | WaitForContainer.waitForCondition | static void waitForCondition(final StartConditionCheck condition, int timeoutSeconds, final String containerDescription) throws TimeoutException {
try {
log.info("wait for {} started", condition.describe());
new WaitForUnit(TimeUnit.SECONDS, timeoutSeconds, TimeUnit.SECONDS, 1, new WaitForUnit.WaitForCondition() {
@Override
public boolean isConditionMet() {
return condition.check();
}
@Override
public String timeoutMessage() {
return String.format("timeout waiting for %s in container %s", condition.describe(), containerDescription);
}
}).startWaiting();
log.info("wait for {} - condition met", condition.describe());
} catch (InterruptedException e) {
throw new IllegalStateException(String.format("Interrupted while waiting for %s", condition.describe()), e);
}
} | java | static void waitForCondition(final StartConditionCheck condition, int timeoutSeconds, final String containerDescription) throws TimeoutException {
try {
log.info("wait for {} started", condition.describe());
new WaitForUnit(TimeUnit.SECONDS, timeoutSeconds, TimeUnit.SECONDS, 1, new WaitForUnit.WaitForCondition() {
@Override
public boolean isConditionMet() {
return condition.check();
}
@Override
public String timeoutMessage() {
return String.format("timeout waiting for %s in container %s", condition.describe(), containerDescription);
}
}).startWaiting();
log.info("wait for {} - condition met", condition.describe());
} catch (InterruptedException e) {
throw new IllegalStateException(String.format("Interrupted while waiting for %s", condition.describe()), e);
}
} | [
"static",
"void",
"waitForCondition",
"(",
"final",
"StartConditionCheck",
"condition",
",",
"int",
"timeoutSeconds",
",",
"final",
"String",
"containerDescription",
")",
"throws",
"TimeoutException",
"{",
"try",
"{",
"log",
".",
"info",
"(",
"\"wait for {} started\""... | Wait till all given conditions are met.
@param condition Conditions to wait for - all must be met to continue.
@param timeoutSeconds Wait timeout.
@param containerDescription Container description. For log and exception message usage only. | [
"Wait",
"till",
"all",
"given",
"conditions",
"are",
"met",
"."
] | train | https://github.com/tdomzal/junit-docker-rule/blob/5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2/src/main/java/pl/domzal/junit/docker/rule/WaitForContainer.java#L25-L42 |
alkacon/opencms-core | src/org/opencms/relations/CmsLink.java | CmsLink.computeUri | private String computeUri(String target, String query, String anchor) {
StringBuffer uri = new StringBuffer(64);
uri.append(target);
if (query != null) {
uri.append('?');
uri.append(query);
}
if (anchor != null) {
uri.append('#');
uri.append(anchor);
}
return uri.toString();
} | java | private String computeUri(String target, String query, String anchor) {
StringBuffer uri = new StringBuffer(64);
uri.append(target);
if (query != null) {
uri.append('?');
uri.append(query);
}
if (anchor != null) {
uri.append('#');
uri.append(anchor);
}
return uri.toString();
} | [
"private",
"String",
"computeUri",
"(",
"String",
"target",
",",
"String",
"query",
",",
"String",
"anchor",
")",
"{",
"StringBuffer",
"uri",
"=",
"new",
"StringBuffer",
"(",
"64",
")",
";",
"uri",
".",
"append",
"(",
"target",
")",
";",
"if",
"(",
"qu... | Helper method for creating a uri from its components.<p>
@param target the uri target
@param query the uri query component
@param anchor the uri anchor component
@return the uri | [
"Helper",
"method",
"for",
"creating",
"a",
"uri",
"from",
"its",
"components",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/relations/CmsLink.java#L703-L717 |
aws/aws-sdk-java | aws-java-sdk-cloudsearch/src/main/java/com/amazonaws/services/cloudsearchdomain/model/Hit.java | Hit.withFields | public Hit withFields(java.util.Map<String, java.util.List<String>> fields) {
setFields(fields);
return this;
} | java | public Hit withFields(java.util.Map<String, java.util.List<String>> fields) {
setFields(fields);
return this;
} | [
"public",
"Hit",
"withFields",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"java",
".",
"util",
".",
"List",
"<",
"String",
">",
">",
"fields",
")",
"{",
"setFields",
"(",
"fields",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The fields returned from a document that matches the search request.
</p>
@param fields
The fields returned from a document that matches the search request.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"fields",
"returned",
"from",
"a",
"document",
"that",
"matches",
"the",
"search",
"request",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-cloudsearch/src/main/java/com/amazonaws/services/cloudsearchdomain/model/Hit.java#L131-L134 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/matchspace/utils/TraceImpl.java | TraceImpl.internalInfo | private final void internalInfo(Object source, Class sourceClass, String methodName, String messageIdentifier, Object object)
{
if (usePrintWriterForTrace)
{
if (printWriter != null)
{
StringBuffer stringBuffer = new StringBuffer(new java.util.Date().toString());
stringBuffer.append(" I ");
stringBuffer.append(sourceClass.getName());
stringBuffer.append(".");
stringBuffer.append(methodName);
printWriter.println(stringBuffer.toString());
printWriter.println("\t\t"+NLS.format(messageIdentifier, object));
printWriter.flush();
}
}
if (object != null)
{
Tr.info(traceComponent, messageIdentifier, object);
}
else
{
Tr.info(traceComponent, messageIdentifier);
}
} | java | private final void internalInfo(Object source, Class sourceClass, String methodName, String messageIdentifier, Object object)
{
if (usePrintWriterForTrace)
{
if (printWriter != null)
{
StringBuffer stringBuffer = new StringBuffer(new java.util.Date().toString());
stringBuffer.append(" I ");
stringBuffer.append(sourceClass.getName());
stringBuffer.append(".");
stringBuffer.append(methodName);
printWriter.println(stringBuffer.toString());
printWriter.println("\t\t"+NLS.format(messageIdentifier, object));
printWriter.flush();
}
}
if (object != null)
{
Tr.info(traceComponent, messageIdentifier, object);
}
else
{
Tr.info(traceComponent, messageIdentifier);
}
} | [
"private",
"final",
"void",
"internalInfo",
"(",
"Object",
"source",
",",
"Class",
"sourceClass",
",",
"String",
"methodName",
",",
"String",
"messageIdentifier",
",",
"Object",
"object",
")",
"{",
"if",
"(",
"usePrintWriterForTrace",
")",
"{",
"if",
"(",
"pri... | Internal implementation of info NLS message tracing.
@param source
@param sourceClass
@param methodName
@param messageIdentifier
@param object | [
"Internal",
"implementation",
"of",
"info",
"NLS",
"message",
"tracing",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/matchspace/utils/TraceImpl.java#L819-L847 |
Azure/azure-sdk-for-java | resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/ResourcesInner.java | ResourcesInner.beginValidateMoveResources | public void beginValidateMoveResources(String sourceResourceGroupName, ResourcesMoveInfo parameters) {
beginValidateMoveResourcesWithServiceResponseAsync(sourceResourceGroupName, parameters).toBlocking().single().body();
} | java | public void beginValidateMoveResources(String sourceResourceGroupName, ResourcesMoveInfo parameters) {
beginValidateMoveResourcesWithServiceResponseAsync(sourceResourceGroupName, parameters).toBlocking().single().body();
} | [
"public",
"void",
"beginValidateMoveResources",
"(",
"String",
"sourceResourceGroupName",
",",
"ResourcesMoveInfo",
"parameters",
")",
"{",
"beginValidateMoveResourcesWithServiceResponseAsync",
"(",
"sourceResourceGroupName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")... | Validates whether resources can be moved from one resource group to another resource group.
This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation.
@param sourceResourceGroupName The name of the resource group containing the resources to validate for move.
@param parameters Parameters for moving resources.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Validates",
"whether",
"resources",
"can",
"be",
"moved",
"from",
"one",
"resource",
"group",
"to",
"another",
"resource",
"group",
".",
"This",
"operation",
"checks",
"whether",
"the",
"specified",
"resources",
"can",
"be",
"moved",
"to",
"the",
"target",
".... | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/ResourcesInner.java#L655-L657 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ThreadLocalRandom.java | ThreadLocalRandom.longs | public LongStream longs(long streamSize, long randomNumberOrigin,
long randomNumberBound) {
if (streamSize < 0L)
throw new IllegalArgumentException(BAD_SIZE);
if (randomNumberOrigin >= randomNumberBound)
throw new IllegalArgumentException(BAD_RANGE);
return StreamSupport.longStream
(new RandomLongsSpliterator
(0L, streamSize, randomNumberOrigin, randomNumberBound),
false);
} | java | public LongStream longs(long streamSize, long randomNumberOrigin,
long randomNumberBound) {
if (streamSize < 0L)
throw new IllegalArgumentException(BAD_SIZE);
if (randomNumberOrigin >= randomNumberBound)
throw new IllegalArgumentException(BAD_RANGE);
return StreamSupport.longStream
(new RandomLongsSpliterator
(0L, streamSize, randomNumberOrigin, randomNumberBound),
false);
} | [
"public",
"LongStream",
"longs",
"(",
"long",
"streamSize",
",",
"long",
"randomNumberOrigin",
",",
"long",
"randomNumberBound",
")",
"{",
"if",
"(",
"streamSize",
"<",
"0L",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"BAD_SIZE",
")",
";",
"if",
"("... | Returns a stream producing the given {@code streamSize} number of
pseudorandom {@code long}, each conforming to the given origin
(inclusive) and bound (exclusive).
@param streamSize the number of values to generate
@param randomNumberOrigin the origin (inclusive) of each random value
@param randomNumberBound the bound (exclusive) of each random value
@return a stream of pseudorandom {@code long} values,
each with the given origin (inclusive) and bound (exclusive)
@throws IllegalArgumentException if {@code streamSize} is
less than zero, or {@code randomNumberOrigin}
is greater than or equal to {@code randomNumberBound}
@since 1.8 | [
"Returns",
"a",
"stream",
"producing",
"the",
"given",
"{",
"@code",
"streamSize",
"}",
"number",
"of",
"pseudorandom",
"{",
"@code",
"long",
"}",
"each",
"conforming",
"to",
"the",
"given",
"origin",
"(",
"inclusive",
")",
"and",
"bound",
"(",
"exclusive",
... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ThreadLocalRandom.java#L603-L613 |
teatrove/teatrove | trove/src/main/java/org/teatrove/trove/util/MergedClass.java | MergedClass.buildClassFile | public static ClassFile buildClassFile(String className, Class<?>[] classes)
throws IllegalArgumentException
{
return buildClassFile(className, classes, null, null, OBSERVER_DISABLED);
} | java | public static ClassFile buildClassFile(String className, Class<?>[] classes)
throws IllegalArgumentException
{
return buildClassFile(className, classes, null, null, OBSERVER_DISABLED);
} | [
"public",
"static",
"ClassFile",
"buildClassFile",
"(",
"String",
"className",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"classes",
")",
"throws",
"IllegalArgumentException",
"{",
"return",
"buildClassFile",
"(",
"className",
",",
"classes",
",",
"null",
",",
"nu... | Just create the bytecode for the merged class, but don't load it. Since
no ClassInjector is provided to resolve name conflicts, the class name
must be manually provided.
@param className name to give to merged class
@param classes Source classes used to derive merged class | [
"Just",
"create",
"the",
"bytecode",
"for",
"the",
"merged",
"class",
"but",
"don",
"t",
"load",
"it",
".",
"Since",
"no",
"ClassInjector",
"is",
"provided",
"to",
"resolve",
"name",
"conflicts",
"the",
"class",
"name",
"must",
"be",
"manually",
"provided",
... | train | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/MergedClass.java#L420-L424 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.