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 |
|---|---|---|---|---|---|---|---|---|---|---|
vdurmont/emoji-java | src/main/java/com/vdurmont/emoji/EmojiParser.java | EmojiParser.getNextUnicodeCandidate | protected static UnicodeCandidate getNextUnicodeCandidate(char[] chars, int start) {
for (int i = start; i < chars.length; i++) {
int emojiEnd = getEmojiEndPos(chars, i);
if (emojiEnd != -1) {
Emoji emoji = EmojiManager.getByUnicode(new String(chars, i, emojiEnd - i));
String fitzpatrickString = (emojiEnd + 2 <= chars.length) ?
new String(chars, emojiEnd, 2) :
null;
return new UnicodeCandidate(
emoji,
fitzpatrickString,
i
);
}
}
return null;
} | java | protected static UnicodeCandidate getNextUnicodeCandidate(char[] chars, int start) {
for (int i = start; i < chars.length; i++) {
int emojiEnd = getEmojiEndPos(chars, i);
if (emojiEnd != -1) {
Emoji emoji = EmojiManager.getByUnicode(new String(chars, i, emojiEnd - i));
String fitzpatrickString = (emojiEnd + 2 <= chars.length) ?
new String(chars, emojiEnd, 2) :
null;
return new UnicodeCandidate(
emoji,
fitzpatrickString,
i
);
}
}
return null;
} | [
"protected",
"static",
"UnicodeCandidate",
"getNextUnicodeCandidate",
"(",
"char",
"[",
"]",
"chars",
",",
"int",
"start",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"start",
";",
"i",
"<",
"chars",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"emojiEnd... | Finds the next UnicodeCandidate after a given starting index
@param chars char array to find UnicodeCandidate in
@param start starting index for search
@return the next UnicodeCandidate or null if no UnicodeCandidate is found after start index | [
"Finds",
"the",
"next",
"UnicodeCandidate",
"after",
"a",
"given",
"starting",
"index"
] | train | https://github.com/vdurmont/emoji-java/blob/8cf5fbe0d7c1020b926791f2b342a263ed07bb0f/src/main/java/com/vdurmont/emoji/EmojiParser.java#L416-L434 |
hortonworks/dstream | dstream-api/src/main/java/io/dstream/AbstractStreamMergingFunction.java | AbstractStreamMergingFunction.addTransformationOrPredicate | public void addTransformationOrPredicate(String operationName, Object transformationOrPredicate) {
DStreamToStreamAdapterFunction incomingFunc = new DStreamToStreamAdapterFunction(operationName, transformationOrPredicate);
this.addTransformationOrPredicate(incomingFunc);
} | java | public void addTransformationOrPredicate(String operationName, Object transformationOrPredicate) {
DStreamToStreamAdapterFunction incomingFunc = new DStreamToStreamAdapterFunction(operationName, transformationOrPredicate);
this.addTransformationOrPredicate(incomingFunc);
} | [
"public",
"void",
"addTransformationOrPredicate",
"(",
"String",
"operationName",
",",
"Object",
"transformationOrPredicate",
")",
"{",
"DStreamToStreamAdapterFunction",
"incomingFunc",
"=",
"new",
"DStreamToStreamAdapterFunction",
"(",
"operationName",
",",
"transformationOrPr... | Will add transformation ({@link SerFunction}) or predicate ({@link SerPredicate}) to be
applied to the last (current) checkpoint.<br>
To ensure that both (transformation and predicate) cold be represented as a {@link SerFunction},
this method will wrap provided 'transformationOrPredicate' with {@link DStreamToStreamAdapterFunction}.
@param operationName
@param transformationOrPredicate | [
"Will",
"add",
"transformation",
"(",
"{",
"@link",
"SerFunction",
"}",
")",
"or",
"predicate",
"(",
"{",
"@link",
"SerPredicate",
"}",
")",
"to",
"be",
"applied",
"to",
"the",
"last",
"(",
"current",
")",
"checkpoint",
".",
"<br",
">",
"To",
"ensure",
... | train | https://github.com/hortonworks/dstream/blob/3a106c0f14725b028fe7fe2dbc660406d9a5f142/dstream-api/src/main/java/io/dstream/AbstractStreamMergingFunction.java#L111-L114 |
apereo/cas | support/cas-server-support-wsfederation/src/main/java/org/apereo/cas/support/wsfederation/WsFederationHelper.java | WsFederationHelper.getEncryptionCredential | @SneakyThrows
private static Credential getEncryptionCredential(final WsFederationConfiguration config) {
LOGGER.debug("Locating encryption credential private key [{}]", config.getEncryptionPrivateKey());
val br = new BufferedReader(new InputStreamReader(config.getEncryptionPrivateKey().getInputStream(), StandardCharsets.UTF_8));
Security.addProvider(new BouncyCastleProvider());
LOGGER.debug("Parsing credential private key");
try (val pemParser = new PEMParser(br)) {
val privateKeyPemObject = pemParser.readObject();
val converter = new JcaPEMKeyConverter().setProvider(new BouncyCastleProvider());
val kp = FunctionUtils.doIf(Predicates.instanceOf(PEMEncryptedKeyPair.class),
Unchecked.supplier(() -> {
LOGGER.debug("Encryption private key is an encrypted keypair");
val ckp = (PEMEncryptedKeyPair) privateKeyPemObject;
val decProv = new JcePEMDecryptorProviderBuilder().build(config.getEncryptionPrivateKeyPassword().toCharArray());
LOGGER.debug("Attempting to decrypt the encrypted keypair based on the provided encryption private key password");
return converter.getKeyPair(ckp.decryptKeyPair(decProv));
}),
Unchecked.supplier(() -> {
LOGGER.debug("Extracting a keypair from the private key");
return converter.getKeyPair((PEMKeyPair) privateKeyPemObject);
}))
.apply(privateKeyPemObject);
val certParser = new X509CertParser();
LOGGER.debug("Locating encryption certificate [{}]", config.getEncryptionCertificate());
certParser.engineInit(config.getEncryptionCertificate().getInputStream());
LOGGER.debug("Invoking certificate engine to parse the certificate [{}]", config.getEncryptionCertificate());
val cert = (X509CertificateObject) certParser.engineRead();
LOGGER.debug("Creating final credential based on the certificate [{}] and the private key", cert.getIssuerDN());
return new BasicX509Credential(cert, kp.getPrivate());
}
} | java | @SneakyThrows
private static Credential getEncryptionCredential(final WsFederationConfiguration config) {
LOGGER.debug("Locating encryption credential private key [{}]", config.getEncryptionPrivateKey());
val br = new BufferedReader(new InputStreamReader(config.getEncryptionPrivateKey().getInputStream(), StandardCharsets.UTF_8));
Security.addProvider(new BouncyCastleProvider());
LOGGER.debug("Parsing credential private key");
try (val pemParser = new PEMParser(br)) {
val privateKeyPemObject = pemParser.readObject();
val converter = new JcaPEMKeyConverter().setProvider(new BouncyCastleProvider());
val kp = FunctionUtils.doIf(Predicates.instanceOf(PEMEncryptedKeyPair.class),
Unchecked.supplier(() -> {
LOGGER.debug("Encryption private key is an encrypted keypair");
val ckp = (PEMEncryptedKeyPair) privateKeyPemObject;
val decProv = new JcePEMDecryptorProviderBuilder().build(config.getEncryptionPrivateKeyPassword().toCharArray());
LOGGER.debug("Attempting to decrypt the encrypted keypair based on the provided encryption private key password");
return converter.getKeyPair(ckp.decryptKeyPair(decProv));
}),
Unchecked.supplier(() -> {
LOGGER.debug("Extracting a keypair from the private key");
return converter.getKeyPair((PEMKeyPair) privateKeyPemObject);
}))
.apply(privateKeyPemObject);
val certParser = new X509CertParser();
LOGGER.debug("Locating encryption certificate [{}]", config.getEncryptionCertificate());
certParser.engineInit(config.getEncryptionCertificate().getInputStream());
LOGGER.debug("Invoking certificate engine to parse the certificate [{}]", config.getEncryptionCertificate());
val cert = (X509CertificateObject) certParser.engineRead();
LOGGER.debug("Creating final credential based on the certificate [{}] and the private key", cert.getIssuerDN());
return new BasicX509Credential(cert, kp.getPrivate());
}
} | [
"@",
"SneakyThrows",
"private",
"static",
"Credential",
"getEncryptionCredential",
"(",
"final",
"WsFederationConfiguration",
"config",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Locating encryption credential private key [{}]\"",
",",
"config",
".",
"getEncryptionPrivateKey",... | Gets encryption credential.
The encryption private key will need to contain the private keypair in PEM format.
The encryption certificate is shared with ADFS in DER format, i.e certificate.crt.
@param config the config
@return the encryption credential | [
"Gets",
"encryption",
"credential",
".",
"The",
"encryption",
"private",
"key",
"will",
"need",
"to",
"contain",
"the",
"private",
"keypair",
"in",
"PEM",
"format",
".",
"The",
"encryption",
"certificate",
"is",
"shared",
"with",
"ADFS",
"in",
"DER",
"format",... | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-wsfederation/src/main/java/org/apereo/cas/support/wsfederation/WsFederationHelper.java#L110-L143 |
Impetus/Kundera | src/jpa-engine/core/src/main/java/com/impetus/kundera/metadata/processor/TableProcessor.java | TableProcessor.populateRelationMetaData | private <X> void populateRelationMetaData(EntityType entityType, Class<X> clazz, EntityMetadata metadata)
{
Set<Attribute> attributes = entityType.getAttributes();
for (Attribute attribute : attributes)
{
if (attribute.isAssociation())
{
addRelationIntoMetadata(clazz, (Field) attribute.getJavaMember(), metadata);
}
}
} | java | private <X> void populateRelationMetaData(EntityType entityType, Class<X> clazz, EntityMetadata metadata)
{
Set<Attribute> attributes = entityType.getAttributes();
for (Attribute attribute : attributes)
{
if (attribute.isAssociation())
{
addRelationIntoMetadata(clazz, (Field) attribute.getJavaMember(), metadata);
}
}
} | [
"private",
"<",
"X",
">",
"void",
"populateRelationMetaData",
"(",
"EntityType",
"entityType",
",",
"Class",
"<",
"X",
">",
"clazz",
",",
"EntityMetadata",
"metadata",
")",
"{",
"Set",
"<",
"Attribute",
">",
"attributes",
"=",
"entityType",
".",
"getAttributes... | Populate metadata.
@param entityType
the EntityType
@param <X>
the generic type
@param metadata
the metadata
@throws RuleValidationException | [
"Populate",
"metadata",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/metadata/processor/TableProcessor.java#L168-L181 |
jferard/fastods | fastods/src/main/java/com/github/jferard/fastods/odselement/StylesContainer.java | StylesContainer.writeHiddenDataStyles | public void writeHiddenDataStyles(final XMLUtil util, final Appendable appendable)
throws IOException {
for (final DataStyle dataStyle : this.dataStylesContainer
.getValues(Dest.CONTENT_AUTOMATIC_STYLES)) {
dataStyle.appendXMLContent(util, appendable);
}
} | java | public void writeHiddenDataStyles(final XMLUtil util, final Appendable appendable)
throws IOException {
for (final DataStyle dataStyle : this.dataStylesContainer
.getValues(Dest.CONTENT_AUTOMATIC_STYLES)) {
dataStyle.appendXMLContent(util, appendable);
}
} | [
"public",
"void",
"writeHiddenDataStyles",
"(",
"final",
"XMLUtil",
"util",
",",
"final",
"Appendable",
"appendable",
")",
"throws",
"IOException",
"{",
"for",
"(",
"final",
"DataStyle",
"dataStyle",
":",
"this",
".",
"dataStylesContainer",
".",
"getValues",
"(",
... | Write the data styles in the automatic-styles. They belong to content.xml/automatic-styles
@param util an XML util
@param appendable the destination
@throws IOException if the styles can't be written | [
"Write",
"the",
"data",
"styles",
"in",
"the",
"automatic",
"-",
"styles",
".",
"They",
"belong",
"to",
"content",
".",
"xml",
"/",
"automatic",
"-",
"styles"
] | train | https://github.com/jferard/fastods/blob/a034d173083ffa602dc525699b97f753082eaef9/fastods/src/main/java/com/github/jferard/fastods/odselement/StylesContainer.java#L380-L386 |
tvesalainen/util | rpm/src/main/java/org/vesalainen/pm/rpm/RPMBuilder.java | RPMBuilder.addConflict | @Override
public RPMBuilder addConflict(String name, String version, Condition... dependency)
{
addString(RPMTAG_CONFLICTNAME, name);
addString(RPMTAG_CONFLICTVERSION, version);
addInt32(RPMTAG_CONFLICTFLAGS, Dependency.or(dependency));
ensureVersionReq(version);
return this;
} | java | @Override
public RPMBuilder addConflict(String name, String version, Condition... dependency)
{
addString(RPMTAG_CONFLICTNAME, name);
addString(RPMTAG_CONFLICTVERSION, version);
addInt32(RPMTAG_CONFLICTFLAGS, Dependency.or(dependency));
ensureVersionReq(version);
return this;
} | [
"@",
"Override",
"public",
"RPMBuilder",
"addConflict",
"(",
"String",
"name",
",",
"String",
"version",
",",
"Condition",
"...",
"dependency",
")",
"{",
"addString",
"(",
"RPMTAG_CONFLICTNAME",
",",
"name",
")",
";",
"addString",
"(",
"RPMTAG_CONFLICTVERSION",
... | Add RPMTAG_CONFLICTNAME, RPMTAG_CONFLICTVERSION and RPMTAG_CONFLICTFLAGS
@param name
@param version
@param dependency
@return | [
"Add",
"RPMTAG_CONFLICTNAME",
"RPMTAG_CONFLICTVERSION",
"and",
"RPMTAG_CONFLICTFLAGS"
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/rpm/src/main/java/org/vesalainen/pm/rpm/RPMBuilder.java#L295-L303 |
Azure/azure-sdk-for-java | logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/IntegrationAccountBatchConfigurationsInner.java | IntegrationAccountBatchConfigurationsInner.createOrUpdateAsync | public Observable<BatchConfigurationInner> createOrUpdateAsync(String resourceGroupName, String integrationAccountName, String batchConfigurationName, BatchConfigurationInner batchConfiguration) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, integrationAccountName, batchConfigurationName, batchConfiguration).map(new Func1<ServiceResponse<BatchConfigurationInner>, BatchConfigurationInner>() {
@Override
public BatchConfigurationInner call(ServiceResponse<BatchConfigurationInner> response) {
return response.body();
}
});
} | java | public Observable<BatchConfigurationInner> createOrUpdateAsync(String resourceGroupName, String integrationAccountName, String batchConfigurationName, BatchConfigurationInner batchConfiguration) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, integrationAccountName, batchConfigurationName, batchConfiguration).map(new Func1<ServiceResponse<BatchConfigurationInner>, BatchConfigurationInner>() {
@Override
public BatchConfigurationInner call(ServiceResponse<BatchConfigurationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"BatchConfigurationInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"integrationAccountName",
",",
"String",
"batchConfigurationName",
",",
"BatchConfigurationInner",
"batchConfiguration",
")",
"{",
"return",
... | Create or update a batch configuration for an integration account.
@param resourceGroupName The resource group name.
@param integrationAccountName The integration account name.
@param batchConfigurationName The batch configuration name.
@param batchConfiguration The batch configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the BatchConfigurationInner object | [
"Create",
"or",
"update",
"a",
"batch",
"configuration",
"for",
"an",
"integration",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/IntegrationAccountBatchConfigurationsInner.java#L302-L309 |
elastic/elasticsearch-hadoop | mr/src/main/java/org/elasticsearch/hadoop/rest/pooling/TransportPool.java | TransportPool.borrowTransport | synchronized Transport borrowTransport() {
long now = System.currentTimeMillis();
List<PooledTransport> garbageTransports = new ArrayList<PooledTransport>();
PooledTransport candidate = null;
// Grab a transport
for (Map.Entry<PooledTransport, Long> entry : idle.entrySet()) {
PooledTransport transport = entry.getKey();
if (validate(transport)) {
candidate = transport;
break;
} else {
garbageTransports.add(transport);
}
}
// Remove any dead connections found
for (PooledTransport transport : garbageTransports) {
idle.remove(transport);
release(transport);
}
// Create the connection if we didn't find any, remove it from the pool if we did.
if (candidate == null) {
candidate = create();
} else {
idle.remove(candidate);
}
// Lease.
leased.put(candidate, now);
return new LeasedTransport(candidate, this);
} | java | synchronized Transport borrowTransport() {
long now = System.currentTimeMillis();
List<PooledTransport> garbageTransports = new ArrayList<PooledTransport>();
PooledTransport candidate = null;
// Grab a transport
for (Map.Entry<PooledTransport, Long> entry : idle.entrySet()) {
PooledTransport transport = entry.getKey();
if (validate(transport)) {
candidate = transport;
break;
} else {
garbageTransports.add(transport);
}
}
// Remove any dead connections found
for (PooledTransport transport : garbageTransports) {
idle.remove(transport);
release(transport);
}
// Create the connection if we didn't find any, remove it from the pool if we did.
if (candidate == null) {
candidate = create();
} else {
idle.remove(candidate);
}
// Lease.
leased.put(candidate, now);
return new LeasedTransport(candidate, this);
} | [
"synchronized",
"Transport",
"borrowTransport",
"(",
")",
"{",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"List",
"<",
"PooledTransport",
">",
"garbageTransports",
"=",
"new",
"ArrayList",
"<",
"PooledTransport",
">",
"(",
")",
";",... | Borrows a Transport from this pool. If there are no pooled Transports available, a new one is created.
@return A Transport backed by a pooled resource | [
"Borrows",
"a",
"Transport",
"from",
"this",
"pool",
".",
"If",
"there",
"are",
"no",
"pooled",
"Transports",
"available",
"a",
"new",
"one",
"is",
"created",
"."
] | train | https://github.com/elastic/elasticsearch-hadoop/blob/f3acaba268ff96efae8eb946088c748c777c22cc/mr/src/main/java/org/elasticsearch/hadoop/rest/pooling/TransportPool.java#L122-L155 |
alkacon/opencms-core | src/org/opencms/cmis/CmsCmisUtil.java | CmsCmisUtil.addAction | public static void addAction(Set<Action> aas, Action action, boolean condition) {
if (condition) {
aas.add(action);
}
} | java | public static void addAction(Set<Action> aas, Action action, boolean condition) {
if (condition) {
aas.add(action);
}
} | [
"public",
"static",
"void",
"addAction",
"(",
"Set",
"<",
"Action",
">",
"aas",
",",
"Action",
"action",
",",
"boolean",
"condition",
")",
"{",
"if",
"(",
"condition",
")",
"{",
"aas",
".",
"add",
"(",
"action",
")",
";",
"}",
"}"
] | Adds an action to a set of actions if a condition is fulfilled.<p>
@param aas the set of actions
@param action the action to add
@param condition the value of the condition for adding the action | [
"Adds",
"an",
"action",
"to",
"a",
"set",
"of",
"actions",
"if",
"a",
"condition",
"is",
"fulfilled",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/cmis/CmsCmisUtil.java#L91-L96 |
wildfly/wildfly-core | cli/src/main/java/org/jboss/as/cli/handlers/DeploymentOverlayHandler.java | DeploymentOverlayHandler.getName | private String getName(CommandContext ctx, boolean failInBatch) throws CommandLineException {
final ParsedCommandLine args = ctx.getParsedCommandLine();
final String name = this.name.getValue(args, true);
if (name == null) {
throw new CommandFormatException(this.name + " is missing value.");
}
if (!ctx.isBatchMode() || failInBatch) {
if (!Util.isValidPath(ctx.getModelControllerClient(), Util.DEPLOYMENT_OVERLAY, name)) {
throw new CommandFormatException("Deployment overlay " + name + " does not exist.");
}
}
return name;
} | java | private String getName(CommandContext ctx, boolean failInBatch) throws CommandLineException {
final ParsedCommandLine args = ctx.getParsedCommandLine();
final String name = this.name.getValue(args, true);
if (name == null) {
throw new CommandFormatException(this.name + " is missing value.");
}
if (!ctx.isBatchMode() || failInBatch) {
if (!Util.isValidPath(ctx.getModelControllerClient(), Util.DEPLOYMENT_OVERLAY, name)) {
throw new CommandFormatException("Deployment overlay " + name + " does not exist.");
}
}
return name;
} | [
"private",
"String",
"getName",
"(",
"CommandContext",
"ctx",
",",
"boolean",
"failInBatch",
")",
"throws",
"CommandLineException",
"{",
"final",
"ParsedCommandLine",
"args",
"=",
"ctx",
".",
"getParsedCommandLine",
"(",
")",
";",
"final",
"String",
"name",
"=",
... | Validate that the overlay exists. If it doesn't exist, throws an
exception if not in batch mode or if failInBatch is true. In batch mode,
we could be in the case that the overlay doesn't exist yet. | [
"Validate",
"that",
"the",
"overlay",
"exists",
".",
"If",
"it",
"doesn",
"t",
"exist",
"throws",
"an",
"exception",
"if",
"not",
"in",
"batch",
"mode",
"or",
"if",
"failInBatch",
"is",
"true",
".",
"In",
"batch",
"mode",
"we",
"could",
"be",
"in",
"th... | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/handlers/DeploymentOverlayHandler.java#L545-L557 |
mike10004/common-helper | native-helper/src/main/java/com/github/mike10004/nativehelper/subprocess/StreamConduit.java | StreamConduit.createProcessErrorPump | private void createProcessErrorPump(InputStream is, OutputStream os) {
errorThread = createPump(is, os, CLOSE_STDOUT_AND_STDERR_INSTREAMS_WHEN_EXHAUSTED);
} | java | private void createProcessErrorPump(InputStream is, OutputStream os) {
errorThread = createPump(is, os, CLOSE_STDOUT_AND_STDERR_INSTREAMS_WHEN_EXHAUSTED);
} | [
"private",
"void",
"createProcessErrorPump",
"(",
"InputStream",
"is",
",",
"OutputStream",
"os",
")",
"{",
"errorThread",
"=",
"createPump",
"(",
"is",
",",
"os",
",",
"CLOSE_STDOUT_AND_STDERR_INSTREAMS_WHEN_EXHAUSTED",
")",
";",
"}"
] | Create the pump to handle error output.
@param is the input stream to copy from.
@param os the output stream to copy to. | [
"Create",
"the",
"pump",
"to",
"handle",
"error",
"output",
"."
] | train | https://github.com/mike10004/common-helper/blob/744f82d9b0768a9ad9c63a57a37ab2c93bf408f4/native-helper/src/main/java/com/github/mike10004/nativehelper/subprocess/StreamConduit.java#L199-L201 |
Azure/azure-sdk-for-java | storage/resource-manager/v2018_03_01_preview/src/main/java/com/microsoft/azure/management/storage/v2018_03_01_preview/implementation/StorageAccountsInner.java | StorageAccountsInner.getByResourceGroup | public StorageAccountInner getByResourceGroup(String resourceGroupName, String accountName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body();
} | java | public StorageAccountInner getByResourceGroup(String resourceGroupName, String accountName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body();
} | [
"public",
"StorageAccountInner",
"getByResourceGroup",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
")",
".",
"toBlocking",
"(",
")",
".",
... | Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys.
@param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive.
@param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
@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 StorageAccountInner object if successful. | [
"Returns",
"the",
"properties",
"for",
"the",
"specified",
"storage",
"account",
"including",
"but",
"not",
"limited",
"to",
"name",
"SKU",
"name",
"location",
"and",
"account",
"status",
".",
"The",
"ListKeys",
"operation",
"should",
"be",
"used",
"to",
"retr... | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/storage/resource-manager/v2018_03_01_preview/src/main/java/com/microsoft/azure/management/storage/v2018_03_01_preview/implementation/StorageAccountsInner.java#L484-L486 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/layers/embeddings/KerasEmbedding.java | KerasEmbedding.setWeights | @Override
public void setWeights(Map<String, INDArray> weights) throws InvalidKerasConfigurationException {
this.weights = new HashMap<>();
// TODO: "embeddings" is incorrectly read as "s" for some applications
if (weights.containsKey("s")) {
INDArray kernel = weights.get("s");
weights.remove("s");
weights.put(conf.getLAYER_FIELD_EMBEDDING_WEIGHTS(), kernel);
}
if (!weights.containsKey(conf.getLAYER_FIELD_EMBEDDING_WEIGHTS()))
throw new InvalidKerasConfigurationException(
"Parameter " + conf.getLAYER_FIELD_EMBEDDING_WEIGHTS() + " does not exist in weights");
INDArray kernel = weights.get(conf.getLAYER_FIELD_EMBEDDING_WEIGHTS());
if (this.zeroMasking) {
kernel.putRow(0, Nd4j.zeros(kernel.columns()));
}
this.weights.put(DefaultParamInitializer.WEIGHT_KEY, kernel);
if (weights.size() > 2) {
Set<String> paramNames = weights.keySet();
paramNames.remove(conf.getLAYER_FIELD_EMBEDDING_WEIGHTS());
String unknownParamNames = paramNames.toString();
log.warn("Attemping to set weights for unknown parameters: "
+ unknownParamNames.substring(1, unknownParamNames.length() - 1));
}
} | java | @Override
public void setWeights(Map<String, INDArray> weights) throws InvalidKerasConfigurationException {
this.weights = new HashMap<>();
// TODO: "embeddings" is incorrectly read as "s" for some applications
if (weights.containsKey("s")) {
INDArray kernel = weights.get("s");
weights.remove("s");
weights.put(conf.getLAYER_FIELD_EMBEDDING_WEIGHTS(), kernel);
}
if (!weights.containsKey(conf.getLAYER_FIELD_EMBEDDING_WEIGHTS()))
throw new InvalidKerasConfigurationException(
"Parameter " + conf.getLAYER_FIELD_EMBEDDING_WEIGHTS() + " does not exist in weights");
INDArray kernel = weights.get(conf.getLAYER_FIELD_EMBEDDING_WEIGHTS());
if (this.zeroMasking) {
kernel.putRow(0, Nd4j.zeros(kernel.columns()));
}
this.weights.put(DefaultParamInitializer.WEIGHT_KEY, kernel);
if (weights.size() > 2) {
Set<String> paramNames = weights.keySet();
paramNames.remove(conf.getLAYER_FIELD_EMBEDDING_WEIGHTS());
String unknownParamNames = paramNames.toString();
log.warn("Attemping to set weights for unknown parameters: "
+ unknownParamNames.substring(1, unknownParamNames.length() - 1));
}
} | [
"@",
"Override",
"public",
"void",
"setWeights",
"(",
"Map",
"<",
"String",
",",
"INDArray",
">",
"weights",
")",
"throws",
"InvalidKerasConfigurationException",
"{",
"this",
".",
"weights",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"// TODO: \"embeddings\" is... | Set weights for layer.
@param weights Embedding layer weights | [
"Set",
"weights",
"for",
"layer",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/layers/embeddings/KerasEmbedding.java#L175-L201 |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/social/SocialTemplate.java | SocialTemplate.parseProfile | protected SocialProfile parseProfile(Map<String, Object> props) {
if (!props.containsKey("id")) {
throw new IllegalArgumentException("No id in profile");
}
SocialProfile profile = SocialProfile.with(props)
.displayName("name")
.first("first_name")
.last("last_name")
.id("id")
.username("username")
.profileUrl("link")
.build();
profile.setThumbnailUrl(getBaseUrl() + "/" + profile.getId() + "/picture");
return profile;
} | java | protected SocialProfile parseProfile(Map<String, Object> props) {
if (!props.containsKey("id")) {
throw new IllegalArgumentException("No id in profile");
}
SocialProfile profile = SocialProfile.with(props)
.displayName("name")
.first("first_name")
.last("last_name")
.id("id")
.username("username")
.profileUrl("link")
.build();
profile.setThumbnailUrl(getBaseUrl() + "/" + profile.getId() + "/picture");
return profile;
} | [
"protected",
"SocialProfile",
"parseProfile",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
")",
"{",
"if",
"(",
"!",
"props",
".",
"containsKey",
"(",
"\"id\"",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No id in profile\"",
... | Property names for Facebook - Override to customize
@param props
@return | [
"Property",
"names",
"for",
"Facebook",
"-",
"Override",
"to",
"customize"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/social/SocialTemplate.java#L94-L108 |
algermissen/hawkj | src/main/java/net/jalg/hawkj/util/StringUtils.java | StringUtils.newString | private static String newString(byte[] bytes, Charset charset) {
return bytes == null ? null : new String(bytes, charset);
} | java | private static String newString(byte[] bytes, Charset charset) {
return bytes == null ? null : new String(bytes, charset);
} | [
"private",
"static",
"String",
"newString",
"(",
"byte",
"[",
"]",
"bytes",
",",
"Charset",
"charset",
")",
"{",
"return",
"bytes",
"==",
"null",
"?",
"null",
":",
"new",
"String",
"(",
"bytes",
",",
"charset",
")",
";",
"}"
] | Constructs a new <code>String</code> by decoding the specified array of bytes using the given charset.
@param bytes
The bytes to be decoded into characters
@param charset
The {@link Charset} to encode the {@code String}
@return A new <code>String</code> decoded from the specified array of bytes using the given charset,
or {@code null} if the input byte array was {@code null}.
@throws NullPointerException
Thrown if {@link Charsets#UTF_8} is not initialized, which should never happen since it is
required by the Java platform specification. | [
"Constructs",
"a",
"new",
"<code",
">",
"String<",
"/",
"code",
">",
"by",
"decoding",
"the",
"specified",
"array",
"of",
"bytes",
"using",
"the",
"given",
"charset",
"."
] | train | https://github.com/algermissen/hawkj/blob/f798a20f058474bcfe761f7c5c02afee17326c71/src/main/java/net/jalg/hawkj/util/StringUtils.java#L121-L123 |
Javacord/Javacord | javacord-api/src/main/java/org/javacord/api/entity/server/ServerUpdater.java | ServerUpdater.addRoleToUser | public ServerUpdater addRoleToUser(User user, Role role) {
delegate.addRoleToUser(user, role);
return this;
} | java | public ServerUpdater addRoleToUser(User user, Role role) {
delegate.addRoleToUser(user, role);
return this;
} | [
"public",
"ServerUpdater",
"addRoleToUser",
"(",
"User",
"user",
",",
"Role",
"role",
")",
"{",
"delegate",
".",
"addRoleToUser",
"(",
"user",
",",
"role",
")",
";",
"return",
"this",
";",
"}"
] | Queues a role to be assigned to the user.
@param user The server member the role should be added to.
@param role The role which should be added to the server member.
@return The current instance in order to chain call methods. | [
"Queues",
"a",
"role",
"to",
"be",
"assigned",
"to",
"the",
"user",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-api/src/main/java/org/javacord/api/entity/server/ServerUpdater.java#L467-L470 |
alipay/sofa-rpc | core/common/src/main/java/com/alipay/sofa/rpc/common/utils/CommonUtils.java | CommonUtils.putToConcurrentMap | public static <K, V> V putToConcurrentMap(ConcurrentMap<K, V> map, K key, V value) {
V old = map.putIfAbsent(key, value);
return old != null ? old : value;
} | java | public static <K, V> V putToConcurrentMap(ConcurrentMap<K, V> map, K key, V value) {
V old = map.putIfAbsent(key, value);
return old != null ? old : value;
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"V",
"putToConcurrentMap",
"(",
"ConcurrentMap",
"<",
"K",
",",
"V",
">",
"map",
",",
"K",
"key",
",",
"V",
"value",
")",
"{",
"V",
"old",
"=",
"map",
".",
"putIfAbsent",
"(",
"key",
",",
"value",
")",... | 将值放入ConcurrentMap,已经考虑第一次并发问题
@param map ConcurrentMap
@param key 关键字
@param value 值
@param <K> 关键字类型
@param <V> 值类型
@return 旧值 | [
"将值放入ConcurrentMap,已经考虑第一次并发问题"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core/common/src/main/java/com/alipay/sofa/rpc/common/utils/CommonUtils.java#L42-L45 |
nmorel/gwt-jackson | gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractCreator.java | AbstractCreator.getKeySerializerFromType | protected final JSerializerType getKeySerializerFromType( JType type ) throws UnsupportedTypeException, UnableToCompleteException {
return getKeySerializerFromType( type, false, false );
} | java | protected final JSerializerType getKeySerializerFromType( JType type ) throws UnsupportedTypeException, UnableToCompleteException {
return getKeySerializerFromType( type, false, false );
} | [
"protected",
"final",
"JSerializerType",
"getKeySerializerFromType",
"(",
"JType",
"type",
")",
"throws",
"UnsupportedTypeException",
",",
"UnableToCompleteException",
"{",
"return",
"getKeySerializerFromType",
"(",
"type",
",",
"false",
",",
"false",
")",
";",
"}"
] | Build the {@link JSerializerType} that instantiate a {@link KeySerializer} for the given type.
@param type type
@return the {@link JSerializerType}.
@throws com.github.nmorel.gwtjackson.rebind.exception.UnsupportedTypeException if any. | [
"Build",
"the",
"{",
"@link",
"JSerializerType",
"}",
"that",
"instantiate",
"a",
"{",
"@link",
"KeySerializer",
"}",
"for",
"the",
"given",
"type",
"."
] | train | https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractCreator.java#L388-L390 |
netty/netty | buffer/src/main/java/io/netty/buffer/Unpooled.java | Unpooled.wrappedBuffer | public static ByteBuf wrappedBuffer(byte[] array, int offset, int length) {
if (length == 0) {
return EMPTY_BUFFER;
}
if (offset == 0 && length == array.length) {
return wrappedBuffer(array);
}
return wrappedBuffer(array).slice(offset, length);
} | java | public static ByteBuf wrappedBuffer(byte[] array, int offset, int length) {
if (length == 0) {
return EMPTY_BUFFER;
}
if (offset == 0 && length == array.length) {
return wrappedBuffer(array);
}
return wrappedBuffer(array).slice(offset, length);
} | [
"public",
"static",
"ByteBuf",
"wrappedBuffer",
"(",
"byte",
"[",
"]",
"array",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"if",
"(",
"length",
"==",
"0",
")",
"{",
"return",
"EMPTY_BUFFER",
";",
"}",
"if",
"(",
"offset",
"==",
"0",
"&&",
... | Creates a new big-endian buffer which wraps the sub-region of the
specified {@code array}. A modification on the specified array's
content will be visible to the returned buffer. | [
"Creates",
"a",
"new",
"big",
"-",
"endian",
"buffer",
"which",
"wraps",
"the",
"sub",
"-",
"region",
"of",
"the",
"specified",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/Unpooled.java#L165-L175 |
zeroturnaround/zt-exec | src/main/java/org/zeroturnaround/exec/close/ExceptionUtil.java | ExceptionUtil.addSuppressed | public static void addSuppressed(Throwable t, Throwable suppressed) {
if (METHOD_ADD_SUPPRESSED != null) {
try {
METHOD_ADD_SUPPRESSED.invoke(t, suppressed);
}
catch (Exception e) {
throw new IllegalStateException("Could not add suppressed exception:", e);
}
}
} | java | public static void addSuppressed(Throwable t, Throwable suppressed) {
if (METHOD_ADD_SUPPRESSED != null) {
try {
METHOD_ADD_SUPPRESSED.invoke(t, suppressed);
}
catch (Exception e) {
throw new IllegalStateException("Could not add suppressed exception:", e);
}
}
} | [
"public",
"static",
"void",
"addSuppressed",
"(",
"Throwable",
"t",
",",
"Throwable",
"suppressed",
")",
"{",
"if",
"(",
"METHOD_ADD_SUPPRESSED",
"!=",
"null",
")",
"{",
"try",
"{",
"METHOD_ADD_SUPPRESSED",
".",
"invoke",
"(",
"t",
",",
"suppressed",
")",
";... | If supported. appends the specified exception to the exceptions that were suppressed in order to deliver this exception. | [
"If",
"supported",
".",
"appends",
"the",
"specified",
"exception",
"to",
"the",
"exceptions",
"that",
"were",
"suppressed",
"in",
"order",
"to",
"deliver",
"this",
"exception",
"."
] | train | https://github.com/zeroturnaround/zt-exec/blob/6c3b93b99bf3c69c9f41d6350bf7707005b6a4cd/src/main/java/org/zeroturnaround/exec/close/ExceptionUtil.java#L25-L34 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-container/src/main/java/com/google/cloud/container/v1/ClusterManagerClient.java | ClusterManagerClient.cancelOperation | public final void cancelOperation(String projectId, String zone, String operationId) {
CancelOperationRequest request =
CancelOperationRequest.newBuilder()
.setProjectId(projectId)
.setZone(zone)
.setOperationId(operationId)
.build();
cancelOperation(request);
} | java | public final void cancelOperation(String projectId, String zone, String operationId) {
CancelOperationRequest request =
CancelOperationRequest.newBuilder()
.setProjectId(projectId)
.setZone(zone)
.setOperationId(operationId)
.build();
cancelOperation(request);
} | [
"public",
"final",
"void",
"cancelOperation",
"(",
"String",
"projectId",
",",
"String",
"zone",
",",
"String",
"operationId",
")",
"{",
"CancelOperationRequest",
"request",
"=",
"CancelOperationRequest",
".",
"newBuilder",
"(",
")",
".",
"setProjectId",
"(",
"pro... | Cancels the specified operation.
<p>Sample code:
<pre><code>
try (ClusterManagerClient clusterManagerClient = ClusterManagerClient.create()) {
String projectId = "";
String zone = "";
String operationId = "";
clusterManagerClient.cancelOperation(projectId, zone, operationId);
}
</code></pre>
@param projectId Deprecated. The Google Developers Console [project ID or project
number](https://support.google.com/cloud/answer/6158840). This field has been deprecated
and replaced by the name field.
@param zone Deprecated. The name of the Google Compute Engine
[zone](/compute/docs/zones#available) in which the operation resides. This field has been
deprecated and replaced by the name field.
@param operationId Deprecated. The server-assigned `name` of the operation. This field has been
deprecated and replaced by the name field.
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Cancels",
"the",
"specified",
"operation",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-container/src/main/java/com/google/cloud/container/v1/ClusterManagerClient.java#L1567-L1576 |
cryptomator/cryptofs | src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java | CryptoFileSystemProvider.newFileSystem | public static CryptoFileSystem newFileSystem(Path pathToVault, CryptoFileSystemProperties properties) throws FileSystemNeedsMigrationException, IOException {
URI uri = CryptoFileSystemUri.create(pathToVault.toAbsolutePath());
return (CryptoFileSystem) FileSystems.newFileSystem(uri, properties);
} | java | public static CryptoFileSystem newFileSystem(Path pathToVault, CryptoFileSystemProperties properties) throws FileSystemNeedsMigrationException, IOException {
URI uri = CryptoFileSystemUri.create(pathToVault.toAbsolutePath());
return (CryptoFileSystem) FileSystems.newFileSystem(uri, properties);
} | [
"public",
"static",
"CryptoFileSystem",
"newFileSystem",
"(",
"Path",
"pathToVault",
",",
"CryptoFileSystemProperties",
"properties",
")",
"throws",
"FileSystemNeedsMigrationException",
",",
"IOException",
"{",
"URI",
"uri",
"=",
"CryptoFileSystemUri",
".",
"create",
"(",... | Typesafe alternative to {@link FileSystems#newFileSystem(URI, Map)}. Default way to retrieve a CryptoFS instance.
@param pathToVault Path to this vault's storage location
@param properties Parameters used during initialization of the file system
@return a new file system
@throws FileSystemNeedsMigrationException if the vault format needs to get updated and <code>properties</code> did not contain a flag for implicit migration.
@throws IOException if an I/O error occurs creating the file system | [
"Typesafe",
"alternative",
"to",
"{",
"@link",
"FileSystems#newFileSystem",
"(",
"URI",
"Map",
")",
"}",
".",
"Default",
"way",
"to",
"retrieve",
"a",
"CryptoFS",
"instance",
"."
] | train | https://github.com/cryptomator/cryptofs/blob/67fc1a4950dd1c150cd2e2c75bcabbeb7c9ac82e/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java#L126-L129 |
JM-Lab/utils-java8 | src/main/java/kr/jm/utils/collections/JMNestedMap.java | JMNestedMap.getOrPutGetNew | public V getOrPutGetNew(K1 key1, K2 key2, Supplier<V> newValueSupplier) {
return JMMap
.getOrPutGetNew(getOrPutGetNew(key1), key2, newValueSupplier);
} | java | public V getOrPutGetNew(K1 key1, K2 key2, Supplier<V> newValueSupplier) {
return JMMap
.getOrPutGetNew(getOrPutGetNew(key1), key2, newValueSupplier);
} | [
"public",
"V",
"getOrPutGetNew",
"(",
"K1",
"key1",
",",
"K2",
"key2",
",",
"Supplier",
"<",
"V",
">",
"newValueSupplier",
")",
"{",
"return",
"JMMap",
".",
"getOrPutGetNew",
"(",
"getOrPutGetNew",
"(",
"key1",
")",
",",
"key2",
",",
"newValueSupplier",
")... | Gets or put get new.
@param key1 the key 1
@param key2 the key 2
@param newValueSupplier the new value supplier
@return the or put get new | [
"Gets",
"or",
"put",
"get",
"new",
"."
] | train | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/JMNestedMap.java#L174-L177 |
OpenLiberty/open-liberty | dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/FileSharedServerLeaseLog.java | FileSharedServerLeaseLog.getFileSharedServerLeaseLog | public static FileSharedServerLeaseLog getFileSharedServerLeaseLog(String logDirStem, String localRecoveryIdentity, String recoveryGroup) {
if (tc.isEntryEnabled())
Tr.entry(tc, "FileSharedServerLeaseLog", new Object[] { logDirStem, localRecoveryIdentity, recoveryGroup });
if (_serverInstallLeaseLogDir == null)
setLeaseLog(logDirStem, localRecoveryIdentity, recoveryGroup);
if (tc.isEntryEnabled())
Tr.exit(tc, "FileSharedServerLeaseLog", _fileLeaseLog);
return _fileLeaseLog;
} | java | public static FileSharedServerLeaseLog getFileSharedServerLeaseLog(String logDirStem, String localRecoveryIdentity, String recoveryGroup) {
if (tc.isEntryEnabled())
Tr.entry(tc, "FileSharedServerLeaseLog", new Object[] { logDirStem, localRecoveryIdentity, recoveryGroup });
if (_serverInstallLeaseLogDir == null)
setLeaseLog(logDirStem, localRecoveryIdentity, recoveryGroup);
if (tc.isEntryEnabled())
Tr.exit(tc, "FileSharedServerLeaseLog", _fileLeaseLog);
return _fileLeaseLog;
} | [
"public",
"static",
"FileSharedServerLeaseLog",
"getFileSharedServerLeaseLog",
"(",
"String",
"logDirStem",
",",
"String",
"localRecoveryIdentity",
",",
"String",
"recoveryGroup",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
... | Access the singleton instance of the FileSystem Lease log.
@return ChannelFrameworkImpl | [
"Access",
"the",
"singleton",
"instance",
"of",
"the",
"FileSystem",
"Lease",
"log",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/FileSharedServerLeaseLog.java#L106-L116 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java | TwitterEndpointServices.createAuthzHeaderForAuthorizedEndpoint | public String createAuthzHeaderForAuthorizedEndpoint(String endpointUrl, String token) {
Map<String, String> parameters = populateAuthorizedEndpointAuthzHeaderParams(token);
return signAndCreateAuthzHeader(endpointUrl, parameters);
} | java | public String createAuthzHeaderForAuthorizedEndpoint(String endpointUrl, String token) {
Map<String, String> parameters = populateAuthorizedEndpointAuthzHeaderParams(token);
return signAndCreateAuthzHeader(endpointUrl, parameters);
} | [
"public",
"String",
"createAuthzHeaderForAuthorizedEndpoint",
"(",
"String",
"endpointUrl",
",",
"String",
"token",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
"=",
"populateAuthorizedEndpointAuthzHeaderParams",
"(",
"token",
")",
";",
"return",
... | Generates the Authorization header value required for an authorized endpoint request. Assumes that {@code tokenSecret} has
already been set to the appropriate value based on the provided token. See
{@link https://dev.twitter.com/oauth/reference/post/oauth/access_token} for details.
@param endpointUrl
@param token
For {@value TwitterConstants#TWITTER_ENDPOINT_ACCESS_TOKEN} requests, this is the request token obtained in an
earlier call. For other authorized requests, this is a valid access token.
@return | [
"Generates",
"the",
"Authorization",
"header",
"value",
"required",
"for",
"an",
"authorized",
"endpoint",
"request",
".",
"Assumes",
"that",
"{",
"@code",
"tokenSecret",
"}",
"has",
"already",
"been",
"set",
"to",
"the",
"appropriate",
"value",
"based",
"on",
... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java#L441-L444 |
scireum/server-sass | src/main/java/org/serversass/Functions.java | Functions.mix | public static Expression mix(Generator generator, FunctionCall input) {
Color color1 = input.getExpectedColorParam(0);
Color color2 = input.getExpectedColorParam(1);
float weight = input.getParameters().size() > 2 ? input.getExpectedFloatParam(2) : 0.5f;
return new Color((int) Math.round(color1.getR() * weight + color2.getR() * (1.0 - weight)),
(int) Math.round(color1.getG() * weight + color2.getG() * (1.0 - weight)),
(int) Math.round(color1.getB() * weight + color2.getB() * (1.0 - weight)),
(float) (color1.getA() * weight + color2.getA() * (1.0 - weight)));
} | java | public static Expression mix(Generator generator, FunctionCall input) {
Color color1 = input.getExpectedColorParam(0);
Color color2 = input.getExpectedColorParam(1);
float weight = input.getParameters().size() > 2 ? input.getExpectedFloatParam(2) : 0.5f;
return new Color((int) Math.round(color1.getR() * weight + color2.getR() * (1.0 - weight)),
(int) Math.round(color1.getG() * weight + color2.getG() * (1.0 - weight)),
(int) Math.round(color1.getB() * weight + color2.getB() * (1.0 - weight)),
(float) (color1.getA() * weight + color2.getA() * (1.0 - weight)));
} | [
"public",
"static",
"Expression",
"mix",
"(",
"Generator",
"generator",
",",
"FunctionCall",
"input",
")",
"{",
"Color",
"color1",
"=",
"input",
".",
"getExpectedColorParam",
"(",
"0",
")",
";",
"Color",
"color2",
"=",
"input",
".",
"getExpectedColorParam",
"(... | Calculates the weighted arithmetic mean of two colors.
@param generator the surrounding generator
@param input the function call to evaluate
@return the result of the evaluation | [
"Calculates",
"the",
"weighted",
"arithmetic",
"mean",
"of",
"two",
"colors",
"."
] | train | https://github.com/scireum/server-sass/blob/e74af983567f10c43420d70cd31165dd080ba8fc/src/main/java/org/serversass/Functions.java#L219-L227 |
google/closure-compiler | src/com/google/javascript/jscomp/ExpressionDecomposer.java | ExpressionDecomposer.isSafeAssign | private boolean isSafeAssign(Node n, boolean seenSideEffects) {
if (n.isAssign()) {
Node lhs = n.getFirstChild();
switch (lhs.getToken()) {
case NAME:
return true;
case GETPROP:
return !isExpressionTreeUnsafe(lhs.getFirstChild(), seenSideEffects);
case GETELEM:
return !isExpressionTreeUnsafe(lhs.getFirstChild(), seenSideEffects)
&& !isExpressionTreeUnsafe(lhs.getLastChild(), seenSideEffects);
default:
break;
}
}
return false;
} | java | private boolean isSafeAssign(Node n, boolean seenSideEffects) {
if (n.isAssign()) {
Node lhs = n.getFirstChild();
switch (lhs.getToken()) {
case NAME:
return true;
case GETPROP:
return !isExpressionTreeUnsafe(lhs.getFirstChild(), seenSideEffects);
case GETELEM:
return !isExpressionTreeUnsafe(lhs.getFirstChild(), seenSideEffects)
&& !isExpressionTreeUnsafe(lhs.getLastChild(), seenSideEffects);
default:
break;
}
}
return false;
} | [
"private",
"boolean",
"isSafeAssign",
"(",
"Node",
"n",
",",
"boolean",
"seenSideEffects",
")",
"{",
"if",
"(",
"n",
".",
"isAssign",
"(",
")",
")",
"{",
"Node",
"lhs",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"switch",
"(",
"lhs",
".",
"getTok... | It is always safe to inline "foo()" for expressions such as "a = b = c = foo();" As the
assignment is unaffected by side effect of "foo()" and the names assigned-to can not influence
the state before the call to foo.
<p>It is also safe in cases where the object is constant:
<pre>
CONST_NAME.a = foo()
CONST_NAME[CONST_VALUE] = foo();
</pre>
<p>This is not true of more complex LHS values, such as
<pre>
a.x = foo();
next().x = foo();
</pre>
in these cases the checks below are necessary.
@param seenSideEffects If true, check to see if node-tree maybe affected by side-effects,
otherwise if the tree has side-effects. @see isExpressionTreeUnsafe
@return Whether the assignment is safe from side-effects. | [
"It",
"is",
"always",
"safe",
"to",
"inline",
"foo",
"()",
"for",
"expressions",
"such",
"as",
"a",
"=",
"b",
"=",
"c",
"=",
"foo",
"()",
";",
"As",
"the",
"assignment",
"is",
"unaffected",
"by",
"side",
"effect",
"of",
"foo",
"()",
"and",
"the",
"... | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ExpressionDecomposer.java#L1021-L1037 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/BaseField.java | BaseField.setState | public int setState(boolean state, boolean bDisplayOption, int iMoveMode)
{
String tempString = "N";
if (state)
tempString = "Y";
return this.setString(tempString, bDisplayOption, iMoveMode); // Move value to this field
} | java | public int setState(boolean state, boolean bDisplayOption, int iMoveMode)
{
String tempString = "N";
if (state)
tempString = "Y";
return this.setString(tempString, bDisplayOption, iMoveMode); // Move value to this field
} | [
"public",
"int",
"setState",
"(",
"boolean",
"state",
",",
"boolean",
"bDisplayOption",
",",
"int",
"iMoveMode",
")",
"{",
"String",
"tempString",
"=",
"\"N\"",
";",
"if",
"(",
"state",
")",
"tempString",
"=",
"\"Y\"",
";",
"return",
"this",
".",
"setStrin... | For binary fields, set the current state.
@param state The state to set this field.
@param bDisplayOption Display changed fields if true.
@param iMoveMode The move mode.
@return The error code (or NORMAL_RETURN). | [
"For",
"binary",
"fields",
"set",
"the",
"current",
"state",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/BaseField.java#L878-L884 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java | ByteArrayUtil.readInt | public static int readInt(byte[] array, int offset) {
// First make integers to resolve signed vs. unsigned issues.
int b0 = array[offset + 0] & 0xFF;
int b1 = array[offset + 1] & 0xFF;
int b2 = array[offset + 2] & 0xFF;
int b3 = array[offset + 3] & 0xFF;
return ((b0 << 24) + (b1 << 16) + (b2 << 8) + (b3 << 0));
} | java | public static int readInt(byte[] array, int offset) {
// First make integers to resolve signed vs. unsigned issues.
int b0 = array[offset + 0] & 0xFF;
int b1 = array[offset + 1] & 0xFF;
int b2 = array[offset + 2] & 0xFF;
int b3 = array[offset + 3] & 0xFF;
return ((b0 << 24) + (b1 << 16) + (b2 << 8) + (b3 << 0));
} | [
"public",
"static",
"int",
"readInt",
"(",
"byte",
"[",
"]",
"array",
",",
"int",
"offset",
")",
"{",
"// First make integers to resolve signed vs. unsigned issues.",
"int",
"b0",
"=",
"array",
"[",
"offset",
"+",
"0",
"]",
"&",
"0xFF",
";",
"int",
"b1",
"="... | Read an integer from the byte array at the given offset.
@param array Array to read from
@param offset Offset to read at
@return data | [
"Read",
"an",
"integer",
"from",
"the",
"byte",
"array",
"at",
"the",
"given",
"offset",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L207-L214 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/RepositoryApi.java | RepositoryApi.createBranch | public Branch createBranch(Object projectIdOrPath, String branchName, String ref) throws GitLabApiException {
Form formData = new GitLabApiForm()
.withParam(isApiVersion(ApiVersion.V3) ? "branch_name" : "branch", branchName, true)
.withParam("ref", ref, true);
Response response = post(Response.Status.CREATED, formData.asMap(), "projects",
getProjectIdOrPath(projectIdOrPath), "repository", "branches");
return (response.readEntity(Branch.class));
} | java | public Branch createBranch(Object projectIdOrPath, String branchName, String ref) throws GitLabApiException {
Form formData = new GitLabApiForm()
.withParam(isApiVersion(ApiVersion.V3) ? "branch_name" : "branch", branchName, true)
.withParam("ref", ref, true);
Response response = post(Response.Status.CREATED, formData.asMap(), "projects",
getProjectIdOrPath(projectIdOrPath), "repository", "branches");
return (response.readEntity(Branch.class));
} | [
"public",
"Branch",
"createBranch",
"(",
"Object",
"projectIdOrPath",
",",
"String",
"branchName",
",",
"String",
"ref",
")",
"throws",
"GitLabApiException",
"{",
"Form",
"formData",
"=",
"new",
"GitLabApiForm",
"(",
")",
".",
"withParam",
"(",
"isApiVersion",
"... | Creates a branch for the project. Support as of version 6.8.x
<pre><code>GitLab Endpoint: POST /projects/:id/repository/branches</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param branchName the name of the branch to create
@param ref Source to create the branch from, can be an existing branch, tag or commit SHA
@return the branch info for the created branch
@throws GitLabApiException if any exception occurs | [
"Creates",
"a",
"branch",
"for",
"the",
"project",
".",
"Support",
"as",
"of",
"version",
"6",
".",
"8",
".",
"x"
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/RepositoryApi.java#L139-L147 |
dejv78/javafx-commons | jfx-controls/src/main/java/dejv/jfx/controls/radialmenu1/RadialMenuParams.java | RadialMenuParams.setAngles | public RadialMenuParams setAngles(double angleFromDeg, double angleToDeg) {
if (angleFromDeg > angleToDeg) {
final double tmpDeg = angleFromDeg;
angleFromDeg = angleToDeg;
angleToDeg = tmpDeg;
setDirection(Direction.CCW);
}
this.angleFromDeg.set(angleFromDeg);
this.angleToDeg.set(angleToDeg);
return this;
} | java | public RadialMenuParams setAngles(double angleFromDeg, double angleToDeg) {
if (angleFromDeg > angleToDeg) {
final double tmpDeg = angleFromDeg;
angleFromDeg = angleToDeg;
angleToDeg = tmpDeg;
setDirection(Direction.CCW);
}
this.angleFromDeg.set(angleFromDeg);
this.angleToDeg.set(angleToDeg);
return this;
} | [
"public",
"RadialMenuParams",
"setAngles",
"(",
"double",
"angleFromDeg",
",",
"double",
"angleToDeg",
")",
"{",
"if",
"(",
"angleFromDeg",
">",
"angleToDeg",
")",
"{",
"final",
"double",
"tmpDeg",
"=",
"angleFromDeg",
";",
"angleFromDeg",
"=",
"angleToDeg",
";"... | Sets limit angles of the menu arc (in degrees).
<p>
There are two limit angles - "from" (arc start), and "to" (arc end).
<p>
If the "to" angle is greater than "from" angle, arc direction (order of menu items) is clockwise.
If the "to" angle is less than "from" angle, arc direction (order of menu items) is counterclockwise.
If the limited arc size is too small to accomodate all menu items, its radius will increase.
@param angleFromDeg "From" angle in degrees - start angle of the menu arc
@param angleToDeg "To" angle in degrees - end angle of the menu arc
@return The current RadialMenuParams instance for fluent setup | [
"Sets",
"limit",
"angles",
"of",
"the",
"menu",
"arc",
"(",
"in",
"degrees",
")",
".",
"<p",
">",
"There",
"are",
"two",
"limit",
"angles",
"-",
"from",
"(",
"arc",
"start",
")",
"and",
"to",
"(",
"arc",
"end",
")",
".",
"<p",
">",
"If",
"the",
... | train | https://github.com/dejv78/javafx-commons/blob/ea846eeeb4ed43a7628a40931a3e6f27d513592f/jfx-controls/src/main/java/dejv/jfx/controls/radialmenu1/RadialMenuParams.java#L73-L85 |
ujmp/universal-java-matrix-package | ujmp-core/src/main/java/org/ujmp/core/doublematrix/calculation/general/decomposition/Ginv.java | Ginv.addRowTimes | public static void addRowTimes(Matrix matrix, long diag, long fromCol, long row, double factor) {
long cols = matrix.getColumnCount();
for (long col = fromCol; col < cols; col++) {
matrix.setAsDouble(
matrix.getAsDouble(row, col) - factor * matrix.getAsDouble(diag, col), row, col);
}
} | java | public static void addRowTimes(Matrix matrix, long diag, long fromCol, long row, double factor) {
long cols = matrix.getColumnCount();
for (long col = fromCol; col < cols; col++) {
matrix.setAsDouble(
matrix.getAsDouble(row, col) - factor * matrix.getAsDouble(diag, col), row, col);
}
} | [
"public",
"static",
"void",
"addRowTimes",
"(",
"Matrix",
"matrix",
",",
"long",
"diag",
",",
"long",
"fromCol",
",",
"long",
"row",
",",
"double",
"factor",
")",
"{",
"long",
"cols",
"=",
"matrix",
".",
"getColumnCount",
"(",
")",
";",
"for",
"(",
"lo... | Add a factor times one row to another row
@param matrix
the matrix to modify
@param diag
coordinate on the diagonal
@param fromCol
first column to process
@param row
row to process
@param factor
factor to multiply | [
"Add",
"a",
"factor",
"times",
"one",
"row",
"to",
"another",
"row"
] | train | https://github.com/ujmp/universal-java-matrix-package/blob/b7e1d293adeadaf35d208ffe8884028d6c06b63b/ujmp-core/src/main/java/org/ujmp/core/doublematrix/calculation/general/decomposition/Ginv.java#L654-L660 |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/sql/Condition.java | Condition.buildValuePartForIN | private void buildValuePartForIN(StringBuilder conditionStrBuilder, List<Object> paramValues) {
conditionStrBuilder.append(" (");
final Object value = this.value;
if (isPlaceHolder()) {
List<?> valuesForIn;
// 占位符对应值列表
if (value instanceof CharSequence) {
valuesForIn = StrUtil.split((CharSequence) value, ',');
} else {
valuesForIn = Arrays.asList(Convert.convert(String[].class, value));
if (null == valuesForIn) {
valuesForIn = CollUtil.newArrayList(Convert.toStr(value));
}
}
conditionStrBuilder.append(StrUtil.repeatAndJoin("?", valuesForIn.size(), ","));
if(null != paramValues) {
paramValues.addAll(valuesForIn);
}
} else {
conditionStrBuilder.append(StrUtil.join(",", value));
}
conditionStrBuilder.append(')');
} | java | private void buildValuePartForIN(StringBuilder conditionStrBuilder, List<Object> paramValues) {
conditionStrBuilder.append(" (");
final Object value = this.value;
if (isPlaceHolder()) {
List<?> valuesForIn;
// 占位符对应值列表
if (value instanceof CharSequence) {
valuesForIn = StrUtil.split((CharSequence) value, ',');
} else {
valuesForIn = Arrays.asList(Convert.convert(String[].class, value));
if (null == valuesForIn) {
valuesForIn = CollUtil.newArrayList(Convert.toStr(value));
}
}
conditionStrBuilder.append(StrUtil.repeatAndJoin("?", valuesForIn.size(), ","));
if(null != paramValues) {
paramValues.addAll(valuesForIn);
}
} else {
conditionStrBuilder.append(StrUtil.join(",", value));
}
conditionStrBuilder.append(')');
} | [
"private",
"void",
"buildValuePartForIN",
"(",
"StringBuilder",
"conditionStrBuilder",
",",
"List",
"<",
"Object",
">",
"paramValues",
")",
"{",
"conditionStrBuilder",
".",
"append",
"(",
"\" (\"",
")",
";",
"final",
"Object",
"value",
"=",
"this",
".",
"value",... | 构建IN语句中的值部分<br>
开头必须加空格,类似:" (?,?,?)" 或者 " (1,2,3,4)"
@param conditionStrBuilder 条件语句构建器
@param paramValues 参数集合,用于参数占位符对应参数回填 | [
"构建IN语句中的值部分<br",
">",
"开头必须加空格,类似:",
"(",
"?",
"?",
"?",
")",
"或者",
"(",
"1",
"2",
"3",
"4",
")"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/sql/Condition.java#L354-L376 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java | ElementsExceptionsFactory.newNoAvailablePortException | public static NoAvailablePortException newNoAvailablePortException(String message, Object... args) {
return newNoAvailablePortException(null, message, args);
} | java | public static NoAvailablePortException newNoAvailablePortException(String message, Object... args) {
return newNoAvailablePortException(null, message, args);
} | [
"public",
"static",
"NoAvailablePortException",
"newNoAvailablePortException",
"(",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"newNoAvailablePortException",
"(",
"null",
",",
"message",
",",
"args",
")",
";",
"}"
] | Constructs and initializes a new {@link NoAvailablePortException} with the given {@link String message}
formatted with the given {@link Object[] arguments}.
@param message {@link String} describing the {@link NoAvailablePortException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link NoAvailablePortException} with the given {@link String message}.
@see #newNoAvailablePortException(Throwable, String, Object...)
@see org.cp.elements.net.NoAvailablePortException | [
"Constructs",
"and",
"initializes",
"a",
"new",
"{",
"@link",
"NoAvailablePortException",
"}",
"with",
"the",
"given",
"{",
"@link",
"String",
"message",
"}",
"formatted",
"with",
"the",
"given",
"{",
"@link",
"Object",
"[]",
"arguments",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java#L555-L557 |
jhalterman/lyra | src/main/java/net/jodah/lyra/internal/RetryableResource.java | RetryableResource.recoverQueue | String recoverQueue(String queueName, QueueDeclaration queueDeclaration) throws Exception {
try {
String newQueueName =
((Queue.DeclareOk) queueDeclaration.invoke(getRecoveryChannel())).getQueue();
if (queueName.equals(newQueueName))
log.info("Recovered queue {} via {}", queueName, this);
else {
log.info("Recovered queue {} as {} via {}", queueName, newQueueName, this);
queueDeclaration.name = newQueueName;
}
return newQueueName;
} catch (Exception e) {
log.error("Failed to recover queue {} via {}", queueName, this, e);
if (throwOnRecoveryFailure() || Exceptions.isCausedByConnectionClosure(e))
throw e;
return queueName;
}
} | java | String recoverQueue(String queueName, QueueDeclaration queueDeclaration) throws Exception {
try {
String newQueueName =
((Queue.DeclareOk) queueDeclaration.invoke(getRecoveryChannel())).getQueue();
if (queueName.equals(newQueueName))
log.info("Recovered queue {} via {}", queueName, this);
else {
log.info("Recovered queue {} as {} via {}", queueName, newQueueName, this);
queueDeclaration.name = newQueueName;
}
return newQueueName;
} catch (Exception e) {
log.error("Failed to recover queue {} via {}", queueName, this, e);
if (throwOnRecoveryFailure() || Exceptions.isCausedByConnectionClosure(e))
throw e;
return queueName;
}
} | [
"String",
"recoverQueue",
"(",
"String",
"queueName",
",",
"QueueDeclaration",
"queueDeclaration",
")",
"throws",
"Exception",
"{",
"try",
"{",
"String",
"newQueueName",
"=",
"(",
"(",
"Queue",
".",
"DeclareOk",
")",
"queueDeclaration",
".",
"invoke",
"(",
"getR... | Recovers a queue using the {@code channelSupplier}, returning the recovered queue's name. | [
"Recovers",
"a",
"queue",
"using",
"the",
"{"
] | train | https://github.com/jhalterman/lyra/blob/ce347a69357fef1b34e92d92a4f9e68792d81255/src/main/java/net/jodah/lyra/internal/RetryableResource.java#L166-L184 |
bazaarvoice/emodb | sor/src/main/java/com/bazaarvoice/emodb/sor/db/astyanax/AstyanaxBlockedDataReaderDAO.java | AstyanaxBlockedDataReaderDAO.rowQuery | private Iterator<Record> rowQuery(DeltaPlacement placement,
List<Map.Entry<ByteBuffer, Key>> keys,
ReadConsistency consistency) {
// Build the list of row IDs to query for.
List<ByteBuffer> rowIds = Lists.transform(keys, entryKeyFunction());
// Query for Delta & Compaction info, just the first 50 columns for now.
final Rows<ByteBuffer, DeltaKey> rows = execute(placement.getKeyspace()
.prepareQuery(placement.getBlockedDeltaColumnFamily(), SorConsistencies.toAstyanax(consistency))
.getKeySlice(rowIds)
.withColumnRange(_maxColumnsRange),
"query %d keys from placement %s", rowIds.size(), placement.getName());
// Track metrics
_randomReadMeter.mark(rowIds.size());
// Return an iterator that decodes the row results, avoiding pinning multiple decoded rows into memory at once.
return decodeRows(keys, rows, _maxColumnsRange.getLimit(), consistency);
} | java | private Iterator<Record> rowQuery(DeltaPlacement placement,
List<Map.Entry<ByteBuffer, Key>> keys,
ReadConsistency consistency) {
// Build the list of row IDs to query for.
List<ByteBuffer> rowIds = Lists.transform(keys, entryKeyFunction());
// Query for Delta & Compaction info, just the first 50 columns for now.
final Rows<ByteBuffer, DeltaKey> rows = execute(placement.getKeyspace()
.prepareQuery(placement.getBlockedDeltaColumnFamily(), SorConsistencies.toAstyanax(consistency))
.getKeySlice(rowIds)
.withColumnRange(_maxColumnsRange),
"query %d keys from placement %s", rowIds.size(), placement.getName());
// Track metrics
_randomReadMeter.mark(rowIds.size());
// Return an iterator that decodes the row results, avoiding pinning multiple decoded rows into memory at once.
return decodeRows(keys, rows, _maxColumnsRange.getLimit(), consistency);
} | [
"private",
"Iterator",
"<",
"Record",
">",
"rowQuery",
"(",
"DeltaPlacement",
"placement",
",",
"List",
"<",
"Map",
".",
"Entry",
"<",
"ByteBuffer",
",",
"Key",
">",
">",
"keys",
",",
"ReadConsistency",
"consistency",
")",
"{",
"// Build the list of row IDs to q... | Queries for rows given an enumerated list of Cassandra row keys. | [
"Queries",
"for",
"rows",
"given",
"an",
"enumerated",
"list",
"of",
"Cassandra",
"row",
"keys",
"."
] | train | https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/sor/src/main/java/com/bazaarvoice/emodb/sor/db/astyanax/AstyanaxBlockedDataReaderDAO.java#L786-L804 |
alkacon/opencms-core | src/org/opencms/xml/containerpage/CmsADESessionCache.java | CmsADESessionCache.setLastPage | public void setLastPage(CmsObject cms, CmsUUID pageId, CmsUUID detailId) {
m_lastPage = new LastPageBean(cms.getRequestContext().getSiteRoot(), pageId, detailId);
} | java | public void setLastPage(CmsObject cms, CmsUUID pageId, CmsUUID detailId) {
m_lastPage = new LastPageBean(cms.getRequestContext().getSiteRoot(), pageId, detailId);
} | [
"public",
"void",
"setLastPage",
"(",
"CmsObject",
"cms",
",",
"CmsUUID",
"pageId",
",",
"CmsUUID",
"detailId",
")",
"{",
"m_lastPage",
"=",
"new",
"LastPageBean",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getSiteRoot",
"(",
")",
",",
"pageId",
... | Stores information about the last edited container page.<p>
@param cms the CMS context
@param pageId the page id
@param detailId the detail content id | [
"Stores",
"information",
"about",
"the",
"last",
"edited",
"container",
"page",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/containerpage/CmsADESessionCache.java#L464-L468 |
fcrepo4-exts/fcrepo-camel-toolbox | fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/ClientFactory.java | ClientFactory.createClient | public static ClientConfiguration createClient(final Endpoint endpoint, final DataProvider provider) {
return createClient(singletonList(endpoint), singletonList(provider));
} | java | public static ClientConfiguration createClient(final Endpoint endpoint, final DataProvider provider) {
return createClient(singletonList(endpoint), singletonList(provider));
} | [
"public",
"static",
"ClientConfiguration",
"createClient",
"(",
"final",
"Endpoint",
"endpoint",
",",
"final",
"DataProvider",
"provider",
")",
"{",
"return",
"createClient",
"(",
"singletonList",
"(",
"endpoint",
")",
",",
"singletonList",
"(",
"provider",
")",
"... | Configure a linked data client suitable for use with a Fedora Repository.
@param endpoint Endpoint to enable on the client
@param provider Provider to enable on the client
@return a configuration for use with an LDClient | [
"Configure",
"a",
"linked",
"data",
"client",
"suitable",
"for",
"use",
"with",
"a",
"Fedora",
"Repository",
"."
] | train | https://github.com/fcrepo4-exts/fcrepo-camel-toolbox/blob/9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/ClientFactory.java#L72-L74 |
amplexus/java-flac-encoder | src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java | EncodedElement.addLong | private static void addLong(long input, int count, int startPos, byte[] dest) {
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::addLong : Begin");
int currentByte = startPos/8;
int currentOffset = startPos%8;
int bitRoom;//how many bits can be placed in current byte
long upMask;//to clear upper bits(lower bits auto-cleared by L-shift
int downShift;//bits to shift down, isolating top bits of input
int upShift;//bits to shift up, packing byte from top.
while(count > 0) {
//find how many bits can be placed in current byte
bitRoom = 8-currentOffset;
//get those bits
//i.e, take upper 'bitsNeeded' of input, put to lower part of byte.
downShift = count-bitRoom;
upMask = 255 >>> currentOffset;
upShift = 0;
if(downShift < 0) {
//upMask = 255 >>> bitRoom-count;
upShift = bitRoom - count;
upMask = 255 >>> (currentOffset+upShift);
downShift = 0;
}
if(DEBUG_LEV > 30) {
System.err.println("count:offset:bitRoom:downShift:upShift:" +
count+":"+currentOffset+":"+bitRoom+":"+downShift+":"+upShift);
}
long currentBits = (input >>> downShift) & (upMask);
//shift bits back up to match offset
currentBits = currentBits << upShift;
upMask = (byte)upMask << upShift;
dest[currentByte] = (byte)(dest[currentByte] & (~upMask));
//merge bytes~
dest[currentByte] = (byte)(dest[currentByte] | currentBits);
//System.out.println("new currentByte: " + dest[currentByte]);
count -= bitRoom;
currentOffset = 0;
currentByte++;
}
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::addLong : End");
} | java | private static void addLong(long input, int count, int startPos, byte[] dest) {
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::addLong : Begin");
int currentByte = startPos/8;
int currentOffset = startPos%8;
int bitRoom;//how many bits can be placed in current byte
long upMask;//to clear upper bits(lower bits auto-cleared by L-shift
int downShift;//bits to shift down, isolating top bits of input
int upShift;//bits to shift up, packing byte from top.
while(count > 0) {
//find how many bits can be placed in current byte
bitRoom = 8-currentOffset;
//get those bits
//i.e, take upper 'bitsNeeded' of input, put to lower part of byte.
downShift = count-bitRoom;
upMask = 255 >>> currentOffset;
upShift = 0;
if(downShift < 0) {
//upMask = 255 >>> bitRoom-count;
upShift = bitRoom - count;
upMask = 255 >>> (currentOffset+upShift);
downShift = 0;
}
if(DEBUG_LEV > 30) {
System.err.println("count:offset:bitRoom:downShift:upShift:" +
count+":"+currentOffset+":"+bitRoom+":"+downShift+":"+upShift);
}
long currentBits = (input >>> downShift) & (upMask);
//shift bits back up to match offset
currentBits = currentBits << upShift;
upMask = (byte)upMask << upShift;
dest[currentByte] = (byte)(dest[currentByte] & (~upMask));
//merge bytes~
dest[currentByte] = (byte)(dest[currentByte] | currentBits);
//System.out.println("new currentByte: " + dest[currentByte]);
count -= bitRoom;
currentOffset = 0;
currentByte++;
}
if(DEBUG_LEV > 30)
System.err.println("EncodedElement::addLong : End");
} | [
"private",
"static",
"void",
"addLong",
"(",
"long",
"input",
",",
"int",
"count",
",",
"int",
"startPos",
",",
"byte",
"[",
"]",
"dest",
")",
"{",
"if",
"(",
"DEBUG_LEV",
">",
"30",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"EncodedElement::ad... | This method adds a given number of bits of a long to a byte array.
@param input long to store bits from
@param count number of low-order bits to store
@param startPos start bit location in array to begin writing
@param dest array to store bits in. dest MUST have enough space to store
the given data, or this function will fail. | [
"This",
"method",
"adds",
"a",
"given",
"number",
"of",
"bits",
"of",
"a",
"long",
"to",
"a",
"byte",
"array",
"."
] | train | https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/EncodedElement.java#L616-L658 |
google/closure-compiler | src/com/google/javascript/jscomp/OptimizeArgumentsArray.java | OptimizeArgumentsArray.changeMethodSignature | private void changeMethodSignature(ImmutableSortedMap<Integer, String> argNames, Node paramList) {
ImmutableSortedMap<Integer, String> newParams = argNames.tailMap(paramList.getChildCount());
for (String name : newParams.values()) {
paramList.addChildToBack(IR.name(name).useSourceInfoIfMissingFrom(paramList));
}
if (!newParams.isEmpty()) {
compiler.reportChangeToEnclosingScope(paramList);
}
} | java | private void changeMethodSignature(ImmutableSortedMap<Integer, String> argNames, Node paramList) {
ImmutableSortedMap<Integer, String> newParams = argNames.tailMap(paramList.getChildCount());
for (String name : newParams.values()) {
paramList.addChildToBack(IR.name(name).useSourceInfoIfMissingFrom(paramList));
}
if (!newParams.isEmpty()) {
compiler.reportChangeToEnclosingScope(paramList);
}
} | [
"private",
"void",
"changeMethodSignature",
"(",
"ImmutableSortedMap",
"<",
"Integer",
",",
"String",
">",
"argNames",
",",
"Node",
"paramList",
")",
"{",
"ImmutableSortedMap",
"<",
"Integer",
",",
"String",
">",
"newParams",
"=",
"argNames",
".",
"tailMap",
"("... | Inserts new formal parameters into the method's signature based on the given set of names.
<p>Example: function() --> function(r0, r1, r2)
@param argNames maps param index to param name, if the param with that index has a name.
@param paramList node representing the function signature | [
"Inserts",
"new",
"formal",
"parameters",
"into",
"the",
"method",
"s",
"signature",
"based",
"on",
"the",
"given",
"set",
"of",
"names",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/OptimizeArgumentsArray.java#L233-L241 |
attribyte/wpdb | src/main/java/org/attribyte/wp/db/DB.java | DB.updatePostTimestamps | public boolean updatePostTimestamps(long postId, final long publishTimestamp, final long modifiedTimestamp, final TimeZone tz) throws SQLException {
int offset = tz.getOffset(publishTimestamp);
Connection conn = null;
PreparedStatement stmt = null;
Timer.Context ctx = metrics.updatePostTimer.time();
try {
conn = connectionSupplier.getConnection();
stmt = conn.prepareStatement(updatePostTimestampsSQL);
stmt.setTimestamp(1, new Timestamp(publishTimestamp));
stmt.setTimestamp(2, new Timestamp(publishTimestamp - offset));
stmt.setTimestamp(3, new Timestamp(modifiedTimestamp));
stmt.setTimestamp(4, new Timestamp(modifiedTimestamp - offset));
stmt.setLong(5, postId);
return stmt.executeUpdate() > 0;
} finally {
ctx.stop();
SQLUtil.closeQuietly(conn, stmt);
}
} | java | public boolean updatePostTimestamps(long postId, final long publishTimestamp, final long modifiedTimestamp, final TimeZone tz) throws SQLException {
int offset = tz.getOffset(publishTimestamp);
Connection conn = null;
PreparedStatement stmt = null;
Timer.Context ctx = metrics.updatePostTimer.time();
try {
conn = connectionSupplier.getConnection();
stmt = conn.prepareStatement(updatePostTimestampsSQL);
stmt.setTimestamp(1, new Timestamp(publishTimestamp));
stmt.setTimestamp(2, new Timestamp(publishTimestamp - offset));
stmt.setTimestamp(3, new Timestamp(modifiedTimestamp));
stmt.setTimestamp(4, new Timestamp(modifiedTimestamp - offset));
stmt.setLong(5, postId);
return stmt.executeUpdate() > 0;
} finally {
ctx.stop();
SQLUtil.closeQuietly(conn, stmt);
}
} | [
"public",
"boolean",
"updatePostTimestamps",
"(",
"long",
"postId",
",",
"final",
"long",
"publishTimestamp",
",",
"final",
"long",
"modifiedTimestamp",
",",
"final",
"TimeZone",
"tz",
")",
"throws",
"SQLException",
"{",
"int",
"offset",
"=",
"tz",
".",
"getOffs... | Updates only the timestamp fields for a post.
@param postId The post to update.
@param publishTimestamp The publish timestamp.
@param modifiedTimestamp The modified timestamp.
@param tz The local time zone.
@return Were the timestamps modified?
@throws SQLException on database error or missing post id. | [
"Updates",
"only",
"the",
"timestamp",
"fields",
"for",
"a",
"post",
"."
] | train | https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1496-L1514 |
jenkinsci/jenkins | core/src/main/java/hudson/Util.java | Util.loadFile | @Nonnull
public static String loadFile(@Nonnull File logfile, @Nonnull Charset charset) throws IOException {
// Note: Until charset handling is resolved (e.g. by implementing
// https://issues.jenkins-ci.org/browse/JENKINS-48923 ), this method
// must be able to handle character encoding errors. As reported at
// https://issues.jenkins-ci.org/browse/JENKINS-49112 Run.getLog() calls
// loadFile() to fully read the generated log file. This file might
// contain unmappable and/or malformed byte sequences. We need to make
// sure that in such cases, no CharacterCodingException is thrown.
//
// One approach that cannot be used is to call Files.newBufferedReader()
// because there is a difference in how an InputStreamReader constructed
// from a Charset and the reader returned by Files.newBufferedReader()
// handle malformed and unmappable byte sequences for the specified
// encoding; the latter is more picky and will throw an exception.
// See: https://issues.jenkins-ci.org/browse/JENKINS-49060?focusedCommentId=325989&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-325989
try {
return FileUtils.readFileToString(logfile, charset);
} catch (FileNotFoundException e) {
return "";
} catch (Exception e) {
throw new IOException("Failed to fully read " + logfile, e);
}
} | java | @Nonnull
public static String loadFile(@Nonnull File logfile, @Nonnull Charset charset) throws IOException {
// Note: Until charset handling is resolved (e.g. by implementing
// https://issues.jenkins-ci.org/browse/JENKINS-48923 ), this method
// must be able to handle character encoding errors. As reported at
// https://issues.jenkins-ci.org/browse/JENKINS-49112 Run.getLog() calls
// loadFile() to fully read the generated log file. This file might
// contain unmappable and/or malformed byte sequences. We need to make
// sure that in such cases, no CharacterCodingException is thrown.
//
// One approach that cannot be used is to call Files.newBufferedReader()
// because there is a difference in how an InputStreamReader constructed
// from a Charset and the reader returned by Files.newBufferedReader()
// handle malformed and unmappable byte sequences for the specified
// encoding; the latter is more picky and will throw an exception.
// See: https://issues.jenkins-ci.org/browse/JENKINS-49060?focusedCommentId=325989&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-325989
try {
return FileUtils.readFileToString(logfile, charset);
} catch (FileNotFoundException e) {
return "";
} catch (Exception e) {
throw new IOException("Failed to fully read " + logfile, e);
}
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"loadFile",
"(",
"@",
"Nonnull",
"File",
"logfile",
",",
"@",
"Nonnull",
"Charset",
"charset",
")",
"throws",
"IOException",
"{",
"// Note: Until charset handling is resolved (e.g. by implementing",
"// https://issues.jenkins-ci... | Reads the entire contents of the text file at <code>logfile</code> into a
string using <code>charset</code> for decoding. If no such file exists,
an empty string is returned.
@param logfile The text file to read in its entirety.
@param charset The charset to use for decoding the bytes in <code>logfile</code>.
@return The entire text content of <code>logfile</code>.
@throws IOException If an error occurs while reading the file. | [
"Reads",
"the",
"entire",
"contents",
"of",
"the",
"text",
"file",
"at",
"<code",
">",
"logfile<",
"/",
"code",
">",
"into",
"a",
"string",
"using",
"<code",
">",
"charset<",
"/",
"code",
">",
"for",
"decoding",
".",
"If",
"no",
"such",
"file",
"exists... | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/Util.java#L213-L236 |
jingwei/krati | krati-main/src/main/java/krati/core/StoreConfig.java | StoreConfig.getInt | public int getInt(String pName, int defaultValue) {
String pValue = _properties.getProperty(pName);
return parseInt(pName, pValue, defaultValue);
} | java | public int getInt(String pName, int defaultValue) {
String pValue = _properties.getProperty(pName);
return parseInt(pName, pValue, defaultValue);
} | [
"public",
"int",
"getInt",
"(",
"String",
"pName",
",",
"int",
"defaultValue",
")",
"{",
"String",
"pValue",
"=",
"_properties",
".",
"getProperty",
"(",
"pName",
")",
";",
"return",
"parseInt",
"(",
"pName",
",",
"pValue",
",",
"defaultValue",
")",
";",
... | Gets an integer property via a string property name.
@param pName - the property name
@param defaultValue - the default property value
@return an integer property | [
"Gets",
"an",
"integer",
"property",
"via",
"a",
"string",
"property",
"name",
"."
] | train | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/StoreConfig.java#L423-L426 |
yanzhenjie/AndServer | api/src/main/java/com/yanzhenjie/andserver/ComponentRegister.java | ComponentRegister.getDexFilePaths | public static List<String> getDexFilePaths(Context context) {
ApplicationInfo appInfo = context.getApplicationInfo();
File sourceApk = new File(appInfo.sourceDir);
List<String> sourcePaths = new ArrayList<>();
sourcePaths.add(appInfo.sourceDir);
if (!isVMMultidexCapable()) {
String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;
int totalDexNumber = getMultiDexPreferences(context).getInt(KEY_DEX_NUMBER, 1);
File dexDir = new File(appInfo.dataDir, CODE_CACHE_SECONDARY_DIRECTORY);
for (int secondaryNumber = 2; secondaryNumber <= totalDexNumber; secondaryNumber++) {
String fileName = extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX;
File extractedFile = new File(dexDir, fileName);
if (extractedFile.isFile()) {
sourcePaths.add(extractedFile.getAbsolutePath());
}
}
}
if (AndServer.isDebug()) {
sourcePaths.addAll(loadInstantRunDexFile(appInfo));
}
return sourcePaths;
} | java | public static List<String> getDexFilePaths(Context context) {
ApplicationInfo appInfo = context.getApplicationInfo();
File sourceApk = new File(appInfo.sourceDir);
List<String> sourcePaths = new ArrayList<>();
sourcePaths.add(appInfo.sourceDir);
if (!isVMMultidexCapable()) {
String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;
int totalDexNumber = getMultiDexPreferences(context).getInt(KEY_DEX_NUMBER, 1);
File dexDir = new File(appInfo.dataDir, CODE_CACHE_SECONDARY_DIRECTORY);
for (int secondaryNumber = 2; secondaryNumber <= totalDexNumber; secondaryNumber++) {
String fileName = extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX;
File extractedFile = new File(dexDir, fileName);
if (extractedFile.isFile()) {
sourcePaths.add(extractedFile.getAbsolutePath());
}
}
}
if (AndServer.isDebug()) {
sourcePaths.addAll(loadInstantRunDexFile(appInfo));
}
return sourcePaths;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getDexFilePaths",
"(",
"Context",
"context",
")",
"{",
"ApplicationInfo",
"appInfo",
"=",
"context",
".",
"getApplicationInfo",
"(",
")",
";",
"File",
"sourceApk",
"=",
"new",
"File",
"(",
"appInfo",
".",
"sou... | Obtain all the dex path.
@see com.android.support.MultiDex#loadExistingExtractions(Context, String)
@see com.android.support.MultiDex#clearOldDexDir(Context) | [
"Obtain",
"all",
"the",
"dex",
"path",
"."
] | train | https://github.com/yanzhenjie/AndServer/blob/f95f316cdfa5755d6a3fec3c6a1b5df783b81517/api/src/main/java/com/yanzhenjie/andserver/ComponentRegister.java#L123-L148 |
salesforce/Argus | ArgusCore/src/main/java/com/salesforce/dva/argus/entity/SuspensionRecord.java | SuspensionRecord.findByUserAndSubsystem | public static SuspensionRecord findByUserAndSubsystem(EntityManager em, PrincipalUser user, SubSystem subSystem) {
TypedQuery<SuspensionRecord> query = em.createNamedQuery("SuspensionRecord.findByUserAndSubsystem", SuspensionRecord.class);
try {
query.setParameter("user", user);
query.setParameter("subSystem", subSystem);
query.setHint("javax.persistence.cache.storeMode", "REFRESH");
return query.getSingleResult();
} catch (NoResultException ex) {
return null;
}
} | java | public static SuspensionRecord findByUserAndSubsystem(EntityManager em, PrincipalUser user, SubSystem subSystem) {
TypedQuery<SuspensionRecord> query = em.createNamedQuery("SuspensionRecord.findByUserAndSubsystem", SuspensionRecord.class);
try {
query.setParameter("user", user);
query.setParameter("subSystem", subSystem);
query.setHint("javax.persistence.cache.storeMode", "REFRESH");
return query.getSingleResult();
} catch (NoResultException ex) {
return null;
}
} | [
"public",
"static",
"SuspensionRecord",
"findByUserAndSubsystem",
"(",
"EntityManager",
"em",
",",
"PrincipalUser",
"user",
",",
"SubSystem",
"subSystem",
")",
"{",
"TypedQuery",
"<",
"SuspensionRecord",
">",
"query",
"=",
"em",
".",
"createNamedQuery",
"(",
"\"Susp... | Find the suspension record for a given user-subsystem combination.
@param em The EntityManager to use.
@param user The user for which to retrieve record.
@param subSystem THe subsystem for which to retrieve record.
@return The suspension record for the given user-subsystem combination. Null if no such record exists. | [
"Find",
"the",
"suspension",
"record",
"for",
"a",
"given",
"user",
"-",
"subsystem",
"combination",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusCore/src/main/java/com/salesforce/dva/argus/entity/SuspensionRecord.java#L171-L182 |
anotheria/moskito | moskito-core/src/main/java/net/anotheria/moskito/core/util/storage/Storage.java | Storage.putAll | public void putAll(Storage<? extends K, ? extends V> anotherStorage){
wrapper.putAll(anotherStorage.getWrapper());
stats.setSize(wrapper.size());
} | java | public void putAll(Storage<? extends K, ? extends V> anotherStorage){
wrapper.putAll(anotherStorage.getWrapper());
stats.setSize(wrapper.size());
} | [
"public",
"void",
"putAll",
"(",
"Storage",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
"anotherStorage",
")",
"{",
"wrapper",
".",
"putAll",
"(",
"anotherStorage",
".",
"getWrapper",
"(",
")",
")",
";",
"stats",
".",
"setSize",
"(",
"wrap... | Puts all elements from anotherStorage to this storage.
@param anotherStorage | [
"Puts",
"all",
"elements",
"from",
"anotherStorage",
"to",
"this",
"storage",
"."
] | train | https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-core/src/main/java/net/anotheria/moskito/core/util/storage/Storage.java#L166-L169 |
cloudfoundry/cf-java-client | cloudfoundry-util/src/main/java/org/cloudfoundry/util/JobUtils.java | JobUtils.waitForCompletion | public static <R extends Resource<JobEntity>> Mono<Void> waitForCompletion(CloudFoundryClient cloudFoundryClient, Duration completionTimeout, R resource) {
return waitForCompletion(cloudFoundryClient, completionTimeout, ResourceUtils.getEntity(resource));
} | java | public static <R extends Resource<JobEntity>> Mono<Void> waitForCompletion(CloudFoundryClient cloudFoundryClient, Duration completionTimeout, R resource) {
return waitForCompletion(cloudFoundryClient, completionTimeout, ResourceUtils.getEntity(resource));
} | [
"public",
"static",
"<",
"R",
"extends",
"Resource",
"<",
"JobEntity",
">",
">",
"Mono",
"<",
"Void",
">",
"waitForCompletion",
"(",
"CloudFoundryClient",
"cloudFoundryClient",
",",
"Duration",
"completionTimeout",
",",
"R",
"resource",
")",
"{",
"return",
"wait... | Waits for a job to complete
@param cloudFoundryClient the client to use to request job status
@param completionTimeout the amount of time to wait for the job to complete.
@param resource the resource representing the job
@param <R> the Job resource type
@return {@code onComplete} once job has completed | [
"Waits",
"for",
"a",
"job",
"to",
"complete"
] | train | https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/JobUtils.java#L56-L58 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/debug/cli/ShellFactory.java | ShellFactory.createConsoleShell | public static Shell createConsoleShell(String prompt, String appName, Object... handlers) {
ConsoleIO io = new ConsoleIO();
List<String> path = new ArrayList<String>(1);
path.add(prompt);
MultiMap<String, Object> modifAuxHandlers = new ArrayHashMultiMap<String, Object>();
modifAuxHandlers.put("!", io);
Shell theShell = new Shell(new Shell.Settings(io, io, modifAuxHandlers, false),
new CommandTable(new DashJoinedNamer(true)), path);
theShell.setAppName(appName);
theShell.addMainHandler(theShell, "!");
theShell.addMainHandler(new HelpCommandHandler(), "?");
for (Object h : handlers) {
theShell.addMainHandler(h, "");
}
return theShell;
} | java | public static Shell createConsoleShell(String prompt, String appName, Object... handlers) {
ConsoleIO io = new ConsoleIO();
List<String> path = new ArrayList<String>(1);
path.add(prompt);
MultiMap<String, Object> modifAuxHandlers = new ArrayHashMultiMap<String, Object>();
modifAuxHandlers.put("!", io);
Shell theShell = new Shell(new Shell.Settings(io, io, modifAuxHandlers, false),
new CommandTable(new DashJoinedNamer(true)), path);
theShell.setAppName(appName);
theShell.addMainHandler(theShell, "!");
theShell.addMainHandler(new HelpCommandHandler(), "?");
for (Object h : handlers) {
theShell.addMainHandler(h, "");
}
return theShell;
} | [
"public",
"static",
"Shell",
"createConsoleShell",
"(",
"String",
"prompt",
",",
"String",
"appName",
",",
"Object",
"...",
"handlers",
")",
"{",
"ConsoleIO",
"io",
"=",
"new",
"ConsoleIO",
"(",
")",
";",
"List",
"<",
"String",
">",
"path",
"=",
"new",
"... | One of facade methods for operating the Shell.
Run the obtained Shell with commandLoop().
@see org.gearvrf.debug.cli.Shell#Shell(org.gearvrf.debug.cli.Shell.Settings, org.gearvrf.debug.cli.CommandTable, java.util.List)
@param prompt Prompt to be displayed
@param appName The app name string
@param handlers Command handlers
@return Shell that can be either further customized or run directly by calling commandLoop(). | [
"One",
"of",
"facade",
"methods",
"for",
"operating",
"the",
"Shell",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/debug/cli/ShellFactory.java#L35-L55 |
powermock/powermock | powermock-reflect/src/main/java/org/powermock/reflect/internal/WhiteboxImpl.java | WhiteboxImpl.invokeMethod | @SuppressWarnings("unchecked")
public static synchronized <T> T invokeMethod(Class<?> clazz, String methodToExecute, Object... arguments)
throws Exception {
return (T) doInvokeMethod(clazz, null, methodToExecute, arguments);
} | java | @SuppressWarnings("unchecked")
public static synchronized <T> T invokeMethod(Class<?> clazz, String methodToExecute, Object... arguments)
throws Exception {
return (T) doInvokeMethod(clazz, null, methodToExecute, arguments);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"synchronized",
"<",
"T",
">",
"T",
"invokeMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"methodToExecute",
",",
"Object",
"...",
"arguments",
")",
"throws",
"Exception",
... | Invoke a private or inner class method. This might be useful to test
private methods.
@param <T> the generic type
@param clazz the clazz
@param methodToExecute the method to execute
@param arguments the arguments
@return the t
@throws Exception the exception | [
"Invoke",
"a",
"private",
"or",
"inner",
"class",
"method",
".",
"This",
"might",
"be",
"useful",
"to",
"test",
"private",
"methods",
"."
] | train | https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-reflect/src/main/java/org/powermock/reflect/internal/WhiteboxImpl.java#L793-L797 |
lestard/advanced-bindings | src/main/java/eu/lestard/advanced_bindings/api/MathBindings.java | MathBindings.subtractExact | public static IntegerBinding subtractExact(final int x, final ObservableIntegerValue y) {
return createIntegerBinding(() -> Math.subtractExact(x, y.get()), y);
} | java | public static IntegerBinding subtractExact(final int x, final ObservableIntegerValue y) {
return createIntegerBinding(() -> Math.subtractExact(x, y.get()), y);
} | [
"public",
"static",
"IntegerBinding",
"subtractExact",
"(",
"final",
"int",
"x",
",",
"final",
"ObservableIntegerValue",
"y",
")",
"{",
"return",
"createIntegerBinding",
"(",
"(",
")",
"->",
"Math",
".",
"subtractExact",
"(",
"x",
",",
"y",
".",
"get",
"(",
... | Binding for {@link java.lang.Math#subtractExact(int, int)}
@param x the first value
@param y the second value to subtract from the first
@return the result
@throws ArithmeticException if the result overflows an int | [
"Binding",
"for",
"{",
"@link",
"java",
".",
"lang",
".",
"Math#subtractExact",
"(",
"int",
"int",
")",
"}"
] | train | https://github.com/lestard/advanced-bindings/blob/054a5dde261c29f862b971765fa3da3704a13ab4/src/main/java/eu/lestard/advanced_bindings/api/MathBindings.java#L1415-L1417 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/util/ResourceTable.java | ResourceTable.copyRecord | public void copyRecord(Record recAlt, Record recMain)
{
// Already done in preCopyRecord(), just make sure the primary key is the same
this.copyKeys(recAlt, recMain, DBConstants.MAIN_KEY_AREA);
} | java | public void copyRecord(Record recAlt, Record recMain)
{
// Already done in preCopyRecord(), just make sure the primary key is the same
this.copyKeys(recAlt, recMain, DBConstants.MAIN_KEY_AREA);
} | [
"public",
"void",
"copyRecord",
"(",
"Record",
"recAlt",
",",
"Record",
"recMain",
")",
"{",
"// Already done in preCopyRecord(), just make sure the primary key is the same",
"this",
".",
"copyKeys",
"(",
"recAlt",
",",
"recMain",
",",
"DBConstants",
".",
"MAIN_KEY_AREA",... | Copy the fields from the (main) source to the (mirrored) destination record.
This is done before any write or set.
@param recAlt Destination record
@param recMain Source record | [
"Copy",
"the",
"fields",
"from",
"the",
"(",
"main",
")",
"source",
"to",
"the",
"(",
"mirrored",
")",
"destination",
"record",
".",
"This",
"is",
"done",
"before",
"any",
"write",
"or",
"set",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/util/ResourceTable.java#L118-L122 |
passwordmaker/java-passwordmaker-lib | src/main/java/org/daveware/passwordmaker/Database.java | Database.setGlobalSetting | public void setGlobalSetting(String name, String value) {
String oldValue;
// Avoid redundant setting
if (globalSettings.containsKey(name)) {
oldValue = globalSettings.get(name);
if (value.compareTo(oldValue) == 0)
return;
}
globalSettings.put(name, value);
setDirty(true);
} | java | public void setGlobalSetting(String name, String value) {
String oldValue;
// Avoid redundant setting
if (globalSettings.containsKey(name)) {
oldValue = globalSettings.get(name);
if (value.compareTo(oldValue) == 0)
return;
}
globalSettings.put(name, value);
setDirty(true);
} | [
"public",
"void",
"setGlobalSetting",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"String",
"oldValue",
";",
"// Avoid redundant setting",
"if",
"(",
"globalSettings",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"oldValue",
"=",
"globalSettings"... | Sets a firefox global setting. This allows any name and should be avoided. It
is used by the RDF reader.
@param name The name of the setting.
@param value The value. | [
"Sets",
"a",
"firefox",
"global",
"setting",
".",
"This",
"allows",
"any",
"name",
"and",
"should",
"be",
"avoided",
".",
"It",
"is",
"used",
"by",
"the",
"RDF",
"reader",
"."
] | train | https://github.com/passwordmaker/java-passwordmaker-lib/blob/18c22fca7dd9a47f08161425b85a5bd257afbb2b/src/main/java/org/daveware/passwordmaker/Database.java#L170-L181 |
infinispan/infinispan | commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java | MarshallUtil.unmarshallIntCollection | public static <T extends Collection<Integer>> T unmarshallIntCollection(ObjectInput in, CollectionBuilder<Integer, T> builder) throws IOException {
final int size = unmarshallSize(in);
if (size == NULL_VALUE) {
return null;
}
T collection = Objects.requireNonNull(builder, "CollectionBuilder must be non-null").build(size);
for (int i = 0; i < size; ++i) {
collection.add(in.readInt());
}
return collection;
} | java | public static <T extends Collection<Integer>> T unmarshallIntCollection(ObjectInput in, CollectionBuilder<Integer, T> builder) throws IOException {
final int size = unmarshallSize(in);
if (size == NULL_VALUE) {
return null;
}
T collection = Objects.requireNonNull(builder, "CollectionBuilder must be non-null").build(size);
for (int i = 0; i < size; ++i) {
collection.add(in.readInt());
}
return collection;
} | [
"public",
"static",
"<",
"T",
"extends",
"Collection",
"<",
"Integer",
">",
">",
"T",
"unmarshallIntCollection",
"(",
"ObjectInput",
"in",
",",
"CollectionBuilder",
"<",
"Integer",
",",
"T",
">",
"builder",
")",
"throws",
"IOException",
"{",
"final",
"int",
... | Unmarshalls a collection of integers.
@param in the {@link ObjectInput} to read from.
@param builder the {@link CollectionBuilder} to build the collection of integer.
@param <T> the concrete type of the collection.
@return the collection.
@throws IOException if an error occurs. | [
"Unmarshalls",
"a",
"collection",
"of",
"integers",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L489-L499 |
kiswanij/jk-util | src/main/java/com/jk/util/UserPreferences.java | UserPreferences.getFloat | public static float getFloat(final String key, final float def) {
try {
return systemRoot.getFloat(fixKey(key), def);
} catch (final Exception e) {
// just eat the exception to avoid any system
// crash on system issues
return def;
}
} | java | public static float getFloat(final String key, final float def) {
try {
return systemRoot.getFloat(fixKey(key), def);
} catch (final Exception e) {
// just eat the exception to avoid any system
// crash on system issues
return def;
}
} | [
"public",
"static",
"float",
"getFloat",
"(",
"final",
"String",
"key",
",",
"final",
"float",
"def",
")",
"{",
"try",
"{",
"return",
"systemRoot",
".",
"getFloat",
"(",
"fixKey",
"(",
"key",
")",
",",
"def",
")",
";",
"}",
"catch",
"(",
"final",
"Ex... | Gets the float.
@param key the key
@param def the def
@return the float
@see java.util.prefs.Preferences#getFloat(java.lang.String, float) | [
"Gets",
"the",
"float",
"."
] | train | https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/UserPreferences.java#L108-L116 |
Harium/keel | src/main/java/com/harium/keel/catalano/math/distance/Distance.java | Distance.Chessboard | public static double Chessboard(IntPoint p, IntPoint q) {
return Chessboard(p.x, p.y, q.x, q.y);
} | java | public static double Chessboard(IntPoint p, IntPoint q) {
return Chessboard(p.x, p.y, q.x, q.y);
} | [
"public",
"static",
"double",
"Chessboard",
"(",
"IntPoint",
"p",
",",
"IntPoint",
"q",
")",
"{",
"return",
"Chessboard",
"(",
"p",
".",
"x",
",",
"p",
".",
"y",
",",
"q",
".",
"x",
",",
"q",
".",
"y",
")",
";",
"}"
] | Gets the Chessboard distance between two points.
@param p IntPoint with X and Y axis coordinates.
@param q IntPoint with X and Y axis coordinates.
@return The Chessboard distance between x and y. | [
"Gets",
"the",
"Chessboard",
"distance",
"between",
"two",
"points",
"."
] | train | https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L254-L256 |
wellner/jcarafe | jcarafe-core/src/main/java/cern/colt/map/AbstractMap.java | AbstractMap.setUp | protected void setUp(int initialCapacity, double minLoadFactor, double maxLoadFactor) {
if (initialCapacity < 0)
throw new IllegalArgumentException("Initial Capacity must not be less than zero: "+ initialCapacity);
if (minLoadFactor < 0.0 || minLoadFactor >= 1.0)
throw new IllegalArgumentException("Illegal minLoadFactor: "+ minLoadFactor);
if (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0)
throw new IllegalArgumentException("Illegal maxLoadFactor: "+ maxLoadFactor);
if (minLoadFactor >= maxLoadFactor)
throw new IllegalArgumentException("Illegal minLoadFactor: "+ minLoadFactor+" and maxLoadFactor: "+ maxLoadFactor);
} | java | protected void setUp(int initialCapacity, double minLoadFactor, double maxLoadFactor) {
if (initialCapacity < 0)
throw new IllegalArgumentException("Initial Capacity must not be less than zero: "+ initialCapacity);
if (minLoadFactor < 0.0 || minLoadFactor >= 1.0)
throw new IllegalArgumentException("Illegal minLoadFactor: "+ minLoadFactor);
if (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0)
throw new IllegalArgumentException("Illegal maxLoadFactor: "+ maxLoadFactor);
if (minLoadFactor >= maxLoadFactor)
throw new IllegalArgumentException("Illegal minLoadFactor: "+ minLoadFactor+" and maxLoadFactor: "+ maxLoadFactor);
} | [
"protected",
"void",
"setUp",
"(",
"int",
"initialCapacity",
",",
"double",
"minLoadFactor",
",",
"double",
"maxLoadFactor",
")",
"{",
"if",
"(",
"initialCapacity",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Initial Capacity must not be less th... | Initializes the receiver.
You will almost certainly need to override this method in subclasses to initialize the hash table.
@param initialCapacity the initial capacity of the receiver.
@param minLoadFactor the minLoadFactor of the receiver.
@param maxLoadFactor the maxLoadFactor of the receiver.
@throws IllegalArgumentException if <tt>initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) || (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >= maxLoadFactor)</tt>. | [
"Initializes",
"the",
"receiver",
".",
"You",
"will",
"almost",
"certainly",
"need",
"to",
"override",
"this",
"method",
"in",
"subclasses",
"to",
"initialize",
"the",
"hash",
"table",
"."
] | train | https://github.com/wellner/jcarafe/blob/ab8b0a83dbf600fe80c27711815c90bd3055b217/jcarafe-core/src/main/java/cern/colt/map/AbstractMap.java#L137-L146 |
sagiegurari/fax4j | src/main/java/org/fax4j/util/IOHelper.java | IOHelper.createReader | public static Reader createReader(InputStream inputStream,String encoding)
{
//get encoding
String updatedEncoding=IOHelper.getEncodingToUse(encoding);
//create reader
Reader reader=null;
try
{
reader=new InputStreamReader(inputStream,updatedEncoding);
}
catch(UnsupportedEncodingException exception)
{
throw new FaxException("Unable to create reader, unsupported encoding: "+encoding,exception);
}
return reader;
} | java | public static Reader createReader(InputStream inputStream,String encoding)
{
//get encoding
String updatedEncoding=IOHelper.getEncodingToUse(encoding);
//create reader
Reader reader=null;
try
{
reader=new InputStreamReader(inputStream,updatedEncoding);
}
catch(UnsupportedEncodingException exception)
{
throw new FaxException("Unable to create reader, unsupported encoding: "+encoding,exception);
}
return reader;
} | [
"public",
"static",
"Reader",
"createReader",
"(",
"InputStream",
"inputStream",
",",
"String",
"encoding",
")",
"{",
"//get encoding",
"String",
"updatedEncoding",
"=",
"IOHelper",
".",
"getEncodingToUse",
"(",
"encoding",
")",
";",
"//create reader",
"Reader",
"re... | This function creates and returns a new reader for the
provided input stream.
@param inputStream
The input stream
@param encoding
The encoding used by the reader (null for default system encoding)
@return The reader | [
"This",
"function",
"creates",
"and",
"returns",
"a",
"new",
"reader",
"for",
"the",
"provided",
"input",
"stream",
"."
] | train | https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L235-L252 |
treelogic-swe/aws-mock | src/main/java/com/tlswe/awsmock/ec2/control/MockEC2QueryHandler.java | MockEC2QueryHandler.createSubnet | private CreateSubnetResponseType createSubnet(final String vpcId, final String cidrBlock) {
CreateSubnetResponseType ret = new CreateSubnetResponseType();
ret.setRequestId(UUID.randomUUID().toString());
MockSubnet mockSubnet = mockSubnetController.createSubnet(cidrBlock, vpcId);
SubnetType subnetType = new SubnetType();
subnetType.setVpcId(mockSubnet.getVpcId());
subnetType.setSubnetId(mockSubnet.getSubnetId());
ret.setSubnet(subnetType);
return ret;
} | java | private CreateSubnetResponseType createSubnet(final String vpcId, final String cidrBlock) {
CreateSubnetResponseType ret = new CreateSubnetResponseType();
ret.setRequestId(UUID.randomUUID().toString());
MockSubnet mockSubnet = mockSubnetController.createSubnet(cidrBlock, vpcId);
SubnetType subnetType = new SubnetType();
subnetType.setVpcId(mockSubnet.getVpcId());
subnetType.setSubnetId(mockSubnet.getSubnetId());
ret.setSubnet(subnetType);
return ret;
} | [
"private",
"CreateSubnetResponseType",
"createSubnet",
"(",
"final",
"String",
"vpcId",
",",
"final",
"String",
"cidrBlock",
")",
"{",
"CreateSubnetResponseType",
"ret",
"=",
"new",
"CreateSubnetResponseType",
"(",
")",
";",
"ret",
".",
"setRequestId",
"(",
"UUID",
... | Handles "createSubnet" request to create Subnet and returns response with a subnet.
@param vpcId vpc Id for subnet.
@param cidrBlock VPC cidr block.
@return a CreateSubnetResponseType with our new Subnet | [
"Handles",
"createSubnet",
"request",
"to",
"create",
"Subnet",
"and",
"returns",
"response",
"with",
"a",
"subnet",
"."
] | train | https://github.com/treelogic-swe/aws-mock/blob/1d1058c0ebbd0615efa28695481e36ae3ffc58a0/src/main/java/com/tlswe/awsmock/ec2/control/MockEC2QueryHandler.java#L1474-L1485 |
google/gson | gson/src/main/java/com/google/gson/Gson.java | Gson.fromJson | @SuppressWarnings("unchecked")
public <T> T fromJson(JsonReader reader, Type typeOfT) throws JsonIOException, JsonSyntaxException {
boolean isEmpty = true;
boolean oldLenient = reader.isLenient();
reader.setLenient(true);
try {
reader.peek();
isEmpty = false;
TypeToken<T> typeToken = (TypeToken<T>) TypeToken.get(typeOfT);
TypeAdapter<T> typeAdapter = getAdapter(typeToken);
T object = typeAdapter.read(reader);
return object;
} catch (EOFException e) {
/*
* For compatibility with JSON 1.5 and earlier, we return null for empty
* documents instead of throwing.
*/
if (isEmpty) {
return null;
}
throw new JsonSyntaxException(e);
} catch (IllegalStateException e) {
throw new JsonSyntaxException(e);
} catch (IOException e) {
// TODO(inder): Figure out whether it is indeed right to rethrow this as JsonSyntaxException
throw new JsonSyntaxException(e);
} catch (AssertionError e) {
AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage());
error.initCause(e);
throw error;
} finally {
reader.setLenient(oldLenient);
}
} | java | @SuppressWarnings("unchecked")
public <T> T fromJson(JsonReader reader, Type typeOfT) throws JsonIOException, JsonSyntaxException {
boolean isEmpty = true;
boolean oldLenient = reader.isLenient();
reader.setLenient(true);
try {
reader.peek();
isEmpty = false;
TypeToken<T> typeToken = (TypeToken<T>) TypeToken.get(typeOfT);
TypeAdapter<T> typeAdapter = getAdapter(typeToken);
T object = typeAdapter.read(reader);
return object;
} catch (EOFException e) {
/*
* For compatibility with JSON 1.5 and earlier, we return null for empty
* documents instead of throwing.
*/
if (isEmpty) {
return null;
}
throw new JsonSyntaxException(e);
} catch (IllegalStateException e) {
throw new JsonSyntaxException(e);
} catch (IOException e) {
// TODO(inder): Figure out whether it is indeed right to rethrow this as JsonSyntaxException
throw new JsonSyntaxException(e);
} catch (AssertionError e) {
AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage());
error.initCause(e);
throw error;
} finally {
reader.setLenient(oldLenient);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"fromJson",
"(",
"JsonReader",
"reader",
",",
"Type",
"typeOfT",
")",
"throws",
"JsonIOException",
",",
"JsonSyntaxException",
"{",
"boolean",
"isEmpty",
"=",
"true",
";",
"boole... | Reads the next JSON value from {@code reader} and convert it to an object
of type {@code typeOfT}. Returns {@code null}, if the {@code reader} is at EOF.
Since Type is not parameterized by T, this method is type unsafe and should be used carefully
@throws JsonIOException if there was a problem writing to the Reader
@throws JsonSyntaxException if json is not a valid representation for an object of type | [
"Reads",
"the",
"next",
"JSON",
"value",
"from",
"{",
"@code",
"reader",
"}",
"and",
"convert",
"it",
"to",
"an",
"object",
"of",
"type",
"{",
"@code",
"typeOfT",
"}",
".",
"Returns",
"{",
"@code",
"null",
"}",
"if",
"the",
"{",
"@code",
"reader",
"}... | train | https://github.com/google/gson/blob/63ee47cb642c8018e5cddd639aa2be143220ad4b/gson/src/main/java/com/google/gson/Gson.java#L922-L955 |
UrielCh/ovh-java-sdk | ovh-java-sdk-vrack/src/main/java/net/minidev/ovh/api/ApiOvhVrack.java | ApiOvhVrack.serviceName_ipLoadbalancing_ipLoadbalancing_GET | public OvhIplb serviceName_ipLoadbalancing_ipLoadbalancing_GET(String serviceName, String ipLoadbalancing) throws IOException {
String qPath = "/vrack/{serviceName}/ipLoadbalancing/{ipLoadbalancing}";
StringBuilder sb = path(qPath, serviceName, ipLoadbalancing);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhIplb.class);
} | java | public OvhIplb serviceName_ipLoadbalancing_ipLoadbalancing_GET(String serviceName, String ipLoadbalancing) throws IOException {
String qPath = "/vrack/{serviceName}/ipLoadbalancing/{ipLoadbalancing}";
StringBuilder sb = path(qPath, serviceName, ipLoadbalancing);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhIplb.class);
} | [
"public",
"OvhIplb",
"serviceName_ipLoadbalancing_ipLoadbalancing_GET",
"(",
"String",
"serviceName",
",",
"String",
"ipLoadbalancing",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/vrack/{serviceName}/ipLoadbalancing/{ipLoadbalancing}\"",
";",
"StringBuilder",
... | Get this object properties
REST: GET /vrack/{serviceName}/ipLoadbalancing/{ipLoadbalancing}
@param serviceName [required] The internal name of your vrack
@param ipLoadbalancing [required] Your ipLoadbalancing
API beta | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-vrack/src/main/java/net/minidev/ovh/api/ApiOvhVrack.java#L60-L65 |
dmak/jaxb-xew-plugin | src/main/java/com/sun/tools/xjc/addon/xew/XmlElementWrapperPlugin.java | XmlElementWrapperPlugin.deleteClass | private void deleteClass(Outline outline, JDefinedClass clazz) {
if (clazz.parentContainer().isClass()) {
// The candidate class is an inner class. Remove the class from its parent class.
JDefinedClass parentClass = (JDefinedClass) clazz.parentContainer();
writeSummary("\tRemoving class " + clazz.fullName() + " from class " + parentClass.fullName());
for (Iterator<JDefinedClass> iter = parentClass.classes(); iter.hasNext();) {
if (iter.next().equals(clazz)) {
iter.remove();
break;
}
}
}
else {
// The candidate class is in a package. Remove the class from the package.
JPackage parentPackage = (JPackage) clazz.parentContainer();
writeSummary("\tRemoving class " + clazz.fullName() + " from package " + parentPackage.name());
parentPackage.remove(clazz);
// And also remove the class from model.
for (Iterator<? extends ClassOutline> iter = outline.getClasses().iterator(); iter.hasNext();) {
ClassOutline classOutline = iter.next();
if (classOutline.implClass == clazz) {
outline.getModel().beans().remove(classOutline.target);
Set<Object> packageClasses = getPrivateField(classOutline._package(), "classes");
packageClasses.remove(classOutline);
iter.remove();
break;
}
}
}
} | java | private void deleteClass(Outline outline, JDefinedClass clazz) {
if (clazz.parentContainer().isClass()) {
// The candidate class is an inner class. Remove the class from its parent class.
JDefinedClass parentClass = (JDefinedClass) clazz.parentContainer();
writeSummary("\tRemoving class " + clazz.fullName() + " from class " + parentClass.fullName());
for (Iterator<JDefinedClass> iter = parentClass.classes(); iter.hasNext();) {
if (iter.next().equals(clazz)) {
iter.remove();
break;
}
}
}
else {
// The candidate class is in a package. Remove the class from the package.
JPackage parentPackage = (JPackage) clazz.parentContainer();
writeSummary("\tRemoving class " + clazz.fullName() + " from package " + parentPackage.name());
parentPackage.remove(clazz);
// And also remove the class from model.
for (Iterator<? extends ClassOutline> iter = outline.getClasses().iterator(); iter.hasNext();) {
ClassOutline classOutline = iter.next();
if (classOutline.implClass == clazz) {
outline.getModel().beans().remove(classOutline.target);
Set<Object> packageClasses = getPrivateField(classOutline._package(), "classes");
packageClasses.remove(classOutline);
iter.remove();
break;
}
}
}
} | [
"private",
"void",
"deleteClass",
"(",
"Outline",
"outline",
",",
"JDefinedClass",
"clazz",
")",
"{",
"if",
"(",
"clazz",
".",
"parentContainer",
"(",
")",
".",
"isClass",
"(",
")",
")",
"{",
"// The candidate class is an inner class. Remove the class from its parent ... | Remove the given class from it's parent class or package it is defined in. | [
"Remove",
"the",
"given",
"class",
"from",
"it",
"s",
"parent",
"class",
"or",
"package",
"it",
"is",
"defined",
"in",
"."
] | train | https://github.com/dmak/jaxb-xew-plugin/blob/d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3/src/main/java/com/sun/tools/xjc/addon/xew/XmlElementWrapperPlugin.java#L928-L962 |
DDTH/ddth-commons | ddth-commons-core/src/main/java/com/github/ddth/commons/utils/IdGenerator.java | IdGenerator.extractTimestampMiniAscii | public static long extractTimestampMiniAscii(String idMiniAscii) throws NumberFormatException {
return extractTimestampMini(Long.parseLong(idMiniAscii, Character.MAX_RADIX));
} | java | public static long extractTimestampMiniAscii(String idMiniAscii) throws NumberFormatException {
return extractTimestampMini(Long.parseLong(idMiniAscii, Character.MAX_RADIX));
} | [
"public",
"static",
"long",
"extractTimestampMiniAscii",
"(",
"String",
"idMiniAscii",
")",
"throws",
"NumberFormatException",
"{",
"return",
"extractTimestampMini",
"(",
"Long",
".",
"parseLong",
"(",
"idMiniAscii",
",",
"Character",
".",
"MAX_RADIX",
")",
")",
";"... | Extracts the (UNIX) timestamp from a mini ASCII id (radix
{@link Character#MAX_RADIX}).
@param idMiniAscii
@return the UNIX timestamp (milliseconds)
@throws NumberFormatException | [
"Extracts",
"the",
"(",
"UNIX",
")",
"timestamp",
"from",
"a",
"mini",
"ASCII",
"id",
"(",
"radix",
"{",
"@link",
"Character#MAX_RADIX",
"}",
")",
"."
] | train | https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/IdGenerator.java#L430-L432 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/config/Config.java | Config.setMapConfigs | public Config setMapConfigs(Map<String, MapConfig> mapConfigs) {
this.mapConfigs.clear();
this.mapConfigs.putAll(mapConfigs);
for (final Entry<String, MapConfig> entry : this.mapConfigs.entrySet()) {
entry.getValue().setName(entry.getKey());
}
return this;
} | java | public Config setMapConfigs(Map<String, MapConfig> mapConfigs) {
this.mapConfigs.clear();
this.mapConfigs.putAll(mapConfigs);
for (final Entry<String, MapConfig> entry : this.mapConfigs.entrySet()) {
entry.getValue().setName(entry.getKey());
}
return this;
} | [
"public",
"Config",
"setMapConfigs",
"(",
"Map",
"<",
"String",
",",
"MapConfig",
">",
"mapConfigs",
")",
"{",
"this",
".",
"mapConfigs",
".",
"clear",
"(",
")",
";",
"this",
".",
"mapConfigs",
".",
"putAll",
"(",
"mapConfigs",
")",
";",
"for",
"(",
"f... | Sets the map of {@link com.hazelcast.core.IMap} configurations,
mapped by config name. The config name may be a pattern with which the
configuration will be obtained in the future.
@param mapConfigs the IMap configuration map to set
@return this config instance | [
"Sets",
"the",
"map",
"of",
"{",
"@link",
"com",
".",
"hazelcast",
".",
"core",
".",
"IMap",
"}",
"configurations",
"mapped",
"by",
"config",
"name",
".",
"The",
"config",
"name",
"may",
"be",
"a",
"pattern",
"with",
"which",
"the",
"configuration",
"wil... | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/Config.java#L495-L502 |
graknlabs/grakn | common/util/CommonUtil.java | CommonUtil.containsOnly | public static boolean containsOnly(Stream stream, long size){
long count = 0L;
Iterator it = stream.iterator();
while(it.hasNext()){
it.next();
if(++count > size) return false;
}
return size == count;
} | java | public static boolean containsOnly(Stream stream, long size){
long count = 0L;
Iterator it = stream.iterator();
while(it.hasNext()){
it.next();
if(++count > size) return false;
}
return size == count;
} | [
"public",
"static",
"boolean",
"containsOnly",
"(",
"Stream",
"stream",
",",
"long",
"size",
")",
"{",
"long",
"count",
"=",
"0L",
";",
"Iterator",
"it",
"=",
"stream",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")"... | Helper which lazily checks if a {@link Stream} contains the number specified
WARNING: This consumes the stream rendering it unusable afterwards
@param stream the {@link Stream} to check the count against
@param size the expected number of elements in the stream
@return true if the expected size is found | [
"Helper",
"which",
"lazily",
"checks",
"if",
"a",
"{",
"@link",
"Stream",
"}",
"contains",
"the",
"number",
"specified",
"WARNING",
":",
"This",
"consumes",
"the",
"stream",
"rendering",
"it",
"unusable",
"afterwards"
] | train | https://github.com/graknlabs/grakn/blob/6aaee75ea846202474d591f8809d62028262fac5/common/util/CommonUtil.java#L71-L81 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/spec/ScanSpec.java | ScanSpec.withValueMap | public ScanSpec withValueMap(Map<String, Object> valueMap) {
if (valueMap == null)
this.valueMap = null;
else
this.valueMap = Collections.unmodifiableMap(new LinkedHashMap<String, Object>(valueMap));
return this;
} | java | public ScanSpec withValueMap(Map<String, Object> valueMap) {
if (valueMap == null)
this.valueMap = null;
else
this.valueMap = Collections.unmodifiableMap(new LinkedHashMap<String, Object>(valueMap));
return this;
} | [
"public",
"ScanSpec",
"withValueMap",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"valueMap",
")",
"{",
"if",
"(",
"valueMap",
"==",
"null",
")",
"this",
".",
"valueMap",
"=",
"null",
";",
"else",
"this",
".",
"valueMap",
"=",
"Collections",
".",
"u... | Applicable only when an expression has been specified. Used to
specify the actual values for the attribute-value placeholders.
@see ScanRequest#withExpressionAttributeValues(Map) | [
"Applicable",
"only",
"when",
"an",
"expression",
"has",
"been",
"specified",
".",
"Used",
"to",
"specify",
"the",
"actual",
"values",
"for",
"the",
"attribute",
"-",
"value",
"placeholders",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/spec/ScanSpec.java#L184-L190 |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.objectDeepCopyWithBlackList | public static <T> T objectDeepCopyWithBlackList(Object from, Object to, Class<?> baseClass, String... blockFields) {
List<String> bFields = getDeclaredFields(baseClass);
for (String blockField : blockFields) {
bFields.add(blockField);
}
return objectDeepCopyWithBlackList(from, to, bFields.toArray(new String[bFields.size()]));
} | java | public static <T> T objectDeepCopyWithBlackList(Object from, Object to, Class<?> baseClass, String... blockFields) {
List<String> bFields = getDeclaredFields(baseClass);
for (String blockField : blockFields) {
bFields.add(blockField);
}
return objectDeepCopyWithBlackList(from, to, bFields.toArray(new String[bFields.size()]));
} | [
"public",
"static",
"<",
"T",
">",
"T",
"objectDeepCopyWithBlackList",
"(",
"Object",
"from",
",",
"Object",
"to",
",",
"Class",
"<",
"?",
">",
"baseClass",
",",
"String",
"...",
"blockFields",
")",
"{",
"List",
"<",
"String",
">",
"bFields",
"=",
"getDe... | Object deep copy with black list t.
@param <T> the type parameter
@param from the from
@param to the to
@param baseClass the base class
@param blockFields the block fields
@return the t | [
"Object",
"deep",
"copy",
"with",
"black",
"list",
"t",
"."
] | train | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L435-L444 |
hawkular/hawkular-apm | api/src/main/java/org/hawkular/apm/api/model/config/CollectorConfiguration.java | CollectorConfiguration.getProperty | public String getProperty(String name, String def) {
String ret=PropertyUtil.getProperty(name, null);
if (ret == null) {
if (getProperties().containsKey(name)) {
ret = getProperties().get(name);
} else {
ret = def;
}
}
if (log.isLoggable(Level.FINEST)) {
log.finest("Get property '"+name+"' (default="+def+") = "+ret);
}
return ret;
} | java | public String getProperty(String name, String def) {
String ret=PropertyUtil.getProperty(name, null);
if (ret == null) {
if (getProperties().containsKey(name)) {
ret = getProperties().get(name);
} else {
ret = def;
}
}
if (log.isLoggable(Level.FINEST)) {
log.finest("Get property '"+name+"' (default="+def+") = "+ret);
}
return ret;
} | [
"public",
"String",
"getProperty",
"(",
"String",
"name",
",",
"String",
"def",
")",
"{",
"String",
"ret",
"=",
"PropertyUtil",
".",
"getProperty",
"(",
"name",
",",
"null",
")",
";",
"if",
"(",
"ret",
"==",
"null",
")",
"{",
"if",
"(",
"getProperties"... | This method returns the property associated with the supplied name. The
system properties will be checked first, and if not available, then the
collector configuration properties.
@param name The name of the required property
@param def The optional default value
@return The property value, or if not found then the default | [
"This",
"method",
"returns",
"the",
"property",
"associated",
"with",
"the",
"supplied",
"name",
".",
"The",
"system",
"properties",
"will",
"be",
"checked",
"first",
"and",
"if",
"not",
"available",
"then",
"the",
"collector",
"configuration",
"properties",
"."... | train | https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/api/src/main/java/org/hawkular/apm/api/model/config/CollectorConfiguration.java#L72-L87 |
aspectran/aspectran | core/src/main/java/com/aspectran/core/util/BeanDescriptor.java | BeanDescriptor.getSetterAnnotation | @SuppressWarnings("unchecked")
public <T extends Annotation> T getSetterAnnotation(Method method, Class<T> annotationType) {
T annotation = method.getAnnotation(annotationType);
if (annotation != null) {
return annotation;
}
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
if (parameterAnnotations.length > 0 ) {
for (Annotation anno : parameterAnnotations[0]) {
if (annotationType.isInstance(anno)) {
return (T)anno;
}
}
}
return null;
} | java | @SuppressWarnings("unchecked")
public <T extends Annotation> T getSetterAnnotation(Method method, Class<T> annotationType) {
T annotation = method.getAnnotation(annotationType);
if (annotation != null) {
return annotation;
}
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
if (parameterAnnotations.length > 0 ) {
for (Annotation anno : parameterAnnotations[0]) {
if (annotationType.isInstance(anno)) {
return (T)anno;
}
}
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
"extends",
"Annotation",
">",
"T",
"getSetterAnnotation",
"(",
"Method",
"method",
",",
"Class",
"<",
"T",
">",
"annotationType",
")",
"{",
"T",
"annotation",
"=",
"method",
".",
"getAnn... | Invokes the annotation of the given type.
@param method the given setter method
@param annotationType the annotation type to look for
@param <T> the annotation type
@return the annotation object, or null if not found | [
"Invokes",
"the",
"annotation",
"of",
"the",
"given",
"type",
"."
] | train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/BeanDescriptor.java#L325-L340 |
Azure/azure-sdk-for-java | policyinsights/resource-manager/v2018_04_04/src/main/java/com/microsoft/azure/management/policyinsights/v2018_04_04/implementation/PolicyStatesInner.java | PolicyStatesInner.listQueryResultsForManagementGroupAsync | public Observable<PolicyStatesQueryResultsInner> listQueryResultsForManagementGroupAsync(PolicyStatesResource policyStatesResource, String managementGroupName) {
return listQueryResultsForManagementGroupWithServiceResponseAsync(policyStatesResource, managementGroupName).map(new Func1<ServiceResponse<PolicyStatesQueryResultsInner>, PolicyStatesQueryResultsInner>() {
@Override
public PolicyStatesQueryResultsInner call(ServiceResponse<PolicyStatesQueryResultsInner> response) {
return response.body();
}
});
} | java | public Observable<PolicyStatesQueryResultsInner> listQueryResultsForManagementGroupAsync(PolicyStatesResource policyStatesResource, String managementGroupName) {
return listQueryResultsForManagementGroupWithServiceResponseAsync(policyStatesResource, managementGroupName).map(new Func1<ServiceResponse<PolicyStatesQueryResultsInner>, PolicyStatesQueryResultsInner>() {
@Override
public PolicyStatesQueryResultsInner call(ServiceResponse<PolicyStatesQueryResultsInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"PolicyStatesQueryResultsInner",
">",
"listQueryResultsForManagementGroupAsync",
"(",
"PolicyStatesResource",
"policyStatesResource",
",",
"String",
"managementGroupName",
")",
"{",
"return",
"listQueryResultsForManagementGroupWithServiceResponseAsync",
"... | Queries policy states for the resources under the management group.
@param policyStatesResource The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). Possible values include: 'default', 'latest'
@param managementGroupName Management group name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PolicyStatesQueryResultsInner object | [
"Queries",
"policy",
"states",
"for",
"the",
"resources",
"under",
"the",
"management",
"group",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/policyinsights/resource-manager/v2018_04_04/src/main/java/com/microsoft/azure/management/policyinsights/v2018_04_04/implementation/PolicyStatesInner.java#L164-L171 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/LoadBalancerProbesInner.java | LoadBalancerProbesInner.getAsync | public Observable<ProbeInner> getAsync(String resourceGroupName, String loadBalancerName, String probeName) {
return getWithServiceResponseAsync(resourceGroupName, loadBalancerName, probeName).map(new Func1<ServiceResponse<ProbeInner>, ProbeInner>() {
@Override
public ProbeInner call(ServiceResponse<ProbeInner> response) {
return response.body();
}
});
} | java | public Observable<ProbeInner> getAsync(String resourceGroupName, String loadBalancerName, String probeName) {
return getWithServiceResponseAsync(resourceGroupName, loadBalancerName, probeName).map(new Func1<ServiceResponse<ProbeInner>, ProbeInner>() {
@Override
public ProbeInner call(ServiceResponse<ProbeInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ProbeInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"loadBalancerName",
",",
"String",
"probeName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"loadBalancerName",
",",
"p... | Gets load balancer probe.
@param resourceGroupName The name of the resource group.
@param loadBalancerName The name of the load balancer.
@param probeName The name of the probe.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ProbeInner object | [
"Gets",
"load",
"balancer",
"probe",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/LoadBalancerProbesInner.java#L233-L240 |
jcuda/jnvgraph | JNvgraphJava/src/main/java/jcuda/jnvgraph/JNvgraph.java | JNvgraph.nvgraphWidestPath | public static int nvgraphWidestPath(
nvgraphHandle handle,
nvgraphGraphDescr descrG,
long weight_index,
Pointer source_vert,
long widest_path_index)
{
return checkResult(nvgraphWidestPathNative(handle, descrG, weight_index, source_vert, widest_path_index));
} | java | public static int nvgraphWidestPath(
nvgraphHandle handle,
nvgraphGraphDescr descrG,
long weight_index,
Pointer source_vert,
long widest_path_index)
{
return checkResult(nvgraphWidestPathNative(handle, descrG, weight_index, source_vert, widest_path_index));
} | [
"public",
"static",
"int",
"nvgraphWidestPath",
"(",
"nvgraphHandle",
"handle",
",",
"nvgraphGraphDescr",
"descrG",
",",
"long",
"weight_index",
",",
"Pointer",
"source_vert",
",",
"long",
"widest_path_index",
")",
"{",
"return",
"checkResult",
"(",
"nvgraphWidestPath... | nvGRAPH WidestPath
Find widest path potential from source_index to every other vertices. | [
"nvGRAPH",
"WidestPath",
"Find",
"widest",
"path",
"potential",
"from",
"source_index",
"to",
"every",
"other",
"vertices",
"."
] | train | https://github.com/jcuda/jnvgraph/blob/2c6bd7c58edac181753bacf30af2cceeb1989a78/JNvgraphJava/src/main/java/jcuda/jnvgraph/JNvgraph.java#L625-L633 |
agmip/agmip-common-functions | src/main/java/org/agmip/functions/PTSaxton2006.java | PTSaxton2006.getSLLL | public static String getSLLL(String[] soilParas) {
if (soilParas != null && soilParas.length >= 3) {
return divide(calcMoisture1500Kpa(soilParas[0], soilParas[1], soilParas[2]), "100", 3);
} else {
return null;
}
} | java | public static String getSLLL(String[] soilParas) {
if (soilParas != null && soilParas.length >= 3) {
return divide(calcMoisture1500Kpa(soilParas[0], soilParas[1], soilParas[2]), "100", 3);
} else {
return null;
}
} | [
"public",
"static",
"String",
"getSLLL",
"(",
"String",
"[",
"]",
"soilParas",
")",
"{",
"if",
"(",
"soilParas",
"!=",
"null",
"&&",
"soilParas",
".",
"length",
">=",
"3",
")",
"{",
"return",
"divide",
"(",
"calcMoisture1500Kpa",
"(",
"soilParas",
"[",
"... | For calculating SLLL
@param soilParas should include 1. Sand weight percentage by layer
([0,100]%), 2. Clay weight percentage by layer ([0,100]%), 3. Organic
matter weight percentage by layer ([0,100]%), (= SLOC * 1.72)
@return Soil water, lower limit, fraction | [
"For",
"calculating",
"SLLL"
] | train | https://github.com/agmip/agmip-common-functions/blob/4efa3042178841b026ca6fba9c96da02fbfb9a8e/src/main/java/org/agmip/functions/PTSaxton2006.java#L31-L37 |
symphonyoss/messageml-utils | src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java | Element.buildNode | private void buildNode(MessageMLParser context, org.w3c.dom.Node node) throws InvalidInputException, ProcessingException {
switch (node.getNodeType()) {
case org.w3c.dom.Node.TEXT_NODE:
buildText((Text) node);
break;
case org.w3c.dom.Node.ELEMENT_NODE:
buildElement(context, (org.w3c.dom.Element) node);
break;
default:
throw new InvalidInputException("Invalid element \"" + node.getNodeName() + "\"");
}
} | java | private void buildNode(MessageMLParser context, org.w3c.dom.Node node) throws InvalidInputException, ProcessingException {
switch (node.getNodeType()) {
case org.w3c.dom.Node.TEXT_NODE:
buildText((Text) node);
break;
case org.w3c.dom.Node.ELEMENT_NODE:
buildElement(context, (org.w3c.dom.Element) node);
break;
default:
throw new InvalidInputException("Invalid element \"" + node.getNodeName() + "\"");
}
} | [
"private",
"void",
"buildNode",
"(",
"MessageMLParser",
"context",
",",
"org",
".",
"w3c",
".",
"dom",
".",
"Node",
"node",
")",
"throws",
"InvalidInputException",
",",
"ProcessingException",
"{",
"switch",
"(",
"node",
".",
"getNodeType",
"(",
")",
")",
"{"... | Build a text node or a MessageML element based on the provided DOM node. | [
"Build",
"a",
"text",
"node",
"or",
"a",
"MessageML",
"element",
"based",
"on",
"the",
"provided",
"DOM",
"node",
"."
] | train | https://github.com/symphonyoss/messageml-utils/blob/68daed66267062d144a05b3ee9a9bf4b715e3f95/src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java#L117-L131 |
js-lib-com/commons | src/main/java/js/lang/Config.java | Config.setProperty | public void setProperty(String name, String value)
{
Params.notNullOrEmpty(name, "Property name");
Params.notEmpty(value, "Property value");
if(value != null) {
properties.setProperty(name, value);
}
} | java | public void setProperty(String name, String value)
{
Params.notNullOrEmpty(name, "Property name");
Params.notEmpty(value, "Property value");
if(value != null) {
properties.setProperty(name, value);
}
} | [
"public",
"void",
"setProperty",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"Params",
".",
"notNullOrEmpty",
"(",
"name",
",",
"\"Property name\"",
")",
";",
"Params",
".",
"notEmpty",
"(",
"value",
",",
"\"Property value\"",
")",
";",
"if",
... | Set configuration object string property. If property already exists overwrite old value. If <code>value</code>
argument is null this setter does nothing.
@param name property name,
@param value property value, null ignored.
@throws IllegalArgumentException if <code>name</code> argument is null or empty.
@throws IllegalArgumentException if <code>value</code> argument is empty. | [
"Set",
"configuration",
"object",
"string",
"property",
".",
"If",
"property",
"already",
"exists",
"overwrite",
"old",
"value",
".",
"If",
"<code",
">",
"value<",
"/",
"code",
">",
"argument",
"is",
"null",
"this",
"setter",
"does",
"nothing",
"."
] | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/lang/Config.java#L148-L155 |
line/armeria | core/src/main/java/com/linecorp/armeria/client/Endpoint.java | Endpoint.of | public static Endpoint of(String host, int port) {
validatePort("port", port);
return create(host, port);
} | java | public static Endpoint of(String host, int port) {
validatePort("port", port);
return create(host, port);
} | [
"public",
"static",
"Endpoint",
"of",
"(",
"String",
"host",
",",
"int",
"port",
")",
"{",
"validatePort",
"(",
"\"port\"",
",",
"port",
")",
";",
"return",
"create",
"(",
"host",
",",
"port",
")",
";",
"}"
] | Creates a new host {@link Endpoint}.
@throws IllegalArgumentException if {@code host} is not a valid host name or
{@code port} is not a valid port number | [
"Creates",
"a",
"new",
"host",
"{",
"@link",
"Endpoint",
"}",
"."
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/client/Endpoint.java#L91-L94 |
wcm-io/wcm-io-tooling | commons/crx-packmgr-helper/src/main/java/io/wcm/tooling/commons/packmgr/PackageManagerHelper.java | PackageManagerHelper.executeHttpCallWithRetry | private <T> T executeHttpCallWithRetry(HttpCall<T> call, int runCount) {
try {
return call.execute();
}
catch (PackageManagerHttpActionException ex) {
// retry again if configured so...
if (runCount < props.getRetryCount()) {
log.info("ERROR: " + ex.getMessage());
log.debug("HTTP call failed.", ex);
log.info("---------------");
StringBuilder msg = new StringBuilder();
msg.append("HTTP call failed, try again (" + (runCount + 1) + "/" + props.getRetryCount() + ")");
if (props.getRetryDelaySec() > 0) {
msg.append(" after " + props.getRetryDelaySec() + " second(s)");
}
msg.append("...");
log.info(msg);
if (props.getRetryDelaySec() > 0) {
try {
Thread.sleep(props.getRetryDelaySec() * DateUtils.MILLIS_PER_SECOND);
}
catch (InterruptedException ex1) {
// ignore
}
}
return executeHttpCallWithRetry(call, runCount + 1);
}
else {
throw ex;
}
}
} | java | private <T> T executeHttpCallWithRetry(HttpCall<T> call, int runCount) {
try {
return call.execute();
}
catch (PackageManagerHttpActionException ex) {
// retry again if configured so...
if (runCount < props.getRetryCount()) {
log.info("ERROR: " + ex.getMessage());
log.debug("HTTP call failed.", ex);
log.info("---------------");
StringBuilder msg = new StringBuilder();
msg.append("HTTP call failed, try again (" + (runCount + 1) + "/" + props.getRetryCount() + ")");
if (props.getRetryDelaySec() > 0) {
msg.append(" after " + props.getRetryDelaySec() + " second(s)");
}
msg.append("...");
log.info(msg);
if (props.getRetryDelaySec() > 0) {
try {
Thread.sleep(props.getRetryDelaySec() * DateUtils.MILLIS_PER_SECOND);
}
catch (InterruptedException ex1) {
// ignore
}
}
return executeHttpCallWithRetry(call, runCount + 1);
}
else {
throw ex;
}
}
} | [
"private",
"<",
"T",
">",
"T",
"executeHttpCallWithRetry",
"(",
"HttpCall",
"<",
"T",
">",
"call",
",",
"int",
"runCount",
")",
"{",
"try",
"{",
"return",
"call",
".",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"PackageManagerHttpActionException",
"ex",
... | Execute HTTP call with automatic retry as configured for the MOJO.
@param call HTTP call
@param runCount Number of runs this call was already executed | [
"Execute",
"HTTP",
"call",
"with",
"automatic",
"retry",
"as",
"configured",
"for",
"the",
"MOJO",
"."
] | train | https://github.com/wcm-io/wcm-io-tooling/blob/1abcd01dd3ad4cc248f03b431f929573d84fa9b4/commons/crx-packmgr-helper/src/main/java/io/wcm/tooling/commons/packmgr/PackageManagerHelper.java#L180-L212 |
ravendb/ravendb-jvm-client | src/main/java/net/ravendb/client/documents/subscriptions/DocumentSubscriptions.java | DocumentSubscriptions.createForRevisions | public <T> String createForRevisions(Class<T> clazz, SubscriptionCreationOptions options) {
return createForRevisions(clazz, options, null);
} | java | public <T> String createForRevisions(Class<T> clazz, SubscriptionCreationOptions options) {
return createForRevisions(clazz, options, null);
} | [
"public",
"<",
"T",
">",
"String",
"createForRevisions",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"SubscriptionCreationOptions",
"options",
")",
"{",
"return",
"createForRevisions",
"(",
"clazz",
",",
"options",
",",
"null",
")",
";",
"}"
] | Creates a data subscription in a database. The subscription will expose all documents that match the specified subscription options for a given type.
@param options Subscription options
@param clazz Document class
@param <T> Document class
@return created subscription | [
"Creates",
"a",
"data",
"subscription",
"in",
"a",
"database",
".",
"The",
"subscription",
"will",
"expose",
"all",
"documents",
"that",
"match",
"the",
"specified",
"subscription",
"options",
"for",
"a",
"given",
"type",
"."
] | train | https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/subscriptions/DocumentSubscriptions.java#L108-L110 |
twitter/scrooge | scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java | AbstractMavenScroogeMojo.extractThriftFile | private File extractThriftFile(String artifactId, String fileName, Set<File> thriftFiles) {
for (File thriftFile : thriftFiles) {
boolean fileFound = false;
if (fileName.equals(thriftFile.getName())) {
for (String pathComponent : thriftFile.getPath().split(File.separator)) {
if (pathComponent.equals(artifactId)) {
fileFound = true;
}
}
}
if (fileFound) {
return thriftFile;
}
}
return null;
} | java | private File extractThriftFile(String artifactId, String fileName, Set<File> thriftFiles) {
for (File thriftFile : thriftFiles) {
boolean fileFound = false;
if (fileName.equals(thriftFile.getName())) {
for (String pathComponent : thriftFile.getPath().split(File.separator)) {
if (pathComponent.equals(artifactId)) {
fileFound = true;
}
}
}
if (fileFound) {
return thriftFile;
}
}
return null;
} | [
"private",
"File",
"extractThriftFile",
"(",
"String",
"artifactId",
",",
"String",
"fileName",
",",
"Set",
"<",
"File",
">",
"thriftFiles",
")",
"{",
"for",
"(",
"File",
"thriftFile",
":",
"thriftFiles",
")",
"{",
"boolean",
"fileFound",
"=",
"false",
";",
... | Picks out a File from `thriftFiles` corresponding to a given artifact ID
and file name. Returns null if `artifactId` and `fileName` do not map to a
thrift file path.
@parameter artifactId The artifact ID of which to look up the path
@parameter fileName the name of the thrift file for which to extract a path
@parameter thriftFiles The set of Thrift files in which to lookup the
artifact ID.
@return The path of the directory containing Thrift files for the given
artifact ID. null if artifact ID not found. | [
"Picks",
"out",
"a",
"File",
"from",
"thriftFiles",
"corresponding",
"to",
"a",
"given",
"artifact",
"ID",
"and",
"file",
"name",
".",
"Returns",
"null",
"if",
"artifactId",
"and",
"fileName",
"do",
"not",
"map",
"to",
"a",
"thrift",
"file",
"path",
"."
] | train | https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L228-L244 |
exoplatform/jcr | exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/artifact/rest/RESTArtifactLoaderService.java | RESTArtifactLoaderService.getRootNodeList | @GET
public Response getRootNodeList(final @Context UriInfo uriInfo, final @QueryParam("view") String view,
final @QueryParam("gadget") String gadget)
{
return getResource("", uriInfo, view, gadget);
} | java | @GET
public Response getRootNodeList(final @Context UriInfo uriInfo, final @QueryParam("view") String view,
final @QueryParam("gadget") String gadget)
{
return getResource("", uriInfo, view, gadget);
} | [
"@",
"GET",
"public",
"Response",
"getRootNodeList",
"(",
"final",
"@",
"Context",
"UriInfo",
"uriInfo",
",",
"final",
"@",
"QueryParam",
"(",
"\"view\"",
")",
"String",
"view",
",",
"final",
"@",
"QueryParam",
"(",
"\"gadget\"",
")",
"String",
"gadget",
")"... | Browsing of root node of Maven repository.
@param uriInfo
@param view
@param gadget
@return {@link Response}. | [
"Browsing",
"of",
"root",
"node",
"of",
"Maven",
"repository",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/artifact/rest/RESTArtifactLoaderService.java#L254-L259 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/media/MediaClient.java | MediaClient.getPipeline | public GetPipelineResponse getPipeline(GetPipelineRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getPipelineName(),
"The parameter pipelineName should NOT be null or empty string.");
InternalRequest internalRequest =
createRequest(HttpMethodName.GET, request, PIPELINE, request.getPipelineName());
return invokeHttpClient(internalRequest, GetPipelineResponse.class);
} | java | public GetPipelineResponse getPipeline(GetPipelineRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getPipelineName(),
"The parameter pipelineName should NOT be null or empty string.");
InternalRequest internalRequest =
createRequest(HttpMethodName.GET, request, PIPELINE, request.getPipelineName());
return invokeHttpClient(internalRequest, GetPipelineResponse.class);
} | [
"public",
"GetPipelineResponse",
"getPipeline",
"(",
"GetPipelineRequest",
"request",
")",
"{",
"checkNotNull",
"(",
"request",
",",
"\"The parameter request should NOT be null.\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getPipelineName",
"(",
")",
",",
... | Gets a pipeline with the specified pipeline name.
@param request The request object containing all options for getting a pipelines.
@return The information of your pipeline. | [
"Gets",
"a",
"pipeline",
"with",
"the",
"specified",
"pipeline",
"name",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/media/MediaClient.java#L632-L640 |
raydac/java-binary-block-parser | jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java | JBBPDslBuilder.StringArray | public JBBPDslBuilder StringArray(final String name, final String sizeExpression) {
final Item item = new Item(BinType.STRING_ARRAY, name, this.byteOrder);
item.sizeExpression = assertExpressionChars(sizeExpression);
this.addItem(item);
return this;
} | java | public JBBPDslBuilder StringArray(final String name, final String sizeExpression) {
final Item item = new Item(BinType.STRING_ARRAY, name, this.byteOrder);
item.sizeExpression = assertExpressionChars(sizeExpression);
this.addItem(item);
return this;
} | [
"public",
"JBBPDslBuilder",
"StringArray",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"sizeExpression",
")",
"{",
"final",
"Item",
"item",
"=",
"new",
"Item",
"(",
"BinType",
".",
"STRING_ARRAY",
",",
"name",
",",
"this",
".",
"byteOrder",
")",
... | Add named string array which size calculated through expression.
@param name name of field, can be null for anonymous
@param sizeExpression expression to calculate size, must not be null
@return the builder instance, must not be null | [
"Add",
"named",
"string",
"array",
"which",
"size",
"calculated",
"through",
"expression",
"."
] | train | https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java#L1421-L1426 |
threerings/narya | core/src/main/java/com/threerings/io/ObjectInputStream.java | ObjectInputStream.addTranslation | public void addTranslation (String oldname, String newname)
{
if (_translations == null) {
_translations = Maps.newHashMap();
}
_translations.put(oldname, newname);
} | java | public void addTranslation (String oldname, String newname)
{
if (_translations == null) {
_translations = Maps.newHashMap();
}
_translations.put(oldname, newname);
} | [
"public",
"void",
"addTranslation",
"(",
"String",
"oldname",
",",
"String",
"newname",
")",
"{",
"if",
"(",
"_translations",
"==",
"null",
")",
"{",
"_translations",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"}",
"_translations",
".",
"put",
"(",
"... | Configures this object input stream with a mapping from an old class name to a new
one. Serialized instances of the old class name will use the new class name when
unserializing. | [
"Configures",
"this",
"object",
"input",
"stream",
"with",
"a",
"mapping",
"from",
"an",
"old",
"class",
"name",
"to",
"a",
"new",
"one",
".",
"Serialized",
"instances",
"of",
"the",
"old",
"class",
"name",
"will",
"use",
"the",
"new",
"class",
"name",
"... | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/ObjectInputStream.java#L67-L73 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/ResourceBundle.java | ResourceBundle.strip | private static Locale strip(Locale locale) {
String language = locale.getLanguage();
String country = locale.getCountry();
String variant = locale.getVariant();
if (!variant.isEmpty()) {
variant = "";
} else if (!country.isEmpty()) {
country = "";
} else if (!language.isEmpty()) {
language = "";
} else {
return null;
}
return new Locale(language, country, variant);
} | java | private static Locale strip(Locale locale) {
String language = locale.getLanguage();
String country = locale.getCountry();
String variant = locale.getVariant();
if (!variant.isEmpty()) {
variant = "";
} else if (!country.isEmpty()) {
country = "";
} else if (!language.isEmpty()) {
language = "";
} else {
return null;
}
return new Locale(language, country, variant);
} | [
"private",
"static",
"Locale",
"strip",
"(",
"Locale",
"locale",
")",
"{",
"String",
"language",
"=",
"locale",
".",
"getLanguage",
"(",
")",
";",
"String",
"country",
"=",
"locale",
".",
"getCountry",
"(",
")",
";",
"String",
"variant",
"=",
"locale",
"... | Returns a locale with the most-specific field removed, or null if this
locale had an empty language, country and variant. | [
"Returns",
"a",
"locale",
"with",
"the",
"most",
"-",
"specific",
"field",
"removed",
"or",
"null",
"if",
"this",
"locale",
"had",
"an",
"empty",
"language",
"country",
"and",
"variant",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/ResourceBundle.java#L588-L602 |
iig-uni-freiburg/SEWOL | ext/org/deckfour/xes/extension/std/XCostExtension.java | XCostExtension.assignDrivers | public void assignDrivers(XEvent event, Map<String, String> drivers) {
XCostDriver.instance().assignValues(event, drivers);
} | java | public void assignDrivers(XEvent event, Map<String, String> drivers) {
XCostDriver.instance().assignValues(event, drivers);
} | [
"public",
"void",
"assignDrivers",
"(",
"XEvent",
"event",
",",
"Map",
"<",
"String",
",",
"String",
">",
"drivers",
")",
"{",
"XCostDriver",
".",
"instance",
"(",
")",
".",
"assignValues",
"(",
"event",
",",
"drivers",
")",
";",
"}"
] | Assigns (to the given event) multiple cost drivers given their key. Note
that as a side effect this method creates attributes when it does not
find an attribute with the proper key.
@see #assignAmounts(XEvent, Map)
@param event
Event to assign the cost drivers to.
@param drivers
Mapping from keys to cost drivers which are to be assigned. | [
"Assigns",
"(",
"to",
"the",
"given",
"event",
")",
"multiple",
"cost",
"drivers",
"given",
"their",
"key",
".",
"Note",
"that",
"as",
"a",
"side",
"effect",
"this",
"method",
"creates",
"attributes",
"when",
"it",
"does",
"not",
"find",
"an",
"attribute",... | train | https://github.com/iig-uni-freiburg/SEWOL/blob/e791cb07a6e62ecf837d760d58a25f32fbf6bbca/ext/org/deckfour/xes/extension/std/XCostExtension.java#L822-L824 |
palatable/lambda | src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java | HMap.hMap | public static <V1, V2> HMap hMap(TypeSafeKey<?, V1> key1, V1 value1,
TypeSafeKey<?, V2> key2, V2 value2) {
return singletonHMap(key1, value1).put(key2, value2);
} | java | public static <V1, V2> HMap hMap(TypeSafeKey<?, V1> key1, V1 value1,
TypeSafeKey<?, V2> key2, V2 value2) {
return singletonHMap(key1, value1).put(key2, value2);
} | [
"public",
"static",
"<",
"V1",
",",
"V2",
">",
"HMap",
"hMap",
"(",
"TypeSafeKey",
"<",
"?",
",",
"V1",
">",
"key1",
",",
"V1",
"value1",
",",
"TypeSafeKey",
"<",
"?",
",",
"V2",
">",
"key2",
",",
"V2",
"value2",
")",
"{",
"return",
"singletonHMap"... | Static factory method for creating an HMap from two given associations.
@param key1 the first mapped key
@param value1 the value mapped at key1
@param key2 the second mapped key
@param value2 the value mapped at key2
@param <V1> value1's type
@param <V2> value2's type
@return an HMap with the given associations | [
"Static",
"factory",
"method",
"for",
"creating",
"an",
"HMap",
"from",
"two",
"given",
"associations",
"."
] | train | https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java#L212-L215 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java | FormatUtil.formatTimeDelta | public static String formatTimeDelta(long time, CharSequence sep) {
final StringBuilder sb = new StringBuilder();
final Formatter fmt = new Formatter(sb);
for(int i = TIME_UNIT_SIZES.length - 1; i >= 0; --i) {
// We do not include ms if we are in the order of minutes.
if(i == 0 && sb.length() > 4) {
continue;
}
// Separator
if(sb.length() > 0) {
sb.append(sep);
}
final long acValue = time / TIME_UNIT_SIZES[i];
time = time % TIME_UNIT_SIZES[i];
if(!(acValue == 0 && sb.length() == 0)) {
fmt.format("%0" + TIME_UNIT_DIGITS[i] + "d%s", Long.valueOf(acValue), TIME_UNIT_NAMES[i]);
}
}
fmt.close();
return sb.toString();
} | java | public static String formatTimeDelta(long time, CharSequence sep) {
final StringBuilder sb = new StringBuilder();
final Formatter fmt = new Formatter(sb);
for(int i = TIME_UNIT_SIZES.length - 1; i >= 0; --i) {
// We do not include ms if we are in the order of minutes.
if(i == 0 && sb.length() > 4) {
continue;
}
// Separator
if(sb.length() > 0) {
sb.append(sep);
}
final long acValue = time / TIME_UNIT_SIZES[i];
time = time % TIME_UNIT_SIZES[i];
if(!(acValue == 0 && sb.length() == 0)) {
fmt.format("%0" + TIME_UNIT_DIGITS[i] + "d%s", Long.valueOf(acValue), TIME_UNIT_NAMES[i]);
}
}
fmt.close();
return sb.toString();
} | [
"public",
"static",
"String",
"formatTimeDelta",
"(",
"long",
"time",
",",
"CharSequence",
"sep",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"Formatter",
"fmt",
"=",
"new",
"Formatter",
"(",
"sb",
")",
";... | Formats a time delta in human readable format.
@param time time delta in ms
@return Formatted string | [
"Formats",
"a",
"time",
"delta",
"in",
"human",
"readable",
"format",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L935-L956 |
splitwise/TokenAutoComplete | library/src/main/java/com/tokenautocomplete/TokenCompleteTextView.java | TokenCompleteTextView.setPrefix | @SuppressWarnings("SameParameterValue")
public void setPrefix(CharSequence prefix, int color) {
SpannableString spannablePrefix = new SpannableString(prefix);
spannablePrefix.setSpan(new ForegroundColorSpan(color), 0, spannablePrefix.length(), 0);
setPrefix(spannablePrefix);
} | java | @SuppressWarnings("SameParameterValue")
public void setPrefix(CharSequence prefix, int color) {
SpannableString spannablePrefix = new SpannableString(prefix);
spannablePrefix.setSpan(new ForegroundColorSpan(color), 0, spannablePrefix.length(), 0);
setPrefix(spannablePrefix);
} | [
"@",
"SuppressWarnings",
"(",
"\"SameParameterValue\"",
")",
"public",
"void",
"setPrefix",
"(",
"CharSequence",
"prefix",
",",
"int",
"color",
")",
"{",
"SpannableString",
"spannablePrefix",
"=",
"new",
"SpannableString",
"(",
"prefix",
")",
";",
"spannablePrefix",... | <p>You can get a color integer either using
{@link android.support.v4.content.ContextCompat#getColor(android.content.Context, int)}
or with {@link android.graphics.Color#parseColor(String)}.</p>
<p>{@link android.graphics.Color#parseColor(String)}
accepts these formats (copied from android.graphics.Color):
You can use: '#RRGGBB', '#AARRGGBB'
or one of the following names: 'red', 'blue', 'green', 'black', 'white',
'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray', 'grey',
'lightgrey', 'darkgrey', 'aqua', 'fuchsia', 'lime', 'maroon', 'navy',
'olive', 'purple', 'silver', 'teal'.</p>
@param prefix prefix
@param color A single color value in the form 0xAARRGGBB. | [
"<p",
">",
"You",
"can",
"get",
"a",
"color",
"integer",
"either",
"using",
"{",
"@link",
"android",
".",
"support",
".",
"v4",
".",
"content",
".",
"ContextCompat#getColor",
"(",
"android",
".",
"content",
".",
"Context",
"int",
")",
"}",
"or",
"with",
... | train | https://github.com/splitwise/TokenAutoComplete/blob/3f92f90c4c42efc7129d91cbc3d3ec2d1a7bfac5/library/src/main/java/com/tokenautocomplete/TokenCompleteTextView.java#L311-L316 |
hortonworks/dstream | dstream-api/src/main/java/io/dstream/utils/ExecutionResultUtils.java | ExecutionResultUtils.printResults | public static <T> void printResults(Stream<Stream<T>> resultPartitionsStream, boolean printPartitionSeparator){
AtomicInteger partitionCounter = new AtomicInteger();
resultPartitionsStream.forEach(resultPartition -> {
if (printPartitionSeparator){
System.out.println("\n=> PARTITION:" + partitionCounter.getAndIncrement());
}
resultPartition.forEach(System.out::println);
});
} | java | public static <T> void printResults(Stream<Stream<T>> resultPartitionsStream, boolean printPartitionSeparator){
AtomicInteger partitionCounter = new AtomicInteger();
resultPartitionsStream.forEach(resultPartition -> {
if (printPartitionSeparator){
System.out.println("\n=> PARTITION:" + partitionCounter.getAndIncrement());
}
resultPartition.forEach(System.out::println);
});
} | [
"public",
"static",
"<",
"T",
">",
"void",
"printResults",
"(",
"Stream",
"<",
"Stream",
"<",
"T",
">",
">",
"resultPartitionsStream",
",",
"boolean",
"printPartitionSeparator",
")",
"{",
"AtomicInteger",
"partitionCounter",
"=",
"new",
"AtomicInteger",
"(",
")"... | Prints the resultPartitionsStream to the standard out, also printing partition separator at the
start of each result partition if 'printPartitionSeparator' is set to <i>true</i>.
@param resultPartitionsStream
@param printPartitionSeparator | [
"Prints",
"the",
"resultPartitionsStream",
"to",
"the",
"standard",
"out",
"also",
"printing",
"partition",
"separator",
"at",
"the",
"start",
"of",
"each",
"result",
"partition",
"if",
"printPartitionSeparator",
"is",
"set",
"to",
"<i",
">",
"true<",
"/",
"i",
... | train | https://github.com/hortonworks/dstream/blob/3a106c0f14725b028fe7fe2dbc660406d9a5f142/dstream-api/src/main/java/io/dstream/utils/ExecutionResultUtils.java#L24-L33 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/lock/LockManager.java | LockManager.detectDeadlock | boolean detectDeadlock(Locker acquirer, Lock l, int mode) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "detectDeadlock", new Object[] { acquirer, l,
modeStrs[mode] });
}
boolean result = false;
//----------------------------------------------------------------
// Iterate through the holders of the given lock and determine if
// any of them are waiting on a lock held by the requestor. If
// any of them are then a deadlock exists.
//----------------------------------------------------------------
Enumeration holders = l.getHolders();
while (holders.hasMoreElements()) {
if (lockerWaitingOn((Locker) holders.nextElement(), acquirer)) {
result = true;
break;
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "detectDeadlock:" + result);
}
return result;
} | java | boolean detectDeadlock(Locker acquirer, Lock l, int mode) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "detectDeadlock", new Object[] { acquirer, l,
modeStrs[mode] });
}
boolean result = false;
//----------------------------------------------------------------
// Iterate through the holders of the given lock and determine if
// any of them are waiting on a lock held by the requestor. If
// any of them are then a deadlock exists.
//----------------------------------------------------------------
Enumeration holders = l.getHolders();
while (holders.hasMoreElements()) {
if (lockerWaitingOn((Locker) holders.nextElement(), acquirer)) {
result = true;
break;
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "detectDeadlock:" + result);
}
return result;
} | [
"boolean",
"detectDeadlock",
"(",
"Locker",
"acquirer",
",",
"Lock",
"l",
",",
"int",
"mode",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"entry",
"(",
"... | /*
This method returns true iff waiting for the given lock instance in
the given mode would cause a deadlock with respect to the set of
locks known to this <code>LockManager</code> instance. <p> | [
"/",
"*",
"This",
"method",
"returns",
"true",
"iff",
"waiting",
"for",
"the",
"given",
"lock",
"instance",
"in",
"the",
"given",
"mode",
"would",
"cause",
"a",
"deadlock",
"with",
"respect",
"to",
"the",
"set",
"of",
"locks",
"known",
"to",
"this",
"<co... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/lock/LockManager.java#L377-L405 |
aspectran/aspectran | core/src/main/java/com/aspectran/core/support/i18n/message/ResourceBundleMessageSource.java | ResourceBundleMessageSource.doGetBundle | protected ResourceBundle doGetBundle(String basename, Locale locale) throws MissingResourceException {
return ResourceBundle.getBundle(basename, locale, getClassLoader(), new MessageSourceControl());
} | java | protected ResourceBundle doGetBundle(String basename, Locale locale) throws MissingResourceException {
return ResourceBundle.getBundle(basename, locale, getClassLoader(), new MessageSourceControl());
} | [
"protected",
"ResourceBundle",
"doGetBundle",
"(",
"String",
"basename",
",",
"Locale",
"locale",
")",
"throws",
"MissingResourceException",
"{",
"return",
"ResourceBundle",
".",
"getBundle",
"(",
"basename",
",",
"locale",
",",
"getClassLoader",
"(",
")",
",",
"n... | Obtain the resource bundle for the given basename and Locale.
@param basename the basename to look for
@param locale the Locale to look for
@return the corresponding ResourceBundle
@throws MissingResourceException if no matching bundle could be found
@see java.util.ResourceBundle#getBundle(String, Locale, ClassLoader) java.util.ResourceBundle#getBundle(String, Locale, ClassLoader) | [
"Obtain",
"the",
"resource",
"bundle",
"for",
"the",
"given",
"basename",
"and",
"Locale",
"."
] | train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/support/i18n/message/ResourceBundleMessageSource.java#L292-L294 |
Red5/red5-io | src/main/java/org/red5/io/object/Serializer.java | Serializer.writeComplex | public static boolean writeComplex(Output out, Object complex) {
log.trace("writeComplex");
if (writeListType(out, complex)) {
return true;
} else if (writeArrayType(out, complex)) {
return true;
} else if (writeXMLType(out, complex)) {
return true;
} else if (writeCustomType(out, complex)) {
return true;
} else if (writeObjectType(out, complex)) {
return true;
} else {
return false;
}
} | java | public static boolean writeComplex(Output out, Object complex) {
log.trace("writeComplex");
if (writeListType(out, complex)) {
return true;
} else if (writeArrayType(out, complex)) {
return true;
} else if (writeXMLType(out, complex)) {
return true;
} else if (writeCustomType(out, complex)) {
return true;
} else if (writeObjectType(out, complex)) {
return true;
} else {
return false;
}
} | [
"public",
"static",
"boolean",
"writeComplex",
"(",
"Output",
"out",
",",
"Object",
"complex",
")",
"{",
"log",
".",
"trace",
"(",
"\"writeComplex\"",
")",
";",
"if",
"(",
"writeListType",
"(",
"out",
",",
"complex",
")",
")",
"{",
"return",
"true",
";",... | Writes a complex type object out
@param out
Output writer
@param complex
Complex datatype object
@return boolean true if object was successfully serialized, false otherwise | [
"Writes",
"a",
"complex",
"type",
"object",
"out"
] | train | https://github.com/Red5/red5-io/blob/9bbbc506423c5a8f18169d46d400df56c0072a33/src/main/java/org/red5/io/object/Serializer.java#L174-L189 |
xiancloud/xian | xian-core/src/main/java/info/xiancloud/core/util/RandomUtils.java | RandomUtils.getRandom | public static String getRandom(char[] sourceChar, int length) {
if (sourceChar == null || sourceChar.length == 0 || length < 0) {
return null;
}
StringBuilder str = new StringBuilder(length);
Random random = new Random();
for (int i = 0; i < length; i++) {
str.append(sourceChar[random.nextInt(sourceChar.length)]);
}
return str.toString();
} | java | public static String getRandom(char[] sourceChar, int length) {
if (sourceChar == null || sourceChar.length == 0 || length < 0) {
return null;
}
StringBuilder str = new StringBuilder(length);
Random random = new Random();
for (int i = 0; i < length; i++) {
str.append(sourceChar[random.nextInt(sourceChar.length)]);
}
return str.toString();
} | [
"public",
"static",
"String",
"getRandom",
"(",
"char",
"[",
"]",
"sourceChar",
",",
"int",
"length",
")",
"{",
"if",
"(",
"sourceChar",
"==",
"null",
"||",
"sourceChar",
".",
"length",
"==",
"0",
"||",
"length",
"<",
"0",
")",
"{",
"return",
"null",
... | 得到固定长度的随机字符串,字符串由sourceChar中字符混合组成
@param sourceChar 源字符数组
@param length 长度
@return <ul>
<li>若sourceChar为null或长度为0,返回null</li>
<li>若length小于0,返回null</li>
</ul> | [
"得到固定长度的随机字符串,字符串由sourceChar中字符混合组成"
] | train | https://github.com/xiancloud/xian/blob/1948e088545553d2745b2c86d8b5a64988bb850e/xian-core/src/main/java/info/xiancloud/core/util/RandomUtils.java#L83-L93 |
infinispan/infinispan | jcache/commons/src/main/java/org/infinispan/jcache/RIMBeanServerRegistrationUtility.java | RIMBeanServerRegistrationUtility.isRegistered | static <K, V> boolean isRegistered(AbstractJCache<K, V> cache, ObjectNameType objectNameType) {
Set<ObjectName> registeredObjectNames;
MBeanServer mBeanServer = cache.getMBeanServer();
if (mBeanServer != null) {
ObjectName objectName = calculateObjectName(cache, objectNameType);
registeredObjectNames = SecurityActions.queryNames(objectName, null, mBeanServer);
return !registeredObjectNames.isEmpty();
} else {
return false;
}
} | java | static <K, V> boolean isRegistered(AbstractJCache<K, V> cache, ObjectNameType objectNameType) {
Set<ObjectName> registeredObjectNames;
MBeanServer mBeanServer = cache.getMBeanServer();
if (mBeanServer != null) {
ObjectName objectName = calculateObjectName(cache, objectNameType);
registeredObjectNames = SecurityActions.queryNames(objectName, null, mBeanServer);
return !registeredObjectNames.isEmpty();
} else {
return false;
}
} | [
"static",
"<",
"K",
",",
"V",
">",
"boolean",
"isRegistered",
"(",
"AbstractJCache",
"<",
"K",
",",
"V",
">",
"cache",
",",
"ObjectNameType",
"objectNameType",
")",
"{",
"Set",
"<",
"ObjectName",
">",
"registeredObjectNames",
";",
"MBeanServer",
"mBeanServer",... | Checks whether an ObjectName is already registered.
@throws javax.cache.CacheException - all exceptions are wrapped in
CacheException | [
"Checks",
"whether",
"an",
"ObjectName",
"is",
"already",
"registered",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/jcache/commons/src/main/java/org/infinispan/jcache/RIMBeanServerRegistrationUtility.java#L82-L94 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java | TmdbMovies.getRecommendations | public ResultList<MovieInfo> getRecommendations(int movieId, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, movieId);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.RECOMMENDATIONS).buildUrl(parameters);
WrapperGenericList<MovieInfo> wrapper = processWrapper(getTypeReference(MovieInfo.class), url, "recommendations");
return wrapper.getResultsList();
} | java | public ResultList<MovieInfo> getRecommendations(int movieId, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, movieId);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.RECOMMENDATIONS).buildUrl(parameters);
WrapperGenericList<MovieInfo> wrapper = processWrapper(getTypeReference(MovieInfo.class), url, "recommendations");
return wrapper.getResultsList();
} | [
"public",
"ResultList",
"<",
"MovieInfo",
">",
"getRecommendations",
"(",
"int",
"movieId",
",",
"String",
"language",
")",
"throws",
"MovieDbException",
"{",
"TmdbParameters",
"parameters",
"=",
"new",
"TmdbParameters",
"(",
")",
";",
"parameters",
".",
"add",
... | The recommendations method will let you retrieve the movie recommendations for a particular movie.
@param movieId
@param language
@return
@throws MovieDbException | [
"The",
"recommendations",
"method",
"will",
"let",
"you",
"retrieve",
"the",
"movie",
"recommendations",
"for",
"a",
"particular",
"movie",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java#L273-L281 |
aws/aws-sdk-java | aws-java-sdk-logs/src/main/java/com/amazonaws/services/logs/model/CreateLogGroupRequest.java | CreateLogGroupRequest.withTags | public CreateLogGroupRequest withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
} | java | public CreateLogGroupRequest withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
} | [
"public",
"CreateLogGroupRequest",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The key-value pairs to use for the tags.
</p>
@param tags
The key-value pairs to use for the tags.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"key",
"-",
"value",
"pairs",
"to",
"use",
"for",
"the",
"tags",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-logs/src/main/java/com/amazonaws/services/logs/model/CreateLogGroupRequest.java#L197-L200 |
biezhi/anima | src/main/java/io/github/biezhi/anima/Anima.java | Anima.deleteById | public static <T extends Model> int deleteById(Class<T> model, Serializable id) {
return new AnimaQuery<>(model).deleteById(id);
} | java | public static <T extends Model> int deleteById(Class<T> model, Serializable id) {
return new AnimaQuery<>(model).deleteById(id);
} | [
"public",
"static",
"<",
"T",
"extends",
"Model",
">",
"int",
"deleteById",
"(",
"Class",
"<",
"T",
">",
"model",
",",
"Serializable",
"id",
")",
"{",
"return",
"new",
"AnimaQuery",
"<>",
"(",
"model",
")",
".",
"deleteById",
"(",
"id",
")",
";",
"}"... | Delete model by id
@param model model type class
@param id model primary key
@param <T>
@return | [
"Delete",
"model",
"by",
"id"
] | train | https://github.com/biezhi/anima/blob/d6655e47ac4c08d9d7f961ac0569062bead8b1ed/src/main/java/io/github/biezhi/anima/Anima.java#L444-L446 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java | JspViewDeclarationLanguageBase.actuallyRenderView | protected boolean actuallyRenderView(FacesContext facesContext, UIViewRoot viewToRender)
throws IOException
{
// Set the new ResponseWriter into the FacesContext, saving the old one aside.
ResponseWriter responseWriter = facesContext.getResponseWriter();
// Now we actually render the document
// Call startDocument() on the ResponseWriter.
responseWriter.startDocument();
// Call encodeAll() on the UIViewRoot
viewToRender.encodeAll(facesContext);
// Call endDocument() on the ResponseWriter
responseWriter.endDocument();
responseWriter.flush();
// rendered successfully -- forge ahead
return true;
} | java | protected boolean actuallyRenderView(FacesContext facesContext, UIViewRoot viewToRender)
throws IOException
{
// Set the new ResponseWriter into the FacesContext, saving the old one aside.
ResponseWriter responseWriter = facesContext.getResponseWriter();
// Now we actually render the document
// Call startDocument() on the ResponseWriter.
responseWriter.startDocument();
// Call encodeAll() on the UIViewRoot
viewToRender.encodeAll(facesContext);
// Call endDocument() on the ResponseWriter
responseWriter.endDocument();
responseWriter.flush();
// rendered successfully -- forge ahead
return true;
} | [
"protected",
"boolean",
"actuallyRenderView",
"(",
"FacesContext",
"facesContext",
",",
"UIViewRoot",
"viewToRender",
")",
"throws",
"IOException",
"{",
"// Set the new ResponseWriter into the FacesContext, saving the old one aside.",
"ResponseWriter",
"responseWriter",
"=",
"faces... | Render the view now - properly setting and resetting the response writer
[MF] Modified to return a boolean so subclass that delegates can determine
whether the rendering succeeded or not. TRUE means success. | [
"Render",
"the",
"view",
"now",
"-",
"properly",
"setting",
"and",
"resetting",
"the",
"response",
"writer",
"[",
"MF",
"]",
"Modified",
"to",
"return",
"a",
"boolean",
"so",
"subclass",
"that",
"delegates",
"can",
"determine",
"whether",
"the",
"rendering",
... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java#L340-L360 |
reactor/reactor-netty | src/main/java/reactor/netty/tcp/TcpServer.java | TcpServer.selectorAttr | public final <T> TcpServer selectorAttr(AttributeKey<T> key, T value) {
Objects.requireNonNull(key, "key");
return bootstrap(b -> b.attr(key, value));
} | java | public final <T> TcpServer selectorAttr(AttributeKey<T> key, T value) {
Objects.requireNonNull(key, "key");
return bootstrap(b -> b.attr(key, value));
} | [
"public",
"final",
"<",
"T",
">",
"TcpServer",
"selectorAttr",
"(",
"AttributeKey",
"<",
"T",
">",
"key",
",",
"T",
"value",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"key",
",",
"\"key\"",
")",
";",
"return",
"bootstrap",
"(",
"b",
"->",
"b",
... | Injects default attribute to the future {@link io.netty.channel.ServerChannel}
selector connection.
@param key the attribute key
@param value the attribute value
@param <T> the attribute type
@return a new {@link TcpServer}
@see ServerBootstrap#attr(AttributeKey, Object) | [
"Injects",
"default",
"attribute",
"to",
"the",
"future",
"{",
"@link",
"io",
".",
"netty",
".",
"channel",
".",
"ServerChannel",
"}",
"selector",
"connection",
"."
] | train | https://github.com/reactor/reactor-netty/blob/4ed14316e1d7fca3cecd18d6caa5f2251e159e49/src/main/java/reactor/netty/tcp/TcpServer.java#L493-L496 |
adyliu/jafka | src/main/java/io/jafka/network/SocketServer.java | SocketServer.startup | public void startup() throws InterruptedException {
final int maxCacheConnectionPerThread = serverConfig.getMaxConnections() / processors.length;
logger.debug("start {} Processor threads",processors.length);
for (int i = 0; i < processors.length; i++) {
processors[i] = new Processor(handlerFactory, stats, maxRequestSize, maxCacheConnectionPerThread);
Utils.newThread("jafka-processor-" + i, processors[i], false).start();
}
Utils.newThread("jafka-acceptor", acceptor, false).start();
acceptor.awaitStartup();
} | java | public void startup() throws InterruptedException {
final int maxCacheConnectionPerThread = serverConfig.getMaxConnections() / processors.length;
logger.debug("start {} Processor threads",processors.length);
for (int i = 0; i < processors.length; i++) {
processors[i] = new Processor(handlerFactory, stats, maxRequestSize, maxCacheConnectionPerThread);
Utils.newThread("jafka-processor-" + i, processors[i], false).start();
}
Utils.newThread("jafka-acceptor", acceptor, false).start();
acceptor.awaitStartup();
} | [
"public",
"void",
"startup",
"(",
")",
"throws",
"InterruptedException",
"{",
"final",
"int",
"maxCacheConnectionPerThread",
"=",
"serverConfig",
".",
"getMaxConnections",
"(",
")",
"/",
"processors",
".",
"length",
";",
"logger",
".",
"debug",
"(",
"\"start {} Pr... | Start the socket server and waiting for finished
@throws InterruptedException thread interrupted | [
"Start",
"the",
"socket",
"server",
"and",
"waiting",
"for",
"finished"
] | train | https://github.com/adyliu/jafka/blob/cc14d2ed60c039b12d7b106bb5269ef21d0add7e/src/main/java/io/jafka/network/SocketServer.java#L81-L90 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jaxrs.2.0.common/src/org/apache/cxf/common/util/UrlUtils.java | UrlUtils.pathDecode | public static String pathDecode(String value) {
return urlDecode(value, StandardCharsets.UTF_8.name(), true);
} | java | public static String pathDecode(String value) {
return urlDecode(value, StandardCharsets.UTF_8.name(), true);
} | [
"public",
"static",
"String",
"pathDecode",
"(",
"String",
"value",
")",
"{",
"return",
"urlDecode",
"(",
"value",
",",
"StandardCharsets",
".",
"UTF_8",
".",
"name",
"(",
")",
",",
"true",
")",
";",
"}"
] | URL path segments may contain '+' symbols which should not be decoded into ' '
This method replaces '+' with %2B and delegates to URLDecoder
@param value value to decode | [
"URL",
"path",
"segments",
"may",
"contain",
"+",
"symbols",
"which",
"should",
"not",
"be",
"decoded",
"into",
"This",
"method",
"replaces",
"+",
"with",
"%2B",
"and",
"delegates",
"to",
"URLDecoder"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jaxrs.2.0.common/src/org/apache/cxf/common/util/UrlUtils.java#L141-L143 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.