repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
phax/ph-commons | ph-charset/src/main/java/com/helger/charset/utf7/UTF7StyleCharsetEncoder.java | UTF7StyleCharsetEncoder._encodeBase64 | private void _encodeBase64 (final char ch, final ByteBuffer out) {
"""
<p>
Writes the bytes necessary to encode a character in <i>base 64 mode</i>.
All bytes which are fully determined will be written. The fields
<code>bitsToOutput</code> and <code>sextet</code> are used to remember the
bytes not yet fully determined.
</p>
@param out
@param ch
"""
if (!m_bBase64mode)
out.put (m_nShift);
m_bBase64mode = true;
m_nBitsToOutput += 16;
while (m_nBitsToOutput >= 6)
{
m_nBitsToOutput -= 6;
m_nSextet += (ch >> m_nBitsToOutput);
m_nSextet &= 0x3F;
out.put (m_aBase64.getChar (m_nSextet));
m_nSextet = 0;
}
m_nSextet = (ch << (6 - m_nBitsToOutput)) & 0x3F;
} | java | private void _encodeBase64 (final char ch, final ByteBuffer out)
{
if (!m_bBase64mode)
out.put (m_nShift);
m_bBase64mode = true;
m_nBitsToOutput += 16;
while (m_nBitsToOutput >= 6)
{
m_nBitsToOutput -= 6;
m_nSextet += (ch >> m_nBitsToOutput);
m_nSextet &= 0x3F;
out.put (m_aBase64.getChar (m_nSextet));
m_nSextet = 0;
}
m_nSextet = (ch << (6 - m_nBitsToOutput)) & 0x3F;
} | [
"private",
"void",
"_encodeBase64",
"(",
"final",
"char",
"ch",
",",
"final",
"ByteBuffer",
"out",
")",
"{",
"if",
"(",
"!",
"m_bBase64mode",
")",
"out",
".",
"put",
"(",
"m_nShift",
")",
";",
"m_bBase64mode",
"=",
"true",
";",
"m_nBitsToOutput",
"+=",
"16",
";",
"while",
"(",
"m_nBitsToOutput",
">=",
"6",
")",
"{",
"m_nBitsToOutput",
"-=",
"6",
";",
"m_nSextet",
"+=",
"(",
"ch",
">>",
"m_nBitsToOutput",
")",
";",
"m_nSextet",
"&=",
"0x3F",
";",
"out",
".",
"put",
"(",
"m_aBase64",
".",
"getChar",
"(",
"m_nSextet",
")",
")",
";",
"m_nSextet",
"=",
"0",
";",
"}",
"m_nSextet",
"=",
"(",
"ch",
"<<",
"(",
"6",
"-",
"m_nBitsToOutput",
")",
")",
"&",
"0x3F",
";",
"}"
] | <p>
Writes the bytes necessary to encode a character in <i>base 64 mode</i>.
All bytes which are fully determined will be written. The fields
<code>bitsToOutput</code> and <code>sextet</code> are used to remember the
bytes not yet fully determined.
</p>
@param out
@param ch | [
"<p",
">",
"Writes",
"the",
"bytes",
"necessary",
"to",
"encode",
"a",
"character",
"in",
"<i",
">",
"base",
"64",
"mode<",
"/",
"i",
">",
".",
"All",
"bytes",
"which",
"are",
"fully",
"determined",
"will",
"be",
"written",
".",
"The",
"fields",
"<code",
">",
"bitsToOutput<",
"/",
"code",
">",
"and",
"<code",
">",
"sextet<",
"/",
"code",
">",
"are",
"used",
"to",
"remember",
"the",
"bytes",
"not",
"yet",
"fully",
"determined",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-charset/src/main/java/com/helger/charset/utf7/UTF7StyleCharsetEncoder.java#L196-L211 |
VoltDB/voltdb | src/frontend/org/voltdb/utils/VoltTrace.java | VoltTrace.beginDuration | public static TraceEvent beginDuration(String name, Object... args) {
"""
Creates a begin duration trace event. This method does not queue the
event. Call {@link TraceEventBatch#add(Supplier)} to queue the event.
"""
return new TraceEvent(TraceEventType.DURATION_BEGIN, name, null, args);
} | java | public static TraceEvent beginDuration(String name, Object... args) {
return new TraceEvent(TraceEventType.DURATION_BEGIN, name, null, args);
} | [
"public",
"static",
"TraceEvent",
"beginDuration",
"(",
"String",
"name",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"TraceEvent",
"(",
"TraceEventType",
".",
"DURATION_BEGIN",
",",
"name",
",",
"null",
",",
"args",
")",
";",
"}"
] | Creates a begin duration trace event. This method does not queue the
event. Call {@link TraceEventBatch#add(Supplier)} to queue the event. | [
"Creates",
"a",
"begin",
"duration",
"trace",
"event",
".",
"This",
"method",
"does",
"not",
"queue",
"the",
"event",
".",
"Call",
"{"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTrace.java#L473-L475 |
apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/converter/json/JsonStringToJsonIntermediateConverter.java | JsonStringToJsonIntermediateConverter.convertSchema | @Override
public JsonArray convertSchema(String inputSchema, WorkUnitState workUnit)
throws SchemaConversionException {
"""
Take in an input schema of type string, the schema must be in JSON format
@return a JsonArray representation of the schema
"""
this.unpackComplexSchemas =
workUnit.getPropAsBoolean(UNPACK_COMPLEX_SCHEMAS_KEY, DEFAULT_UNPACK_COMPLEX_SCHEMAS_KEY);
JsonParser jsonParser = new JsonParser();
log.info("Schema: " + inputSchema);
JsonElement jsonSchema = jsonParser.parse(inputSchema);
return jsonSchema.getAsJsonArray();
} | java | @Override
public JsonArray convertSchema(String inputSchema, WorkUnitState workUnit)
throws SchemaConversionException {
this.unpackComplexSchemas =
workUnit.getPropAsBoolean(UNPACK_COMPLEX_SCHEMAS_KEY, DEFAULT_UNPACK_COMPLEX_SCHEMAS_KEY);
JsonParser jsonParser = new JsonParser();
log.info("Schema: " + inputSchema);
JsonElement jsonSchema = jsonParser.parse(inputSchema);
return jsonSchema.getAsJsonArray();
} | [
"@",
"Override",
"public",
"JsonArray",
"convertSchema",
"(",
"String",
"inputSchema",
",",
"WorkUnitState",
"workUnit",
")",
"throws",
"SchemaConversionException",
"{",
"this",
".",
"unpackComplexSchemas",
"=",
"workUnit",
".",
"getPropAsBoolean",
"(",
"UNPACK_COMPLEX_SCHEMAS_KEY",
",",
"DEFAULT_UNPACK_COMPLEX_SCHEMAS_KEY",
")",
";",
"JsonParser",
"jsonParser",
"=",
"new",
"JsonParser",
"(",
")",
";",
"log",
".",
"info",
"(",
"\"Schema: \"",
"+",
"inputSchema",
")",
";",
"JsonElement",
"jsonSchema",
"=",
"jsonParser",
".",
"parse",
"(",
"inputSchema",
")",
";",
"return",
"jsonSchema",
".",
"getAsJsonArray",
"(",
")",
";",
"}"
] | Take in an input schema of type string, the schema must be in JSON format
@return a JsonArray representation of the schema | [
"Take",
"in",
"an",
"input",
"schema",
"of",
"type",
"string",
"the",
"schema",
"must",
"be",
"in",
"JSON",
"format"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/converter/json/JsonStringToJsonIntermediateConverter.java#L62-L72 |
jmapper-framework/jmapper-core | JMapper Framework/src/main/java/com/googlecode/jmapper/config/Error.java | Error.xmlAttributeExistent | public static void xmlAttributeExistent(String path, Attribute attribute, Class<?> aClass) {
"""
Thrown if attribute is present in the xml file.
@param path xml path
@param attribute attribute present
@param aClass attribute's class
"""
throw new XmlMappingAttributeExistException (MSG.INSTANCE.message(xmlMappingAttributeExistException2,attribute.getName(),aClass.getSimpleName(),path));
} | java | public static void xmlAttributeExistent(String path, Attribute attribute, Class<?> aClass){
throw new XmlMappingAttributeExistException (MSG.INSTANCE.message(xmlMappingAttributeExistException2,attribute.getName(),aClass.getSimpleName(),path));
} | [
"public",
"static",
"void",
"xmlAttributeExistent",
"(",
"String",
"path",
",",
"Attribute",
"attribute",
",",
"Class",
"<",
"?",
">",
"aClass",
")",
"{",
"throw",
"new",
"XmlMappingAttributeExistException",
"(",
"MSG",
".",
"INSTANCE",
".",
"message",
"(",
"xmlMappingAttributeExistException2",
",",
"attribute",
".",
"getName",
"(",
")",
",",
"aClass",
".",
"getSimpleName",
"(",
")",
",",
"path",
")",
")",
";",
"}"
] | Thrown if attribute is present in the xml file.
@param path xml path
@param attribute attribute present
@param aClass attribute's class | [
"Thrown",
"if",
"attribute",
"is",
"present",
"in",
"the",
"xml",
"file",
"."
] | train | https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/config/Error.java#L303-L305 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_easyHunting_serviceName_hunting_eventToken_POST | public String billingAccount_easyHunting_serviceName_hunting_eventToken_POST(String billingAccount, String serviceName, OvhTokenExpirationEnum expiration) throws IOException {
"""
Create a new token
REST: POST /telephony/{billingAccount}/easyHunting/{serviceName}/hunting/eventToken
@param expiration [required] Time to live in seconds for the token
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
"""
String qPath = "/telephony/{billingAccount}/easyHunting/{serviceName}/hunting/eventToken";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "expiration", expiration);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, String.class);
} | java | public String billingAccount_easyHunting_serviceName_hunting_eventToken_POST(String billingAccount, String serviceName, OvhTokenExpirationEnum expiration) throws IOException {
String qPath = "/telephony/{billingAccount}/easyHunting/{serviceName}/hunting/eventToken";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "expiration", expiration);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, String.class);
} | [
"public",
"String",
"billingAccount_easyHunting_serviceName_hunting_eventToken_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"OvhTokenExpirationEnum",
"expiration",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/easyHunting/{serviceName}/hunting/eventToken\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"expiration\"",
",",
"expiration",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"String",
".",
"class",
")",
";",
"}"
] | Create a new token
REST: POST /telephony/{billingAccount}/easyHunting/{serviceName}/hunting/eventToken
@param expiration [required] Time to live in seconds for the token
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] | [
"Create",
"a",
"new",
"token"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L2313-L2320 |
drewnoakes/metadata-extractor | Source/com/drew/metadata/exif/ExifReader.java | ExifReader.extract | public void extract(@NotNull final RandomAccessReader reader, @NotNull final Metadata metadata, int readerOffset, @Nullable Directory parentDirectory) {
"""
Reads TIFF formatted Exif data at a specified offset within a {@link RandomAccessReader}.
"""
ExifTiffHandler exifTiffHandler = new ExifTiffHandler(metadata, parentDirectory);
try {
// Read the TIFF-formatted Exif data
new TiffReader().processTiff(
reader,
exifTiffHandler,
readerOffset
);
} catch (TiffProcessingException e) {
exifTiffHandler.error("Exception processing TIFF data: " + e.getMessage());
// TODO what do to with this error state?
e.printStackTrace(System.err);
} catch (IOException e) {
exifTiffHandler.error("Exception processing TIFF data: " + e.getMessage());
// TODO what do to with this error state?
e.printStackTrace(System.err);
}
} | java | public void extract(@NotNull final RandomAccessReader reader, @NotNull final Metadata metadata, int readerOffset, @Nullable Directory parentDirectory)
{
ExifTiffHandler exifTiffHandler = new ExifTiffHandler(metadata, parentDirectory);
try {
// Read the TIFF-formatted Exif data
new TiffReader().processTiff(
reader,
exifTiffHandler,
readerOffset
);
} catch (TiffProcessingException e) {
exifTiffHandler.error("Exception processing TIFF data: " + e.getMessage());
// TODO what do to with this error state?
e.printStackTrace(System.err);
} catch (IOException e) {
exifTiffHandler.error("Exception processing TIFF data: " + e.getMessage());
// TODO what do to with this error state?
e.printStackTrace(System.err);
}
} | [
"public",
"void",
"extract",
"(",
"@",
"NotNull",
"final",
"RandomAccessReader",
"reader",
",",
"@",
"NotNull",
"final",
"Metadata",
"metadata",
",",
"int",
"readerOffset",
",",
"@",
"Nullable",
"Directory",
"parentDirectory",
")",
"{",
"ExifTiffHandler",
"exifTiffHandler",
"=",
"new",
"ExifTiffHandler",
"(",
"metadata",
",",
"parentDirectory",
")",
";",
"try",
"{",
"// Read the TIFF-formatted Exif data",
"new",
"TiffReader",
"(",
")",
".",
"processTiff",
"(",
"reader",
",",
"exifTiffHandler",
",",
"readerOffset",
")",
";",
"}",
"catch",
"(",
"TiffProcessingException",
"e",
")",
"{",
"exifTiffHandler",
".",
"error",
"(",
"\"Exception processing TIFF data: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"// TODO what do to with this error state?",
"e",
".",
"printStackTrace",
"(",
"System",
".",
"err",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"exifTiffHandler",
".",
"error",
"(",
"\"Exception processing TIFF data: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"// TODO what do to with this error state?",
"e",
".",
"printStackTrace",
"(",
"System",
".",
"err",
")",
";",
"}",
"}"
] | Reads TIFF formatted Exif data at a specified offset within a {@link RandomAccessReader}. | [
"Reads",
"TIFF",
"formatted",
"Exif",
"data",
"at",
"a",
"specified",
"offset",
"within",
"a",
"{"
] | train | https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/exif/ExifReader.java#L81-L101 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractIndirectionHandler.java | AbstractIndirectionHandler.getBroker | protected TemporaryBrokerWrapper getBroker() throws PBFactoryException {
"""
Gets the persistence broker used by this indirection handler.
If no PBKey is available a runtime exception will be thrown.
@return a PersistenceBroker
"""
PersistenceBrokerInternal broker;
boolean needsClose = false;
if (getBrokerKey() == null)
{
/*
arminw:
if no PBKey is set we throw an exception, because we don't
know which PB (connection) should be used.
*/
throw new OJBRuntimeException("Can't find associated PBKey. Need PBKey to obtain a valid" +
"PersistenceBroker instance from intern resources.");
}
// first try to use the current threaded broker to avoid blocking
broker = PersistenceBrokerThreadMapping.currentPersistenceBroker(getBrokerKey());
// current broker not found, create a intern new one
if ((broker == null) || broker.isClosed())
{
broker = (PersistenceBrokerInternal) PersistenceBrokerFactory.createPersistenceBroker(getBrokerKey());
/** Specifies whether we obtained a fresh broker which we have to close after we used it */
needsClose = true;
}
return new TemporaryBrokerWrapper(broker, needsClose);
} | java | protected TemporaryBrokerWrapper getBroker() throws PBFactoryException
{
PersistenceBrokerInternal broker;
boolean needsClose = false;
if (getBrokerKey() == null)
{
/*
arminw:
if no PBKey is set we throw an exception, because we don't
know which PB (connection) should be used.
*/
throw new OJBRuntimeException("Can't find associated PBKey. Need PBKey to obtain a valid" +
"PersistenceBroker instance from intern resources.");
}
// first try to use the current threaded broker to avoid blocking
broker = PersistenceBrokerThreadMapping.currentPersistenceBroker(getBrokerKey());
// current broker not found, create a intern new one
if ((broker == null) || broker.isClosed())
{
broker = (PersistenceBrokerInternal) PersistenceBrokerFactory.createPersistenceBroker(getBrokerKey());
/** Specifies whether we obtained a fresh broker which we have to close after we used it */
needsClose = true;
}
return new TemporaryBrokerWrapper(broker, needsClose);
} | [
"protected",
"TemporaryBrokerWrapper",
"getBroker",
"(",
")",
"throws",
"PBFactoryException",
"{",
"PersistenceBrokerInternal",
"broker",
";",
"boolean",
"needsClose",
"=",
"false",
";",
"if",
"(",
"getBrokerKey",
"(",
")",
"==",
"null",
")",
"{",
"/*\r\n arminw:\r\n if no PBKey is set we throw an exception, because we don't\r\n know which PB (connection) should be used.\r\n */",
"throw",
"new",
"OJBRuntimeException",
"(",
"\"Can't find associated PBKey. Need PBKey to obtain a valid\"",
"+",
"\"PersistenceBroker instance from intern resources.\"",
")",
";",
"}",
"// first try to use the current threaded broker to avoid blocking\r",
"broker",
"=",
"PersistenceBrokerThreadMapping",
".",
"currentPersistenceBroker",
"(",
"getBrokerKey",
"(",
")",
")",
";",
"// current broker not found, create a intern new one\r",
"if",
"(",
"(",
"broker",
"==",
"null",
")",
"||",
"broker",
".",
"isClosed",
"(",
")",
")",
"{",
"broker",
"=",
"(",
"PersistenceBrokerInternal",
")",
"PersistenceBrokerFactory",
".",
"createPersistenceBroker",
"(",
"getBrokerKey",
"(",
")",
")",
";",
"/** Specifies whether we obtained a fresh broker which we have to close after we used it */",
"needsClose",
"=",
"true",
";",
"}",
"return",
"new",
"TemporaryBrokerWrapper",
"(",
"broker",
",",
"needsClose",
")",
";",
"}"
] | Gets the persistence broker used by this indirection handler.
If no PBKey is available a runtime exception will be thrown.
@return a PersistenceBroker | [
"Gets",
"the",
"persistence",
"broker",
"used",
"by",
"this",
"indirection",
"handler",
".",
"If",
"no",
"PBKey",
"is",
"available",
"a",
"runtime",
"exception",
"will",
"be",
"thrown",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractIndirectionHandler.java#L180-L205 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/appservice/v2016_03_01/implementation/CertificatesInner.java | CertificatesInner.createOrUpdateAsync | public Observable<CertificateInner> createOrUpdateAsync(String resourceGroupName, String name, CertificateInner certificateEnvelope) {
"""
Create or update a certificate.
Create or update a certificate.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the certificate.
@param certificateEnvelope Details of certificate, if it exists already.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CertificateInner object
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, certificateEnvelope).map(new Func1<ServiceResponse<CertificateInner>, CertificateInner>() {
@Override
public CertificateInner call(ServiceResponse<CertificateInner> response) {
return response.body();
}
});
} | java | public Observable<CertificateInner> createOrUpdateAsync(String resourceGroupName, String name, CertificateInner certificateEnvelope) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, certificateEnvelope).map(new Func1<ServiceResponse<CertificateInner>, CertificateInner>() {
@Override
public CertificateInner call(ServiceResponse<CertificateInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"CertificateInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"name",
",",
"CertificateInner",
"certificateEnvelope",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
",",
"certificateEnvelope",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"CertificateInner",
">",
",",
"CertificateInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CertificateInner",
"call",
"(",
"ServiceResponse",
"<",
"CertificateInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create or update a certificate.
Create or update a certificate.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the certificate.
@param certificateEnvelope Details of certificate, if it exists already.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CertificateInner object | [
"Create",
"or",
"update",
"a",
"certificate",
".",
"Create",
"or",
"update",
"a",
"certificate",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/appservice/v2016_03_01/implementation/CertificatesInner.java#L466-L473 |
rpuch/xremoting | xremoting-core/src/main/java/com/googlecode/xremoting/core/commonshttpclient/HttpClientBuilder.java | HttpClientBuilder.keyStore | public HttpClientBuilder keyStore(URL url, String password) {
"""
Configures a key store for the current SSL host (see
{@link #ssl(String)}). If set, SSL server validation will be used (i.e.
the server certificate will be requested and validated).
@param url URL from which to obtain key store
@param password key store password
@return this
@see #ssl(String)
@see #trustKeyStore(URL, String)
"""
if (sslHostConfig == null) {
throw new IllegalStateException("ssl(String) must be called before this");
}
sslHostConfig.keyStoreUrl = url;
sslHostConfig.keyStorePassword = password;
return this;
} | java | public HttpClientBuilder keyStore(URL url, String password) {
if (sslHostConfig == null) {
throw new IllegalStateException("ssl(String) must be called before this");
}
sslHostConfig.keyStoreUrl = url;
sslHostConfig.keyStorePassword = password;
return this;
} | [
"public",
"HttpClientBuilder",
"keyStore",
"(",
"URL",
"url",
",",
"String",
"password",
")",
"{",
"if",
"(",
"sslHostConfig",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"ssl(String) must be called before this\"",
")",
";",
"}",
"sslHostConfig",
".",
"keyStoreUrl",
"=",
"url",
";",
"sslHostConfig",
".",
"keyStorePassword",
"=",
"password",
";",
"return",
"this",
";",
"}"
] | Configures a key store for the current SSL host (see
{@link #ssl(String)}). If set, SSL server validation will be used (i.e.
the server certificate will be requested and validated).
@param url URL from which to obtain key store
@param password key store password
@return this
@see #ssl(String)
@see #trustKeyStore(URL, String) | [
"Configures",
"a",
"key",
"store",
"for",
"the",
"current",
"SSL",
"host",
"(",
"see",
"{",
"@link",
"#ssl",
"(",
"String",
")",
"}",
")",
".",
"If",
"set",
"SSL",
"server",
"validation",
"will",
"be",
"used",
"(",
"i",
".",
"e",
".",
"the",
"server",
"certificate",
"will",
"be",
"requested",
"and",
"validated",
")",
"."
] | train | https://github.com/rpuch/xremoting/blob/519b640e5225652a8c23e10e5cab71827636a8b1/xremoting-core/src/main/java/com/googlecode/xremoting/core/commonshttpclient/HttpClientBuilder.java#L209-L216 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/AbstractGpxParserWpt.java | AbstractGpxParserWpt.initialise | public void initialise(XMLReader reader, AbstractGpxParserDefault parent) {
"""
Create a new specific parser. It has in memory the default parser, the
contentBuffer, the elementNames and the currentPoint.
@param reader The XMLReader used in the default class
@param parent The parser used in the default class
"""
setReader(reader);
setParent(parent);
setContentBuffer(parent.getContentBuffer());
setWptPreparedStmt(parent.getWptPreparedStmt());
setElementNames(parent.getElementNames());
setCurrentPoint(parent.getCurrentPoint());
} | java | public void initialise(XMLReader reader, AbstractGpxParserDefault parent) {
setReader(reader);
setParent(parent);
setContentBuffer(parent.getContentBuffer());
setWptPreparedStmt(parent.getWptPreparedStmt());
setElementNames(parent.getElementNames());
setCurrentPoint(parent.getCurrentPoint());
} | [
"public",
"void",
"initialise",
"(",
"XMLReader",
"reader",
",",
"AbstractGpxParserDefault",
"parent",
")",
"{",
"setReader",
"(",
"reader",
")",
";",
"setParent",
"(",
"parent",
")",
";",
"setContentBuffer",
"(",
"parent",
".",
"getContentBuffer",
"(",
")",
")",
";",
"setWptPreparedStmt",
"(",
"parent",
".",
"getWptPreparedStmt",
"(",
")",
")",
";",
"setElementNames",
"(",
"parent",
".",
"getElementNames",
"(",
")",
")",
";",
"setCurrentPoint",
"(",
"parent",
".",
"getCurrentPoint",
"(",
")",
")",
";",
"}"
] | Create a new specific parser. It has in memory the default parser, the
contentBuffer, the elementNames and the currentPoint.
@param reader The XMLReader used in the default class
@param parent The parser used in the default class | [
"Create",
"a",
"new",
"specific",
"parser",
".",
"It",
"has",
"in",
"memory",
"the",
"default",
"parser",
"the",
"contentBuffer",
"the",
"elementNames",
"and",
"the",
"currentPoint",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/AbstractGpxParserWpt.java#L48-L55 |
lessthanoptimal/ddogleg | src/org/ddogleg/solver/FitQuadratic1D.java | FitQuadratic1D.process | public boolean process( int offset , int length , double ...data ) {
"""
Computes polynomial coefficients for the given data.
@param length Number of elements in data with relevant data.
@param data Set of observation data.
@return true if successful or false if it fails.
"""
if( data.length < 3 )
throw new IllegalArgumentException("At least three points");
A.reshape(data.length,3);
y.reshape(data.length,1);
int indexDst = 0;
int indexSrc = offset;
for( int i = 0; i < length; i++ ) {
double d = data[indexSrc++];
A.data[indexDst++] = i*i;
A.data[indexDst++] = i;
A.data[indexDst++] = 1;
y.data[i] = d;
}
if( !solver.setA(A) )
return false;
solver.solve(y,x);
return true;
} | java | public boolean process( int offset , int length , double ...data ) {
if( data.length < 3 )
throw new IllegalArgumentException("At least three points");
A.reshape(data.length,3);
y.reshape(data.length,1);
int indexDst = 0;
int indexSrc = offset;
for( int i = 0; i < length; i++ ) {
double d = data[indexSrc++];
A.data[indexDst++] = i*i;
A.data[indexDst++] = i;
A.data[indexDst++] = 1;
y.data[i] = d;
}
if( !solver.setA(A) )
return false;
solver.solve(y,x);
return true;
} | [
"public",
"boolean",
"process",
"(",
"int",
"offset",
",",
"int",
"length",
",",
"double",
"...",
"data",
")",
"{",
"if",
"(",
"data",
".",
"length",
"<",
"3",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"At least three points\"",
")",
";",
"A",
".",
"reshape",
"(",
"data",
".",
"length",
",",
"3",
")",
";",
"y",
".",
"reshape",
"(",
"data",
".",
"length",
",",
"1",
")",
";",
"int",
"indexDst",
"=",
"0",
";",
"int",
"indexSrc",
"=",
"offset",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"double",
"d",
"=",
"data",
"[",
"indexSrc",
"++",
"]",
";",
"A",
".",
"data",
"[",
"indexDst",
"++",
"]",
"=",
"i",
"*",
"i",
";",
"A",
".",
"data",
"[",
"indexDst",
"++",
"]",
"=",
"i",
";",
"A",
".",
"data",
"[",
"indexDst",
"++",
"]",
"=",
"1",
";",
"y",
".",
"data",
"[",
"i",
"]",
"=",
"d",
";",
"}",
"if",
"(",
"!",
"solver",
".",
"setA",
"(",
"A",
")",
")",
"return",
"false",
";",
"solver",
".",
"solve",
"(",
"y",
",",
"x",
")",
";",
"return",
"true",
";",
"}"
] | Computes polynomial coefficients for the given data.
@param length Number of elements in data with relevant data.
@param data Set of observation data.
@return true if successful or false if it fails. | [
"Computes",
"polynomial",
"coefficients",
"for",
"the",
"given",
"data",
"."
] | train | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/FitQuadratic1D.java#L52-L77 |
protostuff/protostuff | protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeSchema.java | RuntimeSchema.getSchemaWrapper | static <T> HasSchema<T> getSchemaWrapper(Class<T> typeClass) {
"""
Returns the schema wrapper.
<p>
Method overload for backwards compatibility.
"""
return getSchemaWrapper(typeClass, ID_STRATEGY);
} | java | static <T> HasSchema<T> getSchemaWrapper(Class<T> typeClass)
{
return getSchemaWrapper(typeClass, ID_STRATEGY);
} | [
"static",
"<",
"T",
">",
"HasSchema",
"<",
"T",
">",
"getSchemaWrapper",
"(",
"Class",
"<",
"T",
">",
"typeClass",
")",
"{",
"return",
"getSchemaWrapper",
"(",
"typeClass",
",",
"ID_STRATEGY",
")",
";",
"}"
] | Returns the schema wrapper.
<p>
Method overload for backwards compatibility. | [
"Returns",
"the",
"schema",
"wrapper",
".",
"<p",
">",
"Method",
"overload",
"for",
"backwards",
"compatibility",
"."
] | train | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeSchema.java#L157-L160 |
Ellzord/JALSE | src/main/java/jalse/actions/Actions.java | Actions.copy | public static <T> void copy(final ActionContext<T> source, final SchedulableActionContext<T> target) {
"""
Copies context information to a target context (actor, bindings, initial delay and period).
@param source
Source context.
@param target
Target context.
"""
target.setActor(source.getActor());
target.putAll(source.toMap());
target.setInitialDelay(target.getInitialDelay(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
target.setPeriod(source.getPeriod(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
} | java | public static <T> void copy(final ActionContext<T> source, final SchedulableActionContext<T> target) {
target.setActor(source.getActor());
target.putAll(source.toMap());
target.setInitialDelay(target.getInitialDelay(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
target.setPeriod(source.getPeriod(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
} | [
"public",
"static",
"<",
"T",
">",
"void",
"copy",
"(",
"final",
"ActionContext",
"<",
"T",
">",
"source",
",",
"final",
"SchedulableActionContext",
"<",
"T",
">",
"target",
")",
"{",
"target",
".",
"setActor",
"(",
"source",
".",
"getActor",
"(",
")",
")",
";",
"target",
".",
"putAll",
"(",
"source",
".",
"toMap",
"(",
")",
")",
";",
"target",
".",
"setInitialDelay",
"(",
"target",
".",
"getInitialDelay",
"(",
"TimeUnit",
".",
"NANOSECONDS",
")",
",",
"TimeUnit",
".",
"NANOSECONDS",
")",
";",
"target",
".",
"setPeriod",
"(",
"source",
".",
"getPeriod",
"(",
"TimeUnit",
".",
"NANOSECONDS",
")",
",",
"TimeUnit",
".",
"NANOSECONDS",
")",
";",
"}"
] | Copies context information to a target context (actor, bindings, initial delay and period).
@param source
Source context.
@param target
Target context. | [
"Copies",
"context",
"information",
"to",
"a",
"target",
"context",
"(",
"actor",
"bindings",
"initial",
"delay",
"and",
"period",
")",
"."
] | train | https://github.com/Ellzord/JALSE/blob/43fc6572de9b16eb8474aa21a88b6b2d11291615/src/main/java/jalse/actions/Actions.java#L39-L44 |
artikcloud/artikcloud-java | src/main/java/cloud/artik/api/ExportApi.java | ExportApi.getExportHistory | public ExportHistoryResponse getExportHistory(String trialId, Integer count, Integer offset) throws ApiException {
"""
Get Export History
Get the history of export requests.
@param trialId Filter by trialId. (optional)
@param count Pagination count. (optional)
@param offset Pagination offset. (optional)
@return ExportHistoryResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<ExportHistoryResponse> resp = getExportHistoryWithHttpInfo(trialId, count, offset);
return resp.getData();
} | java | public ExportHistoryResponse getExportHistory(String trialId, Integer count, Integer offset) throws ApiException {
ApiResponse<ExportHistoryResponse> resp = getExportHistoryWithHttpInfo(trialId, count, offset);
return resp.getData();
} | [
"public",
"ExportHistoryResponse",
"getExportHistory",
"(",
"String",
"trialId",
",",
"Integer",
"count",
",",
"Integer",
"offset",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"ExportHistoryResponse",
">",
"resp",
"=",
"getExportHistoryWithHttpInfo",
"(",
"trialId",
",",
"count",
",",
"offset",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] | Get Export History
Get the history of export requests.
@param trialId Filter by trialId. (optional)
@param count Pagination count. (optional)
@param offset Pagination offset. (optional)
@return ExportHistoryResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Get",
"Export",
"History",
"Get",
"the",
"history",
"of",
"export",
"requests",
"."
] | train | https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/ExportApi.java#L247-L250 |
code4everything/util | src/main/java/com/zhazhapan/util/dialog/Alerts.java | Alerts.showWarning | public static Optional<ButtonType> showWarning(String title, String header, String content) {
"""
弹出警告框
@param title 标题
@param header 信息头
@param content 内容
@return {@link ButtonType}
"""
return alert(title, header, content, AlertType.WARNING);
} | java | public static Optional<ButtonType> showWarning(String title, String header, String content) {
return alert(title, header, content, AlertType.WARNING);
} | [
"public",
"static",
"Optional",
"<",
"ButtonType",
">",
"showWarning",
"(",
"String",
"title",
",",
"String",
"header",
",",
"String",
"content",
")",
"{",
"return",
"alert",
"(",
"title",
",",
"header",
",",
"content",
",",
"AlertType",
".",
"WARNING",
")",
";",
"}"
] | 弹出警告框
@param title 标题
@param header 信息头
@param content 内容
@return {@link ButtonType} | [
"弹出警告框"
] | train | https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/dialog/Alerts.java#L70-L72 |
loadcoder/chart-extensions | src/main/java/com/loadcoder/load/jfreechartfixes/XYLineAndShapeRendererExtention.java | XYLineAndShapeRendererExtention.getLegendItem | @Override
public LegendItem getLegendItem(int datasetIndex, int series) {
"""
/*
The purpose of this override is to change the behaviour for the visibility of the legend
and how the color of the legend is set.
"""
XYPlot plot = getPlot();
if (plot == null) {
return null;
}
XYDataset dataset = plot.getDataset(datasetIndex);
if (dataset == null) {
return null;
}
//jfreechart diff: set the line paint with the implementation of abstract getLinePaint
Paint linePaint = getLinePaint(series);
String label = getLegendItemLabelGenerator().generateLabel(dataset,
series);
String description = label;
String toolTipText = null;
if (getLegendItemToolTipGenerator() != null) {
toolTipText = getLegendItemToolTipGenerator().generateLabel(
dataset, series);
}
String urlText = null;
if (getLegendItemURLGenerator() != null) {
urlText = getLegendItemURLGenerator().generateLabel(dataset,
series);
}
boolean shapeIsVisible = getItemShapeVisible(series, 0);
Shape shape = lookupLegendShape(series);
boolean shapeIsFilled = getItemShapeFilled(series, 0);
Paint fillPaint = (this.getUseFillPaint() ? lookupSeriesFillPaint(series)
: linePaint);
boolean shapeOutlineVisible = this.getDrawOutlines();
Paint outlinePaint = (this.getUseOutlinePaint() ? lookupSeriesOutlinePaint(
series) : linePaint);
Stroke outlineStroke = lookupSeriesOutlineStroke(series);
boolean lineVisible = getItemLineVisible(series, 0);
Stroke lineStroke = lookupSeriesStroke(series);
LegendItem result = new LegendItem(label, description, toolTipText, urlText, shapeIsVisible, shape,
shapeIsFilled, fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, lineVisible,
this.getLegendLine(), lineStroke, linePaint);
result.setLabelFont(lookupLegendTextFont(series));
Paint labelPaint = lookupLegendTextPaint(series);
if (labelPaint != null) {
result.setLabelPaint(labelPaint);
}
result.setSeriesKey(dataset.getSeriesKey(series));
result.setSeriesIndex(series);
result.setDataset(dataset);
result.setDatasetIndex(datasetIndex);
return result;
} | java | @Override
public LegendItem getLegendItem(int datasetIndex, int series) {
XYPlot plot = getPlot();
if (plot == null) {
return null;
}
XYDataset dataset = plot.getDataset(datasetIndex);
if (dataset == null) {
return null;
}
//jfreechart diff: set the line paint with the implementation of abstract getLinePaint
Paint linePaint = getLinePaint(series);
String label = getLegendItemLabelGenerator().generateLabel(dataset,
series);
String description = label;
String toolTipText = null;
if (getLegendItemToolTipGenerator() != null) {
toolTipText = getLegendItemToolTipGenerator().generateLabel(
dataset, series);
}
String urlText = null;
if (getLegendItemURLGenerator() != null) {
urlText = getLegendItemURLGenerator().generateLabel(dataset,
series);
}
boolean shapeIsVisible = getItemShapeVisible(series, 0);
Shape shape = lookupLegendShape(series);
boolean shapeIsFilled = getItemShapeFilled(series, 0);
Paint fillPaint = (this.getUseFillPaint() ? lookupSeriesFillPaint(series)
: linePaint);
boolean shapeOutlineVisible = this.getDrawOutlines();
Paint outlinePaint = (this.getUseOutlinePaint() ? lookupSeriesOutlinePaint(
series) : linePaint);
Stroke outlineStroke = lookupSeriesOutlineStroke(series);
boolean lineVisible = getItemLineVisible(series, 0);
Stroke lineStroke = lookupSeriesStroke(series);
LegendItem result = new LegendItem(label, description, toolTipText, urlText, shapeIsVisible, shape,
shapeIsFilled, fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, lineVisible,
this.getLegendLine(), lineStroke, linePaint);
result.setLabelFont(lookupLegendTextFont(series));
Paint labelPaint = lookupLegendTextPaint(series);
if (labelPaint != null) {
result.setLabelPaint(labelPaint);
}
result.setSeriesKey(dataset.getSeriesKey(series));
result.setSeriesIndex(series);
result.setDataset(dataset);
result.setDatasetIndex(datasetIndex);
return result;
} | [
"@",
"Override",
"public",
"LegendItem",
"getLegendItem",
"(",
"int",
"datasetIndex",
",",
"int",
"series",
")",
"{",
"XYPlot",
"plot",
"=",
"getPlot",
"(",
")",
";",
"if",
"(",
"plot",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"XYDataset",
"dataset",
"=",
"plot",
".",
"getDataset",
"(",
"datasetIndex",
")",
";",
"if",
"(",
"dataset",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"//jfreechart diff: set the line paint with the implementation of abstract getLinePaint\r",
"Paint",
"linePaint",
"=",
"getLinePaint",
"(",
"series",
")",
";",
"String",
"label",
"=",
"getLegendItemLabelGenerator",
"(",
")",
".",
"generateLabel",
"(",
"dataset",
",",
"series",
")",
";",
"String",
"description",
"=",
"label",
";",
"String",
"toolTipText",
"=",
"null",
";",
"if",
"(",
"getLegendItemToolTipGenerator",
"(",
")",
"!=",
"null",
")",
"{",
"toolTipText",
"=",
"getLegendItemToolTipGenerator",
"(",
")",
".",
"generateLabel",
"(",
"dataset",
",",
"series",
")",
";",
"}",
"String",
"urlText",
"=",
"null",
";",
"if",
"(",
"getLegendItemURLGenerator",
"(",
")",
"!=",
"null",
")",
"{",
"urlText",
"=",
"getLegendItemURLGenerator",
"(",
")",
".",
"generateLabel",
"(",
"dataset",
",",
"series",
")",
";",
"}",
"boolean",
"shapeIsVisible",
"=",
"getItemShapeVisible",
"(",
"series",
",",
"0",
")",
";",
"Shape",
"shape",
"=",
"lookupLegendShape",
"(",
"series",
")",
";",
"boolean",
"shapeIsFilled",
"=",
"getItemShapeFilled",
"(",
"series",
",",
"0",
")",
";",
"Paint",
"fillPaint",
"=",
"(",
"this",
".",
"getUseFillPaint",
"(",
")",
"?",
"lookupSeriesFillPaint",
"(",
"series",
")",
":",
"linePaint",
")",
";",
"boolean",
"shapeOutlineVisible",
"=",
"this",
".",
"getDrawOutlines",
"(",
")",
";",
"Paint",
"outlinePaint",
"=",
"(",
"this",
".",
"getUseOutlinePaint",
"(",
")",
"?",
"lookupSeriesOutlinePaint",
"(",
"series",
")",
":",
"linePaint",
")",
";",
"Stroke",
"outlineStroke",
"=",
"lookupSeriesOutlineStroke",
"(",
"series",
")",
";",
"boolean",
"lineVisible",
"=",
"getItemLineVisible",
"(",
"series",
",",
"0",
")",
";",
"Stroke",
"lineStroke",
"=",
"lookupSeriesStroke",
"(",
"series",
")",
";",
"LegendItem",
"result",
"=",
"new",
"LegendItem",
"(",
"label",
",",
"description",
",",
"toolTipText",
",",
"urlText",
",",
"shapeIsVisible",
",",
"shape",
",",
"shapeIsFilled",
",",
"fillPaint",
",",
"shapeOutlineVisible",
",",
"outlinePaint",
",",
"outlineStroke",
",",
"lineVisible",
",",
"this",
".",
"getLegendLine",
"(",
")",
",",
"lineStroke",
",",
"linePaint",
")",
";",
"result",
".",
"setLabelFont",
"(",
"lookupLegendTextFont",
"(",
"series",
")",
")",
";",
"Paint",
"labelPaint",
"=",
"lookupLegendTextPaint",
"(",
"series",
")",
";",
"if",
"(",
"labelPaint",
"!=",
"null",
")",
"{",
"result",
".",
"setLabelPaint",
"(",
"labelPaint",
")",
";",
"}",
"result",
".",
"setSeriesKey",
"(",
"dataset",
".",
"getSeriesKey",
"(",
"series",
")",
")",
";",
"result",
".",
"setSeriesIndex",
"(",
"series",
")",
";",
"result",
".",
"setDataset",
"(",
"dataset",
")",
";",
"result",
".",
"setDatasetIndex",
"(",
"datasetIndex",
")",
";",
"return",
"result",
";",
"}"
] | /*
The purpose of this override is to change the behaviour for the visibility of the legend
and how the color of the legend is set. | [
"/",
"*",
"The",
"purpose",
"of",
"this",
"override",
"is",
"to",
"change",
"the",
"behaviour",
"for",
"the",
"visibility",
"of",
"the",
"legend",
"and",
"how",
"the",
"color",
"of",
"the",
"legend",
"is",
"set",
"."
] | train | https://github.com/loadcoder/chart-extensions/blob/ded73ad337d18072b3fd4b1b4e3b7a581567d76d/src/main/java/com/loadcoder/load/jfreechartfixes/XYLineAndShapeRendererExtention.java#L59-L112 |
Hygieia/Hygieia | collectors/build/jenkins/src/main/java/com/capitalone/dashboard/collector/DefaultHudsonClient.java | DefaultHudsonClient.joinURL | public static String joinURL(String base, String[] paths) {
"""
join a base url to another path or paths - this will handle trailing or non-trailing /'s
"""
StringBuilder result = new StringBuilder(base);
Arrays.stream(paths).map(path -> path.replaceFirst("^(\\/)+", "")).forEach(p -> {
if (result.lastIndexOf("/") != result.length() - 1) {
result.append('/');
}
result.append(p);
});
return result.toString();
} | java | public static String joinURL(String base, String[] paths) {
StringBuilder result = new StringBuilder(base);
Arrays.stream(paths).map(path -> path.replaceFirst("^(\\/)+", "")).forEach(p -> {
if (result.lastIndexOf("/") != result.length() - 1) {
result.append('/');
}
result.append(p);
});
return result.toString();
} | [
"public",
"static",
"String",
"joinURL",
"(",
"String",
"base",
",",
"String",
"[",
"]",
"paths",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"base",
")",
";",
"Arrays",
".",
"stream",
"(",
"paths",
")",
".",
"map",
"(",
"path",
"->",
"path",
".",
"replaceFirst",
"(",
"\"^(\\\\/)+\"",
",",
"\"\"",
")",
")",
".",
"forEach",
"(",
"p",
"->",
"{",
"if",
"(",
"result",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
"!=",
"result",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"result",
".",
"append",
"(",
"p",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | join a base url to another path or paths - this will handle trailing or non-trailing /'s | [
"join",
"a",
"base",
"url",
"to",
"another",
"path",
"or",
"paths",
"-",
"this",
"will",
"handle",
"trailing",
"or",
"non",
"-",
"trailing",
"/",
"s"
] | train | https://github.com/Hygieia/Hygieia/blob/d8b67a590da2744acf59bcd99d9b34ef1bb84890/collectors/build/jenkins/src/main/java/com/capitalone/dashboard/collector/DefaultHudsonClient.java#L691-L700 |
deephacks/confit | core/src/main/java/org/deephacks/confit/internal/core/property/typesafe/impl/AbstractConfigObject.java | AbstractConfigObject.peekPath | protected AbstractConfigValue peekPath(Path path, ResolveContext context) throws NotPossibleToResolve {
"""
Looks up the path with no transformation, type conversion, or exceptions
(just returns null if path not found). Does however resolve the path, if
resolver != null.
@throws NotPossibleToResolve
if context is not null and resolution fails
"""
return peekPath(this, path, context);
} | java | protected AbstractConfigValue peekPath(Path path, ResolveContext context) throws NotPossibleToResolve {
return peekPath(this, path, context);
} | [
"protected",
"AbstractConfigValue",
"peekPath",
"(",
"Path",
"path",
",",
"ResolveContext",
"context",
")",
"throws",
"NotPossibleToResolve",
"{",
"return",
"peekPath",
"(",
"this",
",",
"path",
",",
"context",
")",
";",
"}"
] | Looks up the path with no transformation, type conversion, or exceptions
(just returns null if path not found). Does however resolve the path, if
resolver != null.
@throws NotPossibleToResolve
if context is not null and resolution fails | [
"Looks",
"up",
"the",
"path",
"with",
"no",
"transformation",
"type",
"conversion",
"or",
"exceptions",
"(",
"just",
"returns",
"null",
"if",
"path",
"not",
"found",
")",
".",
"Does",
"however",
"resolve",
"the",
"path",
"if",
"resolver",
"!",
"=",
"null",
"."
] | train | https://github.com/deephacks/confit/blob/4e6d4ee5fed32cbc5104433e61de1bcf1b360832/core/src/main/java/org/deephacks/confit/internal/core/property/typesafe/impl/AbstractConfigObject.java#L95-L97 |
JoeKerouac/utils | src/main/java/com/joe/utils/reflect/BeanUtils.java | BeanUtils.convert | public static Map<String, Object> convert(Object pojo,
Class<? extends Annotation> annotationType) {
"""
将pojo的所有字段映射为map,默认包含null值
@param pojo pojo
@param annotationType 别名注解类型,支持{@link JsonProperty JsonProperty}和{@link XmlNode XmlNode}
@return map,当pojo为null时返回空map
"""
return convert(pojo, annotationType, true);
} | java | public static Map<String, Object> convert(Object pojo,
Class<? extends Annotation> annotationType) {
return convert(pojo, annotationType, true);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"convert",
"(",
"Object",
"pojo",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationType",
")",
"{",
"return",
"convert",
"(",
"pojo",
",",
"annotationType",
",",
"true",
")",
";",
"}"
] | 将pojo的所有字段映射为map,默认包含null值
@param pojo pojo
@param annotationType 别名注解类型,支持{@link JsonProperty JsonProperty}和{@link XmlNode XmlNode}
@return map,当pojo为null时返回空map | [
"将pojo的所有字段映射为map,默认包含null值"
] | train | https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/reflect/BeanUtils.java#L40-L43 |
looly/hutool | hutool-socket/src/main/java/cn/hutool/socket/aio/AioServer.java | AioServer.setOption | public <T> AioServer setOption(SocketOption<T> name, T value) throws IOException {
"""
设置 Socket 的 Option 选项<br>
选项见:{@link java.net.StandardSocketOptions}
@param <T> 选项泛型
@param name {@link SocketOption} 枚举
@param value SocketOption参数
@throws IOException IO异常
"""
this.channel.setOption(name, value);
return this;
} | java | public <T> AioServer setOption(SocketOption<T> name, T value) throws IOException {
this.channel.setOption(name, value);
return this;
} | [
"public",
"<",
"T",
">",
"AioServer",
"setOption",
"(",
"SocketOption",
"<",
"T",
">",
"name",
",",
"T",
"value",
")",
"throws",
"IOException",
"{",
"this",
".",
"channel",
".",
"setOption",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | 设置 Socket 的 Option 选项<br>
选项见:{@link java.net.StandardSocketOptions}
@param <T> 选项泛型
@param name {@link SocketOption} 枚举
@param value SocketOption参数
@throws IOException IO异常 | [
"设置",
"Socket",
"的",
"Option",
"选项<br",
">",
"选项见:",
"{",
"@link",
"java",
".",
"net",
".",
"StandardSocketOptions",
"}"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-socket/src/main/java/cn/hutool/socket/aio/AioServer.java#L95-L98 |
HanSolo/SteelSeries-Swing | src/main/java/eu/hansolo/steelseries/tools/Model.java | Model.setMaxValue | public void setMaxValue(final double MAX_VALUE) {
"""
Sets the maximum value that will be used for the calculation
of the nice maximum vlaue for the scale.
@param MAX_VALUE
"""
// check min-max values
if (Double.compare(MAX_VALUE, minValue) == 0) {
throw new IllegalArgumentException("Max value cannot be equal to min value");
}
if (Double.compare(MAX_VALUE, minValue) < 0) {
maxValue = minValue;
minValue = MAX_VALUE;
} else {
maxValue = MAX_VALUE;
}
calculate();
validate();
calcAngleStep();
fireStateChanged();
} | java | public void setMaxValue(final double MAX_VALUE) {
// check min-max values
if (Double.compare(MAX_VALUE, minValue) == 0) {
throw new IllegalArgumentException("Max value cannot be equal to min value");
}
if (Double.compare(MAX_VALUE, minValue) < 0) {
maxValue = minValue;
minValue = MAX_VALUE;
} else {
maxValue = MAX_VALUE;
}
calculate();
validate();
calcAngleStep();
fireStateChanged();
} | [
"public",
"void",
"setMaxValue",
"(",
"final",
"double",
"MAX_VALUE",
")",
"{",
"// check min-max values",
"if",
"(",
"Double",
".",
"compare",
"(",
"MAX_VALUE",
",",
"minValue",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Max value cannot be equal to min value\"",
")",
";",
"}",
"if",
"(",
"Double",
".",
"compare",
"(",
"MAX_VALUE",
",",
"minValue",
")",
"<",
"0",
")",
"{",
"maxValue",
"=",
"minValue",
";",
"minValue",
"=",
"MAX_VALUE",
";",
"}",
"else",
"{",
"maxValue",
"=",
"MAX_VALUE",
";",
"}",
"calculate",
"(",
")",
";",
"validate",
"(",
")",
";",
"calcAngleStep",
"(",
")",
";",
"fireStateChanged",
"(",
")",
";",
"}"
] | Sets the maximum value that will be used for the calculation
of the nice maximum vlaue for the scale.
@param MAX_VALUE | [
"Sets",
"the",
"maximum",
"value",
"that",
"will",
"be",
"used",
"for",
"the",
"calculation",
"of",
"the",
"nice",
"maximum",
"vlaue",
"for",
"the",
"scale",
"."
] | train | https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/tools/Model.java#L386-L402 |
Azure/azure-sdk-for-java | containerinstance/resource-manager/v2018_10_01/src/main/java/com/microsoft/azure/management/containerinstance/v2018_10_01/implementation/ContainersInner.java | ContainersInner.listLogsAsync | public Observable<LogsInner> listLogsAsync(String resourceGroupName, String containerGroupName, String containerName) {
"""
Get the logs for a specified container instance.
Get the logs for a specified container instance in a specified resource group and container group.
@param resourceGroupName The name of the resource group.
@param containerGroupName The name of the container group.
@param containerName The name of the container instance.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the LogsInner object
"""
return listLogsWithServiceResponseAsync(resourceGroupName, containerGroupName, containerName).map(new Func1<ServiceResponse<LogsInner>, LogsInner>() {
@Override
public LogsInner call(ServiceResponse<LogsInner> response) {
return response.body();
}
});
} | java | public Observable<LogsInner> listLogsAsync(String resourceGroupName, String containerGroupName, String containerName) {
return listLogsWithServiceResponseAsync(resourceGroupName, containerGroupName, containerName).map(new Func1<ServiceResponse<LogsInner>, LogsInner>() {
@Override
public LogsInner call(ServiceResponse<LogsInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"LogsInner",
">",
"listLogsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"containerGroupName",
",",
"String",
"containerName",
")",
"{",
"return",
"listLogsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"containerGroupName",
",",
"containerName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"LogsInner",
">",
",",
"LogsInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"LogsInner",
"call",
"(",
"ServiceResponse",
"<",
"LogsInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get the logs for a specified container instance.
Get the logs for a specified container instance in a specified resource group and container group.
@param resourceGroupName The name of the resource group.
@param containerGroupName The name of the container group.
@param containerName The name of the container instance.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the LogsInner object | [
"Get",
"the",
"logs",
"for",
"a",
"specified",
"container",
"instance",
".",
"Get",
"the",
"logs",
"for",
"a",
"specified",
"container",
"instance",
"in",
"a",
"specified",
"resource",
"group",
"and",
"container",
"group",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerinstance/resource-manager/v2018_10_01/src/main/java/com/microsoft/azure/management/containerinstance/v2018_10_01/implementation/ContainersInner.java#L109-L116 |
allcolor/YaHP-Converter | YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java | CClassLoader.addClass | public final void addClass(final String className, final URL urlToClass) {
"""
add a class to known class
@param className
class name
@param urlToClass
url to class file
"""
if ((className == null) || (urlToClass == null)) {
return;
}
if (!this.classesMap.containsKey(className)) {
this.classesMap.put(className, urlToClass);
}
} | java | public final void addClass(final String className, final URL urlToClass) {
if ((className == null) || (urlToClass == null)) {
return;
}
if (!this.classesMap.containsKey(className)) {
this.classesMap.put(className, urlToClass);
}
} | [
"public",
"final",
"void",
"addClass",
"(",
"final",
"String",
"className",
",",
"final",
"URL",
"urlToClass",
")",
"{",
"if",
"(",
"(",
"className",
"==",
"null",
")",
"||",
"(",
"urlToClass",
"==",
"null",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"this",
".",
"classesMap",
".",
"containsKey",
"(",
"className",
")",
")",
"{",
"this",
".",
"classesMap",
".",
"put",
"(",
"className",
",",
"urlToClass",
")",
";",
"}",
"}"
] | add a class to known class
@param className
class name
@param urlToClass
url to class file | [
"add",
"a",
"class",
"to",
"known",
"class"
] | train | https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1292-L1300 |
Nordstrom/JUnit-Foundation | src/main/java/com/nordstrom/automation/junit/RetryHandler.java | RetryHandler.isRetriable | static boolean isRetriable(final FrameworkMethod method, final Throwable thrown) {
"""
Determine if the specified failed test should be retried.
@param method failed test method
@param thrown exception for this failed test
@return {@code true} if test should be retried; otherwise {@code false}
"""
synchronized(retryAnalyzerLoader) {
for (JUnitRetryAnalyzer analyzer : retryAnalyzerLoader) {
if (analyzer.retry(method, thrown)) {
return true;
}
}
}
return false;
} | java | static boolean isRetriable(final FrameworkMethod method, final Throwable thrown) {
synchronized(retryAnalyzerLoader) {
for (JUnitRetryAnalyzer analyzer : retryAnalyzerLoader) {
if (analyzer.retry(method, thrown)) {
return true;
}
}
}
return false;
} | [
"static",
"boolean",
"isRetriable",
"(",
"final",
"FrameworkMethod",
"method",
",",
"final",
"Throwable",
"thrown",
")",
"{",
"synchronized",
"(",
"retryAnalyzerLoader",
")",
"{",
"for",
"(",
"JUnitRetryAnalyzer",
"analyzer",
":",
"retryAnalyzerLoader",
")",
"{",
"if",
"(",
"analyzer",
".",
"retry",
"(",
"method",
",",
"thrown",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Determine if the specified failed test should be retried.
@param method failed test method
@param thrown exception for this failed test
@return {@code true} if test should be retried; otherwise {@code false} | [
"Determine",
"if",
"the",
"specified",
"failed",
"test",
"should",
"be",
"retried",
"."
] | train | https://github.com/Nordstrom/JUnit-Foundation/blob/f24d91f8677d262c27d18ef29ed633eaac717be5/src/main/java/com/nordstrom/automation/junit/RetryHandler.java#L129-L138 |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d3/dfx/RectangularPrism3dfx.java | RectangularPrism3dfx.depthProperty | @Pure
public DoubleProperty depthProperty() {
"""
Replies the property that is the depth of the box.
@return the depth property.
"""
if (this.depth == null) {
this.depth = new ReadOnlyDoubleWrapper(this, MathFXAttributeNames.DEPTH);
this.depth.bind(Bindings.subtract(maxZProperty(), minZProperty()));
}
return this.depth;
} | java | @Pure
public DoubleProperty depthProperty() {
if (this.depth == null) {
this.depth = new ReadOnlyDoubleWrapper(this, MathFXAttributeNames.DEPTH);
this.depth.bind(Bindings.subtract(maxZProperty(), minZProperty()));
}
return this.depth;
} | [
"@",
"Pure",
"public",
"DoubleProperty",
"depthProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"depth",
"==",
"null",
")",
"{",
"this",
".",
"depth",
"=",
"new",
"ReadOnlyDoubleWrapper",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"DEPTH",
")",
";",
"this",
".",
"depth",
".",
"bind",
"(",
"Bindings",
".",
"subtract",
"(",
"maxZProperty",
"(",
")",
",",
"minZProperty",
"(",
")",
")",
")",
";",
"}",
"return",
"this",
".",
"depth",
";",
"}"
] | Replies the property that is the depth of the box.
@return the depth property. | [
"Replies",
"the",
"property",
"that",
"is",
"the",
"depth",
"of",
"the",
"box",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d3/dfx/RectangularPrism3dfx.java#L404-L411 |
netty/netty | codec-http2/src/main/java/io/netty/handler/codec/http2/CompressorHttp2ConnectionEncoder.java | CompressorHttp2ConnectionEncoder.newCompressionChannel | private EmbeddedChannel newCompressionChannel(final ChannelHandlerContext ctx, ZlibWrapper wrapper) {
"""
Generate a new instance of an {@link EmbeddedChannel} capable of compressing data
@param ctx the context.
@param wrapper Defines what type of encoder should be used
"""
return new EmbeddedChannel(ctx.channel().id(), ctx.channel().metadata().hasDisconnect(),
ctx.channel().config(), ZlibCodecFactory.newZlibEncoder(wrapper, compressionLevel, windowBits,
memLevel));
} | java | private EmbeddedChannel newCompressionChannel(final ChannelHandlerContext ctx, ZlibWrapper wrapper) {
return new EmbeddedChannel(ctx.channel().id(), ctx.channel().metadata().hasDisconnect(),
ctx.channel().config(), ZlibCodecFactory.newZlibEncoder(wrapper, compressionLevel, windowBits,
memLevel));
} | [
"private",
"EmbeddedChannel",
"newCompressionChannel",
"(",
"final",
"ChannelHandlerContext",
"ctx",
",",
"ZlibWrapper",
"wrapper",
")",
"{",
"return",
"new",
"EmbeddedChannel",
"(",
"ctx",
".",
"channel",
"(",
")",
".",
"id",
"(",
")",
",",
"ctx",
".",
"channel",
"(",
")",
".",
"metadata",
"(",
")",
".",
"hasDisconnect",
"(",
")",
",",
"ctx",
".",
"channel",
"(",
")",
".",
"config",
"(",
")",
",",
"ZlibCodecFactory",
".",
"newZlibEncoder",
"(",
"wrapper",
",",
"compressionLevel",
",",
"windowBits",
",",
"memLevel",
")",
")",
";",
"}"
] | Generate a new instance of an {@link EmbeddedChannel} capable of compressing data
@param ctx the context.
@param wrapper Defines what type of encoder should be used | [
"Generate",
"a",
"new",
"instance",
"of",
"an",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http2/src/main/java/io/netty/handler/codec/http2/CompressorHttp2ConnectionEncoder.java#L222-L226 |
Azure/azure-sdk-for-java | servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClient.java | ManagementClient.subscriptionExists | public Boolean subscriptionExists(String topicPath, String subscriptionName) throws ServiceBusException, InterruptedException {
"""
Checks whether a given subscription exists or not.
@param topicPath - Path of the topic
@param subscriptionName - Name of the subscription.
@return - True if the entity exists. False otherwise.
@throws IllegalArgumentException - path is not null / empty / too long / invalid.
@throws TimeoutException - The operation times out. The timeout period is initiated through ClientSettings.operationTimeout
@throws AuthorizationFailedException - No sufficient permission to perform this operation. Please check ClientSettings.tokenProvider has correct details.
@throws ServerBusyException - The server is busy. You should wait before you retry the operation.
@throws ServiceBusException - An internal error or an unexpected exception occurred.
@throws InterruptedException if the current thread was interrupted
"""
return Utils.completeFuture(this.asyncClient.subscriptionExistsAsync(topicPath, subscriptionName));
} | java | public Boolean subscriptionExists(String topicPath, String subscriptionName) throws ServiceBusException, InterruptedException {
return Utils.completeFuture(this.asyncClient.subscriptionExistsAsync(topicPath, subscriptionName));
} | [
"public",
"Boolean",
"subscriptionExists",
"(",
"String",
"topicPath",
",",
"String",
"subscriptionName",
")",
"throws",
"ServiceBusException",
",",
"InterruptedException",
"{",
"return",
"Utils",
".",
"completeFuture",
"(",
"this",
".",
"asyncClient",
".",
"subscriptionExistsAsync",
"(",
"topicPath",
",",
"subscriptionName",
")",
")",
";",
"}"
] | Checks whether a given subscription exists or not.
@param topicPath - Path of the topic
@param subscriptionName - Name of the subscription.
@return - True if the entity exists. False otherwise.
@throws IllegalArgumentException - path is not null / empty / too long / invalid.
@throws TimeoutException - The operation times out. The timeout period is initiated through ClientSettings.operationTimeout
@throws AuthorizationFailedException - No sufficient permission to perform this operation. Please check ClientSettings.tokenProvider has correct details.
@throws ServerBusyException - The server is busy. You should wait before you retry the operation.
@throws ServiceBusException - An internal error or an unexpected exception occurred.
@throws InterruptedException if the current thread was interrupted | [
"Checks",
"whether",
"a",
"given",
"subscription",
"exists",
"or",
"not",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClient.java#L535-L537 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java | AbstractExecutableMemberWriter.addTypeParameters | protected void addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
"""
Add the type parameters for the executable member.
@param member the member to write type parameters for.
@param htmltree the content tree to which the parameters will be added.
"""
Content typeParameters = getTypeParameters(member);
if (!typeParameters.isEmpty()) {
htmltree.addContent(typeParameters);
htmltree.addContent(writer.getSpace());
}
} | java | protected void addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
Content typeParameters = getTypeParameters(member);
if (!typeParameters.isEmpty()) {
htmltree.addContent(typeParameters);
htmltree.addContent(writer.getSpace());
}
} | [
"protected",
"void",
"addTypeParameters",
"(",
"ExecutableMemberDoc",
"member",
",",
"Content",
"htmltree",
")",
"{",
"Content",
"typeParameters",
"=",
"getTypeParameters",
"(",
"member",
")",
";",
"if",
"(",
"!",
"typeParameters",
".",
"isEmpty",
"(",
")",
")",
"{",
"htmltree",
".",
"addContent",
"(",
"typeParameters",
")",
";",
"htmltree",
".",
"addContent",
"(",
"writer",
".",
"getSpace",
"(",
")",
")",
";",
"}",
"}"
] | Add the type parameters for the executable member.
@param member the member to write type parameters for.
@param htmltree the content tree to which the parameters will be added. | [
"Add",
"the",
"type",
"parameters",
"for",
"the",
"executable",
"member",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java#L63-L69 |
Alluxio/alluxio | core/server/master/src/main/java/alluxio/master/file/activesync/ActiveSyncManager.java | ActiveSyncManager.recoverFromStartSync | public void recoverFromStartSync(AlluxioURI uri, long mountId) {
"""
Recover from start sync operation.
@param uri uri to start sync
@param mountId mount id of the uri
"""
// if the init sync has been launched, we need to stop it
if (mSyncPathStatus.containsKey(uri)) {
Future<?> syncFuture = mSyncPathStatus.remove(uri);
if (syncFuture != null) {
syncFuture.cancel(true);
}
}
// if the polling thread has been launched, we need to stop it
mFilterMap.remove(mountId);
Future<?> future = mPollerMap.remove(mountId);
if (future != null) {
future.cancel(true);
}
} | java | public void recoverFromStartSync(AlluxioURI uri, long mountId) {
// if the init sync has been launched, we need to stop it
if (mSyncPathStatus.containsKey(uri)) {
Future<?> syncFuture = mSyncPathStatus.remove(uri);
if (syncFuture != null) {
syncFuture.cancel(true);
}
}
// if the polling thread has been launched, we need to stop it
mFilterMap.remove(mountId);
Future<?> future = mPollerMap.remove(mountId);
if (future != null) {
future.cancel(true);
}
} | [
"public",
"void",
"recoverFromStartSync",
"(",
"AlluxioURI",
"uri",
",",
"long",
"mountId",
")",
"{",
"// if the init sync has been launched, we need to stop it",
"if",
"(",
"mSyncPathStatus",
".",
"containsKey",
"(",
"uri",
")",
")",
"{",
"Future",
"<",
"?",
">",
"syncFuture",
"=",
"mSyncPathStatus",
".",
"remove",
"(",
"uri",
")",
";",
"if",
"(",
"syncFuture",
"!=",
"null",
")",
"{",
"syncFuture",
".",
"cancel",
"(",
"true",
")",
";",
"}",
"}",
"// if the polling thread has been launched, we need to stop it",
"mFilterMap",
".",
"remove",
"(",
"mountId",
")",
";",
"Future",
"<",
"?",
">",
"future",
"=",
"mPollerMap",
".",
"remove",
"(",
"mountId",
")",
";",
"if",
"(",
"future",
"!=",
"null",
")",
"{",
"future",
".",
"cancel",
"(",
"true",
")",
";",
"}",
"}"
] | Recover from start sync operation.
@param uri uri to start sync
@param mountId mount id of the uri | [
"Recover",
"from",
"start",
"sync",
"operation",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/activesync/ActiveSyncManager.java#L655-L670 |
prolificinteractive/material-calendarview | library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java | MaterialCalendarView.selectRange | public void selectRange(final CalendarDay firstDay, final CalendarDay lastDay) {
"""
Select a fresh range of date including first day and last day.
@param firstDay first day of the range to select
@param lastDay last day of the range to select
"""
if (firstDay == null || lastDay == null) {
return;
} else if (firstDay.isAfter(lastDay)) {
adapter.selectRange(lastDay, firstDay);
dispatchOnRangeSelected(adapter.getSelectedDates());
} else {
adapter.selectRange(firstDay, lastDay);
dispatchOnRangeSelected(adapter.getSelectedDates());
}
} | java | public void selectRange(final CalendarDay firstDay, final CalendarDay lastDay) {
if (firstDay == null || lastDay == null) {
return;
} else if (firstDay.isAfter(lastDay)) {
adapter.selectRange(lastDay, firstDay);
dispatchOnRangeSelected(adapter.getSelectedDates());
} else {
adapter.selectRange(firstDay, lastDay);
dispatchOnRangeSelected(adapter.getSelectedDates());
}
} | [
"public",
"void",
"selectRange",
"(",
"final",
"CalendarDay",
"firstDay",
",",
"final",
"CalendarDay",
"lastDay",
")",
"{",
"if",
"(",
"firstDay",
"==",
"null",
"||",
"lastDay",
"==",
"null",
")",
"{",
"return",
";",
"}",
"else",
"if",
"(",
"firstDay",
".",
"isAfter",
"(",
"lastDay",
")",
")",
"{",
"adapter",
".",
"selectRange",
"(",
"lastDay",
",",
"firstDay",
")",
";",
"dispatchOnRangeSelected",
"(",
"adapter",
".",
"getSelectedDates",
"(",
")",
")",
";",
"}",
"else",
"{",
"adapter",
".",
"selectRange",
"(",
"firstDay",
",",
"lastDay",
")",
";",
"dispatchOnRangeSelected",
"(",
"adapter",
".",
"getSelectedDates",
"(",
")",
")",
";",
"}",
"}"
] | Select a fresh range of date including first day and last day.
@param firstDay first day of the range to select
@param lastDay last day of the range to select | [
"Select",
"a",
"fresh",
"range",
"of",
"date",
"including",
"first",
"day",
"and",
"last",
"day",
"."
] | train | https://github.com/prolificinteractive/material-calendarview/blob/04fae8175fd034d0a7131f8cb253cae883a88aa2/library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java#L1451-L1461 |
zaproxy/zaproxy | src/org/parosproxy/paros/network/HttpMethodHelper.java | HttpMethodHelper.createRequestMethod | public HttpMethod createRequestMethod(HttpRequestHeader header, HttpBody body) throws URIException {
"""
may be replaced by the New method - however the New method is not yet fully tested so this is stil used.
"""
return createRequestMethod(header, body, null);
} | java | public HttpMethod createRequestMethod(HttpRequestHeader header, HttpBody body) throws URIException {
return createRequestMethod(header, body, null);
} | [
"public",
"HttpMethod",
"createRequestMethod",
"(",
"HttpRequestHeader",
"header",
",",
"HttpBody",
"body",
")",
"throws",
"URIException",
"{",
"return",
"createRequestMethod",
"(",
"header",
",",
"body",
",",
"null",
")",
";",
"}"
] | may be replaced by the New method - however the New method is not yet fully tested so this is stil used. | [
"may",
"be",
"replaced",
"by",
"the",
"New",
"method",
"-",
"however",
"the",
"New",
"method",
"is",
"not",
"yet",
"fully",
"tested",
"so",
"this",
"is",
"stil",
"used",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/network/HttpMethodHelper.java#L136-L138 |
michael-rapp/AndroidMaterialPreferences | library/src/main/java/de/mrapp/android/preference/ListPreference.java | ListPreference.createListItemListener | private OnClickListener createListItemListener() {
"""
Creates and returns a listener, which allows to persist the value a list item, which is
clicked by the user.
@return The listener, which has been created, as an instance of the type {@link
OnClickListener}
"""
return new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int which) {
selectedIndex = which;
ListPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
dialog.dismiss();
}
};
} | java | private OnClickListener createListItemListener() {
return new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int which) {
selectedIndex = which;
ListPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
dialog.dismiss();
}
};
} | [
"private",
"OnClickListener",
"createListItemListener",
"(",
")",
"{",
"return",
"new",
"OnClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"final",
"DialogInterface",
"dialog",
",",
"final",
"int",
"which",
")",
"{",
"selectedIndex",
"=",
"which",
";",
"ListPreference",
".",
"this",
".",
"onClick",
"(",
"dialog",
",",
"DialogInterface",
".",
"BUTTON_POSITIVE",
")",
";",
"dialog",
".",
"dismiss",
"(",
")",
";",
"}",
"}",
";",
"}"
] | Creates and returns a listener, which allows to persist the value a list item, which is
clicked by the user.
@return The listener, which has been created, as an instance of the type {@link
OnClickListener} | [
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"persist",
"the",
"value",
"a",
"list",
"item",
"which",
"is",
"clicked",
"by",
"the",
"user",
"."
] | train | https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/ListPreference.java#L134-L144 |
akberc/ceylon-maven-plugin | src/main/java/com/dgwave/car/maven/CeylonInstall.java | CeylonInstall.installAdditional | void installAdditional(final File installedFile, final String fileExt, final String payload, final boolean chop)
throws MojoExecutionException {
"""
Installs additional files into the same repo directory as the artifact.
@param installedFile The artifact to which this additional file is related
@param fileExt The full file name or extension (begins with .) of the additional file
@param payload The String to write to the additional file
@param chop True of it replaces the artifact extension, false to attach the extension
@throws MojoExecutionException In case of installation error
"""
File additionalFile = null;
if (chop) {
String path = installedFile.getAbsolutePath();
additionalFile = new File(path.substring(0, path.lastIndexOf('.')) + fileExt);
} else {
if (fileExt.indexOf('.') > 0) {
additionalFile = new File(installedFile.getParentFile(), fileExt);
} else {
additionalFile = new File(installedFile.getAbsolutePath() + fileExt);
}
}
getLog().debug("Installing additional file to " + additionalFile);
try {
additionalFile.getParentFile().mkdirs();
FileUtils.fileWrite(additionalFile.getAbsolutePath(), "UTF-8", payload);
} catch (IOException e) {
throw new MojoExecutionException("Failed to install additional file to " + additionalFile, e);
}
} | java | void installAdditional(final File installedFile, final String fileExt, final String payload, final boolean chop)
throws MojoExecutionException {
File additionalFile = null;
if (chop) {
String path = installedFile.getAbsolutePath();
additionalFile = new File(path.substring(0, path.lastIndexOf('.')) + fileExt);
} else {
if (fileExt.indexOf('.') > 0) {
additionalFile = new File(installedFile.getParentFile(), fileExt);
} else {
additionalFile = new File(installedFile.getAbsolutePath() + fileExt);
}
}
getLog().debug("Installing additional file to " + additionalFile);
try {
additionalFile.getParentFile().mkdirs();
FileUtils.fileWrite(additionalFile.getAbsolutePath(), "UTF-8", payload);
} catch (IOException e) {
throw new MojoExecutionException("Failed to install additional file to " + additionalFile, e);
}
} | [
"void",
"installAdditional",
"(",
"final",
"File",
"installedFile",
",",
"final",
"String",
"fileExt",
",",
"final",
"String",
"payload",
",",
"final",
"boolean",
"chop",
")",
"throws",
"MojoExecutionException",
"{",
"File",
"additionalFile",
"=",
"null",
";",
"if",
"(",
"chop",
")",
"{",
"String",
"path",
"=",
"installedFile",
".",
"getAbsolutePath",
"(",
")",
";",
"additionalFile",
"=",
"new",
"File",
"(",
"path",
".",
"substring",
"(",
"0",
",",
"path",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
")",
"+",
"fileExt",
")",
";",
"}",
"else",
"{",
"if",
"(",
"fileExt",
".",
"indexOf",
"(",
"'",
"'",
")",
">",
"0",
")",
"{",
"additionalFile",
"=",
"new",
"File",
"(",
"installedFile",
".",
"getParentFile",
"(",
")",
",",
"fileExt",
")",
";",
"}",
"else",
"{",
"additionalFile",
"=",
"new",
"File",
"(",
"installedFile",
".",
"getAbsolutePath",
"(",
")",
"+",
"fileExt",
")",
";",
"}",
"}",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Installing additional file to \"",
"+",
"additionalFile",
")",
";",
"try",
"{",
"additionalFile",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"FileUtils",
".",
"fileWrite",
"(",
"additionalFile",
".",
"getAbsolutePath",
"(",
")",
",",
"\"UTF-8\"",
",",
"payload",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Failed to install additional file to \"",
"+",
"additionalFile",
",",
"e",
")",
";",
"}",
"}"
] | Installs additional files into the same repo directory as the artifact.
@param installedFile The artifact to which this additional file is related
@param fileExt The full file name or extension (begins with .) of the additional file
@param payload The String to write to the additional file
@param chop True of it replaces the artifact extension, false to attach the extension
@throws MojoExecutionException In case of installation error | [
"Installs",
"additional",
"files",
"into",
"the",
"same",
"repo",
"directory",
"as",
"the",
"artifact",
"."
] | train | https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/maven/CeylonInstall.java#L289-L309 |
pietermartin/sqlg | sqlg-core/src/main/java/org/umlg/sqlg/sql/parse/GremlinParser.java | GremlinParser.parse | public SchemaTableTree parse(SchemaTable schemaTable, ReplacedStepTree replacedStepTree) {
"""
This is only called for vertex steps.
Constructs the label paths from the given schemaTable to the leaf vertex labels for the gremlin query.
For each path Sqlg will executeRegularQuery a sql query. The union of the queries is the result the gremlin query.
The vertex labels can be calculated from the steps.
@param schemaTable The schema and table
@param replacedStepTree The original VertexSteps and HasSteps that were replaced
@return a List of paths. Each path is itself a list of SchemaTables.
"""
ReplacedStep<?, ?> rootReplacedStep = replacedStepTree.root().getReplacedStep();
Preconditions.checkArgument(!rootReplacedStep.isGraphStep(), "Expected VertexStep, found GraphStep");
Set<SchemaTableTree> schemaTableTrees = new HashSet<>();
//replacedSteps contains a fake label representing the incoming vertex for the SqlgVertexStepStrategy.
SchemaTableTree rootSchemaTableTree = new SchemaTableTree(this.sqlgGraph, schemaTable, 0, replacedStepTree.getDepth());
rootSchemaTableTree.setOptionalLeftJoin(rootReplacedStep.isLeftJoin());
rootSchemaTableTree.setEmit(rootReplacedStep.isEmit());
rootSchemaTableTree.setUntilFirst(rootReplacedStep.isUntilFirst());
rootSchemaTableTree.initializeAliasColumnNameMaps();
rootSchemaTableTree.setStepType(schemaTable.isVertexTable() ? SchemaTableTree.STEP_TYPE.VERTEX_STEP : SchemaTableTree.STEP_TYPE.EDGE_VERTEX_STEP);
schemaTableTrees.add(rootSchemaTableTree);
replacedStepTree.walkReplacedSteps(schemaTableTrees);
rootSchemaTableTree.removeNodesInvalidatedByHas();
rootSchemaTableTree.removeAllButDeepestAndAddCacheLeafNodes(replacedStepTree.getDepth());
rootSchemaTableTree.setLocalStep(true);
return rootSchemaTableTree;
} | java | public SchemaTableTree parse(SchemaTable schemaTable, ReplacedStepTree replacedStepTree) {
ReplacedStep<?, ?> rootReplacedStep = replacedStepTree.root().getReplacedStep();
Preconditions.checkArgument(!rootReplacedStep.isGraphStep(), "Expected VertexStep, found GraphStep");
Set<SchemaTableTree> schemaTableTrees = new HashSet<>();
//replacedSteps contains a fake label representing the incoming vertex for the SqlgVertexStepStrategy.
SchemaTableTree rootSchemaTableTree = new SchemaTableTree(this.sqlgGraph, schemaTable, 0, replacedStepTree.getDepth());
rootSchemaTableTree.setOptionalLeftJoin(rootReplacedStep.isLeftJoin());
rootSchemaTableTree.setEmit(rootReplacedStep.isEmit());
rootSchemaTableTree.setUntilFirst(rootReplacedStep.isUntilFirst());
rootSchemaTableTree.initializeAliasColumnNameMaps();
rootSchemaTableTree.setStepType(schemaTable.isVertexTable() ? SchemaTableTree.STEP_TYPE.VERTEX_STEP : SchemaTableTree.STEP_TYPE.EDGE_VERTEX_STEP);
schemaTableTrees.add(rootSchemaTableTree);
replacedStepTree.walkReplacedSteps(schemaTableTrees);
rootSchemaTableTree.removeNodesInvalidatedByHas();
rootSchemaTableTree.removeAllButDeepestAndAddCacheLeafNodes(replacedStepTree.getDepth());
rootSchemaTableTree.setLocalStep(true);
return rootSchemaTableTree;
} | [
"public",
"SchemaTableTree",
"parse",
"(",
"SchemaTable",
"schemaTable",
",",
"ReplacedStepTree",
"replacedStepTree",
")",
"{",
"ReplacedStep",
"<",
"?",
",",
"?",
">",
"rootReplacedStep",
"=",
"replacedStepTree",
".",
"root",
"(",
")",
".",
"getReplacedStep",
"(",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"rootReplacedStep",
".",
"isGraphStep",
"(",
")",
",",
"\"Expected VertexStep, found GraphStep\"",
")",
";",
"Set",
"<",
"SchemaTableTree",
">",
"schemaTableTrees",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"//replacedSteps contains a fake label representing the incoming vertex for the SqlgVertexStepStrategy.",
"SchemaTableTree",
"rootSchemaTableTree",
"=",
"new",
"SchemaTableTree",
"(",
"this",
".",
"sqlgGraph",
",",
"schemaTable",
",",
"0",
",",
"replacedStepTree",
".",
"getDepth",
"(",
")",
")",
";",
"rootSchemaTableTree",
".",
"setOptionalLeftJoin",
"(",
"rootReplacedStep",
".",
"isLeftJoin",
"(",
")",
")",
";",
"rootSchemaTableTree",
".",
"setEmit",
"(",
"rootReplacedStep",
".",
"isEmit",
"(",
")",
")",
";",
"rootSchemaTableTree",
".",
"setUntilFirst",
"(",
"rootReplacedStep",
".",
"isUntilFirst",
"(",
")",
")",
";",
"rootSchemaTableTree",
".",
"initializeAliasColumnNameMaps",
"(",
")",
";",
"rootSchemaTableTree",
".",
"setStepType",
"(",
"schemaTable",
".",
"isVertexTable",
"(",
")",
"?",
"SchemaTableTree",
".",
"STEP_TYPE",
".",
"VERTEX_STEP",
":",
"SchemaTableTree",
".",
"STEP_TYPE",
".",
"EDGE_VERTEX_STEP",
")",
";",
"schemaTableTrees",
".",
"add",
"(",
"rootSchemaTableTree",
")",
";",
"replacedStepTree",
".",
"walkReplacedSteps",
"(",
"schemaTableTrees",
")",
";",
"rootSchemaTableTree",
".",
"removeNodesInvalidatedByHas",
"(",
")",
";",
"rootSchemaTableTree",
".",
"removeAllButDeepestAndAddCacheLeafNodes",
"(",
"replacedStepTree",
".",
"getDepth",
"(",
")",
")",
";",
"rootSchemaTableTree",
".",
"setLocalStep",
"(",
"true",
")",
";",
"return",
"rootSchemaTableTree",
";",
"}"
] | This is only called for vertex steps.
Constructs the label paths from the given schemaTable to the leaf vertex labels for the gremlin query.
For each path Sqlg will executeRegularQuery a sql query. The union of the queries is the result the gremlin query.
The vertex labels can be calculated from the steps.
@param schemaTable The schema and table
@param replacedStepTree The original VertexSteps and HasSteps that were replaced
@return a List of paths. Each path is itself a list of SchemaTables. | [
"This",
"is",
"only",
"called",
"for",
"vertex",
"steps",
".",
"Constructs",
"the",
"label",
"paths",
"from",
"the",
"given",
"schemaTable",
"to",
"the",
"leaf",
"vertex",
"labels",
"for",
"the",
"gremlin",
"query",
".",
"For",
"each",
"path",
"Sqlg",
"will",
"executeRegularQuery",
"a",
"sql",
"query",
".",
"The",
"union",
"of",
"the",
"queries",
"is",
"the",
"result",
"the",
"gremlin",
"query",
".",
"The",
"vertex",
"labels",
"can",
"be",
"calculated",
"from",
"the",
"steps",
"."
] | train | https://github.com/pietermartin/sqlg/blob/c1845a1b31328a5ffda646873b0369ee72af56a7/sqlg-core/src/main/java/org/umlg/sqlg/sql/parse/GremlinParser.java#L53-L71 |
zaproxy/zaproxy | src/org/parosproxy/paros/network/SSLConnector.java | SSLConnector.createSocket | @Override
public Socket createSocket(final String host, final int port,
final InetAddress localAddress, final int localPort,
final HttpConnectionParams params) throws IOException,
UnknownHostException, ConnectTimeoutException {
"""
Attempts to get a new socket connection to the given host within the
given time limit.
@param host
the host name/IP
@param port
the port on the host
@param localAddress
the local host name/IP to bind the socket to
@param localPort
the port on the local machine
@param params
{@link HttpConnectionParams Http connection parameters}
@return Socket a new socket
@throws IOException
if an I/O error occurs while creating the socket
@throws UnknownHostException
if the IP address of the host cannot be determined
@throws ConnectTimeoutException
"""
if (params == null) {
throw new IllegalArgumentException("Parameters may not be null");
}
int timeout = params.getConnectionTimeout();
if (timeout == 0) {
InetAddress hostAddress = getCachedMisconfiguredHost(host, port);
if (hostAddress != null) {
return clientSSLSockFactory.createSocket(hostAddress, port, localAddress, localPort);
}
try {
SSLSocket sslSocket = (SSLSocket) clientSSLSockFactory.createSocket(host, port, localAddress, localPort);
sslSocket.startHandshake();
return sslSocket;
} catch (SSLException e) {
if (!e.getMessage().contains(CONTENTS_UNRECOGNIZED_NAME_EXCEPTION)) {
throw e;
}
hostAddress = InetAddress.getByName(host);
cacheMisconfiguredHost(host, port, hostAddress);
return clientSSLSockFactory.createSocket(hostAddress, port, localAddress, localPort);
}
}
Socket socket = clientSSLSockFactory.createSocket();
SocketAddress localAddr = new InetSocketAddress(localAddress, localPort);
socket.bind(localAddr);
SocketAddress remoteAddr = new InetSocketAddress(host, port);
socket.connect(remoteAddr, timeout);
return socket;
} | java | @Override
public Socket createSocket(final String host, final int port,
final InetAddress localAddress, final int localPort,
final HttpConnectionParams params) throws IOException,
UnknownHostException, ConnectTimeoutException {
if (params == null) {
throw new IllegalArgumentException("Parameters may not be null");
}
int timeout = params.getConnectionTimeout();
if (timeout == 0) {
InetAddress hostAddress = getCachedMisconfiguredHost(host, port);
if (hostAddress != null) {
return clientSSLSockFactory.createSocket(hostAddress, port, localAddress, localPort);
}
try {
SSLSocket sslSocket = (SSLSocket) clientSSLSockFactory.createSocket(host, port, localAddress, localPort);
sslSocket.startHandshake();
return sslSocket;
} catch (SSLException e) {
if (!e.getMessage().contains(CONTENTS_UNRECOGNIZED_NAME_EXCEPTION)) {
throw e;
}
hostAddress = InetAddress.getByName(host);
cacheMisconfiguredHost(host, port, hostAddress);
return clientSSLSockFactory.createSocket(hostAddress, port, localAddress, localPort);
}
}
Socket socket = clientSSLSockFactory.createSocket();
SocketAddress localAddr = new InetSocketAddress(localAddress, localPort);
socket.bind(localAddr);
SocketAddress remoteAddr = new InetSocketAddress(host, port);
socket.connect(remoteAddr, timeout);
return socket;
} | [
"@",
"Override",
"public",
"Socket",
"createSocket",
"(",
"final",
"String",
"host",
",",
"final",
"int",
"port",
",",
"final",
"InetAddress",
"localAddress",
",",
"final",
"int",
"localPort",
",",
"final",
"HttpConnectionParams",
"params",
")",
"throws",
"IOException",
",",
"UnknownHostException",
",",
"ConnectTimeoutException",
"{",
"if",
"(",
"params",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameters may not be null\"",
")",
";",
"}",
"int",
"timeout",
"=",
"params",
".",
"getConnectionTimeout",
"(",
")",
";",
"if",
"(",
"timeout",
"==",
"0",
")",
"{",
"InetAddress",
"hostAddress",
"=",
"getCachedMisconfiguredHost",
"(",
"host",
",",
"port",
")",
";",
"if",
"(",
"hostAddress",
"!=",
"null",
")",
"{",
"return",
"clientSSLSockFactory",
".",
"createSocket",
"(",
"hostAddress",
",",
"port",
",",
"localAddress",
",",
"localPort",
")",
";",
"}",
"try",
"{",
"SSLSocket",
"sslSocket",
"=",
"(",
"SSLSocket",
")",
"clientSSLSockFactory",
".",
"createSocket",
"(",
"host",
",",
"port",
",",
"localAddress",
",",
"localPort",
")",
";",
"sslSocket",
".",
"startHandshake",
"(",
")",
";",
"return",
"sslSocket",
";",
"}",
"catch",
"(",
"SSLException",
"e",
")",
"{",
"if",
"(",
"!",
"e",
".",
"getMessage",
"(",
")",
".",
"contains",
"(",
"CONTENTS_UNRECOGNIZED_NAME_EXCEPTION",
")",
")",
"{",
"throw",
"e",
";",
"}",
"hostAddress",
"=",
"InetAddress",
".",
"getByName",
"(",
"host",
")",
";",
"cacheMisconfiguredHost",
"(",
"host",
",",
"port",
",",
"hostAddress",
")",
";",
"return",
"clientSSLSockFactory",
".",
"createSocket",
"(",
"hostAddress",
",",
"port",
",",
"localAddress",
",",
"localPort",
")",
";",
"}",
"}",
"Socket",
"socket",
"=",
"clientSSLSockFactory",
".",
"createSocket",
"(",
")",
";",
"SocketAddress",
"localAddr",
"=",
"new",
"InetSocketAddress",
"(",
"localAddress",
",",
"localPort",
")",
";",
"socket",
".",
"bind",
"(",
"localAddr",
")",
";",
"SocketAddress",
"remoteAddr",
"=",
"new",
"InetSocketAddress",
"(",
"host",
",",
"port",
")",
";",
"socket",
".",
"connect",
"(",
"remoteAddr",
",",
"timeout",
")",
";",
"return",
"socket",
";",
"}"
] | Attempts to get a new socket connection to the given host within the
given time limit.
@param host
the host name/IP
@param port
the port on the host
@param localAddress
the local host name/IP to bind the socket to
@param localPort
the port on the local machine
@param params
{@link HttpConnectionParams Http connection parameters}
@return Socket a new socket
@throws IOException
if an I/O error occurs while creating the socket
@throws UnknownHostException
if the IP address of the host cannot be determined
@throws ConnectTimeoutException | [
"Attempts",
"to",
"get",
"a",
"new",
"socket",
"connection",
"to",
"the",
"given",
"host",
"within",
"the",
"given",
"time",
"limit",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/network/SSLConnector.java#L409-L445 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/code/AsCodeGen.java | AsCodeGen.writeImport | @Override
public void writeImport(Definition def, Writer out) throws IOException {
"""
Output class import
@param def definition
@param out Writer
@throws IOException ioException
"""
out.write("package " + def.getRaPackage() + ".inflow;\n\n");
importLogging(def, out);
if (def.isUseAnnotation())
{
out.write("import javax.resource.spi.Activation;");
writeEol(out);
}
out.write("import javax.resource.spi.ActivationSpec;\n");
if (def.isUseAnnotation())
{
importConfigProperty(def, out);
}
out.write("import javax.resource.spi.InvalidPropertyException;\n");
out.write("import javax.resource.spi.ResourceAdapter;\n");
if (def.isUseAnnotation())
{
for (int i = 0; i < getConfigProps(def).size(); i++)
{
if (getConfigProps(def).get(i).isRequired())
{
out.write("import javax.validation.constraints.NotNull;\n");
break;
}
}
}
} | java | @Override
public void writeImport(Definition def, Writer out) throws IOException
{
out.write("package " + def.getRaPackage() + ".inflow;\n\n");
importLogging(def, out);
if (def.isUseAnnotation())
{
out.write("import javax.resource.spi.Activation;");
writeEol(out);
}
out.write("import javax.resource.spi.ActivationSpec;\n");
if (def.isUseAnnotation())
{
importConfigProperty(def, out);
}
out.write("import javax.resource.spi.InvalidPropertyException;\n");
out.write("import javax.resource.spi.ResourceAdapter;\n");
if (def.isUseAnnotation())
{
for (int i = 0; i < getConfigProps(def).size(); i++)
{
if (getConfigProps(def).get(i).isRequired())
{
out.write("import javax.validation.constraints.NotNull;\n");
break;
}
}
}
} | [
"@",
"Override",
"public",
"void",
"writeImport",
"(",
"Definition",
"def",
",",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"out",
".",
"write",
"(",
"\"package \"",
"+",
"def",
".",
"getRaPackage",
"(",
")",
"+",
"\".inflow;\\n\\n\"",
")",
";",
"importLogging",
"(",
"def",
",",
"out",
")",
";",
"if",
"(",
"def",
".",
"isUseAnnotation",
"(",
")",
")",
"{",
"out",
".",
"write",
"(",
"\"import javax.resource.spi.Activation;\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"}",
"out",
".",
"write",
"(",
"\"import javax.resource.spi.ActivationSpec;\\n\"",
")",
";",
"if",
"(",
"def",
".",
"isUseAnnotation",
"(",
")",
")",
"{",
"importConfigProperty",
"(",
"def",
",",
"out",
")",
";",
"}",
"out",
".",
"write",
"(",
"\"import javax.resource.spi.InvalidPropertyException;\\n\"",
")",
";",
"out",
".",
"write",
"(",
"\"import javax.resource.spi.ResourceAdapter;\\n\"",
")",
";",
"if",
"(",
"def",
".",
"isUseAnnotation",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getConfigProps",
"(",
"def",
")",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"getConfigProps",
"(",
"def",
")",
".",
"get",
"(",
"i",
")",
".",
"isRequired",
"(",
")",
")",
"{",
"out",
".",
"write",
"(",
"\"import javax.validation.constraints.NotNull;\\n\"",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] | Output class import
@param def definition
@param out Writer
@throws IOException ioException | [
"Output",
"class",
"import"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/code/AsCodeGen.java#L146-L176 |
pmlopes/yoke | framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java | YokeRequest.destroySession | public void destroySession() {
"""
Destroys a session from the request context and also from the storage engine.
"""
JsonObject session = get("session");
if (session == null) {
return;
}
String sessionId = session.getString("id");
// remove from the context
put("session", null);
if (sessionId == null) {
return;
}
store.destroy(sessionId, new Handler<Object>() {
@Override
public void handle(Object error) {
if (error != null) {
// TODO: better handling of errors
System.err.println(error);
}
}
});
} | java | public void destroySession() {
JsonObject session = get("session");
if (session == null) {
return;
}
String sessionId = session.getString("id");
// remove from the context
put("session", null);
if (sessionId == null) {
return;
}
store.destroy(sessionId, new Handler<Object>() {
@Override
public void handle(Object error) {
if (error != null) {
// TODO: better handling of errors
System.err.println(error);
}
}
});
} | [
"public",
"void",
"destroySession",
"(",
")",
"{",
"JsonObject",
"session",
"=",
"get",
"(",
"\"session\"",
")",
";",
"if",
"(",
"session",
"==",
"null",
")",
"{",
"return",
";",
"}",
"String",
"sessionId",
"=",
"session",
".",
"getString",
"(",
"\"id\"",
")",
";",
"// remove from the context",
"put",
"(",
"\"session\"",
",",
"null",
")",
";",
"if",
"(",
"sessionId",
"==",
"null",
")",
"{",
"return",
";",
"}",
"store",
".",
"destroy",
"(",
"sessionId",
",",
"new",
"Handler",
"<",
"Object",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"handle",
"(",
"Object",
"error",
")",
"{",
"if",
"(",
"error",
"!=",
"null",
")",
"{",
"// TODO: better handling of errors",
"System",
".",
"err",
".",
"println",
"(",
"error",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Destroys a session from the request context and also from the storage engine. | [
"Destroys",
"a",
"session",
"from",
"the",
"request",
"context",
"and",
"also",
"from",
"the",
"storage",
"engine",
"."
] | train | https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L317-L340 |
puniverse/galaxy | src/main/java/co/paralleluniverse/common/io/Streamables.java | Streamables.writeBuffer | public static void writeBuffer(DataOutput out, ByteBuffer buffer) throws IOException {
"""
Writes the given {@link ByteBuffer} into the given {@link DataOutput}.
@param out The {@link DataOutput} into which the buffer will be written.
@param buffer The buffer to write into the {@link DataOutput}.
@throws IOException
"""
if (buffer.hasArray()) {
out.write(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
buffer.position(buffer.limit());
} else {
final byte[] array = new byte[buffer.remaining()];
buffer.get(array);
assert buffer.remaining() == 0 && buffer.position() == buffer.limit();
out.write(array);
}
} | java | public static void writeBuffer(DataOutput out, ByteBuffer buffer) throws IOException {
if (buffer.hasArray()) {
out.write(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
buffer.position(buffer.limit());
} else {
final byte[] array = new byte[buffer.remaining()];
buffer.get(array);
assert buffer.remaining() == 0 && buffer.position() == buffer.limit();
out.write(array);
}
} | [
"public",
"static",
"void",
"writeBuffer",
"(",
"DataOutput",
"out",
",",
"ByteBuffer",
"buffer",
")",
"throws",
"IOException",
"{",
"if",
"(",
"buffer",
".",
"hasArray",
"(",
")",
")",
"{",
"out",
".",
"write",
"(",
"buffer",
".",
"array",
"(",
")",
",",
"buffer",
".",
"arrayOffset",
"(",
")",
"+",
"buffer",
".",
"position",
"(",
")",
",",
"buffer",
".",
"remaining",
"(",
")",
")",
";",
"buffer",
".",
"position",
"(",
"buffer",
".",
"limit",
"(",
")",
")",
";",
"}",
"else",
"{",
"final",
"byte",
"[",
"]",
"array",
"=",
"new",
"byte",
"[",
"buffer",
".",
"remaining",
"(",
")",
"]",
";",
"buffer",
".",
"get",
"(",
"array",
")",
";",
"assert",
"buffer",
".",
"remaining",
"(",
")",
"==",
"0",
"&&",
"buffer",
".",
"position",
"(",
")",
"==",
"buffer",
".",
"limit",
"(",
")",
";",
"out",
".",
"write",
"(",
"array",
")",
";",
"}",
"}"
] | Writes the given {@link ByteBuffer} into the given {@link DataOutput}.
@param out The {@link DataOutput} into which the buffer will be written.
@param buffer The buffer to write into the {@link DataOutput}.
@throws IOException | [
"Writes",
"the",
"given",
"{",
"@link",
"ByteBuffer",
"}",
"into",
"the",
"given",
"{",
"@link",
"DataOutput",
"}",
"."
] | train | https://github.com/puniverse/galaxy/blob/1d077532c4a5bcd6c52ff670770c31e98420ff63/src/main/java/co/paralleluniverse/common/io/Streamables.java#L106-L116 |
sriharshachilakapati/WebGL4J | webgl4j/src/main/java/com/shc/webgl4j/client/WebGL10.java | WebGL10.glBindRenderbuffer | public static void glBindRenderbuffer(int target, int renderBuffer) {
"""
<p>{@code glBindRenderbuffer} binds the renderbuffer object with name renderbuffer to the renderbuffer target
specified by target. target must be {@code GL_RENDERBUFFER}. {@code renderbuffer} is the name of a renderbuffer
object previously returned from a call to {@link #glCreateRenderbuffer()}, or zero to break the existing binding
of a renderbuffer object to target.</p>
<p>{@link #GL_INVALID_ENUM} is generated if target is not {@code GL_RENDERBUFFER}.</p>
<p>{@link #GL_INVALID_OPERATION} is generated if renderbuffer is not zero or the name of a renderbuffer
previously returned from a call to {@link #glCreateRenderbuffer()}.</p>
@param target Specifies the renderbuffer target of the binding operation. target must be {@code
GL_RENDERBUFFER}.
@param renderBuffer Specifies the name of the renderbuffer object to bind.
"""
checkContextCompatibility();
nglBindRenderbuffer(target, WebGLObjectMap.get().toRenderBuffer(renderBuffer));
} | java | public static void glBindRenderbuffer(int target, int renderBuffer)
{
checkContextCompatibility();
nglBindRenderbuffer(target, WebGLObjectMap.get().toRenderBuffer(renderBuffer));
} | [
"public",
"static",
"void",
"glBindRenderbuffer",
"(",
"int",
"target",
",",
"int",
"renderBuffer",
")",
"{",
"checkContextCompatibility",
"(",
")",
";",
"nglBindRenderbuffer",
"(",
"target",
",",
"WebGLObjectMap",
".",
"get",
"(",
")",
".",
"toRenderBuffer",
"(",
"renderBuffer",
")",
")",
";",
"}"
] | <p>{@code glBindRenderbuffer} binds the renderbuffer object with name renderbuffer to the renderbuffer target
specified by target. target must be {@code GL_RENDERBUFFER}. {@code renderbuffer} is the name of a renderbuffer
object previously returned from a call to {@link #glCreateRenderbuffer()}, or zero to break the existing binding
of a renderbuffer object to target.</p>
<p>{@link #GL_INVALID_ENUM} is generated if target is not {@code GL_RENDERBUFFER}.</p>
<p>{@link #GL_INVALID_OPERATION} is generated if renderbuffer is not zero or the name of a renderbuffer
previously returned from a call to {@link #glCreateRenderbuffer()}.</p>
@param target Specifies the renderbuffer target of the binding operation. target must be {@code
GL_RENDERBUFFER}.
@param renderBuffer Specifies the name of the renderbuffer object to bind. | [
"<p",
">",
"{",
"@code",
"glBindRenderbuffer",
"}",
"binds",
"the",
"renderbuffer",
"object",
"with",
"name",
"renderbuffer",
"to",
"the",
"renderbuffer",
"target",
"specified",
"by",
"target",
".",
"target",
"must",
"be",
"{",
"@code",
"GL_RENDERBUFFER",
"}",
".",
"{",
"@code",
"renderbuffer",
"}",
"is",
"the",
"name",
"of",
"a",
"renderbuffer",
"object",
"previously",
"returned",
"from",
"a",
"call",
"to",
"{",
"@link",
"#glCreateRenderbuffer",
"()",
"}",
"or",
"zero",
"to",
"break",
"the",
"existing",
"binding",
"of",
"a",
"renderbuffer",
"object",
"to",
"target",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/sriharshachilakapati/WebGL4J/blob/7daa425300b08b338b50cef2935289849c92d415/webgl4j/src/main/java/com/shc/webgl4j/client/WebGL10.java#L618-L622 |
apache/flink | flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/HadoopInputs.java | HadoopInputs.readSequenceFile | public static <K, V> HadoopInputFormat<K, V> readSequenceFile(Class<K> key, Class<V> value, String inputPath) throws IOException {
"""
Creates a Flink {@link InputFormat} to read a Hadoop sequence file for the given key and value classes.
@return A Flink InputFormat that wraps a Hadoop SequenceFileInputFormat.
"""
return readHadoopFile(new org.apache.hadoop.mapred.SequenceFileInputFormat<K, V>(), key, value, inputPath);
} | java | public static <K, V> HadoopInputFormat<K, V> readSequenceFile(Class<K> key, Class<V> value, String inputPath) throws IOException {
return readHadoopFile(new org.apache.hadoop.mapred.SequenceFileInputFormat<K, V>(), key, value, inputPath);
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"HadoopInputFormat",
"<",
"K",
",",
"V",
">",
"readSequenceFile",
"(",
"Class",
"<",
"K",
">",
"key",
",",
"Class",
"<",
"V",
">",
"value",
",",
"String",
"inputPath",
")",
"throws",
"IOException",
"{",
"return",
"readHadoopFile",
"(",
"new",
"org",
".",
"apache",
".",
"hadoop",
".",
"mapred",
".",
"SequenceFileInputFormat",
"<",
"K",
",",
"V",
">",
"(",
")",
",",
"key",
",",
"value",
",",
"inputPath",
")",
";",
"}"
] | Creates a Flink {@link InputFormat} to read a Hadoop sequence file for the given key and value classes.
@return A Flink InputFormat that wraps a Hadoop SequenceFileInputFormat. | [
"Creates",
"a",
"Flink",
"{",
"@link",
"InputFormat",
"}",
"to",
"read",
"a",
"Hadoop",
"sequence",
"file",
"for",
"the",
"given",
"key",
"and",
"value",
"classes",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/HadoopInputs.java#L71-L73 |
jeremylong/DependencyCheck | core/src/main/java/org/owasp/dependencycheck/data/artifactory/ArtifactorySearch.java | ArtifactorySearch.processResponse | protected List<MavenArtifact> processResponse(Dependency dependency, HttpURLConnection conn) throws IOException {
"""
Process the Artifactory response.
@param dependency the dependency
@param conn the HTTP URL Connection
@return a list of the Maven Artifact information
@throws IOException thrown if there is an I/O error
"""
final JsonObject asJsonObject;
try (final InputStreamReader streamReader = new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)) {
asJsonObject = new JsonParser().parse(streamReader).getAsJsonObject();
}
final JsonArray results = asJsonObject.getAsJsonArray("results");
final int numFound = results.size();
if (numFound == 0) {
throw new FileNotFoundException("Artifact " + dependency + " not found in Artifactory");
}
final List<MavenArtifact> result = new ArrayList<>(numFound);
for (JsonElement jsonElement : results) {
final JsonObject checksumList = jsonElement.getAsJsonObject().getAsJsonObject("checksums");
final JsonPrimitive sha256Primitive = checksumList.getAsJsonPrimitive("sha256");
final String sha1 = checksumList.getAsJsonPrimitive("sha1").getAsString();
final String sha256 = sha256Primitive == null ? null : sha256Primitive.getAsString();
final String md5 = checksumList.getAsJsonPrimitive("md5").getAsString();
checkHashes(dependency, sha1, sha256, md5);
final String downloadUri = jsonElement.getAsJsonObject().getAsJsonPrimitive("downloadUri").getAsString();
final String path = jsonElement.getAsJsonObject().getAsJsonPrimitive("path").getAsString();
final Matcher pathMatcher = PATH_PATTERN.matcher(path);
if (!pathMatcher.matches()) {
throw new IllegalStateException("Cannot extract the Maven information from the apth retrieved in Artifactory " + path);
}
final String groupId = pathMatcher.group("groupId").replace('/', '.');
final String artifactId = pathMatcher.group("artifactId");
final String version = pathMatcher.group("version");
result.add(new MavenArtifact(groupId, artifactId, version, downloadUri, MavenArtifact.derivePomUrl(artifactId, version, downloadUri)));
}
return result;
} | java | protected List<MavenArtifact> processResponse(Dependency dependency, HttpURLConnection conn) throws IOException {
final JsonObject asJsonObject;
try (final InputStreamReader streamReader = new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)) {
asJsonObject = new JsonParser().parse(streamReader).getAsJsonObject();
}
final JsonArray results = asJsonObject.getAsJsonArray("results");
final int numFound = results.size();
if (numFound == 0) {
throw new FileNotFoundException("Artifact " + dependency + " not found in Artifactory");
}
final List<MavenArtifact> result = new ArrayList<>(numFound);
for (JsonElement jsonElement : results) {
final JsonObject checksumList = jsonElement.getAsJsonObject().getAsJsonObject("checksums");
final JsonPrimitive sha256Primitive = checksumList.getAsJsonPrimitive("sha256");
final String sha1 = checksumList.getAsJsonPrimitive("sha1").getAsString();
final String sha256 = sha256Primitive == null ? null : sha256Primitive.getAsString();
final String md5 = checksumList.getAsJsonPrimitive("md5").getAsString();
checkHashes(dependency, sha1, sha256, md5);
final String downloadUri = jsonElement.getAsJsonObject().getAsJsonPrimitive("downloadUri").getAsString();
final String path = jsonElement.getAsJsonObject().getAsJsonPrimitive("path").getAsString();
final Matcher pathMatcher = PATH_PATTERN.matcher(path);
if (!pathMatcher.matches()) {
throw new IllegalStateException("Cannot extract the Maven information from the apth retrieved in Artifactory " + path);
}
final String groupId = pathMatcher.group("groupId").replace('/', '.');
final String artifactId = pathMatcher.group("artifactId");
final String version = pathMatcher.group("version");
result.add(new MavenArtifact(groupId, artifactId, version, downloadUri, MavenArtifact.derivePomUrl(artifactId, version, downloadUri)));
}
return result;
} | [
"protected",
"List",
"<",
"MavenArtifact",
">",
"processResponse",
"(",
"Dependency",
"dependency",
",",
"HttpURLConnection",
"conn",
")",
"throws",
"IOException",
"{",
"final",
"JsonObject",
"asJsonObject",
";",
"try",
"(",
"final",
"InputStreamReader",
"streamReader",
"=",
"new",
"InputStreamReader",
"(",
"conn",
".",
"getInputStream",
"(",
")",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
"{",
"asJsonObject",
"=",
"new",
"JsonParser",
"(",
")",
".",
"parse",
"(",
"streamReader",
")",
".",
"getAsJsonObject",
"(",
")",
";",
"}",
"final",
"JsonArray",
"results",
"=",
"asJsonObject",
".",
"getAsJsonArray",
"(",
"\"results\"",
")",
";",
"final",
"int",
"numFound",
"=",
"results",
".",
"size",
"(",
")",
";",
"if",
"(",
"numFound",
"==",
"0",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"\"Artifact \"",
"+",
"dependency",
"+",
"\" not found in Artifactory\"",
")",
";",
"}",
"final",
"List",
"<",
"MavenArtifact",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
"numFound",
")",
";",
"for",
"(",
"JsonElement",
"jsonElement",
":",
"results",
")",
"{",
"final",
"JsonObject",
"checksumList",
"=",
"jsonElement",
".",
"getAsJsonObject",
"(",
")",
".",
"getAsJsonObject",
"(",
"\"checksums\"",
")",
";",
"final",
"JsonPrimitive",
"sha256Primitive",
"=",
"checksumList",
".",
"getAsJsonPrimitive",
"(",
"\"sha256\"",
")",
";",
"final",
"String",
"sha1",
"=",
"checksumList",
".",
"getAsJsonPrimitive",
"(",
"\"sha1\"",
")",
".",
"getAsString",
"(",
")",
";",
"final",
"String",
"sha256",
"=",
"sha256Primitive",
"==",
"null",
"?",
"null",
":",
"sha256Primitive",
".",
"getAsString",
"(",
")",
";",
"final",
"String",
"md5",
"=",
"checksumList",
".",
"getAsJsonPrimitive",
"(",
"\"md5\"",
")",
".",
"getAsString",
"(",
")",
";",
"checkHashes",
"(",
"dependency",
",",
"sha1",
",",
"sha256",
",",
"md5",
")",
";",
"final",
"String",
"downloadUri",
"=",
"jsonElement",
".",
"getAsJsonObject",
"(",
")",
".",
"getAsJsonPrimitive",
"(",
"\"downloadUri\"",
")",
".",
"getAsString",
"(",
")",
";",
"final",
"String",
"path",
"=",
"jsonElement",
".",
"getAsJsonObject",
"(",
")",
".",
"getAsJsonPrimitive",
"(",
"\"path\"",
")",
".",
"getAsString",
"(",
")",
";",
"final",
"Matcher",
"pathMatcher",
"=",
"PATH_PATTERN",
".",
"matcher",
"(",
"path",
")",
";",
"if",
"(",
"!",
"pathMatcher",
".",
"matches",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot extract the Maven information from the apth retrieved in Artifactory \"",
"+",
"path",
")",
";",
"}",
"final",
"String",
"groupId",
"=",
"pathMatcher",
".",
"group",
"(",
"\"groupId\"",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"final",
"String",
"artifactId",
"=",
"pathMatcher",
".",
"group",
"(",
"\"artifactId\"",
")",
";",
"final",
"String",
"version",
"=",
"pathMatcher",
".",
"group",
"(",
"\"version\"",
")",
";",
"result",
".",
"add",
"(",
"new",
"MavenArtifact",
"(",
"groupId",
",",
"artifactId",
",",
"version",
",",
"downloadUri",
",",
"MavenArtifact",
".",
"derivePomUrl",
"(",
"artifactId",
",",
"version",
",",
"downloadUri",
")",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Process the Artifactory response.
@param dependency the dependency
@param conn the HTTP URL Connection
@return a list of the Maven Artifact information
@throws IOException thrown if there is an I/O error | [
"Process",
"the",
"Artifactory",
"response",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/data/artifactory/ArtifactorySearch.java#L196-L234 |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/BasePrepareStatement.java | BasePrepareStatement.setTimestamp | public void setTimestamp(final int parameterIndex, final Timestamp timestamp)
throws SQLException {
"""
Sets the designated parameter to the given <code>java.sql.Timestamp</code> value. The driver
converts this to an SQL <code>TIMESTAMP</code> value when it sends it to the database.
@param parameterIndex the first parameter is 1, the second is 2, ...
@param timestamp the parameter value
@throws SQLException if parameterIndex does not correspond to a parameter marker in the SQL
statement; if a database access error occurs or this method is called on a
closed
<code>PreparedStatement</code>
"""
if (timestamp == null) {
setNull(parameterIndex, ColumnType.DATETIME);
return;
}
setParameter(parameterIndex,
new TimestampParameter(timestamp, protocol.getTimeZone(), useFractionalSeconds));
} | java | public void setTimestamp(final int parameterIndex, final Timestamp timestamp)
throws SQLException {
if (timestamp == null) {
setNull(parameterIndex, ColumnType.DATETIME);
return;
}
setParameter(parameterIndex,
new TimestampParameter(timestamp, protocol.getTimeZone(), useFractionalSeconds));
} | [
"public",
"void",
"setTimestamp",
"(",
"final",
"int",
"parameterIndex",
",",
"final",
"Timestamp",
"timestamp",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"timestamp",
"==",
"null",
")",
"{",
"setNull",
"(",
"parameterIndex",
",",
"ColumnType",
".",
"DATETIME",
")",
";",
"return",
";",
"}",
"setParameter",
"(",
"parameterIndex",
",",
"new",
"TimestampParameter",
"(",
"timestamp",
",",
"protocol",
".",
"getTimeZone",
"(",
")",
",",
"useFractionalSeconds",
")",
")",
";",
"}"
] | Sets the designated parameter to the given <code>java.sql.Timestamp</code> value. The driver
converts this to an SQL <code>TIMESTAMP</code> value when it sends it to the database.
@param parameterIndex the first parameter is 1, the second is 2, ...
@param timestamp the parameter value
@throws SQLException if parameterIndex does not correspond to a parameter marker in the SQL
statement; if a database access error occurs or this method is called on a
closed
<code>PreparedStatement</code> | [
"Sets",
"the",
"designated",
"parameter",
"to",
"the",
"given",
"<code",
">",
"java",
".",
"sql",
".",
"Timestamp<",
"/",
"code",
">",
"value",
".",
"The",
"driver",
"converts",
"this",
"to",
"an",
"SQL",
"<code",
">",
"TIMESTAMP<",
"/",
"code",
">",
"value",
"when",
"it",
"sends",
"it",
"to",
"the",
"database",
"."
] | train | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/BasePrepareStatement.java#L615-L624 |
UrielCh/ovh-java-sdk | ovh-java-sdk-price/src/main/java/net/minidev/ovh/api/ApiOvhPrice.java | ApiOvhPrice.domain_zone_option_optionName_GET | public OvhPrice domain_zone_option_optionName_GET(net.minidev.ovh.api.price.domain.zone.OvhOptionEnum optionName) throws IOException {
"""
Get price of zone options
REST: GET /price/domain/zone/option/{optionName}
@param optionName [required] Option
"""
String qPath = "/price/domain/zone/option/{optionName}";
StringBuilder sb = path(qPath, optionName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrice.class);
} | java | public OvhPrice domain_zone_option_optionName_GET(net.minidev.ovh.api.price.domain.zone.OvhOptionEnum optionName) throws IOException {
String qPath = "/price/domain/zone/option/{optionName}";
StringBuilder sb = path(qPath, optionName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrice.class);
} | [
"public",
"OvhPrice",
"domain_zone_option_optionName_GET",
"(",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"price",
".",
"domain",
".",
"zone",
".",
"OvhOptionEnum",
"optionName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/price/domain/zone/option/{optionName}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"optionName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhPrice",
".",
"class",
")",
";",
"}"
] | Get price of zone options
REST: GET /price/domain/zone/option/{optionName}
@param optionName [required] Option | [
"Get",
"price",
"of",
"zone",
"options"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-price/src/main/java/net/minidev/ovh/api/ApiOvhPrice.java#L284-L289 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLDataIntersectionOfImpl_CustomFieldSerializer.java | OWLDataIntersectionOfImpl_CustomFieldSerializer.deserializeInstance | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLDataIntersectionOfImpl instance) throws SerializationException {
"""
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
"""
deserialize(streamReader, instance);
} | java | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLDataIntersectionOfImpl instance) throws SerializationException {
deserialize(streamReader, instance);
} | [
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLDataIntersectionOfImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
] | Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful | [
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLDataIntersectionOfImpl_CustomFieldSerializer.java#L89-L92 |
datacleaner/DataCleaner | engine/core/src/main/java/org/datacleaner/output/csv/CsvOutputWriterFactory.java | CsvOutputWriterFactory.getWriter | public static OutputWriter getWriter(final String filename, final List<InputColumn<?>> columns) {
"""
Creates a CSV output writer with default configuration
@param filename
@param columns
@return
"""
final InputColumn<?>[] columnArray = columns.toArray(new InputColumn<?>[columns.size()]);
final String[] headers = new String[columnArray.length];
for (int i = 0; i < headers.length; i++) {
headers[i] = columnArray[i].getName();
}
return getWriter(filename, headers, ',', '"', '\\', true, columnArray);
} | java | public static OutputWriter getWriter(final String filename, final List<InputColumn<?>> columns) {
final InputColumn<?>[] columnArray = columns.toArray(new InputColumn<?>[columns.size()]);
final String[] headers = new String[columnArray.length];
for (int i = 0; i < headers.length; i++) {
headers[i] = columnArray[i].getName();
}
return getWriter(filename, headers, ',', '"', '\\', true, columnArray);
} | [
"public",
"static",
"OutputWriter",
"getWriter",
"(",
"final",
"String",
"filename",
",",
"final",
"List",
"<",
"InputColumn",
"<",
"?",
">",
">",
"columns",
")",
"{",
"final",
"InputColumn",
"<",
"?",
">",
"[",
"]",
"columnArray",
"=",
"columns",
".",
"toArray",
"(",
"new",
"InputColumn",
"<",
"?",
">",
"[",
"columns",
".",
"size",
"(",
")",
"]",
")",
";",
"final",
"String",
"[",
"]",
"headers",
"=",
"new",
"String",
"[",
"columnArray",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"headers",
".",
"length",
";",
"i",
"++",
")",
"{",
"headers",
"[",
"i",
"]",
"=",
"columnArray",
"[",
"i",
"]",
".",
"getName",
"(",
")",
";",
"}",
"return",
"getWriter",
"(",
"filename",
",",
"headers",
",",
"'",
"'",
",",
"'",
"'",
",",
"'",
"'",
",",
"true",
",",
"columnArray",
")",
";",
"}"
] | Creates a CSV output writer with default configuration
@param filename
@param columns
@return | [
"Creates",
"a",
"CSV",
"output",
"writer",
"with",
"default",
"configuration"
] | train | https://github.com/datacleaner/DataCleaner/blob/9aa01fdac3560cef51c55df3cb2ac5c690b57639/engine/core/src/main/java/org/datacleaner/output/csv/CsvOutputWriterFactory.java#L47-L54 |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/Resources.java | Resources.getResourceAsStream | @Pure
public static InputStream getResourceAsStream(ClassLoader classLoader, Package packagename, String path) {
"""
Replies the input stream of a resource.
<p>You may use Unix-like syntax to write the resource path, ie.
you may use slashes to separate filenames.
<p>The name of {@code packagename} is translated into a resource
path (by replacing the dots by slashes) and the given path
is append to. For example, the two following codes are equivalent:<pre><code>
Resources.getResources(Package.getPackage("org.arakhne.afc"), "/a/b/c/d.png");
Resources.getResources("org/arakhne/afc/a/b/c/d.png");
</code></pre>
<p>If the {@code classLoader} parameter is <code>null</code>,
the class loader replied by {@link ClassLoaderFinder} is used.
If this last is <code>null</code>, the class loader of
the Resources class is used.
@param classLoader is the research scope. If <code>null</code>,
the class loader replied by {@link ClassLoaderFinder} is used.
@param packagename is the package in which the resource should be located.
@param path is the relative path of the resource in the package.
@return the url of the resource or <code>null</code> if the resource was
not found in class paths.
@since 6.2
"""
if (packagename == null || path == null) {
return null;
}
final StringBuilder b = new StringBuilder();
b.append(packagename.getName().replaceAll(
Pattern.quote("."), //$NON-NLS-1$
Matcher.quoteReplacement(NAME_SEPARATOR)));
if (!path.startsWith(NAME_SEPARATOR)) {
b.append(NAME_SEPARATOR);
}
b.append(path);
ClassLoader cl = classLoader;
if (cl == null) {
cl = packagename.getClass().getClassLoader();
}
return getResourceAsStream(cl, b.toString());
} | java | @Pure
public static InputStream getResourceAsStream(ClassLoader classLoader, Package packagename, String path) {
if (packagename == null || path == null) {
return null;
}
final StringBuilder b = new StringBuilder();
b.append(packagename.getName().replaceAll(
Pattern.quote("."), //$NON-NLS-1$
Matcher.quoteReplacement(NAME_SEPARATOR)));
if (!path.startsWith(NAME_SEPARATOR)) {
b.append(NAME_SEPARATOR);
}
b.append(path);
ClassLoader cl = classLoader;
if (cl == null) {
cl = packagename.getClass().getClassLoader();
}
return getResourceAsStream(cl, b.toString());
} | [
"@",
"Pure",
"public",
"static",
"InputStream",
"getResourceAsStream",
"(",
"ClassLoader",
"classLoader",
",",
"Package",
"packagename",
",",
"String",
"path",
")",
"{",
"if",
"(",
"packagename",
"==",
"null",
"||",
"path",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"StringBuilder",
"b",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"b",
".",
"append",
"(",
"packagename",
".",
"getName",
"(",
")",
".",
"replaceAll",
"(",
"Pattern",
".",
"quote",
"(",
"\".\"",
")",
",",
"//$NON-NLS-1$",
"Matcher",
".",
"quoteReplacement",
"(",
"NAME_SEPARATOR",
")",
")",
")",
";",
"if",
"(",
"!",
"path",
".",
"startsWith",
"(",
"NAME_SEPARATOR",
")",
")",
"{",
"b",
".",
"append",
"(",
"NAME_SEPARATOR",
")",
";",
"}",
"b",
".",
"append",
"(",
"path",
")",
";",
"ClassLoader",
"cl",
"=",
"classLoader",
";",
"if",
"(",
"cl",
"==",
"null",
")",
"{",
"cl",
"=",
"packagename",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
";",
"}",
"return",
"getResourceAsStream",
"(",
"cl",
",",
"b",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Replies the input stream of a resource.
<p>You may use Unix-like syntax to write the resource path, ie.
you may use slashes to separate filenames.
<p>The name of {@code packagename} is translated into a resource
path (by replacing the dots by slashes) and the given path
is append to. For example, the two following codes are equivalent:<pre><code>
Resources.getResources(Package.getPackage("org.arakhne.afc"), "/a/b/c/d.png");
Resources.getResources("org/arakhne/afc/a/b/c/d.png");
</code></pre>
<p>If the {@code classLoader} parameter is <code>null</code>,
the class loader replied by {@link ClassLoaderFinder} is used.
If this last is <code>null</code>, the class loader of
the Resources class is used.
@param classLoader is the research scope. If <code>null</code>,
the class loader replied by {@link ClassLoaderFinder} is used.
@param packagename is the package in which the resource should be located.
@param path is the relative path of the resource in the package.
@return the url of the resource or <code>null</code> if the resource was
not found in class paths.
@since 6.2 | [
"Replies",
"the",
"input",
"stream",
"of",
"a",
"resource",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/Resources.java#L244-L262 |
zeroturnaround/maven-jrebel-plugin | src/main/java/org/zeroturnaround/javarebel/maven/GenerateRebelMojo.java | GenerateRebelMojo.getPluginSetting | private String getPluginSetting(MavenProject project, String pluginId, String optionName, String defaultValue) {
"""
Search for a configuration setting of an other plugin.
@param project the current maven project to get the configuration from.
@param pluginId the group id and artifact id of the plugin to search for
@param optionName the option to get from the configuration
@param defaultValue the default value if the configuration was not found
@return the value of the option configured in the plugin configuration
"""
Xpp3Dom dom = getPluginConfigurationDom(project, pluginId);
if (dom != null && dom.getChild(optionName) != null) {
return getValue(project, dom.getChild(optionName));
}
return defaultValue;
} | java | private String getPluginSetting(MavenProject project, String pluginId, String optionName, String defaultValue) {
Xpp3Dom dom = getPluginConfigurationDom(project, pluginId);
if (dom != null && dom.getChild(optionName) != null) {
return getValue(project, dom.getChild(optionName));
}
return defaultValue;
} | [
"private",
"String",
"getPluginSetting",
"(",
"MavenProject",
"project",
",",
"String",
"pluginId",
",",
"String",
"optionName",
",",
"String",
"defaultValue",
")",
"{",
"Xpp3Dom",
"dom",
"=",
"getPluginConfigurationDom",
"(",
"project",
",",
"pluginId",
")",
";",
"if",
"(",
"dom",
"!=",
"null",
"&&",
"dom",
".",
"getChild",
"(",
"optionName",
")",
"!=",
"null",
")",
"{",
"return",
"getValue",
"(",
"project",
",",
"dom",
".",
"getChild",
"(",
"optionName",
")",
")",
";",
"}",
"return",
"defaultValue",
";",
"}"
] | Search for a configuration setting of an other plugin.
@param project the current maven project to get the configuration from.
@param pluginId the group id and artifact id of the plugin to search for
@param optionName the option to get from the configuration
@param defaultValue the default value if the configuration was not found
@return the value of the option configured in the plugin configuration | [
"Search",
"for",
"a",
"configuration",
"setting",
"of",
"an",
"other",
"plugin",
"."
] | train | https://github.com/zeroturnaround/maven-jrebel-plugin/blob/6a0d12529a13ae6b2b772658a714398147c091ca/src/main/java/org/zeroturnaround/javarebel/maven/GenerateRebelMojo.java#L760-L766 |
motown-io/motown | domain/core-api/src/main/java/io/motown/domain/api/chargingstation/TransactionIdFactory.java | TransactionIdFactory.createTransactionId | public static TransactionId createTransactionId(String transactionNumber, ChargingStationId chargingStationId, String protocol) {
"""
Creates {@code NumberedTransactionId} or {@code UUIDTransactionId} by inspecting the provided transactionId String.
@param transactionNumber the String to create into a TransactionId
@param chargingStationId the chargingstation id
@param protocol the protocol identifier
@return a {@code TransactionId}
@throws NullPointerException in case transactionNumber is null.
@throws IllegalArgumentException in case no {@code TransactionId} could be created.
"""
return Ints.tryParse(checkNotNull(transactionNumber)) != null
? new NumberedTransactionId(chargingStationId, protocol, Ints.tryParse(transactionNumber))
: new UuidTransactionId(UUID.fromString(transactionNumber));
} | java | public static TransactionId createTransactionId(String transactionNumber, ChargingStationId chargingStationId, String protocol) {
return Ints.tryParse(checkNotNull(transactionNumber)) != null
? new NumberedTransactionId(chargingStationId, protocol, Ints.tryParse(transactionNumber))
: new UuidTransactionId(UUID.fromString(transactionNumber));
} | [
"public",
"static",
"TransactionId",
"createTransactionId",
"(",
"String",
"transactionNumber",
",",
"ChargingStationId",
"chargingStationId",
",",
"String",
"protocol",
")",
"{",
"return",
"Ints",
".",
"tryParse",
"(",
"checkNotNull",
"(",
"transactionNumber",
")",
")",
"!=",
"null",
"?",
"new",
"NumberedTransactionId",
"(",
"chargingStationId",
",",
"protocol",
",",
"Ints",
".",
"tryParse",
"(",
"transactionNumber",
")",
")",
":",
"new",
"UuidTransactionId",
"(",
"UUID",
".",
"fromString",
"(",
"transactionNumber",
")",
")",
";",
"}"
] | Creates {@code NumberedTransactionId} or {@code UUIDTransactionId} by inspecting the provided transactionId String.
@param transactionNumber the String to create into a TransactionId
@param chargingStationId the chargingstation id
@param protocol the protocol identifier
@return a {@code TransactionId}
@throws NullPointerException in case transactionNumber is null.
@throws IllegalArgumentException in case no {@code TransactionId} could be created. | [
"Creates",
"{"
] | train | https://github.com/motown-io/motown/blob/783ccda7c28b273a529ddd47defe8673b1ea365b/domain/core-api/src/main/java/io/motown/domain/api/chargingstation/TransactionIdFactory.java#L41-L45 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/webapp/WebGroup.java | WebGroup.addWebApplication | @SuppressWarnings("unchecked")
public void addWebApplication(DeployedModule deployedModule, List extensionFactories)
throws Throwable {
"""
BEGIN: NEVER INVOKED BY WEBSPHERE APPLICATION SERVER (Common Component Specific)
"""
WebAppConfiguration wConfig = deployedModule.getWebAppConfig();
String displayName = wConfig.getDisplayName();
logger.logp(Level.INFO, CLASS_NAME,"addWebApplication", "loading.web.module", displayName);
WebApp webApp = deployedModule.getWebApp();
try
{
this.webApp = webApp; // PK40127
webApp.initialize(wConfig, deployedModule, extensionFactories);
}
catch (Throwable th)
{
webApp.failed();
webApp.destroy();
this.webApp = null; // PK40127
com.ibm.ws.ffdc.FFDCFilter.processException(th, "com.ibm.ws.webcontainer.webapp.WebGroup", "131", this);
Object[] arg = {displayName};
logger.logp(Level.SEVERE, CLASS_NAME,"addWebApplication", "Failed.to.initialize.webapp.{0}", arg);
throw th;
}
//this.webApp = webApp; // PK25527
} | java | @SuppressWarnings("unchecked")
public void addWebApplication(DeployedModule deployedModule, List extensionFactories)
throws Throwable
{
WebAppConfiguration wConfig = deployedModule.getWebAppConfig();
String displayName = wConfig.getDisplayName();
logger.logp(Level.INFO, CLASS_NAME,"addWebApplication", "loading.web.module", displayName);
WebApp webApp = deployedModule.getWebApp();
try
{
this.webApp = webApp; // PK40127
webApp.initialize(wConfig, deployedModule, extensionFactories);
}
catch (Throwable th)
{
webApp.failed();
webApp.destroy();
this.webApp = null; // PK40127
com.ibm.ws.ffdc.FFDCFilter.processException(th, "com.ibm.ws.webcontainer.webapp.WebGroup", "131", this);
Object[] arg = {displayName};
logger.logp(Level.SEVERE, CLASS_NAME,"addWebApplication", "Failed.to.initialize.webapp.{0}", arg);
throw th;
}
//this.webApp = webApp; // PK25527
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"void",
"addWebApplication",
"(",
"DeployedModule",
"deployedModule",
",",
"List",
"extensionFactories",
")",
"throws",
"Throwable",
"{",
"WebAppConfiguration",
"wConfig",
"=",
"deployedModule",
".",
"getWebAppConfig",
"(",
")",
";",
"String",
"displayName",
"=",
"wConfig",
".",
"getDisplayName",
"(",
")",
";",
"logger",
".",
"logp",
"(",
"Level",
".",
"INFO",
",",
"CLASS_NAME",
",",
"\"addWebApplication\"",
",",
"\"loading.web.module\"",
",",
"displayName",
")",
";",
"WebApp",
"webApp",
"=",
"deployedModule",
".",
"getWebApp",
"(",
")",
";",
"try",
"{",
"this",
".",
"webApp",
"=",
"webApp",
";",
"// PK40127",
"webApp",
".",
"initialize",
"(",
"wConfig",
",",
"deployedModule",
",",
"extensionFactories",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"webApp",
".",
"failed",
"(",
")",
";",
"webApp",
".",
"destroy",
"(",
")",
";",
"this",
".",
"webApp",
"=",
"null",
";",
"// PK40127",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"th",
",",
"\"com.ibm.ws.webcontainer.webapp.WebGroup\"",
",",
"\"131\"",
",",
"this",
")",
";",
"Object",
"[",
"]",
"arg",
"=",
"{",
"displayName",
"}",
";",
"logger",
".",
"logp",
"(",
"Level",
".",
"SEVERE",
",",
"CLASS_NAME",
",",
"\"addWebApplication\"",
",",
"\"Failed.to.initialize.webapp.{0}\"",
",",
"arg",
")",
";",
"throw",
"th",
";",
"}",
"//this.webApp = webApp; // PK25527\t\t",
"}"
] | BEGIN: NEVER INVOKED BY WEBSPHERE APPLICATION SERVER (Common Component Specific) | [
"BEGIN",
":",
"NEVER",
"INVOKED",
"BY",
"WEBSPHERE",
"APPLICATION",
"SERVER",
"(",
"Common",
"Component",
"Specific",
")"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/webapp/WebGroup.java#L108-L133 |
aalmiray/Json-lib | src/main/java/net/sf/json/JsonConfig.java | JsonConfig.findJsonValueProcessor | public JsonValueProcessor findJsonValueProcessor( Class propertyType, String key ) {
"""
Finds a JsonValueProcessor.<br>
It will search the registered JsonValueProcessors in the following order:
<ol>
<li>key</li>
<li>type</li>
</ol>
Returns null if none is registered.<br>
[Java -> JSON]
@param propertyType the type of the property
@param key the name of the property which may belong to the target class
"""
JsonValueProcessor jsonValueProcessor = null;
jsonValueProcessor = (JsonValueProcessor) keyMap.get( key );
if( jsonValueProcessor != null ) {
return jsonValueProcessor;
}
Object tkey = jsonValueProcessorMatcher.getMatch( propertyType, typeMap.keySet() );
jsonValueProcessor = (JsonValueProcessor) typeMap.get( tkey );
if( jsonValueProcessor != null ) {
return jsonValueProcessor;
}
return null;
} | java | public JsonValueProcessor findJsonValueProcessor( Class propertyType, String key ) {
JsonValueProcessor jsonValueProcessor = null;
jsonValueProcessor = (JsonValueProcessor) keyMap.get( key );
if( jsonValueProcessor != null ) {
return jsonValueProcessor;
}
Object tkey = jsonValueProcessorMatcher.getMatch( propertyType, typeMap.keySet() );
jsonValueProcessor = (JsonValueProcessor) typeMap.get( tkey );
if( jsonValueProcessor != null ) {
return jsonValueProcessor;
}
return null;
} | [
"public",
"JsonValueProcessor",
"findJsonValueProcessor",
"(",
"Class",
"propertyType",
",",
"String",
"key",
")",
"{",
"JsonValueProcessor",
"jsonValueProcessor",
"=",
"null",
";",
"jsonValueProcessor",
"=",
"(",
"JsonValueProcessor",
")",
"keyMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"jsonValueProcessor",
"!=",
"null",
")",
"{",
"return",
"jsonValueProcessor",
";",
"}",
"Object",
"tkey",
"=",
"jsonValueProcessorMatcher",
".",
"getMatch",
"(",
"propertyType",
",",
"typeMap",
".",
"keySet",
"(",
")",
")",
";",
"jsonValueProcessor",
"=",
"(",
"JsonValueProcessor",
")",
"typeMap",
".",
"get",
"(",
"tkey",
")",
";",
"if",
"(",
"jsonValueProcessor",
"!=",
"null",
")",
"{",
"return",
"jsonValueProcessor",
";",
"}",
"return",
"null",
";",
"}"
] | Finds a JsonValueProcessor.<br>
It will search the registered JsonValueProcessors in the following order:
<ol>
<li>key</li>
<li>type</li>
</ol>
Returns null if none is registered.<br>
[Java -> JSON]
@param propertyType the type of the property
@param key the name of the property which may belong to the target class | [
"Finds",
"a",
"JsonValueProcessor",
".",
"<br",
">",
"It",
"will",
"search",
"the",
"registered",
"JsonValueProcessors",
"in",
"the",
"following",
"order",
":",
"<ol",
">",
"<li",
">",
"key<",
"/",
"li",
">",
"<li",
">",
"type<",
"/",
"li",
">",
"<",
"/",
"ol",
">",
"Returns",
"null",
"if",
"none",
"is",
"registered",
".",
"<br",
">",
"[",
"Java",
"-",
">",
";",
"JSON",
"]"
] | train | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JsonConfig.java#L398-L412 |
elki-project/elki | elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VALPNormDistance.java | VALPNormDistance.initializeLookupTable | private void initializeLookupTable(double[][] splitPositions, NumberVector query, double p) {
"""
Initialize the lookup table.
@param splitPositions Split positions
@param query Query vector
@param p p
"""
final int dimensions = splitPositions.length;
final int bordercount = splitPositions[0].length;
lookup = new double[dimensions][bordercount];
for(int d = 0; d < dimensions; d++) {
final double val = query.doubleValue(d);
for(int i = 0; i < bordercount; i++) {
lookup[d][i] = FastMath.pow(splitPositions[d][i] - val, p);
}
}
} | java | private void initializeLookupTable(double[][] splitPositions, NumberVector query, double p) {
final int dimensions = splitPositions.length;
final int bordercount = splitPositions[0].length;
lookup = new double[dimensions][bordercount];
for(int d = 0; d < dimensions; d++) {
final double val = query.doubleValue(d);
for(int i = 0; i < bordercount; i++) {
lookup[d][i] = FastMath.pow(splitPositions[d][i] - val, p);
}
}
} | [
"private",
"void",
"initializeLookupTable",
"(",
"double",
"[",
"]",
"[",
"]",
"splitPositions",
",",
"NumberVector",
"query",
",",
"double",
"p",
")",
"{",
"final",
"int",
"dimensions",
"=",
"splitPositions",
".",
"length",
";",
"final",
"int",
"bordercount",
"=",
"splitPositions",
"[",
"0",
"]",
".",
"length",
";",
"lookup",
"=",
"new",
"double",
"[",
"dimensions",
"]",
"[",
"bordercount",
"]",
";",
"for",
"(",
"int",
"d",
"=",
"0",
";",
"d",
"<",
"dimensions",
";",
"d",
"++",
")",
"{",
"final",
"double",
"val",
"=",
"query",
".",
"doubleValue",
"(",
"d",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"bordercount",
";",
"i",
"++",
")",
"{",
"lookup",
"[",
"d",
"]",
"[",
"i",
"]",
"=",
"FastMath",
".",
"pow",
"(",
"splitPositions",
"[",
"d",
"]",
"[",
"i",
"]",
"-",
"val",
",",
"p",
")",
";",
"}",
"}",
"}"
] | Initialize the lookup table.
@param splitPositions Split positions
@param query Query vector
@param p p | [
"Initialize",
"the",
"lookup",
"table",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VALPNormDistance.java#L157-L167 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionWitness.java | TransactionWitness.redeemP2WPKH | public static TransactionWitness redeemP2WPKH(@Nullable TransactionSignature signature, ECKey pubKey) {
"""
Creates the stack pushes necessary to redeem a P2WPKH output. If given signature is null, an empty push will be
used as a placeholder.
"""
checkArgument(pubKey.isCompressed(), "only compressed keys allowed");
TransactionWitness witness = new TransactionWitness(2);
witness.setPush(0, signature != null ? signature.encodeToBitcoin() : new byte[0]); // signature
witness.setPush(1, pubKey.getPubKey()); // pubkey
return witness;
} | java | public static TransactionWitness redeemP2WPKH(@Nullable TransactionSignature signature, ECKey pubKey) {
checkArgument(pubKey.isCompressed(), "only compressed keys allowed");
TransactionWitness witness = new TransactionWitness(2);
witness.setPush(0, signature != null ? signature.encodeToBitcoin() : new byte[0]); // signature
witness.setPush(1, pubKey.getPubKey()); // pubkey
return witness;
} | [
"public",
"static",
"TransactionWitness",
"redeemP2WPKH",
"(",
"@",
"Nullable",
"TransactionSignature",
"signature",
",",
"ECKey",
"pubKey",
")",
"{",
"checkArgument",
"(",
"pubKey",
".",
"isCompressed",
"(",
")",
",",
"\"only compressed keys allowed\"",
")",
";",
"TransactionWitness",
"witness",
"=",
"new",
"TransactionWitness",
"(",
"2",
")",
";",
"witness",
".",
"setPush",
"(",
"0",
",",
"signature",
"!=",
"null",
"?",
"signature",
".",
"encodeToBitcoin",
"(",
")",
":",
"new",
"byte",
"[",
"0",
"]",
")",
";",
"// signature",
"witness",
".",
"setPush",
"(",
"1",
",",
"pubKey",
".",
"getPubKey",
"(",
")",
")",
";",
"// pubkey",
"return",
"witness",
";",
"}"
] | Creates the stack pushes necessary to redeem a P2WPKH output. If given signature is null, an empty push will be
used as a placeholder. | [
"Creates",
"the",
"stack",
"pushes",
"necessary",
"to",
"redeem",
"a",
"P2WPKH",
"output",
".",
"If",
"given",
"signature",
"is",
"null",
"an",
"empty",
"push",
"will",
"be",
"used",
"as",
"a",
"placeholder",
"."
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionWitness.java#L36-L42 |
alkacon/opencms-core | src/org/opencms/db/CmsSecurityManager.java | CmsSecurityManager.publishProject | public CmsUUID publishProject(CmsObject cms, CmsPublishList publishList, I_CmsReport report) throws CmsException {
"""
Publishes the resources of a specified publish list.<p>
@param cms the current request context
@param publishList a publish list
@param report an instance of <code>{@link I_CmsReport}</code> to print messages
@return the publish history id of the published project
@throws CmsException if something goes wrong
@see #fillPublishList(CmsRequestContext, CmsPublishList)
"""
CmsRequestContext context = cms.getRequestContext();
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
try {
// check if the current user has the required publish permissions
checkPublishPermissions(dbc, publishList);
m_driverManager.publishProject(cms, dbc, publishList, report);
} finally {
dbc.clear();
}
return publishList.getPublishHistoryId();
} | java | public CmsUUID publishProject(CmsObject cms, CmsPublishList publishList, I_CmsReport report) throws CmsException {
CmsRequestContext context = cms.getRequestContext();
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
try {
// check if the current user has the required publish permissions
checkPublishPermissions(dbc, publishList);
m_driverManager.publishProject(cms, dbc, publishList, report);
} finally {
dbc.clear();
}
return publishList.getPublishHistoryId();
} | [
"public",
"CmsUUID",
"publishProject",
"(",
"CmsObject",
"cms",
",",
"CmsPublishList",
"publishList",
",",
"I_CmsReport",
"report",
")",
"throws",
"CmsException",
"{",
"CmsRequestContext",
"context",
"=",
"cms",
".",
"getRequestContext",
"(",
")",
";",
"CmsDbContext",
"dbc",
"=",
"m_dbContextFactory",
".",
"getDbContext",
"(",
"context",
")",
";",
"try",
"{",
"// check if the current user has the required publish permissions",
"checkPublishPermissions",
"(",
"dbc",
",",
"publishList",
")",
";",
"m_driverManager",
".",
"publishProject",
"(",
"cms",
",",
"dbc",
",",
"publishList",
",",
"report",
")",
";",
"}",
"finally",
"{",
"dbc",
".",
"clear",
"(",
")",
";",
"}",
"return",
"publishList",
".",
"getPublishHistoryId",
"(",
")",
";",
"}"
] | Publishes the resources of a specified publish list.<p>
@param cms the current request context
@param publishList a publish list
@param report an instance of <code>{@link I_CmsReport}</code> to print messages
@return the publish history id of the published project
@throws CmsException if something goes wrong
@see #fillPublishList(CmsRequestContext, CmsPublishList) | [
"Publishes",
"the",
"resources",
"of",
"a",
"specified",
"publish",
"list",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsSecurityManager.java#L3854-L3866 |
Red5/red5-server-common | src/main/java/org/red5/server/util/HttpConnectionUtil.java | HttpConnectionUtil.getClient | public static final HttpClient getClient(int timeout) {
"""
Returns a client with all our selected properties / params.
@param timeout
- socket timeout to set
@return client
"""
HttpClientBuilder client = HttpClientBuilder.create();
// set the connection manager
client.setConnectionManager(connectionManager);
// dont retry
client.setRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
// establish a connection within x seconds
RequestConfig config = RequestConfig.custom().setSocketTimeout(timeout).build();
client.setDefaultRequestConfig(config);
// no redirects
client.disableRedirectHandling();
// set custom ua
client.setUserAgent(userAgent);
// set the proxy if the user has one set
if ((System.getProperty("http.proxyHost") != null) && (System.getProperty("http.proxyPort") != null)) {
HttpHost proxy = new HttpHost(System.getProperty("http.proxyHost").toString(), Integer.valueOf(System.getProperty("http.proxyPort")));
client.setProxy(proxy);
}
return client.build();
} | java | public static final HttpClient getClient(int timeout) {
HttpClientBuilder client = HttpClientBuilder.create();
// set the connection manager
client.setConnectionManager(connectionManager);
// dont retry
client.setRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
// establish a connection within x seconds
RequestConfig config = RequestConfig.custom().setSocketTimeout(timeout).build();
client.setDefaultRequestConfig(config);
// no redirects
client.disableRedirectHandling();
// set custom ua
client.setUserAgent(userAgent);
// set the proxy if the user has one set
if ((System.getProperty("http.proxyHost") != null) && (System.getProperty("http.proxyPort") != null)) {
HttpHost proxy = new HttpHost(System.getProperty("http.proxyHost").toString(), Integer.valueOf(System.getProperty("http.proxyPort")));
client.setProxy(proxy);
}
return client.build();
} | [
"public",
"static",
"final",
"HttpClient",
"getClient",
"(",
"int",
"timeout",
")",
"{",
"HttpClientBuilder",
"client",
"=",
"HttpClientBuilder",
".",
"create",
"(",
")",
";",
"// set the connection manager\r",
"client",
".",
"setConnectionManager",
"(",
"connectionManager",
")",
";",
"// dont retry\r",
"client",
".",
"setRetryHandler",
"(",
"new",
"DefaultHttpRequestRetryHandler",
"(",
"0",
",",
"false",
")",
")",
";",
"// establish a connection within x seconds\r",
"RequestConfig",
"config",
"=",
"RequestConfig",
".",
"custom",
"(",
")",
".",
"setSocketTimeout",
"(",
"timeout",
")",
".",
"build",
"(",
")",
";",
"client",
".",
"setDefaultRequestConfig",
"(",
"config",
")",
";",
"// no redirects\r",
"client",
".",
"disableRedirectHandling",
"(",
")",
";",
"// set custom ua\r",
"client",
".",
"setUserAgent",
"(",
"userAgent",
")",
";",
"// set the proxy if the user has one set\r",
"if",
"(",
"(",
"System",
".",
"getProperty",
"(",
"\"http.proxyHost\"",
")",
"!=",
"null",
")",
"&&",
"(",
"System",
".",
"getProperty",
"(",
"\"http.proxyPort\"",
")",
"!=",
"null",
")",
")",
"{",
"HttpHost",
"proxy",
"=",
"new",
"HttpHost",
"(",
"System",
".",
"getProperty",
"(",
"\"http.proxyHost\"",
")",
".",
"toString",
"(",
")",
",",
"Integer",
".",
"valueOf",
"(",
"System",
".",
"getProperty",
"(",
"\"http.proxyPort\"",
")",
")",
")",
";",
"client",
".",
"setProxy",
"(",
"proxy",
")",
";",
"}",
"return",
"client",
".",
"build",
"(",
")",
";",
"}"
] | Returns a client with all our selected properties / params.
@param timeout
- socket timeout to set
@return client | [
"Returns",
"a",
"client",
"with",
"all",
"our",
"selected",
"properties",
"/",
"params",
"."
] | train | https://github.com/Red5/red5-server-common/blob/39ae73710c25bda86d70b13ef37ae707962217b9/src/main/java/org/red5/server/util/HttpConnectionUtil.java#L77-L96 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.mixin | public static void mixin(Class self, List<Class> categoryClasses) {
"""
Extend class globally with category methods.
All methods for given class and all super classes will be added to the class.
@param self any Class
@param categoryClasses a category classes to use
@since 1.6.0
"""
mixin(getMetaClass(self), categoryClasses);
} | java | public static void mixin(Class self, List<Class> categoryClasses) {
mixin(getMetaClass(self), categoryClasses);
} | [
"public",
"static",
"void",
"mixin",
"(",
"Class",
"self",
",",
"List",
"<",
"Class",
">",
"categoryClasses",
")",
"{",
"mixin",
"(",
"getMetaClass",
"(",
"self",
")",
",",
"categoryClasses",
")",
";",
"}"
] | Extend class globally with category methods.
All methods for given class and all super classes will be added to the class.
@param self any Class
@param categoryClasses a category classes to use
@since 1.6.0 | [
"Extend",
"class",
"globally",
"with",
"category",
"methods",
".",
"All",
"methods",
"for",
"given",
"class",
"and",
"all",
"super",
"classes",
"will",
"be",
"added",
"to",
"the",
"class",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L578-L580 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/tai/TAISubjectUtils.java | TAISubjectUtils.createResult | @FFDCIgnore(SettingCustomPropertiesException.class)
public TAIResult createResult(HttpServletResponse res, SocialLoginConfig clientConfig) throws WebTrustAssociationFailedException, SocialLoginException {
"""
Populates a series of custom properties based on the user API response tokens/string and JWT used to instantiate the
object, builds a subject using those custom properties as private credentials, and returns a TAIResult with the produced
username and subject.
"""
Hashtable<String, Object> customProperties = new Hashtable<String, Object>();
try {
customProperties = setAllCustomProperties(clientConfig);
} catch (SettingCustomPropertiesException e) {
// Error occurred populating subject builder properties; any error should have already been logged, so just return the result
return taiWebUtils.sendToErrorPage(res, TAIResult.create(HttpServletResponse.SC_UNAUTHORIZED));
}
Subject subject = buildSubject(clientConfig, customProperties);
return TAIResult.create(HttpServletResponse.SC_OK, username, subject);
} | java | @FFDCIgnore(SettingCustomPropertiesException.class)
public TAIResult createResult(HttpServletResponse res, SocialLoginConfig clientConfig) throws WebTrustAssociationFailedException, SocialLoginException {
Hashtable<String, Object> customProperties = new Hashtable<String, Object>();
try {
customProperties = setAllCustomProperties(clientConfig);
} catch (SettingCustomPropertiesException e) {
// Error occurred populating subject builder properties; any error should have already been logged, so just return the result
return taiWebUtils.sendToErrorPage(res, TAIResult.create(HttpServletResponse.SC_UNAUTHORIZED));
}
Subject subject = buildSubject(clientConfig, customProperties);
return TAIResult.create(HttpServletResponse.SC_OK, username, subject);
} | [
"@",
"FFDCIgnore",
"(",
"SettingCustomPropertiesException",
".",
"class",
")",
"public",
"TAIResult",
"createResult",
"(",
"HttpServletResponse",
"res",
",",
"SocialLoginConfig",
"clientConfig",
")",
"throws",
"WebTrustAssociationFailedException",
",",
"SocialLoginException",
"{",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"customProperties",
"=",
"new",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"try",
"{",
"customProperties",
"=",
"setAllCustomProperties",
"(",
"clientConfig",
")",
";",
"}",
"catch",
"(",
"SettingCustomPropertiesException",
"e",
")",
"{",
"// Error occurred populating subject builder properties; any error should have already been logged, so just return the result",
"return",
"taiWebUtils",
".",
"sendToErrorPage",
"(",
"res",
",",
"TAIResult",
".",
"create",
"(",
"HttpServletResponse",
".",
"SC_UNAUTHORIZED",
")",
")",
";",
"}",
"Subject",
"subject",
"=",
"buildSubject",
"(",
"clientConfig",
",",
"customProperties",
")",
";",
"return",
"TAIResult",
".",
"create",
"(",
"HttpServletResponse",
".",
"SC_OK",
",",
"username",
",",
"subject",
")",
";",
"}"
] | Populates a series of custom properties based on the user API response tokens/string and JWT used to instantiate the
object, builds a subject using those custom properties as private credentials, and returns a TAIResult with the produced
username and subject. | [
"Populates",
"a",
"series",
"of",
"custom",
"properties",
"based",
"on",
"the",
"user",
"API",
"response",
"tokens",
"/",
"string",
"and",
"JWT",
"used",
"to",
"instantiate",
"the",
"object",
"builds",
"a",
"subject",
"using",
"those",
"custom",
"properties",
"as",
"private",
"credentials",
"and",
"returns",
"a",
"TAIResult",
"with",
"the",
"produced",
"username",
"and",
"subject",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/tai/TAISubjectUtils.java#L87-L98 |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/ObjectUtils.java | ObjectUtils.caseInsensitiveValueOf | public static <E extends Enum<?>> E caseInsensitiveValueOf(E[] enumValues, String constant) {
"""
Case insensitive alternative to {@link Enum#valueOf(Class, String)}.
@param <E> the concrete Enum type
@param enumValues the array of all Enum constants in question, usually per
Enum.values()
@param constant the constant to get the enum value of
@throws IllegalArgumentException if the given constant is not found in the given array of enum
values. Use {@link #containsConstant(Enum[], String)} as a
guard to avoid this exception.
"""
for (E candidate : enumValues) {
if (candidate.toString().equalsIgnoreCase(constant)) {
return candidate;
}
}
throw new IllegalArgumentException(String.format("constant [%s] does not exist in enum type %s", constant,
enumValues.getClass().getComponentType().getName()));
} | java | public static <E extends Enum<?>> E caseInsensitiveValueOf(E[] enumValues, String constant) {
for (E candidate : enumValues) {
if (candidate.toString().equalsIgnoreCase(constant)) {
return candidate;
}
}
throw new IllegalArgumentException(String.format("constant [%s] does not exist in enum type %s", constant,
enumValues.getClass().getComponentType().getName()));
} | [
"public",
"static",
"<",
"E",
"extends",
"Enum",
"<",
"?",
">",
">",
"E",
"caseInsensitiveValueOf",
"(",
"E",
"[",
"]",
"enumValues",
",",
"String",
"constant",
")",
"{",
"for",
"(",
"E",
"candidate",
":",
"enumValues",
")",
"{",
"if",
"(",
"candidate",
".",
"toString",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"constant",
")",
")",
"{",
"return",
"candidate",
";",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"constant [%s] does not exist in enum type %s\"",
",",
"constant",
",",
"enumValues",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
";",
"}"
] | Case insensitive alternative to {@link Enum#valueOf(Class, String)}.
@param <E> the concrete Enum type
@param enumValues the array of all Enum constants in question, usually per
Enum.values()
@param constant the constant to get the enum value of
@throws IllegalArgumentException if the given constant is not found in the given array of enum
values. Use {@link #containsConstant(Enum[], String)} as a
guard to avoid this exception. | [
"Case",
"insensitive",
"alternative",
"to",
"{",
"@link",
"Enum#valueOf",
"(",
"Class",
"String",
")",
"}",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ObjectUtils.java#L187-L195 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java | ResourceGroovyMethods.withReader | public static <T> T withReader(File file, @ClosureParams(value = SimpleType.class, options = "java.io.BufferedReader") Closure<T> closure) throws IOException {
"""
Create a new BufferedReader for this file and then
passes it into the closure, ensuring the reader is closed after the
closure returns.
@param file a file object
@param closure a closure
@return the value returned by the closure
@throws IOException if an IOException occurs.
@since 1.5.2
"""
return IOGroovyMethods.withReader(newReader(file), closure);
} | java | public static <T> T withReader(File file, @ClosureParams(value = SimpleType.class, options = "java.io.BufferedReader") Closure<T> closure) throws IOException {
return IOGroovyMethods.withReader(newReader(file), closure);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"withReader",
"(",
"File",
"file",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"SimpleType",
".",
"class",
",",
"options",
"=",
"\"java.io.BufferedReader\"",
")",
"Closure",
"<",
"T",
">",
"closure",
")",
"throws",
"IOException",
"{",
"return",
"IOGroovyMethods",
".",
"withReader",
"(",
"newReader",
"(",
"file",
")",
",",
"closure",
")",
";",
"}"
] | Create a new BufferedReader for this file and then
passes it into the closure, ensuring the reader is closed after the
closure returns.
@param file a file object
@param closure a closure
@return the value returned by the closure
@throws IOException if an IOException occurs.
@since 1.5.2 | [
"Create",
"a",
"new",
"BufferedReader",
"for",
"this",
"file",
"and",
"then",
"passes",
"it",
"into",
"the",
"closure",
"ensuring",
"the",
"reader",
"is",
"closed",
"after",
"the",
"closure",
"returns",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L1772-L1774 |
Azure/azure-sdk-for-java | sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/ManagedBackupShortTermRetentionPoliciesInner.java | ManagedBackupShortTermRetentionPoliciesInner.getAsync | public Observable<ManagedBackupShortTermRetentionPolicyInner> getAsync(String resourceGroupName, String managedInstanceName, String databaseName) {
"""
Gets a managed database's short term retention policy.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param managedInstanceName The name of the managed instance.
@param databaseName The name of the database.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ManagedBackupShortTermRetentionPolicyInner object
"""
return getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName).map(new Func1<ServiceResponse<ManagedBackupShortTermRetentionPolicyInner>, ManagedBackupShortTermRetentionPolicyInner>() {
@Override
public ManagedBackupShortTermRetentionPolicyInner call(ServiceResponse<ManagedBackupShortTermRetentionPolicyInner> response) {
return response.body();
}
});
} | java | public Observable<ManagedBackupShortTermRetentionPolicyInner> getAsync(String resourceGroupName, String managedInstanceName, String databaseName) {
return getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName).map(new Func1<ServiceResponse<ManagedBackupShortTermRetentionPolicyInner>, ManagedBackupShortTermRetentionPolicyInner>() {
@Override
public ManagedBackupShortTermRetentionPolicyInner call(ServiceResponse<ManagedBackupShortTermRetentionPolicyInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ManagedBackupShortTermRetentionPolicyInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"managedInstanceName",
",",
"String",
"databaseName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"managedInstanceName",
",",
"databaseName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ManagedBackupShortTermRetentionPolicyInner",
">",
",",
"ManagedBackupShortTermRetentionPolicyInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ManagedBackupShortTermRetentionPolicyInner",
"call",
"(",
"ServiceResponse",
"<",
"ManagedBackupShortTermRetentionPolicyInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets a managed database's short term retention policy.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param managedInstanceName The name of the managed instance.
@param databaseName The name of the database.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ManagedBackupShortTermRetentionPolicyInner object | [
"Gets",
"a",
"managed",
"database",
"s",
"short",
"term",
"retention",
"policy",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/ManagedBackupShortTermRetentionPoliciesInner.java#L131-L138 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/misc/ImageMiscOps.java | ImageMiscOps.addGaussian | public static void addGaussian(InterleavedS16 input, Random rand , double sigma , int lowerBound , int upperBound ) {
"""
Adds Gaussian/normal i.i.d noise to each pixel in the image. If a value exceeds the specified
it will be set to the closest bound.
@param input Input image. Modified.
@param rand Random number generator.
@param sigma Distributions standard deviation.
@param lowerBound Allowed lower bound
@param upperBound Allowed upper bound
"""
int length = input.width*input.numBands;
for (int y = 0; y < input.height; y++) {
int index = input.getStartIndex() + y * input.getStride();
int indexEnd = index+length;
while( index < indexEnd ) {
int value = (input.data[index]) + (int)(rand.nextGaussian()*sigma);
if( value < lowerBound ) value = lowerBound;
if( value > upperBound ) value = upperBound;
input.data[index++] = (short)value;
}
}
} | java | public static void addGaussian(InterleavedS16 input, Random rand , double sigma , int lowerBound , int upperBound ) {
int length = input.width*input.numBands;
for (int y = 0; y < input.height; y++) {
int index = input.getStartIndex() + y * input.getStride();
int indexEnd = index+length;
while( index < indexEnd ) {
int value = (input.data[index]) + (int)(rand.nextGaussian()*sigma);
if( value < lowerBound ) value = lowerBound;
if( value > upperBound ) value = upperBound;
input.data[index++] = (short)value;
}
}
} | [
"public",
"static",
"void",
"addGaussian",
"(",
"InterleavedS16",
"input",
",",
"Random",
"rand",
",",
"double",
"sigma",
",",
"int",
"lowerBound",
",",
"int",
"upperBound",
")",
"{",
"int",
"length",
"=",
"input",
".",
"width",
"*",
"input",
".",
"numBands",
";",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"input",
".",
"height",
";",
"y",
"++",
")",
"{",
"int",
"index",
"=",
"input",
".",
"getStartIndex",
"(",
")",
"+",
"y",
"*",
"input",
".",
"getStride",
"(",
")",
";",
"int",
"indexEnd",
"=",
"index",
"+",
"length",
";",
"while",
"(",
"index",
"<",
"indexEnd",
")",
"{",
"int",
"value",
"=",
"(",
"input",
".",
"data",
"[",
"index",
"]",
")",
"+",
"(",
"int",
")",
"(",
"rand",
".",
"nextGaussian",
"(",
")",
"*",
"sigma",
")",
";",
"if",
"(",
"value",
"<",
"lowerBound",
")",
"value",
"=",
"lowerBound",
";",
"if",
"(",
"value",
">",
"upperBound",
")",
"value",
"=",
"upperBound",
";",
"input",
".",
"data",
"[",
"index",
"++",
"]",
"=",
"(",
"short",
")",
"value",
";",
"}",
"}",
"}"
] | Adds Gaussian/normal i.i.d noise to each pixel in the image. If a value exceeds the specified
it will be set to the closest bound.
@param input Input image. Modified.
@param rand Random number generator.
@param sigma Distributions standard deviation.
@param lowerBound Allowed lower bound
@param upperBound Allowed upper bound | [
"Adds",
"Gaussian",
"/",
"normal",
"i",
".",
"i",
".",
"d",
"noise",
"to",
"each",
"pixel",
"in",
"the",
"image",
".",
"If",
"a",
"value",
"exceeds",
"the",
"specified",
"it",
"will",
"be",
"set",
"to",
"the",
"closest",
"bound",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/ImageMiscOps.java#L3608-L3622 |
spotbugs/spotbugs | eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java | FindbugsPlugin.saveCurrentBugCollection | public static void saveCurrentBugCollection(IProject project, IProgressMonitor monitor) throws CoreException {
"""
If necessary, save current bug collection for project to disk.
@param project
the project
@param monitor
a progress monitor
@throws CoreException
"""
if (isBugCollectionDirty(project)) {
SortedBugCollection bugCollection = (SortedBugCollection) project.getSessionProperty(SESSION_PROPERTY_BUG_COLLECTION);
if (bugCollection != null) {
writeBugCollection(project, bugCollection, monitor);
}
}
} | java | public static void saveCurrentBugCollection(IProject project, IProgressMonitor monitor) throws CoreException {
if (isBugCollectionDirty(project)) {
SortedBugCollection bugCollection = (SortedBugCollection) project.getSessionProperty(SESSION_PROPERTY_BUG_COLLECTION);
if (bugCollection != null) {
writeBugCollection(project, bugCollection, monitor);
}
}
} | [
"public",
"static",
"void",
"saveCurrentBugCollection",
"(",
"IProject",
"project",
",",
"IProgressMonitor",
"monitor",
")",
"throws",
"CoreException",
"{",
"if",
"(",
"isBugCollectionDirty",
"(",
"project",
")",
")",
"{",
"SortedBugCollection",
"bugCollection",
"=",
"(",
"SortedBugCollection",
")",
"project",
".",
"getSessionProperty",
"(",
"SESSION_PROPERTY_BUG_COLLECTION",
")",
";",
"if",
"(",
"bugCollection",
"!=",
"null",
")",
"{",
"writeBugCollection",
"(",
"project",
",",
"bugCollection",
",",
"monitor",
")",
";",
"}",
"}",
"}"
] | If necessary, save current bug collection for project to disk.
@param project
the project
@param monitor
a progress monitor
@throws CoreException | [
"If",
"necessary",
"save",
"current",
"bug",
"collection",
"for",
"project",
"to",
"disk",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java#L764-L772 |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java | SqlDateTimeUtils.internalToDate | public static java.sql.Date internalToDate(int v, TimeZone tz) {
"""
Converts the internal representation of a SQL DATE (int) to the Java
type used for UDF parameters ({@link java.sql.Date}) with the given TimeZone.
<p>The internal int represents the days since January 1, 1970. When we convert it
to {@link java.sql.Date} (time milliseconds since January 1, 1970, 00:00:00 GMT),
we need a TimeZone.
"""
// note that, in this case, can't handle Daylight Saving Time
final long t = v * MILLIS_PER_DAY;
return new java.sql.Date(t - tz.getOffset(t));
} | java | public static java.sql.Date internalToDate(int v, TimeZone tz) {
// note that, in this case, can't handle Daylight Saving Time
final long t = v * MILLIS_PER_DAY;
return new java.sql.Date(t - tz.getOffset(t));
} | [
"public",
"static",
"java",
".",
"sql",
".",
"Date",
"internalToDate",
"(",
"int",
"v",
",",
"TimeZone",
"tz",
")",
"{",
"// note that, in this case, can't handle Daylight Saving Time",
"final",
"long",
"t",
"=",
"v",
"*",
"MILLIS_PER_DAY",
";",
"return",
"new",
"java",
".",
"sql",
".",
"Date",
"(",
"t",
"-",
"tz",
".",
"getOffset",
"(",
"t",
")",
")",
";",
"}"
] | Converts the internal representation of a SQL DATE (int) to the Java
type used for UDF parameters ({@link java.sql.Date}) with the given TimeZone.
<p>The internal int represents the days since January 1, 1970. When we convert it
to {@link java.sql.Date} (time milliseconds since January 1, 1970, 00:00:00 GMT),
we need a TimeZone. | [
"Converts",
"the",
"internal",
"representation",
"of",
"a",
"SQL",
"DATE",
"(",
"int",
")",
"to",
"the",
"Java",
"type",
"used",
"for",
"UDF",
"parameters",
"(",
"{",
"@link",
"java",
".",
"sql",
".",
"Date",
"}",
")",
"with",
"the",
"given",
"TimeZone",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java#L133-L137 |
fuinorg/utils4j | src/main/java/org/fuin/utils4j/Utils4J.java | Utils4J.addToClasspath | public static void addToClasspath(final String url, final ClassLoader classLoader) {
"""
Adds an URL to the classpath.
@param url
URL to add - Cannot be <code>null</code>.
@param classLoader
Class loader to use - Cannot be <code>null</code>.
"""
checkNotNull("url", url);
try {
addToClasspath(new URL(url), classLoader);
} catch (final MalformedURLException e) {
throw new RuntimeException(e);
}
} | java | public static void addToClasspath(final String url, final ClassLoader classLoader) {
checkNotNull("url", url);
try {
addToClasspath(new URL(url), classLoader);
} catch (final MalformedURLException e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"void",
"addToClasspath",
"(",
"final",
"String",
"url",
",",
"final",
"ClassLoader",
"classLoader",
")",
"{",
"checkNotNull",
"(",
"\"url\"",
",",
"url",
")",
";",
"try",
"{",
"addToClasspath",
"(",
"new",
"URL",
"(",
"url",
")",
",",
"classLoader",
")",
";",
"}",
"catch",
"(",
"final",
"MalformedURLException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Adds an URL to the classpath.
@param url
URL to add - Cannot be <code>null</code>.
@param classLoader
Class loader to use - Cannot be <code>null</code>. | [
"Adds",
"an",
"URL",
"to",
"the",
"classpath",
"."
] | train | https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L254-L261 |
apache/incubator-druid | server/src/main/java/org/apache/druid/curator/discovery/DiscoveryModule.java | DiscoveryModule.registerKey | public static void registerKey(Binder binder, Key<DruidNode> key) {
"""
Requests that the keyed DruidNode instance be injected and published as part of the lifecycle.
That is, this module will announce the DruidNode instance returned by
injector.getInstance(Key.get(DruidNode.class, annotation)) automatically.
Announcement will happen in the ANNOUNCEMENTS stage of the Lifecycle
@param binder the Binder to register with
@param key The key to use in finding the DruidNode instance
"""
DruidBinders.discoveryAnnouncementBinder(binder).addBinding().toInstance(new KeyHolder<>(key));
LifecycleModule.register(binder, ServiceAnnouncer.class);
} | java | public static void registerKey(Binder binder, Key<DruidNode> key)
{
DruidBinders.discoveryAnnouncementBinder(binder).addBinding().toInstance(new KeyHolder<>(key));
LifecycleModule.register(binder, ServiceAnnouncer.class);
} | [
"public",
"static",
"void",
"registerKey",
"(",
"Binder",
"binder",
",",
"Key",
"<",
"DruidNode",
">",
"key",
")",
"{",
"DruidBinders",
".",
"discoveryAnnouncementBinder",
"(",
"binder",
")",
".",
"addBinding",
"(",
")",
".",
"toInstance",
"(",
"new",
"KeyHolder",
"<>",
"(",
"key",
")",
")",
";",
"LifecycleModule",
".",
"register",
"(",
"binder",
",",
"ServiceAnnouncer",
".",
"class",
")",
";",
"}"
] | Requests that the keyed DruidNode instance be injected and published as part of the lifecycle.
That is, this module will announce the DruidNode instance returned by
injector.getInstance(Key.get(DruidNode.class, annotation)) automatically.
Announcement will happen in the ANNOUNCEMENTS stage of the Lifecycle
@param binder the Binder to register with
@param key The key to use in finding the DruidNode instance | [
"Requests",
"that",
"the",
"keyed",
"DruidNode",
"instance",
"be",
"injected",
"and",
"published",
"as",
"part",
"of",
"the",
"lifecycle",
"."
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/server/src/main/java/org/apache/druid/curator/discovery/DiscoveryModule.java#L142-L146 |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java | IPAddressSegment.isChangedByMask | protected boolean isChangedByMask(int maskValue, Integer segmentPrefixLength) throws IncompatibleAddressException {
"""
returns a new segment masked by the given mask
This method applies the mask first to every address in the range, and it does not preserve any existing prefix.
The given prefix will be applied to the range of addresses after the mask.
If the combination of the two does not result in a contiguous range, then {@link IncompatibleAddressException} is thrown.
"""
boolean hasBits = (segmentPrefixLength != null);
if(hasBits && (segmentPrefixLength < 0 || segmentPrefixLength > getBitCount())) {
throw new PrefixLenException(this, segmentPrefixLength);
}
//note that the mask can represent a range (for example a CIDR mask),
//but we use the lowest value (maskSegment.value) in the range when masking (ie we discard the range)
int value = getSegmentValue();
int upperValue = getUpperSegmentValue();
return value != (value & maskValue) ||
upperValue != (upperValue & maskValue) ||
(isPrefixed() ? !getSegmentPrefixLength().equals(segmentPrefixLength) : hasBits);
} | java | protected boolean isChangedByMask(int maskValue, Integer segmentPrefixLength) throws IncompatibleAddressException {
boolean hasBits = (segmentPrefixLength != null);
if(hasBits && (segmentPrefixLength < 0 || segmentPrefixLength > getBitCount())) {
throw new PrefixLenException(this, segmentPrefixLength);
}
//note that the mask can represent a range (for example a CIDR mask),
//but we use the lowest value (maskSegment.value) in the range when masking (ie we discard the range)
int value = getSegmentValue();
int upperValue = getUpperSegmentValue();
return value != (value & maskValue) ||
upperValue != (upperValue & maskValue) ||
(isPrefixed() ? !getSegmentPrefixLength().equals(segmentPrefixLength) : hasBits);
} | [
"protected",
"boolean",
"isChangedByMask",
"(",
"int",
"maskValue",
",",
"Integer",
"segmentPrefixLength",
")",
"throws",
"IncompatibleAddressException",
"{",
"boolean",
"hasBits",
"=",
"(",
"segmentPrefixLength",
"!=",
"null",
")",
";",
"if",
"(",
"hasBits",
"&&",
"(",
"segmentPrefixLength",
"<",
"0",
"||",
"segmentPrefixLength",
">",
"getBitCount",
"(",
")",
")",
")",
"{",
"throw",
"new",
"PrefixLenException",
"(",
"this",
",",
"segmentPrefixLength",
")",
";",
"}",
"//note that the mask can represent a range (for example a CIDR mask), \r",
"//but we use the lowest value (maskSegment.value) in the range when masking (ie we discard the range)\r",
"int",
"value",
"=",
"getSegmentValue",
"(",
")",
";",
"int",
"upperValue",
"=",
"getUpperSegmentValue",
"(",
")",
";",
"return",
"value",
"!=",
"(",
"value",
"&",
"maskValue",
")",
"||",
"upperValue",
"!=",
"(",
"upperValue",
"&",
"maskValue",
")",
"||",
"(",
"isPrefixed",
"(",
")",
"?",
"!",
"getSegmentPrefixLength",
"(",
")",
".",
"equals",
"(",
"segmentPrefixLength",
")",
":",
"hasBits",
")",
";",
"}"
] | returns a new segment masked by the given mask
This method applies the mask first to every address in the range, and it does not preserve any existing prefix.
The given prefix will be applied to the range of addresses after the mask.
If the combination of the two does not result in a contiguous range, then {@link IncompatibleAddressException} is thrown. | [
"returns",
"a",
"new",
"segment",
"masked",
"by",
"the",
"given",
"mask"
] | train | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java#L273-L286 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/files/StaticFileServerHandler.java | StaticFileServerHandler.sendNotModified | public static void sendNotModified(ChannelHandlerContext ctx) {
"""
Send the "304 Not Modified" response. This response can be used when the
file timestamp is the same as what the browser is sending up.
@param ctx The channel context to write the response to.
"""
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, NOT_MODIFIED);
setDateHeader(response);
// close the connection as soon as the error message is sent.
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} | java | public static void sendNotModified(ChannelHandlerContext ctx) {
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, NOT_MODIFIED);
setDateHeader(response);
// close the connection as soon as the error message is sent.
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} | [
"public",
"static",
"void",
"sendNotModified",
"(",
"ChannelHandlerContext",
"ctx",
")",
"{",
"FullHttpResponse",
"response",
"=",
"new",
"DefaultFullHttpResponse",
"(",
"HTTP_1_1",
",",
"NOT_MODIFIED",
")",
";",
"setDateHeader",
"(",
"response",
")",
";",
"// close the connection as soon as the error message is sent.",
"ctx",
".",
"writeAndFlush",
"(",
"response",
")",
".",
"addListener",
"(",
"ChannelFutureListener",
".",
"CLOSE",
")",
";",
"}"
] | Send the "304 Not Modified" response. This response can be used when the
file timestamp is the same as what the browser is sending up.
@param ctx The channel context to write the response to. | [
"Send",
"the",
"304",
"Not",
"Modified",
"response",
".",
"This",
"response",
"can",
"be",
"used",
"when",
"the",
"file",
"timestamp",
"is",
"the",
"same",
"as",
"what",
"the",
"browser",
"is",
"sending",
"up",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/files/StaticFileServerHandler.java#L324-L330 |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/LongExtensions.java | LongExtensions.operator_equals | @Pure
@Inline(value="($1 == $2)", constantExpression=true)
public static boolean operator_equals(long a, double b) {
"""
The binary <code>equals</code> operator. This is the equivalent to the Java <code>==</code> operator.
@param a a long.
@param b a double.
@return <code>a==b</code>
@since 2.3
"""
return a == b;
} | java | @Pure
@Inline(value="($1 == $2)", constantExpression=true)
public static boolean operator_equals(long a, double b) {
return a == b;
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"($1 == $2)\"",
",",
"constantExpression",
"=",
"true",
")",
"public",
"static",
"boolean",
"operator_equals",
"(",
"long",
"a",
",",
"double",
"b",
")",
"{",
"return",
"a",
"==",
"b",
";",
"}"
] | The binary <code>equals</code> operator. This is the equivalent to the Java <code>==</code> operator.
@param a a long.
@param b a double.
@return <code>a==b</code>
@since 2.3 | [
"The",
"binary",
"<code",
">",
"equals<",
"/",
"code",
">",
"operator",
".",
"This",
"is",
"the",
"equivalent",
"to",
"the",
"Java",
"<code",
">",
"==",
"<",
"/",
"code",
">",
"operator",
"."
] | train | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/LongExtensions.java#L376-L380 |
btaz/data-util | src/main/java/com/btaz/util/xml/model/Element.java | Element.addAttribute | public void addAttribute(String attributeName, String attributeValue) throws XmlModelException {
"""
Add a new element attribute
@param attributeName attribute name
@param attributeValue attribute value
@throws XmlModelException XML model exception
"""
String name = attributeName.trim();
String value = attributeValue.trim();
if(attributesMap.containsKey(name)) {
throw new XmlModelException("Duplicate attribute: " + name);
}
attributeNames.add(name);
attributesMap.put(name, new Attribute(name, value));
} | java | public void addAttribute(String attributeName, String attributeValue) throws XmlModelException {
String name = attributeName.trim();
String value = attributeValue.trim();
if(attributesMap.containsKey(name)) {
throw new XmlModelException("Duplicate attribute: " + name);
}
attributeNames.add(name);
attributesMap.put(name, new Attribute(name, value));
} | [
"public",
"void",
"addAttribute",
"(",
"String",
"attributeName",
",",
"String",
"attributeValue",
")",
"throws",
"XmlModelException",
"{",
"String",
"name",
"=",
"attributeName",
".",
"trim",
"(",
")",
";",
"String",
"value",
"=",
"attributeValue",
".",
"trim",
"(",
")",
";",
"if",
"(",
"attributesMap",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"XmlModelException",
"(",
"\"Duplicate attribute: \"",
"+",
"name",
")",
";",
"}",
"attributeNames",
".",
"add",
"(",
"name",
")",
";",
"attributesMap",
".",
"put",
"(",
"name",
",",
"new",
"Attribute",
"(",
"name",
",",
"value",
")",
")",
";",
"}"
] | Add a new element attribute
@param attributeName attribute name
@param attributeValue attribute value
@throws XmlModelException XML model exception | [
"Add",
"a",
"new",
"element",
"attribute"
] | train | https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/xml/model/Element.java#L105-L113 |
ontop/ontop | mapping/sql/core/src/main/java/it/unibz/inf/ontop/spec/mapping/parser/impl/RAExpression.java | RAExpression.joinOn | public static RAExpression joinOn(RAExpression re1, RAExpression re2,
java.util.function.Function<ImmutableMap<QualifiedAttributeID, Term>, ImmutableList<Function>> getAtomOnExpression,
TermFactory termFactory) throws IllegalJoinException {
"""
JOIN ON
@param re1 a {@link RAExpression}
@param re2 a {@link RAExpression}
@param getAtomOnExpression
@return a {@link RAExpression}
@throws IllegalJoinException if the same alias occurs in both arguments
"""
RAExpressionAttributes attributes =
RAExpressionAttributes.crossJoin(re1.attributes, re2.attributes);
return new RAExpression(union(re1.dataAtoms, re2.dataAtoms),
union(re1.filterAtoms, re2.filterAtoms,
getAtomOnExpression.apply(attributes.getAttributes())), attributes, termFactory);
} | java | public static RAExpression joinOn(RAExpression re1, RAExpression re2,
java.util.function.Function<ImmutableMap<QualifiedAttributeID, Term>, ImmutableList<Function>> getAtomOnExpression,
TermFactory termFactory) throws IllegalJoinException {
RAExpressionAttributes attributes =
RAExpressionAttributes.crossJoin(re1.attributes, re2.attributes);
return new RAExpression(union(re1.dataAtoms, re2.dataAtoms),
union(re1.filterAtoms, re2.filterAtoms,
getAtomOnExpression.apply(attributes.getAttributes())), attributes, termFactory);
} | [
"public",
"static",
"RAExpression",
"joinOn",
"(",
"RAExpression",
"re1",
",",
"RAExpression",
"re2",
",",
"java",
".",
"util",
".",
"function",
".",
"Function",
"<",
"ImmutableMap",
"<",
"QualifiedAttributeID",
",",
"Term",
">",
",",
"ImmutableList",
"<",
"Function",
">",
">",
"getAtomOnExpression",
",",
"TermFactory",
"termFactory",
")",
"throws",
"IllegalJoinException",
"{",
"RAExpressionAttributes",
"attributes",
"=",
"RAExpressionAttributes",
".",
"crossJoin",
"(",
"re1",
".",
"attributes",
",",
"re2",
".",
"attributes",
")",
";",
"return",
"new",
"RAExpression",
"(",
"union",
"(",
"re1",
".",
"dataAtoms",
",",
"re2",
".",
"dataAtoms",
")",
",",
"union",
"(",
"re1",
".",
"filterAtoms",
",",
"re2",
".",
"filterAtoms",
",",
"getAtomOnExpression",
".",
"apply",
"(",
"attributes",
".",
"getAttributes",
"(",
")",
")",
")",
",",
"attributes",
",",
"termFactory",
")",
";",
"}"
] | JOIN ON
@param re1 a {@link RAExpression}
@param re2 a {@link RAExpression}
@param getAtomOnExpression
@return a {@link RAExpression}
@throws IllegalJoinException if the same alias occurs in both arguments | [
"JOIN",
"ON"
] | train | https://github.com/ontop/ontop/blob/ddf78b26981b6129ee9a1a59310016830f5352e4/mapping/sql/core/src/main/java/it/unibz/inf/ontop/spec/mapping/parser/impl/RAExpression.java#L83-L93 |
jtrfp/javamod | src/main/java/de/quippy/javamod/multimedia/mp3/id3/MP3FileID3Controller.java | MP3FileID3Controller.setTitle | public void setTitle(String title, int type) {
"""
Set the title of this mp3.
@param title the title of the mp3
"""
if (allow(type&ID3V1))
{
id3v1.setTitle(title);
}
if (allow(type&ID3V2))
{
id3v2.setTextFrame(ID3v2Frames.TITLE, title);
}
} | java | public void setTitle(String title, int type)
{
if (allow(type&ID3V1))
{
id3v1.setTitle(title);
}
if (allow(type&ID3V2))
{
id3v2.setTextFrame(ID3v2Frames.TITLE, title);
}
} | [
"public",
"void",
"setTitle",
"(",
"String",
"title",
",",
"int",
"type",
")",
"{",
"if",
"(",
"allow",
"(",
"type",
"&",
"ID3V1",
")",
")",
"{",
"id3v1",
".",
"setTitle",
"(",
"title",
")",
";",
"}",
"if",
"(",
"allow",
"(",
"type",
"&",
"ID3V2",
")",
")",
"{",
"id3v2",
".",
"setTextFrame",
"(",
"ID3v2Frames",
".",
"TITLE",
",",
"title",
")",
";",
"}",
"}"
] | Set the title of this mp3.
@param title the title of the mp3 | [
"Set",
"the",
"title",
"of",
"this",
"mp3",
"."
] | train | https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mp3/id3/MP3FileID3Controller.java#L159-L169 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/ConcurrentServiceReferenceMap.java | ConcurrentServiceReferenceMap.putReference | public boolean putReference(K key, ServiceReference<V> reference) {
"""
Associates the reference with the key.
@param key Key associated with this reference
@param reference ServiceReference for the target service
@return true if this is replacing a previous (non-null) service reference
"""
if (key == null || reference == null)
return false;
ConcurrentServiceReferenceElement<V> element = new ConcurrentServiceReferenceElement<V>(referenceName, reference);
return (elementMap.put(key, element) != null);
} | java | public boolean putReference(K key, ServiceReference<V> reference) {
if (key == null || reference == null)
return false;
ConcurrentServiceReferenceElement<V> element = new ConcurrentServiceReferenceElement<V>(referenceName, reference);
return (elementMap.put(key, element) != null);
} | [
"public",
"boolean",
"putReference",
"(",
"K",
"key",
",",
"ServiceReference",
"<",
"V",
">",
"reference",
")",
"{",
"if",
"(",
"key",
"==",
"null",
"||",
"reference",
"==",
"null",
")",
"return",
"false",
";",
"ConcurrentServiceReferenceElement",
"<",
"V",
">",
"element",
"=",
"new",
"ConcurrentServiceReferenceElement",
"<",
"V",
">",
"(",
"referenceName",
",",
"reference",
")",
";",
"return",
"(",
"elementMap",
".",
"put",
"(",
"key",
",",
"element",
")",
"!=",
"null",
")",
";",
"}"
] | Associates the reference with the key.
@param key Key associated with this reference
@param reference ServiceReference for the target service
@return true if this is replacing a previous (non-null) service reference | [
"Associates",
"the",
"reference",
"with",
"the",
"key",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/ConcurrentServiceReferenceMap.java#L118-L124 |
landawn/AbacusUtil | src/com/landawn/abacus/util/stream/Collectors.java | Collectors.minAll | public static <T> Collector<T, ?, List<T>> minAll(Comparator<? super T> comparator) {
"""
It's copied from StreamEx: https://github.com/amaembo/streamex under Apache License v2 and may be modified.
<br />
Returns a {@code Collector} which finds all the elements which are equal
to each other and smaller than any other element according to the
specified {@link Comparator}. The found elements are collected to
{@link List}.
@param <T> the type of the input elements
@param comparator a {@code Comparator} to compare the elements
@return a {@code Collector} which finds all the minimal elements and
collects them to the {@code List}.
@see #minAll(Comparator, Collector)
@see #minAll()
"""
return minAll(comparator, Integer.MAX_VALUE);
} | java | public static <T> Collector<T, ?, List<T>> minAll(Comparator<? super T> comparator) {
return minAll(comparator, Integer.MAX_VALUE);
} | [
"public",
"static",
"<",
"T",
">",
"Collector",
"<",
"T",
",",
"?",
",",
"List",
"<",
"T",
">",
">",
"minAll",
"(",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comparator",
")",
"{",
"return",
"minAll",
"(",
"comparator",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"}"
] | It's copied from StreamEx: https://github.com/amaembo/streamex under Apache License v2 and may be modified.
<br />
Returns a {@code Collector} which finds all the elements which are equal
to each other and smaller than any other element according to the
specified {@link Comparator}. The found elements are collected to
{@link List}.
@param <T> the type of the input elements
@param comparator a {@code Comparator} to compare the elements
@return a {@code Collector} which finds all the minimal elements and
collects them to the {@code List}.
@see #minAll(Comparator, Collector)
@see #minAll() | [
"It",
"s",
"copied",
"from",
"StreamEx",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"amaembo",
"/",
"streamex",
"under",
"Apache",
"License",
"v2",
"and",
"may",
"be",
"modified",
".",
"<br",
"/",
">"
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/stream/Collectors.java#L2527-L2529 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/JobScheduleOperations.java | JobScheduleOperations.updateJobSchedule | public void updateJobSchedule(String jobScheduleId, Schedule schedule, JobSpecification jobSpecification, List<MetadataItem> metadata, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
"""
Updates the specified job schedule.
This method performs a full replace of all the updatable properties of the job schedule. For example, if the schedule parameter is null, then the Batch service removes the job schedule’s existing schedule and replaces it with the default schedule.
@param jobScheduleId The ID of the job schedule.
@param schedule The schedule according to which jobs will be created. If null, it is equivalent to passing the default schedule: that is, a single job scheduled to run immediately.
@param jobSpecification The details of the jobs to be created on this schedule. Updates affect only jobs that are started after the update has taken place. Any currently active job continues with the older specification.
@param metadata A list of name-value pairs associated with the job schedule as metadata. If null, it takes the default value of an empty list; in effect, any existing metadata is deleted.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
"""
JobScheduleUpdateOptions options = new JobScheduleUpdateOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
JobScheduleUpdateParameter param = new JobScheduleUpdateParameter()
.withJobSpecification(jobSpecification)
.withMetadata(metadata)
.withSchedule(schedule);
this.parentBatchClient.protocolLayer().jobSchedules().update(jobScheduleId, param, options);
} | java | public void updateJobSchedule(String jobScheduleId, Schedule schedule, JobSpecification jobSpecification, List<MetadataItem> metadata, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
JobScheduleUpdateOptions options = new JobScheduleUpdateOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
JobScheduleUpdateParameter param = new JobScheduleUpdateParameter()
.withJobSpecification(jobSpecification)
.withMetadata(metadata)
.withSchedule(schedule);
this.parentBatchClient.protocolLayer().jobSchedules().update(jobScheduleId, param, options);
} | [
"public",
"void",
"updateJobSchedule",
"(",
"String",
"jobScheduleId",
",",
"Schedule",
"schedule",
",",
"JobSpecification",
"jobSpecification",
",",
"List",
"<",
"MetadataItem",
">",
"metadata",
",",
"Iterable",
"<",
"BatchClientBehavior",
">",
"additionalBehaviors",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"JobScheduleUpdateOptions",
"options",
"=",
"new",
"JobScheduleUpdateOptions",
"(",
")",
";",
"BehaviorManager",
"bhMgr",
"=",
"new",
"BehaviorManager",
"(",
"this",
".",
"customBehaviors",
"(",
")",
",",
"additionalBehaviors",
")",
";",
"bhMgr",
".",
"applyRequestBehaviors",
"(",
"options",
")",
";",
"JobScheduleUpdateParameter",
"param",
"=",
"new",
"JobScheduleUpdateParameter",
"(",
")",
".",
"withJobSpecification",
"(",
"jobSpecification",
")",
".",
"withMetadata",
"(",
"metadata",
")",
".",
"withSchedule",
"(",
"schedule",
")",
";",
"this",
".",
"parentBatchClient",
".",
"protocolLayer",
"(",
")",
".",
"jobSchedules",
"(",
")",
".",
"update",
"(",
"jobScheduleId",
",",
"param",
",",
"options",
")",
";",
"}"
] | Updates the specified job schedule.
This method performs a full replace of all the updatable properties of the job schedule. For example, if the schedule parameter is null, then the Batch service removes the job schedule’s existing schedule and replaces it with the default schedule.
@param jobScheduleId The ID of the job schedule.
@param schedule The schedule according to which jobs will be created. If null, it is equivalent to passing the default schedule: that is, a single job scheduled to run immediately.
@param jobSpecification The details of the jobs to be created on this schedule. Updates affect only jobs that are started after the update has taken place. Any currently active job continues with the older specification.
@param metadata A list of name-value pairs associated with the job schedule as metadata. If null, it takes the default value of an empty list; in effect, any existing metadata is deleted.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. | [
"Updates",
"the",
"specified",
"job",
"schedule",
".",
"This",
"method",
"performs",
"a",
"full",
"replace",
"of",
"all",
"the",
"updatable",
"properties",
"of",
"the",
"job",
"schedule",
".",
"For",
"example",
"if",
"the",
"schedule",
"parameter",
"is",
"null",
"then",
"the",
"Batch",
"service",
"removes",
"the",
"job",
"schedule’s",
"existing",
"schedule",
"and",
"replaces",
"it",
"with",
"the",
"default",
"schedule",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/JobScheduleOperations.java#L262-L272 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/io/shp/internal/SHPDriver.java | SHPDriver.initDriver | public void initDriver(File shpFile, ShapeType shapeType, DbaseFileHeader dbaseHeader) throws IOException {
"""
Init Driver for Write mode
@param shpFile
@param shapeType
@param dbaseHeader
@throws IOException
"""
String path = shpFile.getAbsolutePath();
String nameWithoutExt = path.substring(0,path.lastIndexOf('.'));
this.shpFile = new File(nameWithoutExt+".shp");
this.shxFile = new File(nameWithoutExt+".shx");
this.dbfFile = new File(nameWithoutExt+".dbf");
FileOutputStream shpFos = new FileOutputStream(shpFile);
FileOutputStream shxFos = new FileOutputStream(shxFile);
shapefileWriter = new ShapefileWriter(shpFos.getChannel(), shxFos.getChannel());
this.shapeType = shapeType;
shapefileWriter.writeHeaders(shapeType);
dbfDriver.initDriver(dbfFile, dbaseHeader);
} | java | public void initDriver(File shpFile, ShapeType shapeType, DbaseFileHeader dbaseHeader) throws IOException {
String path = shpFile.getAbsolutePath();
String nameWithoutExt = path.substring(0,path.lastIndexOf('.'));
this.shpFile = new File(nameWithoutExt+".shp");
this.shxFile = new File(nameWithoutExt+".shx");
this.dbfFile = new File(nameWithoutExt+".dbf");
FileOutputStream shpFos = new FileOutputStream(shpFile);
FileOutputStream shxFos = new FileOutputStream(shxFile);
shapefileWriter = new ShapefileWriter(shpFos.getChannel(), shxFos.getChannel());
this.shapeType = shapeType;
shapefileWriter.writeHeaders(shapeType);
dbfDriver.initDriver(dbfFile, dbaseHeader);
} | [
"public",
"void",
"initDriver",
"(",
"File",
"shpFile",
",",
"ShapeType",
"shapeType",
",",
"DbaseFileHeader",
"dbaseHeader",
")",
"throws",
"IOException",
"{",
"String",
"path",
"=",
"shpFile",
".",
"getAbsolutePath",
"(",
")",
";",
"String",
"nameWithoutExt",
"=",
"path",
".",
"substring",
"(",
"0",
",",
"path",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
")",
";",
"this",
".",
"shpFile",
"=",
"new",
"File",
"(",
"nameWithoutExt",
"+",
"\".shp\"",
")",
";",
"this",
".",
"shxFile",
"=",
"new",
"File",
"(",
"nameWithoutExt",
"+",
"\".shx\"",
")",
";",
"this",
".",
"dbfFile",
"=",
"new",
"File",
"(",
"nameWithoutExt",
"+",
"\".dbf\"",
")",
";",
"FileOutputStream",
"shpFos",
"=",
"new",
"FileOutputStream",
"(",
"shpFile",
")",
";",
"FileOutputStream",
"shxFos",
"=",
"new",
"FileOutputStream",
"(",
"shxFile",
")",
";",
"shapefileWriter",
"=",
"new",
"ShapefileWriter",
"(",
"shpFos",
".",
"getChannel",
"(",
")",
",",
"shxFos",
".",
"getChannel",
"(",
")",
")",
";",
"this",
".",
"shapeType",
"=",
"shapeType",
";",
"shapefileWriter",
".",
"writeHeaders",
"(",
"shapeType",
")",
";",
"dbfDriver",
".",
"initDriver",
"(",
"dbfFile",
",",
"dbaseHeader",
")",
";",
"}"
] | Init Driver for Write mode
@param shpFile
@param shapeType
@param dbaseHeader
@throws IOException | [
"Init",
"Driver",
"for",
"Write",
"mode"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/shp/internal/SHPDriver.java#L109-L121 |
Multifarious/MacroManager | src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java | BalancingPolicy.attemptToClaim | boolean attemptToClaim(String workUnit, boolean claimForHandoff)
throws InterruptedException {
"""
Attempts to claim a given work unit by creating an ephemeral node in ZooKeeper
with this node's ID. If the claim succeeds, start work. If not, move on.
@throws ZooKeeperConnectionException
@throws KeeperException
"""
LOG.debug("Attempting to claim {}. For handoff? {}", workUnit, claimForHandoff);
String path = claimForHandoff
? String.format("/%s/handoff-result/%s", cluster.name, workUnit)
: cluster.workUnitClaimPath(workUnit);
final boolean created = ZKUtils.createEphemeral(cluster.zk, path, cluster.myNodeID);
if (created) {
if (claimForHandoff) {
cluster.claimedForHandoff.add(workUnit);
}
cluster.startWork(workUnit);
return true;
}
if (isPeggedToMe(workUnit)) {
claimWorkPeggedToMe(workUnit);
return true;
}
return false;
} | java | boolean attemptToClaim(String workUnit, boolean claimForHandoff)
throws InterruptedException
{
LOG.debug("Attempting to claim {}. For handoff? {}", workUnit, claimForHandoff);
String path = claimForHandoff
? String.format("/%s/handoff-result/%s", cluster.name, workUnit)
: cluster.workUnitClaimPath(workUnit);
final boolean created = ZKUtils.createEphemeral(cluster.zk, path, cluster.myNodeID);
if (created) {
if (claimForHandoff) {
cluster.claimedForHandoff.add(workUnit);
}
cluster.startWork(workUnit);
return true;
}
if (isPeggedToMe(workUnit)) {
claimWorkPeggedToMe(workUnit);
return true;
}
return false;
} | [
"boolean",
"attemptToClaim",
"(",
"String",
"workUnit",
",",
"boolean",
"claimForHandoff",
")",
"throws",
"InterruptedException",
"{",
"LOG",
".",
"debug",
"(",
"\"Attempting to claim {}. For handoff? {}\"",
",",
"workUnit",
",",
"claimForHandoff",
")",
";",
"String",
"path",
"=",
"claimForHandoff",
"?",
"String",
".",
"format",
"(",
"\"/%s/handoff-result/%s\"",
",",
"cluster",
".",
"name",
",",
"workUnit",
")",
":",
"cluster",
".",
"workUnitClaimPath",
"(",
"workUnit",
")",
";",
"final",
"boolean",
"created",
"=",
"ZKUtils",
".",
"createEphemeral",
"(",
"cluster",
".",
"zk",
",",
"path",
",",
"cluster",
".",
"myNodeID",
")",
";",
"if",
"(",
"created",
")",
"{",
"if",
"(",
"claimForHandoff",
")",
"{",
"cluster",
".",
"claimedForHandoff",
".",
"add",
"(",
"workUnit",
")",
";",
"}",
"cluster",
".",
"startWork",
"(",
"workUnit",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"isPeggedToMe",
"(",
"workUnit",
")",
")",
"{",
"claimWorkPeggedToMe",
"(",
"workUnit",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Attempts to claim a given work unit by creating an ephemeral node in ZooKeeper
with this node's ID. If the claim succeeds, start work. If not, move on.
@throws ZooKeeperConnectionException
@throws KeeperException | [
"Attempts",
"to",
"claim",
"a",
"given",
"work",
"unit",
"by",
"creating",
"an",
"ephemeral",
"node",
"in",
"ZooKeeper",
"with",
"this",
"node",
"s",
"ID",
".",
"If",
"the",
"claim",
"succeeds",
"start",
"work",
".",
"If",
"not",
"move",
"on",
"."
] | train | https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java#L130-L153 |
OpenLiberty/open-liberty | dev/com.ibm.ws.injection.core/src/com/ibm/ws/injectionengine/processor/ClientInjectionBinding.java | ClientInjectionBinding.getInjectionTarget | public static InjectionTarget getInjectionTarget(ComponentNameSpaceConfiguration compNSConfig, ClientInjection injection)
throws InjectionException {
"""
Acquires an InjectionTarget for the specified ClientInjection.
@param compNSConfig the minimal namespace configuration
@param injection the injection target descriptor
@return the injection target
@throws InjectionException if the target cannot be acquired
"""
final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
if (isTraceOn && tc.isEntryEnabled())
Tr.entry(tc, "getInjectionTarget: " + injection);
// Create a temporary InjectionBinding in order to resolve the target.
ClientInjectionBinding binding = new ClientInjectionBinding(compNSConfig, injection);
Class<?> injectionType = binding.loadClass(injection.getInjectionTypeName());
String targetName = injection.getTargetName();
String targetClassName = injection.getTargetClassName();
// Add a single injection target and then retrieve it.
binding.addInjectionTarget(injectionType, targetName, targetClassName);
InjectionTarget target = InjectionProcessorContextImpl.getInjectionTargets(binding).get(0);
binding.metadataProcessingComplete(); // d681767
if (isTraceOn && tc.isEntryEnabled())
Tr.exit(tc, "getInjectionTarget: " + target);
return target;
} | java | public static InjectionTarget getInjectionTarget(ComponentNameSpaceConfiguration compNSConfig, ClientInjection injection)
throws InjectionException
{
final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
if (isTraceOn && tc.isEntryEnabled())
Tr.entry(tc, "getInjectionTarget: " + injection);
// Create a temporary InjectionBinding in order to resolve the target.
ClientInjectionBinding binding = new ClientInjectionBinding(compNSConfig, injection);
Class<?> injectionType = binding.loadClass(injection.getInjectionTypeName());
String targetName = injection.getTargetName();
String targetClassName = injection.getTargetClassName();
// Add a single injection target and then retrieve it.
binding.addInjectionTarget(injectionType, targetName, targetClassName);
InjectionTarget target = InjectionProcessorContextImpl.getInjectionTargets(binding).get(0);
binding.metadataProcessingComplete(); // d681767
if (isTraceOn && tc.isEntryEnabled())
Tr.exit(tc, "getInjectionTarget: " + target);
return target;
} | [
"public",
"static",
"InjectionTarget",
"getInjectionTarget",
"(",
"ComponentNameSpaceConfiguration",
"compNSConfig",
",",
"ClientInjection",
"injection",
")",
"throws",
"InjectionException",
"{",
"final",
"boolean",
"isTraceOn",
"=",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
";",
"if",
"(",
"isTraceOn",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"getInjectionTarget: \"",
"+",
"injection",
")",
";",
"// Create a temporary InjectionBinding in order to resolve the target.",
"ClientInjectionBinding",
"binding",
"=",
"new",
"ClientInjectionBinding",
"(",
"compNSConfig",
",",
"injection",
")",
";",
"Class",
"<",
"?",
">",
"injectionType",
"=",
"binding",
".",
"loadClass",
"(",
"injection",
".",
"getInjectionTypeName",
"(",
")",
")",
";",
"String",
"targetName",
"=",
"injection",
".",
"getTargetName",
"(",
")",
";",
"String",
"targetClassName",
"=",
"injection",
".",
"getTargetClassName",
"(",
")",
";",
"// Add a single injection target and then retrieve it.",
"binding",
".",
"addInjectionTarget",
"(",
"injectionType",
",",
"targetName",
",",
"targetClassName",
")",
";",
"InjectionTarget",
"target",
"=",
"InjectionProcessorContextImpl",
".",
"getInjectionTargets",
"(",
"binding",
")",
".",
"get",
"(",
"0",
")",
";",
"binding",
".",
"metadataProcessingComplete",
"(",
")",
";",
"// d681767",
"if",
"(",
"isTraceOn",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"getInjectionTarget: \"",
"+",
"target",
")",
";",
"return",
"target",
";",
"}"
] | Acquires an InjectionTarget for the specified ClientInjection.
@param compNSConfig the minimal namespace configuration
@param injection the injection target descriptor
@return the injection target
@throws InjectionException if the target cannot be acquired | [
"Acquires",
"an",
"InjectionTarget",
"for",
"the",
"specified",
"ClientInjection",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection.core/src/com/ibm/ws/injectionengine/processor/ClientInjectionBinding.java#L49-L70 |
qos-ch/slf4j | slf4j-ext/src/main/java/org/slf4j/profiler/SpacePadder.java | SpacePadder.spacePad | final static public void spacePad(StringBuilder sbuf, int length) {
"""
Fast space padding method.
@param sbuf the buffer to pad
@param length the target size of the buffer after padding
"""
while (length >= 32) {
sbuf.append(SPACES[5]);
length -= 32;
}
for (int i = 4; i >= 0; i--) {
if ((length & (1 << i)) != 0) {
sbuf.append(SPACES[i]);
}
}
} | java | final static public void spacePad(StringBuilder sbuf, int length) {
while (length >= 32) {
sbuf.append(SPACES[5]);
length -= 32;
}
for (int i = 4; i >= 0; i--) {
if ((length & (1 << i)) != 0) {
sbuf.append(SPACES[i]);
}
}
} | [
"final",
"static",
"public",
"void",
"spacePad",
"(",
"StringBuilder",
"sbuf",
",",
"int",
"length",
")",
"{",
"while",
"(",
"length",
">=",
"32",
")",
"{",
"sbuf",
".",
"append",
"(",
"SPACES",
"[",
"5",
"]",
")",
";",
"length",
"-=",
"32",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"4",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"(",
"length",
"&",
"(",
"1",
"<<",
"i",
")",
")",
"!=",
"0",
")",
"{",
"sbuf",
".",
"append",
"(",
"SPACES",
"[",
"i",
"]",
")",
";",
"}",
"}",
"}"
] | Fast space padding method.
@param sbuf the buffer to pad
@param length the target size of the buffer after padding | [
"Fast",
"space",
"padding",
"method",
"."
] | train | https://github.com/qos-ch/slf4j/blob/905443f39fadd88a8dd2c467e44affd8cb072a4d/slf4j-ext/src/main/java/org/slf4j/profiler/SpacePadder.java#L115-L126 |
JOML-CI/JOML | src/org/joml/Matrix4x3d.java | Matrix4x3d.rotateLocal | public Matrix4x3d rotateLocal(double ang, double x, double y, double z) {
"""
Pre-multiply a rotation to this matrix by rotating the given amount of radians
about the specified <code>(x, y, z)</code> axis.
<p>
The axis described by the three components needs to be a unit vector.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
If <code>M</code> is <code>this</code> matrix and <code>R</code> the rotation matrix,
then the new matrix will be <code>R * M</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>R * M * v</code>, the
rotation will be applied last!
<p>
In order to set the matrix to a rotation matrix without pre-multiplying the rotation
transformation, use {@link #rotation(double, double, double, double) rotation()}.
<p>
Reference: <a href="http://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle">http://en.wikipedia.org</a>
@see #rotation(double, double, double, double)
@param ang
the angle in radians
@param x
the x component of the axis
@param y
the y component of the axis
@param z
the z component of the axis
@return this
"""
return rotateLocal(ang, x, y, z, this);
} | java | public Matrix4x3d rotateLocal(double ang, double x, double y, double z) {
return rotateLocal(ang, x, y, z, this);
} | [
"public",
"Matrix4x3d",
"rotateLocal",
"(",
"double",
"ang",
",",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
")",
"{",
"return",
"rotateLocal",
"(",
"ang",
",",
"x",
",",
"y",
",",
"z",
",",
"this",
")",
";",
"}"
] | Pre-multiply a rotation to this matrix by rotating the given amount of radians
about the specified <code>(x, y, z)</code> axis.
<p>
The axis described by the three components needs to be a unit vector.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
If <code>M</code> is <code>this</code> matrix and <code>R</code> the rotation matrix,
then the new matrix will be <code>R * M</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>R * M * v</code>, the
rotation will be applied last!
<p>
In order to set the matrix to a rotation matrix without pre-multiplying the rotation
transformation, use {@link #rotation(double, double, double, double) rotation()}.
<p>
Reference: <a href="http://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle">http://en.wikipedia.org</a>
@see #rotation(double, double, double, double)
@param ang
the angle in radians
@param x
the x component of the axis
@param y
the y component of the axis
@param z
the z component of the axis
@return this | [
"Pre",
"-",
"multiply",
"a",
"rotation",
"to",
"this",
"matrix",
"by",
"rotating",
"the",
"given",
"amount",
"of",
"radians",
"about",
"the",
"specified",
"<code",
">",
"(",
"x",
"y",
"z",
")",
"<",
"/",
"code",
">",
"axis",
".",
"<p",
">",
"The",
"axis",
"described",
"by",
"the",
"three",
"components",
"needs",
"to",
"be",
"a",
"unit",
"vector",
".",
"<p",
">",
"When",
"used",
"with",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"the",
"produced",
"rotation",
"will",
"rotate",
"a",
"vector",
"counter",
"-",
"clockwise",
"around",
"the",
"rotation",
"axis",
"when",
"viewing",
"along",
"the",
"negative",
"axis",
"direction",
"towards",
"the",
"origin",
".",
"When",
"used",
"with",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"the",
"rotation",
"is",
"clockwise",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"R<",
"/",
"code",
">",
"the",
"rotation",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"R",
"*",
"M<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"R",
"*",
"M",
"*",
"v<",
"/",
"code",
">",
"the",
"rotation",
"will",
"be",
"applied",
"last!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"rotation",
"matrix",
"without",
"pre",
"-",
"multiplying",
"the",
"rotation",
"transformation",
"use",
"{",
"@link",
"#rotation",
"(",
"double",
"double",
"double",
"double",
")",
"rotation",
"()",
"}",
".",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Rotation_matrix#Rotation_matrix_from_axis_and_angle",
">",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org<",
"/",
"a",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4x3d.java#L3554-L3556 |
spring-projects/spring-security-oauth | spring-security-oauth/src/main/java/org/springframework/security/oauth/provider/DefaultAuthenticationHandler.java | DefaultAuthenticationHandler.createAuthentication | public Authentication createAuthentication(HttpServletRequest request, ConsumerAuthentication authentication, OAuthAccessProviderToken authToken) {
"""
Default implementation returns the user authentication associated with the auth token, if the token is provided. Otherwise, the consumer authentication
is returned.
@param request The request that was successfully authenticated.
@param authentication The consumer authentication (details about how the request was authenticated).
@param authToken The OAuth token associated with the authentication. This token MAY be null if no authenticated token was needed to successfully
authenticate the request (for example, in the case of 2-legged OAuth).
@return The authentication.
"""
if (authToken != null) {
Authentication userAuthentication = authToken.getUserAuthentication();
if (userAuthentication instanceof AbstractAuthenticationToken) {
//initialize the details with the consumer that is actually making the request on behalf of the user.
((AbstractAuthenticationToken) userAuthentication).setDetails(new OAuthAuthenticationDetails(request, authentication.getConsumerDetails()));
}
return userAuthentication;
}
return authentication;
} | java | public Authentication createAuthentication(HttpServletRequest request, ConsumerAuthentication authentication, OAuthAccessProviderToken authToken) {
if (authToken != null) {
Authentication userAuthentication = authToken.getUserAuthentication();
if (userAuthentication instanceof AbstractAuthenticationToken) {
//initialize the details with the consumer that is actually making the request on behalf of the user.
((AbstractAuthenticationToken) userAuthentication).setDetails(new OAuthAuthenticationDetails(request, authentication.getConsumerDetails()));
}
return userAuthentication;
}
return authentication;
} | [
"public",
"Authentication",
"createAuthentication",
"(",
"HttpServletRequest",
"request",
",",
"ConsumerAuthentication",
"authentication",
",",
"OAuthAccessProviderToken",
"authToken",
")",
"{",
"if",
"(",
"authToken",
"!=",
"null",
")",
"{",
"Authentication",
"userAuthentication",
"=",
"authToken",
".",
"getUserAuthentication",
"(",
")",
";",
"if",
"(",
"userAuthentication",
"instanceof",
"AbstractAuthenticationToken",
")",
"{",
"//initialize the details with the consumer that is actually making the request on behalf of the user.",
"(",
"(",
"AbstractAuthenticationToken",
")",
"userAuthentication",
")",
".",
"setDetails",
"(",
"new",
"OAuthAuthenticationDetails",
"(",
"request",
",",
"authentication",
".",
"getConsumerDetails",
"(",
")",
")",
")",
";",
"}",
"return",
"userAuthentication",
";",
"}",
"return",
"authentication",
";",
"}"
] | Default implementation returns the user authentication associated with the auth token, if the token is provided. Otherwise, the consumer authentication
is returned.
@param request The request that was successfully authenticated.
@param authentication The consumer authentication (details about how the request was authenticated).
@param authToken The OAuth token associated with the authentication. This token MAY be null if no authenticated token was needed to successfully
authenticate the request (for example, in the case of 2-legged OAuth).
@return The authentication. | [
"Default",
"implementation",
"returns",
"the",
"user",
"authentication",
"associated",
"with",
"the",
"auth",
"token",
"if",
"the",
"token",
"is",
"provided",
".",
"Otherwise",
"the",
"consumer",
"authentication",
"is",
"returned",
"."
] | train | https://github.com/spring-projects/spring-security-oauth/blob/bbae0027eceb2c74a21ac26bbc86142dc732ffbe/spring-security-oauth/src/main/java/org/springframework/security/oauth/provider/DefaultAuthenticationHandler.java#L26-L37 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/ns/nslimitidentifier.java | nslimitidentifier.get | public static nslimitidentifier get(nitro_service service, String limitidentifier) throws Exception {
"""
Use this API to fetch nslimitidentifier resource of given name .
"""
nslimitidentifier obj = new nslimitidentifier();
obj.set_limitidentifier(limitidentifier);
nslimitidentifier response = (nslimitidentifier) obj.get_resource(service);
return response;
} | java | public static nslimitidentifier get(nitro_service service, String limitidentifier) throws Exception{
nslimitidentifier obj = new nslimitidentifier();
obj.set_limitidentifier(limitidentifier);
nslimitidentifier response = (nslimitidentifier) obj.get_resource(service);
return response;
} | [
"public",
"static",
"nslimitidentifier",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"limitidentifier",
")",
"throws",
"Exception",
"{",
"nslimitidentifier",
"obj",
"=",
"new",
"nslimitidentifier",
"(",
")",
";",
"obj",
".",
"set_limitidentifier",
"(",
"limitidentifier",
")",
";",
"nslimitidentifier",
"response",
"=",
"(",
"nslimitidentifier",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch nslimitidentifier resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"nslimitidentifier",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/ns/nslimitidentifier.java#L590-L595 |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/domain/builders/SubReportBuilder.java | SubReportBuilder.setDataSource | public SubReportBuilder setDataSource(String expression) {
"""
like addDataSource(int origin, String expression) but the origin will be from a Parameter
@param expression
@return
"""
return setDataSource(DJConstants.DATA_SOURCE_ORIGIN_PARAMETER, DJConstants.DATA_SOURCE_TYPE_JRDATASOURCE, expression);
} | java | public SubReportBuilder setDataSource(String expression) {
return setDataSource(DJConstants.DATA_SOURCE_ORIGIN_PARAMETER, DJConstants.DATA_SOURCE_TYPE_JRDATASOURCE, expression);
} | [
"public",
"SubReportBuilder",
"setDataSource",
"(",
"String",
"expression",
")",
"{",
"return",
"setDataSource",
"(",
"DJConstants",
".",
"DATA_SOURCE_ORIGIN_PARAMETER",
",",
"DJConstants",
".",
"DATA_SOURCE_TYPE_JRDATASOURCE",
",",
"expression",
")",
";",
"}"
] | like addDataSource(int origin, String expression) but the origin will be from a Parameter
@param expression
@return | [
"like",
"addDataSource",
"(",
"int",
"origin",
"String",
"expression",
")",
"but",
"the",
"origin",
"will",
"be",
"from",
"a",
"Parameter"
] | train | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/builders/SubReportBuilder.java#L129-L131 |
FasterXML/woodstox | src/main/java/com/ctc/wstx/dtd/FullDTDReader.java | FullDTDReader.readDTDQName | private PrefixedName readDTDQName(char firstChar)
throws XMLStreamException {
"""
Method that will read an element or attribute name from DTD; depending
on namespace mode, it can have prefix as well.
<p>
Note: returned {@link PrefixedName} instances are canonicalized so that
all instances read during parsing of a single DTD subset so that
identity comparison can be used instead of calling <code>equals()</code>
method (but only within a single subset!). This also reduces memory
usage to some extent.
"""
String prefix, localName;
if (!mCfgNsEnabled) {
prefix = null;
localName = parseFullName(firstChar);
} else {
localName = parseLocalName(firstChar);
/* Hmmh. This is tricky; should only read from the current
* scope, but it is ok to hit end-of-block if it was a PE
* expansion...
*/
char c = dtdNextIfAvailable();
if (c == CHAR_NULL) { // end-of-block
// ok, that's it...
prefix = null;
} else {
if (c == ':') { // Ok, got namespace and local name
prefix = localName;
c = dtdNextFromCurr();
localName = parseLocalName(c);
} else {
prefix = null;
--mInputPtr;
}
}
}
return findSharedName(prefix, localName);
} | java | private PrefixedName readDTDQName(char firstChar)
throws XMLStreamException
{
String prefix, localName;
if (!mCfgNsEnabled) {
prefix = null;
localName = parseFullName(firstChar);
} else {
localName = parseLocalName(firstChar);
/* Hmmh. This is tricky; should only read from the current
* scope, but it is ok to hit end-of-block if it was a PE
* expansion...
*/
char c = dtdNextIfAvailable();
if (c == CHAR_NULL) { // end-of-block
// ok, that's it...
prefix = null;
} else {
if (c == ':') { // Ok, got namespace and local name
prefix = localName;
c = dtdNextFromCurr();
localName = parseLocalName(c);
} else {
prefix = null;
--mInputPtr;
}
}
}
return findSharedName(prefix, localName);
} | [
"private",
"PrefixedName",
"readDTDQName",
"(",
"char",
"firstChar",
")",
"throws",
"XMLStreamException",
"{",
"String",
"prefix",
",",
"localName",
";",
"if",
"(",
"!",
"mCfgNsEnabled",
")",
"{",
"prefix",
"=",
"null",
";",
"localName",
"=",
"parseFullName",
"(",
"firstChar",
")",
";",
"}",
"else",
"{",
"localName",
"=",
"parseLocalName",
"(",
"firstChar",
")",
";",
"/* Hmmh. This is tricky; should only read from the current\n * scope, but it is ok to hit end-of-block if it was a PE\n * expansion...\n */",
"char",
"c",
"=",
"dtdNextIfAvailable",
"(",
")",
";",
"if",
"(",
"c",
"==",
"CHAR_NULL",
")",
"{",
"// end-of-block",
"// ok, that's it...",
"prefix",
"=",
"null",
";",
"}",
"else",
"{",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"// Ok, got namespace and local name",
"prefix",
"=",
"localName",
";",
"c",
"=",
"dtdNextFromCurr",
"(",
")",
";",
"localName",
"=",
"parseLocalName",
"(",
"c",
")",
";",
"}",
"else",
"{",
"prefix",
"=",
"null",
";",
"--",
"mInputPtr",
";",
"}",
"}",
"}",
"return",
"findSharedName",
"(",
"prefix",
",",
"localName",
")",
";",
"}"
] | Method that will read an element or attribute name from DTD; depending
on namespace mode, it can have prefix as well.
<p>
Note: returned {@link PrefixedName} instances are canonicalized so that
all instances read during parsing of a single DTD subset so that
identity comparison can be used instead of calling <code>equals()</code>
method (but only within a single subset!). This also reduces memory
usage to some extent. | [
"Method",
"that",
"will",
"read",
"an",
"element",
"or",
"attribute",
"name",
"from",
"DTD",
";",
"depending",
"on",
"namespace",
"mode",
"it",
"can",
"have",
"prefix",
"as",
"well",
".",
"<p",
">",
"Note",
":",
"returned",
"{"
] | train | https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/dtd/FullDTDReader.java#L1340-L1371 |
mozilla/rhino | src/org/mozilla/javascript/ScriptableObject.java | ScriptableObject.has | @Override
public boolean has(String name, Scriptable start) {
"""
Returns true if the named property is defined.
@param name the name of the property
@param start the object in which the lookup began
@return true if and only if the property was found in the object
"""
return null != slotMap.query(name, 0);
} | java | @Override
public boolean has(String name, Scriptable start)
{
return null != slotMap.query(name, 0);
} | [
"@",
"Override",
"public",
"boolean",
"has",
"(",
"String",
"name",
",",
"Scriptable",
"start",
")",
"{",
"return",
"null",
"!=",
"slotMap",
".",
"query",
"(",
"name",
",",
"0",
")",
";",
"}"
] | Returns true if the named property is defined.
@param name the name of the property
@param start the object in which the lookup began
@return true if and only if the property was found in the object | [
"Returns",
"true",
"if",
"the",
"named",
"property",
"is",
"defined",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L415-L419 |
apache/incubator-atlas | repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java | AtlasTypeDefGraphStoreV1.hasIncomingEdgesWithLabel | boolean hasIncomingEdgesWithLabel(AtlasVertex vertex, String label) throws AtlasBaseException {
"""
Look to see if there are any IN edges with the supplied label
@param vertex
@param label
@return
@throws AtlasBaseException
"""
boolean foundEdges = false;
Iterator<AtlasEdge> inEdges = vertex.getEdges(AtlasEdgeDirection.IN).iterator();
while (inEdges.hasNext()) {
AtlasEdge edge = inEdges.next();
if (label.equals(edge.getLabel())) {
foundEdges = true;
break;
}
}
return foundEdges;
} | java | boolean hasIncomingEdgesWithLabel(AtlasVertex vertex, String label) throws AtlasBaseException {
boolean foundEdges = false;
Iterator<AtlasEdge> inEdges = vertex.getEdges(AtlasEdgeDirection.IN).iterator();
while (inEdges.hasNext()) {
AtlasEdge edge = inEdges.next();
if (label.equals(edge.getLabel())) {
foundEdges = true;
break;
}
}
return foundEdges;
} | [
"boolean",
"hasIncomingEdgesWithLabel",
"(",
"AtlasVertex",
"vertex",
",",
"String",
"label",
")",
"throws",
"AtlasBaseException",
"{",
"boolean",
"foundEdges",
"=",
"false",
";",
"Iterator",
"<",
"AtlasEdge",
">",
"inEdges",
"=",
"vertex",
".",
"getEdges",
"(",
"AtlasEdgeDirection",
".",
"IN",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"inEdges",
".",
"hasNext",
"(",
")",
")",
"{",
"AtlasEdge",
"edge",
"=",
"inEdges",
".",
"next",
"(",
")",
";",
"if",
"(",
"label",
".",
"equals",
"(",
"edge",
".",
"getLabel",
"(",
")",
")",
")",
"{",
"foundEdges",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"foundEdges",
";",
"}"
] | Look to see if there are any IN edges with the supplied label
@param vertex
@param label
@return
@throws AtlasBaseException | [
"Look",
"to",
"see",
"if",
"there",
"are",
"any",
"IN",
"edges",
"with",
"the",
"supplied",
"label"
] | train | https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java#L252-L265 |
apache/flink | flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java | ExecutionEnvironment.registerTypeWithKryoSerializer | public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass) {
"""
Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer.
@param type The class of the types serialized with the given serializer.
@param serializerClass The class of the serializer to use.
"""
config.registerTypeWithKryoSerializer(type, serializerClass);
} | java | public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass) {
config.registerTypeWithKryoSerializer(type, serializerClass);
} | [
"public",
"void",
"registerTypeWithKryoSerializer",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Class",
"<",
"?",
"extends",
"Serializer",
"<",
"?",
">",
">",
"serializerClass",
")",
"{",
"config",
".",
"registerTypeWithKryoSerializer",
"(",
"type",
",",
"serializerClass",
")",
";",
"}"
] | Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer.
@param type The class of the types serialized with the given serializer.
@param serializerClass The class of the serializer to use. | [
"Registers",
"the",
"given",
"Serializer",
"via",
"its",
"class",
"as",
"a",
"serializer",
"for",
"the",
"given",
"type",
"at",
"the",
"KryoSerializer",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java#L354-L356 |
lightblueseas/vintage-time | src/main/java/de/alpharogroup/date/CalculateDateExtensions.java | CalculateDateExtensions.addMonths | public static Date addMonths(final Date date, final int addMonths) {
"""
Adds months to the given Date object and returns it. Note: you can add negative values too
for get date in past.
@param date
The Date object to add the years.
@param addMonths
The months to add.
@return The resulted Date object.
"""
final Calendar dateOnCalendar = Calendar.getInstance();
dateOnCalendar.setTime(date);
dateOnCalendar.add(Calendar.MONTH, addMonths);
return dateOnCalendar.getTime();
} | java | public static Date addMonths(final Date date, final int addMonths)
{
final Calendar dateOnCalendar = Calendar.getInstance();
dateOnCalendar.setTime(date);
dateOnCalendar.add(Calendar.MONTH, addMonths);
return dateOnCalendar.getTime();
} | [
"public",
"static",
"Date",
"addMonths",
"(",
"final",
"Date",
"date",
",",
"final",
"int",
"addMonths",
")",
"{",
"final",
"Calendar",
"dateOnCalendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"dateOnCalendar",
".",
"setTime",
"(",
"date",
")",
";",
"dateOnCalendar",
".",
"add",
"(",
"Calendar",
".",
"MONTH",
",",
"addMonths",
")",
";",
"return",
"dateOnCalendar",
".",
"getTime",
"(",
")",
";",
"}"
] | Adds months to the given Date object and returns it. Note: you can add negative values too
for get date in past.
@param date
The Date object to add the years.
@param addMonths
The months to add.
@return The resulted Date object. | [
"Adds",
"months",
"to",
"the",
"given",
"Date",
"object",
"and",
"returns",
"it",
".",
"Note",
":",
"you",
"can",
"add",
"negative",
"values",
"too",
"for",
"get",
"date",
"in",
"past",
"."
] | train | https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/CalculateDateExtensions.java#L128-L134 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/RepositoryFileApi.java | RepositoryFileApi.getFileV3 | @Deprecated
protected RepositoryFile getFileV3(String filePath, Integer projectId, String ref) throws GitLabApiException {
"""
Get file from repository. Allows you to receive information about file in repository like name, size, content.
Note that file content is Base64 encoded.
<pre><code>GitLab Endpoint: GET /projects/:id/repository/files</code></pre>
@param filePath (required) - Full path to new file. Ex. lib/class.rb
@param projectId (required) - the project ID
@param ref (required) - The name of branch, tag or commit
@return a RepositoryFile instance with the file info
@throws GitLabApiException if any exception occurs
@deprecated Will be removed in version 5.0
"""
Form form = new Form();
addFormParam(form, "file_path", filePath, true);
addFormParam(form, "ref", ref, true);
Response response = get(Response.Status.OK, form.asMap(), "projects", projectId, "repository", "files");
return (response.readEntity(RepositoryFile.class));
} | java | @Deprecated
protected RepositoryFile getFileV3(String filePath, Integer projectId, String ref) throws GitLabApiException {
Form form = new Form();
addFormParam(form, "file_path", filePath, true);
addFormParam(form, "ref", ref, true);
Response response = get(Response.Status.OK, form.asMap(), "projects", projectId, "repository", "files");
return (response.readEntity(RepositoryFile.class));
} | [
"@",
"Deprecated",
"protected",
"RepositoryFile",
"getFileV3",
"(",
"String",
"filePath",
",",
"Integer",
"projectId",
",",
"String",
"ref",
")",
"throws",
"GitLabApiException",
"{",
"Form",
"form",
"=",
"new",
"Form",
"(",
")",
";",
"addFormParam",
"(",
"form",
",",
"\"file_path\"",
",",
"filePath",
",",
"true",
")",
";",
"addFormParam",
"(",
"form",
",",
"\"ref\"",
",",
"ref",
",",
"true",
")",
";",
"Response",
"response",
"=",
"get",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"form",
".",
"asMap",
"(",
")",
",",
"\"projects\"",
",",
"projectId",
",",
"\"repository\"",
",",
"\"files\"",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"RepositoryFile",
".",
"class",
")",
")",
";",
"}"
] | Get file from repository. Allows you to receive information about file in repository like name, size, content.
Note that file content is Base64 encoded.
<pre><code>GitLab Endpoint: GET /projects/:id/repository/files</code></pre>
@param filePath (required) - Full path to new file. Ex. lib/class.rb
@param projectId (required) - the project ID
@param ref (required) - The name of branch, tag or commit
@return a RepositoryFile instance with the file info
@throws GitLabApiException if any exception occurs
@deprecated Will be removed in version 5.0 | [
"Get",
"file",
"from",
"repository",
".",
"Allows",
"you",
"to",
"receive",
"information",
"about",
"file",
"in",
"repository",
"like",
"name",
"size",
"content",
".",
"Note",
"that",
"file",
"content",
"is",
"Base64",
"encoded",
"."
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/RepositoryFileApi.java#L179-L186 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/input/category/CmsCategoryTree.java | CmsCategoryTree.buildTreeItem | private CmsTreeItem buildTreeItem(CmsCategoryTreeEntry category, Collection<String> selectedCategories) {
"""
Builds a tree item for the given category.<p>
@param category the category
@param selectedCategories the selected categories
@return the tree item widget
"""
// generate the widget that should be shown in the list
CmsDataValue dataValue = new CmsDataValue(
600,
3,
CmsCategoryBean.SMALL_ICON_CLASSES,
true,
category.getTitle(),
"rtl:" + category.getPath(),
"hide:" + category.getSitePath());
// create the check box for this item
CmsCheckBox checkBox = new CmsCheckBox();
// if it has to be selected, select it
boolean isPartofPath = false;
Iterator<String> it = selectedCategories.iterator();
while (it.hasNext()) {
String path = it.next();
if (path.startsWith(category.getPath()) || path.contains("/" + category.getPath())) {
isPartofPath = true;
}
}
if (isPartofPath) {
checkBox.setChecked(true);
}
if (!isEnabled()) {
checkBox.disable(m_disabledReason);
}
if (category.getPath().isEmpty()) {
checkBox.setVisible(false);
}
// bild the CmsTreeItem out of the widget and the check box
CmsTreeItem treeItem = new CmsTreeItem(true, checkBox, dataValue);
// abb the handler to the check box
dataValue.addClickHandler(new DataValueClickHander(treeItem));
checkBox.addValueChangeHandler(new CheckBoxValueChangeHandler(treeItem));
// set the right style for the small view
treeItem.setSmallView(true);
treeItem.setId(category.getPath());
// add it to the list of all categories
m_categories.put(treeItem.getId(), treeItem);
return treeItem;
} | java | private CmsTreeItem buildTreeItem(CmsCategoryTreeEntry category, Collection<String> selectedCategories) {
// generate the widget that should be shown in the list
CmsDataValue dataValue = new CmsDataValue(
600,
3,
CmsCategoryBean.SMALL_ICON_CLASSES,
true,
category.getTitle(),
"rtl:" + category.getPath(),
"hide:" + category.getSitePath());
// create the check box for this item
CmsCheckBox checkBox = new CmsCheckBox();
// if it has to be selected, select it
boolean isPartofPath = false;
Iterator<String> it = selectedCategories.iterator();
while (it.hasNext()) {
String path = it.next();
if (path.startsWith(category.getPath()) || path.contains("/" + category.getPath())) {
isPartofPath = true;
}
}
if (isPartofPath) {
checkBox.setChecked(true);
}
if (!isEnabled()) {
checkBox.disable(m_disabledReason);
}
if (category.getPath().isEmpty()) {
checkBox.setVisible(false);
}
// bild the CmsTreeItem out of the widget and the check box
CmsTreeItem treeItem = new CmsTreeItem(true, checkBox, dataValue);
// abb the handler to the check box
dataValue.addClickHandler(new DataValueClickHander(treeItem));
checkBox.addValueChangeHandler(new CheckBoxValueChangeHandler(treeItem));
// set the right style for the small view
treeItem.setSmallView(true);
treeItem.setId(category.getPath());
// add it to the list of all categories
m_categories.put(treeItem.getId(), treeItem);
return treeItem;
} | [
"private",
"CmsTreeItem",
"buildTreeItem",
"(",
"CmsCategoryTreeEntry",
"category",
",",
"Collection",
"<",
"String",
">",
"selectedCategories",
")",
"{",
"// generate the widget that should be shown in the list\r",
"CmsDataValue",
"dataValue",
"=",
"new",
"CmsDataValue",
"(",
"600",
",",
"3",
",",
"CmsCategoryBean",
".",
"SMALL_ICON_CLASSES",
",",
"true",
",",
"category",
".",
"getTitle",
"(",
")",
",",
"\"rtl:\"",
"+",
"category",
".",
"getPath",
"(",
")",
",",
"\"hide:\"",
"+",
"category",
".",
"getSitePath",
"(",
")",
")",
";",
"// create the check box for this item\r",
"CmsCheckBox",
"checkBox",
"=",
"new",
"CmsCheckBox",
"(",
")",
";",
"// if it has to be selected, select it\r",
"boolean",
"isPartofPath",
"=",
"false",
";",
"Iterator",
"<",
"String",
">",
"it",
"=",
"selectedCategories",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"path",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"path",
".",
"startsWith",
"(",
"category",
".",
"getPath",
"(",
")",
")",
"||",
"path",
".",
"contains",
"(",
"\"/\"",
"+",
"category",
".",
"getPath",
"(",
")",
")",
")",
"{",
"isPartofPath",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"isPartofPath",
")",
"{",
"checkBox",
".",
"setChecked",
"(",
"true",
")",
";",
"}",
"if",
"(",
"!",
"isEnabled",
"(",
")",
")",
"{",
"checkBox",
".",
"disable",
"(",
"m_disabledReason",
")",
";",
"}",
"if",
"(",
"category",
".",
"getPath",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"checkBox",
".",
"setVisible",
"(",
"false",
")",
";",
"}",
"// bild the CmsTreeItem out of the widget and the check box\r",
"CmsTreeItem",
"treeItem",
"=",
"new",
"CmsTreeItem",
"(",
"true",
",",
"checkBox",
",",
"dataValue",
")",
";",
"// abb the handler to the check box\r",
"dataValue",
".",
"addClickHandler",
"(",
"new",
"DataValueClickHander",
"(",
"treeItem",
")",
")",
";",
"checkBox",
".",
"addValueChangeHandler",
"(",
"new",
"CheckBoxValueChangeHandler",
"(",
"treeItem",
")",
")",
";",
"// set the right style for the small view\r",
"treeItem",
".",
"setSmallView",
"(",
"true",
")",
";",
"treeItem",
".",
"setId",
"(",
"category",
".",
"getPath",
"(",
")",
")",
";",
"// add it to the list of all categories\r",
"m_categories",
".",
"put",
"(",
"treeItem",
".",
"getId",
"(",
")",
",",
"treeItem",
")",
";",
"return",
"treeItem",
";",
"}"
] | Builds a tree item for the given category.<p>
@param category the category
@param selectedCategories the selected categories
@return the tree item widget | [
"Builds",
"a",
"tree",
"item",
"for",
"the",
"given",
"category",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/input/category/CmsCategoryTree.java#L921-L966 |
GeoLatte/geolatte-common | src/main/java/org/geolatte/common/expressions/Expressions.java | Expressions.isNotEqual | public static IsNotEqual isNotEqual(ComparableExpression<Number> left, Object constant) {
"""
Creates an IsNotEqual expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a Number).
@throws IllegalArgumentException If the constant is not a Number
@return A new is less than binary expression.
"""
if (!(constant instanceof Number))
throw new IllegalArgumentException("constant is not a Number");
return new IsNotEqual(left, constant((Number)constant));
} | java | public static IsNotEqual isNotEqual(ComparableExpression<Number> left, Object constant) {
if (!(constant instanceof Number))
throw new IllegalArgumentException("constant is not a Number");
return new IsNotEqual(left, constant((Number)constant));
} | [
"public",
"static",
"IsNotEqual",
"isNotEqual",
"(",
"ComparableExpression",
"<",
"Number",
">",
"left",
",",
"Object",
"constant",
")",
"{",
"if",
"(",
"!",
"(",
"constant",
"instanceof",
"Number",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"constant is not a Number\"",
")",
";",
"return",
"new",
"IsNotEqual",
"(",
"left",
",",
"constant",
"(",
"(",
"Number",
")",
"constant",
")",
")",
";",
"}"
] | Creates an IsNotEqual expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a Number).
@throws IllegalArgumentException If the constant is not a Number
@return A new is less than binary expression. | [
"Creates",
"an",
"IsNotEqual",
"expression",
"from",
"the",
"given",
"expression",
"and",
"constant",
"."
] | train | https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L472-L478 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/Validator.java | Validator.validateLetter | public static <T extends CharSequence> T validateLetter(T value, String errorMsg) throws ValidateException {
"""
验证是否全部为字母组成,包括大写和小写字母和汉字
@param <T> 字符串类型
@param value 表单值
@param errorMsg 验证错误的信息
@return 验证后的值
@throws ValidateException 验证异常
@since 3.3.0
"""
if (false == isLetter(value)) {
throw new ValidateException(errorMsg);
}
return value;
} | java | public static <T extends CharSequence> T validateLetter(T value, String errorMsg) throws ValidateException {
if (false == isLetter(value)) {
throw new ValidateException(errorMsg);
}
return value;
} | [
"public",
"static",
"<",
"T",
"extends",
"CharSequence",
">",
"T",
"validateLetter",
"(",
"T",
"value",
",",
"String",
"errorMsg",
")",
"throws",
"ValidateException",
"{",
"if",
"(",
"false",
"==",
"isLetter",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"ValidateException",
"(",
"errorMsg",
")",
";",
"}",
"return",
"value",
";",
"}"
] | 验证是否全部为字母组成,包括大写和小写字母和汉字
@param <T> 字符串类型
@param value 表单值
@param errorMsg 验证错误的信息
@return 验证后的值
@throws ValidateException 验证异常
@since 3.3.0 | [
"验证是否全部为字母组成,包括大写和小写字母和汉字"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Validator.java#L453-L458 |
JRebirth/JRebirth | org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirth.java | JRebirth.runIntoJTP | public static void runIntoJTP(final String runnableName, final PriorityLevel runnablePriority, final Runnable runnable) {
"""
Run into the JRebirth Thread Pool [JTP].
Be careful this method can be called through any thread.
@param runnableName the name of the runnable for logging purpose
@param runnablePriority the priority to try to apply to the runnable
@param runnable the task to run
"""
runIntoJTP(new JrbReferenceRunnable(runnableName, runnablePriority, runnable));
} | java | public static void runIntoJTP(final String runnableName, final PriorityLevel runnablePriority, final Runnable runnable) {
runIntoJTP(new JrbReferenceRunnable(runnableName, runnablePriority, runnable));
} | [
"public",
"static",
"void",
"runIntoJTP",
"(",
"final",
"String",
"runnableName",
",",
"final",
"PriorityLevel",
"runnablePriority",
",",
"final",
"Runnable",
"runnable",
")",
"{",
"runIntoJTP",
"(",
"new",
"JrbReferenceRunnable",
"(",
"runnableName",
",",
"runnablePriority",
",",
"runnable",
")",
")",
";",
"}"
] | Run into the JRebirth Thread Pool [JTP].
Be careful this method can be called through any thread.
@param runnableName the name of the runnable for logging purpose
@param runnablePriority the priority to try to apply to the runnable
@param runnable the task to run | [
"Run",
"into",
"the",
"JRebirth",
"Thread",
"Pool",
"[",
"JTP",
"]",
"."
] | train | https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirth.java#L341-L343 |
apereo/cas | core/cas-server-core-web-api/src/main/java/org/apereo/cas/services/web/view/AbstractCasView.java | AbstractCasView.getServiceFrom | protected Service getServiceFrom(final Map<String, Object> model) {
"""
Gets validated service from the model.
@param model the model
@return the validated service from
"""
return (Service) model.get(CasViewConstants.MODEL_ATTRIBUTE_NAME_SERVICE);
} | java | protected Service getServiceFrom(final Map<String, Object> model) {
return (Service) model.get(CasViewConstants.MODEL_ATTRIBUTE_NAME_SERVICE);
} | [
"protected",
"Service",
"getServiceFrom",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"model",
")",
"{",
"return",
"(",
"Service",
")",
"model",
".",
"get",
"(",
"CasViewConstants",
".",
"MODEL_ATTRIBUTE_NAME_SERVICE",
")",
";",
"}"
] | Gets validated service from the model.
@param model the model
@return the validated service from | [
"Gets",
"validated",
"service",
"from",
"the",
"model",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-web-api/src/main/java/org/apereo/cas/services/web/view/AbstractCasView.java#L164-L166 |
pdef/pdef-java | pdef/src/main/java/io/pdef/descriptors/Descriptors.java | Descriptors.findInterfaceDescriptor | @Nullable
public static <T> InterfaceDescriptor<T> findInterfaceDescriptor(final Class<T> cls) {
"""
Returns an interface descriptor or throws an IllegalArgumentException.
"""
if (!cls.isInterface()) {
throw new IllegalArgumentException("Interface required, got " + cls);
}
Field field;
try {
field = cls.getField("DESCRIPTOR");
} catch (NoSuchFieldException e) {
throw new IllegalArgumentException("No DESCRIPTOR field in " + cls);
}
if (!InterfaceDescriptor.class.isAssignableFrom(field.getType())) {
throw new IllegalArgumentException("Not an InterfaceDescriptor field, " + field);
}
try {
// Get the static TYPE field.
@SuppressWarnings("unchecked")
InterfaceDescriptor<T> descriptor = (InterfaceDescriptor<T>) field.get(null);
return descriptor;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | java | @Nullable
public static <T> InterfaceDescriptor<T> findInterfaceDescriptor(final Class<T> cls) {
if (!cls.isInterface()) {
throw new IllegalArgumentException("Interface required, got " + cls);
}
Field field;
try {
field = cls.getField("DESCRIPTOR");
} catch (NoSuchFieldException e) {
throw new IllegalArgumentException("No DESCRIPTOR field in " + cls);
}
if (!InterfaceDescriptor.class.isAssignableFrom(field.getType())) {
throw new IllegalArgumentException("Not an InterfaceDescriptor field, " + field);
}
try {
// Get the static TYPE field.
@SuppressWarnings("unchecked")
InterfaceDescriptor<T> descriptor = (InterfaceDescriptor<T>) field.get(null);
return descriptor;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | [
"@",
"Nullable",
"public",
"static",
"<",
"T",
">",
"InterfaceDescriptor",
"<",
"T",
">",
"findInterfaceDescriptor",
"(",
"final",
"Class",
"<",
"T",
">",
"cls",
")",
"{",
"if",
"(",
"!",
"cls",
".",
"isInterface",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Interface required, got \"",
"+",
"cls",
")",
";",
"}",
"Field",
"field",
";",
"try",
"{",
"field",
"=",
"cls",
".",
"getField",
"(",
"\"DESCRIPTOR\"",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No DESCRIPTOR field in \"",
"+",
"cls",
")",
";",
"}",
"if",
"(",
"!",
"InterfaceDescriptor",
".",
"class",
".",
"isAssignableFrom",
"(",
"field",
".",
"getType",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Not an InterfaceDescriptor field, \"",
"+",
"field",
")",
";",
"}",
"try",
"{",
"// Get the static TYPE field.",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"InterfaceDescriptor",
"<",
"T",
">",
"descriptor",
"=",
"(",
"InterfaceDescriptor",
"<",
"T",
">",
")",
"field",
".",
"get",
"(",
"null",
")",
";",
"return",
"descriptor",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Returns an interface descriptor or throws an IllegalArgumentException. | [
"Returns",
"an",
"interface",
"descriptor",
"or",
"throws",
"an",
"IllegalArgumentException",
"."
] | train | https://github.com/pdef/pdef-java/blob/7776c44d1aab0f3dbf7267b0c32b8f9282fe6167/pdef/src/main/java/io/pdef/descriptors/Descriptors.java#L58-L83 |
jenkinsci/jenkins | core/src/main/java/hudson/model/View.java | View.createViewFromXML | public static View createViewFromXML(String name, InputStream xml) throws IOException {
"""
Instantiate View subtype from XML stream.
@param name Alternative name to use or {@code null} to keep the one in xml.
"""
try (InputStream in = new BufferedInputStream(xml)) {
View v = (View) Jenkins.XSTREAM.fromXML(in);
if (name != null) v.name = name;
Jenkins.checkGoodName(v.name);
return v;
} catch(StreamException|ConversionException|Error e) {// mostly reflection errors
throw new IOException("Unable to read",e);
}
} | java | public static View createViewFromXML(String name, InputStream xml) throws IOException {
try (InputStream in = new BufferedInputStream(xml)) {
View v = (View) Jenkins.XSTREAM.fromXML(in);
if (name != null) v.name = name;
Jenkins.checkGoodName(v.name);
return v;
} catch(StreamException|ConversionException|Error e) {// mostly reflection errors
throw new IOException("Unable to read",e);
}
} | [
"public",
"static",
"View",
"createViewFromXML",
"(",
"String",
"name",
",",
"InputStream",
"xml",
")",
"throws",
"IOException",
"{",
"try",
"(",
"InputStream",
"in",
"=",
"new",
"BufferedInputStream",
"(",
"xml",
")",
")",
"{",
"View",
"v",
"=",
"(",
"View",
")",
"Jenkins",
".",
"XSTREAM",
".",
"fromXML",
"(",
"in",
")",
";",
"if",
"(",
"name",
"!=",
"null",
")",
"v",
".",
"name",
"=",
"name",
";",
"Jenkins",
".",
"checkGoodName",
"(",
"v",
".",
"name",
")",
";",
"return",
"v",
";",
"}",
"catch",
"(",
"StreamException",
"|",
"ConversionException",
"|",
"Error",
"e",
")",
"{",
"// mostly reflection errors",
"throw",
"new",
"IOException",
"(",
"\"Unable to read\"",
",",
"e",
")",
";",
"}",
"}"
] | Instantiate View subtype from XML stream.
@param name Alternative name to use or {@code null} to keep the one in xml. | [
"Instantiate",
"View",
"subtype",
"from",
"XML",
"stream",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/model/View.java#L1371-L1381 |
lucee/Lucee | core/src/main/java/lucee/runtime/converter/JSONConverter.java | JSONConverter._serializeArray | private void _serializeArray(PageContext pc, Set test, Array array, StringBuilder sb, boolean serializeQueryByColumns, Set<Object> done) throws ConverterException {
"""
serialize a Array
@param array Array to serialize
@param sb
@param serializeQueryByColumns
@param done
@throws ConverterException
"""
_serializeList(pc, test, array.toList(), sb, serializeQueryByColumns, done);
} | java | private void _serializeArray(PageContext pc, Set test, Array array, StringBuilder sb, boolean serializeQueryByColumns, Set<Object> done) throws ConverterException {
_serializeList(pc, test, array.toList(), sb, serializeQueryByColumns, done);
} | [
"private",
"void",
"_serializeArray",
"(",
"PageContext",
"pc",
",",
"Set",
"test",
",",
"Array",
"array",
",",
"StringBuilder",
"sb",
",",
"boolean",
"serializeQueryByColumns",
",",
"Set",
"<",
"Object",
">",
"done",
")",
"throws",
"ConverterException",
"{",
"_serializeList",
"(",
"pc",
",",
"test",
",",
"array",
".",
"toList",
"(",
")",
",",
"sb",
",",
"serializeQueryByColumns",
",",
"done",
")",
";",
"}"
] | serialize a Array
@param array Array to serialize
@param sb
@param serializeQueryByColumns
@param done
@throws ConverterException | [
"serialize",
"a",
"Array"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/converter/JSONConverter.java#L201-L203 |
alipay/sofa-rpc | extension-impl/fault-tolerance/src/main/java/com/alipay/sofa/rpc/client/aft/ProviderInfoWeightManager.java | ProviderInfoWeightManager.recoverOriginWeight | public static void recoverOriginWeight(ProviderInfo providerInfo, int originWeight) {
"""
Recover weight of provider info, and set default status
@param providerInfo ProviderInfo
@param originWeight origin weight
"""
providerInfo.setStatus(ProviderStatus.AVAILABLE);
providerInfo.setWeight(originWeight);
} | java | public static void recoverOriginWeight(ProviderInfo providerInfo, int originWeight) {
providerInfo.setStatus(ProviderStatus.AVAILABLE);
providerInfo.setWeight(originWeight);
} | [
"public",
"static",
"void",
"recoverOriginWeight",
"(",
"ProviderInfo",
"providerInfo",
",",
"int",
"originWeight",
")",
"{",
"providerInfo",
".",
"setStatus",
"(",
"ProviderStatus",
".",
"AVAILABLE",
")",
";",
"providerInfo",
".",
"setWeight",
"(",
"originWeight",
")",
";",
"}"
] | Recover weight of provider info, and set default status
@param providerInfo ProviderInfo
@param originWeight origin weight | [
"Recover",
"weight",
"of",
"provider",
"info",
"and",
"set",
"default",
"status"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/extension-impl/fault-tolerance/src/main/java/com/alipay/sofa/rpc/client/aft/ProviderInfoWeightManager.java#L61-L64 |
ldapchai/ldapchai | src/main/java/com/novell/ldapchai/provider/ChaiConfiguration.java | ChaiConfiguration.newConfiguration | public static ChaiConfiguration newConfiguration( final String ldapURL, final String bindDN, final String bindPassword ) {
"""
Construct a default {@code ChaiConfiguration}.
@param bindDN ldap bind DN, in ldap fully qualified syntax. Also used as the DN of the returned ChaiUser.
@param bindPassword password for the bind DN.
@param ldapURL ldap server and port in url format, example: <i>ldap://127.0.0.1:389</i>
@return a new configuration instance.
"""
return new ChaiConfigurationBuilder( ldapURL, bindDN, bindPassword ).build();
} | java | public static ChaiConfiguration newConfiguration( final String ldapURL, final String bindDN, final String bindPassword )
{
return new ChaiConfigurationBuilder( ldapURL, bindDN, bindPassword ).build();
} | [
"public",
"static",
"ChaiConfiguration",
"newConfiguration",
"(",
"final",
"String",
"ldapURL",
",",
"final",
"String",
"bindDN",
",",
"final",
"String",
"bindPassword",
")",
"{",
"return",
"new",
"ChaiConfigurationBuilder",
"(",
"ldapURL",
",",
"bindDN",
",",
"bindPassword",
")",
".",
"build",
"(",
")",
";",
"}"
] | Construct a default {@code ChaiConfiguration}.
@param bindDN ldap bind DN, in ldap fully qualified syntax. Also used as the DN of the returned ChaiUser.
@param bindPassword password for the bind DN.
@param ldapURL ldap server and port in url format, example: <i>ldap://127.0.0.1:389</i>
@return a new configuration instance. | [
"Construct",
"a",
"default",
"{",
"@code",
"ChaiConfiguration",
"}",
"."
] | train | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/provider/ChaiConfiguration.java#L81-L84 |
couchbase/couchbase-lite-java | src/main/java/com/couchbase/lite/AbstractQuery.java | AbstractQuery.addChangeListener | @NonNull
@Override
public ListenerToken addChangeListener(@NonNull QueryChangeListener listener) {
"""
Adds a query change listener. Changes will be posted on the main queue.
@param listener The listener to post changes.
@return An opaque listener token object for removing the listener.
"""
if (listener == null) { throw new IllegalArgumentException("listener cannot be null."); }
return addChangeListener(null, listener);
} | java | @NonNull
@Override
public ListenerToken addChangeListener(@NonNull QueryChangeListener listener) {
if (listener == null) { throw new IllegalArgumentException("listener cannot be null."); }
return addChangeListener(null, listener);
} | [
"@",
"NonNull",
"@",
"Override",
"public",
"ListenerToken",
"addChangeListener",
"(",
"@",
"NonNull",
"QueryChangeListener",
"listener",
")",
"{",
"if",
"(",
"listener",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"listener cannot be null.\"",
")",
";",
"}",
"return",
"addChangeListener",
"(",
"null",
",",
"listener",
")",
";",
"}"
] | Adds a query change listener. Changes will be posted on the main queue.
@param listener The listener to post changes.
@return An opaque listener token object for removing the listener. | [
"Adds",
"a",
"query",
"change",
"listener",
".",
"Changes",
"will",
"be",
"posted",
"on",
"the",
"main",
"queue",
"."
] | train | https://github.com/couchbase/couchbase-lite-java/blob/cb72c44186456e6191a9ad0a7feb310011d0b081/src/main/java/com/couchbase/lite/AbstractQuery.java#L169-L174 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.security/src/com/ibm/ws/ejbcontainer/security/internal/jacc/EJBJaccAuthorizationHelper.java | EJBJaccAuthorizationHelper.authorizeEJB | @Override
public void authorizeEJB(EJBRequestData request, Subject subject) throws EJBAccessDeniedException {
"""
Authorizes the subject to call the given EJB by using JACC, based on the given method info.
If the subject is not authorized, an exception is thrown. The following checks are made:
<li>is the bean method excluded (denyAll)</li>
<li>are the required roles null or empty</li>
<li>is EVERYONE granted to any of the required roles</li>
<li>is the subject authorized to any of the required roles</li>
@param methodMetaData the info on the EJB method to call
@param subject the subject authorize
@throws EJBAccessDeniedException when the subject is not authorized to the EJB
"""
auditManager = new AuditManager();
Object req = auditManager.getHttpServletRequest();
Object webRequest = auditManager.getWebRequest();
String realm = auditManager.getRealm();
EJBMethodMetaData methodMetaData = request.getEJBMethodMetaData();
Object[] methodArguments = request.getMethodArguments();
String applicationName = methodMetaData.getEJBComponentMetaData().getJ2EEName().getApplication();
String moduleName = methodMetaData.getEJBComponentMetaData().getJ2EEName().getModule();
String methodName = methodMetaData.getMethodName();
String methodInterface = methodMetaData.getEJBMethodInterface().specName();
String methodSignature = methodMetaData.getMethodSignature();
String beanName = methodMetaData.getEJBComponentMetaData().getJ2EEName().getComponent();
List<Object> methodParameters = null;
populateAuditEJBHashMap(request);
Object bean = request.getBeanInstance();
EnterpriseBean ejb = null;
if (bean instanceof EnterpriseBean) {
ejb = (EnterpriseBean) bean;
}
if (methodArguments != null && methodArguments.length > 0) {
methodParameters = Arrays.asList(methodArguments);
}
boolean isAuthorized = jaccServiceRef.getService().isAuthorized(applicationName, moduleName, beanName, methodName, methodInterface, methodSignature, methodParameters, ejb,
subject);
String authzUserName = subject.getPrincipals(WSPrincipal.class).iterator().next().getName();
if (!isAuthorized) {
Tr.audit(tc, "EJB_JACC_AUTHZ_FAILED", authzUserName, methodName, applicationName);
AuditAuthenticationResult auditAuthResult = new AuditAuthenticationResult(AuditAuthResult.FAILURE, authzUserName, AuditEvent.CRED_TYPE_BASIC, null, AuditEvent.OUTCOME_FAILURE);
Audit.audit(Audit.EventID.SECURITY_AUTHZ_03, auditAuthResult, ejbAuditHashMap, req, webRequest, realm, subject, Integer.valueOf("403"));
throw new EJBAccessDeniedException(TraceNLS.getFormattedMessage(this.getClass(),
TraceConstants.MESSAGE_BUNDLE,
"EJB_JACC_AUTHZ_FAILED",
new Object[] { authzUserName, methodName, applicationName },
"CWWKS9406A: Authorization by the JACC provider failed. The user is not granted access to any of the required roles."));
} else {
AuditAuthenticationResult auditAuthResult = new AuditAuthenticationResult(AuditAuthResult.SUCCESS, authzUserName, AuditEvent.CRED_TYPE_BASIC, null, AuditEvent.OUTCOME_SUCCESS);
Audit.audit(Audit.EventID.SECURITY_AUTHZ_03, auditAuthResult, ejbAuditHashMap, req, webRequest, realm, subject, Integer.valueOf("200"));
}
} | java | @Override
public void authorizeEJB(EJBRequestData request, Subject subject) throws EJBAccessDeniedException {
auditManager = new AuditManager();
Object req = auditManager.getHttpServletRequest();
Object webRequest = auditManager.getWebRequest();
String realm = auditManager.getRealm();
EJBMethodMetaData methodMetaData = request.getEJBMethodMetaData();
Object[] methodArguments = request.getMethodArguments();
String applicationName = methodMetaData.getEJBComponentMetaData().getJ2EEName().getApplication();
String moduleName = methodMetaData.getEJBComponentMetaData().getJ2EEName().getModule();
String methodName = methodMetaData.getMethodName();
String methodInterface = methodMetaData.getEJBMethodInterface().specName();
String methodSignature = methodMetaData.getMethodSignature();
String beanName = methodMetaData.getEJBComponentMetaData().getJ2EEName().getComponent();
List<Object> methodParameters = null;
populateAuditEJBHashMap(request);
Object bean = request.getBeanInstance();
EnterpriseBean ejb = null;
if (bean instanceof EnterpriseBean) {
ejb = (EnterpriseBean) bean;
}
if (methodArguments != null && methodArguments.length > 0) {
methodParameters = Arrays.asList(methodArguments);
}
boolean isAuthorized = jaccServiceRef.getService().isAuthorized(applicationName, moduleName, beanName, methodName, methodInterface, methodSignature, methodParameters, ejb,
subject);
String authzUserName = subject.getPrincipals(WSPrincipal.class).iterator().next().getName();
if (!isAuthorized) {
Tr.audit(tc, "EJB_JACC_AUTHZ_FAILED", authzUserName, methodName, applicationName);
AuditAuthenticationResult auditAuthResult = new AuditAuthenticationResult(AuditAuthResult.FAILURE, authzUserName, AuditEvent.CRED_TYPE_BASIC, null, AuditEvent.OUTCOME_FAILURE);
Audit.audit(Audit.EventID.SECURITY_AUTHZ_03, auditAuthResult, ejbAuditHashMap, req, webRequest, realm, subject, Integer.valueOf("403"));
throw new EJBAccessDeniedException(TraceNLS.getFormattedMessage(this.getClass(),
TraceConstants.MESSAGE_BUNDLE,
"EJB_JACC_AUTHZ_FAILED",
new Object[] { authzUserName, methodName, applicationName },
"CWWKS9406A: Authorization by the JACC provider failed. The user is not granted access to any of the required roles."));
} else {
AuditAuthenticationResult auditAuthResult = new AuditAuthenticationResult(AuditAuthResult.SUCCESS, authzUserName, AuditEvent.CRED_TYPE_BASIC, null, AuditEvent.OUTCOME_SUCCESS);
Audit.audit(Audit.EventID.SECURITY_AUTHZ_03, auditAuthResult, ejbAuditHashMap, req, webRequest, realm, subject, Integer.valueOf("200"));
}
} | [
"@",
"Override",
"public",
"void",
"authorizeEJB",
"(",
"EJBRequestData",
"request",
",",
"Subject",
"subject",
")",
"throws",
"EJBAccessDeniedException",
"{",
"auditManager",
"=",
"new",
"AuditManager",
"(",
")",
";",
"Object",
"req",
"=",
"auditManager",
".",
"getHttpServletRequest",
"(",
")",
";",
"Object",
"webRequest",
"=",
"auditManager",
".",
"getWebRequest",
"(",
")",
";",
"String",
"realm",
"=",
"auditManager",
".",
"getRealm",
"(",
")",
";",
"EJBMethodMetaData",
"methodMetaData",
"=",
"request",
".",
"getEJBMethodMetaData",
"(",
")",
";",
"Object",
"[",
"]",
"methodArguments",
"=",
"request",
".",
"getMethodArguments",
"(",
")",
";",
"String",
"applicationName",
"=",
"methodMetaData",
".",
"getEJBComponentMetaData",
"(",
")",
".",
"getJ2EEName",
"(",
")",
".",
"getApplication",
"(",
")",
";",
"String",
"moduleName",
"=",
"methodMetaData",
".",
"getEJBComponentMetaData",
"(",
")",
".",
"getJ2EEName",
"(",
")",
".",
"getModule",
"(",
")",
";",
"String",
"methodName",
"=",
"methodMetaData",
".",
"getMethodName",
"(",
")",
";",
"String",
"methodInterface",
"=",
"methodMetaData",
".",
"getEJBMethodInterface",
"(",
")",
".",
"specName",
"(",
")",
";",
"String",
"methodSignature",
"=",
"methodMetaData",
".",
"getMethodSignature",
"(",
")",
";",
"String",
"beanName",
"=",
"methodMetaData",
".",
"getEJBComponentMetaData",
"(",
")",
".",
"getJ2EEName",
"(",
")",
".",
"getComponent",
"(",
")",
";",
"List",
"<",
"Object",
">",
"methodParameters",
"=",
"null",
";",
"populateAuditEJBHashMap",
"(",
"request",
")",
";",
"Object",
"bean",
"=",
"request",
".",
"getBeanInstance",
"(",
")",
";",
"EnterpriseBean",
"ejb",
"=",
"null",
";",
"if",
"(",
"bean",
"instanceof",
"EnterpriseBean",
")",
"{",
"ejb",
"=",
"(",
"EnterpriseBean",
")",
"bean",
";",
"}",
"if",
"(",
"methodArguments",
"!=",
"null",
"&&",
"methodArguments",
".",
"length",
">",
"0",
")",
"{",
"methodParameters",
"=",
"Arrays",
".",
"asList",
"(",
"methodArguments",
")",
";",
"}",
"boolean",
"isAuthorized",
"=",
"jaccServiceRef",
".",
"getService",
"(",
")",
".",
"isAuthorized",
"(",
"applicationName",
",",
"moduleName",
",",
"beanName",
",",
"methodName",
",",
"methodInterface",
",",
"methodSignature",
",",
"methodParameters",
",",
"ejb",
",",
"subject",
")",
";",
"String",
"authzUserName",
"=",
"subject",
".",
"getPrincipals",
"(",
"WSPrincipal",
".",
"class",
")",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"isAuthorized",
")",
"{",
"Tr",
".",
"audit",
"(",
"tc",
",",
"\"EJB_JACC_AUTHZ_FAILED\"",
",",
"authzUserName",
",",
"methodName",
",",
"applicationName",
")",
";",
"AuditAuthenticationResult",
"auditAuthResult",
"=",
"new",
"AuditAuthenticationResult",
"(",
"AuditAuthResult",
".",
"FAILURE",
",",
"authzUserName",
",",
"AuditEvent",
".",
"CRED_TYPE_BASIC",
",",
"null",
",",
"AuditEvent",
".",
"OUTCOME_FAILURE",
")",
";",
"Audit",
".",
"audit",
"(",
"Audit",
".",
"EventID",
".",
"SECURITY_AUTHZ_03",
",",
"auditAuthResult",
",",
"ejbAuditHashMap",
",",
"req",
",",
"webRequest",
",",
"realm",
",",
"subject",
",",
"Integer",
".",
"valueOf",
"(",
"\"403\"",
")",
")",
";",
"throw",
"new",
"EJBAccessDeniedException",
"(",
"TraceNLS",
".",
"getFormattedMessage",
"(",
"this",
".",
"getClass",
"(",
")",
",",
"TraceConstants",
".",
"MESSAGE_BUNDLE",
",",
"\"EJB_JACC_AUTHZ_FAILED\"",
",",
"new",
"Object",
"[",
"]",
"{",
"authzUserName",
",",
"methodName",
",",
"applicationName",
"}",
",",
"\"CWWKS9406A: Authorization by the JACC provider failed. The user is not granted access to any of the required roles.\"",
")",
")",
";",
"}",
"else",
"{",
"AuditAuthenticationResult",
"auditAuthResult",
"=",
"new",
"AuditAuthenticationResult",
"(",
"AuditAuthResult",
".",
"SUCCESS",
",",
"authzUserName",
",",
"AuditEvent",
".",
"CRED_TYPE_BASIC",
",",
"null",
",",
"AuditEvent",
".",
"OUTCOME_SUCCESS",
")",
";",
"Audit",
".",
"audit",
"(",
"Audit",
".",
"EventID",
".",
"SECURITY_AUTHZ_03",
",",
"auditAuthResult",
",",
"ejbAuditHashMap",
",",
"req",
",",
"webRequest",
",",
"realm",
",",
"subject",
",",
"Integer",
".",
"valueOf",
"(",
"\"200\"",
")",
")",
";",
"}",
"}"
] | Authorizes the subject to call the given EJB by using JACC, based on the given method info.
If the subject is not authorized, an exception is thrown. The following checks are made:
<li>is the bean method excluded (denyAll)</li>
<li>are the required roles null or empty</li>
<li>is EVERYONE granted to any of the required roles</li>
<li>is the subject authorized to any of the required roles</li>
@param methodMetaData the info on the EJB method to call
@param subject the subject authorize
@throws EJBAccessDeniedException when the subject is not authorized to the EJB | [
"Authorizes",
"the",
"subject",
"to",
"call",
"the",
"given",
"EJB",
"by",
"using",
"JACC",
"based",
"on",
"the",
"given",
"method",
"info",
".",
"If",
"the",
"subject",
"is",
"not",
"authorized",
"an",
"exception",
"is",
"thrown",
".",
"The",
"following",
"checks",
"are",
"made",
":",
"<li",
">",
"is",
"the",
"bean",
"method",
"excluded",
"(",
"denyAll",
")",
"<",
"/",
"li",
">",
"<li",
">",
"are",
"the",
"required",
"roles",
"null",
"or",
"empty<",
"/",
"li",
">",
"<li",
">",
"is",
"EVERYONE",
"granted",
"to",
"any",
"of",
"the",
"required",
"roles<",
"/",
"li",
">",
"<li",
">",
"is",
"the",
"subject",
"authorized",
"to",
"any",
"of",
"the",
"required",
"roles<",
"/",
"li",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.security/src/com/ibm/ws/ejbcontainer/security/internal/jacc/EJBJaccAuthorizationHelper.java#L91-L138 |
OpenLiberty/open-liberty | dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/Director.java | Director.uninstallFeaturesPrereqChecking | public void uninstallFeaturesPrereqChecking(Collection<String> featureNames, boolean allowUninstallAll, boolean force) throws InstallException {
"""
Creates array of productIds and calls method below
@param featureNames Collection of features names to uninstall
@param allowUninstallAll If false, will fail if no user features are installed
@param force If uninstallation should be forced
@throws InstallException
"""
getUninstallDirector().uninstallFeaturesPrereqChecking(featureNames, allowUninstallAll, force);
} | java | public void uninstallFeaturesPrereqChecking(Collection<String> featureNames, boolean allowUninstallAll, boolean force) throws InstallException {
getUninstallDirector().uninstallFeaturesPrereqChecking(featureNames, allowUninstallAll, force);
} | [
"public",
"void",
"uninstallFeaturesPrereqChecking",
"(",
"Collection",
"<",
"String",
">",
"featureNames",
",",
"boolean",
"allowUninstallAll",
",",
"boolean",
"force",
")",
"throws",
"InstallException",
"{",
"getUninstallDirector",
"(",
")",
".",
"uninstallFeaturesPrereqChecking",
"(",
"featureNames",
",",
"allowUninstallAll",
",",
"force",
")",
";",
"}"
] | Creates array of productIds and calls method below
@param featureNames Collection of features names to uninstall
@param allowUninstallAll If false, will fail if no user features are installed
@param force If uninstallation should be forced
@throws InstallException | [
"Creates",
"array",
"of",
"productIds",
"and",
"calls",
"method",
"below"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/Director.java#L1896-L1898 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.