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
|
---|---|---|---|---|---|---|---|---|---|---|
Appendium/objectlabkit | utils/src/main/java/net/objectlab/kit/util/ObjectUtil.java | ObjectUtil.equalsValue | public static boolean equalsValue(final Object o1, final Object o2) {
"""
Return true if o1 equals (according to {@link Object#equals(Object)}) o2.
Also returns true if o1 is null and o2 is null! Is safe on either o1 or o2 being null.
"""
if (o1 == null) {
return o2 == null;
}
return o1.equals(o2);
} | java | public static boolean equalsValue(final Object o1, final Object o2) {
if (o1 == null) {
return o2 == null;
}
return o1.equals(o2);
} | [
"public",
"static",
"boolean",
"equalsValue",
"(",
"final",
"Object",
"o1",
",",
"final",
"Object",
"o2",
")",
"{",
"if",
"(",
"o1",
"==",
"null",
")",
"{",
"return",
"o2",
"==",
"null",
";",
"}",
"return",
"o1",
".",
"equals",
"(",
"o2",
")",
";",
"}"
] | Return true if o1 equals (according to {@link Object#equals(Object)}) o2.
Also returns true if o1 is null and o2 is null! Is safe on either o1 or o2 being null. | [
"Return",
"true",
"if",
"o1",
"equals",
"(",
"according",
"to",
"{"
] | train | https://github.com/Appendium/objectlabkit/blob/cd649bce7a32e4e926520e62cb765f3b1d451594/utils/src/main/java/net/objectlab/kit/util/ObjectUtil.java#L69-L74 |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/ssh/JschUtil.java | JschUtil.openChannel | public static Channel openChannel(Session session, ChannelType channelType) {
"""
打开Channel连接
@param session Session会话
@param channelType 通道类型,可以是shell或sftp等,见{@link ChannelType}
@return {@link Channel}
@since 4.5.2
"""
final Channel channel = createChannel(session, channelType);
try {
channel.connect();
} catch (JSchException e) {
throw new JschRuntimeException(e);
}
return channel;
} | java | public static Channel openChannel(Session session, ChannelType channelType) {
final Channel channel = createChannel(session, channelType);
try {
channel.connect();
} catch (JSchException e) {
throw new JschRuntimeException(e);
}
return channel;
} | [
"public",
"static",
"Channel",
"openChannel",
"(",
"Session",
"session",
",",
"ChannelType",
"channelType",
")",
"{",
"final",
"Channel",
"channel",
"=",
"createChannel",
"(",
"session",
",",
"channelType",
")",
";",
"try",
"{",
"channel",
".",
"connect",
"(",
")",
";",
"}",
"catch",
"(",
"JSchException",
"e",
")",
"{",
"throw",
"new",
"JschRuntimeException",
"(",
"e",
")",
";",
"}",
"return",
"channel",
";",
"}"
] | 打开Channel连接
@param session Session会话
@param channelType 通道类型,可以是shell或sftp等,见{@link ChannelType}
@return {@link Channel}
@since 4.5.2 | [
"打开Channel连接"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/ssh/JschUtil.java#L218-L226 |
jglobus/JGlobus | ssl-proxies/src/main/java/org/globus/gsi/trustmanager/UnsupportedCriticalExtensionChecker.java | UnsupportedCriticalExtensionChecker.invoke | public void invoke(X509Certificate cert, GSIConstants.CertificateType certType) throws CertPathValidatorException {
"""
Method that checks if there are unsupported critical extension. Supported
ones are only BasicConstrains, KeyUsage, Proxy Certificate (old and new)
@param cert The certificate to validate.
@param certType The type of certificate to validate.
@throws CertPathValidatorException If any critical extension that is not supported is in the certificate.
Anything other than those listed above will trigger the exception.
"""
Set<String> criticalExtensionOids =
cert.getCriticalExtensionOIDs();
if (criticalExtensionOids == null) {
return;
}
for (String criticalExtensionOid : criticalExtensionOids) {
isUnsupported(certType, criticalExtensionOid);
}
} | java | public void invoke(X509Certificate cert, GSIConstants.CertificateType certType) throws CertPathValidatorException {
Set<String> criticalExtensionOids =
cert.getCriticalExtensionOIDs();
if (criticalExtensionOids == null) {
return;
}
for (String criticalExtensionOid : criticalExtensionOids) {
isUnsupported(certType, criticalExtensionOid);
}
} | [
"public",
"void",
"invoke",
"(",
"X509Certificate",
"cert",
",",
"GSIConstants",
".",
"CertificateType",
"certType",
")",
"throws",
"CertPathValidatorException",
"{",
"Set",
"<",
"String",
">",
"criticalExtensionOids",
"=",
"cert",
".",
"getCriticalExtensionOIDs",
"(",
")",
";",
"if",
"(",
"criticalExtensionOids",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"String",
"criticalExtensionOid",
":",
"criticalExtensionOids",
")",
"{",
"isUnsupported",
"(",
"certType",
",",
"criticalExtensionOid",
")",
";",
"}",
"}"
] | Method that checks if there are unsupported critical extension. Supported
ones are only BasicConstrains, KeyUsage, Proxy Certificate (old and new)
@param cert The certificate to validate.
@param certType The type of certificate to validate.
@throws CertPathValidatorException If any critical extension that is not supported is in the certificate.
Anything other than those listed above will trigger the exception. | [
"Method",
"that",
"checks",
"if",
"there",
"are",
"unsupported",
"critical",
"extension",
".",
"Supported",
"ones",
"are",
"only",
"BasicConstrains",
"KeyUsage",
"Proxy",
"Certificate",
"(",
"old",
"and",
"new",
")"
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/ssl-proxies/src/main/java/org/globus/gsi/trustmanager/UnsupportedCriticalExtensionChecker.java#L44-L53 |
twitter/cloudhopper-commons | ch-commons-util/src/main/java/com/cloudhopper/commons/util/ByteBuffer.java | ByteBuffer.toArray | public void toArray(int offset, int length, byte[] targetBuffer, int targetOffset) {
"""
Will copy data from this ByteBuffer's buffer into the targetBuffer. This
method requires the targetBuffer to already be allocated with enough capacity
to hold this ByteBuffer's data.
@param offset The offset within the ByteBuffer to start copy from
@param length The length from the offset to copy
@param targetBuffer The target byte array we'll copy data into. Must already
be allocated with enough capacity.
@param targetOffset The offset within the target byte array to start from
@throws IllegalArgumentException If the offset and length are invalid
for this ByteBuffer, if the targetOffset and targetLength are invalid
for the targetBuffer, or if if the targetBuffer's capacity is not
large enough to hold the copied data.
"""
// validate the offset, length are ok
ByteBuffer.checkOffsetLength(size(), offset, length);
// validate the offset, length are ok
ByteBuffer.checkOffsetLength(targetBuffer.length, targetOffset, length);
// will we have a large enough byte[] allocated?
if (targetBuffer.length < length) {
throw new IllegalArgumentException("TargetBuffer size must be large enough to hold a byte[] of at least a size=" + length);
}
// are we actually copying any data?
if (length > 0) {
// create adjusted versions of read and write positions based
// on the offset and length passed into this method
int offsetReadPosition = (this.currentReadPosition + offset) % this.buffer.length;
int offsetWritePosition = (this.currentReadPosition + offset + length) % this.buffer.length;
if (offsetReadPosition >= offsetWritePosition) {
System.arraycopy(
this.buffer,
offsetReadPosition,
targetBuffer,
targetOffset,
this.buffer.length - offsetReadPosition);
System.arraycopy(
this.buffer,
0,
targetBuffer,
targetOffset + this.buffer.length - offsetReadPosition,
offsetWritePosition);
} else {
System.arraycopy(
this.buffer,
offsetReadPosition,
targetBuffer,
targetOffset,
offsetWritePosition - offsetReadPosition);
}
}
} | java | public void toArray(int offset, int length, byte[] targetBuffer, int targetOffset) {
// validate the offset, length are ok
ByteBuffer.checkOffsetLength(size(), offset, length);
// validate the offset, length are ok
ByteBuffer.checkOffsetLength(targetBuffer.length, targetOffset, length);
// will we have a large enough byte[] allocated?
if (targetBuffer.length < length) {
throw new IllegalArgumentException("TargetBuffer size must be large enough to hold a byte[] of at least a size=" + length);
}
// are we actually copying any data?
if (length > 0) {
// create adjusted versions of read and write positions based
// on the offset and length passed into this method
int offsetReadPosition = (this.currentReadPosition + offset) % this.buffer.length;
int offsetWritePosition = (this.currentReadPosition + offset + length) % this.buffer.length;
if (offsetReadPosition >= offsetWritePosition) {
System.arraycopy(
this.buffer,
offsetReadPosition,
targetBuffer,
targetOffset,
this.buffer.length - offsetReadPosition);
System.arraycopy(
this.buffer,
0,
targetBuffer,
targetOffset + this.buffer.length - offsetReadPosition,
offsetWritePosition);
} else {
System.arraycopy(
this.buffer,
offsetReadPosition,
targetBuffer,
targetOffset,
offsetWritePosition - offsetReadPosition);
}
}
} | [
"public",
"void",
"toArray",
"(",
"int",
"offset",
",",
"int",
"length",
",",
"byte",
"[",
"]",
"targetBuffer",
",",
"int",
"targetOffset",
")",
"{",
"// validate the offset, length are ok",
"ByteBuffer",
".",
"checkOffsetLength",
"(",
"size",
"(",
")",
",",
"offset",
",",
"length",
")",
";",
"// validate the offset, length are ok",
"ByteBuffer",
".",
"checkOffsetLength",
"(",
"targetBuffer",
".",
"length",
",",
"targetOffset",
",",
"length",
")",
";",
"// will we have a large enough byte[] allocated?",
"if",
"(",
"targetBuffer",
".",
"length",
"<",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"TargetBuffer size must be large enough to hold a byte[] of at least a size=\"",
"+",
"length",
")",
";",
"}",
"// are we actually copying any data?",
"if",
"(",
"length",
">",
"0",
")",
"{",
"// create adjusted versions of read and write positions based",
"// on the offset and length passed into this method",
"int",
"offsetReadPosition",
"=",
"(",
"this",
".",
"currentReadPosition",
"+",
"offset",
")",
"%",
"this",
".",
"buffer",
".",
"length",
";",
"int",
"offsetWritePosition",
"=",
"(",
"this",
".",
"currentReadPosition",
"+",
"offset",
"+",
"length",
")",
"%",
"this",
".",
"buffer",
".",
"length",
";",
"if",
"(",
"offsetReadPosition",
">=",
"offsetWritePosition",
")",
"{",
"System",
".",
"arraycopy",
"(",
"this",
".",
"buffer",
",",
"offsetReadPosition",
",",
"targetBuffer",
",",
"targetOffset",
",",
"this",
".",
"buffer",
".",
"length",
"-",
"offsetReadPosition",
")",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"buffer",
",",
"0",
",",
"targetBuffer",
",",
"targetOffset",
"+",
"this",
".",
"buffer",
".",
"length",
"-",
"offsetReadPosition",
",",
"offsetWritePosition",
")",
";",
"}",
"else",
"{",
"System",
".",
"arraycopy",
"(",
"this",
".",
"buffer",
",",
"offsetReadPosition",
",",
"targetBuffer",
",",
"targetOffset",
",",
"offsetWritePosition",
"-",
"offsetReadPosition",
")",
";",
"}",
"}",
"}"
] | Will copy data from this ByteBuffer's buffer into the targetBuffer. This
method requires the targetBuffer to already be allocated with enough capacity
to hold this ByteBuffer's data.
@param offset The offset within the ByteBuffer to start copy from
@param length The length from the offset to copy
@param targetBuffer The target byte array we'll copy data into. Must already
be allocated with enough capacity.
@param targetOffset The offset within the target byte array to start from
@throws IllegalArgumentException If the offset and length are invalid
for this ByteBuffer, if the targetOffset and targetLength are invalid
for the targetBuffer, or if if the targetBuffer's capacity is not
large enough to hold the copied data. | [
"Will",
"copy",
"data",
"from",
"this",
"ByteBuffer",
"s",
"buffer",
"into",
"the",
"targetBuffer",
".",
"This",
"method",
"requires",
"the",
"targetBuffer",
"to",
"already",
"be",
"allocated",
"with",
"enough",
"capacity",
"to",
"hold",
"this",
"ByteBuffer",
"s",
"data",
"."
] | train | https://github.com/twitter/cloudhopper-commons/blob/b5bc397dbec4537e8149e7ec0733c1d7ed477499/ch-commons-util/src/main/java/com/cloudhopper/commons/util/ByteBuffer.java#L804-L847 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/linalg/cpu/nativecpu/blas/SparseCpuLevel1.java | SparseCpuLevel1.droti | @Override
protected void droti(long N, INDArray X, DataBuffer indexes, INDArray Y, double c, double s) {
"""
Applies Givens rotation to sparse vectors one of which is in compressed form.
@param N The number of elements in vectors X and Y
@param X a double sparse vector
@param indexes The indexes of the sparse vector
@param Y a double full-storage vector
@param c a scalar
@param s a scalar
"""
cblas_droti((int) N, (DoublePointer) X.data().addressPointer(), (IntPointer) indexes.addressPointer(),
(DoublePointer) Y.data().addressPointer(), c, s);
} | java | @Override
protected void droti(long N, INDArray X, DataBuffer indexes, INDArray Y, double c, double s) {
cblas_droti((int) N, (DoublePointer) X.data().addressPointer(), (IntPointer) indexes.addressPointer(),
(DoublePointer) Y.data().addressPointer(), c, s);
} | [
"@",
"Override",
"protected",
"void",
"droti",
"(",
"long",
"N",
",",
"INDArray",
"X",
",",
"DataBuffer",
"indexes",
",",
"INDArray",
"Y",
",",
"double",
"c",
",",
"double",
"s",
")",
"{",
"cblas_droti",
"(",
"(",
"int",
")",
"N",
",",
"(",
"DoublePointer",
")",
"X",
".",
"data",
"(",
")",
".",
"addressPointer",
"(",
")",
",",
"(",
"IntPointer",
")",
"indexes",
".",
"addressPointer",
"(",
")",
",",
"(",
"DoublePointer",
")",
"Y",
".",
"data",
"(",
")",
".",
"addressPointer",
"(",
")",
",",
"c",
",",
"s",
")",
";",
"}"
] | Applies Givens rotation to sparse vectors one of which is in compressed form.
@param N The number of elements in vectors X and Y
@param X a double sparse vector
@param indexes The indexes of the sparse vector
@param Y a double full-storage vector
@param c a scalar
@param s a scalar | [
"Applies",
"Givens",
"rotation",
"to",
"sparse",
"vectors",
"one",
"of",
"which",
"is",
"in",
"compressed",
"form",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/linalg/cpu/nativecpu/blas/SparseCpuLevel1.java#L232-L236 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionBroadcast.java | TransactionBroadcast.setProgressCallback | public void setProgressCallback(ProgressCallback callback, @Nullable Executor executor) {
"""
Sets the given callback for receiving progress values, which will run on the given executor. If the executor
is null then the callback will run on a network thread and may be invoked multiple times in parallel. You
probably want to provide your UI thread or Threading.USER_THREAD for the second parameter. If the broadcast
has already started then the callback will be invoked immediately with the current progress.
"""
boolean shouldInvoke;
int num;
boolean mined;
synchronized (this) {
this.callback = callback;
this.progressCallbackExecutor = executor;
num = this.numSeemPeers;
mined = this.mined;
shouldInvoke = numWaitingFor > 0;
}
if (shouldInvoke)
invokeProgressCallback(num, mined);
} | java | public void setProgressCallback(ProgressCallback callback, @Nullable Executor executor) {
boolean shouldInvoke;
int num;
boolean mined;
synchronized (this) {
this.callback = callback;
this.progressCallbackExecutor = executor;
num = this.numSeemPeers;
mined = this.mined;
shouldInvoke = numWaitingFor > 0;
}
if (shouldInvoke)
invokeProgressCallback(num, mined);
} | [
"public",
"void",
"setProgressCallback",
"(",
"ProgressCallback",
"callback",
",",
"@",
"Nullable",
"Executor",
"executor",
")",
"{",
"boolean",
"shouldInvoke",
";",
"int",
"num",
";",
"boolean",
"mined",
";",
"synchronized",
"(",
"this",
")",
"{",
"this",
".",
"callback",
"=",
"callback",
";",
"this",
".",
"progressCallbackExecutor",
"=",
"executor",
";",
"num",
"=",
"this",
".",
"numSeemPeers",
";",
"mined",
"=",
"this",
".",
"mined",
";",
"shouldInvoke",
"=",
"numWaitingFor",
">",
"0",
";",
"}",
"if",
"(",
"shouldInvoke",
")",
"invokeProgressCallback",
"(",
"num",
",",
"mined",
")",
";",
"}"
] | Sets the given callback for receiving progress values, which will run on the given executor. If the executor
is null then the callback will run on a network thread and may be invoked multiple times in parallel. You
probably want to provide your UI thread or Threading.USER_THREAD for the second parameter. If the broadcast
has already started then the callback will be invoked immediately with the current progress. | [
"Sets",
"the",
"given",
"callback",
"for",
"receiving",
"progress",
"values",
"which",
"will",
"run",
"on",
"the",
"given",
"executor",
".",
"If",
"the",
"executor",
"is",
"null",
"then",
"the",
"callback",
"will",
"run",
"on",
"a",
"network",
"thread",
"and",
"may",
"be",
"invoked",
"multiple",
"times",
"in",
"parallel",
".",
"You",
"probably",
"want",
"to",
"provide",
"your",
"UI",
"thread",
"or",
"Threading",
".",
"USER_THREAD",
"for",
"the",
"second",
"parameter",
".",
"If",
"the",
"broadcast",
"has",
"already",
"started",
"then",
"the",
"callback",
"will",
"be",
"invoked",
"immediately",
"with",
"the",
"current",
"progress",
"."
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionBroadcast.java#L279-L292 |
mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/AmazonDynamoDBClient.java | AmazonDynamoDBClient.updateItem | public UpdateItemResult updateItem(UpdateItemRequest updateItemRequest)
throws AmazonServiceException, AmazonClientException {
"""
<p>
Edits an existing item's attributes.
</p>
<p>
You can perform a conditional update (insert a new attribute
name-value pair if it doesn't exist, or replace an existing name-value
pair if it has certain expected attribute values).
</p>
@param updateItemRequest Container for the necessary parameters to
execute the UpdateItem service method on AmazonDynamoDB.
@return The response from the UpdateItem service method, as returned
by AmazonDynamoDB.
@throws LimitExceededException
@throws ProvisionedThroughputExceededException
@throws ConditionalCheckFailedException
@throws InternalServerErrorException
@throws ResourceNotFoundException
@throws AmazonClientException
If any internal errors are encountered inside the client while
attempting to make the request or handle the response. For example
if a network connection is not available.
@throws AmazonServiceException
If an error response is returned by AmazonDynamoDB indicating
either a problem with the data in the request, or a server side issue.
"""
ExecutionContext executionContext = createExecutionContext(updateItemRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
Request<UpdateItemRequest> request = marshall(updateItemRequest,
new UpdateItemRequestMarshaller(),
executionContext.getAwsRequestMetrics());
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
Unmarshaller<UpdateItemResult, JsonUnmarshallerContext> unmarshaller = new UpdateItemResultJsonUnmarshaller();
JsonResponseHandler<UpdateItemResult> responseHandler = new JsonResponseHandler<UpdateItemResult>(unmarshaller);
return invoke(request, responseHandler, executionContext);
} | java | public UpdateItemResult updateItem(UpdateItemRequest updateItemRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(updateItemRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
Request<UpdateItemRequest> request = marshall(updateItemRequest,
new UpdateItemRequestMarshaller(),
executionContext.getAwsRequestMetrics());
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
Unmarshaller<UpdateItemResult, JsonUnmarshallerContext> unmarshaller = new UpdateItemResultJsonUnmarshaller();
JsonResponseHandler<UpdateItemResult> responseHandler = new JsonResponseHandler<UpdateItemResult>(unmarshaller);
return invoke(request, responseHandler, executionContext);
} | [
"public",
"UpdateItemResult",
"updateItem",
"(",
"UpdateItemRequest",
"updateItemRequest",
")",
"throws",
"AmazonServiceException",
",",
"AmazonClientException",
"{",
"ExecutionContext",
"executionContext",
"=",
"createExecutionContext",
"(",
"updateItemRequest",
")",
";",
"AWSRequestMetrics",
"awsRequestMetrics",
"=",
"executionContext",
".",
"getAwsRequestMetrics",
"(",
")",
";",
"Request",
"<",
"UpdateItemRequest",
">",
"request",
"=",
"marshall",
"(",
"updateItemRequest",
",",
"new",
"UpdateItemRequestMarshaller",
"(",
")",
",",
"executionContext",
".",
"getAwsRequestMetrics",
"(",
")",
")",
";",
"// Binds the request metrics to the current request.",
"request",
".",
"setAWSRequestMetrics",
"(",
"awsRequestMetrics",
")",
";",
"Unmarshaller",
"<",
"UpdateItemResult",
",",
"JsonUnmarshallerContext",
">",
"unmarshaller",
"=",
"new",
"UpdateItemResultJsonUnmarshaller",
"(",
")",
";",
"JsonResponseHandler",
"<",
"UpdateItemResult",
">",
"responseHandler",
"=",
"new",
"JsonResponseHandler",
"<",
"UpdateItemResult",
">",
"(",
"unmarshaller",
")",
";",
"return",
"invoke",
"(",
"request",
",",
"responseHandler",
",",
"executionContext",
")",
";",
"}"
] | <p>
Edits an existing item's attributes.
</p>
<p>
You can perform a conditional update (insert a new attribute
name-value pair if it doesn't exist, or replace an existing name-value
pair if it has certain expected attribute values).
</p>
@param updateItemRequest Container for the necessary parameters to
execute the UpdateItem service method on AmazonDynamoDB.
@return The response from the UpdateItem service method, as returned
by AmazonDynamoDB.
@throws LimitExceededException
@throws ProvisionedThroughputExceededException
@throws ConditionalCheckFailedException
@throws InternalServerErrorException
@throws ResourceNotFoundException
@throws AmazonClientException
If any internal errors are encountered inside the client while
attempting to make the request or handle the response. For example
if a network connection is not available.
@throws AmazonServiceException
If an error response is returned by AmazonDynamoDB indicating
either a problem with the data in the request, or a server side issue. | [
"<p",
">",
"Edits",
"an",
"existing",
"item",
"s",
"attributes",
".",
"<",
"/",
"p",
">",
"<p",
">",
"You",
"can",
"perform",
"a",
"conditional",
"update",
"(",
"insert",
"a",
"new",
"attribute",
"name",
"-",
"value",
"pair",
"if",
"it",
"doesn",
"t",
"exist",
"or",
"replace",
"an",
"existing",
"name",
"-",
"value",
"pair",
"if",
"it",
"has",
"certain",
"expected",
"attribute",
"values",
")",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/AmazonDynamoDBClient.java#L501-L513 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/proxyhandler/SubscriptionMessageHandler.java | SubscriptionMessageHandler.addSubscriptionToMessage | protected void addSubscriptionToMessage(MESubscription subscription, boolean isLocalBus) {
"""
Adds a subscription to the proxy message that is to be sent.
This will either be a delete or reset message.
Reset will add messages to the list to resync with the Neighbour
and the Delete will send it on due to receiving a Reset.
@param subscription The MESubscription to add to the message.
@param isLocalBus The message is for the messaging engine's local bus
"""
if (tc.isEntryEnabled())
SibTr.entry(tc, "addSubscriptionToMessage", new Object[]{subscription, new Boolean(isLocalBus)});
// Add the subscription related information.
iTopics.add(subscription.getTopic());
if(isLocalBus)
{
//see defect 267686:
//local bus subscriptions expect the subscribing ME's
//detination uuid to be set in the iTopicSpaces field
iTopicSpaces.add(subscription.getTopicSpaceUuid().toString());
}
else
{
//see defect 267686:
//foreign bus subscriptions need to set the subscribers's topic space name.
//This is because the messages sent to this topic over the link
//will need to have a routing destination set, which requires
//this value.
iTopicSpaces.add(subscription.getTopicSpaceName().toString());
}
iTopicSpaceMappings.add(subscription.getForeignTSName());
if (tc.isEntryEnabled())
SibTr.exit(tc, "addSubscriptionToMessage");
} | java | protected void addSubscriptionToMessage(MESubscription subscription, boolean isLocalBus)
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "addSubscriptionToMessage", new Object[]{subscription, new Boolean(isLocalBus)});
// Add the subscription related information.
iTopics.add(subscription.getTopic());
if(isLocalBus)
{
//see defect 267686:
//local bus subscriptions expect the subscribing ME's
//detination uuid to be set in the iTopicSpaces field
iTopicSpaces.add(subscription.getTopicSpaceUuid().toString());
}
else
{
//see defect 267686:
//foreign bus subscriptions need to set the subscribers's topic space name.
//This is because the messages sent to this topic over the link
//will need to have a routing destination set, which requires
//this value.
iTopicSpaces.add(subscription.getTopicSpaceName().toString());
}
iTopicSpaceMappings.add(subscription.getForeignTSName());
if (tc.isEntryEnabled())
SibTr.exit(tc, "addSubscriptionToMessage");
} | [
"protected",
"void",
"addSubscriptionToMessage",
"(",
"MESubscription",
"subscription",
",",
"boolean",
"isLocalBus",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"addSubscriptionToMessage\"",
",",
"new",
"Object",
"[",
"]",
"{",
"subscription",
",",
"new",
"Boolean",
"(",
"isLocalBus",
")",
"}",
")",
";",
"// Add the subscription related information.",
"iTopics",
".",
"add",
"(",
"subscription",
".",
"getTopic",
"(",
")",
")",
";",
"if",
"(",
"isLocalBus",
")",
"{",
"//see defect 267686:",
"//local bus subscriptions expect the subscribing ME's",
"//detination uuid to be set in the iTopicSpaces field",
"iTopicSpaces",
".",
"add",
"(",
"subscription",
".",
"getTopicSpaceUuid",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"{",
"//see defect 267686:",
"//foreign bus subscriptions need to set the subscribers's topic space name.",
"//This is because the messages sent to this topic over the link",
"//will need to have a routing destination set, which requires",
"//this value.",
"iTopicSpaces",
".",
"add",
"(",
"subscription",
".",
"getTopicSpaceName",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"iTopicSpaceMappings",
".",
"add",
"(",
"subscription",
".",
"getForeignTSName",
"(",
")",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"addSubscriptionToMessage\"",
")",
";",
"}"
] | Adds a subscription to the proxy message that is to be sent.
This will either be a delete or reset message.
Reset will add messages to the list to resync with the Neighbour
and the Delete will send it on due to receiving a Reset.
@param subscription The MESubscription to add to the message.
@param isLocalBus The message is for the messaging engine's local bus | [
"Adds",
"a",
"subscription",
"to",
"the",
"proxy",
"message",
"that",
"is",
"to",
"be",
"sent",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/proxyhandler/SubscriptionMessageHandler.java#L328-L355 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/lss/LssClient.java | LssClient.listRecordings | public ListRecordingsResponse listRecordings() {
"""
List all your live recording presets.
@return The list of all your live recording preset.
"""
GetRecordingRequest request = new GetRecordingRequest();
InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, RECORDING);
return invokeHttpClient(internalRequest, ListRecordingsResponse.class);
} | java | public ListRecordingsResponse listRecordings() {
GetRecordingRequest request = new GetRecordingRequest();
InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, RECORDING);
return invokeHttpClient(internalRequest, ListRecordingsResponse.class);
} | [
"public",
"ListRecordingsResponse",
"listRecordings",
"(",
")",
"{",
"GetRecordingRequest",
"request",
"=",
"new",
"GetRecordingRequest",
"(",
")",
";",
"InternalRequest",
"internalRequest",
"=",
"createRequest",
"(",
"HttpMethodName",
".",
"GET",
",",
"request",
",",
"RECORDING",
")",
";",
"return",
"invokeHttpClient",
"(",
"internalRequest",
",",
"ListRecordingsResponse",
".",
"class",
")",
";",
"}"
] | List all your live recording presets.
@return The list of all your live recording preset. | [
"List",
"all",
"your",
"live",
"recording",
"presets",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/lss/LssClient.java#L1137-L1141 |
BlueBrain/bluima | modules/bluima_abbreviations/src/main/java/com/wcohen/ss/lookup/SoftTFIDFDictionary.java | SoftTFIDFDictionary.put | public void put(String string,Object value) {
"""
Insert a string into the dictionary, and associate it with the
given value.
"""
if (frozen) throw new IllegalStateException("can't add new values to a frozen dictionary");
Set valset = (Set)valueMap.get(string);
if (valset==null) valueMap.put(string, (valset=new HashSet()));
valset.add( value );
} | java | public void put(String string,Object value)
{
if (frozen) throw new IllegalStateException("can't add new values to a frozen dictionary");
Set valset = (Set)valueMap.get(string);
if (valset==null) valueMap.put(string, (valset=new HashSet()));
valset.add( value );
} | [
"public",
"void",
"put",
"(",
"String",
"string",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"frozen",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"can't add new values to a frozen dictionary\"",
")",
";",
"Set",
"valset",
"=",
"(",
"Set",
")",
"valueMap",
".",
"get",
"(",
"string",
")",
";",
"if",
"(",
"valset",
"==",
"null",
")",
"valueMap",
".",
"put",
"(",
"string",
",",
"(",
"valset",
"=",
"new",
"HashSet",
"(",
")",
")",
")",
";",
"valset",
".",
"add",
"(",
"value",
")",
";",
"}"
] | Insert a string into the dictionary, and associate it with the
given value. | [
"Insert",
"a",
"string",
"into",
"the",
"dictionary",
"and",
"associate",
"it",
"with",
"the",
"given",
"value",
"."
] | train | https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_abbreviations/src/main/java/com/wcohen/ss/lookup/SoftTFIDFDictionary.java#L347-L353 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.importCertificate | public CertificateBundle importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map<String, String> tags) {
"""
Imports a certificate into a specified key vault.
Imports an existing valid certificate, containing a private key, into Azure Key Vault. The certificate to be imported can be in either PFX or PEM format. If the certificate is in PEM format the PEM file must contain the key as well as x509 certificates. This operation requires the certificates/import permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param certificateName The name of the certificate.
@param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key.
@param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption.
@param certificatePolicy The management policy for the certificate.
@param certificateAttributes The attributes of the certificate (optional).
@param tags Application specific metadata in the form of key-value pairs.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the CertificateBundle object if successful.
"""
return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single().body();
} | java | public CertificateBundle importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map<String, String> tags) {
return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single().body();
} | [
"public",
"CertificateBundle",
"importCertificate",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"certificateName",
",",
"String",
"base64EncodedCertificate",
",",
"String",
"password",
",",
"CertificatePolicy",
"certificatePolicy",
",",
"CertificateAttributes",
"certificateAttributes",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"return",
"importCertificateWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"certificateName",
",",
"base64EncodedCertificate",
",",
"password",
",",
"certificatePolicy",
",",
"certificateAttributes",
",",
"tags",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Imports a certificate into a specified key vault.
Imports an existing valid certificate, containing a private key, into Azure Key Vault. The certificate to be imported can be in either PFX or PEM format. If the certificate is in PEM format the PEM file must contain the key as well as x509 certificates. This operation requires the certificates/import permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param certificateName The name of the certificate.
@param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key.
@param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption.
@param certificatePolicy The management policy for the certificate.
@param certificateAttributes The attributes of the certificate (optional).
@param tags Application specific metadata in the form of key-value pairs.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the CertificateBundle object if successful. | [
"Imports",
"a",
"certificate",
"into",
"a",
"specified",
"key",
"vault",
".",
"Imports",
"an",
"existing",
"valid",
"certificate",
"containing",
"a",
"private",
"key",
"into",
"Azure",
"Key",
"Vault",
".",
"The",
"certificate",
"to",
"be",
"imported",
"can",
"be",
"in",
"either",
"PFX",
"or",
"PEM",
"format",
".",
"If",
"the",
"certificate",
"is",
"in",
"PEM",
"format",
"the",
"PEM",
"file",
"must",
"contain",
"the",
"key",
"as",
"well",
"as",
"x509",
"certificates",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"import",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L6786-L6788 |
OpenLiberty/open-liberty | dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java | MetricRegistryImpl.getGauges | @Override
public SortedMap<String, Gauge> getGauges(MetricFilter filter) {
"""
Returns a map of all the gauges in the registry and their names which match the given filter.
@param filter the metric filter to match
@return all the gauges in the registry
"""
return getMetrics(Gauge.class, filter);
} | java | @Override
public SortedMap<String, Gauge> getGauges(MetricFilter filter) {
return getMetrics(Gauge.class, filter);
} | [
"@",
"Override",
"public",
"SortedMap",
"<",
"String",
",",
"Gauge",
">",
"getGauges",
"(",
"MetricFilter",
"filter",
")",
"{",
"return",
"getMetrics",
"(",
"Gauge",
".",
"class",
",",
"filter",
")",
";",
"}"
] | Returns a map of all the gauges in the registry and their names which match the given filter.
@param filter the metric filter to match
@return all the gauges in the registry | [
"Returns",
"a",
"map",
"of",
"all",
"the",
"gauges",
"in",
"the",
"registry",
"and",
"their",
"names",
"which",
"match",
"the",
"given",
"filter",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java#L340-L343 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ExpressRoutePortsInner.java | ExpressRoutePortsInner.beginUpdateTagsAsync | public Observable<ExpressRoutePortInner> beginUpdateTagsAsync(String resourceGroupName, String expressRoutePortName) {
"""
Update ExpressRoutePort tags.
@param resourceGroupName The name of the resource group.
@param expressRoutePortName The name of the ExpressRoutePort resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ExpressRoutePortInner object
"""
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, expressRoutePortName).map(new Func1<ServiceResponse<ExpressRoutePortInner>, ExpressRoutePortInner>() {
@Override
public ExpressRoutePortInner call(ServiceResponse<ExpressRoutePortInner> response) {
return response.body();
}
});
} | java | public Observable<ExpressRoutePortInner> beginUpdateTagsAsync(String resourceGroupName, String expressRoutePortName) {
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, expressRoutePortName).map(new Func1<ServiceResponse<ExpressRoutePortInner>, ExpressRoutePortInner>() {
@Override
public ExpressRoutePortInner call(ServiceResponse<ExpressRoutePortInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ExpressRoutePortInner",
">",
"beginUpdateTagsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"expressRoutePortName",
")",
"{",
"return",
"beginUpdateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"expressRoutePortName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ExpressRoutePortInner",
">",
",",
"ExpressRoutePortInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ExpressRoutePortInner",
"call",
"(",
"ServiceResponse",
"<",
"ExpressRoutePortInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Update ExpressRoutePort tags.
@param resourceGroupName The name of the resource group.
@param expressRoutePortName The name of the ExpressRoutePort resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ExpressRoutePortInner object | [
"Update",
"ExpressRoutePort",
"tags",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ExpressRoutePortsInner.java#L697-L704 |
UrielCh/ovh-java-sdk | ovh-java-sdk-caasregistry/src/main/java/net/minidev/ovh/api/ApiOvhCaasregistry.java | ApiOvhCaasregistry.serviceName_serviceInfos_PUT | public void serviceName_serviceInfos_PUT(String serviceName, net.minidev.ovh.api.services.OvhService body) throws IOException {
"""
Alter this object properties
REST: PUT /caas/registry/{serviceName}/serviceInfos
@param body [required] New object properties
@param serviceName [required] The internal ID of your project
API beta
"""
String qPath = "/caas/registry/{serviceName}/serviceInfos";
StringBuilder sb = path(qPath, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void serviceName_serviceInfos_PUT(String serviceName, net.minidev.ovh.api.services.OvhService body) throws IOException {
String qPath = "/caas/registry/{serviceName}/serviceInfos";
StringBuilder sb = path(qPath, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"serviceName_serviceInfos_PUT",
"(",
"String",
"serviceName",
",",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"services",
".",
"OvhService",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/caas/registry/{serviceName}/serviceInfos\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /caas/registry/{serviceName}/serviceInfos
@param body [required] New object properties
@param serviceName [required] The internal ID of your project
API beta | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-caasregistry/src/main/java/net/minidev/ovh/api/ApiOvhCaasregistry.java#L185-L189 |
nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/font/effects/OutlineEffect.java | OutlineEffect.getStroke | public Stroke getStroke() {
"""
Get the stroke being used to draw the outline
@return The stroke being used to draw the outline
"""
if (stroke == null) {
return new BasicStroke(width, BasicStroke.CAP_SQUARE, join);
}
return stroke;
} | java | public Stroke getStroke() {
if (stroke == null) {
return new BasicStroke(width, BasicStroke.CAP_SQUARE, join);
}
return stroke;
} | [
"public",
"Stroke",
"getStroke",
"(",
")",
"{",
"if",
"(",
"stroke",
"==",
"null",
")",
"{",
"return",
"new",
"BasicStroke",
"(",
"width",
",",
"BasicStroke",
".",
"CAP_SQUARE",
",",
"join",
")",
";",
"}",
"return",
"stroke",
";",
"}"
] | Get the stroke being used to draw the outline
@return The stroke being used to draw the outline | [
"Get",
"the",
"stroke",
"being",
"used",
"to",
"draw",
"the",
"outline"
] | train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/effects/OutlineEffect.java#L113-L119 |
exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/lock/NullResourceLocksHolder.java | NullResourceLocksHolder.checkLock | public void checkLock(Session session, String path, List<String> tokens) throws LockException {
"""
Checks if the node can be unlocked using current tokens.
@param session current session
@param path node path
@param tokens tokens
@throws LockException {@link LockException}
"""
String repoPath = session.getRepository().hashCode() + "/" + session.getWorkspace().getName() + "/" + path;
String currentToken = nullResourceLocks.get(repoPath);
if (currentToken == null)
{
return;
}
if (tokens != null)
{
for (String token : tokens)
{
if (token.equals(currentToken))
{
return;
}
}
}
throw new LockException("Resource already locked " + repoPath);
} | java | public void checkLock(Session session, String path, List<String> tokens) throws LockException
{
String repoPath = session.getRepository().hashCode() + "/" + session.getWorkspace().getName() + "/" + path;
String currentToken = nullResourceLocks.get(repoPath);
if (currentToken == null)
{
return;
}
if (tokens != null)
{
for (String token : tokens)
{
if (token.equals(currentToken))
{
return;
}
}
}
throw new LockException("Resource already locked " + repoPath);
} | [
"public",
"void",
"checkLock",
"(",
"Session",
"session",
",",
"String",
"path",
",",
"List",
"<",
"String",
">",
"tokens",
")",
"throws",
"LockException",
"{",
"String",
"repoPath",
"=",
"session",
".",
"getRepository",
"(",
")",
".",
"hashCode",
"(",
")",
"+",
"\"/\"",
"+",
"session",
".",
"getWorkspace",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"/\"",
"+",
"path",
";",
"String",
"currentToken",
"=",
"nullResourceLocks",
".",
"get",
"(",
"repoPath",
")",
";",
"if",
"(",
"currentToken",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"tokens",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"token",
":",
"tokens",
")",
"{",
"if",
"(",
"token",
".",
"equals",
"(",
"currentToken",
")",
")",
"{",
"return",
";",
"}",
"}",
"}",
"throw",
"new",
"LockException",
"(",
"\"Resource already locked \"",
"+",
"repoPath",
")",
";",
"}"
] | Checks if the node can be unlocked using current tokens.
@param session current session
@param path node path
@param tokens tokens
@throws LockException {@link LockException} | [
"Checks",
"if",
"the",
"node",
"can",
"be",
"unlocked",
"using",
"current",
"tokens",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/lock/NullResourceLocksHolder.java#L123-L146 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/util/POIUtils.java | POIUtils.getDataFormatIndex | public static short getDataFormatIndex(final Sheet sheet, final String pattern) {
"""
指定した書式のインデックス番号を取得する。シートに存在しない場合は、新しく作成する。
@param sheet シート
@param pattern 作成する書式のパターン
@return 書式のインデックス番号。
@throws IllegalArgumentException {@literal sheet == null.}
@throws IllegalArgumentException {@literal pattern == null || pattern.isEmpty().}
"""
ArgUtils.notNull(sheet, "sheet");
ArgUtils.notEmpty(pattern, "pattern");
return sheet.getWorkbook().getCreationHelper().createDataFormat().getFormat(pattern);
} | java | public static short getDataFormatIndex(final Sheet sheet, final String pattern) {
ArgUtils.notNull(sheet, "sheet");
ArgUtils.notEmpty(pattern, "pattern");
return sheet.getWorkbook().getCreationHelper().createDataFormat().getFormat(pattern);
} | [
"public",
"static",
"short",
"getDataFormatIndex",
"(",
"final",
"Sheet",
"sheet",
",",
"final",
"String",
"pattern",
")",
"{",
"ArgUtils",
".",
"notNull",
"(",
"sheet",
",",
"\"sheet\"",
")",
";",
"ArgUtils",
".",
"notEmpty",
"(",
"pattern",
",",
"\"pattern\"",
")",
";",
"return",
"sheet",
".",
"getWorkbook",
"(",
")",
".",
"getCreationHelper",
"(",
")",
".",
"createDataFormat",
"(",
")",
".",
"getFormat",
"(",
"pattern",
")",
";",
"}"
] | 指定した書式のインデックス番号を取得する。シートに存在しない場合は、新しく作成する。
@param sheet シート
@param pattern 作成する書式のパターン
@return 書式のインデックス番号。
@throws IllegalArgumentException {@literal sheet == null.}
@throws IllegalArgumentException {@literal pattern == null || pattern.isEmpty().} | [
"指定した書式のインデックス番号を取得する。シートに存在しない場合は、新しく作成する。"
] | train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/util/POIUtils.java#L294-L300 |
Steveice10/OpenNBT | src/main/java/com/github/steveice10/opennbt/NBTIO.java | NBTIO.writeFile | public static void writeFile(CompoundTag tag, String path) throws IOException {
"""
Writes the given root CompoundTag to the given file, compressed and in big endian.
@param tag Tag to write.
@param path Path to write to.
@throws java.io.IOException If an I/O error occurs.
"""
writeFile(tag, new File(path));
} | java | public static void writeFile(CompoundTag tag, String path) throws IOException {
writeFile(tag, new File(path));
} | [
"public",
"static",
"void",
"writeFile",
"(",
"CompoundTag",
"tag",
",",
"String",
"path",
")",
"throws",
"IOException",
"{",
"writeFile",
"(",
"tag",
",",
"new",
"File",
"(",
"path",
")",
")",
";",
"}"
] | Writes the given root CompoundTag to the given file, compressed and in big endian.
@param tag Tag to write.
@param path Path to write to.
@throws java.io.IOException If an I/O error occurs. | [
"Writes",
"the",
"given",
"root",
"CompoundTag",
"to",
"the",
"given",
"file",
"compressed",
"and",
"in",
"big",
"endian",
"."
] | train | https://github.com/Steveice10/OpenNBT/blob/9bf4adb2afd206a21bc4309c85d642494d1fb536/src/main/java/com/github/steveice10/opennbt/NBTIO.java#L93-L95 |
lucee/Lucee | core/src/main/java/lucee/runtime/text/xml/XMLCaster.java | XMLCaster.toText | public static Text toText(Document doc, Object o) throws PageException {
"""
casts a value to a XML Text
@param doc XML Document
@param o Object to cast
@return XML Text Object
@throws PageException
"""
if (o instanceof Text) return (Text) o;
else if (o instanceof CharacterData) return doc.createTextNode(((CharacterData) o).getData());
return doc.createTextNode(Caster.toString(o));
} | java | public static Text toText(Document doc, Object o) throws PageException {
if (o instanceof Text) return (Text) o;
else if (o instanceof CharacterData) return doc.createTextNode(((CharacterData) o).getData());
return doc.createTextNode(Caster.toString(o));
} | [
"public",
"static",
"Text",
"toText",
"(",
"Document",
"doc",
",",
"Object",
"o",
")",
"throws",
"PageException",
"{",
"if",
"(",
"o",
"instanceof",
"Text",
")",
"return",
"(",
"Text",
")",
"o",
";",
"else",
"if",
"(",
"o",
"instanceof",
"CharacterData",
")",
"return",
"doc",
".",
"createTextNode",
"(",
"(",
"(",
"CharacterData",
")",
"o",
")",
".",
"getData",
"(",
")",
")",
";",
"return",
"doc",
".",
"createTextNode",
"(",
"Caster",
".",
"toString",
"(",
"o",
")",
")",
";",
"}"
] | casts a value to a XML Text
@param doc XML Document
@param o Object to cast
@return XML Text Object
@throws PageException | [
"casts",
"a",
"value",
"to",
"a",
"XML",
"Text"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/text/xml/XMLCaster.java#L86-L90 |
google/Accessibility-Test-Framework-for-Android | src/main/java/com/googlecode/eyesfree/utils/LogUtils.java | LogUtils.wtf | public static void wtf(Object source, String format, Object... args) {
"""
Logs a string to the console using the source object's name as the log tag at the assert level.
If the source object is null, the default tag (see {@link LogUtils#TAG}) is used.
@param source The object that generated the log event.
@param format A format string, see {@link String#format(String, Object...)}.
@param args String formatter arguments.
"""
log(source, Log.ASSERT, format, args);
} | java | public static void wtf(Object source, String format, Object... args) {
log(source, Log.ASSERT, format, args);
} | [
"public",
"static",
"void",
"wtf",
"(",
"Object",
"source",
",",
"String",
"format",
",",
"Object",
"...",
"args",
")",
"{",
"log",
"(",
"source",
",",
"Log",
".",
"ASSERT",
",",
"format",
",",
"args",
")",
";",
"}"
] | Logs a string to the console using the source object's name as the log tag at the assert level.
If the source object is null, the default tag (see {@link LogUtils#TAG}) is used.
@param source The object that generated the log event.
@param format A format string, see {@link String#format(String, Object...)}.
@param args String formatter arguments. | [
"Logs",
"a",
"string",
"to",
"the",
"console",
"using",
"the",
"source",
"object",
"s",
"name",
"as",
"the",
"log",
"tag",
"at",
"the",
"assert",
"level",
".",
"If",
"the",
"source",
"object",
"is",
"null",
"the",
"default",
"tag",
"(",
"see",
"{",
"@link",
"LogUtils#TAG",
"}",
")",
"is",
"used",
"."
] | train | https://github.com/google/Accessibility-Test-Framework-for-Android/blob/a6117fe0059c82dd764fa628d3817d724570f69e/src/main/java/com/googlecode/eyesfree/utils/LogUtils.java#L240-L242 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_portability_id_document_documentId_GET | public OvhPortabilityDocument billingAccount_portability_id_document_documentId_GET(String billingAccount, Long id, Long documentId) throws IOException {
"""
Get this object properties
REST: GET /telephony/{billingAccount}/portability/{id}/document/{documentId}
@param billingAccount [required] The name of your billingAccount
@param id [required] The ID of the portability
@param documentId [required] Identifier of the document
"""
String qPath = "/telephony/{billingAccount}/portability/{id}/document/{documentId}";
StringBuilder sb = path(qPath, billingAccount, id, documentId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPortabilityDocument.class);
} | java | public OvhPortabilityDocument billingAccount_portability_id_document_documentId_GET(String billingAccount, Long id, Long documentId) throws IOException {
String qPath = "/telephony/{billingAccount}/portability/{id}/document/{documentId}";
StringBuilder sb = path(qPath, billingAccount, id, documentId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPortabilityDocument.class);
} | [
"public",
"OvhPortabilityDocument",
"billingAccount_portability_id_document_documentId_GET",
"(",
"String",
"billingAccount",
",",
"Long",
"id",
",",
"Long",
"documentId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/portability/{id}/document/{documentId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"id",
",",
"documentId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhPortabilityDocument",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /telephony/{billingAccount}/portability/{id}/document/{documentId}
@param billingAccount [required] The name of your billingAccount
@param id [required] The ID of the portability
@param documentId [required] Identifier of the document | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L271-L276 |
osmdroid/osmdroid | osmdroid-android/src/main/java/org/osmdroid/util/SegmentIntersection.java | SegmentIntersection.parallelSideEffect | private static boolean parallelSideEffect(
final double pXA, final double pYA, final double pXB, final double pYB,
final double pXC, final double pYC, final double pXD, final double pYD,
final PointL pIntersection
) {
"""
When the segments are parallels and overlap, the middle of the overlap is considered as the intersection
"""
if (pXA == pXB) {
return parallelSideEffectSameX(pXA, pYA, pXB, pYB, pXC, pYC, pXD, pYD, pIntersection);
}
if (pXC == pXD) {
return parallelSideEffectSameX(pXC, pYC, pXD, pYD, pXA, pYA, pXB, pYB, pIntersection);
}
// formula like "y = k*x + b"
final double k1 = (pYB - pYA) / (pXB - pXA);
final double k2 = (pYD - pYC) / (pXD - pXC);
if (k1 != k2) { // not parallel
return false;
}
final double b1 = pYA - k1 * pXA;
final double b2 = pYC - k2 * pXC;
if (b1 != b2) { // strictly parallel, no overlap
return false;
}
final double xi = middle(pXA, pXB, pXC, pXD);
final double yi = middle(pYA, pYB, pYC, pYD);
return check(pXA, pYA, pXB, pYB, pXC, pYC, pXD, pYD, pIntersection, xi, yi);
} | java | private static boolean parallelSideEffect(
final double pXA, final double pYA, final double pXB, final double pYB,
final double pXC, final double pYC, final double pXD, final double pYD,
final PointL pIntersection
) {
if (pXA == pXB) {
return parallelSideEffectSameX(pXA, pYA, pXB, pYB, pXC, pYC, pXD, pYD, pIntersection);
}
if (pXC == pXD) {
return parallelSideEffectSameX(pXC, pYC, pXD, pYD, pXA, pYA, pXB, pYB, pIntersection);
}
// formula like "y = k*x + b"
final double k1 = (pYB - pYA) / (pXB - pXA);
final double k2 = (pYD - pYC) / (pXD - pXC);
if (k1 != k2) { // not parallel
return false;
}
final double b1 = pYA - k1 * pXA;
final double b2 = pYC - k2 * pXC;
if (b1 != b2) { // strictly parallel, no overlap
return false;
}
final double xi = middle(pXA, pXB, pXC, pXD);
final double yi = middle(pYA, pYB, pYC, pYD);
return check(pXA, pYA, pXB, pYB, pXC, pYC, pXD, pYD, pIntersection, xi, yi);
} | [
"private",
"static",
"boolean",
"parallelSideEffect",
"(",
"final",
"double",
"pXA",
",",
"final",
"double",
"pYA",
",",
"final",
"double",
"pXB",
",",
"final",
"double",
"pYB",
",",
"final",
"double",
"pXC",
",",
"final",
"double",
"pYC",
",",
"final",
"double",
"pXD",
",",
"final",
"double",
"pYD",
",",
"final",
"PointL",
"pIntersection",
")",
"{",
"if",
"(",
"pXA",
"==",
"pXB",
")",
"{",
"return",
"parallelSideEffectSameX",
"(",
"pXA",
",",
"pYA",
",",
"pXB",
",",
"pYB",
",",
"pXC",
",",
"pYC",
",",
"pXD",
",",
"pYD",
",",
"pIntersection",
")",
";",
"}",
"if",
"(",
"pXC",
"==",
"pXD",
")",
"{",
"return",
"parallelSideEffectSameX",
"(",
"pXC",
",",
"pYC",
",",
"pXD",
",",
"pYD",
",",
"pXA",
",",
"pYA",
",",
"pXB",
",",
"pYB",
",",
"pIntersection",
")",
";",
"}",
"// formula like \"y = k*x + b\"",
"final",
"double",
"k1",
"=",
"(",
"pYB",
"-",
"pYA",
")",
"/",
"(",
"pXB",
"-",
"pXA",
")",
";",
"final",
"double",
"k2",
"=",
"(",
"pYD",
"-",
"pYC",
")",
"/",
"(",
"pXD",
"-",
"pXC",
")",
";",
"if",
"(",
"k1",
"!=",
"k2",
")",
"{",
"// not parallel",
"return",
"false",
";",
"}",
"final",
"double",
"b1",
"=",
"pYA",
"-",
"k1",
"*",
"pXA",
";",
"final",
"double",
"b2",
"=",
"pYC",
"-",
"k2",
"*",
"pXC",
";",
"if",
"(",
"b1",
"!=",
"b2",
")",
"{",
"// strictly parallel, no overlap",
"return",
"false",
";",
"}",
"final",
"double",
"xi",
"=",
"middle",
"(",
"pXA",
",",
"pXB",
",",
"pXC",
",",
"pXD",
")",
";",
"final",
"double",
"yi",
"=",
"middle",
"(",
"pYA",
",",
"pYB",
",",
"pYC",
",",
"pYD",
")",
";",
"return",
"check",
"(",
"pXA",
",",
"pYA",
",",
"pXB",
",",
"pYB",
",",
"pXC",
",",
"pYC",
",",
"pXD",
",",
"pYD",
",",
"pIntersection",
",",
"xi",
",",
"yi",
")",
";",
"}"
] | When the segments are parallels and overlap, the middle of the overlap is considered as the intersection | [
"When",
"the",
"segments",
"are",
"parallels",
"and",
"overlap",
"the",
"middle",
"of",
"the",
"overlap",
"is",
"considered",
"as",
"the",
"intersection"
] | train | https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-android/src/main/java/org/osmdroid/util/SegmentIntersection.java#L47-L72 |
alkacon/opencms-core | src/org/opencms/xml/content/CmsXmlContent.java | CmsXmlContent.addBookmarkForValue | protected void addBookmarkForValue(I_CmsXmlContentValue value, String path, Locale locale, boolean enabled) {
"""
Adds a bookmark for the given value.<p>
@param value the value to bookmark
@param path the lookup path to use for the bookmark
@param locale the locale to use for the bookmark
@param enabled if true, the value is enabled, if false it is disabled
"""
addBookmark(path, locale, enabled, value);
} | java | protected void addBookmarkForValue(I_CmsXmlContentValue value, String path, Locale locale, boolean enabled) {
addBookmark(path, locale, enabled, value);
} | [
"protected",
"void",
"addBookmarkForValue",
"(",
"I_CmsXmlContentValue",
"value",
",",
"String",
"path",
",",
"Locale",
"locale",
",",
"boolean",
"enabled",
")",
"{",
"addBookmark",
"(",
"path",
",",
"locale",
",",
"enabled",
",",
"value",
")",
";",
"}"
] | Adds a bookmark for the given value.<p>
@param value the value to bookmark
@param path the lookup path to use for the bookmark
@param locale the locale to use for the bookmark
@param enabled if true, the value is enabled, if false it is disabled | [
"Adds",
"a",
"bookmark",
"for",
"the",
"given",
"value",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/content/CmsXmlContent.java#L847-L850 |
sawano/java-commons | src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java | AbstractValidate.exclusiveBetween | public <T, V extends Comparable<T>> V exclusiveBetween(final T start, final T end, final V value) {
"""
<p>Validate that the specified argument object fall between the two exclusive values specified; otherwise, throws an exception.</p>
<pre>Validate.exclusiveBetween(0, 2, 1);</pre>
@param <T>
the type of the argument start and end values
@param <V>
the type of the value
@param start
the exclusive start value, not null
@param end
the exclusive end value, not null
@param value
the object to validate, not null
@return the value
@throws IllegalArgumentValidationException
if the value falls outside the boundaries
@see #exclusiveBetween(Object, Object, Comparable, String, Object...)
"""
if (value.compareTo(start) <= 0 || value.compareTo(end) >= 0) {
fail(String.format(DEFAULT_EXCLUSIVE_BETWEEN_EX_MESSAGE, value, start, end));
}
return value;
} | java | public <T, V extends Comparable<T>> V exclusiveBetween(final T start, final T end, final V value) {
if (value.compareTo(start) <= 0 || value.compareTo(end) >= 0) {
fail(String.format(DEFAULT_EXCLUSIVE_BETWEEN_EX_MESSAGE, value, start, end));
}
return value;
} | [
"public",
"<",
"T",
",",
"V",
"extends",
"Comparable",
"<",
"T",
">",
">",
"V",
"exclusiveBetween",
"(",
"final",
"T",
"start",
",",
"final",
"T",
"end",
",",
"final",
"V",
"value",
")",
"{",
"if",
"(",
"value",
".",
"compareTo",
"(",
"start",
")",
"<=",
"0",
"||",
"value",
".",
"compareTo",
"(",
"end",
")",
">=",
"0",
")",
"{",
"fail",
"(",
"String",
".",
"format",
"(",
"DEFAULT_EXCLUSIVE_BETWEEN_EX_MESSAGE",
",",
"value",
",",
"start",
",",
"end",
")",
")",
";",
"}",
"return",
"value",
";",
"}"
] | <p>Validate that the specified argument object fall between the two exclusive values specified; otherwise, throws an exception.</p>
<pre>Validate.exclusiveBetween(0, 2, 1);</pre>
@param <T>
the type of the argument start and end values
@param <V>
the type of the value
@param start
the exclusive start value, not null
@param end
the exclusive end value, not null
@param value
the object to validate, not null
@return the value
@throws IllegalArgumentValidationException
if the value falls outside the boundaries
@see #exclusiveBetween(Object, Object, Comparable, String, Object...) | [
"<p",
">",
"Validate",
"that",
"the",
"specified",
"argument",
"object",
"fall",
"between",
"the",
"two",
"exclusive",
"values",
"specified",
";",
"otherwise",
"throws",
"an",
"exception",
".",
"<",
"/",
"p",
">",
"<pre",
">",
"Validate",
".",
"exclusiveBetween",
"(",
"0",
"2",
"1",
")",
";",
"<",
"/",
"pre",
">"
] | train | https://github.com/sawano/java-commons/blob/6f219c9e8dec4401dbe528d17ae6ec1ef9c0d284/src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java#L1387-L1392 |
OpenLiberty/open-liberty | dev/com.ibm.ws.repository/src/com/ibm/ws/repository/transport/client/RestClient.java | RestClient.getAttachmentMetaData | public Attachment getAttachmentMetaData(String assetId, String attachmentId) throws IOException, BadVersionException, RequestFailureException {
"""
Returns the meta data about an attachment
@param assetId
The ID of the asset owning the attachment
@param attachmentId
The ID of the attachment
@return The attachment meta data
@throws IOException
@throws RequestFailureException
"""
// At the moment can only get all attachments
Asset ass = getAsset(assetId);
List<Attachment> allAttachments = ass.getAttachments();
for (Attachment attachment : allAttachments) {
if (attachmentId.equals(attachment.get_id())) {
return attachment;
}
}
// Didn't find it so just return null
return null;
} | java | public Attachment getAttachmentMetaData(String assetId, String attachmentId) throws IOException, BadVersionException, RequestFailureException {
// At the moment can only get all attachments
Asset ass = getAsset(assetId);
List<Attachment> allAttachments = ass.getAttachments();
for (Attachment attachment : allAttachments) {
if (attachmentId.equals(attachment.get_id())) {
return attachment;
}
}
// Didn't find it so just return null
return null;
} | [
"public",
"Attachment",
"getAttachmentMetaData",
"(",
"String",
"assetId",
",",
"String",
"attachmentId",
")",
"throws",
"IOException",
",",
"BadVersionException",
",",
"RequestFailureException",
"{",
"// At the moment can only get all attachments",
"Asset",
"ass",
"=",
"getAsset",
"(",
"assetId",
")",
";",
"List",
"<",
"Attachment",
">",
"allAttachments",
"=",
"ass",
".",
"getAttachments",
"(",
")",
";",
"for",
"(",
"Attachment",
"attachment",
":",
"allAttachments",
")",
"{",
"if",
"(",
"attachmentId",
".",
"equals",
"(",
"attachment",
".",
"get_id",
"(",
")",
")",
")",
"{",
"return",
"attachment",
";",
"}",
"}",
"// Didn't find it so just return null",
"return",
"null",
";",
"}"
] | Returns the meta data about an attachment
@param assetId
The ID of the asset owning the attachment
@param attachmentId
The ID of the attachment
@return The attachment meta data
@throws IOException
@throws RequestFailureException | [
"Returns",
"the",
"meta",
"data",
"about",
"an",
"attachment"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.repository/src/com/ibm/ws/repository/transport/client/RestClient.java#L503-L515 |
kiegroup/jbpm | jbpm-runtime-manager/src/main/java/org/jbpm/runtime/manager/impl/RuntimeEnvironmentBuilder.java | RuntimeEnvironmentBuilder.getDefault | public static RuntimeEnvironmentBuilder getDefault(String groupId, String artifactId, String version, String kbaseName, String ksessionName) {
"""
Provides default configuration of <code>RuntimeEnvironmentBuilder</code> that is based on:
<ul>
<li>DefaultRuntimeEnvironment</li>
</ul>
This one is tailored to works smoothly with kjars as the notion of kbase and ksessions
@param groupId group id of kjar
@param artifactId artifact id of kjar
@param version version number of kjar
@param kbaseName name of the kbase defined in kmodule.xml stored in kjar
@param ksessionName name of the ksession define in kmodule.xml stored in kjar
@return new instance of <code>RuntimeEnvironmentBuilder</code> that is already preconfigured with defaults
@see DefaultRuntimeEnvironment
"""
KieServices ks = KieServices.Factory.get();
return getDefault(ks.newReleaseId(groupId, artifactId, version), kbaseName, ksessionName);
} | java | public static RuntimeEnvironmentBuilder getDefault(String groupId, String artifactId, String version, String kbaseName, String ksessionName) {
KieServices ks = KieServices.Factory.get();
return getDefault(ks.newReleaseId(groupId, artifactId, version), kbaseName, ksessionName);
} | [
"public",
"static",
"RuntimeEnvironmentBuilder",
"getDefault",
"(",
"String",
"groupId",
",",
"String",
"artifactId",
",",
"String",
"version",
",",
"String",
"kbaseName",
",",
"String",
"ksessionName",
")",
"{",
"KieServices",
"ks",
"=",
"KieServices",
".",
"Factory",
".",
"get",
"(",
")",
";",
"return",
"getDefault",
"(",
"ks",
".",
"newReleaseId",
"(",
"groupId",
",",
"artifactId",
",",
"version",
")",
",",
"kbaseName",
",",
"ksessionName",
")",
";",
"}"
] | Provides default configuration of <code>RuntimeEnvironmentBuilder</code> that is based on:
<ul>
<li>DefaultRuntimeEnvironment</li>
</ul>
This one is tailored to works smoothly with kjars as the notion of kbase and ksessions
@param groupId group id of kjar
@param artifactId artifact id of kjar
@param version version number of kjar
@param kbaseName name of the kbase defined in kmodule.xml stored in kjar
@param ksessionName name of the ksession define in kmodule.xml stored in kjar
@return new instance of <code>RuntimeEnvironmentBuilder</code> that is already preconfigured with defaults
@see DefaultRuntimeEnvironment | [
"Provides",
"default",
"configuration",
"of",
"<code",
">",
"RuntimeEnvironmentBuilder<",
"/",
"code",
">",
"that",
"is",
"based",
"on",
":",
"<ul",
">",
"<li",
">",
"DefaultRuntimeEnvironment<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"This",
"one",
"is",
"tailored",
"to",
"works",
"smoothly",
"with",
"kjars",
"as",
"the",
"notion",
"of",
"kbase",
"and",
"ksessions",
"@param",
"groupId",
"group",
"id",
"of",
"kjar",
"@param",
"artifactId",
"artifact",
"id",
"of",
"kjar",
"@param",
"version",
"version",
"number",
"of",
"kjar",
"@param",
"kbaseName",
"name",
"of",
"the",
"kbase",
"defined",
"in",
"kmodule",
".",
"xml",
"stored",
"in",
"kjar",
"@param",
"ksessionName",
"name",
"of",
"the",
"ksession",
"define",
"in",
"kmodule",
".",
"xml",
"stored",
"in",
"kjar",
"@return",
"new",
"instance",
"of",
"<code",
">",
"RuntimeEnvironmentBuilder<",
"/",
"code",
">",
"that",
"is",
"already",
"preconfigured",
"with",
"defaults"
] | train | https://github.com/kiegroup/jbpm/blob/c3473c728aa382ebbea01e380c5e754a96647b82/jbpm-runtime-manager/src/main/java/org/jbpm/runtime/manager/impl/RuntimeEnvironmentBuilder.java#L163-L166 |
davidmarquis/fluent-interface-proxy | src/main/java/com/fluentinterface/beans/reflect/Property.java | Property.get | public Object get(Object obj) throws ReflectionException {
"""
Returns the value of the representation of this property from the specified object.
<p> The underlying property's value is obtained trying to invoke the {@code readMethod}.
<p> If this {@link Property} object has no public {@code readMethod},
it is considered write-only, and the action will be prevented throwing
a {@link ReflectionException}.
<p> The value is automatically wrapped in an object if it has a primitive type.
@param obj object from which the property's value is to be extracted
@return the value of the represented property in object {@code obj}
@throws ReflectionException if access to the underlying method throws an exception
@throws ReflectionException if this property is write-only (no public readMethod)
"""
try {
if (isPublic(readMethod)) {
return readMethod.invoke(obj);
} else {
throw new ReflectionException("Cannot get the value of " + this + ", as it is write-only.");
}
} catch (Exception e) {
throw new ReflectionException("Cannot get the value of " + this + " in object " + obj, e);
}
} | java | public Object get(Object obj) throws ReflectionException {
try {
if (isPublic(readMethod)) {
return readMethod.invoke(obj);
} else {
throw new ReflectionException("Cannot get the value of " + this + ", as it is write-only.");
}
} catch (Exception e) {
throw new ReflectionException("Cannot get the value of " + this + " in object " + obj, e);
}
} | [
"public",
"Object",
"get",
"(",
"Object",
"obj",
")",
"throws",
"ReflectionException",
"{",
"try",
"{",
"if",
"(",
"isPublic",
"(",
"readMethod",
")",
")",
"{",
"return",
"readMethod",
".",
"invoke",
"(",
"obj",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ReflectionException",
"(",
"\"Cannot get the value of \"",
"+",
"this",
"+",
"\", as it is write-only.\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ReflectionException",
"(",
"\"Cannot get the value of \"",
"+",
"this",
"+",
"\" in object \"",
"+",
"obj",
",",
"e",
")",
";",
"}",
"}"
] | Returns the value of the representation of this property from the specified object.
<p> The underlying property's value is obtained trying to invoke the {@code readMethod}.
<p> If this {@link Property} object has no public {@code readMethod},
it is considered write-only, and the action will be prevented throwing
a {@link ReflectionException}.
<p> The value is automatically wrapped in an object if it has a primitive type.
@param obj object from which the property's value is to be extracted
@return the value of the represented property in object {@code obj}
@throws ReflectionException if access to the underlying method throws an exception
@throws ReflectionException if this property is write-only (no public readMethod) | [
"Returns",
"the",
"value",
"of",
"the",
"representation",
"of",
"this",
"property",
"from",
"the",
"specified",
"object",
"."
] | train | https://github.com/davidmarquis/fluent-interface-proxy/blob/8e72fff6cd1f496c76a01773269caead994fea65/src/main/java/com/fluentinterface/beans/reflect/Property.java#L403-L413 |
minio/minio-java | api/src/main/java/io/minio/ServerSideEncryption.java | ServerSideEncryption.withManagedKeys | public static ServerSideEncryption withManagedKeys(String keyId, Map<String,String> context)
throws InvalidArgumentException, UnsupportedEncodingException {
"""
Create a new server-side-encryption object for encryption using a KMS (a.k.a. SSE-KMS).
@param keyId specifies the customer-master-key (CMK) and must not be null.
@param context is the encryption context. If the context is null no context is used.
@return an instance of ServerSideEncryption implementing SSE-KMS.
"""
if (keyId == null) {
throw new InvalidArgumentException("The key-ID cannot be null");
}
if (context == null) {
return new ServerSideEncryptionKms(keyId, Optional.empty());
}
StringBuilder builder = new StringBuilder();
int i = 0;
builder.append('{');
for (Entry<String,String> entry : context.entrySet()) {
builder.append('"');
builder.append(entry.getKey());
builder.append('"');
builder.append(':');
builder.append('"');
builder.append(entry.getValue());
builder.append('"');
if (i < context.entrySet().size() - 1) {
builder.append(',');
}
}
builder.append('}');
String contextString = BaseEncoding.base64().encode(builder.toString().getBytes("UTF-8"));
return new ServerSideEncryptionKms(keyId, Optional.of(contextString));
} | java | public static ServerSideEncryption withManagedKeys(String keyId, Map<String,String> context)
throws InvalidArgumentException, UnsupportedEncodingException {
if (keyId == null) {
throw new InvalidArgumentException("The key-ID cannot be null");
}
if (context == null) {
return new ServerSideEncryptionKms(keyId, Optional.empty());
}
StringBuilder builder = new StringBuilder();
int i = 0;
builder.append('{');
for (Entry<String,String> entry : context.entrySet()) {
builder.append('"');
builder.append(entry.getKey());
builder.append('"');
builder.append(':');
builder.append('"');
builder.append(entry.getValue());
builder.append('"');
if (i < context.entrySet().size() - 1) {
builder.append(',');
}
}
builder.append('}');
String contextString = BaseEncoding.base64().encode(builder.toString().getBytes("UTF-8"));
return new ServerSideEncryptionKms(keyId, Optional.of(contextString));
} | [
"public",
"static",
"ServerSideEncryption",
"withManagedKeys",
"(",
"String",
"keyId",
",",
"Map",
"<",
"String",
",",
"String",
">",
"context",
")",
"throws",
"InvalidArgumentException",
",",
"UnsupportedEncodingException",
"{",
"if",
"(",
"keyId",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The key-ID cannot be null\"",
")",
";",
"}",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"return",
"new",
"ServerSideEncryptionKms",
"(",
"keyId",
",",
"Optional",
".",
"empty",
"(",
")",
")",
";",
"}",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"i",
"=",
"0",
";",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"context",
".",
"entrySet",
"(",
")",
")",
"{",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"builder",
".",
"append",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"builder",
".",
"append",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"if",
"(",
"i",
"<",
"context",
".",
"entrySet",
"(",
")",
".",
"size",
"(",
")",
"-",
"1",
")",
"{",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"String",
"contextString",
"=",
"BaseEncoding",
".",
"base64",
"(",
")",
".",
"encode",
"(",
"builder",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
")",
";",
"return",
"new",
"ServerSideEncryptionKms",
"(",
"keyId",
",",
"Optional",
".",
"of",
"(",
"contextString",
")",
")",
";",
"}"
] | Create a new server-side-encryption object for encryption using a KMS (a.k.a. SSE-KMS).
@param keyId specifies the customer-master-key (CMK) and must not be null.
@param context is the encryption context. If the context is null no context is used.
@return an instance of ServerSideEncryption implementing SSE-KMS. | [
"Create",
"a",
"new",
"server",
"-",
"side",
"-",
"encryption",
"object",
"for",
"encryption",
"using",
"a",
"KMS",
"(",
"a",
".",
"k",
".",
"a",
".",
"SSE",
"-",
"KMS",
")",
"."
] | train | https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/ServerSideEncryption.java#L142-L169 |
google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/Parameter.java | Parameter.isAssignableTo | boolean isAssignableTo(Parameter target, VisitorState state) {
"""
Return true if this parameter is assignable to the target parameter. This will consider
subclassing, autoboxing and null.
"""
if (state.getTypes().isSameType(type(), Type.noType)
|| state.getTypes().isSameType(target.type(), Type.noType)) {
return false;
}
try {
return state.getTypes().isAssignable(type(), target.type());
} catch (CompletionFailure e) {
// Report completion errors to avoid e.g. https://github.com/bazelbuild/bazel/issues/4105
Check.instance(state.context)
.completionError((DiagnosticPosition) state.getPath().getLeaf(), e);
return false;
}
} | java | boolean isAssignableTo(Parameter target, VisitorState state) {
if (state.getTypes().isSameType(type(), Type.noType)
|| state.getTypes().isSameType(target.type(), Type.noType)) {
return false;
}
try {
return state.getTypes().isAssignable(type(), target.type());
} catch (CompletionFailure e) {
// Report completion errors to avoid e.g. https://github.com/bazelbuild/bazel/issues/4105
Check.instance(state.context)
.completionError((DiagnosticPosition) state.getPath().getLeaf(), e);
return false;
}
} | [
"boolean",
"isAssignableTo",
"(",
"Parameter",
"target",
",",
"VisitorState",
"state",
")",
"{",
"if",
"(",
"state",
".",
"getTypes",
"(",
")",
".",
"isSameType",
"(",
"type",
"(",
")",
",",
"Type",
".",
"noType",
")",
"||",
"state",
".",
"getTypes",
"(",
")",
".",
"isSameType",
"(",
"target",
".",
"type",
"(",
")",
",",
"Type",
".",
"noType",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"return",
"state",
".",
"getTypes",
"(",
")",
".",
"isAssignable",
"(",
"type",
"(",
")",
",",
"target",
".",
"type",
"(",
")",
")",
";",
"}",
"catch",
"(",
"CompletionFailure",
"e",
")",
"{",
"// Report completion errors to avoid e.g. https://github.com/bazelbuild/bazel/issues/4105",
"Check",
".",
"instance",
"(",
"state",
".",
"context",
")",
".",
"completionError",
"(",
"(",
"DiagnosticPosition",
")",
"state",
".",
"getPath",
"(",
")",
".",
"getLeaf",
"(",
")",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Return true if this parameter is assignable to the target parameter. This will consider
subclassing, autoboxing and null. | [
"Return",
"true",
"if",
"this",
"parameter",
"is",
"assignable",
"to",
"the",
"target",
"parameter",
".",
"This",
"will",
"consider",
"subclassing",
"autoboxing",
"and",
"null",
"."
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/Parameter.java#L115-L128 |
aws/aws-sdk-java | aws-java-sdk-elasticsearch/src/main/java/com/amazonaws/services/elasticsearch/model/UpdateElasticsearchDomainConfigRequest.java | UpdateElasticsearchDomainConfigRequest.withAdvancedOptions | public UpdateElasticsearchDomainConfigRequest withAdvancedOptions(java.util.Map<String, String> advancedOptions) {
"""
<p>
Modifies the advanced option to allow references to indices in an HTTP request body. Must be <code>false</code>
when configuring access to individual sub-resources. By default, the value is <code>true</code>. See <a href=
"http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-createupdatedomains.html#es-createdomain-configure-advanced-options"
target="_blank">Configuration Advanced Options</a> for more information.
</p>
@param advancedOptions
Modifies the advanced option to allow references to indices in an HTTP request body. Must be
<code>false</code> when configuring access to individual sub-resources. By default, the value is
<code>true</code>. See <a href=
"http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-createupdatedomains.html#es-createdomain-configure-advanced-options"
target="_blank">Configuration Advanced Options</a> for more information.
@return Returns a reference to this object so that method calls can be chained together.
"""
setAdvancedOptions(advancedOptions);
return this;
} | java | public UpdateElasticsearchDomainConfigRequest withAdvancedOptions(java.util.Map<String, String> advancedOptions) {
setAdvancedOptions(advancedOptions);
return this;
} | [
"public",
"UpdateElasticsearchDomainConfigRequest",
"withAdvancedOptions",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"advancedOptions",
")",
"{",
"setAdvancedOptions",
"(",
"advancedOptions",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Modifies the advanced option to allow references to indices in an HTTP request body. Must be <code>false</code>
when configuring access to individual sub-resources. By default, the value is <code>true</code>. See <a href=
"http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-createupdatedomains.html#es-createdomain-configure-advanced-options"
target="_blank">Configuration Advanced Options</a> for more information.
</p>
@param advancedOptions
Modifies the advanced option to allow references to indices in an HTTP request body. Must be
<code>false</code> when configuring access to individual sub-resources. By default, the value is
<code>true</code>. See <a href=
"http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-createupdatedomains.html#es-createdomain-configure-advanced-options"
target="_blank">Configuration Advanced Options</a> for more information.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Modifies",
"the",
"advanced",
"option",
"to",
"allow",
"references",
"to",
"indices",
"in",
"an",
"HTTP",
"request",
"body",
".",
"Must",
"be",
"<code",
">",
"false<",
"/",
"code",
">",
"when",
"configuring",
"access",
"to",
"individual",
"sub",
"-",
"resources",
".",
"By",
"default",
"the",
"value",
"is",
"<code",
">",
"true<",
"/",
"code",
">",
".",
"See",
"<a",
"href",
"=",
"http",
":",
"//",
"docs",
".",
"aws",
".",
"amazon",
".",
"com",
"/",
"elasticsearch",
"-",
"service",
"/",
"latest",
"/",
"developerguide",
"/",
"es",
"-",
"createupdatedomains",
".",
"html#es",
"-",
"createdomain",
"-",
"configure",
"-",
"advanced",
"-",
"options",
"target",
"=",
"_blank",
">",
"Configuration",
"Advanced",
"Options<",
"/",
"a",
">",
"for",
"more",
"information",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-elasticsearch/src/main/java/com/amazonaws/services/elasticsearch/model/UpdateElasticsearchDomainConfigRequest.java#L415-L418 |
alibaba/canal | client-adapter/elasticsearch/src/main/java/com/alibaba/otter/canal/client/adapter/es/service/ESSyncService.java | ESSyncService.mainTableInsert | private void mainTableInsert(ESSyncConfig config, Dml dml, Map<String, Object> data) {
"""
主表(单表)复杂字段insert
@param config es配置
@param dml dml信息
@param data 单行dml数据
"""
ESMapping mapping = config.getEsMapping();
String sql = mapping.getSql();
String condition = ESSyncUtil.pkConditionSql(mapping, data);
sql = ESSyncUtil.appendCondition(sql, condition);
DataSource ds = DatasourceConfig.DATA_SOURCES.get(config.getDataSourceKey());
if (logger.isTraceEnabled()) {
logger.trace("Main table insert to es index by query sql, destination:{}, table: {}, index: {}, sql: {}",
config.getDestination(),
dml.getTable(),
mapping.get_index(),
sql.replace("\n", " "));
}
Util.sqlRS(ds, sql, rs -> {
try {
while (rs.next()) {
Map<String, Object> esFieldData = new LinkedHashMap<>();
Object idVal = esTemplate.getESDataFromRS(mapping, rs, esFieldData);
if (logger.isTraceEnabled()) {
logger.trace(
"Main table insert to es index by query sql, destination:{}, table: {}, index: {}, id: {}",
config.getDestination(),
dml.getTable(),
mapping.get_index(),
idVal);
}
esTemplate.insert(mapping, idVal, esFieldData);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return 0;
});
} | java | private void mainTableInsert(ESSyncConfig config, Dml dml, Map<String, Object> data) {
ESMapping mapping = config.getEsMapping();
String sql = mapping.getSql();
String condition = ESSyncUtil.pkConditionSql(mapping, data);
sql = ESSyncUtil.appendCondition(sql, condition);
DataSource ds = DatasourceConfig.DATA_SOURCES.get(config.getDataSourceKey());
if (logger.isTraceEnabled()) {
logger.trace("Main table insert to es index by query sql, destination:{}, table: {}, index: {}, sql: {}",
config.getDestination(),
dml.getTable(),
mapping.get_index(),
sql.replace("\n", " "));
}
Util.sqlRS(ds, sql, rs -> {
try {
while (rs.next()) {
Map<String, Object> esFieldData = new LinkedHashMap<>();
Object idVal = esTemplate.getESDataFromRS(mapping, rs, esFieldData);
if (logger.isTraceEnabled()) {
logger.trace(
"Main table insert to es index by query sql, destination:{}, table: {}, index: {}, id: {}",
config.getDestination(),
dml.getTable(),
mapping.get_index(),
idVal);
}
esTemplate.insert(mapping, idVal, esFieldData);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return 0;
});
} | [
"private",
"void",
"mainTableInsert",
"(",
"ESSyncConfig",
"config",
",",
"Dml",
"dml",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"data",
")",
"{",
"ESMapping",
"mapping",
"=",
"config",
".",
"getEsMapping",
"(",
")",
";",
"String",
"sql",
"=",
"mapping",
".",
"getSql",
"(",
")",
";",
"String",
"condition",
"=",
"ESSyncUtil",
".",
"pkConditionSql",
"(",
"mapping",
",",
"data",
")",
";",
"sql",
"=",
"ESSyncUtil",
".",
"appendCondition",
"(",
"sql",
",",
"condition",
")",
";",
"DataSource",
"ds",
"=",
"DatasourceConfig",
".",
"DATA_SOURCES",
".",
"get",
"(",
"config",
".",
"getDataSourceKey",
"(",
")",
")",
";",
"if",
"(",
"logger",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"logger",
".",
"trace",
"(",
"\"Main table insert to es index by query sql, destination:{}, table: {}, index: {}, sql: {}\"",
",",
"config",
".",
"getDestination",
"(",
")",
",",
"dml",
".",
"getTable",
"(",
")",
",",
"mapping",
".",
"get_index",
"(",
")",
",",
"sql",
".",
"replace",
"(",
"\"\\n\"",
",",
"\" \"",
")",
")",
";",
"}",
"Util",
".",
"sqlRS",
"(",
"ds",
",",
"sql",
",",
"rs",
"->",
"{",
"try",
"{",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"esFieldData",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
")",
";",
"Object",
"idVal",
"=",
"esTemplate",
".",
"getESDataFromRS",
"(",
"mapping",
",",
"rs",
",",
"esFieldData",
")",
";",
"if",
"(",
"logger",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"logger",
".",
"trace",
"(",
"\"Main table insert to es index by query sql, destination:{}, table: {}, index: {}, id: {}\"",
",",
"config",
".",
"getDestination",
"(",
")",
",",
"dml",
".",
"getTable",
"(",
")",
",",
"mapping",
".",
"get_index",
"(",
")",
",",
"idVal",
")",
";",
"}",
"esTemplate",
".",
"insert",
"(",
"mapping",
",",
"idVal",
",",
"esFieldData",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"return",
"0",
";",
"}",
")",
";",
"}"
] | 主表(单表)复杂字段insert
@param config es配置
@param dml dml信息
@param data 单行dml数据 | [
"主表",
"(",
"单表",
")",
"复杂字段insert"
] | train | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/elasticsearch/src/main/java/com/alibaba/otter/canal/client/adapter/es/service/ESSyncService.java#L455-L489 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejbcontainer/util/ParsedScheduleExpression.java | ParsedScheduleExpression.getNextTimeout | public long getNextTimeout(long lastTimeout) {
"""
Determines the next timeout for the schedule expression.
@param lastTimeout the last timeout in milliseconds
@return the next timeout in milliseconds, or -1 if there are no more
future timeouts for the expression
@throws IllegalArgumentException if lastTimeout is before the start time
of the expression
"""
// Perform basic validation of lastTimeout, which should be a value that
// was previously returned from getFirstTimeout.
if (lastTimeout < start)
{
throw new IllegalArgumentException("last timeout " + lastTimeout + " is before start time " + start);
}
if (lastTimeout > end)
{
throw new IllegalArgumentException("last timeout " + lastTimeout + " is after end time " + end);
}
if (lastTimeout % 1000 != 0) // d666295
{
throw new IllegalArgumentException("last timeout " + lastTimeout + " is mid-second");
}
return getTimeout(lastTimeout, true);
} | java | public long getNextTimeout(long lastTimeout)
{
// Perform basic validation of lastTimeout, which should be a value that
// was previously returned from getFirstTimeout.
if (lastTimeout < start)
{
throw new IllegalArgumentException("last timeout " + lastTimeout + " is before start time " + start);
}
if (lastTimeout > end)
{
throw new IllegalArgumentException("last timeout " + lastTimeout + " is after end time " + end);
}
if (lastTimeout % 1000 != 0) // d666295
{
throw new IllegalArgumentException("last timeout " + lastTimeout + " is mid-second");
}
return getTimeout(lastTimeout, true);
} | [
"public",
"long",
"getNextTimeout",
"(",
"long",
"lastTimeout",
")",
"{",
"// Perform basic validation of lastTimeout, which should be a value that",
"// was previously returned from getFirstTimeout.",
"if",
"(",
"lastTimeout",
"<",
"start",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"last timeout \"",
"+",
"lastTimeout",
"+",
"\" is before start time \"",
"+",
"start",
")",
";",
"}",
"if",
"(",
"lastTimeout",
">",
"end",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"last timeout \"",
"+",
"lastTimeout",
"+",
"\" is after end time \"",
"+",
"end",
")",
";",
"}",
"if",
"(",
"lastTimeout",
"%",
"1000",
"!=",
"0",
")",
"// d666295",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"last timeout \"",
"+",
"lastTimeout",
"+",
"\" is mid-second\"",
")",
";",
"}",
"return",
"getTimeout",
"(",
"lastTimeout",
",",
"true",
")",
";",
"}"
] | Determines the next timeout for the schedule expression.
@param lastTimeout the last timeout in milliseconds
@return the next timeout in milliseconds, or -1 if there are no more
future timeouts for the expression
@throws IllegalArgumentException if lastTimeout is before the start time
of the expression | [
"Determines",
"the",
"next",
"timeout",
"for",
"the",
"schedule",
"expression",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejbcontainer/util/ParsedScheduleExpression.java#L466-L487 |
dnsjava/dnsjava | org/xbill/DNS/TSIG.java | TSIG.verify | private static boolean
verify(Mac mac, byte [] signature, boolean truncation_ok) {
"""
Verifies the data (computes the secure hash and compares it to the input)
@param mac The HMAC generator
@param signature The signature to compare against
@param truncation_ok If true, the signature may be truncated; only the
number of bytes in the provided signature are compared.
@return true if the signature matches, false otherwise
"""
byte [] expected = mac.doFinal();
if (truncation_ok && signature.length < expected.length) {
byte [] truncated = new byte[signature.length];
System.arraycopy(expected, 0, truncated, 0, truncated.length);
expected = truncated;
}
return Arrays.equals(signature, expected);
} | java | private static boolean
verify(Mac mac, byte [] signature, boolean truncation_ok) {
byte [] expected = mac.doFinal();
if (truncation_ok && signature.length < expected.length) {
byte [] truncated = new byte[signature.length];
System.arraycopy(expected, 0, truncated, 0, truncated.length);
expected = truncated;
}
return Arrays.equals(signature, expected);
} | [
"private",
"static",
"boolean",
"verify",
"(",
"Mac",
"mac",
",",
"byte",
"[",
"]",
"signature",
",",
"boolean",
"truncation_ok",
")",
"{",
"byte",
"[",
"]",
"expected",
"=",
"mac",
".",
"doFinal",
"(",
")",
";",
"if",
"(",
"truncation_ok",
"&&",
"signature",
".",
"length",
"<",
"expected",
".",
"length",
")",
"{",
"byte",
"[",
"]",
"truncated",
"=",
"new",
"byte",
"[",
"signature",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"expected",
",",
"0",
",",
"truncated",
",",
"0",
",",
"truncated",
".",
"length",
")",
";",
"expected",
"=",
"truncated",
";",
"}",
"return",
"Arrays",
".",
"equals",
"(",
"signature",
",",
"expected",
")",
";",
"}"
] | Verifies the data (computes the secure hash and compares it to the input)
@param mac The HMAC generator
@param signature The signature to compare against
@param truncation_ok If true, the signature may be truncated; only the
number of bytes in the provided signature are compared.
@return true if the signature matches, false otherwise | [
"Verifies",
"the",
"data",
"(",
"computes",
"the",
"secure",
"hash",
"and",
"compares",
"it",
"to",
"the",
"input",
")"
] | train | https://github.com/dnsjava/dnsjava/blob/d97b6a0685d59143372bb392ab591dd8dd840b61/org/xbill/DNS/TSIG.java#L109-L118 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/painter/TitlePaneMaximizeButtonPainter.java | TitlePaneMaximizeButtonPainter.paintMaximizeHover | private void paintMaximizeHover(Graphics2D g, JComponent c, int width, int height) {
"""
Paint the foreground maximized button mouse-over state.
@param g the Graphics2D context to paint with.
@param c the component.
@param width the width of the component.
@param height the height of the component.
"""
maximizePainter.paintHover(g, c, width, height);
} | java | private void paintMaximizeHover(Graphics2D g, JComponent c, int width, int height) {
maximizePainter.paintHover(g, c, width, height);
} | [
"private",
"void",
"paintMaximizeHover",
"(",
"Graphics2D",
"g",
",",
"JComponent",
"c",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"maximizePainter",
".",
"paintHover",
"(",
"g",
",",
"c",
",",
"width",
",",
"height",
")",
";",
"}"
] | Paint the foreground maximized button mouse-over state.
@param g the Graphics2D context to paint with.
@param c the component.
@param width the width of the component.
@param height the height of the component. | [
"Paint",
"the",
"foreground",
"maximized",
"button",
"mouse",
"-",
"over",
"state",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/TitlePaneMaximizeButtonPainter.java#L185-L187 |
apache/groovy | src/main/groovy/groovy/util/Node.java | Node.breadthFirst | public void breadthFirst(Map<String, Object> options, Closure c) {
"""
Calls the provided closure for all the nodes in the tree
using a breadth-first traversal.
A boolean 'preorder' options is supported.
@param options map containing options
@param c the closure to run for each node (a one or two parameter can be used; if one parameter is given the
closure will be passed the node, for a two param closure the second parameter will be the level).
@since 2.5.0
"""
boolean preorder = Boolean.valueOf(options.get("preorder").toString());
if (preorder) callClosureForNode(c, this, 1);
breadthFirstRest(preorder, 2, c);
if (!preorder) callClosureForNode(c, this, 1);
} | java | public void breadthFirst(Map<String, Object> options, Closure c) {
boolean preorder = Boolean.valueOf(options.get("preorder").toString());
if (preorder) callClosureForNode(c, this, 1);
breadthFirstRest(preorder, 2, c);
if (!preorder) callClosureForNode(c, this, 1);
} | [
"public",
"void",
"breadthFirst",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"options",
",",
"Closure",
"c",
")",
"{",
"boolean",
"preorder",
"=",
"Boolean",
".",
"valueOf",
"(",
"options",
".",
"get",
"(",
"\"preorder\"",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"preorder",
")",
"callClosureForNode",
"(",
"c",
",",
"this",
",",
"1",
")",
";",
"breadthFirstRest",
"(",
"preorder",
",",
"2",
",",
"c",
")",
";",
"if",
"(",
"!",
"preorder",
")",
"callClosureForNode",
"(",
"c",
",",
"this",
",",
"1",
")",
";",
"}"
] | Calls the provided closure for all the nodes in the tree
using a breadth-first traversal.
A boolean 'preorder' options is supported.
@param options map containing options
@param c the closure to run for each node (a one or two parameter can be used; if one parameter is given the
closure will be passed the node, for a two param closure the second parameter will be the level).
@since 2.5.0 | [
"Calls",
"the",
"provided",
"closure",
"for",
"all",
"the",
"nodes",
"in",
"the",
"tree",
"using",
"a",
"breadth",
"-",
"first",
"traversal",
".",
"A",
"boolean",
"preorder",
"options",
"is",
"supported",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L711-L716 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/ServletStartedListener.java | ServletStartedListener.updateSecurityMetadataWithRunAs | public void updateSecurityMetadataWithRunAs(SecurityMetadata securityMetadataFromDD, IServletConfig servletConfig) {
"""
Updates the security metadata object (which at this time only has the deployment descriptor info)
with the runAs roles defined in the servlet. The sources are the web.xml, static annotations,
and dynamic annotations.
@param securityMetadataFromDD the security metadata processed from the deployment descriptor
@param servletConfig the configuration of the servlet
"""
String runAs = servletConfig.getRunAsRole();
if (runAs != null) {
String servletName = servletConfig.getServletName();
//only add if there is no run-as entry in web.xml
Map<String, String> servletNameToRunAsRole = securityMetadataFromDD.getRunAsMap();
if (servletNameToRunAsRole.get(servletName) == null) {
servletNameToRunAsRole.put(servletName, runAs);
List<String> allRoles = securityMetadataFromDD.getRoles();
if (!allRoles.contains(runAs)) {
allRoles.add(runAs);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Added runAs role: " + runAs);
}
}
}
} | java | public void updateSecurityMetadataWithRunAs(SecurityMetadata securityMetadataFromDD, IServletConfig servletConfig) {
String runAs = servletConfig.getRunAsRole();
if (runAs != null) {
String servletName = servletConfig.getServletName();
//only add if there is no run-as entry in web.xml
Map<String, String> servletNameToRunAsRole = securityMetadataFromDD.getRunAsMap();
if (servletNameToRunAsRole.get(servletName) == null) {
servletNameToRunAsRole.put(servletName, runAs);
List<String> allRoles = securityMetadataFromDD.getRoles();
if (!allRoles.contains(runAs)) {
allRoles.add(runAs);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Added runAs role: " + runAs);
}
}
}
} | [
"public",
"void",
"updateSecurityMetadataWithRunAs",
"(",
"SecurityMetadata",
"securityMetadataFromDD",
",",
"IServletConfig",
"servletConfig",
")",
"{",
"String",
"runAs",
"=",
"servletConfig",
".",
"getRunAsRole",
"(",
")",
";",
"if",
"(",
"runAs",
"!=",
"null",
")",
"{",
"String",
"servletName",
"=",
"servletConfig",
".",
"getServletName",
"(",
")",
";",
"//only add if there is no run-as entry in web.xml",
"Map",
"<",
"String",
",",
"String",
">",
"servletNameToRunAsRole",
"=",
"securityMetadataFromDD",
".",
"getRunAsMap",
"(",
")",
";",
"if",
"(",
"servletNameToRunAsRole",
".",
"get",
"(",
"servletName",
")",
"==",
"null",
")",
"{",
"servletNameToRunAsRole",
".",
"put",
"(",
"servletName",
",",
"runAs",
")",
";",
"List",
"<",
"String",
">",
"allRoles",
"=",
"securityMetadataFromDD",
".",
"getRoles",
"(",
")",
";",
"if",
"(",
"!",
"allRoles",
".",
"contains",
"(",
"runAs",
")",
")",
"{",
"allRoles",
".",
"add",
"(",
"runAs",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Added runAs role: \"",
"+",
"runAs",
")",
";",
"}",
"}",
"}",
"}"
] | Updates the security metadata object (which at this time only has the deployment descriptor info)
with the runAs roles defined in the servlet. The sources are the web.xml, static annotations,
and dynamic annotations.
@param securityMetadataFromDD the security metadata processed from the deployment descriptor
@param servletConfig the configuration of the servlet | [
"Updates",
"the",
"security",
"metadata",
"object",
"(",
"which",
"at",
"this",
"time",
"only",
"has",
"the",
"deployment",
"descriptor",
"info",
")",
"with",
"the",
"runAs",
"roles",
"defined",
"in",
"the",
"servlet",
".",
"The",
"sources",
"are",
"the",
"web",
".",
"xml",
"static",
"annotations",
"and",
"dynamic",
"annotations",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/ServletStartedListener.java#L230-L247 |
Daytron/SimpleDialogFX | src/main/java/com/github/daytron/simpledialogfx/dialog/Dialog.java | Dialog.setDetailsFont | public void setDetailsFont(String font_family, int font_size) {
"""
Sets both details label's font family and size.
@param font_family Font family in <code>Strings</code>
@param font_size Font size in <code>integer</code> (pixels)
"""
this.detailsLabel
.setStyle("-fx-font-family: \"" + font_family + "\";"
+ "-fx-font-size:" + Integer.toString(font_size) + "px;");
} | java | public void setDetailsFont(String font_family, int font_size) {
this.detailsLabel
.setStyle("-fx-font-family: \"" + font_family + "\";"
+ "-fx-font-size:" + Integer.toString(font_size) + "px;");
} | [
"public",
"void",
"setDetailsFont",
"(",
"String",
"font_family",
",",
"int",
"font_size",
")",
"{",
"this",
".",
"detailsLabel",
".",
"setStyle",
"(",
"\"-fx-font-family: \\\"\"",
"+",
"font_family",
"+",
"\"\\\";\"",
"+",
"\"-fx-font-size:\"",
"+",
"Integer",
".",
"toString",
"(",
"font_size",
")",
"+",
"\"px;\"",
")",
";",
"}"
] | Sets both details label's font family and size.
@param font_family Font family in <code>Strings</code>
@param font_size Font size in <code>integer</code> (pixels) | [
"Sets",
"both",
"details",
"label",
"s",
"font",
"family",
"and",
"size",
"."
] | train | https://github.com/Daytron/SimpleDialogFX/blob/54e813dbb0ebabad8e0a81b6b5f05e518747611e/src/main/java/com/github/daytron/simpledialogfx/dialog/Dialog.java#L870-L874 |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/ftp/Ftp.java | Ftp.download | public void download(String path, String fileName, File outFile) {
"""
下载文件
@param path 文件路径
@param fileName 文件名
@param outFile 输出文件或目录
"""
if (outFile.isDirectory()) {
outFile = new File(outFile, fileName);
}
if (false == outFile.exists()) {
FileUtil.touch(outFile);
}
try (OutputStream out = FileUtil.getOutputStream(outFile)) {
download(path, fileName, out);
} catch (IOException e) {
throw new FtpException(e);
}
} | java | public void download(String path, String fileName, File outFile) {
if (outFile.isDirectory()) {
outFile = new File(outFile, fileName);
}
if (false == outFile.exists()) {
FileUtil.touch(outFile);
}
try (OutputStream out = FileUtil.getOutputStream(outFile)) {
download(path, fileName, out);
} catch (IOException e) {
throw new FtpException(e);
}
} | [
"public",
"void",
"download",
"(",
"String",
"path",
",",
"String",
"fileName",
",",
"File",
"outFile",
")",
"{",
"if",
"(",
"outFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"outFile",
"=",
"new",
"File",
"(",
"outFile",
",",
"fileName",
")",
";",
"}",
"if",
"(",
"false",
"==",
"outFile",
".",
"exists",
"(",
")",
")",
"{",
"FileUtil",
".",
"touch",
"(",
"outFile",
")",
";",
"}",
"try",
"(",
"OutputStream",
"out",
"=",
"FileUtil",
".",
"getOutputStream",
"(",
"outFile",
")",
")",
"{",
"download",
"(",
"path",
",",
"fileName",
",",
"out",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"FtpException",
"(",
"e",
")",
";",
"}",
"}"
] | 下载文件
@param path 文件路径
@param fileName 文件名
@param outFile 输出文件或目录 | [
"下载文件"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/ftp/Ftp.java#L447-L459 |
Azure/azure-sdk-for-java | edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/DevicesInner.java | DevicesInner.createOrUpdateAsync | public Observable<DataBoxEdgeDeviceInner> createOrUpdateAsync(String deviceName, String resourceGroupName, DataBoxEdgeDeviceInner dataBoxEdgeDevice) {
"""
Creates or updates a Data Box Edge/Gateway resource.
@param deviceName The device name.
@param resourceGroupName The resource group name.
@param dataBoxEdgeDevice The resource object.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createOrUpdateWithServiceResponseAsync(deviceName, resourceGroupName, dataBoxEdgeDevice).map(new Func1<ServiceResponse<DataBoxEdgeDeviceInner>, DataBoxEdgeDeviceInner>() {
@Override
public DataBoxEdgeDeviceInner call(ServiceResponse<DataBoxEdgeDeviceInner> response) {
return response.body();
}
});
} | java | public Observable<DataBoxEdgeDeviceInner> createOrUpdateAsync(String deviceName, String resourceGroupName, DataBoxEdgeDeviceInner dataBoxEdgeDevice) {
return createOrUpdateWithServiceResponseAsync(deviceName, resourceGroupName, dataBoxEdgeDevice).map(new Func1<ServiceResponse<DataBoxEdgeDeviceInner>, DataBoxEdgeDeviceInner>() {
@Override
public DataBoxEdgeDeviceInner call(ServiceResponse<DataBoxEdgeDeviceInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DataBoxEdgeDeviceInner",
">",
"createOrUpdateAsync",
"(",
"String",
"deviceName",
",",
"String",
"resourceGroupName",
",",
"DataBoxEdgeDeviceInner",
"dataBoxEdgeDevice",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"deviceName",
",",
"resourceGroupName",
",",
"dataBoxEdgeDevice",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DataBoxEdgeDeviceInner",
">",
",",
"DataBoxEdgeDeviceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DataBoxEdgeDeviceInner",
"call",
"(",
"ServiceResponse",
"<",
"DataBoxEdgeDeviceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates or updates a Data Box Edge/Gateway resource.
@param deviceName The device name.
@param resourceGroupName The resource group name.
@param dataBoxEdgeDevice The resource object.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"or",
"updates",
"a",
"Data",
"Box",
"Edge",
"/",
"Gateway",
"resource",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/DevicesInner.java#L730-L737 |
tvesalainen/util | util/src/main/java/org/vesalainen/nio/file/attribute/UserAttrs.java | UserAttrs.setFloatAttribute | public static final void setFloatAttribute(Path path, String attribute, float value, LinkOption... options) throws IOException {
"""
Set user-defined-attribute
@param path
@param attribute user:attribute name. user: can be omitted.
@param value
@param options
@throws IOException
"""
attribute = attribute.startsWith("user:") ? attribute : "user:"+attribute;
Files.setAttribute(path, attribute, Primitives.writeFloat(value), options);
} | java | public static final void setFloatAttribute(Path path, String attribute, float value, LinkOption... options) throws IOException
{
attribute = attribute.startsWith("user:") ? attribute : "user:"+attribute;
Files.setAttribute(path, attribute, Primitives.writeFloat(value), options);
} | [
"public",
"static",
"final",
"void",
"setFloatAttribute",
"(",
"Path",
"path",
",",
"String",
"attribute",
",",
"float",
"value",
",",
"LinkOption",
"...",
"options",
")",
"throws",
"IOException",
"{",
"attribute",
"=",
"attribute",
".",
"startsWith",
"(",
"\"user:\"",
")",
"?",
"attribute",
":",
"\"user:\"",
"+",
"attribute",
";",
"Files",
".",
"setAttribute",
"(",
"path",
",",
"attribute",
",",
"Primitives",
".",
"writeFloat",
"(",
"value",
")",
",",
"options",
")",
";",
"}"
] | Set user-defined-attribute
@param path
@param attribute user:attribute name. user: can be omitted.
@param value
@param options
@throws IOException | [
"Set",
"user",
"-",
"defined",
"-",
"attribute"
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/file/attribute/UserAttrs.java#L79-L83 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/server/namenode/CorruptReplicasMap.java | CorruptReplicasMap.isReplicaCorrupt | boolean isReplicaCorrupt(Block blk, DatanodeDescriptor node) {
"""
Check if replica belonging to Datanode is corrupt
@param blk Block to check
@param node DatanodeDescriptor which holds the replica
@return true if replica is corrupt, false if does not exists in this map
"""
Collection<DatanodeDescriptor> nodes = getNodes(blk);
return ((nodes != null) && (nodes.contains(node)));
} | java | boolean isReplicaCorrupt(Block blk, DatanodeDescriptor node) {
Collection<DatanodeDescriptor> nodes = getNodes(blk);
return ((nodes != null) && (nodes.contains(node)));
} | [
"boolean",
"isReplicaCorrupt",
"(",
"Block",
"blk",
",",
"DatanodeDescriptor",
"node",
")",
"{",
"Collection",
"<",
"DatanodeDescriptor",
">",
"nodes",
"=",
"getNodes",
"(",
"blk",
")",
";",
"return",
"(",
"(",
"nodes",
"!=",
"null",
")",
"&&",
"(",
"nodes",
".",
"contains",
"(",
"node",
")",
")",
")",
";",
"}"
] | Check if replica belonging to Datanode is corrupt
@param blk Block to check
@param node DatanodeDescriptor which holds the replica
@return true if replica is corrupt, false if does not exists in this map | [
"Check",
"if",
"replica",
"belonging",
"to",
"Datanode",
"is",
"corrupt"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/namenode/CorruptReplicasMap.java#L121-L124 |
BlueBrain/bluima | modules/bluima_lexica/src/main/java/ch/epfl/bbp/uima/obo/OBOOntology.java | OBOOntology.directIsA | public boolean directIsA(String hypoID, String hyperID) {
"""
Tests whether there is a direct is_a (or has_role) relationship between
two IDs.
@param hypoID
The potential hyponym (child term).
@param hyperID
The potential hypernym (parent term).
@return Whether that direct relationship exists.
"""
if (!terms.containsKey(hypoID))
return false;
OntologyTerm term = terms.get(hypoID);
if (term.getIsA().contains(hyperID))
return true;
return false;
} | java | public boolean directIsA(String hypoID, String hyperID) {
if (!terms.containsKey(hypoID))
return false;
OntologyTerm term = terms.get(hypoID);
if (term.getIsA().contains(hyperID))
return true;
return false;
} | [
"public",
"boolean",
"directIsA",
"(",
"String",
"hypoID",
",",
"String",
"hyperID",
")",
"{",
"if",
"(",
"!",
"terms",
".",
"containsKey",
"(",
"hypoID",
")",
")",
"return",
"false",
";",
"OntologyTerm",
"term",
"=",
"terms",
".",
"get",
"(",
"hypoID",
")",
";",
"if",
"(",
"term",
".",
"getIsA",
"(",
")",
".",
"contains",
"(",
"hyperID",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | Tests whether there is a direct is_a (or has_role) relationship between
two IDs.
@param hypoID
The potential hyponym (child term).
@param hyperID
The potential hypernym (parent term).
@return Whether that direct relationship exists. | [
"Tests",
"whether",
"there",
"is",
"a",
"direct",
"is_a",
"(",
"or",
"has_role",
")",
"relationship",
"between",
"two",
"IDs",
"."
] | train | https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_lexica/src/main/java/ch/epfl/bbp/uima/obo/OBOOntology.java#L322-L329 |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitInstanceElement | public T visitInstanceElement(InstanceElement elm, C context) {
"""
Visit a InstanceElement. This method will be called for
every node in the tree that is a InstanceElement.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result
"""
visitElement(elm.getValue(), context);
return null;
} | java | public T visitInstanceElement(InstanceElement elm, C context) {
visitElement(elm.getValue(), context);
return null;
} | [
"public",
"T",
"visitInstanceElement",
"(",
"InstanceElement",
"elm",
",",
"C",
"context",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getValue",
"(",
")",
",",
"context",
")",
";",
"return",
"null",
";",
"}"
] | Visit a InstanceElement. This method will be called for
every node in the tree that is a InstanceElement.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"InstanceElement",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"InstanceElement",
"."
] | train | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L483-L486 |
google/error-prone-javac | src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java | ArgTokenizer.whitespaceChars | private void whitespaceChars(int low, int hi) {
"""
Specifies that all characters <i>c</i> in the range
<code>low <= <i>c</i> <= high</code>
are white space characters. White space characters serve only to
separate tokens in the input stream.
<p>Any other attribute settings for the characters in the specified
range are cleared.
@param low the low end of the range.
@param hi the high end of the range.
"""
if (low < 0)
low = 0;
if (hi >= ctype.length)
hi = ctype.length - 1;
while (low <= hi)
ctype[low++] = CT_WHITESPACE;
} | java | private void whitespaceChars(int low, int hi) {
if (low < 0)
low = 0;
if (hi >= ctype.length)
hi = ctype.length - 1;
while (low <= hi)
ctype[low++] = CT_WHITESPACE;
} | [
"private",
"void",
"whitespaceChars",
"(",
"int",
"low",
",",
"int",
"hi",
")",
"{",
"if",
"(",
"low",
"<",
"0",
")",
"low",
"=",
"0",
";",
"if",
"(",
"hi",
">=",
"ctype",
".",
"length",
")",
"hi",
"=",
"ctype",
".",
"length",
"-",
"1",
";",
"while",
"(",
"low",
"<=",
"hi",
")",
"ctype",
"[",
"low",
"++",
"]",
"=",
"CT_WHITESPACE",
";",
"}"
] | Specifies that all characters <i>c</i> in the range
<code>low <= <i>c</i> <= high</code>
are white space characters. White space characters serve only to
separate tokens in the input stream.
<p>Any other attribute settings for the characters in the specified
range are cleared.
@param low the low end of the range.
@param hi the high end of the range. | [
"Specifies",
"that",
"all",
"characters",
"<i",
">",
"c<",
"/",
"i",
">",
"in",
"the",
"range",
"<code",
">",
"low ",
";",
"<",
";",
"=",
" ",
";",
"<i",
">",
"c<",
"/",
"i",
">",
" ",
";",
"<",
";",
"=",
" ",
";",
"high<",
"/",
"code",
">",
"are",
"white",
"space",
"characters",
".",
"White",
"space",
"characters",
"serve",
"only",
"to",
"separate",
"tokens",
"in",
"the",
"input",
"stream",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java#L220-L227 |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java | AmqpClient.closeConnection | AmqpClient closeConnection(int replyCode, String replyText, int classId, int methodId1) {
"""
Closes the Amqp Server connection.
@param replyCode
@param replyText
@param classId
@param methodId1
@return AmqpClient
"""
this.closeConnection(replyCode, replyText, classId, methodId1, null, null);
return this;
} | java | AmqpClient closeConnection(int replyCode, String replyText, int classId, int methodId1) {
this.closeConnection(replyCode, replyText, classId, methodId1, null, null);
return this;
} | [
"AmqpClient",
"closeConnection",
"(",
"int",
"replyCode",
",",
"String",
"replyText",
",",
"int",
"classId",
",",
"int",
"methodId1",
")",
"{",
"this",
".",
"closeConnection",
"(",
"replyCode",
",",
"replyText",
",",
"classId",
",",
"methodId1",
",",
"null",
",",
"null",
")",
";",
"return",
"this",
";",
"}"
] | Closes the Amqp Server connection.
@param replyCode
@param replyText
@param classId
@param methodId1
@return AmqpClient | [
"Closes",
"the",
"Amqp",
"Server",
"connection",
"."
] | train | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java#L882-L885 |
Erudika/para | para-core/src/main/java/com/erudika/para/utils/Utils.java | Utils.stripAndTrim | public static String stripAndTrim(String str, String replaceWith, boolean asciiOnly) {
"""
Strips all symbols, punctuation, whitespace and control chars from a string.
@param str a dirty string
@param replaceWith a string to replace spaces with
@param asciiOnly if true, all non-ASCII characters will be stripped
@return a clean string
"""
if (StringUtils.isBlank(str)) {
return "";
}
String s = str;
if (asciiOnly) {
s = str.replaceAll("[^\\p{ASCII}]", "");
}
return s.replaceAll("[\\p{S}\\p{P}\\p{C}]", replaceWith).replaceAll("\\p{Z}+", " ").trim();
} | java | public static String stripAndTrim(String str, String replaceWith, boolean asciiOnly) {
if (StringUtils.isBlank(str)) {
return "";
}
String s = str;
if (asciiOnly) {
s = str.replaceAll("[^\\p{ASCII}]", "");
}
return s.replaceAll("[\\p{S}\\p{P}\\p{C}]", replaceWith).replaceAll("\\p{Z}+", " ").trim();
} | [
"public",
"static",
"String",
"stripAndTrim",
"(",
"String",
"str",
",",
"String",
"replaceWith",
",",
"boolean",
"asciiOnly",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"str",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"String",
"s",
"=",
"str",
";",
"if",
"(",
"asciiOnly",
")",
"{",
"s",
"=",
"str",
".",
"replaceAll",
"(",
"\"[^\\\\p{ASCII}]\"",
",",
"\"\"",
")",
";",
"}",
"return",
"s",
".",
"replaceAll",
"(",
"\"[\\\\p{S}\\\\p{P}\\\\p{C}]\"",
",",
"replaceWith",
")",
".",
"replaceAll",
"(",
"\"\\\\p{Z}+\"",
",",
"\" \"",
")",
".",
"trim",
"(",
")",
";",
"}"
] | Strips all symbols, punctuation, whitespace and control chars from a string.
@param str a dirty string
@param replaceWith a string to replace spaces with
@param asciiOnly if true, all non-ASCII characters will be stripped
@return a clean string | [
"Strips",
"all",
"symbols",
"punctuation",
"whitespace",
"and",
"control",
"chars",
"from",
"a",
"string",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/utils/Utils.java#L347-L356 |
fcrepo3/fcrepo | fcrepo-webapp/fcrepo-webapp-fop/src/main/java/org/fcrepo/localservices/fop/FOPServlet.java | FOPServlet.renderXML | protected void renderXML(String xml, String xslt, HttpServletResponse response)
throws FOPException, TransformerException, IOException {
"""
Renders an XML file into a PDF file by applying a stylesheet
that converts the XML to XSL-FO. The PDF is written to a byte array
that is returned as the method's result.
@param xml the XML file
@param xslt the XSLT file
@param response HTTP response object
@throws FOPException If an error occurs during the rendering of the
XSL-FO
@throws TransformerException If an error occurs during XSL
transformation
@throws IOException In case of an I/O problem
"""
//Setup sources
Source xmlSrc = convertString2Source(xml);
Source xsltSrc = convertString2Source(xslt);
//Setup the XSL transformation
Transformer transformer = this.transFactory.newTransformer(xsltSrc);
transformer.setURIResolver(this.uriResolver);
//Start transformation and rendering process
render(xmlSrc, transformer, response);
} | java | protected void renderXML(String xml, String xslt, HttpServletResponse response)
throws FOPException, TransformerException, IOException {
//Setup sources
Source xmlSrc = convertString2Source(xml);
Source xsltSrc = convertString2Source(xslt);
//Setup the XSL transformation
Transformer transformer = this.transFactory.newTransformer(xsltSrc);
transformer.setURIResolver(this.uriResolver);
//Start transformation and rendering process
render(xmlSrc, transformer, response);
} | [
"protected",
"void",
"renderXML",
"(",
"String",
"xml",
",",
"String",
"xslt",
",",
"HttpServletResponse",
"response",
")",
"throws",
"FOPException",
",",
"TransformerException",
",",
"IOException",
"{",
"//Setup sources",
"Source",
"xmlSrc",
"=",
"convertString2Source",
"(",
"xml",
")",
";",
"Source",
"xsltSrc",
"=",
"convertString2Source",
"(",
"xslt",
")",
";",
"//Setup the XSL transformation",
"Transformer",
"transformer",
"=",
"this",
".",
"transFactory",
".",
"newTransformer",
"(",
"xsltSrc",
")",
";",
"transformer",
".",
"setURIResolver",
"(",
"this",
".",
"uriResolver",
")",
";",
"//Start transformation and rendering process",
"render",
"(",
"xmlSrc",
",",
"transformer",
",",
"response",
")",
";",
"}"
] | Renders an XML file into a PDF file by applying a stylesheet
that converts the XML to XSL-FO. The PDF is written to a byte array
that is returned as the method's result.
@param xml the XML file
@param xslt the XSLT file
@param response HTTP response object
@throws FOPException If an error occurs during the rendering of the
XSL-FO
@throws TransformerException If an error occurs during XSL
transformation
@throws IOException In case of an I/O problem | [
"Renders",
"an",
"XML",
"file",
"into",
"a",
"PDF",
"file",
"by",
"applying",
"a",
"stylesheet",
"that",
"converts",
"the",
"XML",
"to",
"XSL",
"-",
"FO",
".",
"The",
"PDF",
"is",
"written",
"to",
"a",
"byte",
"array",
"that",
"is",
"returned",
"as",
"the",
"method",
"s",
"result",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-fop/src/main/java/org/fcrepo/localservices/fop/FOPServlet.java#L166-L179 |
threerings/gwt-utils | src/main/java/com/threerings/gwt/util/WindowUtil.java | WindowUtil.isScrolledIntoView | public static boolean isScrolledIntoView (Widget target, int minPixels) {
"""
Returns true if the target widget is vertically scrolled into view.
@param minPixels the minimum number of pixels that must be visible to count as "in view".
"""
int wtop = Window.getScrollTop(), wheight = Window.getClientHeight();
int ttop = target.getAbsoluteTop();
if (ttop > wtop) {
return (wtop + wheight - ttop > minPixels);
} else {
return (ttop + target.getOffsetHeight() - wtop > minPixels);
}
} | java | public static boolean isScrolledIntoView (Widget target, int minPixels)
{
int wtop = Window.getScrollTop(), wheight = Window.getClientHeight();
int ttop = target.getAbsoluteTop();
if (ttop > wtop) {
return (wtop + wheight - ttop > minPixels);
} else {
return (ttop + target.getOffsetHeight() - wtop > minPixels);
}
} | [
"public",
"static",
"boolean",
"isScrolledIntoView",
"(",
"Widget",
"target",
",",
"int",
"minPixels",
")",
"{",
"int",
"wtop",
"=",
"Window",
".",
"getScrollTop",
"(",
")",
",",
"wheight",
"=",
"Window",
".",
"getClientHeight",
"(",
")",
";",
"int",
"ttop",
"=",
"target",
".",
"getAbsoluteTop",
"(",
")",
";",
"if",
"(",
"ttop",
">",
"wtop",
")",
"{",
"return",
"(",
"wtop",
"+",
"wheight",
"-",
"ttop",
">",
"minPixels",
")",
";",
"}",
"else",
"{",
"return",
"(",
"ttop",
"+",
"target",
".",
"getOffsetHeight",
"(",
")",
"-",
"wtop",
">",
"minPixels",
")",
";",
"}",
"}"
] | Returns true if the target widget is vertically scrolled into view.
@param minPixels the minimum number of pixels that must be visible to count as "in view". | [
"Returns",
"true",
"if",
"the",
"target",
"widget",
"is",
"vertically",
"scrolled",
"into",
"view",
"."
] | train | https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/WindowUtil.java#L133-L142 |
motown-io/motown | chargingstation-configuration/app/src/main/java/io/motown/chargingstationconfiguration/app/ConfigurationEventListener.java | ConfigurationEventListener.onEvent | @EventHandler
protected void onEvent(UnconfiguredChargingStationBootedEvent event) {
"""
Handles {@code UnconfiguredChargingStationBootedEvent}s by requesting the domainService for information about
the vendor and model code which should be present in the event attributes.
@param event the event to handle.
"""
LOG.info("Handling UnconfiguredChargingStationBootedEvent");
Map<String, String> attributes = event.getAttributes();
Set<Evse> evses = domainService.getEvses(attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL));
if (evses != null && !evses.isEmpty()) {
IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity());
ConfigureChargingStationCommand command = new ConfigureChargingStationCommand(event.getChargingStationId(), evses, identityContext);
LOG.info("Sending configure charging station command for charging station: {}", event.getChargingStationId());
commandGateway.send(command);
} else {
LOG.info("No Evses found for vendor {} and model {}", attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL));
}
} | java | @EventHandler
protected void onEvent(UnconfiguredChargingStationBootedEvent event) {
LOG.info("Handling UnconfiguredChargingStationBootedEvent");
Map<String, String> attributes = event.getAttributes();
Set<Evse> evses = domainService.getEvses(attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL));
if (evses != null && !evses.isEmpty()) {
IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity());
ConfigureChargingStationCommand command = new ConfigureChargingStationCommand(event.getChargingStationId(), evses, identityContext);
LOG.info("Sending configure charging station command for charging station: {}", event.getChargingStationId());
commandGateway.send(command);
} else {
LOG.info("No Evses found for vendor {} and model {}", attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL));
}
} | [
"@",
"EventHandler",
"protected",
"void",
"onEvent",
"(",
"UnconfiguredChargingStationBootedEvent",
"event",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Handling UnconfiguredChargingStationBootedEvent\"",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"attributes",
"=",
"event",
".",
"getAttributes",
"(",
")",
";",
"Set",
"<",
"Evse",
">",
"evses",
"=",
"domainService",
".",
"getEvses",
"(",
"attributes",
".",
"get",
"(",
"AttributeMapKeys",
".",
"VENDOR_ID",
")",
",",
"attributes",
".",
"get",
"(",
"AttributeMapKeys",
".",
"MODEL",
")",
")",
";",
"if",
"(",
"evses",
"!=",
"null",
"&&",
"!",
"evses",
".",
"isEmpty",
"(",
")",
")",
"{",
"IdentityContext",
"identityContext",
"=",
"new",
"IdentityContext",
"(",
"addOnIdentity",
",",
"new",
"NullUserIdentity",
"(",
")",
")",
";",
"ConfigureChargingStationCommand",
"command",
"=",
"new",
"ConfigureChargingStationCommand",
"(",
"event",
".",
"getChargingStationId",
"(",
")",
",",
"evses",
",",
"identityContext",
")",
";",
"LOG",
".",
"info",
"(",
"\"Sending configure charging station command for charging station: {}\"",
",",
"event",
".",
"getChargingStationId",
"(",
")",
")",
";",
"commandGateway",
".",
"send",
"(",
"command",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"info",
"(",
"\"No Evses found for vendor {} and model {}\"",
",",
"attributes",
".",
"get",
"(",
"AttributeMapKeys",
".",
"VENDOR_ID",
")",
",",
"attributes",
".",
"get",
"(",
"AttributeMapKeys",
".",
"MODEL",
")",
")",
";",
"}",
"}"
] | Handles {@code UnconfiguredChargingStationBootedEvent}s by requesting the domainService for information about
the vendor and model code which should be present in the event attributes.
@param event the event to handle. | [
"Handles",
"{",
"@code",
"UnconfiguredChargingStationBootedEvent",
"}",
"s",
"by",
"requesting",
"the",
"domainService",
"for",
"information",
"about",
"the",
"vendor",
"and",
"model",
"code",
"which",
"should",
"be",
"present",
"in",
"the",
"event",
"attributes",
"."
] | train | https://github.com/motown-io/motown/blob/783ccda7c28b273a529ddd47defe8673b1ea365b/chargingstation-configuration/app/src/main/java/io/motown/chargingstationconfiguration/app/ConfigurationEventListener.java#L48-L65 |
Azure/azure-sdk-for-java | resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/DeploymentsInner.java | DeploymentsInner.validateAsync | public Observable<DeploymentValidateResultInner> validateAsync(String resourceGroupName, String deploymentName, DeploymentProperties properties) {
"""
Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager..
@param resourceGroupName The name of the resource group the template will be deployed to. The name is case insensitive.
@param deploymentName The name of the deployment.
@param properties The deployment properties.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DeploymentValidateResultInner object
"""
return validateWithServiceResponseAsync(resourceGroupName, deploymentName, properties).map(new Func1<ServiceResponse<DeploymentValidateResultInner>, DeploymentValidateResultInner>() {
@Override
public DeploymentValidateResultInner call(ServiceResponse<DeploymentValidateResultInner> response) {
return response.body();
}
});
} | java | public Observable<DeploymentValidateResultInner> validateAsync(String resourceGroupName, String deploymentName, DeploymentProperties properties) {
return validateWithServiceResponseAsync(resourceGroupName, deploymentName, properties).map(new Func1<ServiceResponse<DeploymentValidateResultInner>, DeploymentValidateResultInner>() {
@Override
public DeploymentValidateResultInner call(ServiceResponse<DeploymentValidateResultInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DeploymentValidateResultInner",
">",
"validateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"deploymentName",
",",
"DeploymentProperties",
"properties",
")",
"{",
"return",
"validateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"deploymentName",
",",
"properties",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DeploymentValidateResultInner",
">",
",",
"DeploymentValidateResultInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DeploymentValidateResultInner",
"call",
"(",
"ServiceResponse",
"<",
"DeploymentValidateResultInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager..
@param resourceGroupName The name of the resource group the template will be deployed to. The name is case insensitive.
@param deploymentName The name of the deployment.
@param properties The deployment properties.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DeploymentValidateResultInner object | [
"Validates",
"whether",
"the",
"specified",
"template",
"is",
"syntactically",
"correct",
"and",
"will",
"be",
"accepted",
"by",
"Azure",
"Resource",
"Manager",
".."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/DeploymentsInner.java#L761-L768 |
zeroturnaround/zt-zip | src/main/java/org/zeroturnaround/zip/ZipUtil.java | ZipUtil.unpackEntry | public static boolean unpackEntry(ZipFile zf, String name, File file) {
"""
Unpacks a single file from a ZIP archive to a file.
@param zf
ZIP file.
@param name
entry name.
@param file
target file to be created or overwritten.
@return <code>true</code> if the entry was found and unpacked,
<code>false</code> if the entry was not found.
"""
try {
return doUnpackEntry(zf, name, file);
}
catch (IOException e) {
throw ZipExceptionUtil.rethrow(e);
}
} | java | public static boolean unpackEntry(ZipFile zf, String name, File file) {
try {
return doUnpackEntry(zf, name, file);
}
catch (IOException e) {
throw ZipExceptionUtil.rethrow(e);
}
} | [
"public",
"static",
"boolean",
"unpackEntry",
"(",
"ZipFile",
"zf",
",",
"String",
"name",
",",
"File",
"file",
")",
"{",
"try",
"{",
"return",
"doUnpackEntry",
"(",
"zf",
",",
"name",
",",
"file",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"ZipExceptionUtil",
".",
"rethrow",
"(",
"e",
")",
";",
"}",
"}"
] | Unpacks a single file from a ZIP archive to a file.
@param zf
ZIP file.
@param name
entry name.
@param file
target file to be created or overwritten.
@return <code>true</code> if the entry was found and unpacked,
<code>false</code> if the entry was not found. | [
"Unpacks",
"a",
"single",
"file",
"from",
"a",
"ZIP",
"archive",
"to",
"a",
"file",
"."
] | train | https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/ZipUtil.java#L368-L375 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/labeled/textfield/LabeledDateTimeFieldPanel.java | LabeledDateTimeFieldPanel.newDateTimeField | protected DateTimeField newDateTimeField(final String id, final IModel<M> model) {
"""
Factory method for create the new {@link DateTimeField}. This method is invoked in the
constructor from the derived classes and can be overridden so users can provide their own
version of a new {@link DateTimeField}.
@param id
the id
@param model
the model
@return the new {@link DateTimeField}
"""
final IModel<Date> textFieldModel = new PropertyModel<>(model.getObject(), getId());
return ComponentFactory.newDateTimeField(id, textFieldModel);
} | java | protected DateTimeField newDateTimeField(final String id, final IModel<M> model)
{
final IModel<Date> textFieldModel = new PropertyModel<>(model.getObject(), getId());
return ComponentFactory.newDateTimeField(id, textFieldModel);
} | [
"protected",
"DateTimeField",
"newDateTimeField",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"M",
">",
"model",
")",
"{",
"final",
"IModel",
"<",
"Date",
">",
"textFieldModel",
"=",
"new",
"PropertyModel",
"<>",
"(",
"model",
".",
"getObject",
"(",
")",
",",
"getId",
"(",
")",
")",
";",
"return",
"ComponentFactory",
".",
"newDateTimeField",
"(",
"id",
",",
"textFieldModel",
")",
";",
"}"
] | Factory method for create the new {@link DateTimeField}. This method is invoked in the
constructor from the derived classes and can be overridden so users can provide their own
version of a new {@link DateTimeField}.
@param id
the id
@param model
the model
@return the new {@link DateTimeField} | [
"Factory",
"method",
"for",
"create",
"the",
"new",
"{",
"@link",
"DateTimeField",
"}",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"new",
"{",
"@link",
"DateTimeField",
"}",
"."
] | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/labeled/textfield/LabeledDateTimeFieldPanel.java#L93-L97 |
comapi/comapi-sdk-android | COMAPI/foundation/src/main/java/com/comapi/internal/network/InternalService.java | InternalService.createConversation | public Observable<ComapiResult<ConversationDetails>> createConversation(@NonNull final ConversationCreate request) {
"""
Returns observable to create a conversation.
@param request Request with conversation details to create.
@return Observable to to create a conversation.
"""
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueCreateConversation(request);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doCreateConversation(token, request);
}
} | java | public Observable<ComapiResult<ConversationDetails>> createConversation(@NonNull final ConversationCreate request) {
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueCreateConversation(request);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doCreateConversation(token, request);
}
} | [
"public",
"Observable",
"<",
"ComapiResult",
"<",
"ConversationDetails",
">",
">",
"createConversation",
"(",
"@",
"NonNull",
"final",
"ConversationCreate",
"request",
")",
"{",
"final",
"String",
"token",
"=",
"getToken",
"(",
")",
";",
"if",
"(",
"sessionController",
".",
"isCreatingSession",
"(",
")",
")",
"{",
"return",
"getTaskQueue",
"(",
")",
".",
"queueCreateConversation",
"(",
"request",
")",
";",
"}",
"else",
"if",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"token",
")",
")",
"{",
"return",
"Observable",
".",
"error",
"(",
"getSessionStateErrorDescription",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"doCreateConversation",
"(",
"token",
",",
"request",
")",
";",
"}",
"}"
] | Returns observable to create a conversation.
@param request Request with conversation details to create.
@return Observable to to create a conversation. | [
"Returns",
"observable",
"to",
"create",
"a",
"conversation",
"."
] | train | https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/InternalService.java#L414-L425 |
pravega/pravega | segmentstore/storage/impl/src/main/java/io/pravega/segmentstore/storage/impl/bookkeeper/BookKeeperServiceRunner.java | BookKeeperServiceRunner.resumeZooKeeper | public void resumeZooKeeper() throws Exception {
"""
Resumes ZooKeeper (if it had previously been suspended).
@throws Exception If an exception got thrown.
"""
val zk = new ZooKeeperServiceRunner(this.zkPort, this.secureZK, this.tLSKeyStore, this.tLSKeyStorePasswordPath, this.tlsTrustStore);
if (this.zkServer.compareAndSet(null, zk)) {
// Initialize ZK runner (since nobody else did it for us).
zk.initialize();
log.info("ZooKeeper initialized.");
} else {
zk.close();
}
// Start or resume ZK.
this.zkServer.get().start();
log.info("ZooKeeper resumed.");
} | java | public void resumeZooKeeper() throws Exception {
val zk = new ZooKeeperServiceRunner(this.zkPort, this.secureZK, this.tLSKeyStore, this.tLSKeyStorePasswordPath, this.tlsTrustStore);
if (this.zkServer.compareAndSet(null, zk)) {
// Initialize ZK runner (since nobody else did it for us).
zk.initialize();
log.info("ZooKeeper initialized.");
} else {
zk.close();
}
// Start or resume ZK.
this.zkServer.get().start();
log.info("ZooKeeper resumed.");
} | [
"public",
"void",
"resumeZooKeeper",
"(",
")",
"throws",
"Exception",
"{",
"val",
"zk",
"=",
"new",
"ZooKeeperServiceRunner",
"(",
"this",
".",
"zkPort",
",",
"this",
".",
"secureZK",
",",
"this",
".",
"tLSKeyStore",
",",
"this",
".",
"tLSKeyStorePasswordPath",
",",
"this",
".",
"tlsTrustStore",
")",
";",
"if",
"(",
"this",
".",
"zkServer",
".",
"compareAndSet",
"(",
"null",
",",
"zk",
")",
")",
"{",
"// Initialize ZK runner (since nobody else did it for us).",
"zk",
".",
"initialize",
"(",
")",
";",
"log",
".",
"info",
"(",
"\"ZooKeeper initialized.\"",
")",
";",
"}",
"else",
"{",
"zk",
".",
"close",
"(",
")",
";",
"}",
"// Start or resume ZK.",
"this",
".",
"zkServer",
".",
"get",
"(",
")",
".",
"start",
"(",
")",
";",
"log",
".",
"info",
"(",
"\"ZooKeeper resumed.\"",
")",
";",
"}"
] | Resumes ZooKeeper (if it had previously been suspended).
@throws Exception If an exception got thrown. | [
"Resumes",
"ZooKeeper",
"(",
"if",
"it",
"had",
"previously",
"been",
"suspended",
")",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/storage/impl/src/main/java/io/pravega/segmentstore/storage/impl/bookkeeper/BookKeeperServiceRunner.java#L143-L156 |
jbundle/webapp | base/src/main/java/org/jbundle/util/webapp/base/BaseWebappServlet.java | BaseWebappServlet.copyStream | public static void copyStream(Reader inStream, Writer outStream, boolean ignoreErrors) {
"""
Copy the input stream to the output stream
@param inStream
@param outStream
@param ignoreErrors
"""
char[] data = new char[BUFFER];
int count;
try {
while((count = inStream.read(data, 0, BUFFER)) != -1)
{
outStream.write(data, 0, count);
}
} catch (IOException e) {
if (!ignoreErrors)
e.printStackTrace();
}
} | java | public static void copyStream(Reader inStream, Writer outStream, boolean ignoreErrors)
{
char[] data = new char[BUFFER];
int count;
try {
while((count = inStream.read(data, 0, BUFFER)) != -1)
{
outStream.write(data, 0, count);
}
} catch (IOException e) {
if (!ignoreErrors)
e.printStackTrace();
}
} | [
"public",
"static",
"void",
"copyStream",
"(",
"Reader",
"inStream",
",",
"Writer",
"outStream",
",",
"boolean",
"ignoreErrors",
")",
"{",
"char",
"[",
"]",
"data",
"=",
"new",
"char",
"[",
"BUFFER",
"]",
";",
"int",
"count",
";",
"try",
"{",
"while",
"(",
"(",
"count",
"=",
"inStream",
".",
"read",
"(",
"data",
",",
"0",
",",
"BUFFER",
")",
")",
"!=",
"-",
"1",
")",
"{",
"outStream",
".",
"write",
"(",
"data",
",",
"0",
",",
"count",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"if",
"(",
"!",
"ignoreErrors",
")",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | Copy the input stream to the output stream
@param inStream
@param outStream
@param ignoreErrors | [
"Copy",
"the",
"input",
"stream",
"to",
"the",
"output",
"stream"
] | train | https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/base/src/main/java/org/jbundle/util/webapp/base/BaseWebappServlet.java#L165-L178 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractInput.java | AbstractInput.showIndicatorsForComponent | protected void showIndicatorsForComponent(final List<Diagnostic> diags, final int severity) {
"""
Iterates over the {@link Diagnostic}s and finds the diagnostics that related to the current component.
@param diags A List of Diagnostic objects.
@param severity A Diagnostic severity code. e.g. {@link Diagnostic#ERROR}
"""
InputModel model = getOrCreateComponentModel();
if (severity == Diagnostic.ERROR) {
model.errorDiagnostics.clear();
} else {
model.warningDiagnostics.clear();
}
UIContext uic = UIContextHolder.getCurrent();
for (int i = 0; i < diags.size(); i++) {
Diagnostic diagnostic = diags.get(i);
// NOTE: double equals because they must be the same instance.
if (diagnostic.getSeverity() == severity && uic == diagnostic.getContext() && this == diagnostic.getComponent()) {
if (severity == Diagnostic.ERROR) {
model.errorDiagnostics.add(diagnostic);
} else {
model.warningDiagnostics.add(diagnostic);
}
}
}
} | java | protected void showIndicatorsForComponent(final List<Diagnostic> diags, final int severity) {
InputModel model = getOrCreateComponentModel();
if (severity == Diagnostic.ERROR) {
model.errorDiagnostics.clear();
} else {
model.warningDiagnostics.clear();
}
UIContext uic = UIContextHolder.getCurrent();
for (int i = 0; i < diags.size(); i++) {
Diagnostic diagnostic = diags.get(i);
// NOTE: double equals because they must be the same instance.
if (diagnostic.getSeverity() == severity && uic == diagnostic.getContext() && this == diagnostic.getComponent()) {
if (severity == Diagnostic.ERROR) {
model.errorDiagnostics.add(diagnostic);
} else {
model.warningDiagnostics.add(diagnostic);
}
}
}
} | [
"protected",
"void",
"showIndicatorsForComponent",
"(",
"final",
"List",
"<",
"Diagnostic",
">",
"diags",
",",
"final",
"int",
"severity",
")",
"{",
"InputModel",
"model",
"=",
"getOrCreateComponentModel",
"(",
")",
";",
"if",
"(",
"severity",
"==",
"Diagnostic",
".",
"ERROR",
")",
"{",
"model",
".",
"errorDiagnostics",
".",
"clear",
"(",
")",
";",
"}",
"else",
"{",
"model",
".",
"warningDiagnostics",
".",
"clear",
"(",
")",
";",
"}",
"UIContext",
"uic",
"=",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"diags",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Diagnostic",
"diagnostic",
"=",
"diags",
".",
"get",
"(",
"i",
")",
";",
"// NOTE: double equals because they must be the same instance.",
"if",
"(",
"diagnostic",
".",
"getSeverity",
"(",
")",
"==",
"severity",
"&&",
"uic",
"==",
"diagnostic",
".",
"getContext",
"(",
")",
"&&",
"this",
"==",
"diagnostic",
".",
"getComponent",
"(",
")",
")",
"{",
"if",
"(",
"severity",
"==",
"Diagnostic",
".",
"ERROR",
")",
"{",
"model",
".",
"errorDiagnostics",
".",
"add",
"(",
"diagnostic",
")",
";",
"}",
"else",
"{",
"model",
".",
"warningDiagnostics",
".",
"add",
"(",
"diagnostic",
")",
";",
"}",
"}",
"}",
"}"
] | Iterates over the {@link Diagnostic}s and finds the diagnostics that related to the current component.
@param diags A List of Diagnostic objects.
@param severity A Diagnostic severity code. e.g. {@link Diagnostic#ERROR} | [
"Iterates",
"over",
"the",
"{",
"@link",
"Diagnostic",
"}",
"s",
"and",
"finds",
"the",
"diagnostics",
"that",
"related",
"to",
"the",
"current",
"component",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractInput.java#L431-L450 |
stephanrauh/AngularFaces | AngularFaces_2.0/AngularFaces-core/src/main/java/de/beyondjava/angularFaces/core/transformation/PuiAngularTransformer.java | PuiAngularTransformer.addResourceAfterAngularJS | public static void addResourceAfterAngularJS(String library, String resource) {
"""
Registers a JS file that needs to be include in the header of the HTML
file, but after jQuery and AngularJS.
@param library
The name of the sub-folder of the resources folder.
@param resource
The name of the resource file within the library folder.
"""
FacesContext ctx = FacesContext.getCurrentInstance();
UIViewRoot v = ctx.getViewRoot();
Map<String, Object> viewMap = v.getViewMap();
@SuppressWarnings("unchecked")
Map<String, String> resourceMap = (Map<String, String>) viewMap.get(RESOURCE_KEY);
if (null == resourceMap) {
resourceMap = new HashMap<String, String>();
viewMap.put(RESOURCE_KEY, resourceMap);
}
String key = library + "#" + resource;
if (!resourceMap.containsKey(key)) {
resourceMap.put(key, resource);
}
} | java | public static void addResourceAfterAngularJS(String library, String resource) {
FacesContext ctx = FacesContext.getCurrentInstance();
UIViewRoot v = ctx.getViewRoot();
Map<String, Object> viewMap = v.getViewMap();
@SuppressWarnings("unchecked")
Map<String, String> resourceMap = (Map<String, String>) viewMap.get(RESOURCE_KEY);
if (null == resourceMap) {
resourceMap = new HashMap<String, String>();
viewMap.put(RESOURCE_KEY, resourceMap);
}
String key = library + "#" + resource;
if (!resourceMap.containsKey(key)) {
resourceMap.put(key, resource);
}
} | [
"public",
"static",
"void",
"addResourceAfterAngularJS",
"(",
"String",
"library",
",",
"String",
"resource",
")",
"{",
"FacesContext",
"ctx",
"=",
"FacesContext",
".",
"getCurrentInstance",
"(",
")",
";",
"UIViewRoot",
"v",
"=",
"ctx",
".",
"getViewRoot",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"viewMap",
"=",
"v",
".",
"getViewMap",
"(",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Map",
"<",
"String",
",",
"String",
">",
"resourceMap",
"=",
"(",
"Map",
"<",
"String",
",",
"String",
">",
")",
"viewMap",
".",
"get",
"(",
"RESOURCE_KEY",
")",
";",
"if",
"(",
"null",
"==",
"resourceMap",
")",
"{",
"resourceMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"viewMap",
".",
"put",
"(",
"RESOURCE_KEY",
",",
"resourceMap",
")",
";",
"}",
"String",
"key",
"=",
"library",
"+",
"\"#\"",
"+",
"resource",
";",
"if",
"(",
"!",
"resourceMap",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"resourceMap",
".",
"put",
"(",
"key",
",",
"resource",
")",
";",
"}",
"}"
] | Registers a JS file that needs to be include in the header of the HTML
file, but after jQuery and AngularJS.
@param library
The name of the sub-folder of the resources folder.
@param resource
The name of the resource file within the library folder. | [
"Registers",
"a",
"JS",
"file",
"that",
"needs",
"to",
"be",
"include",
"in",
"the",
"header",
"of",
"the",
"HTML",
"file",
"but",
"after",
"jQuery",
"and",
"AngularJS",
"."
] | train | https://github.com/stephanrauh/AngularFaces/blob/43d915f004645b1bbbf2625214294dab0858ba01/AngularFaces_2.0/AngularFaces-core/src/main/java/de/beyondjava/angularFaces/core/transformation/PuiAngularTransformer.java#L328-L342 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/MeanVariance.java | MeanVariance.put | @Override
public void put(double val, double weight) {
"""
Add data with a given weight.
@param val data
@param weight weight
"""
if(weight == 0.) {
return;
}
if(n <= 0) {
n = weight;
sum = val * weight;
return;
}
val *= weight;
final double tmp = n * val - sum * weight;
final double oldn = n; // tmp copy
n += weight;
sum += val;
m2 += tmp * tmp / (weight * n * oldn);
} | java | @Override
public void put(double val, double weight) {
if(weight == 0.) {
return;
}
if(n <= 0) {
n = weight;
sum = val * weight;
return;
}
val *= weight;
final double tmp = n * val - sum * weight;
final double oldn = n; // tmp copy
n += weight;
sum += val;
m2 += tmp * tmp / (weight * n * oldn);
} | [
"@",
"Override",
"public",
"void",
"put",
"(",
"double",
"val",
",",
"double",
"weight",
")",
"{",
"if",
"(",
"weight",
"==",
"0.",
")",
"{",
"return",
";",
"}",
"if",
"(",
"n",
"<=",
"0",
")",
"{",
"n",
"=",
"weight",
";",
"sum",
"=",
"val",
"*",
"weight",
";",
"return",
";",
"}",
"val",
"*=",
"weight",
";",
"final",
"double",
"tmp",
"=",
"n",
"*",
"val",
"-",
"sum",
"*",
"weight",
";",
"final",
"double",
"oldn",
"=",
"n",
";",
"// tmp copy",
"n",
"+=",
"weight",
";",
"sum",
"+=",
"val",
";",
"m2",
"+=",
"tmp",
"*",
"tmp",
"/",
"(",
"weight",
"*",
"n",
"*",
"oldn",
")",
";",
"}"
] | Add data with a given weight.
@param val data
@param weight weight | [
"Add",
"data",
"with",
"a",
"given",
"weight",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/MeanVariance.java#L136-L152 |
UrielCh/ovh-java-sdk | ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java | ApiOvhHostingweb.serviceName_restoreSnapshot_POST | public OvhTask serviceName_restoreSnapshot_POST(String serviceName, net.minidev.ovh.api.hosting.web.backup.OvhTypeEnum backup) throws IOException {
"""
Restore this snapshot ALL CURRENT DATA WILL BE REPLACED BY YOUR SNAPSHOT
REST: POST /hosting/web/{serviceName}/restoreSnapshot
@param backup [required] The backup you want to restore
@param serviceName [required] The internal name of your hosting
"""
String qPath = "/hosting/web/{serviceName}/restoreSnapshot";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "backup", backup);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | java | public OvhTask serviceName_restoreSnapshot_POST(String serviceName, net.minidev.ovh.api.hosting.web.backup.OvhTypeEnum backup) throws IOException {
String qPath = "/hosting/web/{serviceName}/restoreSnapshot";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "backup", backup);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | [
"public",
"OvhTask",
"serviceName_restoreSnapshot_POST",
"(",
"String",
"serviceName",
",",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"hosting",
".",
"web",
".",
"backup",
".",
"OvhTypeEnum",
"backup",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/hosting/web/{serviceName}/restoreSnapshot\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"backup\"",
",",
"backup",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhTask",
".",
"class",
")",
";",
"}"
] | Restore this snapshot ALL CURRENT DATA WILL BE REPLACED BY YOUR SNAPSHOT
REST: POST /hosting/web/{serviceName}/restoreSnapshot
@param backup [required] The backup you want to restore
@param serviceName [required] The internal name of your hosting | [
"Restore",
"this",
"snapshot",
"ALL",
"CURRENT",
"DATA",
"WILL",
"BE",
"REPLACED",
"BY",
"YOUR",
"SNAPSHOT"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java#L1066-L1073 |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java | ColorHolder.applyToOrTransparent | public static void applyToOrTransparent(ColorHolder colorHolder, Context ctx, GradientDrawable gradientDrawable) {
"""
a small static helper to set the color to a GradientDrawable null save
@param colorHolder
@param ctx
@param gradientDrawable
"""
if (colorHolder != null && gradientDrawable != null) {
colorHolder.applyTo(ctx, gradientDrawable);
} else if (gradientDrawable != null) {
gradientDrawable.setColor(Color.TRANSPARENT);
}
} | java | public static void applyToOrTransparent(ColorHolder colorHolder, Context ctx, GradientDrawable gradientDrawable) {
if (colorHolder != null && gradientDrawable != null) {
colorHolder.applyTo(ctx, gradientDrawable);
} else if (gradientDrawable != null) {
gradientDrawable.setColor(Color.TRANSPARENT);
}
} | [
"public",
"static",
"void",
"applyToOrTransparent",
"(",
"ColorHolder",
"colorHolder",
",",
"Context",
"ctx",
",",
"GradientDrawable",
"gradientDrawable",
")",
"{",
"if",
"(",
"colorHolder",
"!=",
"null",
"&&",
"gradientDrawable",
"!=",
"null",
")",
"{",
"colorHolder",
".",
"applyTo",
"(",
"ctx",
",",
"gradientDrawable",
")",
";",
"}",
"else",
"if",
"(",
"gradientDrawable",
"!=",
"null",
")",
"{",
"gradientDrawable",
".",
"setColor",
"(",
"Color",
".",
"TRANSPARENT",
")",
";",
"}",
"}"
] | a small static helper to set the color to a GradientDrawable null save
@param colorHolder
@param ctx
@param gradientDrawable | [
"a",
"small",
"static",
"helper",
"to",
"set",
"the",
"color",
"to",
"a",
"GradientDrawable",
"null",
"save"
] | train | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L184-L190 |
hellosign/hellosign-java-sdk | src/main/java/com/hellosign/sdk/resource/Event.java | Event.isValid | public boolean isValid(String apiKey) throws HelloSignException {
"""
Returns true if the event hash matches the computed hash using the
provided API key.
@param apiKey String api key.
@return true if the hashes match, false otherwise
@throws HelloSignException thrown if there is a problem parsing the API
key.
"""
if (apiKey == null || apiKey == "") {
return false;
}
try {
Mac sha256HMAC = Mac.getInstance(HASH_ALGORITHM);
SecretKeySpec secretKey = new SecretKeySpec(apiKey.getBytes(), HASH_ALGORITHM);
sha256HMAC.init(secretKey);
String data = String.valueOf(getLong(EVENT_TIME)) + getType();
String computedHash = bytesToHex(sha256HMAC.doFinal(data.getBytes()));
String providedHash = getString(EVENT_HASH);
return computedHash.equalsIgnoreCase(providedHash);
} catch (InvalidKeyException e) {
throw new HelloSignException("Invalid API Key (" + e.getMessage() + "): " + apiKey);
} catch (IllegalArgumentException e) {
throw new HelloSignException("Invalid API Key (" + e.getMessage() + "): " + apiKey);
} catch (NoSuchAlgorithmException e) {
throw new HelloSignException("Unable to process API key", e);
}
} | java | public boolean isValid(String apiKey) throws HelloSignException {
if (apiKey == null || apiKey == "") {
return false;
}
try {
Mac sha256HMAC = Mac.getInstance(HASH_ALGORITHM);
SecretKeySpec secretKey = new SecretKeySpec(apiKey.getBytes(), HASH_ALGORITHM);
sha256HMAC.init(secretKey);
String data = String.valueOf(getLong(EVENT_TIME)) + getType();
String computedHash = bytesToHex(sha256HMAC.doFinal(data.getBytes()));
String providedHash = getString(EVENT_HASH);
return computedHash.equalsIgnoreCase(providedHash);
} catch (InvalidKeyException e) {
throw new HelloSignException("Invalid API Key (" + e.getMessage() + "): " + apiKey);
} catch (IllegalArgumentException e) {
throw new HelloSignException("Invalid API Key (" + e.getMessage() + "): " + apiKey);
} catch (NoSuchAlgorithmException e) {
throw new HelloSignException("Unable to process API key", e);
}
} | [
"public",
"boolean",
"isValid",
"(",
"String",
"apiKey",
")",
"throws",
"HelloSignException",
"{",
"if",
"(",
"apiKey",
"==",
"null",
"||",
"apiKey",
"==",
"\"\"",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"Mac",
"sha256HMAC",
"=",
"Mac",
".",
"getInstance",
"(",
"HASH_ALGORITHM",
")",
";",
"SecretKeySpec",
"secretKey",
"=",
"new",
"SecretKeySpec",
"(",
"apiKey",
".",
"getBytes",
"(",
")",
",",
"HASH_ALGORITHM",
")",
";",
"sha256HMAC",
".",
"init",
"(",
"secretKey",
")",
";",
"String",
"data",
"=",
"String",
".",
"valueOf",
"(",
"getLong",
"(",
"EVENT_TIME",
")",
")",
"+",
"getType",
"(",
")",
";",
"String",
"computedHash",
"=",
"bytesToHex",
"(",
"sha256HMAC",
".",
"doFinal",
"(",
"data",
".",
"getBytes",
"(",
")",
")",
")",
";",
"String",
"providedHash",
"=",
"getString",
"(",
"EVENT_HASH",
")",
";",
"return",
"computedHash",
".",
"equalsIgnoreCase",
"(",
"providedHash",
")",
";",
"}",
"catch",
"(",
"InvalidKeyException",
"e",
")",
"{",
"throw",
"new",
"HelloSignException",
"(",
"\"Invalid API Key (\"",
"+",
"e",
".",
"getMessage",
"(",
")",
"+",
"\"): \"",
"+",
"apiKey",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"HelloSignException",
"(",
"\"Invalid API Key (\"",
"+",
"e",
".",
"getMessage",
"(",
")",
"+",
"\"): \"",
"+",
"apiKey",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"throw",
"new",
"HelloSignException",
"(",
"\"Unable to process API key\"",
",",
"e",
")",
";",
"}",
"}"
] | Returns true if the event hash matches the computed hash using the
provided API key.
@param apiKey String api key.
@return true if the hashes match, false otherwise
@throws HelloSignException thrown if there is a problem parsing the API
key. | [
"Returns",
"true",
"if",
"the",
"event",
"hash",
"matches",
"the",
"computed",
"hash",
"using",
"the",
"provided",
"API",
"key",
"."
] | train | https://github.com/hellosign/hellosign-java-sdk/blob/08fa7aeb3b0c68ddb6c7ea797d114d55d36d36b1/src/main/java/com/hellosign/sdk/resource/Event.java#L317-L336 |
apereo/cas | support/cas-server-support-aws/src/main/java/org/apereo/cas/aws/AmazonEnvironmentAwareClientBuilder.java | AmazonEnvironmentAwareClientBuilder.getSetting | public String getSetting(final String key, final String defaultValue) {
"""
Gets setting.
@param key the key
@param defaultValue the default value
@return the setting
"""
val result = environment.getProperty(this.propertyPrefix + '.' + key);
return StringUtils.defaultIfBlank(result, defaultValue);
} | java | public String getSetting(final String key, final String defaultValue) {
val result = environment.getProperty(this.propertyPrefix + '.' + key);
return StringUtils.defaultIfBlank(result, defaultValue);
} | [
"public",
"String",
"getSetting",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"defaultValue",
")",
"{",
"val",
"result",
"=",
"environment",
".",
"getProperty",
"(",
"this",
".",
"propertyPrefix",
"+",
"'",
"'",
"+",
"key",
")",
";",
"return",
"StringUtils",
".",
"defaultIfBlank",
"(",
"result",
",",
"defaultValue",
")",
";",
"}"
] | Gets setting.
@param key the key
@param defaultValue the default value
@return the setting | [
"Gets",
"setting",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-aws/src/main/java/org/apereo/cas/aws/AmazonEnvironmentAwareClientBuilder.java#L43-L46 |
vanilladb/vanillacore | src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java | LockTable.sixLock | void sixLock(Object obj, long txNum) {
"""
Grants an sixlock on the specified item. If any conflict lock exists when
the method is called, then the calling thread will be placed on a wait
list until the lock is released. If the thread remains on the wait list
for a certain amount of time, then an exception is thrown.
@param obj
a lockable item
@param txNum
a transaction number
"""
Object anchor = getAnchor(obj);
txWaitMap.put(txNum, anchor);
synchronized (anchor) {
Lockers lks = prepareLockers(obj);
if (hasSixLock(lks, txNum))
return;
try {
long timestamp = System.currentTimeMillis();
while (!sixLockable(lks, txNum) && !waitingTooLong(timestamp)) {
avoidDeadlock(lks, txNum, SIX_LOCK);
lks.requestSet.add(txNum);
anchor.wait(MAX_TIME);
lks.requestSet.remove(txNum);
}
if (!sixLockable(lks, txNum))
throw new LockAbortException();
lks.sixLocker = txNum;
getObjectSet(txNum).add(obj);
} catch (InterruptedException e) {
throw new LockAbortException();
}
}
txWaitMap.remove(txNum);
} | java | void sixLock(Object obj, long txNum) {
Object anchor = getAnchor(obj);
txWaitMap.put(txNum, anchor);
synchronized (anchor) {
Lockers lks = prepareLockers(obj);
if (hasSixLock(lks, txNum))
return;
try {
long timestamp = System.currentTimeMillis();
while (!sixLockable(lks, txNum) && !waitingTooLong(timestamp)) {
avoidDeadlock(lks, txNum, SIX_LOCK);
lks.requestSet.add(txNum);
anchor.wait(MAX_TIME);
lks.requestSet.remove(txNum);
}
if (!sixLockable(lks, txNum))
throw new LockAbortException();
lks.sixLocker = txNum;
getObjectSet(txNum).add(obj);
} catch (InterruptedException e) {
throw new LockAbortException();
}
}
txWaitMap.remove(txNum);
} | [
"void",
"sixLock",
"(",
"Object",
"obj",
",",
"long",
"txNum",
")",
"{",
"Object",
"anchor",
"=",
"getAnchor",
"(",
"obj",
")",
";",
"txWaitMap",
".",
"put",
"(",
"txNum",
",",
"anchor",
")",
";",
"synchronized",
"(",
"anchor",
")",
"{",
"Lockers",
"lks",
"=",
"prepareLockers",
"(",
"obj",
")",
";",
"if",
"(",
"hasSixLock",
"(",
"lks",
",",
"txNum",
")",
")",
"return",
";",
"try",
"{",
"long",
"timestamp",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"while",
"(",
"!",
"sixLockable",
"(",
"lks",
",",
"txNum",
")",
"&&",
"!",
"waitingTooLong",
"(",
"timestamp",
")",
")",
"{",
"avoidDeadlock",
"(",
"lks",
",",
"txNum",
",",
"SIX_LOCK",
")",
";",
"lks",
".",
"requestSet",
".",
"add",
"(",
"txNum",
")",
";",
"anchor",
".",
"wait",
"(",
"MAX_TIME",
")",
";",
"lks",
".",
"requestSet",
".",
"remove",
"(",
"txNum",
")",
";",
"}",
"if",
"(",
"!",
"sixLockable",
"(",
"lks",
",",
"txNum",
")",
")",
"throw",
"new",
"LockAbortException",
"(",
")",
";",
"lks",
".",
"sixLocker",
"=",
"txNum",
";",
"getObjectSet",
"(",
"txNum",
")",
".",
"add",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"LockAbortException",
"(",
")",
";",
"}",
"}",
"txWaitMap",
".",
"remove",
"(",
"txNum",
")",
";",
"}"
] | Grants an sixlock on the specified item. If any conflict lock exists when
the method is called, then the calling thread will be placed on a wait
list until the lock is released. If the thread remains on the wait list
for a certain amount of time, then an exception is thrown.
@param obj
a lockable item
@param txNum
a transaction number | [
"Grants",
"an",
"sixlock",
"on",
"the",
"specified",
"item",
".",
"If",
"any",
"conflict",
"lock",
"exists",
"when",
"the",
"method",
"is",
"called",
"then",
"the",
"calling",
"thread",
"will",
"be",
"placed",
"on",
"a",
"wait",
"list",
"until",
"the",
"lock",
"is",
"released",
".",
"If",
"the",
"thread",
"remains",
"on",
"the",
"wait",
"list",
"for",
"a",
"certain",
"amount",
"of",
"time",
"then",
"an",
"exception",
"is",
"thrown",
"."
] | train | https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java#L268-L295 |
notnoop/java-apns | src/main/java/com/notnoop/apns/internal/SSLContextBuilder.java | SSLContextBuilder.getKeyStoreWithSingleKey | private KeyStore getKeyStoreWithSingleKey(KeyStore keyStore, String keyStorePassword, String keyAlias)
throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException {
"""
/*
Workaround for keystores containing multiple keys. Java will take the first key that matches
and this way we can still offer configuration for a keystore with multiple keys and a selection
based on alias. Also much easier than making a subclass of a KeyManagerFactory
"""
KeyStore singleKeyKeyStore = KeyStore.getInstance(keyStore.getType(), keyStore.getProvider());
final char[] password = keyStorePassword.toCharArray();
singleKeyKeyStore.load(null, password);
Key key = keyStore.getKey(keyAlias, password);
Certificate[] chain = keyStore.getCertificateChain(keyAlias);
singleKeyKeyStore.setKeyEntry(keyAlias, key, password, chain);
return singleKeyKeyStore;
} | java | private KeyStore getKeyStoreWithSingleKey(KeyStore keyStore, String keyStorePassword, String keyAlias)
throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException {
KeyStore singleKeyKeyStore = KeyStore.getInstance(keyStore.getType(), keyStore.getProvider());
final char[] password = keyStorePassword.toCharArray();
singleKeyKeyStore.load(null, password);
Key key = keyStore.getKey(keyAlias, password);
Certificate[] chain = keyStore.getCertificateChain(keyAlias);
singleKeyKeyStore.setKeyEntry(keyAlias, key, password, chain);
return singleKeyKeyStore;
} | [
"private",
"KeyStore",
"getKeyStoreWithSingleKey",
"(",
"KeyStore",
"keyStore",
",",
"String",
"keyStorePassword",
",",
"String",
"keyAlias",
")",
"throws",
"KeyStoreException",
",",
"IOException",
",",
"NoSuchAlgorithmException",
",",
"CertificateException",
",",
"UnrecoverableKeyException",
"{",
"KeyStore",
"singleKeyKeyStore",
"=",
"KeyStore",
".",
"getInstance",
"(",
"keyStore",
".",
"getType",
"(",
")",
",",
"keyStore",
".",
"getProvider",
"(",
")",
")",
";",
"final",
"char",
"[",
"]",
"password",
"=",
"keyStorePassword",
".",
"toCharArray",
"(",
")",
";",
"singleKeyKeyStore",
".",
"load",
"(",
"null",
",",
"password",
")",
";",
"Key",
"key",
"=",
"keyStore",
".",
"getKey",
"(",
"keyAlias",
",",
"password",
")",
";",
"Certificate",
"[",
"]",
"chain",
"=",
"keyStore",
".",
"getCertificateChain",
"(",
"keyAlias",
")",
";",
"singleKeyKeyStore",
".",
"setKeyEntry",
"(",
"keyAlias",
",",
"key",
",",
"password",
",",
"chain",
")",
";",
"return",
"singleKeyKeyStore",
";",
"}"
] | /*
Workaround for keystores containing multiple keys. Java will take the first key that matches
and this way we can still offer configuration for a keystore with multiple keys and a selection
based on alias. Also much easier than making a subclass of a KeyManagerFactory | [
"/",
"*",
"Workaround",
"for",
"keystores",
"containing",
"multiple",
"keys",
".",
"Java",
"will",
"take",
"the",
"first",
"key",
"that",
"matches",
"and",
"this",
"way",
"we",
"can",
"still",
"offer",
"configuration",
"for",
"a",
"keystore",
"with",
"multiple",
"keys",
"and",
"a",
"selection",
"based",
"on",
"alias",
".",
"Also",
"much",
"easier",
"than",
"making",
"a",
"subclass",
"of",
"a",
"KeyManagerFactory"
] | train | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/internal/SSLContextBuilder.java#L151-L160 |
salesforce/Argus | ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/dto/NotificationDto.java | NotificationDto.transformToDto | public static NotificationDto transformToDto(Notification notification) {
"""
Converts notification entity object to notificationDto object.
@param notification notification entity. Cannot be null.
@return notificationDto.
@throws WebApplicationException If an error occurs.
"""
if (notification == null) {
throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
}
NotificationDto result = createDtoObject(NotificationDto.class, notification);
result.setAlertId(notification.getAlert().getId());
for (Trigger trigger : notification.getTriggers()) {
result.addTriggersIds(trigger);
}
return result;
} | java | public static NotificationDto transformToDto(Notification notification) {
if (notification == null) {
throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
}
NotificationDto result = createDtoObject(NotificationDto.class, notification);
result.setAlertId(notification.getAlert().getId());
for (Trigger trigger : notification.getTriggers()) {
result.addTriggersIds(trigger);
}
return result;
} | [
"public",
"static",
"NotificationDto",
"transformToDto",
"(",
"Notification",
"notification",
")",
"{",
"if",
"(",
"notification",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"\"Null entity object cannot be converted to Dto object.\"",
",",
"Status",
".",
"INTERNAL_SERVER_ERROR",
")",
";",
"}",
"NotificationDto",
"result",
"=",
"createDtoObject",
"(",
"NotificationDto",
".",
"class",
",",
"notification",
")",
";",
"result",
".",
"setAlertId",
"(",
"notification",
".",
"getAlert",
"(",
")",
".",
"getId",
"(",
")",
")",
";",
"for",
"(",
"Trigger",
"trigger",
":",
"notification",
".",
"getTriggers",
"(",
")",
")",
"{",
"result",
".",
"addTriggersIds",
"(",
"trigger",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Converts notification entity object to notificationDto object.
@param notification notification entity. Cannot be null.
@return notificationDto.
@throws WebApplicationException If an error occurs. | [
"Converts",
"notification",
"entity",
"object",
"to",
"notificationDto",
"object",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/dto/NotificationDto.java#L78-L90 |
codescape/bitvunit | bitvunit-core/src/main/java/de/codescape/bitvunit/util/html/HtmlPageUtil.java | HtmlPageUtil.toHtmlPage | public static HtmlPage toHtmlPage(URL url) {
"""
Creates a {@link HtmlPage} from a given {@link URL} that points to the HTML code for that page.
@param url {@link URL} that points to the HTML code
@return {@link HtmlPage} for this {@link URL}
"""
try {
return (HtmlPage) new WebClient().getPage(url);
} catch (IOException e) {
throw new RuntimeException("Error creating HtmlPage from URL.", e);
}
} | java | public static HtmlPage toHtmlPage(URL url) {
try {
return (HtmlPage) new WebClient().getPage(url);
} catch (IOException e) {
throw new RuntimeException("Error creating HtmlPage from URL.", e);
}
} | [
"public",
"static",
"HtmlPage",
"toHtmlPage",
"(",
"URL",
"url",
")",
"{",
"try",
"{",
"return",
"(",
"HtmlPage",
")",
"new",
"WebClient",
"(",
")",
".",
"getPage",
"(",
"url",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error creating HtmlPage from URL.\"",
",",
"e",
")",
";",
"}",
"}"
] | Creates a {@link HtmlPage} from a given {@link URL} that points to the HTML code for that page.
@param url {@link URL} that points to the HTML code
@return {@link HtmlPage} for this {@link URL} | [
"Creates",
"a",
"{",
"@link",
"HtmlPage",
"}",
"from",
"a",
"given",
"{",
"@link",
"URL",
"}",
"that",
"points",
"to",
"the",
"HTML",
"code",
"for",
"that",
"page",
"."
] | train | https://github.com/codescape/bitvunit/blob/cef6d9af60d684e41294981c10b6d92c8f063a4e/bitvunit-core/src/main/java/de/codescape/bitvunit/util/html/HtmlPageUtil.java#L75-L81 |
adamfisk/littleshoot-util | src/main/java/org/littleshoot/util/JmxUtils.java | JmxUtils.getObjectName | public static <T> ObjectName getObjectName(final Class<T> clazz) {
"""
Returns an {@link ObjectName} for the specified object in standard
format, using the package as the domain.
@param <T> The type of class.
@param clazz The {@link Class} to create an {@link ObjectName} for.
@return The new {@link ObjectName}.
"""
final String domain = clazz.getPackage().getName();
final String className = clazz.getSimpleName();
final String objectName = domain+":type="+className;
LOG.debug("Returning object name: {}", objectName);
try
{
return new ObjectName(objectName);
}
catch (final MalformedObjectNameException e)
{
// This should never, ever happen.
LOG.error("Invalid ObjectName: "+objectName, e);
throw new RuntimeException("Could not create ObjectName?", e);
}
} | java | public static <T> ObjectName getObjectName(final Class<T> clazz)
{
final String domain = clazz.getPackage().getName();
final String className = clazz.getSimpleName();
final String objectName = domain+":type="+className;
LOG.debug("Returning object name: {}", objectName);
try
{
return new ObjectName(objectName);
}
catch (final MalformedObjectNameException e)
{
// This should never, ever happen.
LOG.error("Invalid ObjectName: "+objectName, e);
throw new RuntimeException("Could not create ObjectName?", e);
}
} | [
"public",
"static",
"<",
"T",
">",
"ObjectName",
"getObjectName",
"(",
"final",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"final",
"String",
"domain",
"=",
"clazz",
".",
"getPackage",
"(",
")",
".",
"getName",
"(",
")",
";",
"final",
"String",
"className",
"=",
"clazz",
".",
"getSimpleName",
"(",
")",
";",
"final",
"String",
"objectName",
"=",
"domain",
"+",
"\":type=\"",
"+",
"className",
";",
"LOG",
".",
"debug",
"(",
"\"Returning object name: {}\"",
",",
"objectName",
")",
";",
"try",
"{",
"return",
"new",
"ObjectName",
"(",
"objectName",
")",
";",
"}",
"catch",
"(",
"final",
"MalformedObjectNameException",
"e",
")",
"{",
"// This should never, ever happen.",
"LOG",
".",
"error",
"(",
"\"Invalid ObjectName: \"",
"+",
"objectName",
",",
"e",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not create ObjectName?\"",
",",
"e",
")",
";",
"}",
"}"
] | Returns an {@link ObjectName} for the specified object in standard
format, using the package as the domain.
@param <T> The type of class.
@param clazz The {@link Class} to create an {@link ObjectName} for.
@return The new {@link ObjectName}. | [
"Returns",
"an",
"{",
"@link",
"ObjectName",
"}",
"for",
"the",
"specified",
"object",
"in",
"standard",
"format",
"using",
"the",
"package",
"as",
"the",
"domain",
"."
] | train | https://github.com/adamfisk/littleshoot-util/blob/3c0dc4955116b3382d6b0575d2f164b7508a4f73/src/main/java/org/littleshoot/util/JmxUtils.java#L34-L50 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/dbinfo/DatabaseInformationFull.java | DatabaseInformationFull.COLLATIONS | Table COLLATIONS() {
"""
COLLATIONS<p>
<b>Function<b><p>
The COLLATIONS view has one row for each character collation
descriptor. <p>
<b>Definition</b>
<pre class="SqlCodeExample">
CREATE TABLE COLLATIONS (
COLLATION_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER,
COLLATION_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER,
COLLATION_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER,
PAD_ATTRIBUTE INFORMATION_SCHEMA.CHARACTER_DATA
CONSTRAINT COLLATIONS_PAD_ATTRIBUTE_CHECK
CHECK ( PAD_ATTRIBUTE IN
( 'NO PAD', 'PAD SPACE' ) )
)
</pre>
<b>Description</b><p>
<ol>
<li>The values of COLLATION_CATALOG, COLLATION_SCHEMA, and
COLLATION_NAME are the catalog name, unqualified schema name,
and qualified identifier, respectively, of the collation being
described.<p>
<li>The values of PAD_ATTRIBUTE have the following meanings:<p>
<table border cellpadding="3">
<tr>
<td nowrap>NO PAD</td>
<td nowrap>The collation being described has the NO PAD
characteristic.</td>
<tr>
<tr>
<td nowrap>PAD</td>
<td nowrap>The collation being described has the PAD SPACE
characteristic.</td>
<tr>
</table> <p>
</ol>
@return Table
"""
Table t = sysTables[COLLATIONS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[COLLATIONS]);
addColumn(t, "COLLATION_CATALOG", SQL_IDENTIFIER);
addColumn(t, "COLLATION_SCHEMA", SQL_IDENTIFIER); // not null
addColumn(t, "COLLATION_NAME", SQL_IDENTIFIER); // not null
addColumn(t, "PAD_ATTRIBUTE", CHARACTER_DATA);
// false PK, as rows may have NULL COLLATION_CATALOG
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(
sysTableHsqlNames[COLLATIONS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] {
0, 1, 2
}, false);
return t;
}
// Column number mappings
final int collation_catalog = 0;
final int collation_schema = 1;
final int collation_name = 2;
final int pad_attribute = 3;
//
PersistentStore store = database.persistentStoreCollection.getStore(t);
// Intermediate holders
Iterator collations;
String collation;
String collationSchema = SqlInvariants.PUBLIC_SCHEMA;
String padAttribute = "NO PAD";
Object[] row;
// Initialization
collations = Collation.nameToJavaName.keySet().iterator();
// Do it.
while (collations.hasNext()) {
row = t.getEmptyRowData();
collation = (String) collations.next();
row[collation_catalog] = database.getCatalogName().name;
row[collation_schema] = collationSchema;
row[collation_name] = collation;
row[pad_attribute] = padAttribute;
t.insertSys(store, row);
}
return t;
} | java | Table COLLATIONS() {
Table t = sysTables[COLLATIONS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[COLLATIONS]);
addColumn(t, "COLLATION_CATALOG", SQL_IDENTIFIER);
addColumn(t, "COLLATION_SCHEMA", SQL_IDENTIFIER); // not null
addColumn(t, "COLLATION_NAME", SQL_IDENTIFIER); // not null
addColumn(t, "PAD_ATTRIBUTE", CHARACTER_DATA);
// false PK, as rows may have NULL COLLATION_CATALOG
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(
sysTableHsqlNames[COLLATIONS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] {
0, 1, 2
}, false);
return t;
}
// Column number mappings
final int collation_catalog = 0;
final int collation_schema = 1;
final int collation_name = 2;
final int pad_attribute = 3;
//
PersistentStore store = database.persistentStoreCollection.getStore(t);
// Intermediate holders
Iterator collations;
String collation;
String collationSchema = SqlInvariants.PUBLIC_SCHEMA;
String padAttribute = "NO PAD";
Object[] row;
// Initialization
collations = Collation.nameToJavaName.keySet().iterator();
// Do it.
while (collations.hasNext()) {
row = t.getEmptyRowData();
collation = (String) collations.next();
row[collation_catalog] = database.getCatalogName().name;
row[collation_schema] = collationSchema;
row[collation_name] = collation;
row[pad_attribute] = padAttribute;
t.insertSys(store, row);
}
return t;
} | [
"Table",
"COLLATIONS",
"(",
")",
"{",
"Table",
"t",
"=",
"sysTables",
"[",
"COLLATIONS",
"]",
";",
"if",
"(",
"t",
"==",
"null",
")",
"{",
"t",
"=",
"createBlankTable",
"(",
"sysTableHsqlNames",
"[",
"COLLATIONS",
"]",
")",
";",
"addColumn",
"(",
"t",
",",
"\"COLLATION_CATALOG\"",
",",
"SQL_IDENTIFIER",
")",
";",
"addColumn",
"(",
"t",
",",
"\"COLLATION_SCHEMA\"",
",",
"SQL_IDENTIFIER",
")",
";",
"// not null",
"addColumn",
"(",
"t",
",",
"\"COLLATION_NAME\"",
",",
"SQL_IDENTIFIER",
")",
";",
"// not null",
"addColumn",
"(",
"t",
",",
"\"PAD_ATTRIBUTE\"",
",",
"CHARACTER_DATA",
")",
";",
"// false PK, as rows may have NULL COLLATION_CATALOG",
"HsqlName",
"name",
"=",
"HsqlNameManager",
".",
"newInfoSchemaObjectName",
"(",
"sysTableHsqlNames",
"[",
"COLLATIONS",
"]",
".",
"name",
",",
"false",
",",
"SchemaObject",
".",
"INDEX",
")",
";",
"t",
".",
"createPrimaryKey",
"(",
"name",
",",
"new",
"int",
"[",
"]",
"{",
"0",
",",
"1",
",",
"2",
"}",
",",
"false",
")",
";",
"return",
"t",
";",
"}",
"// Column number mappings",
"final",
"int",
"collation_catalog",
"=",
"0",
";",
"final",
"int",
"collation_schema",
"=",
"1",
";",
"final",
"int",
"collation_name",
"=",
"2",
";",
"final",
"int",
"pad_attribute",
"=",
"3",
";",
"//",
"PersistentStore",
"store",
"=",
"database",
".",
"persistentStoreCollection",
".",
"getStore",
"(",
"t",
")",
";",
"// Intermediate holders",
"Iterator",
"collations",
";",
"String",
"collation",
";",
"String",
"collationSchema",
"=",
"SqlInvariants",
".",
"PUBLIC_SCHEMA",
";",
"String",
"padAttribute",
"=",
"\"NO PAD\"",
";",
"Object",
"[",
"]",
"row",
";",
"// Initialization",
"collations",
"=",
"Collation",
".",
"nameToJavaName",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"// Do it.",
"while",
"(",
"collations",
".",
"hasNext",
"(",
")",
")",
"{",
"row",
"=",
"t",
".",
"getEmptyRowData",
"(",
")",
";",
"collation",
"=",
"(",
"String",
")",
"collations",
".",
"next",
"(",
")",
";",
"row",
"[",
"collation_catalog",
"]",
"=",
"database",
".",
"getCatalogName",
"(",
")",
".",
"name",
";",
"row",
"[",
"collation_schema",
"]",
"=",
"collationSchema",
";",
"row",
"[",
"collation_name",
"]",
"=",
"collation",
";",
"row",
"[",
"pad_attribute",
"]",
"=",
"padAttribute",
";",
"t",
".",
"insertSys",
"(",
"store",
",",
"row",
")",
";",
"}",
"return",
"t",
";",
"}"
] | COLLATIONS<p>
<b>Function<b><p>
The COLLATIONS view has one row for each character collation
descriptor. <p>
<b>Definition</b>
<pre class="SqlCodeExample">
CREATE TABLE COLLATIONS (
COLLATION_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER,
COLLATION_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER,
COLLATION_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER,
PAD_ATTRIBUTE INFORMATION_SCHEMA.CHARACTER_DATA
CONSTRAINT COLLATIONS_PAD_ATTRIBUTE_CHECK
CHECK ( PAD_ATTRIBUTE IN
( 'NO PAD', 'PAD SPACE' ) )
)
</pre>
<b>Description</b><p>
<ol>
<li>The values of COLLATION_CATALOG, COLLATION_SCHEMA, and
COLLATION_NAME are the catalog name, unqualified schema name,
and qualified identifier, respectively, of the collation being
described.<p>
<li>The values of PAD_ATTRIBUTE have the following meanings:<p>
<table border cellpadding="3">
<tr>
<td nowrap>NO PAD</td>
<td nowrap>The collation being described has the NO PAD
characteristic.</td>
<tr>
<tr>
<td nowrap>PAD</td>
<td nowrap>The collation being described has the PAD SPACE
characteristic.</td>
<tr>
</table> <p>
</ol>
@return Table | [
"COLLATIONS<p",
">"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/dbinfo/DatabaseInformationFull.java#L1882-L1937 |
alkacon/opencms-core | src/org/opencms/workplace/editors/CmsDialogCopyLanguage.java | CmsDialogCopyLanguage.transferContents | protected void transferContents(CmsXmlContent content, Locale sourceLocale, List<Locale> destLocales)
throws CmsException {
"""
Copies the contents from a source locale to a number of destination locales by overwriting them.<p>
@param content the xml content
@param sourceLocale the source locale
@param destLocales a list of destination locales
@throws CmsException if something goes wrong
"""
for (Iterator<Locale> i = destLocales.iterator(); i.hasNext();) {
Locale to = i.next();
if (content.hasLocale(to)) {
content.removeLocale(to);
}
content.copyLocale(sourceLocale, to);
}
} | java | protected void transferContents(CmsXmlContent content, Locale sourceLocale, List<Locale> destLocales)
throws CmsException {
for (Iterator<Locale> i = destLocales.iterator(); i.hasNext();) {
Locale to = i.next();
if (content.hasLocale(to)) {
content.removeLocale(to);
}
content.copyLocale(sourceLocale, to);
}
} | [
"protected",
"void",
"transferContents",
"(",
"CmsXmlContent",
"content",
",",
"Locale",
"sourceLocale",
",",
"List",
"<",
"Locale",
">",
"destLocales",
")",
"throws",
"CmsException",
"{",
"for",
"(",
"Iterator",
"<",
"Locale",
">",
"i",
"=",
"destLocales",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Locale",
"to",
"=",
"i",
".",
"next",
"(",
")",
";",
"if",
"(",
"content",
".",
"hasLocale",
"(",
"to",
")",
")",
"{",
"content",
".",
"removeLocale",
"(",
"to",
")",
";",
"}",
"content",
".",
"copyLocale",
"(",
"sourceLocale",
",",
"to",
")",
";",
"}",
"}"
] | Copies the contents from a source locale to a number of destination locales by overwriting them.<p>
@param content the xml content
@param sourceLocale the source locale
@param destLocales a list of destination locales
@throws CmsException if something goes wrong | [
"Copies",
"the",
"contents",
"from",
"a",
"source",
"locale",
"to",
"a",
"number",
"of",
"destination",
"locales",
"by",
"overwriting",
"them",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/editors/CmsDialogCopyLanguage.java#L331-L341 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/io/kml/KMLGeometry.java | KMLGeometry.toKMLPolygon | public static void toKMLPolygon(Polygon polygon, ExtrudeMode extrude, int altitudeModeEnum, StringBuilder sb) {
"""
A Polygon is defined by an outer boundary and 0 or more inner boundaries.
The boundaries, in turn, are defined by LinearRings.
Syntax :
<Polygon id="ID">
<!-- specific to Polygon -->
<extrude>0</extrude> <!-- boolean -->
<tessellate>0</tessellate> <!-- boolean -->
<altitudeMode>clampToGround</altitudeMode>
<!-- kml:altitudeModeEnum: clampToGround, relativeToGround, or absolute
-->
<!-- or, substitute gx:altitudeMode: clampToSeaFloor, relativeToSeaFloor
-->
<outerBoundaryIs>
<LinearRing>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</LinearRing>
</innerBoundaryIs>
</Polygon>
Supported syntax :
<Polygon>
<extrude>0</extrude>
<altitudeMode>clampToGround</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</LinearRing>
</innerBoundaryIs>
</Polygon>
@param polygon
"""
sb.append("<Polygon>");
appendExtrude(extrude, sb);
appendAltitudeMode(altitudeModeEnum, sb);
sb.append("<outerBoundaryIs>");
toKMLLinearRing(polygon.getExteriorRing(), extrude, altitudeModeEnum, sb);
sb.append("</outerBoundaryIs>");
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
sb.append("<innerBoundaryIs>");
toKMLLinearRing(polygon.getInteriorRingN(i), extrude, altitudeModeEnum, sb);
sb.append("</innerBoundaryIs>");
}
sb.append("</Polygon>");
} | java | public static void toKMLPolygon(Polygon polygon, ExtrudeMode extrude, int altitudeModeEnum, StringBuilder sb) {
sb.append("<Polygon>");
appendExtrude(extrude, sb);
appendAltitudeMode(altitudeModeEnum, sb);
sb.append("<outerBoundaryIs>");
toKMLLinearRing(polygon.getExteriorRing(), extrude, altitudeModeEnum, sb);
sb.append("</outerBoundaryIs>");
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
sb.append("<innerBoundaryIs>");
toKMLLinearRing(polygon.getInteriorRingN(i), extrude, altitudeModeEnum, sb);
sb.append("</innerBoundaryIs>");
}
sb.append("</Polygon>");
} | [
"public",
"static",
"void",
"toKMLPolygon",
"(",
"Polygon",
"polygon",
",",
"ExtrudeMode",
"extrude",
",",
"int",
"altitudeModeEnum",
",",
"StringBuilder",
"sb",
")",
"{",
"sb",
".",
"append",
"(",
"\"<Polygon>\"",
")",
";",
"appendExtrude",
"(",
"extrude",
",",
"sb",
")",
";",
"appendAltitudeMode",
"(",
"altitudeModeEnum",
",",
"sb",
")",
";",
"sb",
".",
"append",
"(",
"\"<outerBoundaryIs>\"",
")",
";",
"toKMLLinearRing",
"(",
"polygon",
".",
"getExteriorRing",
"(",
")",
",",
"extrude",
",",
"altitudeModeEnum",
",",
"sb",
")",
";",
"sb",
".",
"append",
"(",
"\"</outerBoundaryIs>\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"polygon",
".",
"getNumInteriorRing",
"(",
")",
";",
"i",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"\"<innerBoundaryIs>\"",
")",
";",
"toKMLLinearRing",
"(",
"polygon",
".",
"getInteriorRingN",
"(",
"i",
")",
",",
"extrude",
",",
"altitudeModeEnum",
",",
"sb",
")",
";",
"sb",
".",
"append",
"(",
"\"</innerBoundaryIs>\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"</Polygon>\"",
")",
";",
"}"
] | A Polygon is defined by an outer boundary and 0 or more inner boundaries.
The boundaries, in turn, are defined by LinearRings.
Syntax :
<Polygon id="ID">
<!-- specific to Polygon -->
<extrude>0</extrude> <!-- boolean -->
<tessellate>0</tessellate> <!-- boolean -->
<altitudeMode>clampToGround</altitudeMode>
<!-- kml:altitudeModeEnum: clampToGround, relativeToGround, or absolute
-->
<!-- or, substitute gx:altitudeMode: clampToSeaFloor, relativeToSeaFloor
-->
<outerBoundaryIs>
<LinearRing>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</LinearRing>
</innerBoundaryIs>
</Polygon>
Supported syntax :
<Polygon>
<extrude>0</extrude>
<altitudeMode>clampToGround</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</LinearRing>
</innerBoundaryIs>
</Polygon>
@param polygon | [
"A",
"Polygon",
"is",
"defined",
"by",
"an",
"outer",
"boundary",
"and",
"0",
"or",
"more",
"inner",
"boundaries",
".",
"The",
"boundaries",
"in",
"turn",
"are",
"defined",
"by",
"LinearRings",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/kml/KMLGeometry.java#L230-L243 |
infinispan/infinispan | extended-statistics/src/main/java/org/infinispan/stats/CacheStatisticManager.java | CacheStatisticManager.markAsWriteTransaction | public final void markAsWriteTransaction(GlobalTransaction globalTransaction, boolean local) {
"""
Marks the transaction as a write transaction (instead of a read only transaction)
@param local {@code true} if it is a local transaction.
"""
TransactionStatistics txs = getTransactionStatistic(globalTransaction, local);
if (txs == null) {
log.markUnexistingTransactionAsWriteTransaction(globalTransaction == null ? "null" : globalTransaction.globalId());
return;
}
txs.markAsUpdateTransaction();
} | java | public final void markAsWriteTransaction(GlobalTransaction globalTransaction, boolean local) {
TransactionStatistics txs = getTransactionStatistic(globalTransaction, local);
if (txs == null) {
log.markUnexistingTransactionAsWriteTransaction(globalTransaction == null ? "null" : globalTransaction.globalId());
return;
}
txs.markAsUpdateTransaction();
} | [
"public",
"final",
"void",
"markAsWriteTransaction",
"(",
"GlobalTransaction",
"globalTransaction",
",",
"boolean",
"local",
")",
"{",
"TransactionStatistics",
"txs",
"=",
"getTransactionStatistic",
"(",
"globalTransaction",
",",
"local",
")",
";",
"if",
"(",
"txs",
"==",
"null",
")",
"{",
"log",
".",
"markUnexistingTransactionAsWriteTransaction",
"(",
"globalTransaction",
"==",
"null",
"?",
"\"null\"",
":",
"globalTransaction",
".",
"globalId",
"(",
")",
")",
";",
"return",
";",
"}",
"txs",
".",
"markAsUpdateTransaction",
"(",
")",
";",
"}"
] | Marks the transaction as a write transaction (instead of a read only transaction)
@param local {@code true} if it is a local transaction. | [
"Marks",
"the",
"transaction",
"as",
"a",
"write",
"transaction",
"(",
"instead",
"of",
"a",
"read",
"only",
"transaction",
")"
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/extended-statistics/src/main/java/org/infinispan/stats/CacheStatisticManager.java#L156-L163 |
querydsl/querydsl | querydsl-core/src/main/java/com/querydsl/core/types/dsl/BeanPath.java | BeanPath.createArray | protected <A, E> ArrayPath<A, E> createArray(String property, Class<? super A> type) {
"""
Create a new array path
@param <A>
@param property property name
@param type property type
@return property path
"""
return add(new ArrayPath<A, E>(type, forProperty(property)));
} | java | protected <A, E> ArrayPath<A, E> createArray(String property, Class<? super A> type) {
return add(new ArrayPath<A, E>(type, forProperty(property)));
} | [
"protected",
"<",
"A",
",",
"E",
">",
"ArrayPath",
"<",
"A",
",",
"E",
">",
"createArray",
"(",
"String",
"property",
",",
"Class",
"<",
"?",
"super",
"A",
">",
"type",
")",
"{",
"return",
"add",
"(",
"new",
"ArrayPath",
"<",
"A",
",",
"E",
">",
"(",
"type",
",",
"forProperty",
"(",
"property",
")",
")",
")",
";",
"}"
] | Create a new array path
@param <A>
@param property property name
@param type property type
@return property path | [
"Create",
"a",
"new",
"array",
"path"
] | train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/BeanPath.java#L127-L129 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/URI.java | URI.initializeScheme | private void initializeScheme(String p_uriSpec) throws MalformedURIException {
"""
Initialize the scheme for this URI from a URI string spec.
@param p_uriSpec the URI specification (cannot be null)
@throws MalformedURIException if URI does not have a conformant
scheme
"""
int uriSpecLen = p_uriSpec.length();
int index = 0;
String scheme = null;
char testChar = '\0';
while (index < uriSpecLen)
{
testChar = p_uriSpec.charAt(index);
if (testChar == ':' || testChar == '/' || testChar == '?'
|| testChar == '#')
{
break;
}
index++;
}
scheme = p_uriSpec.substring(0, index);
if (scheme.length() == 0)
{
throw new MalformedURIException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_SCHEME_INURI, null)); //"No scheme found in URI.");
}
else
{
setScheme(scheme);
}
} | java | private void initializeScheme(String p_uriSpec) throws MalformedURIException
{
int uriSpecLen = p_uriSpec.length();
int index = 0;
String scheme = null;
char testChar = '\0';
while (index < uriSpecLen)
{
testChar = p_uriSpec.charAt(index);
if (testChar == ':' || testChar == '/' || testChar == '?'
|| testChar == '#')
{
break;
}
index++;
}
scheme = p_uriSpec.substring(0, index);
if (scheme.length() == 0)
{
throw new MalformedURIException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_SCHEME_INURI, null)); //"No scheme found in URI.");
}
else
{
setScheme(scheme);
}
} | [
"private",
"void",
"initializeScheme",
"(",
"String",
"p_uriSpec",
")",
"throws",
"MalformedURIException",
"{",
"int",
"uriSpecLen",
"=",
"p_uriSpec",
".",
"length",
"(",
")",
";",
"int",
"index",
"=",
"0",
";",
"String",
"scheme",
"=",
"null",
";",
"char",
"testChar",
"=",
"'",
"'",
";",
"while",
"(",
"index",
"<",
"uriSpecLen",
")",
"{",
"testChar",
"=",
"p_uriSpec",
".",
"charAt",
"(",
"index",
")",
";",
"if",
"(",
"testChar",
"==",
"'",
"'",
"||",
"testChar",
"==",
"'",
"'",
"||",
"testChar",
"==",
"'",
"'",
"||",
"testChar",
"==",
"'",
"'",
")",
"{",
"break",
";",
"}",
"index",
"++",
";",
"}",
"scheme",
"=",
"p_uriSpec",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"if",
"(",
"scheme",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"MalformedURIException",
"(",
"XMLMessages",
".",
"createXMLMessage",
"(",
"XMLErrorResources",
".",
"ER_NO_SCHEME_INURI",
",",
"null",
")",
")",
";",
"//\"No scheme found in URI.\");",
"}",
"else",
"{",
"setScheme",
"(",
"scheme",
")",
";",
"}",
"}"
] | Initialize the scheme for this URI from a URI string spec.
@param p_uriSpec the URI specification (cannot be null)
@throws MalformedURIException if URI does not have a conformant
scheme | [
"Initialize",
"the",
"scheme",
"for",
"this",
"URI",
"from",
"a",
"URI",
"string",
"spec",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/URI.java#L600-L631 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/ClassReader.java | ClassReader.complete | private void complete(Symbol sym) throws CompletionFailure {
"""
Completion for classes to be loaded. Before a class is loaded
we make sure its enclosing class (if any) is loaded.
"""
if (sym.kind == TYP) {
ClassSymbol c = (ClassSymbol)sym;
c.members_field = new Scope.ErrorScope(c); // make sure it's always defined
annotate.enterStart();
try {
completeOwners(c.owner);
completeEnclosing(c);
} finally {
// The flush needs to happen only after annotations
// are filled in.
annotate.enterDoneWithoutFlush();
}
fillIn(c);
} else if (sym.kind == PCK) {
PackageSymbol p = (PackageSymbol)sym;
try {
fillIn(p);
} catch (IOException ex) {
throw new CompletionFailure(sym, ex.getLocalizedMessage()).initCause(ex);
}
}
if (!filling)
annotate.flush(); // finish attaching annotations
} | java | private void complete(Symbol sym) throws CompletionFailure {
if (sym.kind == TYP) {
ClassSymbol c = (ClassSymbol)sym;
c.members_field = new Scope.ErrorScope(c); // make sure it's always defined
annotate.enterStart();
try {
completeOwners(c.owner);
completeEnclosing(c);
} finally {
// The flush needs to happen only after annotations
// are filled in.
annotate.enterDoneWithoutFlush();
}
fillIn(c);
} else if (sym.kind == PCK) {
PackageSymbol p = (PackageSymbol)sym;
try {
fillIn(p);
} catch (IOException ex) {
throw new CompletionFailure(sym, ex.getLocalizedMessage()).initCause(ex);
}
}
if (!filling)
annotate.flush(); // finish attaching annotations
} | [
"private",
"void",
"complete",
"(",
"Symbol",
"sym",
")",
"throws",
"CompletionFailure",
"{",
"if",
"(",
"sym",
".",
"kind",
"==",
"TYP",
")",
"{",
"ClassSymbol",
"c",
"=",
"(",
"ClassSymbol",
")",
"sym",
";",
"c",
".",
"members_field",
"=",
"new",
"Scope",
".",
"ErrorScope",
"(",
"c",
")",
";",
"// make sure it's always defined",
"annotate",
".",
"enterStart",
"(",
")",
";",
"try",
"{",
"completeOwners",
"(",
"c",
".",
"owner",
")",
";",
"completeEnclosing",
"(",
"c",
")",
";",
"}",
"finally",
"{",
"// The flush needs to happen only after annotations",
"// are filled in.",
"annotate",
".",
"enterDoneWithoutFlush",
"(",
")",
";",
"}",
"fillIn",
"(",
"c",
")",
";",
"}",
"else",
"if",
"(",
"sym",
".",
"kind",
"==",
"PCK",
")",
"{",
"PackageSymbol",
"p",
"=",
"(",
"PackageSymbol",
")",
"sym",
";",
"try",
"{",
"fillIn",
"(",
"p",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"CompletionFailure",
"(",
"sym",
",",
"ex",
".",
"getLocalizedMessage",
"(",
")",
")",
".",
"initCause",
"(",
"ex",
")",
";",
"}",
"}",
"if",
"(",
"!",
"filling",
")",
"annotate",
".",
"flush",
"(",
")",
";",
"// finish attaching annotations",
"}"
] | Completion for classes to be loaded. Before a class is loaded
we make sure its enclosing class (if any) is loaded. | [
"Completion",
"for",
"classes",
"to",
"be",
"loaded",
".",
"Before",
"a",
"class",
"is",
"loaded",
"we",
"make",
"sure",
"its",
"enclosing",
"class",
"(",
"if",
"any",
")",
"is",
"loaded",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java#L2442-L2466 |
networknt/light-4j | client/src/main/java/com/networknt/client/oauth/OauthHelper.java | OauthHelper.adjustNoChunkedEncoding | public static void adjustNoChunkedEncoding(ClientRequest request, String requestBody) {
"""
this method is to support sending a server which doesn't support chunked transfer encoding.
"""
String fixedLengthString = request.getRequestHeaders().getFirst(Headers.CONTENT_LENGTH);
String transferEncodingString = request.getRequestHeaders().getLast(Headers.TRANSFER_ENCODING);
if(transferEncodingString != null) {
request.getRequestHeaders().remove(Headers.TRANSFER_ENCODING);
}
//if already specify a content-length, should use what they provided
if(fixedLengthString != null && Long.parseLong(fixedLengthString) > 0) {
return;
}
if(!StringUtils.isEmpty(requestBody)) {
long contentLength = requestBody.getBytes(UTF_8).length;
request.getRequestHeaders().put(Headers.CONTENT_LENGTH, contentLength);
}
} | java | public static void adjustNoChunkedEncoding(ClientRequest request, String requestBody) {
String fixedLengthString = request.getRequestHeaders().getFirst(Headers.CONTENT_LENGTH);
String transferEncodingString = request.getRequestHeaders().getLast(Headers.TRANSFER_ENCODING);
if(transferEncodingString != null) {
request.getRequestHeaders().remove(Headers.TRANSFER_ENCODING);
}
//if already specify a content-length, should use what they provided
if(fixedLengthString != null && Long.parseLong(fixedLengthString) > 0) {
return;
}
if(!StringUtils.isEmpty(requestBody)) {
long contentLength = requestBody.getBytes(UTF_8).length;
request.getRequestHeaders().put(Headers.CONTENT_LENGTH, contentLength);
}
} | [
"public",
"static",
"void",
"adjustNoChunkedEncoding",
"(",
"ClientRequest",
"request",
",",
"String",
"requestBody",
")",
"{",
"String",
"fixedLengthString",
"=",
"request",
".",
"getRequestHeaders",
"(",
")",
".",
"getFirst",
"(",
"Headers",
".",
"CONTENT_LENGTH",
")",
";",
"String",
"transferEncodingString",
"=",
"request",
".",
"getRequestHeaders",
"(",
")",
".",
"getLast",
"(",
"Headers",
".",
"TRANSFER_ENCODING",
")",
";",
"if",
"(",
"transferEncodingString",
"!=",
"null",
")",
"{",
"request",
".",
"getRequestHeaders",
"(",
")",
".",
"remove",
"(",
"Headers",
".",
"TRANSFER_ENCODING",
")",
";",
"}",
"//if already specify a content-length, should use what they provided",
"if",
"(",
"fixedLengthString",
"!=",
"null",
"&&",
"Long",
".",
"parseLong",
"(",
"fixedLengthString",
")",
">",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"StringUtils",
".",
"isEmpty",
"(",
"requestBody",
")",
")",
"{",
"long",
"contentLength",
"=",
"requestBody",
".",
"getBytes",
"(",
"UTF_8",
")",
".",
"length",
";",
"request",
".",
"getRequestHeaders",
"(",
")",
".",
"put",
"(",
"Headers",
".",
"CONTENT_LENGTH",
",",
"contentLength",
")",
";",
"}",
"}"
] | this method is to support sending a server which doesn't support chunked transfer encoding. | [
"this",
"method",
"is",
"to",
"support",
"sending",
"a",
"server",
"which",
"doesn",
"t",
"support",
"chunked",
"transfer",
"encoding",
"."
] | train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/oauth/OauthHelper.java#L736-L751 |
alkacon/opencms-core | src/org/opencms/search/CmsSearchIndex.java | CmsSearchIndex.isSortScoring | protected boolean isSortScoring(IndexSearcher searcher, Sort sort) {
"""
Checks if the score for the results must be calculated based on the provided sort option.<p>
Since Lucene 3 apparently the score is no longer calculated by default, but only if the
searcher is explicitly told so. This methods checks if, based on the given sort,
the score must be calculated.<p>
@param searcher the index searcher to prepare
@param sort the sort option to use
@return true if the sort option should be used
"""
boolean doScoring = false;
if (sort != null) {
if ((sort == CmsSearchParameters.SORT_DEFAULT) || (sort == CmsSearchParameters.SORT_TITLE)) {
// these default sorts do need score calculation
doScoring = true;
} else if ((sort == CmsSearchParameters.SORT_DATE_CREATED)
|| (sort == CmsSearchParameters.SORT_DATE_LASTMODIFIED)) {
// these default sorts don't need score calculation
doScoring = false;
} else {
// for all non-defaults: check if the score field is present, in that case we must calculate the score
SortField[] fields = sort.getSort();
for (SortField field : fields) {
if (field == SortField.FIELD_SCORE) {
doScoring = true;
break;
}
}
}
}
return doScoring;
} | java | protected boolean isSortScoring(IndexSearcher searcher, Sort sort) {
boolean doScoring = false;
if (sort != null) {
if ((sort == CmsSearchParameters.SORT_DEFAULT) || (sort == CmsSearchParameters.SORT_TITLE)) {
// these default sorts do need score calculation
doScoring = true;
} else if ((sort == CmsSearchParameters.SORT_DATE_CREATED)
|| (sort == CmsSearchParameters.SORT_DATE_LASTMODIFIED)) {
// these default sorts don't need score calculation
doScoring = false;
} else {
// for all non-defaults: check if the score field is present, in that case we must calculate the score
SortField[] fields = sort.getSort();
for (SortField field : fields) {
if (field == SortField.FIELD_SCORE) {
doScoring = true;
break;
}
}
}
}
return doScoring;
} | [
"protected",
"boolean",
"isSortScoring",
"(",
"IndexSearcher",
"searcher",
",",
"Sort",
"sort",
")",
"{",
"boolean",
"doScoring",
"=",
"false",
";",
"if",
"(",
"sort",
"!=",
"null",
")",
"{",
"if",
"(",
"(",
"sort",
"==",
"CmsSearchParameters",
".",
"SORT_DEFAULT",
")",
"||",
"(",
"sort",
"==",
"CmsSearchParameters",
".",
"SORT_TITLE",
")",
")",
"{",
"// these default sorts do need score calculation",
"doScoring",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"(",
"sort",
"==",
"CmsSearchParameters",
".",
"SORT_DATE_CREATED",
")",
"||",
"(",
"sort",
"==",
"CmsSearchParameters",
".",
"SORT_DATE_LASTMODIFIED",
")",
")",
"{",
"// these default sorts don't need score calculation",
"doScoring",
"=",
"false",
";",
"}",
"else",
"{",
"// for all non-defaults: check if the score field is present, in that case we must calculate the score",
"SortField",
"[",
"]",
"fields",
"=",
"sort",
".",
"getSort",
"(",
")",
";",
"for",
"(",
"SortField",
"field",
":",
"fields",
")",
"{",
"if",
"(",
"field",
"==",
"SortField",
".",
"FIELD_SCORE",
")",
"{",
"doScoring",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"}",
"return",
"doScoring",
";",
"}"
] | Checks if the score for the results must be calculated based on the provided sort option.<p>
Since Lucene 3 apparently the score is no longer calculated by default, but only if the
searcher is explicitly told so. This methods checks if, based on the given sort,
the score must be calculated.<p>
@param searcher the index searcher to prepare
@param sort the sort option to use
@return true if the sort option should be used | [
"Checks",
"if",
"the",
"score",
"for",
"the",
"results",
"must",
"be",
"calculated",
"based",
"on",
"the",
"provided",
"sort",
"option",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/CmsSearchIndex.java#L1922-L1945 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/bind/transform/AbstractNumberBindTransform.java | AbstractNumberBindTransform.generateParseOnJackson | @Override
public void generateParseOnJackson(BindTypeContext context, Builder methodBuilder, String parserName, TypeName beanClass, String beanName, BindProperty property) {
"""
/* (non-Javadoc)
@see com.abubusoft.kripton.processor.bind.transform.BindTransform#generateParseOnJackson(com.abubusoft.kripton.processor.bind.BindTypeContext, com.squareup.javapoet.MethodSpec.Builder, java.lang.String, com.squareup.javapoet.TypeName, java.lang.String, com.abubusoft.kripton.processor.bind.model.BindProperty)
"""
if (property.isNullable()) {
methodBuilder.beginControlFlow("if ($L.currentToken()!=$T.VALUE_NULL)", parserName, JsonToken.class);
}
if (property.hasTypeAdapter()) {
methodBuilder.addStatement(setter(beanClass, beanName, property, PRE_TYPE_ADAPTER_TO_JAVA + "$T.read($L.getText())" + POST_TYPE_ADAPTER), TypeAdapterUtils.class,
TypeUtility.typeName(property.typeAdapter.adapterClazz), NUMBER_UTIL_CLAZZ, parserName);
} else {
methodBuilder.addStatement(setter(beanClass, beanName, property, "$T.read($L.getText())"), NUMBER_UTIL_CLAZZ, parserName);
}
if (property.isNullable()) {
methodBuilder.endControlFlow();
}
} | java | @Override
public void generateParseOnJackson(BindTypeContext context, Builder methodBuilder, String parserName, TypeName beanClass, String beanName, BindProperty property) {
if (property.isNullable()) {
methodBuilder.beginControlFlow("if ($L.currentToken()!=$T.VALUE_NULL)", parserName, JsonToken.class);
}
if (property.hasTypeAdapter()) {
methodBuilder.addStatement(setter(beanClass, beanName, property, PRE_TYPE_ADAPTER_TO_JAVA + "$T.read($L.getText())" + POST_TYPE_ADAPTER), TypeAdapterUtils.class,
TypeUtility.typeName(property.typeAdapter.adapterClazz), NUMBER_UTIL_CLAZZ, parserName);
} else {
methodBuilder.addStatement(setter(beanClass, beanName, property, "$T.read($L.getText())"), NUMBER_UTIL_CLAZZ, parserName);
}
if (property.isNullable()) {
methodBuilder.endControlFlow();
}
} | [
"@",
"Override",
"public",
"void",
"generateParseOnJackson",
"(",
"BindTypeContext",
"context",
",",
"Builder",
"methodBuilder",
",",
"String",
"parserName",
",",
"TypeName",
"beanClass",
",",
"String",
"beanName",
",",
"BindProperty",
"property",
")",
"{",
"if",
"(",
"property",
".",
"isNullable",
"(",
")",
")",
"{",
"methodBuilder",
".",
"beginControlFlow",
"(",
"\"if ($L.currentToken()!=$T.VALUE_NULL)\"",
",",
"parserName",
",",
"JsonToken",
".",
"class",
")",
";",
"}",
"if",
"(",
"property",
".",
"hasTypeAdapter",
"(",
")",
")",
"{",
"methodBuilder",
".",
"addStatement",
"(",
"setter",
"(",
"beanClass",
",",
"beanName",
",",
"property",
",",
"PRE_TYPE_ADAPTER_TO_JAVA",
"+",
"\"$T.read($L.getText())\"",
"+",
"POST_TYPE_ADAPTER",
")",
",",
"TypeAdapterUtils",
".",
"class",
",",
"TypeUtility",
".",
"typeName",
"(",
"property",
".",
"typeAdapter",
".",
"adapterClazz",
")",
",",
"NUMBER_UTIL_CLAZZ",
",",
"parserName",
")",
";",
"}",
"else",
"{",
"methodBuilder",
".",
"addStatement",
"(",
"setter",
"(",
"beanClass",
",",
"beanName",
",",
"property",
",",
"\"$T.read($L.getText())\"",
")",
",",
"NUMBER_UTIL_CLAZZ",
",",
"parserName",
")",
";",
"}",
"if",
"(",
"property",
".",
"isNullable",
"(",
")",
")",
"{",
"methodBuilder",
".",
"endControlFlow",
"(",
")",
";",
"}",
"}"
] | /* (non-Javadoc)
@see com.abubusoft.kripton.processor.bind.transform.BindTransform#generateParseOnJackson(com.abubusoft.kripton.processor.bind.BindTypeContext, com.squareup.javapoet.MethodSpec.Builder, java.lang.String, com.squareup.javapoet.TypeName, java.lang.String, com.abubusoft.kripton.processor.bind.model.BindProperty) | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")"
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/bind/transform/AbstractNumberBindTransform.java#L63-L80 |
jcuda/jcuda | JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java | JCudaDriver.cuDeviceGetPCIBusId | public static int cuDeviceGetPCIBusId(String pciBusId[], int len, CUdevice dev) {
"""
Returns a PCI Bus Id string for the device.
<pre>
CUresult cuDeviceGetPCIBusId (
char* pciBusId,
int len,
CUdevice dev )
</pre>
<div>
<p>Returns a PCI Bus Id string for the
device. Returns an ASCII string identifying the device <tt>dev</tt>
in the NULL-terminated string pointed to by <tt>pciBusId</tt>. <tt>len</tt> specifies the maximum length of the string that may be
returned.
</p>
<div>
<span>Note:</span>
<p>Note that this
function may also return error codes from previous, asynchronous
launches.
</p>
</div>
</p>
</div>
@param pciBusId Returned identifier string for the device in the following format [domain]:[bus]:[device].[function] where domain, bus, device, and function are all hexadecimal values. pciBusId should be large enough to store 13 characters including the NULL-terminator.
@param len Maximum length of string to store in name
@param dev Device to get identifier string for
@return CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED,
CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_DEVICE
@see JCudaDriver#cuDeviceGet
@see JCudaDriver#cuDeviceGetAttribute
@see JCudaDriver#cuDeviceGetByPCIBusId
"""
return checkResult(cuDeviceGetPCIBusIdNative(pciBusId, len, dev));
} | java | public static int cuDeviceGetPCIBusId(String pciBusId[], int len, CUdevice dev)
{
return checkResult(cuDeviceGetPCIBusIdNative(pciBusId, len, dev));
} | [
"public",
"static",
"int",
"cuDeviceGetPCIBusId",
"(",
"String",
"pciBusId",
"[",
"]",
",",
"int",
"len",
",",
"CUdevice",
"dev",
")",
"{",
"return",
"checkResult",
"(",
"cuDeviceGetPCIBusIdNative",
"(",
"pciBusId",
",",
"len",
",",
"dev",
")",
")",
";",
"}"
] | Returns a PCI Bus Id string for the device.
<pre>
CUresult cuDeviceGetPCIBusId (
char* pciBusId,
int len,
CUdevice dev )
</pre>
<div>
<p>Returns a PCI Bus Id string for the
device. Returns an ASCII string identifying the device <tt>dev</tt>
in the NULL-terminated string pointed to by <tt>pciBusId</tt>. <tt>len</tt> specifies the maximum length of the string that may be
returned.
</p>
<div>
<span>Note:</span>
<p>Note that this
function may also return error codes from previous, asynchronous
launches.
</p>
</div>
</p>
</div>
@param pciBusId Returned identifier string for the device in the following format [domain]:[bus]:[device].[function] where domain, bus, device, and function are all hexadecimal values. pciBusId should be large enough to store 13 characters including the NULL-terminator.
@param len Maximum length of string to store in name
@param dev Device to get identifier string for
@return CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED,
CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_DEVICE
@see JCudaDriver#cuDeviceGet
@see JCudaDriver#cuDeviceGetAttribute
@see JCudaDriver#cuDeviceGetByPCIBusId | [
"Returns",
"a",
"PCI",
"Bus",
"Id",
"string",
"for",
"the",
"device",
"."
] | train | https://github.com/jcuda/jcuda/blob/468528b5b9b37dfceb6ed83fcfd889e9b359f984/JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java#L3373-L3376 |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | MapCore/src/main/java/org/wwarn/mapcore/client/utils/XMLUtils.java | XMLUtils.nodeWalker | public static void nodeWalker(NodeList childNodes, NodeElementParser parser) throws ParseException {
"""
nodeWalker walker implementation, simple depth first recursive implementation
@param childNodes take a node list to iterate
@param parser an observer which parses a node element
@throws ParseException
"""
for (int i = 0; i < childNodes.getLength(); i++) {
Node item = childNodes.item(i);
String node = item.getNodeName();
if(item.getNodeType() == Node.ELEMENT_NODE){
parser.parse(item);
}
nodeWalker(item.getChildNodes(), parser);
}
} | java | public static void nodeWalker(NodeList childNodes, NodeElementParser parser) throws ParseException {
for (int i = 0; i < childNodes.getLength(); i++) {
Node item = childNodes.item(i);
String node = item.getNodeName();
if(item.getNodeType() == Node.ELEMENT_NODE){
parser.parse(item);
}
nodeWalker(item.getChildNodes(), parser);
}
} | [
"public",
"static",
"void",
"nodeWalker",
"(",
"NodeList",
"childNodes",
",",
"NodeElementParser",
"parser",
")",
"throws",
"ParseException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"childNodes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"item",
"=",
"childNodes",
".",
"item",
"(",
"i",
")",
";",
"String",
"node",
"=",
"item",
".",
"getNodeName",
"(",
")",
";",
"if",
"(",
"item",
".",
"getNodeType",
"(",
")",
"==",
"Node",
".",
"ELEMENT_NODE",
")",
"{",
"parser",
".",
"parse",
"(",
"item",
")",
";",
"}",
"nodeWalker",
"(",
"item",
".",
"getChildNodes",
"(",
")",
",",
"parser",
")",
";",
"}",
"}"
] | nodeWalker walker implementation, simple depth first recursive implementation
@param childNodes take a node list to iterate
@param parser an observer which parses a node element
@throws ParseException | [
"nodeWalker",
"walker",
"implementation",
"simple",
"depth",
"first",
"recursive",
"implementation"
] | train | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/MapCore/src/main/java/org/wwarn/mapcore/client/utils/XMLUtils.java#L56-L65 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java | HttpChannelConfig.parseBufferType | private void parseBufferType(Map<Object, Object> props) {
"""
Check the input configuration for the type of ByteBuffer to use, direct
or indirect.
@param props
"""
Object value = props.get(HttpConfigConstants.PROPNAME_DIRECT_BUFF);
if (null != value) {
this.bDirectBuffers = convertBoolean(value);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: use direct buffers is " + isDirectBufferType());
}
}
} | java | private void parseBufferType(Map<Object, Object> props) {
Object value = props.get(HttpConfigConstants.PROPNAME_DIRECT_BUFF);
if (null != value) {
this.bDirectBuffers = convertBoolean(value);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: use direct buffers is " + isDirectBufferType());
}
}
} | [
"private",
"void",
"parseBufferType",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"props",
")",
"{",
"Object",
"value",
"=",
"props",
".",
"get",
"(",
"HttpConfigConstants",
".",
"PROPNAME_DIRECT_BUFF",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"this",
".",
"bDirectBuffers",
"=",
"convertBoolean",
"(",
"value",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Config: use direct buffers is \"",
"+",
"isDirectBufferType",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Check the input configuration for the type of ByteBuffer to use, direct
or indirect.
@param props | [
"Check",
"the",
"input",
"configuration",
"for",
"the",
"type",
"of",
"ByteBuffer",
"to",
"use",
"direct",
"or",
"indirect",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java#L550-L558 |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/tree/JTreeExtensions.java | JTreeExtensions.expandAll | public static void expandAll(JTree tree, TreePath path, boolean expand) {
"""
Expand all nodes recursive
@param tree
the tree
@param path
the path
@param expand
the flag to expand or collapse
"""
TreeNode node = (TreeNode)path.getLastPathComponent();
if (node.getChildCount() >= 0)
{
Enumeration<?> enumeration = node.children();
while (enumeration.hasMoreElements())
{
TreeNode n = (TreeNode)enumeration.nextElement();
TreePath p = path.pathByAddingChild(n);
expandAll(tree, p, expand);
}
}
if (expand)
{
tree.expandPath(path);
}
else
{
tree.collapsePath(path);
}
} | java | public static void expandAll(JTree tree, TreePath path, boolean expand)
{
TreeNode node = (TreeNode)path.getLastPathComponent();
if (node.getChildCount() >= 0)
{
Enumeration<?> enumeration = node.children();
while (enumeration.hasMoreElements())
{
TreeNode n = (TreeNode)enumeration.nextElement();
TreePath p = path.pathByAddingChild(n);
expandAll(tree, p, expand);
}
}
if (expand)
{
tree.expandPath(path);
}
else
{
tree.collapsePath(path);
}
} | [
"public",
"static",
"void",
"expandAll",
"(",
"JTree",
"tree",
",",
"TreePath",
"path",
",",
"boolean",
"expand",
")",
"{",
"TreeNode",
"node",
"=",
"(",
"TreeNode",
")",
"path",
".",
"getLastPathComponent",
"(",
")",
";",
"if",
"(",
"node",
".",
"getChildCount",
"(",
")",
">=",
"0",
")",
"{",
"Enumeration",
"<",
"?",
">",
"enumeration",
"=",
"node",
".",
"children",
"(",
")",
";",
"while",
"(",
"enumeration",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"TreeNode",
"n",
"=",
"(",
"TreeNode",
")",
"enumeration",
".",
"nextElement",
"(",
")",
";",
"TreePath",
"p",
"=",
"path",
".",
"pathByAddingChild",
"(",
"n",
")",
";",
"expandAll",
"(",
"tree",
",",
"p",
",",
"expand",
")",
";",
"}",
"}",
"if",
"(",
"expand",
")",
"{",
"tree",
".",
"expandPath",
"(",
"path",
")",
";",
"}",
"else",
"{",
"tree",
".",
"collapsePath",
"(",
"path",
")",
";",
"}",
"}"
] | Expand all nodes recursive
@param tree
the tree
@param path
the path
@param expand
the flag to expand or collapse | [
"Expand",
"all",
"nodes",
"recursive"
] | train | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/tree/JTreeExtensions.java#L51-L75 |
facebookarchive/hadoop-20 | src/contrib/raid/src/java/org/apache/hadoop/raid/HarIndex.java | HarIndex.getHarIndex | public static HarIndex getHarIndex(FileSystem fs, Path initializer)
throws IOException {
"""
Creates a HarIndex object with the path to either the HAR
or a part file in the HAR.
"""
if (!initializer.getName().endsWith(HAR)) {
initializer = initializer.getParent();
}
InputStream in = null;
try {
Path indexFile = new Path(initializer, INDEX);
FileStatus indexStat = fs.getFileStatus(indexFile);
in = fs.open(indexFile);
HarIndex harIndex = new HarIndex(in, indexStat.getLen());
harIndex.harDirectory = initializer;
return harIndex;
} finally {
if (in != null) {
in.close();
}
}
} | java | public static HarIndex getHarIndex(FileSystem fs, Path initializer)
throws IOException {
if (!initializer.getName().endsWith(HAR)) {
initializer = initializer.getParent();
}
InputStream in = null;
try {
Path indexFile = new Path(initializer, INDEX);
FileStatus indexStat = fs.getFileStatus(indexFile);
in = fs.open(indexFile);
HarIndex harIndex = new HarIndex(in, indexStat.getLen());
harIndex.harDirectory = initializer;
return harIndex;
} finally {
if (in != null) {
in.close();
}
}
} | [
"public",
"static",
"HarIndex",
"getHarIndex",
"(",
"FileSystem",
"fs",
",",
"Path",
"initializer",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"initializer",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"HAR",
")",
")",
"{",
"initializer",
"=",
"initializer",
".",
"getParent",
"(",
")",
";",
"}",
"InputStream",
"in",
"=",
"null",
";",
"try",
"{",
"Path",
"indexFile",
"=",
"new",
"Path",
"(",
"initializer",
",",
"INDEX",
")",
";",
"FileStatus",
"indexStat",
"=",
"fs",
".",
"getFileStatus",
"(",
"indexFile",
")",
";",
"in",
"=",
"fs",
".",
"open",
"(",
"indexFile",
")",
";",
"HarIndex",
"harIndex",
"=",
"new",
"HarIndex",
"(",
"in",
",",
"indexStat",
".",
"getLen",
"(",
")",
")",
";",
"harIndex",
".",
"harDirectory",
"=",
"initializer",
";",
"return",
"harIndex",
";",
"}",
"finally",
"{",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Creates a HarIndex object with the path to either the HAR
or a part file in the HAR. | [
"Creates",
"a",
"HarIndex",
"object",
"with",
"the",
"path",
"to",
"either",
"the",
"HAR",
"or",
"a",
"part",
"file",
"in",
"the",
"HAR",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/raid/src/java/org/apache/hadoop/raid/HarIndex.java#L77-L95 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/io/file/tfile/TFile.java | TFile.main | public static void main(String[] args) {
"""
Dumping the TFile information.
@param args
A list of TFile paths.
"""
System.out.printf("TFile Dumper (TFile %s, BCFile %s)\n", TFile.API_VERSION
.toString(), BCFile.API_VERSION.toString());
if (args.length == 0) {
System.out
.println("Usage: java ... org.apache.hadoop.io.file.tfile.TFile tfile-path [tfile-path ...]");
System.exit(0);
}
Configuration conf = new Configuration();
for (String file : args) {
System.out.println("===" + file + "===");
try {
TFileDumper.dumpInfo(file, System.out, conf);
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
} | java | public static void main(String[] args) {
System.out.printf("TFile Dumper (TFile %s, BCFile %s)\n", TFile.API_VERSION
.toString(), BCFile.API_VERSION.toString());
if (args.length == 0) {
System.out
.println("Usage: java ... org.apache.hadoop.io.file.tfile.TFile tfile-path [tfile-path ...]");
System.exit(0);
}
Configuration conf = new Configuration();
for (String file : args) {
System.out.println("===" + file + "===");
try {
TFileDumper.dumpInfo(file, System.out, conf);
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"System",
".",
"out",
".",
"printf",
"(",
"\"TFile Dumper (TFile %s, BCFile %s)\\n\"",
",",
"TFile",
".",
"API_VERSION",
".",
"toString",
"(",
")",
",",
"BCFile",
".",
"API_VERSION",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"args",
".",
"length",
"==",
"0",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Usage: java ... org.apache.hadoop.io.file.tfile.TFile tfile-path [tfile-path ...]\"",
")",
";",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}",
"Configuration",
"conf",
"=",
"new",
"Configuration",
"(",
")",
";",
"for",
"(",
"String",
"file",
":",
"args",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"===\"",
"+",
"file",
"+",
"\"===\"",
")",
";",
"try",
"{",
"TFileDumper",
".",
"dumpInfo",
"(",
"file",
",",
"System",
".",
"out",
",",
"conf",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
"System",
".",
"err",
")",
";",
"}",
"}",
"}"
] | Dumping the TFile information.
@param args
A list of TFile paths. | [
"Dumping",
"the",
"TFile",
"information",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/io/file/tfile/TFile.java#L2335-L2353 |
classgraph/classgraph | src/main/java/nonapi/io/github/classgraph/json/JSONSerializer.java | JSONSerializer.jsonValToJSONString | static void jsonValToJSONString(final Object jsonVal,
final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId,
final boolean includeNullValuedFields, final int depth, final int indentWidth,
final StringBuilder buf) {
"""
Serialize a JSON object, array, or value.
@param jsonVal
the json val
@param jsonReferenceToId
a map from json reference to id
@param includeNullValuedFields
the include null valued fields
@param depth
the depth
@param indentWidth
the indent width
@param buf
the buf
"""
if (jsonVal == null) {
buf.append("null");
} else if (jsonVal instanceof JSONObject) {
// Serialize JSONObject to string
((JSONObject) jsonVal).toJSONString(jsonReferenceToId, includeNullValuedFields, depth, indentWidth,
buf);
} else if (jsonVal instanceof JSONArray) {
// Serialize JSONArray to string
((JSONArray) jsonVal).toJSONString(jsonReferenceToId, includeNullValuedFields, depth, indentWidth, buf);
} else if (jsonVal instanceof JSONReference) {
// Serialize JSONReference to string
final Object referencedObjectId = jsonReferenceToId
.get(new ReferenceEqualityKey<>((JSONReference) jsonVal));
jsonValToJSONString(referencedObjectId, jsonReferenceToId, includeNullValuedFields, depth, indentWidth,
buf);
} else if (jsonVal instanceof CharSequence || jsonVal instanceof Character || jsonVal.getClass().isEnum()) {
// Serialize String, Character or enum val to quoted/escaped string
buf.append('"');
JSONUtils.escapeJSONString(jsonVal.toString(), buf);
buf.append('"');
} else {
// Serialize a numeric or Boolean type (Integer, Long, Short, Float, Double, Boolean, Byte) to string
// (doesn't need quoting or escaping)
buf.append(jsonVal.toString());
}
} | java | static void jsonValToJSONString(final Object jsonVal,
final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId,
final boolean includeNullValuedFields, final int depth, final int indentWidth,
final StringBuilder buf) {
if (jsonVal == null) {
buf.append("null");
} else if (jsonVal instanceof JSONObject) {
// Serialize JSONObject to string
((JSONObject) jsonVal).toJSONString(jsonReferenceToId, includeNullValuedFields, depth, indentWidth,
buf);
} else if (jsonVal instanceof JSONArray) {
// Serialize JSONArray to string
((JSONArray) jsonVal).toJSONString(jsonReferenceToId, includeNullValuedFields, depth, indentWidth, buf);
} else if (jsonVal instanceof JSONReference) {
// Serialize JSONReference to string
final Object referencedObjectId = jsonReferenceToId
.get(new ReferenceEqualityKey<>((JSONReference) jsonVal));
jsonValToJSONString(referencedObjectId, jsonReferenceToId, includeNullValuedFields, depth, indentWidth,
buf);
} else if (jsonVal instanceof CharSequence || jsonVal instanceof Character || jsonVal.getClass().isEnum()) {
// Serialize String, Character or enum val to quoted/escaped string
buf.append('"');
JSONUtils.escapeJSONString(jsonVal.toString(), buf);
buf.append('"');
} else {
// Serialize a numeric or Boolean type (Integer, Long, Short, Float, Double, Boolean, Byte) to string
// (doesn't need quoting or escaping)
buf.append(jsonVal.toString());
}
} | [
"static",
"void",
"jsonValToJSONString",
"(",
"final",
"Object",
"jsonVal",
",",
"final",
"Map",
"<",
"ReferenceEqualityKey",
"<",
"JSONReference",
">",
",",
"CharSequence",
">",
"jsonReferenceToId",
",",
"final",
"boolean",
"includeNullValuedFields",
",",
"final",
"int",
"depth",
",",
"final",
"int",
"indentWidth",
",",
"final",
"StringBuilder",
"buf",
")",
"{",
"if",
"(",
"jsonVal",
"==",
"null",
")",
"{",
"buf",
".",
"append",
"(",
"\"null\"",
")",
";",
"}",
"else",
"if",
"(",
"jsonVal",
"instanceof",
"JSONObject",
")",
"{",
"// Serialize JSONObject to string",
"(",
"(",
"JSONObject",
")",
"jsonVal",
")",
".",
"toJSONString",
"(",
"jsonReferenceToId",
",",
"includeNullValuedFields",
",",
"depth",
",",
"indentWidth",
",",
"buf",
")",
";",
"}",
"else",
"if",
"(",
"jsonVal",
"instanceof",
"JSONArray",
")",
"{",
"// Serialize JSONArray to string",
"(",
"(",
"JSONArray",
")",
"jsonVal",
")",
".",
"toJSONString",
"(",
"jsonReferenceToId",
",",
"includeNullValuedFields",
",",
"depth",
",",
"indentWidth",
",",
"buf",
")",
";",
"}",
"else",
"if",
"(",
"jsonVal",
"instanceof",
"JSONReference",
")",
"{",
"// Serialize JSONReference to string",
"final",
"Object",
"referencedObjectId",
"=",
"jsonReferenceToId",
".",
"get",
"(",
"new",
"ReferenceEqualityKey",
"<>",
"(",
"(",
"JSONReference",
")",
"jsonVal",
")",
")",
";",
"jsonValToJSONString",
"(",
"referencedObjectId",
",",
"jsonReferenceToId",
",",
"includeNullValuedFields",
",",
"depth",
",",
"indentWidth",
",",
"buf",
")",
";",
"}",
"else",
"if",
"(",
"jsonVal",
"instanceof",
"CharSequence",
"||",
"jsonVal",
"instanceof",
"Character",
"||",
"jsonVal",
".",
"getClass",
"(",
")",
".",
"isEnum",
"(",
")",
")",
"{",
"// Serialize String, Character or enum val to quoted/escaped string",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"JSONUtils",
".",
"escapeJSONString",
"(",
"jsonVal",
".",
"toString",
"(",
")",
",",
"buf",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"// Serialize a numeric or Boolean type (Integer, Long, Short, Float, Double, Boolean, Byte) to string",
"// (doesn't need quoting or escaping)",
"buf",
".",
"append",
"(",
"jsonVal",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Serialize a JSON object, array, or value.
@param jsonVal
the json val
@param jsonReferenceToId
a map from json reference to id
@param includeNullValuedFields
the include null valued fields
@param depth
the depth
@param indentWidth
the indent width
@param buf
the buf | [
"Serialize",
"a",
"JSON",
"object",
"array",
"or",
"value",
"."
] | train | https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONSerializer.java#L417-L452 |
actorapp/actor-platform | actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/collections/SparseBooleanArray.java | SparseBooleanArray.append | public void append(int key, boolean value) {
"""
Puts a key/value pair into the array, optimizing for the case where
the key is greater than all existing keys in the array.
"""
if (mSize != 0 && key <= mKeys[mSize - 1]) {
put(key, value);
return;
}
mKeys = GrowingArrayUtils.append(mKeys, mSize, key);
mValues = GrowingArrayUtils.append(mValues, mSize, value);
mSize++;
} | java | public void append(int key, boolean value) {
if (mSize != 0 && key <= mKeys[mSize - 1]) {
put(key, value);
return;
}
mKeys = GrowingArrayUtils.append(mKeys, mSize, key);
mValues = GrowingArrayUtils.append(mValues, mSize, value);
mSize++;
} | [
"public",
"void",
"append",
"(",
"int",
"key",
",",
"boolean",
"value",
")",
"{",
"if",
"(",
"mSize",
"!=",
"0",
"&&",
"key",
"<=",
"mKeys",
"[",
"mSize",
"-",
"1",
"]",
")",
"{",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
";",
"}",
"mKeys",
"=",
"GrowingArrayUtils",
".",
"append",
"(",
"mKeys",
",",
"mSize",
",",
"key",
")",
";",
"mValues",
"=",
"GrowingArrayUtils",
".",
"append",
"(",
"mValues",
",",
"mSize",
",",
"value",
")",
";",
"mSize",
"++",
";",
"}"
] | Puts a key/value pair into the array, optimizing for the case where
the key is greater than all existing keys in the array. | [
"Puts",
"a",
"key",
"/",
"value",
"pair",
"into",
"the",
"array",
"optimizing",
"for",
"the",
"case",
"where",
"the",
"key",
"is",
"greater",
"than",
"all",
"existing",
"keys",
"in",
"the",
"array",
"."
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/collections/SparseBooleanArray.java#L212-L220 |
square/okhttp | okhttp/src/main/java/okhttp3/internal/http/HttpHeaders.java | HttpHeaders.skipUntil | public static int skipUntil(String input, int pos, String characters) {
"""
Returns the next index in {@code input} at or after {@code pos} that contains a character from
{@code characters}. Returns the input length if none of the requested characters can be found.
"""
for (; pos < input.length(); pos++) {
if (characters.indexOf(input.charAt(pos)) != -1) {
break;
}
}
return pos;
} | java | public static int skipUntil(String input, int pos, String characters) {
for (; pos < input.length(); pos++) {
if (characters.indexOf(input.charAt(pos)) != -1) {
break;
}
}
return pos;
} | [
"public",
"static",
"int",
"skipUntil",
"(",
"String",
"input",
",",
"int",
"pos",
",",
"String",
"characters",
")",
"{",
"for",
"(",
";",
"pos",
"<",
"input",
".",
"length",
"(",
")",
";",
"pos",
"++",
")",
"{",
"if",
"(",
"characters",
".",
"indexOf",
"(",
"input",
".",
"charAt",
"(",
"pos",
")",
")",
"!=",
"-",
"1",
")",
"{",
"break",
";",
"}",
"}",
"return",
"pos",
";",
"}"
] | Returns the next index in {@code input} at or after {@code pos} that contains a character from
{@code characters}. Returns the input length if none of the requested characters can be found. | [
"Returns",
"the",
"next",
"index",
"in",
"{"
] | train | https://github.com/square/okhttp/blob/a8c65a822dd6cadd2de7d115bf94adf312e67868/okhttp/src/main/java/okhttp3/internal/http/HttpHeaders.java#L360-L367 |
crawljax/crawljax | core/src/main/java/com/crawljax/oraclecomparator/comparators/EditDistanceComparator.java | EditDistanceComparator.getThreshold | double getThreshold(String x, String y, double p) {
"""
Calculate a threshold.
@param x first string.
@param y second string.
@param p the threshold coefficient.
@return 2 maxLength(x, y) (1-p)
"""
return 2 * Math.max(x.length(), y.length()) * (1 - p);
} | java | double getThreshold(String x, String y, double p) {
return 2 * Math.max(x.length(), y.length()) * (1 - p);
} | [
"double",
"getThreshold",
"(",
"String",
"x",
",",
"String",
"y",
",",
"double",
"p",
")",
"{",
"return",
"2",
"*",
"Math",
".",
"max",
"(",
"x",
".",
"length",
"(",
")",
",",
"y",
".",
"length",
"(",
")",
")",
"*",
"(",
"1",
"-",
"p",
")",
";",
"}"
] | Calculate a threshold.
@param x first string.
@param y second string.
@param p the threshold coefficient.
@return 2 maxLength(x, y) (1-p) | [
"Calculate",
"a",
"threshold",
"."
] | train | https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/oraclecomparator/comparators/EditDistanceComparator.java#L73-L75 |
netty/netty | codec/src/main/java/io/netty/handler/codec/json/JsonObjectDecoder.java | JsonObjectDecoder.extractObject | @SuppressWarnings("UnusedParameters")
protected ByteBuf extractObject(ChannelHandlerContext ctx, ByteBuf buffer, int index, int length) {
"""
Override this method if you want to filter the json objects/arrays that get passed through the pipeline.
"""
return buffer.retainedSlice(index, length);
} | java | @SuppressWarnings("UnusedParameters")
protected ByteBuf extractObject(ChannelHandlerContext ctx, ByteBuf buffer, int index, int length) {
return buffer.retainedSlice(index, length);
} | [
"@",
"SuppressWarnings",
"(",
"\"UnusedParameters\"",
")",
"protected",
"ByteBuf",
"extractObject",
"(",
"ChannelHandlerContext",
"ctx",
",",
"ByteBuf",
"buffer",
",",
"int",
"index",
",",
"int",
"length",
")",
"{",
"return",
"buffer",
".",
"retainedSlice",
"(",
"index",
",",
"length",
")",
";",
"}"
] | Override this method if you want to filter the json objects/arrays that get passed through the pipeline. | [
"Override",
"this",
"method",
"if",
"you",
"want",
"to",
"filter",
"the",
"json",
"objects",
"/",
"arrays",
"that",
"get",
"passed",
"through",
"the",
"pipeline",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/json/JsonObjectDecoder.java#L190-L193 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/plugins/ZipResourceLoader.java | ZipResourceLoader.extractResources | public void extractResources() throws IOException {
"""
Extract resources return the extracted files
@return the collection of extracted files
"""
if (!cacheDir.isDirectory()) {
if (!cacheDir.mkdirs()) {
//debug("Failed to create cachedJar dir for dependent resources: " + cachedir);
}
}
if (null != resourcesList) {
//debug("jar manifest lists resources: " + resourcesList + " for file: " + pluginJar);
extractJarContents(resourcesList, cacheDir);
for (final String s : resourcesList) {
File libFile = new File(cacheDir, s);
libFile.deleteOnExit();
}
} else {
//debug("using resources dir: " + resDir + " for file: " + pluginJar);
ZipUtil.extractZip(zipFile.getAbsolutePath(), cacheDir, resourcesBasedir, resourcesBasedir);
}
} | java | public void extractResources() throws IOException {
if (!cacheDir.isDirectory()) {
if (!cacheDir.mkdirs()) {
//debug("Failed to create cachedJar dir for dependent resources: " + cachedir);
}
}
if (null != resourcesList) {
//debug("jar manifest lists resources: " + resourcesList + " for file: " + pluginJar);
extractJarContents(resourcesList, cacheDir);
for (final String s : resourcesList) {
File libFile = new File(cacheDir, s);
libFile.deleteOnExit();
}
} else {
//debug("using resources dir: " + resDir + " for file: " + pluginJar);
ZipUtil.extractZip(zipFile.getAbsolutePath(), cacheDir, resourcesBasedir, resourcesBasedir);
}
} | [
"public",
"void",
"extractResources",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"cacheDir",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"!",
"cacheDir",
".",
"mkdirs",
"(",
")",
")",
"{",
"//debug(\"Failed to create cachedJar dir for dependent resources: \" + cachedir);",
"}",
"}",
"if",
"(",
"null",
"!=",
"resourcesList",
")",
"{",
"//debug(\"jar manifest lists resources: \" + resourcesList + \" for file: \" + pluginJar);",
"extractJarContents",
"(",
"resourcesList",
",",
"cacheDir",
")",
";",
"for",
"(",
"final",
"String",
"s",
":",
"resourcesList",
")",
"{",
"File",
"libFile",
"=",
"new",
"File",
"(",
"cacheDir",
",",
"s",
")",
";",
"libFile",
".",
"deleteOnExit",
"(",
")",
";",
"}",
"}",
"else",
"{",
"//debug(\"using resources dir: \" + resDir + \" for file: \" + pluginJar);",
"ZipUtil",
".",
"extractZip",
"(",
"zipFile",
".",
"getAbsolutePath",
"(",
")",
",",
"cacheDir",
",",
"resourcesBasedir",
",",
"resourcesBasedir",
")",
";",
"}",
"}"
] | Extract resources return the extracted files
@return the collection of extracted files | [
"Extract",
"resources",
"return",
"the",
"extracted",
"files"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ZipResourceLoader.java#L123-L141 |
to2mbn/JMCCC | jmccc/src/main/java/org/to2mbn/jmccc/internal/org/json/JSONArray.java | JSONArray.optBigInteger | public BigInteger optBigInteger(int index, BigInteger defaultValue) {
"""
Get the optional BigInteger value associated with an index. The
defaultValue is returned if there is no value for the index, or if the
value is not a number and cannot be converted to a number.
@param index The index must be between 0 and length() - 1.
@param defaultValue The default value.
@return The value.
"""
try {
return this.getBigInteger(index);
} catch (Exception e) {
return defaultValue;
}
} | java | public BigInteger optBigInteger(int index, BigInteger defaultValue) {
try {
return this.getBigInteger(index);
} catch (Exception e) {
return defaultValue;
}
} | [
"public",
"BigInteger",
"optBigInteger",
"(",
"int",
"index",
",",
"BigInteger",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"this",
".",
"getBigInteger",
"(",
"index",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] | Get the optional BigInteger value associated with an index. The
defaultValue is returned if there is no value for the index, or if the
value is not a number and cannot be converted to a number.
@param index The index must be between 0 and length() - 1.
@param defaultValue The default value.
@return The value. | [
"Get",
"the",
"optional",
"BigInteger",
"value",
"associated",
"with",
"an",
"index",
".",
"The",
"defaultValue",
"is",
"returned",
"if",
"there",
"is",
"no",
"value",
"for",
"the",
"index",
"or",
"if",
"the",
"value",
"is",
"not",
"a",
"number",
"and",
"cannot",
"be",
"converted",
"to",
"a",
"number",
"."
] | train | https://github.com/to2mbn/JMCCC/blob/17e5b1b56ff18255cfd60976dca1a24598946647/jmccc/src/main/java/org/to2mbn/jmccc/internal/org/json/JSONArray.java#L575-L581 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java | Gen.makeNewArray | Item makeNewArray(DiagnosticPosition pos, Type type, int ndims) {
"""
Generate code to create an array with given element type and number
of dimensions.
"""
Type elemtype = types.elemtype(type);
if (types.dimensions(type) > ClassFile.MAX_DIMENSIONS) {
log.error(pos, "limit.dimensions");
nerrs++;
}
int elemcode = Code.arraycode(elemtype);
if (elemcode == 0 || (elemcode == 1 && ndims == 1)) {
code.emitAnewarray(makeRef(pos, elemtype), type);
} else if (elemcode == 1) {
code.emitMultianewarray(ndims, makeRef(pos, type), type);
} else {
code.emitNewarray(elemcode, type);
}
return items.makeStackItem(type);
} | java | Item makeNewArray(DiagnosticPosition pos, Type type, int ndims) {
Type elemtype = types.elemtype(type);
if (types.dimensions(type) > ClassFile.MAX_DIMENSIONS) {
log.error(pos, "limit.dimensions");
nerrs++;
}
int elemcode = Code.arraycode(elemtype);
if (elemcode == 0 || (elemcode == 1 && ndims == 1)) {
code.emitAnewarray(makeRef(pos, elemtype), type);
} else if (elemcode == 1) {
code.emitMultianewarray(ndims, makeRef(pos, type), type);
} else {
code.emitNewarray(elemcode, type);
}
return items.makeStackItem(type);
} | [
"Item",
"makeNewArray",
"(",
"DiagnosticPosition",
"pos",
",",
"Type",
"type",
",",
"int",
"ndims",
")",
"{",
"Type",
"elemtype",
"=",
"types",
".",
"elemtype",
"(",
"type",
")",
";",
"if",
"(",
"types",
".",
"dimensions",
"(",
"type",
")",
">",
"ClassFile",
".",
"MAX_DIMENSIONS",
")",
"{",
"log",
".",
"error",
"(",
"pos",
",",
"\"limit.dimensions\"",
")",
";",
"nerrs",
"++",
";",
"}",
"int",
"elemcode",
"=",
"Code",
".",
"arraycode",
"(",
"elemtype",
")",
";",
"if",
"(",
"elemcode",
"==",
"0",
"||",
"(",
"elemcode",
"==",
"1",
"&&",
"ndims",
"==",
"1",
")",
")",
"{",
"code",
".",
"emitAnewarray",
"(",
"makeRef",
"(",
"pos",
",",
"elemtype",
")",
",",
"type",
")",
";",
"}",
"else",
"if",
"(",
"elemcode",
"==",
"1",
")",
"{",
"code",
".",
"emitMultianewarray",
"(",
"ndims",
",",
"makeRef",
"(",
"pos",
",",
"type",
")",
",",
"type",
")",
";",
"}",
"else",
"{",
"code",
".",
"emitNewarray",
"(",
"elemcode",
",",
"type",
")",
";",
"}",
"return",
"items",
".",
"makeStackItem",
"(",
"type",
")",
";",
"}"
] | Generate code to create an array with given element type and number
of dimensions. | [
"Generate",
"code",
"to",
"create",
"an",
"array",
"with",
"given",
"element",
"type",
"and",
"number",
"of",
"dimensions",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java#L1760-L1775 |
apache/incubator-gobblin | gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigsResource.java | FlowConfigsResource.get | @Override
public FlowConfig get(ComplexResourceKey<FlowId, EmptyRecord> key) {
"""
Retrieve the flow configuration with the given key
@param key flow config id key containing group name and flow name
@return {@link FlowConfig} with flow configuration
"""
String flowGroup = key.getKey().getFlowGroup();
String flowName = key.getKey().getFlowName();
FlowId flowId = new FlowId().setFlowGroup(flowGroup).setFlowName(flowName);
return this.flowConfigsResourceHandler.getFlowConfig(flowId);
} | java | @Override
public FlowConfig get(ComplexResourceKey<FlowId, EmptyRecord> key) {
String flowGroup = key.getKey().getFlowGroup();
String flowName = key.getKey().getFlowName();
FlowId flowId = new FlowId().setFlowGroup(flowGroup).setFlowName(flowName);
return this.flowConfigsResourceHandler.getFlowConfig(flowId);
} | [
"@",
"Override",
"public",
"FlowConfig",
"get",
"(",
"ComplexResourceKey",
"<",
"FlowId",
",",
"EmptyRecord",
">",
"key",
")",
"{",
"String",
"flowGroup",
"=",
"key",
".",
"getKey",
"(",
")",
".",
"getFlowGroup",
"(",
")",
";",
"String",
"flowName",
"=",
"key",
".",
"getKey",
"(",
")",
".",
"getFlowName",
"(",
")",
";",
"FlowId",
"flowId",
"=",
"new",
"FlowId",
"(",
")",
".",
"setFlowGroup",
"(",
"flowGroup",
")",
".",
"setFlowName",
"(",
"flowName",
")",
";",
"return",
"this",
".",
"flowConfigsResourceHandler",
".",
"getFlowConfig",
"(",
"flowId",
")",
";",
"}"
] | Retrieve the flow configuration with the given key
@param key flow config id key containing group name and flow name
@return {@link FlowConfig} with flow configuration | [
"Retrieve",
"the",
"flow",
"configuration",
"with",
"the",
"given",
"key"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigsResource.java#L76-L82 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java | Feature.setUrlAttribute | public void setUrlAttribute(String name, String value) {
"""
Set attribute value of given type.
@param name attribute name
@param value attribute value
"""
Attribute attribute = getAttributes().get(name);
if (!(attribute instanceof UrlAttribute)) {
throw new IllegalStateException("Cannot set url value on attribute with different type, " +
attribute.getClass().getName() + " setting value " + value);
}
((UrlAttribute) attribute).setValue(value);
} | java | public void setUrlAttribute(String name, String value) {
Attribute attribute = getAttributes().get(name);
if (!(attribute instanceof UrlAttribute)) {
throw new IllegalStateException("Cannot set url value on attribute with different type, " +
attribute.getClass().getName() + " setting value " + value);
}
((UrlAttribute) attribute).setValue(value);
} | [
"public",
"void",
"setUrlAttribute",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"Attribute",
"attribute",
"=",
"getAttributes",
"(",
")",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"!",
"(",
"attribute",
"instanceof",
"UrlAttribute",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot set url value on attribute with different type, \"",
"+",
"attribute",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" setting value \"",
"+",
"value",
")",
";",
"}",
"(",
"(",
"UrlAttribute",
")",
"attribute",
")",
".",
"setValue",
"(",
"value",
")",
";",
"}"
] | Set attribute value of given type.
@param name attribute name
@param value attribute value | [
"Set",
"attribute",
"value",
"of",
"given",
"type",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java#L365-L372 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/convert/MergeConverter.java | MergeConverter.setupDefaultView | public ScreenComponent setupDefaultView(ScreenLoc itsLocation, ComponentParent targetScreen, Convert convert, int iDisplayFieldDesc, Map<String, Object> properties) {
"""
Set up the default control for this field.
Adds the default screen control for the current converter, and makes me it's converter.
@param itsLocation Location of this component on screen (ie., GridBagConstraint).
@param targetScreen Where to place this component (ie., Parent screen or GridBagLayout).
@param iDisplayFieldDesc Display the label? (optional).
@return Return the component or ScreenField that is created for this field.
"""
ScreenComponent sField = null;
Converter converter = this.getNextConverter();
if (converter != null)
sField = converter.setupDefaultView(itsLocation, targetScreen, convert, iDisplayFieldDesc, properties);
else
sField = super.setupDefaultView(itsLocation, targetScreen, converter, iDisplayFieldDesc, properties);
if (sField != null)
{ // Get rid of any and all links to/from field/converter
converter.removeComponent(sField); // Have the field add me to its list for display
sField.setConverter(this);
}
return sField;
} | java | public ScreenComponent setupDefaultView(ScreenLoc itsLocation, ComponentParent targetScreen, Convert convert, int iDisplayFieldDesc, Map<String, Object> properties)
{
ScreenComponent sField = null;
Converter converter = this.getNextConverter();
if (converter != null)
sField = converter.setupDefaultView(itsLocation, targetScreen, convert, iDisplayFieldDesc, properties);
else
sField = super.setupDefaultView(itsLocation, targetScreen, converter, iDisplayFieldDesc, properties);
if (sField != null)
{ // Get rid of any and all links to/from field/converter
converter.removeComponent(sField); // Have the field add me to its list for display
sField.setConverter(this);
}
return sField;
} | [
"public",
"ScreenComponent",
"setupDefaultView",
"(",
"ScreenLoc",
"itsLocation",
",",
"ComponentParent",
"targetScreen",
",",
"Convert",
"convert",
",",
"int",
"iDisplayFieldDesc",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"ScreenComponent",
"sField",
"=",
"null",
";",
"Converter",
"converter",
"=",
"this",
".",
"getNextConverter",
"(",
")",
";",
"if",
"(",
"converter",
"!=",
"null",
")",
"sField",
"=",
"converter",
".",
"setupDefaultView",
"(",
"itsLocation",
",",
"targetScreen",
",",
"convert",
",",
"iDisplayFieldDesc",
",",
"properties",
")",
";",
"else",
"sField",
"=",
"super",
".",
"setupDefaultView",
"(",
"itsLocation",
",",
"targetScreen",
",",
"converter",
",",
"iDisplayFieldDesc",
",",
"properties",
")",
";",
"if",
"(",
"sField",
"!=",
"null",
")",
"{",
"// Get rid of any and all links to/from field/converter",
"converter",
".",
"removeComponent",
"(",
"sField",
")",
";",
"// Have the field add me to its list for display",
"sField",
".",
"setConverter",
"(",
"this",
")",
";",
"}",
"return",
"sField",
";",
"}"
] | Set up the default control for this field.
Adds the default screen control for the current converter, and makes me it's converter.
@param itsLocation Location of this component on screen (ie., GridBagConstraint).
@param targetScreen Where to place this component (ie., Parent screen or GridBagLayout).
@param iDisplayFieldDesc Display the label? (optional).
@return Return the component or ScreenField that is created for this field. | [
"Set",
"up",
"the",
"default",
"control",
"for",
"this",
"field",
".",
"Adds",
"the",
"default",
"screen",
"control",
"for",
"the",
"current",
"converter",
"and",
"makes",
"me",
"it",
"s",
"converter",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/MergeConverter.java#L179-L193 |
joniles/mpxj | src/main/java/net/sf/mpxj/turboproject/TurboProjectReader.java | TurboProjectReader.defineField | private static void defineField(Map<String, FieldType> container, String name, FieldType type, String alias) {
"""
Configure the mapping between a database column and a field, including definition of
an alias.
@param container column to field map
@param name column name
@param type field type
@param alias field alias
"""
container.put(name, type);
if (alias != null)
{
ALIASES.put(type, alias);
}
} | java | private static void defineField(Map<String, FieldType> container, String name, FieldType type, String alias)
{
container.put(name, type);
if (alias != null)
{
ALIASES.put(type, alias);
}
} | [
"private",
"static",
"void",
"defineField",
"(",
"Map",
"<",
"String",
",",
"FieldType",
">",
"container",
",",
"String",
"name",
",",
"FieldType",
"type",
",",
"String",
"alias",
")",
"{",
"container",
".",
"put",
"(",
"name",
",",
"type",
")",
";",
"if",
"(",
"alias",
"!=",
"null",
")",
"{",
"ALIASES",
".",
"put",
"(",
"type",
",",
"alias",
")",
";",
"}",
"}"
] | Configure the mapping between a database column and a field, including definition of
an alias.
@param container column to field map
@param name column name
@param type field type
@param alias field alias | [
"Configure",
"the",
"mapping",
"between",
"a",
"database",
"column",
"and",
"a",
"field",
"including",
"definition",
"of",
"an",
"alias",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/turboproject/TurboProjectReader.java#L504-L511 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/BaseField.java | BaseField.moveSQLToField | public void moveSQLToField(ResultSet resultset, int iColumn) throws SQLException {
"""
Move the physical binary data to this SQL parameter row.
This is overidden to move the physical data type.
@param resultset The resultset to get the SQL data from.
@param iColumn the column in the resultset that has my data.
@exception SQLException From SQL calls.
"""
String strResult = resultset.getString(iColumn);
if (resultset.wasNull())
this.setString(Constants.BLANK, false, DBConstants.READ_MOVE); // Null value
else
this.setString(strResult, false, DBConstants.READ_MOVE);
} | java | public void moveSQLToField(ResultSet resultset, int iColumn) throws SQLException
{
String strResult = resultset.getString(iColumn);
if (resultset.wasNull())
this.setString(Constants.BLANK, false, DBConstants.READ_MOVE); // Null value
else
this.setString(strResult, false, DBConstants.READ_MOVE);
} | [
"public",
"void",
"moveSQLToField",
"(",
"ResultSet",
"resultset",
",",
"int",
"iColumn",
")",
"throws",
"SQLException",
"{",
"String",
"strResult",
"=",
"resultset",
".",
"getString",
"(",
"iColumn",
")",
";",
"if",
"(",
"resultset",
".",
"wasNull",
"(",
")",
")",
"this",
".",
"setString",
"(",
"Constants",
".",
"BLANK",
",",
"false",
",",
"DBConstants",
".",
"READ_MOVE",
")",
";",
"// Null value",
"else",
"this",
".",
"setString",
"(",
"strResult",
",",
"false",
",",
"DBConstants",
".",
"READ_MOVE",
")",
";",
"}"
] | Move the physical binary data to this SQL parameter row.
This is overidden to move the physical data type.
@param resultset The resultset to get the SQL data from.
@param iColumn the column in the resultset that has my data.
@exception SQLException From SQL calls. | [
"Move",
"the",
"physical",
"binary",
"data",
"to",
"this",
"SQL",
"parameter",
"row",
".",
"This",
"is",
"overidden",
"to",
"move",
"the",
"physical",
"data",
"type",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/BaseField.java#L836-L843 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/workplace/broadcast/CmsMessageInfo.java | CmsMessageInfo.createInternetAddresses | private List<InternetAddress> createInternetAddresses(String mailAddresses) throws AddressException {
"""
Creates a list of internet addresses (email) from a semicolon separated String.<p>
@param mailAddresses a semicolon separated String with email addresses
@return list of internet addresses (email)
@throws AddressException if an email address is not correct
"""
if (CmsStringUtil.isNotEmpty(mailAddresses)) {
// at least one email address is present, generate list
StringTokenizer T = new StringTokenizer(mailAddresses, ";");
List<InternetAddress> addresses = new ArrayList<InternetAddress>(T.countTokens());
while (T.hasMoreTokens()) {
InternetAddress address = new InternetAddress(T.nextToken().trim());
addresses.add(address);
}
return addresses;
} else {
// no address given, return empty list
return Collections.emptyList();
}
} | java | private List<InternetAddress> createInternetAddresses(String mailAddresses) throws AddressException {
if (CmsStringUtil.isNotEmpty(mailAddresses)) {
// at least one email address is present, generate list
StringTokenizer T = new StringTokenizer(mailAddresses, ";");
List<InternetAddress> addresses = new ArrayList<InternetAddress>(T.countTokens());
while (T.hasMoreTokens()) {
InternetAddress address = new InternetAddress(T.nextToken().trim());
addresses.add(address);
}
return addresses;
} else {
// no address given, return empty list
return Collections.emptyList();
}
} | [
"private",
"List",
"<",
"InternetAddress",
">",
"createInternetAddresses",
"(",
"String",
"mailAddresses",
")",
"throws",
"AddressException",
"{",
"if",
"(",
"CmsStringUtil",
".",
"isNotEmpty",
"(",
"mailAddresses",
")",
")",
"{",
"// at least one email address is present, generate list",
"StringTokenizer",
"T",
"=",
"new",
"StringTokenizer",
"(",
"mailAddresses",
",",
"\";\"",
")",
";",
"List",
"<",
"InternetAddress",
">",
"addresses",
"=",
"new",
"ArrayList",
"<",
"InternetAddress",
">",
"(",
"T",
".",
"countTokens",
"(",
")",
")",
";",
"while",
"(",
"T",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"InternetAddress",
"address",
"=",
"new",
"InternetAddress",
"(",
"T",
".",
"nextToken",
"(",
")",
".",
"trim",
"(",
")",
")",
";",
"addresses",
".",
"add",
"(",
"address",
")",
";",
"}",
"return",
"addresses",
";",
"}",
"else",
"{",
"// no address given, return empty list",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"}"
] | Creates a list of internet addresses (email) from a semicolon separated String.<p>
@param mailAddresses a semicolon separated String with email addresses
@return list of internet addresses (email)
@throws AddressException if an email address is not correct | [
"Creates",
"a",
"list",
"of",
"internet",
"addresses",
"(",
"email",
")",
"from",
"a",
"semicolon",
"separated",
"String",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/workplace/broadcast/CmsMessageInfo.java#L224-L239 |
trellis-ldp/trellis | components/file/src/main/java/org/trellisldp/file/FileUtils.java | FileUtils.uncheckedList | public static Stream<Path> uncheckedList(final Path path) {
"""
Fetch a stream of files in the provided directory path.
@param path the directory path
@return a stream of filenames
"""
try {
return Files.list(path);
} catch (final IOException ex) {
throw new UncheckedIOException("Error fetching file list", ex);
}
} | java | public static Stream<Path> uncheckedList(final Path path) {
try {
return Files.list(path);
} catch (final IOException ex) {
throw new UncheckedIOException("Error fetching file list", ex);
}
} | [
"public",
"static",
"Stream",
"<",
"Path",
">",
"uncheckedList",
"(",
"final",
"Path",
"path",
")",
"{",
"try",
"{",
"return",
"Files",
".",
"list",
"(",
"path",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"UncheckedIOException",
"(",
"\"Error fetching file list\"",
",",
"ex",
")",
";",
"}",
"}"
] | Fetch a stream of files in the provided directory path.
@param path the directory path
@return a stream of filenames | [
"Fetch",
"a",
"stream",
"of",
"files",
"in",
"the",
"provided",
"directory",
"path",
"."
] | train | https://github.com/trellis-ldp/trellis/blob/789fd7a3df86cab7ebba63e72bf4e58397e5f42d/components/file/src/main/java/org/trellisldp/file/FileUtils.java#L129-L135 |
census-instrumentation/opencensus-java | impl_core/src/main/java/io/opencensus/implcore/internal/VarInt.java | VarInt.putVarInt | public static int putVarInt(int v, byte[] sink, int offset) {
"""
Encodes an integer in a variable-length encoding, 7 bits per byte, into a destination byte[],
following the protocol buffer convention.
@param v the int value to write to sink
@param sink the sink buffer to write to
@param offset the offset within sink to begin writing
@return the updated offset after writing the varint
"""
do {
// Encode next 7 bits + terminator bit
int bits = v & 0x7F;
v >>>= 7;
byte b = (byte) (bits + ((v != 0) ? 0x80 : 0));
sink[offset++] = b;
} while (v != 0);
return offset;
} | java | public static int putVarInt(int v, byte[] sink, int offset) {
do {
// Encode next 7 bits + terminator bit
int bits = v & 0x7F;
v >>>= 7;
byte b = (byte) (bits + ((v != 0) ? 0x80 : 0));
sink[offset++] = b;
} while (v != 0);
return offset;
} | [
"public",
"static",
"int",
"putVarInt",
"(",
"int",
"v",
",",
"byte",
"[",
"]",
"sink",
",",
"int",
"offset",
")",
"{",
"do",
"{",
"// Encode next 7 bits + terminator bit",
"int",
"bits",
"=",
"v",
"&",
"0x7F",
";",
"v",
">>>=",
"7",
";",
"byte",
"b",
"=",
"(",
"byte",
")",
"(",
"bits",
"+",
"(",
"(",
"v",
"!=",
"0",
")",
"?",
"0x80",
":",
"0",
")",
")",
";",
"sink",
"[",
"offset",
"++",
"]",
"=",
"b",
";",
"}",
"while",
"(",
"v",
"!=",
"0",
")",
";",
"return",
"offset",
";",
"}"
] | Encodes an integer in a variable-length encoding, 7 bits per byte, into a destination byte[],
following the protocol buffer convention.
@param v the int value to write to sink
@param sink the sink buffer to write to
@param offset the offset within sink to begin writing
@return the updated offset after writing the varint | [
"Encodes",
"an",
"integer",
"in",
"a",
"variable",
"-",
"length",
"encoding",
"7",
"bits",
"per",
"byte",
"into",
"a",
"destination",
"byte",
"[]",
"following",
"the",
"protocol",
"buffer",
"convention",
"."
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/impl_core/src/main/java/io/opencensus/implcore/internal/VarInt.java#L88-L97 |
janus-project/guava.janusproject.io | guava/src/com/google/common/collect/AbstractMapBasedMultiset.java | AbstractMapBasedMultiset.add | @Override public int add(@Nullable E element, int occurrences) {
"""
{@inheritDoc}
@throws IllegalArgumentException if the call would result in more than
{@link Integer#MAX_VALUE} occurrences of {@code element} in this
multiset.
"""
if (occurrences == 0) {
return count(element);
}
checkArgument(
occurrences > 0, "occurrences cannot be negative: %s", occurrences);
Count frequency = backingMap.get(element);
int oldCount;
if (frequency == null) {
oldCount = 0;
backingMap.put(element, new Count(occurrences));
} else {
oldCount = frequency.get();
long newCount = (long) oldCount + (long) occurrences;
checkArgument(newCount <= Integer.MAX_VALUE,
"too many occurrences: %s", newCount);
frequency.getAndAdd(occurrences);
}
size += occurrences;
return oldCount;
} | java | @Override public int add(@Nullable E element, int occurrences) {
if (occurrences == 0) {
return count(element);
}
checkArgument(
occurrences > 0, "occurrences cannot be negative: %s", occurrences);
Count frequency = backingMap.get(element);
int oldCount;
if (frequency == null) {
oldCount = 0;
backingMap.put(element, new Count(occurrences));
} else {
oldCount = frequency.get();
long newCount = (long) oldCount + (long) occurrences;
checkArgument(newCount <= Integer.MAX_VALUE,
"too many occurrences: %s", newCount);
frequency.getAndAdd(occurrences);
}
size += occurrences;
return oldCount;
} | [
"@",
"Override",
"public",
"int",
"add",
"(",
"@",
"Nullable",
"E",
"element",
",",
"int",
"occurrences",
")",
"{",
"if",
"(",
"occurrences",
"==",
"0",
")",
"{",
"return",
"count",
"(",
"element",
")",
";",
"}",
"checkArgument",
"(",
"occurrences",
">",
"0",
",",
"\"occurrences cannot be negative: %s\"",
",",
"occurrences",
")",
";",
"Count",
"frequency",
"=",
"backingMap",
".",
"get",
"(",
"element",
")",
";",
"int",
"oldCount",
";",
"if",
"(",
"frequency",
"==",
"null",
")",
"{",
"oldCount",
"=",
"0",
";",
"backingMap",
".",
"put",
"(",
"element",
",",
"new",
"Count",
"(",
"occurrences",
")",
")",
";",
"}",
"else",
"{",
"oldCount",
"=",
"frequency",
".",
"get",
"(",
")",
";",
"long",
"newCount",
"=",
"(",
"long",
")",
"oldCount",
"+",
"(",
"long",
")",
"occurrences",
";",
"checkArgument",
"(",
"newCount",
"<=",
"Integer",
".",
"MAX_VALUE",
",",
"\"too many occurrences: %s\"",
",",
"newCount",
")",
";",
"frequency",
".",
"getAndAdd",
"(",
"occurrences",
")",
";",
"}",
"size",
"+=",
"occurrences",
";",
"return",
"oldCount",
";",
"}"
] | {@inheritDoc}
@throws IllegalArgumentException if the call would result in more than
{@link Integer#MAX_VALUE} occurrences of {@code element} in this
multiset. | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java#L214-L234 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.