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
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/AuthenticateApi.java | AuthenticateApi.throwExceptionIfAlreadyAuthenticate | public void throwExceptionIfAlreadyAuthenticate(HttpServletRequest req, HttpServletResponse resp, WebAppSecurityConfig config, String username) throws ServletException {
"""
This method throws an exception if the caller subject is already authenticated and
WebAlwaysLogin is false. If the caller subject is already authenticated and
WebAlwaysLogin is true, then it will logout the user.
@throws IOException
@throws ServletException
"""
Subject callerSubject = subjectManager.getCallerSubject();
if (subjectHelper.isUnauthenticated(callerSubject))
return;
if (!config.getWebAlwaysLogin()) {
AuthenticationResult authResult = new AuthenticationResult(AuthResult.FAILURE, username);
authResult.setAuditCredType(req.getAuthType());
authResult.setAuditCredValue(username);
authResult.setAuditOutcome(AuditEvent.OUTCOME_FAILURE);
Audit.audit(Audit.EventID.SECURITY_API_AUTHN_01, req, authResult, Integer.valueOf(HttpServletResponse.SC_UNAUTHORIZED));
throw new ServletException("Authentication had been already established");
}
logout(req, resp, config);
} | java | public void throwExceptionIfAlreadyAuthenticate(HttpServletRequest req, HttpServletResponse resp, WebAppSecurityConfig config, String username) throws ServletException {
Subject callerSubject = subjectManager.getCallerSubject();
if (subjectHelper.isUnauthenticated(callerSubject))
return;
if (!config.getWebAlwaysLogin()) {
AuthenticationResult authResult = new AuthenticationResult(AuthResult.FAILURE, username);
authResult.setAuditCredType(req.getAuthType());
authResult.setAuditCredValue(username);
authResult.setAuditOutcome(AuditEvent.OUTCOME_FAILURE);
Audit.audit(Audit.EventID.SECURITY_API_AUTHN_01, req, authResult, Integer.valueOf(HttpServletResponse.SC_UNAUTHORIZED));
throw new ServletException("Authentication had been already established");
}
logout(req, resp, config);
} | [
"public",
"void",
"throwExceptionIfAlreadyAuthenticate",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"resp",
",",
"WebAppSecurityConfig",
"config",
",",
"String",
"username",
")",
"throws",
"ServletException",
"{",
"Subject",
"callerSubject",
"=",
"subjectManager",
".",
"getCallerSubject",
"(",
")",
";",
"if",
"(",
"subjectHelper",
".",
"isUnauthenticated",
"(",
"callerSubject",
")",
")",
"return",
";",
"if",
"(",
"!",
"config",
".",
"getWebAlwaysLogin",
"(",
")",
")",
"{",
"AuthenticationResult",
"authResult",
"=",
"new",
"AuthenticationResult",
"(",
"AuthResult",
".",
"FAILURE",
",",
"username",
")",
";",
"authResult",
".",
"setAuditCredType",
"(",
"req",
".",
"getAuthType",
"(",
")",
")",
";",
"authResult",
".",
"setAuditCredValue",
"(",
"username",
")",
";",
"authResult",
".",
"setAuditOutcome",
"(",
"AuditEvent",
".",
"OUTCOME_FAILURE",
")",
";",
"Audit",
".",
"audit",
"(",
"Audit",
".",
"EventID",
".",
"SECURITY_API_AUTHN_01",
",",
"req",
",",
"authResult",
",",
"Integer",
".",
"valueOf",
"(",
"HttpServletResponse",
".",
"SC_UNAUTHORIZED",
")",
")",
";",
"throw",
"new",
"ServletException",
"(",
"\"Authentication had been already established\"",
")",
";",
"}",
"logout",
"(",
"req",
",",
"resp",
",",
"config",
")",
";",
"}"
]
| This method throws an exception if the caller subject is already authenticated and
WebAlwaysLogin is false. If the caller subject is already authenticated and
WebAlwaysLogin is true, then it will logout the user.
@throws IOException
@throws ServletException | [
"This",
"method",
"throws",
"an",
"exception",
"if",
"the",
"caller",
"subject",
"is",
"already",
"authenticated",
"and",
"WebAlwaysLogin",
"is",
"false",
".",
"If",
"the",
"caller",
"subject",
"is",
"already",
"authenticated",
"and",
"WebAlwaysLogin",
"is",
"true",
"then",
"it",
"will",
"logout",
"the",
"user",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/AuthenticateApi.java#L425-L438 |
Samsung/GearVRf | GVRf/Extensions/gvrf-particlesystem/src/main/java/org/gearvrf/particlesystem/GVREmitter.java | GVREmitter.setParticleVolume | public void setParticleVolume(final float width, final float height, final float depth) {
"""
Create a bouding volume for the particle system centered at its position with
the specified width, height and depth. This is important to do because the parent scene
object might fall outside the viewing frustum and cause the entire system to be
culled.
This function creates 8 particles (mesh vertices) with very large spawning time
attributes (i.e. they are always discarded) which define the volume of the system. The
system is assumed to stay inside this volume.
@param width volume length (along x-axis)
@param height volume height (along y-axis)
@param depth volume depth (along z-axis)
"""
final GVRTransform thisTransform = this.getTransform();
if (null != mGVRContext) {
mGVRContext.runOnGlThread(new Runnable() {
@Override
public void run() {Vector3f center = new Vector3f(thisTransform.getPositionX(),
thisTransform.getPositionY(), thisTransform.getPositionZ());
particleBoundingVolume = new float[]{center.x - width/2, center.y - height/2, center.z - depth/2,
center.x - width/2, center.y - height/2, center.z + depth/2,
center.x + width/2, center.y - height/2, center.z + depth/2,
center.x + width/2, center.y - height/2, center.z - depth/2,
center.x - width/2, center.y + height/2, center.z - depth/2,
center.x - width/2, center.y + height/2, center.z + depth/2,
center.x + width/2, center.y + height/2, center.z + depth/2,
center.x - width/2, center.y + height/2, center.z - depth/2};
BVSpawnTimes = new float[]{Float.MAX_VALUE, 0, Float.MAX_VALUE, 0, Float.MAX_VALUE,
0, Float.MAX_VALUE, 0, Float.MAX_VALUE, 0, Float.MAX_VALUE, 0,
Float.MAX_VALUE, 0, Float.MAX_VALUE, 0};
BVVelocities = new float[24];
for ( int i = 0; i < 24; i ++ )
BVVelocities[i] = 0;
}
});
}
} | java | public void setParticleVolume(final float width, final float height, final float depth)
{
final GVRTransform thisTransform = this.getTransform();
if (null != mGVRContext) {
mGVRContext.runOnGlThread(new Runnable() {
@Override
public void run() {Vector3f center = new Vector3f(thisTransform.getPositionX(),
thisTransform.getPositionY(), thisTransform.getPositionZ());
particleBoundingVolume = new float[]{center.x - width/2, center.y - height/2, center.z - depth/2,
center.x - width/2, center.y - height/2, center.z + depth/2,
center.x + width/2, center.y - height/2, center.z + depth/2,
center.x + width/2, center.y - height/2, center.z - depth/2,
center.x - width/2, center.y + height/2, center.z - depth/2,
center.x - width/2, center.y + height/2, center.z + depth/2,
center.x + width/2, center.y + height/2, center.z + depth/2,
center.x - width/2, center.y + height/2, center.z - depth/2};
BVSpawnTimes = new float[]{Float.MAX_VALUE, 0, Float.MAX_VALUE, 0, Float.MAX_VALUE,
0, Float.MAX_VALUE, 0, Float.MAX_VALUE, 0, Float.MAX_VALUE, 0,
Float.MAX_VALUE, 0, Float.MAX_VALUE, 0};
BVVelocities = new float[24];
for ( int i = 0; i < 24; i ++ )
BVVelocities[i] = 0;
}
});
}
} | [
"public",
"void",
"setParticleVolume",
"(",
"final",
"float",
"width",
",",
"final",
"float",
"height",
",",
"final",
"float",
"depth",
")",
"{",
"final",
"GVRTransform",
"thisTransform",
"=",
"this",
".",
"getTransform",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"mGVRContext",
")",
"{",
"mGVRContext",
".",
"runOnGlThread",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"Vector3f",
"center",
"=",
"new",
"Vector3f",
"(",
"thisTransform",
".",
"getPositionX",
"(",
")",
",",
"thisTransform",
".",
"getPositionY",
"(",
")",
",",
"thisTransform",
".",
"getPositionZ",
"(",
")",
")",
";",
"particleBoundingVolume",
"=",
"new",
"float",
"[",
"]",
"{",
"center",
".",
"x",
"-",
"width",
"/",
"2",
",",
"center",
".",
"y",
"-",
"height",
"/",
"2",
",",
"center",
".",
"z",
"-",
"depth",
"/",
"2",
",",
"center",
".",
"x",
"-",
"width",
"/",
"2",
",",
"center",
".",
"y",
"-",
"height",
"/",
"2",
",",
"center",
".",
"z",
"+",
"depth",
"/",
"2",
",",
"center",
".",
"x",
"+",
"width",
"/",
"2",
",",
"center",
".",
"y",
"-",
"height",
"/",
"2",
",",
"center",
".",
"z",
"+",
"depth",
"/",
"2",
",",
"center",
".",
"x",
"+",
"width",
"/",
"2",
",",
"center",
".",
"y",
"-",
"height",
"/",
"2",
",",
"center",
".",
"z",
"-",
"depth",
"/",
"2",
",",
"center",
".",
"x",
"-",
"width",
"/",
"2",
",",
"center",
".",
"y",
"+",
"height",
"/",
"2",
",",
"center",
".",
"z",
"-",
"depth",
"/",
"2",
",",
"center",
".",
"x",
"-",
"width",
"/",
"2",
",",
"center",
".",
"y",
"+",
"height",
"/",
"2",
",",
"center",
".",
"z",
"+",
"depth",
"/",
"2",
",",
"center",
".",
"x",
"+",
"width",
"/",
"2",
",",
"center",
".",
"y",
"+",
"height",
"/",
"2",
",",
"center",
".",
"z",
"+",
"depth",
"/",
"2",
",",
"center",
".",
"x",
"-",
"width",
"/",
"2",
",",
"center",
".",
"y",
"+",
"height",
"/",
"2",
",",
"center",
".",
"z",
"-",
"depth",
"/",
"2",
"}",
";",
"BVSpawnTimes",
"=",
"new",
"float",
"[",
"]",
"{",
"Float",
".",
"MAX_VALUE",
",",
"0",
",",
"Float",
".",
"MAX_VALUE",
",",
"0",
",",
"Float",
".",
"MAX_VALUE",
",",
"0",
",",
"Float",
".",
"MAX_VALUE",
",",
"0",
",",
"Float",
".",
"MAX_VALUE",
",",
"0",
",",
"Float",
".",
"MAX_VALUE",
",",
"0",
",",
"Float",
".",
"MAX_VALUE",
",",
"0",
",",
"Float",
".",
"MAX_VALUE",
",",
"0",
"}",
";",
"BVVelocities",
"=",
"new",
"float",
"[",
"24",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"24",
";",
"i",
"++",
")",
"BVVelocities",
"[",
"i",
"]",
"=",
"0",
";",
"}",
"}",
")",
";",
"}",
"}"
]
| Create a bouding volume for the particle system centered at its position with
the specified width, height and depth. This is important to do because the parent scene
object might fall outside the viewing frustum and cause the entire system to be
culled.
This function creates 8 particles (mesh vertices) with very large spawning time
attributes (i.e. they are always discarded) which define the volume of the system. The
system is assumed to stay inside this volume.
@param width volume length (along x-axis)
@param height volume height (along y-axis)
@param depth volume depth (along z-axis) | [
"Create",
"a",
"bouding",
"volume",
"for",
"the",
"particle",
"system",
"centered",
"at",
"its",
"position",
"with",
"the",
"specified",
"width",
"height",
"and",
"depth",
".",
"This",
"is",
"important",
"to",
"do",
"because",
"the",
"parent",
"scene",
"object",
"might",
"fall",
"outside",
"the",
"viewing",
"frustum",
"and",
"cause",
"the",
"entire",
"system",
"to",
"be",
"culled",
".",
"This",
"function",
"creates",
"8",
"particles",
"(",
"mesh",
"vertices",
")",
"with",
"very",
"large",
"spawning",
"time",
"attributes",
"(",
"i",
".",
"e",
".",
"they",
"are",
"always",
"discarded",
")",
"which",
"define",
"the",
"volume",
"of",
"the",
"system",
".",
"The",
"system",
"is",
"assumed",
"to",
"stay",
"inside",
"this",
"volume",
"."
]
| train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/gvrf-particlesystem/src/main/java/org/gearvrf/particlesystem/GVREmitter.java#L205-L237 |
TNG/JGiven | jgiven-core/src/main/java/com/tngtech/jgiven/attachment/Attachment.java | Attachment.fromTextInputStream | public static Attachment fromTextInputStream( InputStream inputStream, MediaType mediaType ) throws IOException {
"""
Creates a non-binary attachment from the given file.
@throws IOException if an I/O error occurs
@throws java.lang.IllegalArgumentException if mediaType is either binary or has no specified charset
"""
return fromText( CharStreams.toString( new InputStreamReader( inputStream, mediaType.getCharset() ) ), mediaType );
} | java | public static Attachment fromTextInputStream( InputStream inputStream, MediaType mediaType ) throws IOException {
return fromText( CharStreams.toString( new InputStreamReader( inputStream, mediaType.getCharset() ) ), mediaType );
} | [
"public",
"static",
"Attachment",
"fromTextInputStream",
"(",
"InputStream",
"inputStream",
",",
"MediaType",
"mediaType",
")",
"throws",
"IOException",
"{",
"return",
"fromText",
"(",
"CharStreams",
".",
"toString",
"(",
"new",
"InputStreamReader",
"(",
"inputStream",
",",
"mediaType",
".",
"getCharset",
"(",
")",
")",
")",
",",
"mediaType",
")",
";",
"}"
]
| Creates a non-binary attachment from the given file.
@throws IOException if an I/O error occurs
@throws java.lang.IllegalArgumentException if mediaType is either binary or has no specified charset | [
"Creates",
"a",
"non",
"-",
"binary",
"attachment",
"from",
"the",
"given",
"file",
"."
]
| train | https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/attachment/Attachment.java#L231-L233 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/AttributeDefinition.java | AttributeDefinition.correctValue | protected final ModelNode correctValue(final ModelNode newValue, final ModelNode oldValue) {
"""
Corrects the value if the {@link ParameterCorrector value corrector} is not {@code null}. If the {@link
ParameterCorrector value corrector} is {@code null}, the {@code newValue} parameter is returned.
@param newValue the new value.
@param oldValue the old value.
@return the corrected value or the {@code newValue} if the {@link ParameterCorrector value corrector} is {@code
null}.
"""
if (valueCorrector != null) {
return valueCorrector.correct(newValue, oldValue);
}
return newValue;
} | java | protected final ModelNode correctValue(final ModelNode newValue, final ModelNode oldValue) {
if (valueCorrector != null) {
return valueCorrector.correct(newValue, oldValue);
}
return newValue;
} | [
"protected",
"final",
"ModelNode",
"correctValue",
"(",
"final",
"ModelNode",
"newValue",
",",
"final",
"ModelNode",
"oldValue",
")",
"{",
"if",
"(",
"valueCorrector",
"!=",
"null",
")",
"{",
"return",
"valueCorrector",
".",
"correct",
"(",
"newValue",
",",
"oldValue",
")",
";",
"}",
"return",
"newValue",
";",
"}"
]
| Corrects the value if the {@link ParameterCorrector value corrector} is not {@code null}. If the {@link
ParameterCorrector value corrector} is {@code null}, the {@code newValue} parameter is returned.
@param newValue the new value.
@param oldValue the old value.
@return the corrected value or the {@code newValue} if the {@link ParameterCorrector value corrector} is {@code
null}. | [
"Corrects",
"the",
"value",
"if",
"the",
"{",
"@link",
"ParameterCorrector",
"value",
"corrector",
"}",
"is",
"not",
"{",
"@code",
"null",
"}",
".",
"If",
"the",
"{",
"@link",
"ParameterCorrector",
"value",
"corrector",
"}",
"is",
"{",
"@code",
"null",
"}",
"the",
"{",
"@code",
"newValue",
"}",
"parameter",
"is",
"returned",
"."
]
| train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/AttributeDefinition.java#L1162-L1167 |
alibaba/otter | node/etl/src/main/java/com/alibaba/otter/node/etl/load/loader/weight/WeightBarrier.java | WeightBarrier.await | public void await(long weight, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
"""
阻塞等待当前的weight处理,允许设置超时时间
<pre>
阻塞返回条件:
1. 中断事件
2. 其他线程single()的weight > 当前阻塞等待的weight
3. 超时
</pre>
@param timeout
@param unit
@throws InterruptedException
@throws TimeoutException
"""
try {
lock.lockInterruptibly();
while (isPermit(weight) == false) {
condition.await(timeout, unit);
}
} finally {
lock.unlock();
}
} | java | public void await(long weight, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
try {
lock.lockInterruptibly();
while (isPermit(weight) == false) {
condition.await(timeout, unit);
}
} finally {
lock.unlock();
}
} | [
"public",
"void",
"await",
"(",
"long",
"weight",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
",",
"TimeoutException",
"{",
"try",
"{",
"lock",
".",
"lockInterruptibly",
"(",
")",
";",
"while",
"(",
"isPermit",
"(",
"weight",
")",
"==",
"false",
")",
"{",
"condition",
".",
"await",
"(",
"timeout",
",",
"unit",
")",
";",
"}",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
]
| 阻塞等待当前的weight处理,允许设置超时时间
<pre>
阻塞返回条件:
1. 中断事件
2. 其他线程single()的weight > 当前阻塞等待的weight
3. 超时
</pre>
@param timeout
@param unit
@throws InterruptedException
@throws TimeoutException | [
"阻塞等待当前的weight处理",
"允许设置超时时间"
]
| train | https://github.com/alibaba/otter/blob/c7b5f94a0dd162e01ddffaf3a63cade7d23fca55/node/etl/src/main/java/com/alibaba/otter/node/etl/load/loader/weight/WeightBarrier.java#L90-L99 |
smartsheet-platform/smartsheet-java-sdk | src/main/java/com/smartsheet/api/internal/ShareResourcesImpl.java | ShareResourcesImpl.getShare | public Share getShare(long objectId, String shareId) throws SmartsheetException {
"""
Get a Share.
It mirrors to the following Smartsheet REST API method:
GET /workspaces/{workspaceId}/shares/{shareId}
GET /sheets/{sheetId}/shares/{shareId}
GET /sights/{sightId}/shares
GET /reports/{reportId}/shares
Exceptions:
InvalidRequestException : if there is any problem with the REST API request
AuthorizationException : if there is any problem with the REST API authorization(access token)
ResourceNotFoundException : if the resource can not be found
ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
SmartsheetRestException : if there is any other REST API related error occurred during the operation
SmartsheetException : if there is any other error occurred during the operation
@param objectId the ID of the object to share
@param shareId the ID of the share
@return the share (note that if there is no such resource, this method will throw ResourceNotFoundException
rather than returning null).
@throws SmartsheetException the smartsheet exception
"""
return this.getResource(getMasterResourceType() + "/" + objectId + "/shares/" + shareId, Share.class);
} | java | public Share getShare(long objectId, String shareId) throws SmartsheetException{
return this.getResource(getMasterResourceType() + "/" + objectId + "/shares/" + shareId, Share.class);
} | [
"public",
"Share",
"getShare",
"(",
"long",
"objectId",
",",
"String",
"shareId",
")",
"throws",
"SmartsheetException",
"{",
"return",
"this",
".",
"getResource",
"(",
"getMasterResourceType",
"(",
")",
"+",
"\"/\"",
"+",
"objectId",
"+",
"\"/shares/\"",
"+",
"shareId",
",",
"Share",
".",
"class",
")",
";",
"}"
]
| Get a Share.
It mirrors to the following Smartsheet REST API method:
GET /workspaces/{workspaceId}/shares/{shareId}
GET /sheets/{sheetId}/shares/{shareId}
GET /sights/{sightId}/shares
GET /reports/{reportId}/shares
Exceptions:
InvalidRequestException : if there is any problem with the REST API request
AuthorizationException : if there is any problem with the REST API authorization(access token)
ResourceNotFoundException : if the resource can not be found
ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
SmartsheetRestException : if there is any other REST API related error occurred during the operation
SmartsheetException : if there is any other error occurred during the operation
@param objectId the ID of the object to share
@param shareId the ID of the share
@return the share (note that if there is no such resource, this method will throw ResourceNotFoundException
rather than returning null).
@throws SmartsheetException the smartsheet exception | [
"Get",
"a",
"Share",
"."
]
| train | https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/f60e264412076271f83b65889ef9b891fad83df8/src/main/java/com/smartsheet/api/internal/ShareResourcesImpl.java#L117-L119 |
Azure/azure-sdk-for-java | mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/ConfigurationsInner.java | ConfigurationsInner.createOrUpdateAsync | public Observable<ConfigurationInner> createOrUpdateAsync(String resourceGroupName, String serverName, String configurationName, ConfigurationInner parameters) {
"""
Updates a configuration of a server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param configurationName The name of the server configuration.
@param parameters The required parameters for updating a server configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, configurationName, parameters).map(new Func1<ServiceResponse<ConfigurationInner>, ConfigurationInner>() {
@Override
public ConfigurationInner call(ServiceResponse<ConfigurationInner> response) {
return response.body();
}
});
} | java | public Observable<ConfigurationInner> createOrUpdateAsync(String resourceGroupName, String serverName, String configurationName, ConfigurationInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, configurationName, parameters).map(new Func1<ServiceResponse<ConfigurationInner>, ConfigurationInner>() {
@Override
public ConfigurationInner call(ServiceResponse<ConfigurationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ConfigurationInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"configurationName",
",",
"ConfigurationInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"configurationName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ConfigurationInner",
">",
",",
"ConfigurationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ConfigurationInner",
"call",
"(",
"ServiceResponse",
"<",
"ConfigurationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Updates a configuration of a server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param configurationName The name of the server configuration.
@param parameters The required parameters for updating a server configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Updates",
"a",
"configuration",
"of",
"a",
"server",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/ConfigurationsInner.java#L117-L124 |
cdk/cdk | tool/formula/src/main/java/org/openscience/cdk/tools/manipulator/MolecularFormulaManipulator.java | MolecularFormulaManipulator.getMolecularFormula | public static IMolecularFormula getMolecularFormula(IAtomContainer atomContainer, IMolecularFormula formula) {
"""
Method that actually does the work of convert the atomContainer
to IMolecularFormula given a IMolecularFormula.
<p> The hydrogens must be implicit.
@param atomContainer IAtomContainer object
@param formula IMolecularFormula molecularFormula to put the new Isotopes
@return the filled AtomContainer
@see #getMolecularFormula(IAtomContainer)
"""
int charge = 0;
int hcnt = 0;
for (IAtom iAtom : atomContainer.atoms()) {
formula.addIsotope(iAtom);
if (iAtom.getFormalCharge() != null)
charge += iAtom.getFormalCharge();
if (iAtom.getImplicitHydrogenCount() != null)
hcnt += iAtom.getImplicitHydrogenCount();
}
if (hcnt != 0) {
IAtom hAtom = atomContainer.getBuilder().newInstance(IAtom.class, "H");
formula.addIsotope(hAtom, hcnt);
}
formula.setCharge(charge);
return formula;
} | java | public static IMolecularFormula getMolecularFormula(IAtomContainer atomContainer, IMolecularFormula formula) {
int charge = 0;
int hcnt = 0;
for (IAtom iAtom : atomContainer.atoms()) {
formula.addIsotope(iAtom);
if (iAtom.getFormalCharge() != null)
charge += iAtom.getFormalCharge();
if (iAtom.getImplicitHydrogenCount() != null)
hcnt += iAtom.getImplicitHydrogenCount();
}
if (hcnt != 0) {
IAtom hAtom = atomContainer.getBuilder().newInstance(IAtom.class, "H");
formula.addIsotope(hAtom, hcnt);
}
formula.setCharge(charge);
return formula;
} | [
"public",
"static",
"IMolecularFormula",
"getMolecularFormula",
"(",
"IAtomContainer",
"atomContainer",
",",
"IMolecularFormula",
"formula",
")",
"{",
"int",
"charge",
"=",
"0",
";",
"int",
"hcnt",
"=",
"0",
";",
"for",
"(",
"IAtom",
"iAtom",
":",
"atomContainer",
".",
"atoms",
"(",
")",
")",
"{",
"formula",
".",
"addIsotope",
"(",
"iAtom",
")",
";",
"if",
"(",
"iAtom",
".",
"getFormalCharge",
"(",
")",
"!=",
"null",
")",
"charge",
"+=",
"iAtom",
".",
"getFormalCharge",
"(",
")",
";",
"if",
"(",
"iAtom",
".",
"getImplicitHydrogenCount",
"(",
")",
"!=",
"null",
")",
"hcnt",
"+=",
"iAtom",
".",
"getImplicitHydrogenCount",
"(",
")",
";",
"}",
"if",
"(",
"hcnt",
"!=",
"0",
")",
"{",
"IAtom",
"hAtom",
"=",
"atomContainer",
".",
"getBuilder",
"(",
")",
".",
"newInstance",
"(",
"IAtom",
".",
"class",
",",
"\"H\"",
")",
";",
"formula",
".",
"addIsotope",
"(",
"hAtom",
",",
"hcnt",
")",
";",
"}",
"formula",
".",
"setCharge",
"(",
"charge",
")",
";",
"return",
"formula",
";",
"}"
]
| Method that actually does the work of convert the atomContainer
to IMolecularFormula given a IMolecularFormula.
<p> The hydrogens must be implicit.
@param atomContainer IAtomContainer object
@param formula IMolecularFormula molecularFormula to put the new Isotopes
@return the filled AtomContainer
@see #getMolecularFormula(IAtomContainer) | [
"Method",
"that",
"actually",
"does",
"the",
"work",
"of",
"convert",
"the",
"atomContainer",
"to",
"IMolecularFormula",
"given",
"a",
"IMolecularFormula",
".",
"<p",
">",
"The",
"hydrogens",
"must",
"be",
"implicit",
"."
]
| train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/formula/src/main/java/org/openscience/cdk/tools/manipulator/MolecularFormulaManipulator.java#L1067-L1083 |
resilience4j/resilience4j | resilience4j-prometheus/src/main/java/io/github/resilience4j/prometheus/CircuitBreakerExports.java | CircuitBreakerExports.ofCircuitBreakerRegistry | public static CircuitBreakerExports ofCircuitBreakerRegistry(String prefix, CircuitBreakerRegistry circuitBreakerRegistry) {
"""
Creates a new instance of {@link CircuitBreakerExports} with specified metrics names prefix and
{@link CircuitBreakerRegistry} as a source of circuit breakers.
@param prefix the prefix of metrics names
@param circuitBreakerRegistry the registry of circuit breakers
"""
requireNonNull(prefix);
requireNonNull(circuitBreakerRegistry);
return new CircuitBreakerExports(prefix, circuitBreakerRegistry);
} | java | public static CircuitBreakerExports ofCircuitBreakerRegistry(String prefix, CircuitBreakerRegistry circuitBreakerRegistry) {
requireNonNull(prefix);
requireNonNull(circuitBreakerRegistry);
return new CircuitBreakerExports(prefix, circuitBreakerRegistry);
} | [
"public",
"static",
"CircuitBreakerExports",
"ofCircuitBreakerRegistry",
"(",
"String",
"prefix",
",",
"CircuitBreakerRegistry",
"circuitBreakerRegistry",
")",
"{",
"requireNonNull",
"(",
"prefix",
")",
";",
"requireNonNull",
"(",
"circuitBreakerRegistry",
")",
";",
"return",
"new",
"CircuitBreakerExports",
"(",
"prefix",
",",
"circuitBreakerRegistry",
")",
";",
"}"
]
| Creates a new instance of {@link CircuitBreakerExports} with specified metrics names prefix and
{@link CircuitBreakerRegistry} as a source of circuit breakers.
@param prefix the prefix of metrics names
@param circuitBreakerRegistry the registry of circuit breakers | [
"Creates",
"a",
"new",
"instance",
"of",
"{",
"@link",
"CircuitBreakerExports",
"}",
"with",
"specified",
"metrics",
"names",
"prefix",
"and",
"{",
"@link",
"CircuitBreakerRegistry",
"}",
"as",
"a",
"source",
"of",
"circuit",
"breakers",
"."
]
| train | https://github.com/resilience4j/resilience4j/blob/fa843d30f531c00f0c3dc218b65a7f2bb51af336/resilience4j-prometheus/src/main/java/io/github/resilience4j/prometheus/CircuitBreakerExports.java#L114-L118 |
lessthanoptimal/ddogleg | src/org/ddogleg/struct/GrowQueue_I32.java | GrowQueue_I32.setTo | public void setTo( int[] array , int offset , int length ) {
"""
Sets this array to be equal to the array segment
@param array (Input) source array
@param offset first index
@param length number of elements to copy
"""
resize(length);
System.arraycopy(array,offset,data,0,length);
} | java | public void setTo( int[] array , int offset , int length ) {
resize(length);
System.arraycopy(array,offset,data,0,length);
} | [
"public",
"void",
"setTo",
"(",
"int",
"[",
"]",
"array",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"resize",
"(",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"array",
",",
"offset",
",",
"data",
",",
"0",
",",
"length",
")",
";",
"}"
]
| Sets this array to be equal to the array segment
@param array (Input) source array
@param offset first index
@param length number of elements to copy | [
"Sets",
"this",
"array",
"to",
"be",
"equal",
"to",
"the",
"array",
"segment"
]
| train | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_I32.java#L138-L141 |
sangupta/jerry-web | src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java | JavascriptMinificationFilter.compressJavascriptEmbedded | private String compressJavascriptEmbedded(final String uri, final String code) {
"""
Compress the Javascript.
@param uri
the URI for the JS file
@param code
the actual Javascript code
@return the compressed code for the JS file
"""
if(code == null || code.isEmpty()) {
return code;
}
int index = uri.lastIndexOf('/');
String name = uri;
if(index > 0) {
name = uri.substring(index + 1);
}
List<SourceFile> externs = Collections.emptyList();
List<SourceFile> inputs = Arrays.asList(SourceFile.fromCode(name, code));
CompilerOptions options = new CompilerOptions();
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
Result result = compiler.compile(externs, inputs, options);
if (result.success) {
return compiler.toSource();
}
throw new IllegalArgumentException("Unable to compress javascript");
} | java | private String compressJavascriptEmbedded(final String uri, final String code) {
if(code == null || code.isEmpty()) {
return code;
}
int index = uri.lastIndexOf('/');
String name = uri;
if(index > 0) {
name = uri.substring(index + 1);
}
List<SourceFile> externs = Collections.emptyList();
List<SourceFile> inputs = Arrays.asList(SourceFile.fromCode(name, code));
CompilerOptions options = new CompilerOptions();
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
Result result = compiler.compile(externs, inputs, options);
if (result.success) {
return compiler.toSource();
}
throw new IllegalArgumentException("Unable to compress javascript");
} | [
"private",
"String",
"compressJavascriptEmbedded",
"(",
"final",
"String",
"uri",
",",
"final",
"String",
"code",
")",
"{",
"if",
"(",
"code",
"==",
"null",
"||",
"code",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"code",
";",
"}",
"int",
"index",
"=",
"uri",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"String",
"name",
"=",
"uri",
";",
"if",
"(",
"index",
">",
"0",
")",
"{",
"name",
"=",
"uri",
".",
"substring",
"(",
"index",
"+",
"1",
")",
";",
"}",
"List",
"<",
"SourceFile",
">",
"externs",
"=",
"Collections",
".",
"emptyList",
"(",
")",
";",
"List",
"<",
"SourceFile",
">",
"inputs",
"=",
"Arrays",
".",
"asList",
"(",
"SourceFile",
".",
"fromCode",
"(",
"name",
",",
"code",
")",
")",
";",
"CompilerOptions",
"options",
"=",
"new",
"CompilerOptions",
"(",
")",
";",
"CompilationLevel",
".",
"SIMPLE_OPTIMIZATIONS",
".",
"setOptionsForCompilationLevel",
"(",
"options",
")",
";",
"com",
".",
"google",
".",
"javascript",
".",
"jscomp",
".",
"Compiler",
"compiler",
"=",
"new",
"com",
".",
"google",
".",
"javascript",
".",
"jscomp",
".",
"Compiler",
"(",
")",
";",
"Result",
"result",
"=",
"compiler",
".",
"compile",
"(",
"externs",
",",
"inputs",
",",
"options",
")",
";",
"if",
"(",
"result",
".",
"success",
")",
"{",
"return",
"compiler",
".",
"toSource",
"(",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unable to compress javascript\"",
")",
";",
"}"
]
| Compress the Javascript.
@param uri
the URI for the JS file
@param code
the actual Javascript code
@return the compressed code for the JS file | [
"Compress",
"the",
"Javascript",
"."
]
| train | https://github.com/sangupta/jerry-web/blob/f0d02a5d6e7d1c15292509ce588caf52a4ddb895/src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java#L233-L257 |
ThreeTen/threetenbp | src/main/java/org/threeten/bp/format/DateTimeFormatterBuilder.java | DateTimeFormatterBuilder.appendText | public DateTimeFormatterBuilder appendText(TemporalField field, Map<Long, String> textLookup) {
"""
Appends the text of a date-time field to the formatter using the specified
map to supply the text.
<p>
The standard text outputting methods use the localized text in the JDK.
This method allows that text to be specified directly.
The supplied map is not validated by the builder to ensure that printing or
parsing is possible, thus an invalid map may throw an error during later use.
<p>
Supplying the map of text provides considerable flexibility in printing and parsing.
For example, a legacy application might require or supply the months of the
year as "JNY", "FBY", "MCH" etc. These do not match the standard set of text
for localized month names. Using this method, a map can be created which
defines the connection between each value and the text:
<pre>
Map<Long, String> map = new HashMap<>();
map.put(1, "JNY");
map.put(2, "FBY");
map.put(3, "MCH");
...
builder.appendText(MONTH_OF_YEAR, map);
</pre>
<p>
Other uses might be to output the value with a suffix, such as "1st", "2nd", "3rd",
or as Roman numerals "I", "II", "III", "IV".
<p>
During printing, the value is obtained and checked that it is in the valid range.
If text is not available for the value then it is output as a number.
During parsing, the parser will match against the map of text and numeric values.
@param field the field to append, not null
@param textLookup the map from the value to the text
@return this, for chaining, not null
"""
Jdk8Methods.requireNonNull(field, "field");
Jdk8Methods.requireNonNull(textLookup, "textLookup");
Map<Long, String> copy = new LinkedHashMap<Long, String>(textLookup);
Map<TextStyle, Map<Long, String>> map = Collections.singletonMap(TextStyle.FULL, copy);
final LocaleStore store = new LocaleStore(map);
DateTimeTextProvider provider = new DateTimeTextProvider() {
@Override
public String getText(TemporalField field, long value, TextStyle style, Locale locale) {
return store.getText(value, style);
}
@Override
public Iterator<Entry<String, Long>> getTextIterator(TemporalField field, TextStyle style, Locale locale) {
return store.getTextIterator(style);
}
};
appendInternal(new TextPrinterParser(field, TextStyle.FULL, provider));
return this;
} | java | public DateTimeFormatterBuilder appendText(TemporalField field, Map<Long, String> textLookup) {
Jdk8Methods.requireNonNull(field, "field");
Jdk8Methods.requireNonNull(textLookup, "textLookup");
Map<Long, String> copy = new LinkedHashMap<Long, String>(textLookup);
Map<TextStyle, Map<Long, String>> map = Collections.singletonMap(TextStyle.FULL, copy);
final LocaleStore store = new LocaleStore(map);
DateTimeTextProvider provider = new DateTimeTextProvider() {
@Override
public String getText(TemporalField field, long value, TextStyle style, Locale locale) {
return store.getText(value, style);
}
@Override
public Iterator<Entry<String, Long>> getTextIterator(TemporalField field, TextStyle style, Locale locale) {
return store.getTextIterator(style);
}
};
appendInternal(new TextPrinterParser(field, TextStyle.FULL, provider));
return this;
} | [
"public",
"DateTimeFormatterBuilder",
"appendText",
"(",
"TemporalField",
"field",
",",
"Map",
"<",
"Long",
",",
"String",
">",
"textLookup",
")",
"{",
"Jdk8Methods",
".",
"requireNonNull",
"(",
"field",
",",
"\"field\"",
")",
";",
"Jdk8Methods",
".",
"requireNonNull",
"(",
"textLookup",
",",
"\"textLookup\"",
")",
";",
"Map",
"<",
"Long",
",",
"String",
">",
"copy",
"=",
"new",
"LinkedHashMap",
"<",
"Long",
",",
"String",
">",
"(",
"textLookup",
")",
";",
"Map",
"<",
"TextStyle",
",",
"Map",
"<",
"Long",
",",
"String",
">",
">",
"map",
"=",
"Collections",
".",
"singletonMap",
"(",
"TextStyle",
".",
"FULL",
",",
"copy",
")",
";",
"final",
"LocaleStore",
"store",
"=",
"new",
"LocaleStore",
"(",
"map",
")",
";",
"DateTimeTextProvider",
"provider",
"=",
"new",
"DateTimeTextProvider",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"getText",
"(",
"TemporalField",
"field",
",",
"long",
"value",
",",
"TextStyle",
"style",
",",
"Locale",
"locale",
")",
"{",
"return",
"store",
".",
"getText",
"(",
"value",
",",
"style",
")",
";",
"}",
"@",
"Override",
"public",
"Iterator",
"<",
"Entry",
"<",
"String",
",",
"Long",
">",
">",
"getTextIterator",
"(",
"TemporalField",
"field",
",",
"TextStyle",
"style",
",",
"Locale",
"locale",
")",
"{",
"return",
"store",
".",
"getTextIterator",
"(",
"style",
")",
";",
"}",
"}",
";",
"appendInternal",
"(",
"new",
"TextPrinterParser",
"(",
"field",
",",
"TextStyle",
".",
"FULL",
",",
"provider",
")",
")",
";",
"return",
"this",
";",
"}"
]
| Appends the text of a date-time field to the formatter using the specified
map to supply the text.
<p>
The standard text outputting methods use the localized text in the JDK.
This method allows that text to be specified directly.
The supplied map is not validated by the builder to ensure that printing or
parsing is possible, thus an invalid map may throw an error during later use.
<p>
Supplying the map of text provides considerable flexibility in printing and parsing.
For example, a legacy application might require or supply the months of the
year as "JNY", "FBY", "MCH" etc. These do not match the standard set of text
for localized month names. Using this method, a map can be created which
defines the connection between each value and the text:
<pre>
Map<Long, String> map = new HashMap<>();
map.put(1, "JNY");
map.put(2, "FBY");
map.put(3, "MCH");
...
builder.appendText(MONTH_OF_YEAR, map);
</pre>
<p>
Other uses might be to output the value with a suffix, such as "1st", "2nd", "3rd",
or as Roman numerals "I", "II", "III", "IV".
<p>
During printing, the value is obtained and checked that it is in the valid range.
If text is not available for the value then it is output as a number.
During parsing, the parser will match against the map of text and numeric values.
@param field the field to append, not null
@param textLookup the map from the value to the text
@return this, for chaining, not null | [
"Appends",
"the",
"text",
"of",
"a",
"date",
"-",
"time",
"field",
"to",
"the",
"formatter",
"using",
"the",
"specified",
"map",
"to",
"supply",
"the",
"text",
".",
"<p",
">",
"The",
"standard",
"text",
"outputting",
"methods",
"use",
"the",
"localized",
"text",
"in",
"the",
"JDK",
".",
"This",
"method",
"allows",
"that",
"text",
"to",
"be",
"specified",
"directly",
".",
"The",
"supplied",
"map",
"is",
"not",
"validated",
"by",
"the",
"builder",
"to",
"ensure",
"that",
"printing",
"or",
"parsing",
"is",
"possible",
"thus",
"an",
"invalid",
"map",
"may",
"throw",
"an",
"error",
"during",
"later",
"use",
".",
"<p",
">",
"Supplying",
"the",
"map",
"of",
"text",
"provides",
"considerable",
"flexibility",
"in",
"printing",
"and",
"parsing",
".",
"For",
"example",
"a",
"legacy",
"application",
"might",
"require",
"or",
"supply",
"the",
"months",
"of",
"the",
"year",
"as",
"JNY",
"FBY",
"MCH",
"etc",
".",
"These",
"do",
"not",
"match",
"the",
"standard",
"set",
"of",
"text",
"for",
"localized",
"month",
"names",
".",
"Using",
"this",
"method",
"a",
"map",
"can",
"be",
"created",
"which",
"defines",
"the",
"connection",
"between",
"each",
"value",
"and",
"the",
"text",
":",
"<pre",
">",
"Map<",
";",
"Long",
"String>",
";",
"map",
"=",
"new",
"HashMap<",
";",
">",
";",
"()",
";",
"map",
".",
"put",
"(",
"1",
"JNY",
")",
";",
"map",
".",
"put",
"(",
"2",
"FBY",
")",
";",
"map",
".",
"put",
"(",
"3",
"MCH",
")",
";",
"...",
"builder",
".",
"appendText",
"(",
"MONTH_OF_YEAR",
"map",
")",
";",
"<",
"/",
"pre",
">",
"<p",
">",
"Other",
"uses",
"might",
"be",
"to",
"output",
"the",
"value",
"with",
"a",
"suffix",
"such",
"as",
"1st",
"2nd",
"3rd",
"or",
"as",
"Roman",
"numerals",
"I",
"II",
"III",
"IV",
".",
"<p",
">",
"During",
"printing",
"the",
"value",
"is",
"obtained",
"and",
"checked",
"that",
"it",
"is",
"in",
"the",
"valid",
"range",
".",
"If",
"text",
"is",
"not",
"available",
"for",
"the",
"value",
"then",
"it",
"is",
"output",
"as",
"a",
"number",
".",
"During",
"parsing",
"the",
"parser",
"will",
"match",
"against",
"the",
"map",
"of",
"text",
"and",
"numeric",
"values",
"."
]
| train | https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/format/DateTimeFormatterBuilder.java#L721-L739 |
alkacon/opencms-core | src/org/opencms/db/CmsDriverManager.java | CmsDriverManager.readUser | public CmsUser readUser(CmsDbContext dbc, String username, String password) throws CmsException {
"""
Returns a user object if the password for the user is correct.<p>
If the user/pwd pair is not valid a <code>{@link CmsException}</code> is thrown.<p>
@param dbc the current database context
@param username the username of the user that is to be read
@param password the password of the user that is to be read
@return user read
@throws CmsException if operation was not successful
"""
// don't read user from cache here because password may have changed
CmsUser user = getUserDriver(dbc).readUser(dbc, username, password, null);
m_monitor.cacheUser(user);
return user;
} | java | public CmsUser readUser(CmsDbContext dbc, String username, String password) throws CmsException {
// don't read user from cache here because password may have changed
CmsUser user = getUserDriver(dbc).readUser(dbc, username, password, null);
m_monitor.cacheUser(user);
return user;
} | [
"public",
"CmsUser",
"readUser",
"(",
"CmsDbContext",
"dbc",
",",
"String",
"username",
",",
"String",
"password",
")",
"throws",
"CmsException",
"{",
"// don't read user from cache here because password may have changed",
"CmsUser",
"user",
"=",
"getUserDriver",
"(",
"dbc",
")",
".",
"readUser",
"(",
"dbc",
",",
"username",
",",
"password",
",",
"null",
")",
";",
"m_monitor",
".",
"cacheUser",
"(",
"user",
")",
";",
"return",
"user",
";",
"}"
]
| Returns a user object if the password for the user is correct.<p>
If the user/pwd pair is not valid a <code>{@link CmsException}</code> is thrown.<p>
@param dbc the current database context
@param username the username of the user that is to be read
@param password the password of the user that is to be read
@return user read
@throws CmsException if operation was not successful | [
"Returns",
"a",
"user",
"object",
"if",
"the",
"password",
"for",
"the",
"user",
"is",
"correct",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L8142-L8148 |
carewebframework/carewebframework-core | org.carewebframework.shell/src/main/java/org/carewebframework/shell/property/PropertyInfo.java | PropertyInfo.setPropertyValue | public void setPropertyValue(Object instance, Object value, boolean forceDirect) {
"""
Sets the property value for a specified object instance.
@param instance The object instance.
@param value The value to assign.
@param forceDirect If true, a forces a direct write to the instance even if it implements
IPropertyAccessor
"""
try {
if (!forceDirect && instance instanceof IPropertyAccessor) {
((IPropertyAccessor) instance).setPropertyValue(this, value);
return;
}
Method method = null;
try {
method = PropertyUtil.findSetter(setter, instance, value == null ? null : value.getClass());
} catch (Exception e) {
if (value != null) {
PropertySerializer<?> serializer = getPropertyType().getSerializer();
value = value instanceof String ? serializer.deserialize((String) value) : serializer.serialize(value);
method = PropertyUtil.findSetter(setter, instance, value.getClass());
} else {
throw e;
}
}
if (method != null) {
method.invoke(instance, value);
}
} catch (Exception e) {
throw MiscUtil.toUnchecked(e);
}
} | java | public void setPropertyValue(Object instance, Object value, boolean forceDirect) {
try {
if (!forceDirect && instance instanceof IPropertyAccessor) {
((IPropertyAccessor) instance).setPropertyValue(this, value);
return;
}
Method method = null;
try {
method = PropertyUtil.findSetter(setter, instance, value == null ? null : value.getClass());
} catch (Exception e) {
if (value != null) {
PropertySerializer<?> serializer = getPropertyType().getSerializer();
value = value instanceof String ? serializer.deserialize((String) value) : serializer.serialize(value);
method = PropertyUtil.findSetter(setter, instance, value.getClass());
} else {
throw e;
}
}
if (method != null) {
method.invoke(instance, value);
}
} catch (Exception e) {
throw MiscUtil.toUnchecked(e);
}
} | [
"public",
"void",
"setPropertyValue",
"(",
"Object",
"instance",
",",
"Object",
"value",
",",
"boolean",
"forceDirect",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"forceDirect",
"&&",
"instance",
"instanceof",
"IPropertyAccessor",
")",
"{",
"(",
"(",
"IPropertyAccessor",
")",
"instance",
")",
".",
"setPropertyValue",
"(",
"this",
",",
"value",
")",
";",
"return",
";",
"}",
"Method",
"method",
"=",
"null",
";",
"try",
"{",
"method",
"=",
"PropertyUtil",
".",
"findSetter",
"(",
"setter",
",",
"instance",
",",
"value",
"==",
"null",
"?",
"null",
":",
"value",
".",
"getClass",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"PropertySerializer",
"<",
"?",
">",
"serializer",
"=",
"getPropertyType",
"(",
")",
".",
"getSerializer",
"(",
")",
";",
"value",
"=",
"value",
"instanceof",
"String",
"?",
"serializer",
".",
"deserialize",
"(",
"(",
"String",
")",
"value",
")",
":",
"serializer",
".",
"serialize",
"(",
"value",
")",
";",
"method",
"=",
"PropertyUtil",
".",
"findSetter",
"(",
"setter",
",",
"instance",
",",
"value",
".",
"getClass",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"e",
";",
"}",
"}",
"if",
"(",
"method",
"!=",
"null",
")",
"{",
"method",
".",
"invoke",
"(",
"instance",
",",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"MiscUtil",
".",
"toUnchecked",
"(",
"e",
")",
";",
"}",
"}"
]
| Sets the property value for a specified object instance.
@param instance The object instance.
@param value The value to assign.
@param forceDirect If true, a forces a direct write to the instance even if it implements
IPropertyAccessor | [
"Sets",
"the",
"property",
"value",
"for",
"a",
"specified",
"object",
"instance",
"."
]
| train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.shell/src/main/java/org/carewebframework/shell/property/PropertyInfo.java#L223-L250 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen_supplemental_pack.java | xen_supplemental_pack.get_nitro_bulk_response | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception {
"""
<pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre>
"""
xen_supplemental_pack_responses result = (xen_supplemental_pack_responses) service.get_payload_formatter().string_to_resource(xen_supplemental_pack_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.xen_supplemental_pack_response_array);
}
xen_supplemental_pack[] result_xen_supplemental_pack = new xen_supplemental_pack[result.xen_supplemental_pack_response_array.length];
for(int i = 0; i < result.xen_supplemental_pack_response_array.length; i++)
{
result_xen_supplemental_pack[i] = result.xen_supplemental_pack_response_array[i].xen_supplemental_pack[0];
}
return result_xen_supplemental_pack;
} | java | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception
{
xen_supplemental_pack_responses result = (xen_supplemental_pack_responses) service.get_payload_formatter().string_to_resource(xen_supplemental_pack_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.xen_supplemental_pack_response_array);
}
xen_supplemental_pack[] result_xen_supplemental_pack = new xen_supplemental_pack[result.xen_supplemental_pack_response_array.length];
for(int i = 0; i < result.xen_supplemental_pack_response_array.length; i++)
{
result_xen_supplemental_pack[i] = result.xen_supplemental_pack_response_array[i].xen_supplemental_pack[0];
}
return result_xen_supplemental_pack;
} | [
"protected",
"base_resource",
"[",
"]",
"get_nitro_bulk_response",
"(",
"nitro_service",
"service",
",",
"String",
"response",
")",
"throws",
"Exception",
"{",
"xen_supplemental_pack_responses",
"result",
"=",
"(",
"xen_supplemental_pack_responses",
")",
"service",
".",
"get_payload_formatter",
"(",
")",
".",
"string_to_resource",
"(",
"xen_supplemental_pack_responses",
".",
"class",
",",
"response",
")",
";",
"if",
"(",
"result",
".",
"errorcode",
"!=",
"0",
")",
"{",
"if",
"(",
"result",
".",
"errorcode",
"==",
"SESSION_NOT_EXISTS",
")",
"service",
".",
"clear_session",
"(",
")",
";",
"throw",
"new",
"nitro_exception",
"(",
"result",
".",
"message",
",",
"result",
".",
"errorcode",
",",
"(",
"base_response",
"[",
"]",
")",
"result",
".",
"xen_supplemental_pack_response_array",
")",
";",
"}",
"xen_supplemental_pack",
"[",
"]",
"result_xen_supplemental_pack",
"=",
"new",
"xen_supplemental_pack",
"[",
"result",
".",
"xen_supplemental_pack_response_array",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"xen_supplemental_pack_response_array",
".",
"length",
";",
"i",
"++",
")",
"{",
"result_xen_supplemental_pack",
"[",
"i",
"]",
"=",
"result",
".",
"xen_supplemental_pack_response_array",
"[",
"i",
"]",
".",
"xen_supplemental_pack",
"[",
"0",
"]",
";",
"}",
"return",
"result_xen_supplemental_pack",
";",
"}"
]
| <pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre> | [
"<pre",
">",
"Converts",
"API",
"response",
"of",
"bulk",
"operation",
"into",
"object",
"and",
"returns",
"the",
"object",
"array",
"in",
"case",
"of",
"get",
"request",
".",
"<",
"/",
"pre",
">"
]
| train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen_supplemental_pack.java#L307-L324 |
uber/AutoDispose | autodispose/src/main/java/com/uber/autodispose/AutoDisposeEndConsumerHelper.java | AutoDisposeEndConsumerHelper.setOnce | public static boolean setOnce(AtomicReference<Disposable> upstream, Disposable next, Class<?> observer) {
"""
Atomically updates the target upstream AtomicReference from null to the non-null
next Disposable, otherwise disposes next and reports a ProtocolViolationException
if the AtomicReference doesn't contain the shared disposed indicator.
@param upstream the target AtomicReference to update
@param next the Disposable to set on it atomically
@param observer the class of the consumer to have a personalized
error message if the upstream already contains a non-cancelled Disposable.
@return true if successful, false if the content of the AtomicReference was non null
"""
AutoDisposeUtil.checkNotNull(next, "next is null");
if (!upstream.compareAndSet(null, next)) {
next.dispose();
if (upstream.get() != AutoDisposableHelper.DISPOSED) {
reportDoubleSubscription(observer);
}
return false;
}
return true;
} | java | public static boolean setOnce(AtomicReference<Disposable> upstream, Disposable next, Class<?> observer) {
AutoDisposeUtil.checkNotNull(next, "next is null");
if (!upstream.compareAndSet(null, next)) {
next.dispose();
if (upstream.get() != AutoDisposableHelper.DISPOSED) {
reportDoubleSubscription(observer);
}
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"setOnce",
"(",
"AtomicReference",
"<",
"Disposable",
">",
"upstream",
",",
"Disposable",
"next",
",",
"Class",
"<",
"?",
">",
"observer",
")",
"{",
"AutoDisposeUtil",
".",
"checkNotNull",
"(",
"next",
",",
"\"next is null\"",
")",
";",
"if",
"(",
"!",
"upstream",
".",
"compareAndSet",
"(",
"null",
",",
"next",
")",
")",
"{",
"next",
".",
"dispose",
"(",
")",
";",
"if",
"(",
"upstream",
".",
"get",
"(",
")",
"!=",
"AutoDisposableHelper",
".",
"DISPOSED",
")",
"{",
"reportDoubleSubscription",
"(",
"observer",
")",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Atomically updates the target upstream AtomicReference from null to the non-null
next Disposable, otherwise disposes next and reports a ProtocolViolationException
if the AtomicReference doesn't contain the shared disposed indicator.
@param upstream the target AtomicReference to update
@param next the Disposable to set on it atomically
@param observer the class of the consumer to have a personalized
error message if the upstream already contains a non-cancelled Disposable.
@return true if successful, false if the content of the AtomicReference was non null | [
"Atomically",
"updates",
"the",
"target",
"upstream",
"AtomicReference",
"from",
"null",
"to",
"the",
"non",
"-",
"null",
"next",
"Disposable",
"otherwise",
"disposes",
"next",
"and",
"reports",
"a",
"ProtocolViolationException",
"if",
"the",
"AtomicReference",
"doesn",
"t",
"contain",
"the",
"shared",
"disposed",
"indicator",
"."
]
| train | https://github.com/uber/AutoDispose/blob/1115b0274f7960354289bb3ae7ba75b0c5a47457/autodispose/src/main/java/com/uber/autodispose/AutoDisposeEndConsumerHelper.java#L50-L60 |
facebookarchive/hadoop-20 | src/contrib/benchmark/src/java/org/apache/hadoop/hdfs/LoadGenerator.java | LoadGenerator.genFile | private void genFile(Path file, long fileSize) throws IOException {
"""
Create a file with a length of <code>fileSize</code>.
The file is filled with 'a'.
"""
long startTime = System.currentTimeMillis();
FSDataOutputStream out = fs.create(file, true,
getConf().getInt("io.file.buffer.size", 4096),
(short)getConf().getInt("dfs.replication", 3),
fs.getDefaultBlockSize());
executionTime[CREATE] += (System.currentTimeMillis()-startTime);
totalNumOfOps[CREATE]++;
for (long i=0; i<fileSize; i++) {
out.writeByte('a');
}
startTime = System.currentTimeMillis();
out.close();
executionTime[WRITE_CLOSE] += (System.currentTimeMillis()-startTime);
totalNumOfOps[WRITE_CLOSE]++;
} | java | private void genFile(Path file, long fileSize) throws IOException {
long startTime = System.currentTimeMillis();
FSDataOutputStream out = fs.create(file, true,
getConf().getInt("io.file.buffer.size", 4096),
(short)getConf().getInt("dfs.replication", 3),
fs.getDefaultBlockSize());
executionTime[CREATE] += (System.currentTimeMillis()-startTime);
totalNumOfOps[CREATE]++;
for (long i=0; i<fileSize; i++) {
out.writeByte('a');
}
startTime = System.currentTimeMillis();
out.close();
executionTime[WRITE_CLOSE] += (System.currentTimeMillis()-startTime);
totalNumOfOps[WRITE_CLOSE]++;
} | [
"private",
"void",
"genFile",
"(",
"Path",
"file",
",",
"long",
"fileSize",
")",
"throws",
"IOException",
"{",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"FSDataOutputStream",
"out",
"=",
"fs",
".",
"create",
"(",
"file",
",",
"true",
",",
"getConf",
"(",
")",
".",
"getInt",
"(",
"\"io.file.buffer.size\"",
",",
"4096",
")",
",",
"(",
"short",
")",
"getConf",
"(",
")",
".",
"getInt",
"(",
"\"dfs.replication\"",
",",
"3",
")",
",",
"fs",
".",
"getDefaultBlockSize",
"(",
")",
")",
";",
"executionTime",
"[",
"CREATE",
"]",
"+=",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startTime",
")",
";",
"totalNumOfOps",
"[",
"CREATE",
"]",
"++",
";",
"for",
"(",
"long",
"i",
"=",
"0",
";",
"i",
"<",
"fileSize",
";",
"i",
"++",
")",
"{",
"out",
".",
"writeByte",
"(",
"'",
"'",
")",
";",
"}",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"executionTime",
"[",
"WRITE_CLOSE",
"]",
"+=",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startTime",
")",
";",
"totalNumOfOps",
"[",
"WRITE_CLOSE",
"]",
"++",
";",
"}"
]
| Create a file with a length of <code>fileSize</code>.
The file is filled with 'a'. | [
"Create",
"a",
"file",
"with",
"a",
"length",
"of",
"<code",
">",
"fileSize<",
"/",
"code",
">",
".",
"The",
"file",
"is",
"filled",
"with",
"a",
"."
]
| train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/benchmark/src/java/org/apache/hadoop/hdfs/LoadGenerator.java#L440-L456 |
zaproxy/zaproxy | src/org/zaproxy/zap/extension/api/ApiImplementor.java | ApiImplementor.validateParamExists | protected void validateParamExists(JSONObject parameters, String name) throws ApiException {
"""
Validates that a parameter with the given {@code name} exists (and it has a value) in the given {@code parameters}.
@param parameters the parameters
@param name the name of the parameter that must exist
@throws ApiException if the parameter with the given name does not exist or it has no value.
@since 2.6.0
"""
if (!parameters.has(name) || parameters.getString(name).length() == 0) {
throw new ApiException(ApiException.Type.MISSING_PARAMETER, name);
}
} | java | protected void validateParamExists(JSONObject parameters, String name) throws ApiException {
if (!parameters.has(name) || parameters.getString(name).length() == 0) {
throw new ApiException(ApiException.Type.MISSING_PARAMETER, name);
}
} | [
"protected",
"void",
"validateParamExists",
"(",
"JSONObject",
"parameters",
",",
"String",
"name",
")",
"throws",
"ApiException",
"{",
"if",
"(",
"!",
"parameters",
".",
"has",
"(",
"name",
")",
"||",
"parameters",
".",
"getString",
"(",
"name",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"ApiException",
".",
"Type",
".",
"MISSING_PARAMETER",
",",
"name",
")",
";",
"}",
"}"
]
| Validates that a parameter with the given {@code name} exists (and it has a value) in the given {@code parameters}.
@param parameters the parameters
@param name the name of the parameter that must exist
@throws ApiException if the parameter with the given name does not exist or it has no value.
@since 2.6.0 | [
"Validates",
"that",
"a",
"parameter",
"with",
"the",
"given",
"{",
"@code",
"name",
"}",
"exists",
"(",
"and",
"it",
"has",
"a",
"value",
")",
"in",
"the",
"given",
"{",
"@code",
"parameters",
"}",
"."
]
| train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/api/ApiImplementor.java#L460-L464 |
Whiley/WhileyCompiler | src/main/java/wyil/check/FlowTypeCheck.java | FlowTypeCheck.checkIntegerOperator | private SemanticType checkIntegerOperator(Expr.BinaryOperator expr, Environment environment) {
"""
Check the type for a given arithmetic operator. Such an operator has the type
int, and all children should also produce values of type int.
@param expr
@return
"""
checkOperand(Type.Int, expr.getFirstOperand(), environment);
checkOperand(Type.Int, expr.getSecondOperand(), environment);
return Type.Int;
} | java | private SemanticType checkIntegerOperator(Expr.BinaryOperator expr, Environment environment) {
checkOperand(Type.Int, expr.getFirstOperand(), environment);
checkOperand(Type.Int, expr.getSecondOperand(), environment);
return Type.Int;
} | [
"private",
"SemanticType",
"checkIntegerOperator",
"(",
"Expr",
".",
"BinaryOperator",
"expr",
",",
"Environment",
"environment",
")",
"{",
"checkOperand",
"(",
"Type",
".",
"Int",
",",
"expr",
".",
"getFirstOperand",
"(",
")",
",",
"environment",
")",
";",
"checkOperand",
"(",
"Type",
".",
"Int",
",",
"expr",
".",
"getSecondOperand",
"(",
")",
",",
"environment",
")",
";",
"return",
"Type",
".",
"Int",
";",
"}"
]
| Check the type for a given arithmetic operator. Such an operator has the type
int, and all children should also produce values of type int.
@param expr
@return | [
"Check",
"the",
"type",
"for",
"a",
"given",
"arithmetic",
"operator",
".",
"Such",
"an",
"operator",
"has",
"the",
"type",
"int",
"and",
"all",
"children",
"should",
"also",
"produce",
"values",
"of",
"type",
"int",
"."
]
| train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/check/FlowTypeCheck.java#L1604-L1608 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java | CollUtil.addAll | public static <T> Collection<T> addAll(Collection<T> collection, Iterable<T> iterable) {
"""
加入全部
@param <T> 集合元素类型
@param collection 被加入的集合 {@link Collection}
@param iterable 要加入的内容{@link Iterable}
@return 原集合
"""
return addAll(collection, iterable.iterator());
} | java | public static <T> Collection<T> addAll(Collection<T> collection, Iterable<T> iterable) {
return addAll(collection, iterable.iterator());
} | [
"public",
"static",
"<",
"T",
">",
"Collection",
"<",
"T",
">",
"addAll",
"(",
"Collection",
"<",
"T",
">",
"collection",
",",
"Iterable",
"<",
"T",
">",
"iterable",
")",
"{",
"return",
"addAll",
"(",
"collection",
",",
"iterable",
".",
"iterator",
"(",
")",
")",
";",
"}"
]
| 加入全部
@param <T> 集合元素类型
@param collection 被加入的集合 {@link Collection}
@param iterable 要加入的内容{@link Iterable}
@return 原集合 | [
"加入全部"
]
| train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java#L1771-L1773 |
couchbase/couchbase-jvm-core | src/main/java/com/couchbase/client/core/endpoint/kv/KeyValueHandler.java | KeyValueHandler.handleCounterRequest | private static BinaryMemcacheRequest handleCounterRequest(final ChannelHandlerContext ctx,
final CounterRequest msg) {
"""
Encodes a {@link CounterRequest} into its lower level representation.
Depending on if the {@link CounterRequest#delta} is positive or negative, either the incr or decr memcached
commands are utilized. The value is converted to its absolute variant to conform with the protocol.
@return a ready {@link BinaryMemcacheRequest}.
"""
ByteBuf extras = ctx.alloc().buffer();
extras.writeLong(Math.abs(msg.delta()));
extras.writeLong(msg.initial());
extras.writeInt(msg.expiry());
byte[] key = msg.keyBytes();
short keyLength = (short) key.length;
byte extrasLength = (byte) extras.readableBytes();
BinaryMemcacheRequest request = new DefaultBinaryMemcacheRequest(key, extras);
request.setOpcode(msg.delta() < 0 ? OP_COUNTER_DECR : OP_COUNTER_INCR);
request.setKeyLength(keyLength);
request.setTotalBodyLength(keyLength + extrasLength);
request.setExtrasLength(extrasLength);
return request;
} | java | private static BinaryMemcacheRequest handleCounterRequest(final ChannelHandlerContext ctx,
final CounterRequest msg) {
ByteBuf extras = ctx.alloc().buffer();
extras.writeLong(Math.abs(msg.delta()));
extras.writeLong(msg.initial());
extras.writeInt(msg.expiry());
byte[] key = msg.keyBytes();
short keyLength = (short) key.length;
byte extrasLength = (byte) extras.readableBytes();
BinaryMemcacheRequest request = new DefaultBinaryMemcacheRequest(key, extras);
request.setOpcode(msg.delta() < 0 ? OP_COUNTER_DECR : OP_COUNTER_INCR);
request.setKeyLength(keyLength);
request.setTotalBodyLength(keyLength + extrasLength);
request.setExtrasLength(extrasLength);
return request;
} | [
"private",
"static",
"BinaryMemcacheRequest",
"handleCounterRequest",
"(",
"final",
"ChannelHandlerContext",
"ctx",
",",
"final",
"CounterRequest",
"msg",
")",
"{",
"ByteBuf",
"extras",
"=",
"ctx",
".",
"alloc",
"(",
")",
".",
"buffer",
"(",
")",
";",
"extras",
".",
"writeLong",
"(",
"Math",
".",
"abs",
"(",
"msg",
".",
"delta",
"(",
")",
")",
")",
";",
"extras",
".",
"writeLong",
"(",
"msg",
".",
"initial",
"(",
")",
")",
";",
"extras",
".",
"writeInt",
"(",
"msg",
".",
"expiry",
"(",
")",
")",
";",
"byte",
"[",
"]",
"key",
"=",
"msg",
".",
"keyBytes",
"(",
")",
";",
"short",
"keyLength",
"=",
"(",
"short",
")",
"key",
".",
"length",
";",
"byte",
"extrasLength",
"=",
"(",
"byte",
")",
"extras",
".",
"readableBytes",
"(",
")",
";",
"BinaryMemcacheRequest",
"request",
"=",
"new",
"DefaultBinaryMemcacheRequest",
"(",
"key",
",",
"extras",
")",
";",
"request",
".",
"setOpcode",
"(",
"msg",
".",
"delta",
"(",
")",
"<",
"0",
"?",
"OP_COUNTER_DECR",
":",
"OP_COUNTER_INCR",
")",
";",
"request",
".",
"setKeyLength",
"(",
"keyLength",
")",
";",
"request",
".",
"setTotalBodyLength",
"(",
"keyLength",
"+",
"extrasLength",
")",
";",
"request",
".",
"setExtrasLength",
"(",
"extrasLength",
")",
";",
"return",
"request",
";",
"}"
]
| Encodes a {@link CounterRequest} into its lower level representation.
Depending on if the {@link CounterRequest#delta} is positive or negative, either the incr or decr memcached
commands are utilized. The value is converted to its absolute variant to conform with the protocol.
@return a ready {@link BinaryMemcacheRequest}. | [
"Encodes",
"a",
"{",
"@link",
"CounterRequest",
"}",
"into",
"its",
"lower",
"level",
"representation",
"."
]
| train | https://github.com/couchbase/couchbase-jvm-core/blob/97f0427112c2168fee1d6499904f5fa0e24c6797/src/main/java/com/couchbase/client/core/endpoint/kv/KeyValueHandler.java#L608-L624 |
blinkfox/zealot | src/main/java/com/blinkfox/zealot/core/ZealotKhala.java | ZealotKhala.orNotLikePattern | public ZealotKhala orNotLikePattern(String field, String pattern) {
"""
根据指定的模式字符串生成带" OR "前缀的" NOT LIKE "模糊查询的SQL片段.
<p>示例:传入 {"b.title", "Java%"} 两个参数,生成的SQL片段为:" OR b.title NOT LIKE 'Java%' "</p>
@param field 数据库字段
@param pattern 模式字符串
@return ZealotKhala实例
"""
return this.doLikePattern(ZealotConst.OR_PREFIX, field, pattern, true, false);
} | java | public ZealotKhala orNotLikePattern(String field, String pattern) {
return this.doLikePattern(ZealotConst.OR_PREFIX, field, pattern, true, false);
} | [
"public",
"ZealotKhala",
"orNotLikePattern",
"(",
"String",
"field",
",",
"String",
"pattern",
")",
"{",
"return",
"this",
".",
"doLikePattern",
"(",
"ZealotConst",
".",
"OR_PREFIX",
",",
"field",
",",
"pattern",
",",
"true",
",",
"false",
")",
";",
"}"
]
| 根据指定的模式字符串生成带" OR "前缀的" NOT LIKE "模糊查询的SQL片段.
<p>示例:传入 {"b.title", "Java%"} 两个参数,生成的SQL片段为:" OR b.title NOT LIKE 'Java%' "</p>
@param field 数据库字段
@param pattern 模式字符串
@return ZealotKhala实例 | [
"根据指定的模式字符串生成带",
"OR",
"前缀的",
"NOT",
"LIKE",
"模糊查询的SQL片段",
".",
"<p",
">",
"示例:传入",
"{",
"b",
".",
"title",
"Java%",
"}",
"两个参数,生成的SQL片段为:",
"OR",
"b",
".",
"title",
"NOT",
"LIKE",
"Java%",
"<",
"/",
"p",
">"
]
| train | https://github.com/blinkfox/zealot/blob/21b00fa3e4ed42188eef3116d494e112e7a4194c/src/main/java/com/blinkfox/zealot/core/ZealotKhala.java#L1170-L1172 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.license_sqlserver_serviceName_upgrade_GET | public ArrayList<String> license_sqlserver_serviceName_upgrade_GET(String serviceName, OvhSqlServerVersionEnum version) throws IOException {
"""
Get allowed durations for 'upgrade' option
REST: GET /order/license/sqlserver/{serviceName}/upgrade
@param version [required] This license version
@param serviceName [required] The name of your SQL Server license
"""
String qPath = "/order/license/sqlserver/{serviceName}/upgrade";
StringBuilder sb = path(qPath, serviceName);
query(sb, "version", version);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t1);
} | java | public ArrayList<String> license_sqlserver_serviceName_upgrade_GET(String serviceName, OvhSqlServerVersionEnum version) throws IOException {
String qPath = "/order/license/sqlserver/{serviceName}/upgrade";
StringBuilder sb = path(qPath, serviceName);
query(sb, "version", version);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t1);
} | [
"public",
"ArrayList",
"<",
"String",
">",
"license_sqlserver_serviceName_upgrade_GET",
"(",
"String",
"serviceName",
",",
"OvhSqlServerVersionEnum",
"version",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/license/sqlserver/{serviceName}/upgrade\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"query",
"(",
"sb",
",",
"\"version\"",
",",
"version",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t1",
")",
";",
"}"
]
| Get allowed durations for 'upgrade' option
REST: GET /order/license/sqlserver/{serviceName}/upgrade
@param version [required] This license version
@param serviceName [required] The name of your SQL Server license | [
"Get",
"allowed",
"durations",
"for",
"upgrade",
"option"
]
| train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L1395-L1401 |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/wizards/elements/AbstractSuperTypeSelectionDialog.java | AbstractSuperTypeSelectionDialog.createSearchScope | public static IJavaSearchScope createSearchScope(IJavaProject project, Class<?> type, boolean onlySubTypes) {
"""
Creates a searching scope including only one project.
@param project the scope of the search.
@param type the expected super type.
@param onlySubTypes indicates if only the subtypes of the given types are allowed. If
<code>false</code>, the super type is allowed too.
@return the search scope.
"""
try {
final IType superType = project.findType(type.getName());
return SearchEngine.createStrictHierarchyScope(
project,
superType,
// only sub types
onlySubTypes,
// include the type
true,
null);
} catch (JavaModelException e) {
SARLEclipsePlugin.getDefault().log(e);
}
return SearchEngine.createJavaSearchScope(new IJavaElement[] {project});
} | java | public static IJavaSearchScope createSearchScope(IJavaProject project, Class<?> type, boolean onlySubTypes) {
try {
final IType superType = project.findType(type.getName());
return SearchEngine.createStrictHierarchyScope(
project,
superType,
// only sub types
onlySubTypes,
// include the type
true,
null);
} catch (JavaModelException e) {
SARLEclipsePlugin.getDefault().log(e);
}
return SearchEngine.createJavaSearchScope(new IJavaElement[] {project});
} | [
"public",
"static",
"IJavaSearchScope",
"createSearchScope",
"(",
"IJavaProject",
"project",
",",
"Class",
"<",
"?",
">",
"type",
",",
"boolean",
"onlySubTypes",
")",
"{",
"try",
"{",
"final",
"IType",
"superType",
"=",
"project",
".",
"findType",
"(",
"type",
".",
"getName",
"(",
")",
")",
";",
"return",
"SearchEngine",
".",
"createStrictHierarchyScope",
"(",
"project",
",",
"superType",
",",
"// only sub types",
"onlySubTypes",
",",
"// include the type",
"true",
",",
"null",
")",
";",
"}",
"catch",
"(",
"JavaModelException",
"e",
")",
"{",
"SARLEclipsePlugin",
".",
"getDefault",
"(",
")",
".",
"log",
"(",
"e",
")",
";",
"}",
"return",
"SearchEngine",
".",
"createJavaSearchScope",
"(",
"new",
"IJavaElement",
"[",
"]",
"{",
"project",
"}",
")",
";",
"}"
]
| Creates a searching scope including only one project.
@param project the scope of the search.
@param type the expected super type.
@param onlySubTypes indicates if only the subtypes of the given types are allowed. If
<code>false</code>, the super type is allowed too.
@return the search scope. | [
"Creates",
"a",
"searching",
"scope",
"including",
"only",
"one",
"project",
"."
]
| train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/wizards/elements/AbstractSuperTypeSelectionDialog.java#L99-L114 |
mozilla/rhino | src/org/mozilla/classfile/ConstantPool.java | ConstantPool.getUtfEncodingLimit | int getUtfEncodingLimit(String s, int start, int end) {
"""
Get maximum i such that <tt>start <= i <= end</tt> and
<tt>s.substring(start, i)</tt> fits JVM UTF string encoding limit.
"""
if ((end - start) * 3 <= MAX_UTF_ENCODING_SIZE) {
return end;
}
int limit = MAX_UTF_ENCODING_SIZE;
for (int i = start; i != end; i++) {
int c = s.charAt(i);
if (0 != c && c <= 0x7F) {
--limit;
} else if (c < 0x7FF) {
limit -= 2;
} else {
limit -= 3;
}
if (limit < 0) {
return i;
}
}
return end;
} | java | int getUtfEncodingLimit(String s, int start, int end)
{
if ((end - start) * 3 <= MAX_UTF_ENCODING_SIZE) {
return end;
}
int limit = MAX_UTF_ENCODING_SIZE;
for (int i = start; i != end; i++) {
int c = s.charAt(i);
if (0 != c && c <= 0x7F) {
--limit;
} else if (c < 0x7FF) {
limit -= 2;
} else {
limit -= 3;
}
if (limit < 0) {
return i;
}
}
return end;
} | [
"int",
"getUtfEncodingLimit",
"(",
"String",
"s",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"(",
"end",
"-",
"start",
")",
"*",
"3",
"<=",
"MAX_UTF_ENCODING_SIZE",
")",
"{",
"return",
"end",
";",
"}",
"int",
"limit",
"=",
"MAX_UTF_ENCODING_SIZE",
";",
"for",
"(",
"int",
"i",
"=",
"start",
";",
"i",
"!=",
"end",
";",
"i",
"++",
")",
"{",
"int",
"c",
"=",
"s",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"0",
"!=",
"c",
"&&",
"c",
"<=",
"0x7F",
")",
"{",
"--",
"limit",
";",
"}",
"else",
"if",
"(",
"c",
"<",
"0x7FF",
")",
"{",
"limit",
"-=",
"2",
";",
"}",
"else",
"{",
"limit",
"-=",
"3",
";",
"}",
"if",
"(",
"limit",
"<",
"0",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"end",
";",
"}"
]
| Get maximum i such that <tt>start <= i <= end</tt> and
<tt>s.substring(start, i)</tt> fits JVM UTF string encoding limit. | [
"Get",
"maximum",
"i",
"such",
"that",
"<tt",
">",
"start",
"<",
"=",
"i",
"<",
"=",
"end<",
"/",
"tt",
">",
"and",
"<tt",
">",
"s",
".",
"substring",
"(",
"start",
"i",
")",
"<",
"/",
"tt",
">",
"fits",
"JVM",
"UTF",
"string",
"encoding",
"limit",
"."
]
| train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/classfile/ConstantPool.java#L150-L170 |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.buildComparison | private Comparison buildComparison(GDLParser.ComparisonExpressionContext ctx) {
"""
Builds a Comparison filter operator from comparison context
@param ctx the comparison context that will be parsed
@return parsed operator
"""
ComparableExpression lhs = extractComparableExpression(ctx.comparisonElement(0));
ComparableExpression rhs = extractComparableExpression(ctx.comparisonElement(1));
Comparator comp = Comparator.fromString(ctx .ComparisonOP().getText());
return new Comparison(lhs, comp, rhs);
} | java | private Comparison buildComparison(GDLParser.ComparisonExpressionContext ctx) {
ComparableExpression lhs = extractComparableExpression(ctx.comparisonElement(0));
ComparableExpression rhs = extractComparableExpression(ctx.comparisonElement(1));
Comparator comp = Comparator.fromString(ctx .ComparisonOP().getText());
return new Comparison(lhs, comp, rhs);
} | [
"private",
"Comparison",
"buildComparison",
"(",
"GDLParser",
".",
"ComparisonExpressionContext",
"ctx",
")",
"{",
"ComparableExpression",
"lhs",
"=",
"extractComparableExpression",
"(",
"ctx",
".",
"comparisonElement",
"(",
"0",
")",
")",
";",
"ComparableExpression",
"rhs",
"=",
"extractComparableExpression",
"(",
"ctx",
".",
"comparisonElement",
"(",
"1",
")",
")",
";",
"Comparator",
"comp",
"=",
"Comparator",
".",
"fromString",
"(",
"ctx",
".",
"ComparisonOP",
"(",
")",
".",
"getText",
"(",
")",
")",
";",
"return",
"new",
"Comparison",
"(",
"lhs",
",",
"comp",
",",
"rhs",
")",
";",
"}"
]
| Builds a Comparison filter operator from comparison context
@param ctx the comparison context that will be parsed
@return parsed operator | [
"Builds",
"a",
"Comparison",
"filter",
"operator",
"from",
"comparison",
"context"
]
| train | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L706-L712 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/ImagesInner.java | ImagesInner.beginCreateOrUpdateAsync | public Observable<ImageInner> beginCreateOrUpdateAsync(String resourceGroupName, String imageName, ImageInner parameters) {
"""
Create or update an image.
@param resourceGroupName The name of the resource group.
@param imageName The name of the image.
@param parameters Parameters supplied to the Create Image operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ImageInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, imageName, parameters).map(new Func1<ServiceResponse<ImageInner>, ImageInner>() {
@Override
public ImageInner call(ServiceResponse<ImageInner> response) {
return response.body();
}
});
} | java | public Observable<ImageInner> beginCreateOrUpdateAsync(String resourceGroupName, String imageName, ImageInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, imageName, parameters).map(new Func1<ServiceResponse<ImageInner>, ImageInner>() {
@Override
public ImageInner call(ServiceResponse<ImageInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ImageInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"imageName",
",",
"ImageInner",
"parameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"imageName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ImageInner",
">",
",",
"ImageInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ImageInner",
"call",
"(",
"ServiceResponse",
"<",
"ImageInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Create or update an image.
@param resourceGroupName The name of the resource group.
@param imageName The name of the image.
@param parameters Parameters supplied to the Create Image operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ImageInner object | [
"Create",
"or",
"update",
"an",
"image",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/ImagesInner.java#L220-L227 |
alkacon/opencms-core | src-modules/org/opencms/workplace/commons/CmsPropertyAdvanced.java | CmsPropertyAdvanced.actionDefine | public void actionDefine() throws JspException {
"""
Performs the define property action, will be called by the JSP page.<p>
@throws JspException if problems including sub-elements occur
"""
// save initialized instance of this class in request attribute for included sub-elements
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
try {
performDefineOperation();
// set the request parameters before returning to the overview
setParamAction(DIALOG_SHOW_DEFAULT);
setParamNewproperty(null);
sendForward(CmsWorkplace.VFS_PATH_COMMONS + "property_advanced.jsp", paramsAsParameterMap());
} catch (Throwable e) {
// error defining property, show error dialog
includeErrorpage(this, e);
}
} | java | public void actionDefine() throws JspException {
// save initialized instance of this class in request attribute for included sub-elements
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
try {
performDefineOperation();
// set the request parameters before returning to the overview
setParamAction(DIALOG_SHOW_DEFAULT);
setParamNewproperty(null);
sendForward(CmsWorkplace.VFS_PATH_COMMONS + "property_advanced.jsp", paramsAsParameterMap());
} catch (Throwable e) {
// error defining property, show error dialog
includeErrorpage(this, e);
}
} | [
"public",
"void",
"actionDefine",
"(",
")",
"throws",
"JspException",
"{",
"// save initialized instance of this class in request attribute for included sub-elements",
"getJsp",
"(",
")",
".",
"getRequest",
"(",
")",
".",
"setAttribute",
"(",
"SESSION_WORKPLACE_CLASS",
",",
"this",
")",
";",
"try",
"{",
"performDefineOperation",
"(",
")",
";",
"// set the request parameters before returning to the overview",
"setParamAction",
"(",
"DIALOG_SHOW_DEFAULT",
")",
";",
"setParamNewproperty",
"(",
"null",
")",
";",
"sendForward",
"(",
"CmsWorkplace",
".",
"VFS_PATH_COMMONS",
"+",
"\"property_advanced.jsp\"",
",",
"paramsAsParameterMap",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"// error defining property, show error dialog",
"includeErrorpage",
"(",
"this",
",",
"e",
")",
";",
"}",
"}"
]
| Performs the define property action, will be called by the JSP page.<p>
@throws JspException if problems including sub-elements occur | [
"Performs",
"the",
"define",
"property",
"action",
"will",
"be",
"called",
"by",
"the",
"JSP",
"page",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/commons/CmsPropertyAdvanced.java#L331-L345 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/bcc/BccClient.java | BccClient.rollbackVolume | public void rollbackVolume(String volumeId, String snapshotId) {
"""
Rollback the volume with the specified volume snapshot.
<p>
You can rollback the specified volume only when the volume is Available,
otherwise,it's will get <code>409</code> errorCode.
<p>
The snapshot used to rollback must be created by the volume,
otherwise,it's will get <code>404</code> errorCode.
<p>
If rolling back the system volume,the instance must be Running or Stopped,
otherwise,it's will get <code>409</code> errorCode.After rolling back the
volume,all the system disk data will erase.
@param volumeId The id of volume which will be rollback.
@param snapshotId The id of snapshot which will be used to rollback the volume.
"""
this.rollbackVolume(new RollbackVolumeRequest()
.withVolumeId(volumeId).withSnapshotId(snapshotId));
} | java | public void rollbackVolume(String volumeId, String snapshotId) {
this.rollbackVolume(new RollbackVolumeRequest()
.withVolumeId(volumeId).withSnapshotId(snapshotId));
} | [
"public",
"void",
"rollbackVolume",
"(",
"String",
"volumeId",
",",
"String",
"snapshotId",
")",
"{",
"this",
".",
"rollbackVolume",
"(",
"new",
"RollbackVolumeRequest",
"(",
")",
".",
"withVolumeId",
"(",
"volumeId",
")",
".",
"withSnapshotId",
"(",
"snapshotId",
")",
")",
";",
"}"
]
| Rollback the volume with the specified volume snapshot.
<p>
You can rollback the specified volume only when the volume is Available,
otherwise,it's will get <code>409</code> errorCode.
<p>
The snapshot used to rollback must be created by the volume,
otherwise,it's will get <code>404</code> errorCode.
<p>
If rolling back the system volume,the instance must be Running or Stopped,
otherwise,it's will get <code>409</code> errorCode.After rolling back the
volume,all the system disk data will erase.
@param volumeId The id of volume which will be rollback.
@param snapshotId The id of snapshot which will be used to rollback the volume. | [
"Rollback",
"the",
"volume",
"with",
"the",
"specified",
"volume",
"snapshot",
"."
]
| train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/bcc/BccClient.java#L1116-L1119 |
datumbox/datumbox-framework | datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/sampling/StratifiedSampling.java | StratifiedSampling.xbarVariance | public static double xbarVariance(TransposeDataCollection sampleDataCollection, AssociativeArray nh, AssociativeArray populationNh) {
"""
Calculates Variance for Xbar
@param sampleDataCollection
@param nh
@param populationNh
@return
"""
double populationN = Descriptives.sum(populationNh.toFlatDataCollection());
if(populationN<=0) {
throw new IllegalArgumentException("The populationN parameter must be positive.");
}
double variance = 0.0;
for(Map.Entry<Object, FlatDataCollection> entry : sampleDataCollection.entrySet()) {
Object strata = entry.getKey();
Integer strataPopulation = ((Number)populationNh.get(strata)).intValue();
Integer strataSample = ((Number)nh.get(strata)).intValue();
if(strataPopulation==null || strataSample==null) {
throw new IllegalArgumentException("Invalid strata population or sample size.");
}
double Wh = strataPopulation/populationN;
//this is the formula when we do SimpleRandomSampling in each strata. nevertheless in order to keep our code DRY, instead of writing directly the formula of SimpleRandomSampling here, we will call SimpleRandomSampling xbarVariance function to estimate it.
//$fh=$nh[$strata]/$populationNh[$strata];
//$variance+=$Wh*$Wh*SimpleRandomSampling::variance($flatDataCollection)*(1-$fh)/$nh[$strata];
variance+= Wh*Wh* SimpleRandomSampling.xbarVariance(SimpleRandomSampling.variance(entry.getValue()), strataSample, strataPopulation);
}
return variance;
} | java | public static double xbarVariance(TransposeDataCollection sampleDataCollection, AssociativeArray nh, AssociativeArray populationNh) {
double populationN = Descriptives.sum(populationNh.toFlatDataCollection());
if(populationN<=0) {
throw new IllegalArgumentException("The populationN parameter must be positive.");
}
double variance = 0.0;
for(Map.Entry<Object, FlatDataCollection> entry : sampleDataCollection.entrySet()) {
Object strata = entry.getKey();
Integer strataPopulation = ((Number)populationNh.get(strata)).intValue();
Integer strataSample = ((Number)nh.get(strata)).intValue();
if(strataPopulation==null || strataSample==null) {
throw new IllegalArgumentException("Invalid strata population or sample size.");
}
double Wh = strataPopulation/populationN;
//this is the formula when we do SimpleRandomSampling in each strata. nevertheless in order to keep our code DRY, instead of writing directly the formula of SimpleRandomSampling here, we will call SimpleRandomSampling xbarVariance function to estimate it.
//$fh=$nh[$strata]/$populationNh[$strata];
//$variance+=$Wh*$Wh*SimpleRandomSampling::variance($flatDataCollection)*(1-$fh)/$nh[$strata];
variance+= Wh*Wh* SimpleRandomSampling.xbarVariance(SimpleRandomSampling.variance(entry.getValue()), strataSample, strataPopulation);
}
return variance;
} | [
"public",
"static",
"double",
"xbarVariance",
"(",
"TransposeDataCollection",
"sampleDataCollection",
",",
"AssociativeArray",
"nh",
",",
"AssociativeArray",
"populationNh",
")",
"{",
"double",
"populationN",
"=",
"Descriptives",
".",
"sum",
"(",
"populationNh",
".",
"toFlatDataCollection",
"(",
")",
")",
";",
"if",
"(",
"populationN",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The populationN parameter must be positive.\"",
")",
";",
"}",
"double",
"variance",
"=",
"0.0",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"FlatDataCollection",
">",
"entry",
":",
"sampleDataCollection",
".",
"entrySet",
"(",
")",
")",
"{",
"Object",
"strata",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"Integer",
"strataPopulation",
"=",
"(",
"(",
"Number",
")",
"populationNh",
".",
"get",
"(",
"strata",
")",
")",
".",
"intValue",
"(",
")",
";",
"Integer",
"strataSample",
"=",
"(",
"(",
"Number",
")",
"nh",
".",
"get",
"(",
"strata",
")",
")",
".",
"intValue",
"(",
")",
";",
"if",
"(",
"strataPopulation",
"==",
"null",
"||",
"strataSample",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid strata population or sample size.\"",
")",
";",
"}",
"double",
"Wh",
"=",
"strataPopulation",
"/",
"populationN",
";",
"//this is the formula when we do SimpleRandomSampling in each strata. nevertheless in order to keep our code DRY, instead of writing directly the formula of SimpleRandomSampling here, we will call SimpleRandomSampling xbarVariance function to estimate it.",
"//$fh=$nh[$strata]/$populationNh[$strata];",
"//$variance+=$Wh*$Wh*SimpleRandomSampling::variance($flatDataCollection)*(1-$fh)/$nh[$strata]; ",
"variance",
"+=",
"Wh",
"*",
"Wh",
"*",
"SimpleRandomSampling",
".",
"xbarVariance",
"(",
"SimpleRandomSampling",
".",
"variance",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
",",
"strataSample",
",",
"strataPopulation",
")",
";",
"}",
"return",
"variance",
";",
"}"
]
| Calculates Variance for Xbar
@param sampleDataCollection
@param nh
@param populationNh
@return | [
"Calculates",
"Variance",
"for",
"Xbar"
]
| train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/sampling/StratifiedSampling.java#L166-L193 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapConnection.java | LdapConnection.modifyAttributes | public void modifyAttributes(String dn, int mod_op, Attributes attrs) throws NamingException, WIMException {
"""
Modify the attributes for the specified distinguished name.
@param dn The distinguished name to modify attributes on.
@param mod_op The operation to perform.
@param attrs The attributes to modify.
@throws NamingException If there was an issue writing the new attribute values.
@throws WIMException If there was an issue getting or releasing a context, or the context is on a
fail-over server and writing to fail-over servers is prohibited, or the distinguished
name does not exist.
"""
TimedDirContext ctx = iContextManager.getDirContext();
iContextManager.checkWritePermission(ctx);
try {
try {
ctx.modifyAttributes(new LdapName(dn), mod_op, attrs);
} catch (NamingException e) {
if (!ContextManager.isConnectionException(e)) {
throw e;
}
ctx = iContextManager.reCreateDirContext(ctx, e.toString());
ctx.modifyAttributes(new LdapName(dn), mod_op, attrs);
}
} catch (NameNotFoundException e) {
String msg = Tr.formatMessage(tc, WIMMessageKey.NAMING_EXCEPTION, WIMMessageHelper.generateMsgParms(e.toString(true)));
throw new EntityNotFoundException(WIMMessageKey.NAMING_EXCEPTION, msg, e);
} catch (NamingException e) {
throw e;
}
finally {
iContextManager.releaseDirContext(ctx);
}
} | java | public void modifyAttributes(String dn, int mod_op, Attributes attrs) throws NamingException, WIMException {
TimedDirContext ctx = iContextManager.getDirContext();
iContextManager.checkWritePermission(ctx);
try {
try {
ctx.modifyAttributes(new LdapName(dn), mod_op, attrs);
} catch (NamingException e) {
if (!ContextManager.isConnectionException(e)) {
throw e;
}
ctx = iContextManager.reCreateDirContext(ctx, e.toString());
ctx.modifyAttributes(new LdapName(dn), mod_op, attrs);
}
} catch (NameNotFoundException e) {
String msg = Tr.formatMessage(tc, WIMMessageKey.NAMING_EXCEPTION, WIMMessageHelper.generateMsgParms(e.toString(true)));
throw new EntityNotFoundException(WIMMessageKey.NAMING_EXCEPTION, msg, e);
} catch (NamingException e) {
throw e;
}
finally {
iContextManager.releaseDirContext(ctx);
}
} | [
"public",
"void",
"modifyAttributes",
"(",
"String",
"dn",
",",
"int",
"mod_op",
",",
"Attributes",
"attrs",
")",
"throws",
"NamingException",
",",
"WIMException",
"{",
"TimedDirContext",
"ctx",
"=",
"iContextManager",
".",
"getDirContext",
"(",
")",
";",
"iContextManager",
".",
"checkWritePermission",
"(",
"ctx",
")",
";",
"try",
"{",
"try",
"{",
"ctx",
".",
"modifyAttributes",
"(",
"new",
"LdapName",
"(",
"dn",
")",
",",
"mod_op",
",",
"attrs",
")",
";",
"}",
"catch",
"(",
"NamingException",
"e",
")",
"{",
"if",
"(",
"!",
"ContextManager",
".",
"isConnectionException",
"(",
"e",
")",
")",
"{",
"throw",
"e",
";",
"}",
"ctx",
"=",
"iContextManager",
".",
"reCreateDirContext",
"(",
"ctx",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"ctx",
".",
"modifyAttributes",
"(",
"new",
"LdapName",
"(",
"dn",
")",
",",
"mod_op",
",",
"attrs",
")",
";",
"}",
"}",
"catch",
"(",
"NameNotFoundException",
"e",
")",
"{",
"String",
"msg",
"=",
"Tr",
".",
"formatMessage",
"(",
"tc",
",",
"WIMMessageKey",
".",
"NAMING_EXCEPTION",
",",
"WIMMessageHelper",
".",
"generateMsgParms",
"(",
"e",
".",
"toString",
"(",
"true",
")",
")",
")",
";",
"throw",
"new",
"EntityNotFoundException",
"(",
"WIMMessageKey",
".",
"NAMING_EXCEPTION",
",",
"msg",
",",
"e",
")",
";",
"}",
"catch",
"(",
"NamingException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"finally",
"{",
"iContextManager",
".",
"releaseDirContext",
"(",
"ctx",
")",
";",
"}",
"}"
]
| Modify the attributes for the specified distinguished name.
@param dn The distinguished name to modify attributes on.
@param mod_op The operation to perform.
@param attrs The attributes to modify.
@throws NamingException If there was an issue writing the new attribute values.
@throws WIMException If there was an issue getting or releasing a context, or the context is on a
fail-over server and writing to fail-over servers is prohibited, or the distinguished
name does not exist. | [
"Modify",
"the",
"attributes",
"for",
"the",
"specified",
"distinguished",
"name",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapConnection.java#L2165-L2188 |
atteo/classindex | classindex/src/main/java/org/atteo/classindex/ClassIndex.java | ClassIndex.getAnnotatedNames | public static Iterable<String> getAnnotatedNames(Class<? extends Annotation> annotation) {
"""
Retrieves names of classes annotated by given annotation.
<p/>
<p>
The annotation must be annotated with {@link IndexAnnotated} for annotated classes
to be indexed at compile-time by {@link org.atteo.classindex.processor.ClassIndexProcessor}.
</p>
<p>
Please note there is no verification if the class really exists. It can be missing when incremental
compilation is used. Use {@link #getAnnotated(Class) } if you need the verification.
</p>
@param annotation annotation to search class for
@return names of annotated classes
"""
return getAnnotatedNames(annotation, Thread.currentThread().getContextClassLoader());
} | java | public static Iterable<String> getAnnotatedNames(Class<? extends Annotation> annotation) {
return getAnnotatedNames(annotation, Thread.currentThread().getContextClassLoader());
} | [
"public",
"static",
"Iterable",
"<",
"String",
">",
"getAnnotatedNames",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotation",
")",
"{",
"return",
"getAnnotatedNames",
"(",
"annotation",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
")",
";",
"}"
]
| Retrieves names of classes annotated by given annotation.
<p/>
<p>
The annotation must be annotated with {@link IndexAnnotated} for annotated classes
to be indexed at compile-time by {@link org.atteo.classindex.processor.ClassIndexProcessor}.
</p>
<p>
Please note there is no verification if the class really exists. It can be missing when incremental
compilation is used. Use {@link #getAnnotated(Class) } if you need the verification.
</p>
@param annotation annotation to search class for
@return names of annotated classes | [
"Retrieves",
"names",
"of",
"classes",
"annotated",
"by",
"given",
"annotation",
".",
"<p",
"/",
">",
"<p",
">",
"The",
"annotation",
"must",
"be",
"annotated",
"with",
"{"
]
| train | https://github.com/atteo/classindex/blob/ad76c6bd8b4e84c594d94e48f466a095ffe2306a/classindex/src/main/java/org/atteo/classindex/ClassIndex.java#L285-L287 |
dbracewell/mango | src/main/java/com/davidbracewell/logging/LogManager.java | LogManager.addFileHandler | public synchronized static void addFileHandler(String basename) throws IOException {
"""
Adds a file handler that writes to the location specified in <code>com.davidbracewell.logging.dir</code> or if not
set <code>USER_HOME/logs/</code>. The filenames are in the form of <code>basename%g</code> where %g is the rotated
file number. Max file size is 100MB and 50 files will be used.
"""
String dir = Config.get("com.davidbracewell.logging.dir").asString(SystemInfo.USER_HOME + "/logs/");
Resources.from(dir).mkdirs();
FileHandler fh = new FileHandler(dir + "/" + basename + "%g.log", 100000000, 50, false);
fh.setFormatter(new LogFormatter());
addHandler(fh);
} | java | public synchronized static void addFileHandler(String basename) throws IOException {
String dir = Config.get("com.davidbracewell.logging.dir").asString(SystemInfo.USER_HOME + "/logs/");
Resources.from(dir).mkdirs();
FileHandler fh = new FileHandler(dir + "/" + basename + "%g.log", 100000000, 50, false);
fh.setFormatter(new LogFormatter());
addHandler(fh);
} | [
"public",
"synchronized",
"static",
"void",
"addFileHandler",
"(",
"String",
"basename",
")",
"throws",
"IOException",
"{",
"String",
"dir",
"=",
"Config",
".",
"get",
"(",
"\"com.davidbracewell.logging.dir\"",
")",
".",
"asString",
"(",
"SystemInfo",
".",
"USER_HOME",
"+",
"\"/logs/\"",
")",
";",
"Resources",
".",
"from",
"(",
"dir",
")",
".",
"mkdirs",
"(",
")",
";",
"FileHandler",
"fh",
"=",
"new",
"FileHandler",
"(",
"dir",
"+",
"\"/\"",
"+",
"basename",
"+",
"\"%g.log\"",
",",
"100000000",
",",
"50",
",",
"false",
")",
";",
"fh",
".",
"setFormatter",
"(",
"new",
"LogFormatter",
"(",
")",
")",
";",
"addHandler",
"(",
"fh",
")",
";",
"}"
]
| Adds a file handler that writes to the location specified in <code>com.davidbracewell.logging.dir</code> or if not
set <code>USER_HOME/logs/</code>. The filenames are in the form of <code>basename%g</code> where %g is the rotated
file number. Max file size is 100MB and 50 files will be used. | [
"Adds",
"a",
"file",
"handler",
"that",
"writes",
"to",
"the",
"location",
"specified",
"in",
"<code",
">",
"com",
".",
"davidbracewell",
".",
"logging",
".",
"dir<",
"/",
"code",
">",
"or",
"if",
"not",
"set",
"<code",
">",
"USER_HOME",
"/",
"logs",
"/",
"<",
"/",
"code",
">",
".",
"The",
"filenames",
"are",
"in",
"the",
"form",
"of",
"<code",
">",
"basename%g<",
"/",
"code",
">",
"where",
"%g",
"is",
"the",
"rotated",
"file",
"number",
".",
"Max",
"file",
"size",
"is",
"100MB",
"and",
"50",
"files",
"will",
"be",
"used",
"."
]
| train | https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/logging/LogManager.java#L100-L106 |
apache/flink | flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/clustering/directed/TriangleListing.java | TriangleListing.runInternal | @Override
public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
throws Exception {
"""
/*
Implementation notes:
The requirement that "K extends CopyableValue<K>" can be removed when
Flink has a self-join and GenerateTriplets is implemented as such.
ProjectTriangles should eventually be replaced by ".projectFirst("*")"
when projections use code generation.
"""
// u, v, bitmask where u < v
DataSet<Tuple3<K, K, ByteValue>> filteredByID = input
.getEdges()
.map(new OrderByID<>())
.setParallelism(parallelism)
.name("Order by ID")
.groupBy(0, 1)
.reduceGroup(new ReduceBitmask<>())
.setParallelism(parallelism)
.name("Flatten by ID");
// u, v, (deg(u), deg(v))
DataSet<Edge<K, Tuple3<EV, Degrees, Degrees>>> pairDegrees = input
.run(new EdgeDegreesPair<K, VV, EV>()
.setParallelism(parallelism));
// u, v, bitmask where deg(u) < deg(v) or (deg(u) == deg(v) and u < v)
DataSet<Tuple3<K, K, ByteValue>> filteredByDegree = pairDegrees
.map(new OrderByDegree<>())
.setParallelism(parallelism)
.name("Order by degree")
.groupBy(0, 1)
.reduceGroup(new ReduceBitmask<>())
.setParallelism(parallelism)
.name("Flatten by degree");
// u, v, w, bitmask where (u, v) and (u, w) are edges in graph
DataSet<Tuple4<K, K, K, ByteValue>> triplets = filteredByDegree
.groupBy(0)
.sortGroup(1, Order.ASCENDING)
.reduceGroup(new GenerateTriplets<>())
.name("Generate triplets");
// u, v, w, bitmask where (u, v), (u, w), and (v, w) are edges in graph
DataSet<Result<K>> triangles = triplets
.join(filteredByID, JoinOperatorBase.JoinHint.REPARTITION_HASH_SECOND)
.where(1, 2)
.equalTo(0, 1)
.with(new ProjectTriangles<>())
.name("Triangle listing");
if (permuteResults) {
triangles = triangles
.flatMap(new PermuteResult<>())
.name("Permute triangle vertices");
} else if (sortTriangleVertices.get()) {
triangles = triangles
.map(new SortTriangleVertices<>())
.name("Sort triangle vertices");
}
return triangles;
} | java | @Override
public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
throws Exception {
// u, v, bitmask where u < v
DataSet<Tuple3<K, K, ByteValue>> filteredByID = input
.getEdges()
.map(new OrderByID<>())
.setParallelism(parallelism)
.name("Order by ID")
.groupBy(0, 1)
.reduceGroup(new ReduceBitmask<>())
.setParallelism(parallelism)
.name("Flatten by ID");
// u, v, (deg(u), deg(v))
DataSet<Edge<K, Tuple3<EV, Degrees, Degrees>>> pairDegrees = input
.run(new EdgeDegreesPair<K, VV, EV>()
.setParallelism(parallelism));
// u, v, bitmask where deg(u) < deg(v) or (deg(u) == deg(v) and u < v)
DataSet<Tuple3<K, K, ByteValue>> filteredByDegree = pairDegrees
.map(new OrderByDegree<>())
.setParallelism(parallelism)
.name("Order by degree")
.groupBy(0, 1)
.reduceGroup(new ReduceBitmask<>())
.setParallelism(parallelism)
.name("Flatten by degree");
// u, v, w, bitmask where (u, v) and (u, w) are edges in graph
DataSet<Tuple4<K, K, K, ByteValue>> triplets = filteredByDegree
.groupBy(0)
.sortGroup(1, Order.ASCENDING)
.reduceGroup(new GenerateTriplets<>())
.name("Generate triplets");
// u, v, w, bitmask where (u, v), (u, w), and (v, w) are edges in graph
DataSet<Result<K>> triangles = triplets
.join(filteredByID, JoinOperatorBase.JoinHint.REPARTITION_HASH_SECOND)
.where(1, 2)
.equalTo(0, 1)
.with(new ProjectTriangles<>())
.name("Triangle listing");
if (permuteResults) {
triangles = triangles
.flatMap(new PermuteResult<>())
.name("Permute triangle vertices");
} else if (sortTriangleVertices.get()) {
triangles = triangles
.map(new SortTriangleVertices<>())
.name("Sort triangle vertices");
}
return triangles;
} | [
"@",
"Override",
"public",
"DataSet",
"<",
"Result",
"<",
"K",
">",
">",
"runInternal",
"(",
"Graph",
"<",
"K",
",",
"VV",
",",
"EV",
">",
"input",
")",
"throws",
"Exception",
"{",
"// u, v, bitmask where u < v",
"DataSet",
"<",
"Tuple3",
"<",
"K",
",",
"K",
",",
"ByteValue",
">",
">",
"filteredByID",
"=",
"input",
".",
"getEdges",
"(",
")",
".",
"map",
"(",
"new",
"OrderByID",
"<>",
"(",
")",
")",
".",
"setParallelism",
"(",
"parallelism",
")",
".",
"name",
"(",
"\"Order by ID\"",
")",
".",
"groupBy",
"(",
"0",
",",
"1",
")",
".",
"reduceGroup",
"(",
"new",
"ReduceBitmask",
"<>",
"(",
")",
")",
".",
"setParallelism",
"(",
"parallelism",
")",
".",
"name",
"(",
"\"Flatten by ID\"",
")",
";",
"// u, v, (deg(u), deg(v))",
"DataSet",
"<",
"Edge",
"<",
"K",
",",
"Tuple3",
"<",
"EV",
",",
"Degrees",
",",
"Degrees",
">",
">",
">",
"pairDegrees",
"=",
"input",
".",
"run",
"(",
"new",
"EdgeDegreesPair",
"<",
"K",
",",
"VV",
",",
"EV",
">",
"(",
")",
".",
"setParallelism",
"(",
"parallelism",
")",
")",
";",
"// u, v, bitmask where deg(u) < deg(v) or (deg(u) == deg(v) and u < v)",
"DataSet",
"<",
"Tuple3",
"<",
"K",
",",
"K",
",",
"ByteValue",
">",
">",
"filteredByDegree",
"=",
"pairDegrees",
".",
"map",
"(",
"new",
"OrderByDegree",
"<>",
"(",
")",
")",
".",
"setParallelism",
"(",
"parallelism",
")",
".",
"name",
"(",
"\"Order by degree\"",
")",
".",
"groupBy",
"(",
"0",
",",
"1",
")",
".",
"reduceGroup",
"(",
"new",
"ReduceBitmask",
"<>",
"(",
")",
")",
".",
"setParallelism",
"(",
"parallelism",
")",
".",
"name",
"(",
"\"Flatten by degree\"",
")",
";",
"// u, v, w, bitmask where (u, v) and (u, w) are edges in graph",
"DataSet",
"<",
"Tuple4",
"<",
"K",
",",
"K",
",",
"K",
",",
"ByteValue",
">",
">",
"triplets",
"=",
"filteredByDegree",
".",
"groupBy",
"(",
"0",
")",
".",
"sortGroup",
"(",
"1",
",",
"Order",
".",
"ASCENDING",
")",
".",
"reduceGroup",
"(",
"new",
"GenerateTriplets",
"<>",
"(",
")",
")",
".",
"name",
"(",
"\"Generate triplets\"",
")",
";",
"// u, v, w, bitmask where (u, v), (u, w), and (v, w) are edges in graph",
"DataSet",
"<",
"Result",
"<",
"K",
">",
">",
"triangles",
"=",
"triplets",
".",
"join",
"(",
"filteredByID",
",",
"JoinOperatorBase",
".",
"JoinHint",
".",
"REPARTITION_HASH_SECOND",
")",
".",
"where",
"(",
"1",
",",
"2",
")",
".",
"equalTo",
"(",
"0",
",",
"1",
")",
".",
"with",
"(",
"new",
"ProjectTriangles",
"<>",
"(",
")",
")",
".",
"name",
"(",
"\"Triangle listing\"",
")",
";",
"if",
"(",
"permuteResults",
")",
"{",
"triangles",
"=",
"triangles",
".",
"flatMap",
"(",
"new",
"PermuteResult",
"<>",
"(",
")",
")",
".",
"name",
"(",
"\"Permute triangle vertices\"",
")",
";",
"}",
"else",
"if",
"(",
"sortTriangleVertices",
".",
"get",
"(",
")",
")",
"{",
"triangles",
"=",
"triangles",
".",
"map",
"(",
"new",
"SortTriangleVertices",
"<>",
"(",
")",
")",
".",
"name",
"(",
"\"Sort triangle vertices\"",
")",
";",
"}",
"return",
"triangles",
";",
"}"
]
| /*
Implementation notes:
The requirement that "K extends CopyableValue<K>" can be removed when
Flink has a self-join and GenerateTriplets is implemented as such.
ProjectTriangles should eventually be replaced by ".projectFirst("*")"
when projections use code generation. | [
"/",
"*",
"Implementation",
"notes",
":"
]
| train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/clustering/directed/TriangleListing.java#L81-L136 |
dickschoeller/gedbrowser | gedbrowser-datamodel/src/main/java/org/schoellerfamily/gedbrowser/datamodel/util/DateParser.java | DateParser.truncateAt | private String truncateAt(final String input, final String searchString) {
"""
Truncate the input string after the first occurrence of the
searchString.
@param input the source string
@param searchString the string to look for in the source
@return the truncated string
"""
final int i = input.indexOf(searchString);
if (i != -1) {
return input.substring(0, i);
}
return input;
} | java | private String truncateAt(final String input, final String searchString) {
final int i = input.indexOf(searchString);
if (i != -1) {
return input.substring(0, i);
}
return input;
} | [
"private",
"String",
"truncateAt",
"(",
"final",
"String",
"input",
",",
"final",
"String",
"searchString",
")",
"{",
"final",
"int",
"i",
"=",
"input",
".",
"indexOf",
"(",
"searchString",
")",
";",
"if",
"(",
"i",
"!=",
"-",
"1",
")",
"{",
"return",
"input",
".",
"substring",
"(",
"0",
",",
"i",
")",
";",
"}",
"return",
"input",
";",
"}"
]
| Truncate the input string after the first occurrence of the
searchString.
@param input the source string
@param searchString the string to look for in the source
@return the truncated string | [
"Truncate",
"the",
"input",
"string",
"after",
"the",
"first",
"occurrence",
"of",
"the",
"searchString",
"."
]
| train | https://github.com/dickschoeller/gedbrowser/blob/e3e10b1ff3a34ebde9b7edcbfafcd5fe6fb3b3e1/gedbrowser-datamodel/src/main/java/org/schoellerfamily/gedbrowser/datamodel/util/DateParser.java#L219-L225 |
graylog-labs/syslog4j-graylog2 | src/main/java/org/graylog2/syslog4j/util/Base64.java | Base64.encodeBytes | public static String encodeBytes(byte[] source, int off, int len) {
"""
Encodes a byte array into Base64 notation.
Does not GZip-compress data.
@param source The data to convert
@param off Offset in array where conversion should begin
@param len Length of data to convert
@since 1.4
"""
return encodeBytes(source, off, len, NO_OPTIONS);
} | java | public static String encodeBytes(byte[] source, int off, int len) {
return encodeBytes(source, off, len, NO_OPTIONS);
} | [
"public",
"static",
"String",
"encodeBytes",
"(",
"byte",
"[",
"]",
"source",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"return",
"encodeBytes",
"(",
"source",
",",
"off",
",",
"len",
",",
"NO_OPTIONS",
")",
";",
"}"
]
| Encodes a byte array into Base64 notation.
Does not GZip-compress data.
@param source The data to convert
@param off Offset in array where conversion should begin
@param len Length of data to convert
@since 1.4 | [
"Encodes",
"a",
"byte",
"array",
"into",
"Base64",
"notation",
".",
"Does",
"not",
"GZip",
"-",
"compress",
"data",
"."
]
| train | https://github.com/graylog-labs/syslog4j-graylog2/blob/374bc20d77c3aaa36a68bec5125dd82ce0a88aab/src/main/java/org/graylog2/syslog4j/util/Base64.java#L683-L685 |
ops4j/org.ops4j.pax.exam2 | core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/ReactorManager.java | ReactorManager.addConfigurationsToReactor | private void addConfigurationsToReactor(Class<?> testClass, Object testClassInstance)
throws IllegalAccessException, InvocationTargetException {
"""
Scans the current test class for declared or inherited {@code @Configuration} methods and
invokes them, adding the returned configuration to the reactor.
@param testClass
test class
@param testClassInstance
instance of test class
@throws IllegalAccessException
when configuration method is not public
@throws InvocationTargetException
when configuration method cannot be invoked
"""
numConfigurations = 0;
Method[] methods = testClass.getMethods();
for (Method m : methods) {
if (isConfiguration(m)) {
// consider as option, so prepare that one:
reactor.addConfiguration(((Option[]) m.invoke(testClassInstance)));
numConfigurations++;
}
}
failOnUnusedConfiguration(testClass.getDeclaredMethods());
} | java | private void addConfigurationsToReactor(Class<?> testClass, Object testClassInstance)
throws IllegalAccessException, InvocationTargetException {
numConfigurations = 0;
Method[] methods = testClass.getMethods();
for (Method m : methods) {
if (isConfiguration(m)) {
// consider as option, so prepare that one:
reactor.addConfiguration(((Option[]) m.invoke(testClassInstance)));
numConfigurations++;
}
}
failOnUnusedConfiguration(testClass.getDeclaredMethods());
} | [
"private",
"void",
"addConfigurationsToReactor",
"(",
"Class",
"<",
"?",
">",
"testClass",
",",
"Object",
"testClassInstance",
")",
"throws",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"numConfigurations",
"=",
"0",
";",
"Method",
"[",
"]",
"methods",
"=",
"testClass",
".",
"getMethods",
"(",
")",
";",
"for",
"(",
"Method",
"m",
":",
"methods",
")",
"{",
"if",
"(",
"isConfiguration",
"(",
"m",
")",
")",
"{",
"// consider as option, so prepare that one:",
"reactor",
".",
"addConfiguration",
"(",
"(",
"(",
"Option",
"[",
"]",
")",
"m",
".",
"invoke",
"(",
"testClassInstance",
")",
")",
")",
";",
"numConfigurations",
"++",
";",
"}",
"}",
"failOnUnusedConfiguration",
"(",
"testClass",
".",
"getDeclaredMethods",
"(",
")",
")",
";",
"}"
]
| Scans the current test class for declared or inherited {@code @Configuration} methods and
invokes them, adding the returned configuration to the reactor.
@param testClass
test class
@param testClassInstance
instance of test class
@throws IllegalAccessException
when configuration method is not public
@throws InvocationTargetException
when configuration method cannot be invoked | [
"Scans",
"the",
"current",
"test",
"class",
"for",
"declared",
"or",
"inherited",
"{",
"@code",
"@Configuration",
"}",
"methods",
"and",
"invokes",
"them",
"adding",
"the",
"returned",
"configuration",
"to",
"the",
"reactor",
"."
]
| train | https://github.com/ops4j/org.ops4j.pax.exam2/blob/7f83796cbbb857123d8fc7fe817a7637218d5d77/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/ReactorManager.java#L228-L240 |
wcm-io/wcm-io-handler | media/src/main/java/io/wcm/handler/media/format/impl/MediaFormatHandlerImpl.java | MediaFormatHandlerImpl.isRenditionMatchSizeSameBigger | private boolean isRenditionMatchSizeSameBigger(MediaFormat mediaFormat, MediaFormat mediaFormatRequested) {
"""
Checks if the given media format size is same size or bigger than the requested one.
@param mediaFormat Media format
@param mediaFormatRequested Requested media format
@return true if media format is same size or bigger
"""
long widthRequested = mediaFormatRequested.getEffectiveMinWidth();
long heightRequested = mediaFormatRequested.getEffectiveMinHeight();
long widthMax = mediaFormat.getEffectiveMaxWidth();
long heightMax = mediaFormat.getEffectiveMaxHeight();
return ((widthMax >= widthRequested) || (widthMax == 0))
&& ((heightMax >= heightRequested) || (heightMax == 0));
} | java | private boolean isRenditionMatchSizeSameBigger(MediaFormat mediaFormat, MediaFormat mediaFormatRequested) {
long widthRequested = mediaFormatRequested.getEffectiveMinWidth();
long heightRequested = mediaFormatRequested.getEffectiveMinHeight();
long widthMax = mediaFormat.getEffectiveMaxWidth();
long heightMax = mediaFormat.getEffectiveMaxHeight();
return ((widthMax >= widthRequested) || (widthMax == 0))
&& ((heightMax >= heightRequested) || (heightMax == 0));
} | [
"private",
"boolean",
"isRenditionMatchSizeSameBigger",
"(",
"MediaFormat",
"mediaFormat",
",",
"MediaFormat",
"mediaFormatRequested",
")",
"{",
"long",
"widthRequested",
"=",
"mediaFormatRequested",
".",
"getEffectiveMinWidth",
"(",
")",
";",
"long",
"heightRequested",
"=",
"mediaFormatRequested",
".",
"getEffectiveMinHeight",
"(",
")",
";",
"long",
"widthMax",
"=",
"mediaFormat",
".",
"getEffectiveMaxWidth",
"(",
")",
";",
"long",
"heightMax",
"=",
"mediaFormat",
".",
"getEffectiveMaxHeight",
"(",
")",
";",
"return",
"(",
"(",
"widthMax",
">=",
"widthRequested",
")",
"||",
"(",
"widthMax",
"==",
"0",
")",
")",
"&&",
"(",
"(",
"heightMax",
">=",
"heightRequested",
")",
"||",
"(",
"heightMax",
"==",
"0",
")",
")",
";",
"}"
]
| Checks if the given media format size is same size or bigger than the requested one.
@param mediaFormat Media format
@param mediaFormatRequested Requested media format
@return true if media format is same size or bigger | [
"Checks",
"if",
"the",
"given",
"media",
"format",
"size",
"is",
"same",
"size",
"or",
"bigger",
"than",
"the",
"requested",
"one",
"."
]
| train | https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/media/src/main/java/io/wcm/handler/media/format/impl/MediaFormatHandlerImpl.java#L211-L220 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/CharsetMatch.java | CharsetMatch.getString | public String getString(int maxLength) throws java.io.IOException {
"""
Create a Java String from Unicode character data corresponding
to the original byte data supplied to the Charset detect operation.
The length of the returned string is limited to the specified size;
the string will be trunctated to this length if necessary. A limit value of
zero or less is ignored, and treated as no limit.
@param maxLength The maximium length of the String to be created when the
source of the data is an input stream, or -1 for
unlimited length.
@return a String created from the converted input data.
"""
String result = null;
if (fInputStream != null) {
StringBuilder sb = new StringBuilder();
char[] buffer = new char[1024];
Reader reader = getReader();
int max = maxLength < 0? Integer.MAX_VALUE : maxLength;
int bytesRead = 0;
while ((bytesRead = reader.read(buffer, 0, Math.min(max, 1024))) >= 0) {
sb.append(buffer, 0, bytesRead);
max -= bytesRead;
}
reader.close();
return sb.toString();
} else {
String name = getName();
/*
* getName() may return a name with a suffix 'rtl' or 'ltr'. This cannot
* be used to open a charset (e.g. IBM424_rtl). The ending '_rtl' or 'ltr'
* should be stripped off before creating the string.
*/
int startSuffix = name.indexOf("_rtl") < 0 ? name.indexOf("_ltr") : name.indexOf("_rtl");
if (startSuffix > 0) {
name = name.substring(0, startSuffix);
}
result = new String(fRawInput, name);
}
return result;
} | java | public String getString(int maxLength) throws java.io.IOException {
String result = null;
if (fInputStream != null) {
StringBuilder sb = new StringBuilder();
char[] buffer = new char[1024];
Reader reader = getReader();
int max = maxLength < 0? Integer.MAX_VALUE : maxLength;
int bytesRead = 0;
while ((bytesRead = reader.read(buffer, 0, Math.min(max, 1024))) >= 0) {
sb.append(buffer, 0, bytesRead);
max -= bytesRead;
}
reader.close();
return sb.toString();
} else {
String name = getName();
/*
* getName() may return a name with a suffix 'rtl' or 'ltr'. This cannot
* be used to open a charset (e.g. IBM424_rtl). The ending '_rtl' or 'ltr'
* should be stripped off before creating the string.
*/
int startSuffix = name.indexOf("_rtl") < 0 ? name.indexOf("_ltr") : name.indexOf("_rtl");
if (startSuffix > 0) {
name = name.substring(0, startSuffix);
}
result = new String(fRawInput, name);
}
return result;
} | [
"public",
"String",
"getString",
"(",
"int",
"maxLength",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"fInputStream",
"!=",
"null",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"char",
"[",
"]",
"buffer",
"=",
"new",
"char",
"[",
"1024",
"]",
";",
"Reader",
"reader",
"=",
"getReader",
"(",
")",
";",
"int",
"max",
"=",
"maxLength",
"<",
"0",
"?",
"Integer",
".",
"MAX_VALUE",
":",
"maxLength",
";",
"int",
"bytesRead",
"=",
"0",
";",
"while",
"(",
"(",
"bytesRead",
"=",
"reader",
".",
"read",
"(",
"buffer",
",",
"0",
",",
"Math",
".",
"min",
"(",
"max",
",",
"1024",
")",
")",
")",
">=",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"buffer",
",",
"0",
",",
"bytesRead",
")",
";",
"max",
"-=",
"bytesRead",
";",
"}",
"reader",
".",
"close",
"(",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"String",
"name",
"=",
"getName",
"(",
")",
";",
"/*\n * getName() may return a name with a suffix 'rtl' or 'ltr'. This cannot\n * be used to open a charset (e.g. IBM424_rtl). The ending '_rtl' or 'ltr'\n * should be stripped off before creating the string.\n */",
"int",
"startSuffix",
"=",
"name",
".",
"indexOf",
"(",
"\"_rtl\"",
")",
"<",
"0",
"?",
"name",
".",
"indexOf",
"(",
"\"_ltr\"",
")",
":",
"name",
".",
"indexOf",
"(",
"\"_rtl\"",
")",
";",
"if",
"(",
"startSuffix",
">",
"0",
")",
"{",
"name",
"=",
"name",
".",
"substring",
"(",
"0",
",",
"startSuffix",
")",
";",
"}",
"result",
"=",
"new",
"String",
"(",
"fRawInput",
",",
"name",
")",
";",
"}",
"return",
"result",
";",
"}"
]
| Create a Java String from Unicode character data corresponding
to the original byte data supplied to the Charset detect operation.
The length of the returned string is limited to the specified size;
the string will be trunctated to this length if necessary. A limit value of
zero or less is ignored, and treated as no limit.
@param maxLength The maximium length of the String to be created when the
source of the data is an input stream, or -1 for
unlimited length.
@return a String created from the converted input data. | [
"Create",
"a",
"Java",
"String",
"from",
"Unicode",
"character",
"data",
"corresponding",
"to",
"the",
"original",
"byte",
"data",
"supplied",
"to",
"the",
"Charset",
"detect",
"operation",
".",
"The",
"length",
"of",
"the",
"returned",
"string",
"is",
"limited",
"to",
"the",
"specified",
"size",
";",
"the",
"string",
"will",
"be",
"trunctated",
"to",
"this",
"length",
"if",
"necessary",
".",
"A",
"limit",
"value",
"of",
"zero",
"or",
"less",
"is",
"ignored",
"and",
"treated",
"as",
"no",
"limit",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/CharsetMatch.java#L84-L116 |
xvik/dropwizard-guicey | src/main/java/ru/vyarus/dropwizard/guice/module/installer/InstallerModule.java | InstallerModule.findInstaller | @SuppressWarnings("unchecked")
private FeatureInstaller findInstaller(final Class<?> type, final ExtensionsHolder holder) {
"""
Search for matching installer. Extension may match multiple installer, but only one will be actually
used (note that installers are ordered)
@param type extension type
@param holder extensions holder bean
@return matching installer or null if no matching installer found
"""
for (FeatureInstaller installer : holder.getInstallers()) {
if (installer.matches(type)) {
return installer;
}
}
return null;
} | java | @SuppressWarnings("unchecked")
private FeatureInstaller findInstaller(final Class<?> type, final ExtensionsHolder holder) {
for (FeatureInstaller installer : holder.getInstallers()) {
if (installer.matches(type)) {
return installer;
}
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"FeatureInstaller",
"findInstaller",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
",",
"final",
"ExtensionsHolder",
"holder",
")",
"{",
"for",
"(",
"FeatureInstaller",
"installer",
":",
"holder",
".",
"getInstallers",
"(",
")",
")",
"{",
"if",
"(",
"installer",
".",
"matches",
"(",
"type",
")",
")",
"{",
"return",
"installer",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Search for matching installer. Extension may match multiple installer, but only one will be actually
used (note that installers are ordered)
@param type extension type
@param holder extensions holder bean
@return matching installer or null if no matching installer found | [
"Search",
"for",
"matching",
"installer",
".",
"Extension",
"may",
"match",
"multiple",
"installer",
"but",
"only",
"one",
"will",
"be",
"actually",
"used",
"(",
"note",
"that",
"installers",
"are",
"ordered",
")"
]
| train | https://github.com/xvik/dropwizard-guicey/blob/dd39ad77283555be21f606d5ebf0f11207a733d4/src/main/java/ru/vyarus/dropwizard/guice/module/installer/InstallerModule.java#L187-L195 |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java | LazyList.addArray | public static Object addArray(Object list, Object[] array) {
"""
Add the contents of an array to a LazyList
@param list The list to add to or null if none yet created.
@param array The array whose contents should be added.
@return The lazylist created or added to.
"""
for (int i = 0; array != null && i < array.length; i++)
list = LazyList.add(list, array[i]);
return list;
} | java | public static Object addArray(Object list, Object[] array) {
for (int i = 0; array != null && i < array.length; i++)
list = LazyList.add(list, array[i]);
return list;
} | [
"public",
"static",
"Object",
"addArray",
"(",
"Object",
"list",
",",
"Object",
"[",
"]",
"array",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"array",
"!=",
"null",
"&&",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"list",
"=",
"LazyList",
".",
"(",
"list",
",",
"array",
"[",
"i",
"]",
")",
";",
"return",
"list",
";",
"}"
]
| Add the contents of an array to a LazyList
@param list The list to add to or null if none yet created.
@param array The array whose contents should be added.
@return The lazylist created or added to. | [
"Add",
"the",
"contents",
"of",
"an",
"array",
"to",
"a",
"LazyList"
]
| train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java#L126-L130 |
xvik/generics-resolver | src/main/java/ru/vyarus/java/generics/resolver/util/GenericInfoUtils.java | GenericInfoUtils.create | public static GenericsInfo create(final GenericsContext context,
final Type type,
final Class<?> asType,
final Class<?>... ignoreClasses) {
"""
Type analysis in context of analyzed type with child class as target type. Case: we have interface
(or base type) with generic in class (as field or return type), but we need to analyze actual
instance type (from value). This method will analyze type from new root (where generics are unknown), but
will add known middle generics.
<p>
NOTE: some of the root generics could possibly be resolved if there are any traceable connectivity between
the root class and known middle generics. All possible (known) cases should be solved. For example,
{@code Root<K> extends Target<List<K>>} when we know {@code Target<Collection<String>>} then
K will be tracked as String.
<p>
In essence: root generics are partially resolved by tracking definition from known middle class.
Other root generics resolved as upper bound (the same as in usual type resolution case).
If middle type generic is not specified (and so resolved as Object) then known specific type used
(assuming root type would be used in place with known parametrization and so more specifi generic may be
counted).
<p>
The result is not intended to be cached as it's context-sensitive.
@param context generics context of containing class
@param type type to analyze (important: this must be generified type and not raw class in
order to properly resolve generics)
@param asType target child type (this class contain original type in hierarchy)
@param ignoreClasses classes to exclude from hierarchy analysis
@return analyzed type generics info
"""
// root generics are required only to properly solve type
final Map<String, Type> rootGenerics = context.visibleGenericsMap();
// first step: solve type to replace transitive generics with direct values
final Type actual = GenericsUtils.resolveTypeVariables(type, rootGenerics);
final Class<?> middleType = context.resolveClass(actual);
if (!middleType.isAssignableFrom(asType)) {
throw new IllegalArgumentException(String.format("Requested type %s is not a subtype of %s",
asType.getSimpleName(), middleType.getSimpleName()));
}
// known middle type
LinkedHashMap<String, Type> typeGenerics = GenericsResolutionUtils.resolveGenerics(actual, rootGenerics);
final Map<Class<?>, LinkedHashMap<String, Type>> knownGenerics =
new HashMap<Class<?>, LinkedHashMap<String, Type>>();
// field could be declared as (Outer<String>.Inner field) and already contain actual outer generics
knownGenerics.put(middleType, GenericsResolutionUtils
.fillOuterGenerics(actual, typeGenerics, context.getGenericsInfo().getTypesMap()));
if (TypeUtils.isInner(middleType)) {
// remember possibly specified outer generics (they were already resolved above)
knownGenerics.put((Class) TypeUtils.getOuter(middleType), new LinkedHashMap<String, Type>(
GenericsUtils.extractOwnerGenerics(middleType, knownGenerics.get(middleType))));
} else {
// store other types for possible outer classes generics resolution
knownGenerics.putAll(usePossiblyOwnerGenerics(asType, context.getGenericsInfo()));
}
// root type
typeGenerics = asType.getTypeParameters().length > 0
? GenericsTrackingUtils.track(asType, middleType, typeGenerics)
: EmptyGenericsMap.getInstance();
typeGenerics = GenericsResolutionUtils
.fillOuterGenerics(asType, typeGenerics, knownGenerics.size() > 1
// if known middle type is inner class then owner already filled
? knownGenerics : context.getGenericsInfo().getTypesMap());
return create(asType, typeGenerics, knownGenerics, ignoreClasses);
} | java | public static GenericsInfo create(final GenericsContext context,
final Type type,
final Class<?> asType,
final Class<?>... ignoreClasses) {
// root generics are required only to properly solve type
final Map<String, Type> rootGenerics = context.visibleGenericsMap();
// first step: solve type to replace transitive generics with direct values
final Type actual = GenericsUtils.resolveTypeVariables(type, rootGenerics);
final Class<?> middleType = context.resolveClass(actual);
if (!middleType.isAssignableFrom(asType)) {
throw new IllegalArgumentException(String.format("Requested type %s is not a subtype of %s",
asType.getSimpleName(), middleType.getSimpleName()));
}
// known middle type
LinkedHashMap<String, Type> typeGenerics = GenericsResolutionUtils.resolveGenerics(actual, rootGenerics);
final Map<Class<?>, LinkedHashMap<String, Type>> knownGenerics =
new HashMap<Class<?>, LinkedHashMap<String, Type>>();
// field could be declared as (Outer<String>.Inner field) and already contain actual outer generics
knownGenerics.put(middleType, GenericsResolutionUtils
.fillOuterGenerics(actual, typeGenerics, context.getGenericsInfo().getTypesMap()));
if (TypeUtils.isInner(middleType)) {
// remember possibly specified outer generics (they were already resolved above)
knownGenerics.put((Class) TypeUtils.getOuter(middleType), new LinkedHashMap<String, Type>(
GenericsUtils.extractOwnerGenerics(middleType, knownGenerics.get(middleType))));
} else {
// store other types for possible outer classes generics resolution
knownGenerics.putAll(usePossiblyOwnerGenerics(asType, context.getGenericsInfo()));
}
// root type
typeGenerics = asType.getTypeParameters().length > 0
? GenericsTrackingUtils.track(asType, middleType, typeGenerics)
: EmptyGenericsMap.getInstance();
typeGenerics = GenericsResolutionUtils
.fillOuterGenerics(asType, typeGenerics, knownGenerics.size() > 1
// if known middle type is inner class then owner already filled
? knownGenerics : context.getGenericsInfo().getTypesMap());
return create(asType, typeGenerics, knownGenerics, ignoreClasses);
} | [
"public",
"static",
"GenericsInfo",
"create",
"(",
"final",
"GenericsContext",
"context",
",",
"final",
"Type",
"type",
",",
"final",
"Class",
"<",
"?",
">",
"asType",
",",
"final",
"Class",
"<",
"?",
">",
"...",
"ignoreClasses",
")",
"{",
"// root generics are required only to properly solve type",
"final",
"Map",
"<",
"String",
",",
"Type",
">",
"rootGenerics",
"=",
"context",
".",
"visibleGenericsMap",
"(",
")",
";",
"// first step: solve type to replace transitive generics with direct values",
"final",
"Type",
"actual",
"=",
"GenericsUtils",
".",
"resolveTypeVariables",
"(",
"type",
",",
"rootGenerics",
")",
";",
"final",
"Class",
"<",
"?",
">",
"middleType",
"=",
"context",
".",
"resolveClass",
"(",
"actual",
")",
";",
"if",
"(",
"!",
"middleType",
".",
"isAssignableFrom",
"(",
"asType",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Requested type %s is not a subtype of %s\"",
",",
"asType",
".",
"getSimpleName",
"(",
")",
",",
"middleType",
".",
"getSimpleName",
"(",
")",
")",
")",
";",
"}",
"// known middle type",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
"typeGenerics",
"=",
"GenericsResolutionUtils",
".",
"resolveGenerics",
"(",
"actual",
",",
"rootGenerics",
")",
";",
"final",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
">",
"knownGenerics",
"=",
"new",
"HashMap",
"<",
"Class",
"<",
"?",
">",
",",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
">",
"(",
")",
";",
"// field could be declared as (Outer<String>.Inner field) and already contain actual outer generics",
"knownGenerics",
".",
"put",
"(",
"middleType",
",",
"GenericsResolutionUtils",
".",
"fillOuterGenerics",
"(",
"actual",
",",
"typeGenerics",
",",
"context",
".",
"getGenericsInfo",
"(",
")",
".",
"getTypesMap",
"(",
")",
")",
")",
";",
"if",
"(",
"TypeUtils",
".",
"isInner",
"(",
"middleType",
")",
")",
"{",
"// remember possibly specified outer generics (they were already resolved above)",
"knownGenerics",
".",
"put",
"(",
"(",
"Class",
")",
"TypeUtils",
".",
"getOuter",
"(",
"middleType",
")",
",",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
"(",
"GenericsUtils",
".",
"extractOwnerGenerics",
"(",
"middleType",
",",
"knownGenerics",
".",
"get",
"(",
"middleType",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"// store other types for possible outer classes generics resolution",
"knownGenerics",
".",
"putAll",
"(",
"usePossiblyOwnerGenerics",
"(",
"asType",
",",
"context",
".",
"getGenericsInfo",
"(",
")",
")",
")",
";",
"}",
"// root type",
"typeGenerics",
"=",
"asType",
".",
"getTypeParameters",
"(",
")",
".",
"length",
">",
"0",
"?",
"GenericsTrackingUtils",
".",
"track",
"(",
"asType",
",",
"middleType",
",",
"typeGenerics",
")",
":",
"EmptyGenericsMap",
".",
"getInstance",
"(",
")",
";",
"typeGenerics",
"=",
"GenericsResolutionUtils",
".",
"fillOuterGenerics",
"(",
"asType",
",",
"typeGenerics",
",",
"knownGenerics",
".",
"size",
"(",
")",
">",
"1",
"// if known middle type is inner class then owner already filled",
"?",
"knownGenerics",
":",
"context",
".",
"getGenericsInfo",
"(",
")",
".",
"getTypesMap",
"(",
")",
")",
";",
"return",
"create",
"(",
"asType",
",",
"typeGenerics",
",",
"knownGenerics",
",",
"ignoreClasses",
")",
";",
"}"
]
| Type analysis in context of analyzed type with child class as target type. Case: we have interface
(or base type) with generic in class (as field or return type), but we need to analyze actual
instance type (from value). This method will analyze type from new root (where generics are unknown), but
will add known middle generics.
<p>
NOTE: some of the root generics could possibly be resolved if there are any traceable connectivity between
the root class and known middle generics. All possible (known) cases should be solved. For example,
{@code Root<K> extends Target<List<K>>} when we know {@code Target<Collection<String>>} then
K will be tracked as String.
<p>
In essence: root generics are partially resolved by tracking definition from known middle class.
Other root generics resolved as upper bound (the same as in usual type resolution case).
If middle type generic is not specified (and so resolved as Object) then known specific type used
(assuming root type would be used in place with known parametrization and so more specifi generic may be
counted).
<p>
The result is not intended to be cached as it's context-sensitive.
@param context generics context of containing class
@param type type to analyze (important: this must be generified type and not raw class in
order to properly resolve generics)
@param asType target child type (this class contain original type in hierarchy)
@param ignoreClasses classes to exclude from hierarchy analysis
@return analyzed type generics info | [
"Type",
"analysis",
"in",
"context",
"of",
"analyzed",
"type",
"with",
"child",
"class",
"as",
"target",
"type",
".",
"Case",
":",
"we",
"have",
"interface",
"(",
"or",
"base",
"type",
")",
"with",
"generic",
"in",
"class",
"(",
"as",
"field",
"or",
"return",
"type",
")",
"but",
"we",
"need",
"to",
"analyze",
"actual",
"instance",
"type",
"(",
"from",
"value",
")",
".",
"This",
"method",
"will",
"analyze",
"type",
"from",
"new",
"root",
"(",
"where",
"generics",
"are",
"unknown",
")",
"but",
"will",
"add",
"known",
"middle",
"generics",
".",
"<p",
">",
"NOTE",
":",
"some",
"of",
"the",
"root",
"generics",
"could",
"possibly",
"be",
"resolved",
"if",
"there",
"are",
"any",
"traceable",
"connectivity",
"between",
"the",
"root",
"class",
"and",
"known",
"middle",
"generics",
".",
"All",
"possible",
"(",
"known",
")",
"cases",
"should",
"be",
"solved",
".",
"For",
"example",
"{",
"@code",
"Root<K",
">",
"extends",
"Target<List<K",
">>",
"}",
"when",
"we",
"know",
"{",
"@code",
"Target<Collection<String",
">>",
"}",
"then",
"K",
"will",
"be",
"tracked",
"as",
"String",
".",
"<p",
">",
"In",
"essence",
":",
"root",
"generics",
"are",
"partially",
"resolved",
"by",
"tracking",
"definition",
"from",
"known",
"middle",
"class",
".",
"Other",
"root",
"generics",
"resolved",
"as",
"upper",
"bound",
"(",
"the",
"same",
"as",
"in",
"usual",
"type",
"resolution",
"case",
")",
".",
"If",
"middle",
"type",
"generic",
"is",
"not",
"specified",
"(",
"and",
"so",
"resolved",
"as",
"Object",
")",
"then",
"known",
"specific",
"type",
"used",
"(",
"assuming",
"root",
"type",
"would",
"be",
"used",
"in",
"place",
"with",
"known",
"parametrization",
"and",
"so",
"more",
"specifi",
"generic",
"may",
"be",
"counted",
")",
".",
"<p",
">",
"The",
"result",
"is",
"not",
"intended",
"to",
"be",
"cached",
"as",
"it",
"s",
"context",
"-",
"sensitive",
"."
]
| train | https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/GenericInfoUtils.java#L101-L142 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/BrokerHelper.java | BrokerHelper.assertValidPksForStore | public boolean assertValidPksForStore(FieldDescriptor[] fieldDescriptors, Object[] pkValues) {
"""
returns true if the primary key fields are valid for store, else false.
PK fields are valid if each of them is either an OJB managed
attribute (autoincrement or locking) or if it contains
a valid non-null value
@param fieldDescriptors the array of PK fielddescriptors
@param pkValues the array of PK values
@return boolean
"""
int fieldDescriptorSize = fieldDescriptors.length;
for(int i = 0; i < fieldDescriptorSize; i++)
{
FieldDescriptor fld = fieldDescriptors[i];
/**
* a pk field is valid if it is either managed by OJB
* (autoincrement or locking) or if it does contain a
* valid non-null value.
*/
if(!(fld.isAutoIncrement()
|| fld.isLocking()
|| !representsNull(fld, pkValues[i])))
{
return false;
}
}
return true;
} | java | public boolean assertValidPksForStore(FieldDescriptor[] fieldDescriptors, Object[] pkValues)
{
int fieldDescriptorSize = fieldDescriptors.length;
for(int i = 0; i < fieldDescriptorSize; i++)
{
FieldDescriptor fld = fieldDescriptors[i];
/**
* a pk field is valid if it is either managed by OJB
* (autoincrement or locking) or if it does contain a
* valid non-null value.
*/
if(!(fld.isAutoIncrement()
|| fld.isLocking()
|| !representsNull(fld, pkValues[i])))
{
return false;
}
}
return true;
} | [
"public",
"boolean",
"assertValidPksForStore",
"(",
"FieldDescriptor",
"[",
"]",
"fieldDescriptors",
",",
"Object",
"[",
"]",
"pkValues",
")",
"{",
"int",
"fieldDescriptorSize",
"=",
"fieldDescriptors",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fieldDescriptorSize",
";",
"i",
"++",
")",
"{",
"FieldDescriptor",
"fld",
"=",
"fieldDescriptors",
"[",
"i",
"]",
";",
"/**\r\n * a pk field is valid if it is either managed by OJB\r\n * (autoincrement or locking) or if it does contain a\r\n * valid non-null value.\r\n */",
"if",
"(",
"!",
"(",
"fld",
".",
"isAutoIncrement",
"(",
")",
"||",
"fld",
".",
"isLocking",
"(",
")",
"||",
"!",
"representsNull",
"(",
"fld",
",",
"pkValues",
"[",
"i",
"]",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
]
| returns true if the primary key fields are valid for store, else false.
PK fields are valid if each of them is either an OJB managed
attribute (autoincrement or locking) or if it contains
a valid non-null value
@param fieldDescriptors the array of PK fielddescriptors
@param pkValues the array of PK values
@return boolean | [
"returns",
"true",
"if",
"the",
"primary",
"key",
"fields",
"are",
"valid",
"for",
"store",
"else",
"false",
".",
"PK",
"fields",
"are",
"valid",
"if",
"each",
"of",
"them",
"is",
"either",
"an",
"OJB",
"managed",
"attribute",
"(",
"autoincrement",
"or",
"locking",
")",
"or",
"if",
"it",
"contains",
"a",
"valid",
"non",
"-",
"null",
"value"
]
| train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L447-L466 |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/LocalDocumentStore.java | LocalDocumentStore.performOnEachDocument | public DocumentOperationResults performOnEachDocument( BiFunction<String, EditableDocument, Boolean> operation ) {
"""
Perform the supplied operation on each stored document that is accessible within this process. Each document will be
operated upon in a separate transaction, which will be committed if the operation is successful or rolledback if the
operation cannot be complete successfully.
<p>
Generally, this method executes the operation upon all documents. If there is an error processing a single document, that
document is skipped and the execution will continue with the next document(s). However, if there is an exception with the
transactions or another system failure, this method will terminate with an exception.
@param operation the operation to be performed
@return the summary of the number of documents that were affected
"""
DocumentOperationResults results = new DocumentOperationResults();
database.keys().forEach(key ->
runInTransaction(() -> {
// We operate upon each document within a transaction ...
try {
EditableDocument doc = edit(key, false);
if (doc != null) {
if (operation.apply(key, doc)) {
results.recordModified();
} else {
results.recordUnmodified();
}
}
} catch (Throwable t) {
results.recordFailure();
}
return null;
}, 1, key));
return results;
} | java | public DocumentOperationResults performOnEachDocument( BiFunction<String, EditableDocument, Boolean> operation ) {
DocumentOperationResults results = new DocumentOperationResults();
database.keys().forEach(key ->
runInTransaction(() -> {
// We operate upon each document within a transaction ...
try {
EditableDocument doc = edit(key, false);
if (doc != null) {
if (operation.apply(key, doc)) {
results.recordModified();
} else {
results.recordUnmodified();
}
}
} catch (Throwable t) {
results.recordFailure();
}
return null;
}, 1, key));
return results;
} | [
"public",
"DocumentOperationResults",
"performOnEachDocument",
"(",
"BiFunction",
"<",
"String",
",",
"EditableDocument",
",",
"Boolean",
">",
"operation",
")",
"{",
"DocumentOperationResults",
"results",
"=",
"new",
"DocumentOperationResults",
"(",
")",
";",
"database",
".",
"keys",
"(",
")",
".",
"forEach",
"(",
"key",
"->",
"runInTransaction",
"(",
"(",
")",
"->",
"{",
"// We operate upon each document within a transaction ...",
"try",
"{",
"EditableDocument",
"doc",
"=",
"edit",
"(",
"key",
",",
"false",
")",
";",
"if",
"(",
"doc",
"!=",
"null",
")",
"{",
"if",
"(",
"operation",
".",
"apply",
"(",
"key",
",",
"doc",
")",
")",
"{",
"results",
".",
"recordModified",
"(",
")",
";",
"}",
"else",
"{",
"results",
".",
"recordUnmodified",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"results",
".",
"recordFailure",
"(",
")",
";",
"}",
"return",
"null",
";",
"}",
",",
"1",
",",
"key",
")",
")",
";",
"return",
"results",
";",
"}"
]
| Perform the supplied operation on each stored document that is accessible within this process. Each document will be
operated upon in a separate transaction, which will be committed if the operation is successful or rolledback if the
operation cannot be complete successfully.
<p>
Generally, this method executes the operation upon all documents. If there is an error processing a single document, that
document is skipped and the execution will continue with the next document(s). However, if there is an exception with the
transactions or another system failure, this method will terminate with an exception.
@param operation the operation to be performed
@return the summary of the number of documents that were affected | [
"Perform",
"the",
"supplied",
"operation",
"on",
"each",
"stored",
"document",
"that",
"is",
"accessible",
"within",
"this",
"process",
".",
"Each",
"document",
"will",
"be",
"operated",
"upon",
"in",
"a",
"separate",
"transaction",
"which",
"will",
"be",
"committed",
"if",
"the",
"operation",
"is",
"successful",
"or",
"rolledback",
"if",
"the",
"operation",
"cannot",
"be",
"complete",
"successfully",
".",
"<p",
">",
"Generally",
"this",
"method",
"executes",
"the",
"operation",
"upon",
"all",
"documents",
".",
"If",
"there",
"is",
"an",
"error",
"processing",
"a",
"single",
"document",
"that",
"document",
"is",
"skipped",
"and",
"the",
"execution",
"will",
"continue",
"with",
"the",
"next",
"document",
"(",
"s",
")",
".",
"However",
"if",
"there",
"is",
"an",
"exception",
"with",
"the",
"transactions",
"or",
"another",
"system",
"failure",
"this",
"method",
"will",
"terminate",
"with",
"an",
"exception",
"."
]
| train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/LocalDocumentStore.java#L249-L269 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java | ByteArrayUtil.writeUnsignedVarintLong | public static void writeUnsignedVarintLong(ByteBuffer buffer, long val) {
"""
Write an unsigned long using a variable-length encoding.
Data is always written in 7-bit little-endian, where the 8th bit is the
continuation flag.
Note that for integers, this will result in the same encoding as
{@link #writeUnsignedVarint}
@param buffer Buffer to write to
@param val number to write
"""
// Extra bytes have the high bit set
while((val & 0x7F) != val) {
buffer.put((byte) ((val & 0x7F) | 0x80));
val >>>= 7;
}
// Last byte doesn't have high bit set
buffer.put((byte) (val & 0x7F));
} | java | public static void writeUnsignedVarintLong(ByteBuffer buffer, long val) {
// Extra bytes have the high bit set
while((val & 0x7F) != val) {
buffer.put((byte) ((val & 0x7F) | 0x80));
val >>>= 7;
}
// Last byte doesn't have high bit set
buffer.put((byte) (val & 0x7F));
} | [
"public",
"static",
"void",
"writeUnsignedVarintLong",
"(",
"ByteBuffer",
"buffer",
",",
"long",
"val",
")",
"{",
"// Extra bytes have the high bit set",
"while",
"(",
"(",
"val",
"&",
"0x7F",
")",
"!=",
"val",
")",
"{",
"buffer",
".",
"put",
"(",
"(",
"byte",
")",
"(",
"(",
"val",
"&",
"0x7F",
")",
"|",
"0x80",
")",
")",
";",
"val",
">>>=",
"7",
";",
"}",
"// Last byte doesn't have high bit set",
"buffer",
".",
"put",
"(",
"(",
"byte",
")",
"(",
"val",
"&",
"0x7F",
")",
")",
";",
"}"
]
| Write an unsigned long using a variable-length encoding.
Data is always written in 7-bit little-endian, where the 8th bit is the
continuation flag.
Note that for integers, this will result in the same encoding as
{@link #writeUnsignedVarint}
@param buffer Buffer to write to
@param val number to write | [
"Write",
"an",
"unsigned",
"long",
"using",
"a",
"variable",
"-",
"length",
"encoding",
"."
]
| train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L669-L677 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java | AppServiceEnvironmentsInner.listMultiRoleMetricsAsync | public Observable<Page<ResourceMetricInner>> listMultiRoleMetricsAsync(final String resourceGroupName, final String name, final String startTime, final String endTime, final String timeGrain, final Boolean details, final String filter) {
"""
Get metrics for a multi-role pool of an App Service Environment.
Get metrics for a multi-role pool of an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@param startTime Beginning time of the metrics query.
@param endTime End time of the metrics query.
@param timeGrain Time granularity of the metrics query.
@param details Specify <code>true</code> to include instance details. The default is <code>false</code>.
@param filter Return only usages/metrics specified in the filter. Filter conforms to odata syntax. Example: $filter=(name.value eq 'Metric1' or name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' and timeGrain eq duration'[Hour|Minute|Day]'.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ResourceMetricInner> object
"""
return listMultiRoleMetricsWithServiceResponseAsync(resourceGroupName, name, startTime, endTime, timeGrain, details, filter)
.map(new Func1<ServiceResponse<Page<ResourceMetricInner>>, Page<ResourceMetricInner>>() {
@Override
public Page<ResourceMetricInner> call(ServiceResponse<Page<ResourceMetricInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<ResourceMetricInner>> listMultiRoleMetricsAsync(final String resourceGroupName, final String name, final String startTime, final String endTime, final String timeGrain, final Boolean details, final String filter) {
return listMultiRoleMetricsWithServiceResponseAsync(resourceGroupName, name, startTime, endTime, timeGrain, details, filter)
.map(new Func1<ServiceResponse<Page<ResourceMetricInner>>, Page<ResourceMetricInner>>() {
@Override
public Page<ResourceMetricInner> call(ServiceResponse<Page<ResourceMetricInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"ResourceMetricInner",
">",
">",
"listMultiRoleMetricsAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"name",
",",
"final",
"String",
"startTime",
",",
"final",
"String",
"endTime",
",",
"final",
"String",
"timeGrain",
",",
"final",
"Boolean",
"details",
",",
"final",
"String",
"filter",
")",
"{",
"return",
"listMultiRoleMetricsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
",",
"startTime",
",",
"endTime",
",",
"timeGrain",
",",
"details",
",",
"filter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"ResourceMetricInner",
">",
">",
",",
"Page",
"<",
"ResourceMetricInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"ResourceMetricInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"ResourceMetricInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Get metrics for a multi-role pool of an App Service Environment.
Get metrics for a multi-role pool of an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@param startTime Beginning time of the metrics query.
@param endTime End time of the metrics query.
@param timeGrain Time granularity of the metrics query.
@param details Specify <code>true</code> to include instance details. The default is <code>false</code>.
@param filter Return only usages/metrics specified in the filter. Filter conforms to odata syntax. Example: $filter=(name.value eq 'Metric1' or name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' and timeGrain eq duration'[Hour|Minute|Day]'.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ResourceMetricInner> object | [
"Get",
"metrics",
"for",
"a",
"multi",
"-",
"role",
"pool",
"of",
"an",
"App",
"Service",
"Environment",
".",
"Get",
"metrics",
"for",
"a",
"multi",
"-",
"role",
"pool",
"of",
"an",
"App",
"Service",
"Environment",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L3274-L3282 |
adorsys/hbci4java-adorsys | src/main/java/org/kapott/hbci/passport/AbstractHBCIPassport.java | AbstractHBCIPassport.getLowlevelJobResultNames | public List<String> getLowlevelJobResultNames(String gvname) {
"""
<p>Gibt eine Liste mit Strings zurück, welche Bezeichnungen für die einzelnen Rückgabedaten
eines Lowlevel-Jobs darstellen. Jedem {@link org.kapott.hbci.GV.AbstractHBCIJob} ist ein
Result-Objekt zugeordnet, welches die Rückgabedaten und Statusinformationen zu dem jeweiligen
Job enthält (kann mit {@link org.kapott.hbci.GV.AbstractHBCIJob#getJobResult()}
ermittelt werden). Bei den meisten Highlevel-Jobs handelt es sich dabei um bereits aufbereitete
Daten (Kontoauszüge werden z.B. nicht in dem ursprünglichen SWIFT-Format zurückgegeben, sondern
bereits als fertig geparste Buchungseinträge).</p>
<p>Bei Lowlevel-Jobs gibt es diese Aufbereitung der Daten nicht. Statt dessen müssen die Daten
manuell aus der Antwortnachricht extrahiert und interpretiert werden. Die einzelnen Datenelemente
der Antwortnachricht werden in einem Properties-Objekt bereitgestellt. Jeder Eintrag
darin enthält den Namen und den Wert eines Datenelementes aus der Antwortnachricht.</p>
<p>Die Methode <code>getLowlevelJobResultNames()</code> gibt nun alle gültigen Namen zurück,
für welche in dem Result-Objekt Daten gespeichert sein können. Ob für ein Datenelement tatsächlich
ein Wert in dem Result-Objekt existiert, wird damit nicht bestimmt, da einzelne Datenelemente
optional sind.</p>
<p>Mit dem Tool {@link org.kapott.hbci.tools.ShowLowlevelGVRs} kann offline eine
Liste aller Job-Result-Datenelemente erzeugt werden.</p>
<p>Zur Beschreibung von High- und Lowlevel-Jobs siehe auch die Dokumentation
im Package <code>org.kapott.hbci.GV</code>.</p>
@param gvname Lowlevelname des Geschäftsvorfalls, für den die Namen der Rückgabedaten benötigt werden.
@return Liste aller möglichen Property-Keys, für die im Result-Objekt eines Lowlevel-Jobs
Werte vorhanden sein könnten
"""
if (gvname == null || gvname.length() == 0)
throw new InvalidArgumentException(HBCIUtils.getLocMsg("EXCMSG_EMPTY_JOBNAME"));
String version = getSupportedLowlevelJobs().get(gvname);
if (version == null)
throw new HBCI_Exception("*** lowlevel job " + gvname + " not supported");
return getGVResultNames(syntaxDocument, gvname, version);
} | java | public List<String> getLowlevelJobResultNames(String gvname) {
if (gvname == null || gvname.length() == 0)
throw new InvalidArgumentException(HBCIUtils.getLocMsg("EXCMSG_EMPTY_JOBNAME"));
String version = getSupportedLowlevelJobs().get(gvname);
if (version == null)
throw new HBCI_Exception("*** lowlevel job " + gvname + " not supported");
return getGVResultNames(syntaxDocument, gvname, version);
} | [
"public",
"List",
"<",
"String",
">",
"getLowlevelJobResultNames",
"(",
"String",
"gvname",
")",
"{",
"if",
"(",
"gvname",
"==",
"null",
"||",
"gvname",
".",
"length",
"(",
")",
"==",
"0",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"HBCIUtils",
".",
"getLocMsg",
"(",
"\"EXCMSG_EMPTY_JOBNAME\"",
")",
")",
";",
"String",
"version",
"=",
"getSupportedLowlevelJobs",
"(",
")",
".",
"get",
"(",
"gvname",
")",
";",
"if",
"(",
"version",
"==",
"null",
")",
"throw",
"new",
"HBCI_Exception",
"(",
"\"*** lowlevel job \"",
"+",
"gvname",
"+",
"\" not supported\"",
")",
";",
"return",
"getGVResultNames",
"(",
"syntaxDocument",
",",
"gvname",
",",
"version",
")",
";",
"}"
]
| <p>Gibt eine Liste mit Strings zurück, welche Bezeichnungen für die einzelnen Rückgabedaten
eines Lowlevel-Jobs darstellen. Jedem {@link org.kapott.hbci.GV.AbstractHBCIJob} ist ein
Result-Objekt zugeordnet, welches die Rückgabedaten und Statusinformationen zu dem jeweiligen
Job enthält (kann mit {@link org.kapott.hbci.GV.AbstractHBCIJob#getJobResult()}
ermittelt werden). Bei den meisten Highlevel-Jobs handelt es sich dabei um bereits aufbereitete
Daten (Kontoauszüge werden z.B. nicht in dem ursprünglichen SWIFT-Format zurückgegeben, sondern
bereits als fertig geparste Buchungseinträge).</p>
<p>Bei Lowlevel-Jobs gibt es diese Aufbereitung der Daten nicht. Statt dessen müssen die Daten
manuell aus der Antwortnachricht extrahiert und interpretiert werden. Die einzelnen Datenelemente
der Antwortnachricht werden in einem Properties-Objekt bereitgestellt. Jeder Eintrag
darin enthält den Namen und den Wert eines Datenelementes aus der Antwortnachricht.</p>
<p>Die Methode <code>getLowlevelJobResultNames()</code> gibt nun alle gültigen Namen zurück,
für welche in dem Result-Objekt Daten gespeichert sein können. Ob für ein Datenelement tatsächlich
ein Wert in dem Result-Objekt existiert, wird damit nicht bestimmt, da einzelne Datenelemente
optional sind.</p>
<p>Mit dem Tool {@link org.kapott.hbci.tools.ShowLowlevelGVRs} kann offline eine
Liste aller Job-Result-Datenelemente erzeugt werden.</p>
<p>Zur Beschreibung von High- und Lowlevel-Jobs siehe auch die Dokumentation
im Package <code>org.kapott.hbci.GV</code>.</p>
@param gvname Lowlevelname des Geschäftsvorfalls, für den die Namen der Rückgabedaten benötigt werden.
@return Liste aller möglichen Property-Keys, für die im Result-Objekt eines Lowlevel-Jobs
Werte vorhanden sein könnten | [
"<p",
">",
"Gibt",
"eine",
"Liste",
"mit",
"Strings",
"zurück",
"welche",
"Bezeichnungen",
"für",
"die",
"einzelnen",
"Rückgabedaten",
"eines",
"Lowlevel",
"-",
"Jobs",
"darstellen",
".",
"Jedem",
"{",
"@link",
"org",
".",
"kapott",
".",
"hbci",
".",
"GV",
".",
"AbstractHBCIJob",
"}",
"ist",
"ein",
"Result",
"-",
"Objekt",
"zugeordnet",
"welches",
"die",
"Rückgabedaten",
"und",
"Statusinformationen",
"zu",
"dem",
"jeweiligen",
"Job",
"enthält",
"(",
"kann",
"mit",
"{",
"@link",
"org",
".",
"kapott",
".",
"hbci",
".",
"GV",
".",
"AbstractHBCIJob#getJobResult",
"()",
"}",
"ermittelt",
"werden",
")",
".",
"Bei",
"den",
"meisten",
"Highlevel",
"-",
"Jobs",
"handelt",
"es",
"sich",
"dabei",
"um",
"bereits",
"aufbereitete",
"Daten",
"(",
"Kontoauszüge",
"werden",
"z",
".",
"B",
".",
"nicht",
"in",
"dem",
"ursprünglichen",
"SWIFT",
"-",
"Format",
"zurückgegeben",
"sondern",
"bereits",
"als",
"fertig",
"geparste",
"Buchungseinträge",
")",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Bei",
"Lowlevel",
"-",
"Jobs",
"gibt",
"es",
"diese",
"Aufbereitung",
"der",
"Daten",
"nicht",
".",
"Statt",
"dessen",
"müssen",
"die",
"Daten",
"manuell",
"aus",
"der",
"Antwortnachricht",
"extrahiert",
"und",
"interpretiert",
"werden",
".",
"Die",
"einzelnen",
"Datenelemente",
"der",
"Antwortnachricht",
"werden",
"in",
"einem",
"Properties",
"-",
"Objekt",
"bereitgestellt",
".",
"Jeder",
"Eintrag",
"darin",
"enthält",
"den",
"Namen",
"und",
"den",
"Wert",
"eines",
"Datenelementes",
"aus",
"der",
"Antwortnachricht",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Die",
"Methode",
"<code",
">",
"getLowlevelJobResultNames",
"()",
"<",
"/",
"code",
">",
"gibt",
"nun",
"alle",
"gültigen",
"Namen",
"zurück",
"für",
"welche",
"in",
"dem",
"Result",
"-",
"Objekt",
"Daten",
"gespeichert",
"sein",
"können",
".",
"Ob",
"für",
"ein",
"Datenelement",
"tatsächlich",
"ein",
"Wert",
"in",
"dem",
"Result",
"-",
"Objekt",
"existiert",
"wird",
"damit",
"nicht",
"bestimmt",
"da",
"einzelne",
"Datenelemente",
"optional",
"sind",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Mit",
"dem",
"Tool",
"{",
"@link",
"org",
".",
"kapott",
".",
"hbci",
".",
"tools",
".",
"ShowLowlevelGVRs",
"}",
"kann",
"offline",
"eine",
"Liste",
"aller",
"Job",
"-",
"Result",
"-",
"Datenelemente",
"erzeugt",
"werden",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Zur",
"Beschreibung",
"von",
"High",
"-",
"und",
"Lowlevel",
"-",
"Jobs",
"siehe",
"auch",
"die",
"Dokumentation",
"im",
"Package",
"<code",
">",
"org",
".",
"kapott",
".",
"hbci",
".",
"GV<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/passport/AbstractHBCIPassport.java#L465-L474 |
Netflix/Hystrix | hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/utils/MethodProvider.java | MethodProvider.getFallbackMethod | public FallbackMethod getFallbackMethod(Class<?> enclosingType, Method commandMethod, boolean extended) {
"""
Gets fallback method for command method.
@param enclosingType the enclosing class
@param commandMethod the command method. in the essence it can be a fallback
method annotated with HystrixCommand annotation that has a fallback as well.
@param extended true if the given commandMethod was derived using additional parameter, otherwise - false
@return new instance of {@link FallbackMethod} or {@link FallbackMethod#ABSENT} if there is no suitable fallback method for the given command
"""
if (commandMethod.isAnnotationPresent(HystrixCommand.class)) {
return FALLBACK_METHOD_FINDER.find(enclosingType, commandMethod, extended);
}
return FallbackMethod.ABSENT;
} | java | public FallbackMethod getFallbackMethod(Class<?> enclosingType, Method commandMethod, boolean extended) {
if (commandMethod.isAnnotationPresent(HystrixCommand.class)) {
return FALLBACK_METHOD_FINDER.find(enclosingType, commandMethod, extended);
}
return FallbackMethod.ABSENT;
} | [
"public",
"FallbackMethod",
"getFallbackMethod",
"(",
"Class",
"<",
"?",
">",
"enclosingType",
",",
"Method",
"commandMethod",
",",
"boolean",
"extended",
")",
"{",
"if",
"(",
"commandMethod",
".",
"isAnnotationPresent",
"(",
"HystrixCommand",
".",
"class",
")",
")",
"{",
"return",
"FALLBACK_METHOD_FINDER",
".",
"find",
"(",
"enclosingType",
",",
"commandMethod",
",",
"extended",
")",
";",
"}",
"return",
"FallbackMethod",
".",
"ABSENT",
";",
"}"
]
| Gets fallback method for command method.
@param enclosingType the enclosing class
@param commandMethod the command method. in the essence it can be a fallback
method annotated with HystrixCommand annotation that has a fallback as well.
@param extended true if the given commandMethod was derived using additional parameter, otherwise - false
@return new instance of {@link FallbackMethod} or {@link FallbackMethod#ABSENT} if there is no suitable fallback method for the given command | [
"Gets",
"fallback",
"method",
"for",
"command",
"method",
"."
]
| train | https://github.com/Netflix/Hystrix/blob/3cb21589895e9f8f87cfcdbc9d96d9f63d48b848/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/utils/MethodProvider.java#L71-L76 |
auth0/Lock.Android | lib/src/main/java/com/auth0/android/lock/events/PasswordlessLoginEvent.java | PasswordlessLoginEvent.getLoginRequest | public AuthenticationRequest getLoginRequest(AuthenticationAPIClient apiClient, String emailOrNumber) {
"""
Creates the AuthenticationRequest that will finish the Passwordless Authentication flow.
@param apiClient the API Client instance
@param emailOrNumber the email or phone number used on the code request.
@return the Passwordless login request.
"""
Log.d(TAG, String.format("Generating Passwordless Login request for identity %s", emailOrNumber));
if (getMode() == PasswordlessMode.EMAIL_CODE || getMode() == PasswordlessMode.EMAIL_LINK) {
return apiClient.loginWithEmail(emailOrNumber, getCode());
} else {
return apiClient.loginWithPhoneNumber(emailOrNumber, getCode());
}
} | java | public AuthenticationRequest getLoginRequest(AuthenticationAPIClient apiClient, String emailOrNumber) {
Log.d(TAG, String.format("Generating Passwordless Login request for identity %s", emailOrNumber));
if (getMode() == PasswordlessMode.EMAIL_CODE || getMode() == PasswordlessMode.EMAIL_LINK) {
return apiClient.loginWithEmail(emailOrNumber, getCode());
} else {
return apiClient.loginWithPhoneNumber(emailOrNumber, getCode());
}
} | [
"public",
"AuthenticationRequest",
"getLoginRequest",
"(",
"AuthenticationAPIClient",
"apiClient",
",",
"String",
"emailOrNumber",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"String",
".",
"format",
"(",
"\"Generating Passwordless Login request for identity %s\"",
",",
"emailOrNumber",
")",
")",
";",
"if",
"(",
"getMode",
"(",
")",
"==",
"PasswordlessMode",
".",
"EMAIL_CODE",
"||",
"getMode",
"(",
")",
"==",
"PasswordlessMode",
".",
"EMAIL_LINK",
")",
"{",
"return",
"apiClient",
".",
"loginWithEmail",
"(",
"emailOrNumber",
",",
"getCode",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"apiClient",
".",
"loginWithPhoneNumber",
"(",
"emailOrNumber",
",",
"getCode",
"(",
")",
")",
";",
"}",
"}"
]
| Creates the AuthenticationRequest that will finish the Passwordless Authentication flow.
@param apiClient the API Client instance
@param emailOrNumber the email or phone number used on the code request.
@return the Passwordless login request. | [
"Creates",
"the",
"AuthenticationRequest",
"that",
"will",
"finish",
"the",
"Passwordless",
"Authentication",
"flow",
"."
]
| train | https://github.com/auth0/Lock.Android/blob/8eb2a979048d2eb6cf0ec631e82e6c3fe6e7d220/lib/src/main/java/com/auth0/android/lock/events/PasswordlessLoginEvent.java#L118-L125 |
apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/scheduler/JobScheduler.java | JobScheduler.runJob | public boolean runJob(Properties jobProps, JobListener jobListener, JobLauncher jobLauncher)
throws JobException {
"""
Run a job.
<p>
This method runs the job immediately without going through the Quartz scheduler.
This is particularly useful for testing.
</p>
<p>
This method does what {@link #runJob(Properties, JobListener)} does, and additionally it allows
the caller to pass in a {@link JobLauncher} instance used to launch the job to run.
</p>
@param jobProps Job configuration properties
@param jobListener {@link JobListener} used for callback, can be <em>null</em> if no callback is needed.
@param jobLauncher a {@link JobLauncher} object used to launch the job to run
@return If current job is a stop-early job based on {@link Source#isEarlyStopped()}
@throws JobException when there is anything wrong with running the job
"""
Preconditions.checkArgument(jobProps.containsKey(ConfigurationKeys.JOB_NAME_KEY),
"A job must have a job name specified by job.name");
String jobName = jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY);
// Check if the job has been disabled
boolean disabled = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_DISABLED_KEY, "false"));
if (disabled) {
LOG.info("Skipping disabled job " + jobName);
return false;
}
// Launch the job
try (Closer closer = Closer.create()) {
closer.register(jobLauncher).launchJob(jobListener);
boolean runOnce = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_RUN_ONCE_KEY, "false"));
boolean isEarlyStopped = jobLauncher.isEarlyStopped();
if (!isEarlyStopped && runOnce && this.scheduledJobs.containsKey(jobName)) {
this.scheduler.getScheduler().deleteJob(this.scheduledJobs.remove(jobName));
}
return isEarlyStopped;
} catch (Throwable t) {
throw new JobException("Failed to launch and run job " + jobName, t);
}
} | java | public boolean runJob(Properties jobProps, JobListener jobListener, JobLauncher jobLauncher)
throws JobException {
Preconditions.checkArgument(jobProps.containsKey(ConfigurationKeys.JOB_NAME_KEY),
"A job must have a job name specified by job.name");
String jobName = jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY);
// Check if the job has been disabled
boolean disabled = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_DISABLED_KEY, "false"));
if (disabled) {
LOG.info("Skipping disabled job " + jobName);
return false;
}
// Launch the job
try (Closer closer = Closer.create()) {
closer.register(jobLauncher).launchJob(jobListener);
boolean runOnce = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_RUN_ONCE_KEY, "false"));
boolean isEarlyStopped = jobLauncher.isEarlyStopped();
if (!isEarlyStopped && runOnce && this.scheduledJobs.containsKey(jobName)) {
this.scheduler.getScheduler().deleteJob(this.scheduledJobs.remove(jobName));
}
return isEarlyStopped;
} catch (Throwable t) {
throw new JobException("Failed to launch and run job " + jobName, t);
}
} | [
"public",
"boolean",
"runJob",
"(",
"Properties",
"jobProps",
",",
"JobListener",
"jobListener",
",",
"JobLauncher",
"jobLauncher",
")",
"throws",
"JobException",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"jobProps",
".",
"containsKey",
"(",
"ConfigurationKeys",
".",
"JOB_NAME_KEY",
")",
",",
"\"A job must have a job name specified by job.name\"",
")",
";",
"String",
"jobName",
"=",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"JOB_NAME_KEY",
")",
";",
"// Check if the job has been disabled",
"boolean",
"disabled",
"=",
"Boolean",
".",
"valueOf",
"(",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"JOB_DISABLED_KEY",
",",
"\"false\"",
")",
")",
";",
"if",
"(",
"disabled",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Skipping disabled job \"",
"+",
"jobName",
")",
";",
"return",
"false",
";",
"}",
"// Launch the job",
"try",
"(",
"Closer",
"closer",
"=",
"Closer",
".",
"create",
"(",
")",
")",
"{",
"closer",
".",
"register",
"(",
"jobLauncher",
")",
".",
"launchJob",
"(",
"jobListener",
")",
";",
"boolean",
"runOnce",
"=",
"Boolean",
".",
"valueOf",
"(",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"JOB_RUN_ONCE_KEY",
",",
"\"false\"",
")",
")",
";",
"boolean",
"isEarlyStopped",
"=",
"jobLauncher",
".",
"isEarlyStopped",
"(",
")",
";",
"if",
"(",
"!",
"isEarlyStopped",
"&&",
"runOnce",
"&&",
"this",
".",
"scheduledJobs",
".",
"containsKey",
"(",
"jobName",
")",
")",
"{",
"this",
".",
"scheduler",
".",
"getScheduler",
"(",
")",
".",
"deleteJob",
"(",
"this",
".",
"scheduledJobs",
".",
"remove",
"(",
"jobName",
")",
")",
";",
"}",
"return",
"isEarlyStopped",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"JobException",
"(",
"\"Failed to launch and run job \"",
"+",
"jobName",
",",
"t",
")",
";",
"}",
"}"
]
| Run a job.
<p>
This method runs the job immediately without going through the Quartz scheduler.
This is particularly useful for testing.
</p>
<p>
This method does what {@link #runJob(Properties, JobListener)} does, and additionally it allows
the caller to pass in a {@link JobLauncher} instance used to launch the job to run.
</p>
@param jobProps Job configuration properties
@param jobListener {@link JobListener} used for callback, can be <em>null</em> if no callback is needed.
@param jobLauncher a {@link JobLauncher} object used to launch the job to run
@return If current job is a stop-early job based on {@link Source#isEarlyStopped()}
@throws JobException when there is anything wrong with running the job | [
"Run",
"a",
"job",
"."
]
| train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/scheduler/JobScheduler.java#L464-L491 |
groundupworks/wings | wings-dropbox/src/main/java/com/groundupworks/wings/dropbox/DropboxEndpoint.java | DropboxEndpoint.storeAccountParams | private void storeAccountParams(String accountName, String shareUrl, String accessToken) {
"""
Stores the account params in persisted storage.
@param accountName the user name associated with the account.
@param shareUrl the share url associated with the account.
@param accessToken the access token.
"""
Editor editor = PreferenceManager.getDefaultSharedPreferences(mContext).edit();
editor.putString(mContext.getString(R.string.wings_dropbox__account_name_key), accountName);
editor.putString(mContext.getString(R.string.wings_dropbox__share_url_key), shareUrl);
editor.putString(mContext.getString(R.string.wings_dropbox__access_token_key), accessToken);
// Set preference to linked.
editor.putBoolean(mContext.getString(R.string.wings_dropbox__link_key), true);
editor.apply();
} | java | private void storeAccountParams(String accountName, String shareUrl, String accessToken) {
Editor editor = PreferenceManager.getDefaultSharedPreferences(mContext).edit();
editor.putString(mContext.getString(R.string.wings_dropbox__account_name_key), accountName);
editor.putString(mContext.getString(R.string.wings_dropbox__share_url_key), shareUrl);
editor.putString(mContext.getString(R.string.wings_dropbox__access_token_key), accessToken);
// Set preference to linked.
editor.putBoolean(mContext.getString(R.string.wings_dropbox__link_key), true);
editor.apply();
} | [
"private",
"void",
"storeAccountParams",
"(",
"String",
"accountName",
",",
"String",
"shareUrl",
",",
"String",
"accessToken",
")",
"{",
"Editor",
"editor",
"=",
"PreferenceManager",
".",
"getDefaultSharedPreferences",
"(",
"mContext",
")",
".",
"edit",
"(",
")",
";",
"editor",
".",
"putString",
"(",
"mContext",
".",
"getString",
"(",
"R",
".",
"string",
".",
"wings_dropbox__account_name_key",
")",
",",
"accountName",
")",
";",
"editor",
".",
"putString",
"(",
"mContext",
".",
"getString",
"(",
"R",
".",
"string",
".",
"wings_dropbox__share_url_key",
")",
",",
"shareUrl",
")",
";",
"editor",
".",
"putString",
"(",
"mContext",
".",
"getString",
"(",
"R",
".",
"string",
".",
"wings_dropbox__access_token_key",
")",
",",
"accessToken",
")",
";",
"// Set preference to linked.",
"editor",
".",
"putBoolean",
"(",
"mContext",
".",
"getString",
"(",
"R",
".",
"string",
".",
"wings_dropbox__link_key",
")",
",",
"true",
")",
";",
"editor",
".",
"apply",
"(",
")",
";",
"}"
]
| Stores the account params in persisted storage.
@param accountName the user name associated with the account.
@param shareUrl the share url associated with the account.
@param accessToken the access token. | [
"Stores",
"the",
"account",
"params",
"in",
"persisted",
"storage",
"."
]
| train | https://github.com/groundupworks/wings/blob/03d2827c30ef55f2db4e23f7500e016c7771fa39/wings-dropbox/src/main/java/com/groundupworks/wings/dropbox/DropboxEndpoint.java#L248-L257 |
datastax/java-driver | core/src/main/java/com/datastax/oss/driver/internal/core/util/concurrent/CompletableFutures.java | CompletableFutures.getFailed | public static Throwable getFailed(CompletionStage<?> stage) {
"""
Get the error now, when we know for sure that the future is failed.
"""
CompletableFuture<?> future = stage.toCompletableFuture();
Preconditions.checkArgument(future.isCompletedExceptionally());
try {
future.get();
throw new AssertionError("future should be failed");
} catch (InterruptedException e) {
throw new AssertionError("Unexpected error", e);
} catch (ExecutionException e) {
return e.getCause();
}
} | java | public static Throwable getFailed(CompletionStage<?> stage) {
CompletableFuture<?> future = stage.toCompletableFuture();
Preconditions.checkArgument(future.isCompletedExceptionally());
try {
future.get();
throw new AssertionError("future should be failed");
} catch (InterruptedException e) {
throw new AssertionError("Unexpected error", e);
} catch (ExecutionException e) {
return e.getCause();
}
} | [
"public",
"static",
"Throwable",
"getFailed",
"(",
"CompletionStage",
"<",
"?",
">",
"stage",
")",
"{",
"CompletableFuture",
"<",
"?",
">",
"future",
"=",
"stage",
".",
"toCompletableFuture",
"(",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"future",
".",
"isCompletedExceptionally",
"(",
")",
")",
";",
"try",
"{",
"future",
".",
"get",
"(",
")",
";",
"throw",
"new",
"AssertionError",
"(",
"\"future should be failed\"",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"\"Unexpected error\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"return",
"e",
".",
"getCause",
"(",
")",
";",
"}",
"}"
]
| Get the error now, when we know for sure that the future is failed. | [
"Get",
"the",
"error",
"now",
"when",
"we",
"know",
"for",
"sure",
"that",
"the",
"future",
"is",
"failed",
"."
]
| train | https://github.com/datastax/java-driver/blob/612a63f2525618e2020e86c9ad75ab37adba6132/core/src/main/java/com/datastax/oss/driver/internal/core/util/concurrent/CompletableFutures.java#L89-L100 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/dom3/DOM3TreeWalker.java | DOM3TreeWalker.serializePI | protected void serializePI(ProcessingInstruction node)
throws SAXException {
"""
Serializes an ProcessingInstruction Node.
@param node The ProcessingInstruction Node to serialize
"""
ProcessingInstruction pi = node;
String name = pi.getNodeName();
// well-formed=true
if ((fFeatures & WELLFORMED) != 0) {
isPIWellFormed(node);
}
// apply the LSSerializer filter
if (!applyFilter(node, NodeFilter.SHOW_PROCESSING_INSTRUCTION)) {
return;
}
// String data = pi.getData();
if (name.equals("xslt-next-is-raw")) {
fNextIsRaw = true;
} else {
this.fSerializer.processingInstruction(name, pi.getData());
}
} | java | protected void serializePI(ProcessingInstruction node)
throws SAXException {
ProcessingInstruction pi = node;
String name = pi.getNodeName();
// well-formed=true
if ((fFeatures & WELLFORMED) != 0) {
isPIWellFormed(node);
}
// apply the LSSerializer filter
if (!applyFilter(node, NodeFilter.SHOW_PROCESSING_INSTRUCTION)) {
return;
}
// String data = pi.getData();
if (name.equals("xslt-next-is-raw")) {
fNextIsRaw = true;
} else {
this.fSerializer.processingInstruction(name, pi.getData());
}
} | [
"protected",
"void",
"serializePI",
"(",
"ProcessingInstruction",
"node",
")",
"throws",
"SAXException",
"{",
"ProcessingInstruction",
"pi",
"=",
"node",
";",
"String",
"name",
"=",
"pi",
".",
"getNodeName",
"(",
")",
";",
"// well-formed=true",
"if",
"(",
"(",
"fFeatures",
"&",
"WELLFORMED",
")",
"!=",
"0",
")",
"{",
"isPIWellFormed",
"(",
"node",
")",
";",
"}",
"// apply the LSSerializer filter",
"if",
"(",
"!",
"applyFilter",
"(",
"node",
",",
"NodeFilter",
".",
"SHOW_PROCESSING_INSTRUCTION",
")",
")",
"{",
"return",
";",
"}",
"// String data = pi.getData();",
"if",
"(",
"name",
".",
"equals",
"(",
"\"xslt-next-is-raw\"",
")",
")",
"{",
"fNextIsRaw",
"=",
"true",
";",
"}",
"else",
"{",
"this",
".",
"fSerializer",
".",
"processingInstruction",
"(",
"name",
",",
"pi",
".",
"getData",
"(",
")",
")",
";",
"}",
"}"
]
| Serializes an ProcessingInstruction Node.
@param node The ProcessingInstruction Node to serialize | [
"Serializes",
"an",
"ProcessingInstruction",
"Node",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/dom3/DOM3TreeWalker.java#L887-L908 |
BlueBrain/bluima | modules/bluima_abbreviations/src/main/java/com/wcohen/ss/TFIDF.java | TFIDF.prepare | public StringWrapper prepare(String s) {
"""
Preprocess a string by finding tokens and giving them TFIDF weights
"""
lastVector = new UnitVector(s, tokenizer.tokenize(s));
return lastVector;
} | java | public StringWrapper prepare(String s) {
lastVector = new UnitVector(s, tokenizer.tokenize(s));
return lastVector;
} | [
"public",
"StringWrapper",
"prepare",
"(",
"String",
"s",
")",
"{",
"lastVector",
"=",
"new",
"UnitVector",
"(",
"s",
",",
"tokenizer",
".",
"tokenize",
"(",
"s",
")",
")",
";",
"return",
"lastVector",
";",
"}"
]
| Preprocess a string by finding tokens and giving them TFIDF weights | [
"Preprocess",
"a",
"string",
"by",
"finding",
"tokens",
"and",
"giving",
"them",
"TFIDF",
"weights"
]
| train | https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_abbreviations/src/main/java/com/wcohen/ss/TFIDF.java#L39-L42 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRPose.java | GVRPose.getWorldPosition | public void getWorldPosition(int boneindex, Vector3f pos) {
"""
Get the world position of the given bone (relative to skeleton root).
<p>
All bones in the skeleton start out at the origin oriented along the bone axis (usually 0,0,1).
The pose orients and positions each bone in the skeleton with respect to this initial state.
The world bone matrix expresses the orientation and position of the bone relative
to the root of the skeleton. This function gets the world space position of the designated bone.
@param boneindex index of bone whose position is wanted.
@return world position for the given bone.
@see #setWorldPositions
"""
Bone bone = mBones[boneindex];
int boneParent = mSkeleton.getParentBoneIndex(boneindex);
if ((boneParent >= 0) && ((bone.Changed & LOCAL_ROT) == LOCAL_ROT))
{
calcWorld(bone, boneParent);
}
pos.x = bone.WorldMatrix.m30();
pos.y = bone.WorldMatrix.m31();
pos.z = bone.WorldMatrix.m32();
} | java | public void getWorldPosition(int boneindex, Vector3f pos)
{
Bone bone = mBones[boneindex];
int boneParent = mSkeleton.getParentBoneIndex(boneindex);
if ((boneParent >= 0) && ((bone.Changed & LOCAL_ROT) == LOCAL_ROT))
{
calcWorld(bone, boneParent);
}
pos.x = bone.WorldMatrix.m30();
pos.y = bone.WorldMatrix.m31();
pos.z = bone.WorldMatrix.m32();
} | [
"public",
"void",
"getWorldPosition",
"(",
"int",
"boneindex",
",",
"Vector3f",
"pos",
")",
"{",
"Bone",
"bone",
"=",
"mBones",
"[",
"boneindex",
"]",
";",
"int",
"boneParent",
"=",
"mSkeleton",
".",
"getParentBoneIndex",
"(",
"boneindex",
")",
";",
"if",
"(",
"(",
"boneParent",
">=",
"0",
")",
"&&",
"(",
"(",
"bone",
".",
"Changed",
"&",
"LOCAL_ROT",
")",
"==",
"LOCAL_ROT",
")",
")",
"{",
"calcWorld",
"(",
"bone",
",",
"boneParent",
")",
";",
"}",
"pos",
".",
"x",
"=",
"bone",
".",
"WorldMatrix",
".",
"m30",
"(",
")",
";",
"pos",
".",
"y",
"=",
"bone",
".",
"WorldMatrix",
".",
"m31",
"(",
")",
";",
"pos",
".",
"z",
"=",
"bone",
".",
"WorldMatrix",
".",
"m32",
"(",
")",
";",
"}"
]
| Get the world position of the given bone (relative to skeleton root).
<p>
All bones in the skeleton start out at the origin oriented along the bone axis (usually 0,0,1).
The pose orients and positions each bone in the skeleton with respect to this initial state.
The world bone matrix expresses the orientation and position of the bone relative
to the root of the skeleton. This function gets the world space position of the designated bone.
@param boneindex index of bone whose position is wanted.
@return world position for the given bone.
@see #setWorldPositions | [
"Get",
"the",
"world",
"position",
"of",
"the",
"given",
"bone",
"(",
"relative",
"to",
"skeleton",
"root",
")",
".",
"<p",
">",
"All",
"bones",
"in",
"the",
"skeleton",
"start",
"out",
"at",
"the",
"origin",
"oriented",
"along",
"the",
"bone",
"axis",
"(",
"usually",
"0",
"0",
"1",
")",
".",
"The",
"pose",
"orients",
"and",
"positions",
"each",
"bone",
"in",
"the",
"skeleton",
"with",
"respect",
"to",
"this",
"initial",
"state",
".",
"The",
"world",
"bone",
"matrix",
"expresses",
"the",
"orientation",
"and",
"position",
"of",
"the",
"bone",
"relative",
"to",
"the",
"root",
"of",
"the",
"skeleton",
".",
"This",
"function",
"gets",
"the",
"world",
"space",
"position",
"of",
"the",
"designated",
"bone",
".",
"@param",
"boneindex",
"index",
"of",
"bone",
"whose",
"position",
"is",
"wanted",
".",
"@return",
"world",
"position",
"for",
"the",
"given",
"bone",
"."
]
| train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRPose.java#L158-L170 |
lucee/Lucee | core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java | ResourceUtil.getExtension | public static String getExtension(String strFile, String defaultValue) {
"""
get the Extension of a file
@param strFile
@return extension of file
"""
int pos = strFile.lastIndexOf('.');
if (pos == -1) return defaultValue;
return strFile.substring(pos + 1);
} | java | public static String getExtension(String strFile, String defaultValue) {
int pos = strFile.lastIndexOf('.');
if (pos == -1) return defaultValue;
return strFile.substring(pos + 1);
} | [
"public",
"static",
"String",
"getExtension",
"(",
"String",
"strFile",
",",
"String",
"defaultValue",
")",
"{",
"int",
"pos",
"=",
"strFile",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"pos",
"==",
"-",
"1",
")",
"return",
"defaultValue",
";",
"return",
"strFile",
".",
"substring",
"(",
"pos",
"+",
"1",
")",
";",
"}"
]
| get the Extension of a file
@param strFile
@return extension of file | [
"get",
"the",
"Extension",
"of",
"a",
"file"
]
| train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java#L850-L854 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/EnvironmentsInner.java | EnvironmentsInner.updateAsync | public Observable<EnvironmentInner> updateAsync(String resourceGroupName, String labAccountName, String labName, String environmentSettingName, String environmentName, EnvironmentFragment environment) {
"""
Modify properties of environments.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param environmentSettingName The name of the environment Setting.
@param environmentName The name of the environment.
@param environment Represents an environment instance
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the EnvironmentInner object
"""
return updateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, environment).map(new Func1<ServiceResponse<EnvironmentInner>, EnvironmentInner>() {
@Override
public EnvironmentInner call(ServiceResponse<EnvironmentInner> response) {
return response.body();
}
});
} | java | public Observable<EnvironmentInner> updateAsync(String resourceGroupName, String labAccountName, String labName, String environmentSettingName, String environmentName, EnvironmentFragment environment) {
return updateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, environment).map(new Func1<ServiceResponse<EnvironmentInner>, EnvironmentInner>() {
@Override
public EnvironmentInner call(ServiceResponse<EnvironmentInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"EnvironmentInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"labAccountName",
",",
"String",
"labName",
",",
"String",
"environmentSettingName",
",",
"String",
"environmentName",
",",
"EnvironmentFragment",
"environment",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"labAccountName",
",",
"labName",
",",
"environmentSettingName",
",",
"environmentName",
",",
"environment",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"EnvironmentInner",
">",
",",
"EnvironmentInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"EnvironmentInner",
"call",
"(",
"ServiceResponse",
"<",
"EnvironmentInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Modify properties of environments.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param environmentSettingName The name of the environment Setting.
@param environmentName The name of the environment.
@param environment Represents an environment instance
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the EnvironmentInner object | [
"Modify",
"properties",
"of",
"environments",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/EnvironmentsInner.java#L992-L999 |
goldmansachs/gs-collections | collections/src/main/java/com/gs/collections/impl/utility/StringIterate.java | StringIterate.collectChar | public static String collectChar(String string, CharToCharFunction function) {
"""
Transform the char elements to a new string using the specified function {@code function}.
@since 7.0
"""
int size = string.length();
StringBuilder builder = new StringBuilder(size);
for (int i = 0; i < size; i++)
{
builder.append(function.valueOf(string.charAt(i)));
}
return builder.toString();
} | java | public static String collectChar(String string, CharToCharFunction function)
{
int size = string.length();
StringBuilder builder = new StringBuilder(size);
for (int i = 0; i < size; i++)
{
builder.append(function.valueOf(string.charAt(i)));
}
return builder.toString();
} | [
"public",
"static",
"String",
"collectChar",
"(",
"String",
"string",
",",
"CharToCharFunction",
"function",
")",
"{",
"int",
"size",
"=",
"string",
".",
"length",
"(",
")",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"size",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"builder",
".",
"append",
"(",
"function",
".",
"valueOf",
"(",
"string",
".",
"charAt",
"(",
"i",
")",
")",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
]
| Transform the char elements to a new string using the specified function {@code function}.
@since 7.0 | [
"Transform",
"the",
"char",
"elements",
"to",
"a",
"new",
"string",
"using",
"the",
"specified",
"function",
"{",
"@code",
"function",
"}",
"."
]
| train | https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/utility/StringIterate.java#L588-L597 |
beangle/beangle3 | ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java | BeanDefinitionParser.parseConstructorArgElements | public void parseConstructorArgElements(Element beanEle, BeanDefinition bd) {
"""
Parse constructor-arg sub-elements of the given bean element.
@param beanEle a {@link org.w3c.dom.Element} object.
@param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object.
"""
NodeList nl = beanEle.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node node = nl.item(i);
if (node instanceof Element && nodeNameEquals(node, CONSTRUCTOR_ARG_ELEMENT))
parseConstructorArgElement((Element) node, bd);
}
} | java | public void parseConstructorArgElements(Element beanEle, BeanDefinition bd) {
NodeList nl = beanEle.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node node = nl.item(i);
if (node instanceof Element && nodeNameEquals(node, CONSTRUCTOR_ARG_ELEMENT))
parseConstructorArgElement((Element) node, bd);
}
} | [
"public",
"void",
"parseConstructorArgElements",
"(",
"Element",
"beanEle",
",",
"BeanDefinition",
"bd",
")",
"{",
"NodeList",
"nl",
"=",
"beanEle",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nl",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"node",
"=",
"nl",
".",
"item",
"(",
"i",
")",
";",
"if",
"(",
"node",
"instanceof",
"Element",
"&&",
"nodeNameEquals",
"(",
"node",
",",
"CONSTRUCTOR_ARG_ELEMENT",
")",
")",
"parseConstructorArgElement",
"(",
"(",
"Element",
")",
"node",
",",
"bd",
")",
";",
"}",
"}"
]
| Parse constructor-arg sub-elements of the given bean element.
@param beanEle a {@link org.w3c.dom.Element} object.
@param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object. | [
"Parse",
"constructor",
"-",
"arg",
"sub",
"-",
"elements",
"of",
"the",
"given",
"bean",
"element",
"."
]
| train | https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L377-L384 |
mongodb/stitch-android-sdk | core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/internal/CoreRemoteMongoDatabaseImpl.java | CoreRemoteMongoDatabaseImpl.getCollection | public <DocumentT> CoreRemoteMongoCollectionImpl<DocumentT> getCollection(
final String collectionName,
final Class<DocumentT> documentClass
) {
"""
Gets a collection, with a specific default document class.
@param collectionName the name of the collection to return
@param documentClass the default class to cast any documents returned from the database into.
@param <DocumentT> the type of the class to use instead of {@code Document}.
@return the collection
"""
return new CoreRemoteMongoCollectionImpl<>(
new MongoNamespace(name, collectionName),
documentClass,
service,
dataSynchronizer,
networkMonitor
);
} | java | public <DocumentT> CoreRemoteMongoCollectionImpl<DocumentT> getCollection(
final String collectionName,
final Class<DocumentT> documentClass
) {
return new CoreRemoteMongoCollectionImpl<>(
new MongoNamespace(name, collectionName),
documentClass,
service,
dataSynchronizer,
networkMonitor
);
} | [
"public",
"<",
"DocumentT",
">",
"CoreRemoteMongoCollectionImpl",
"<",
"DocumentT",
">",
"getCollection",
"(",
"final",
"String",
"collectionName",
",",
"final",
"Class",
"<",
"DocumentT",
">",
"documentClass",
")",
"{",
"return",
"new",
"CoreRemoteMongoCollectionImpl",
"<>",
"(",
"new",
"MongoNamespace",
"(",
"name",
",",
"collectionName",
")",
",",
"documentClass",
",",
"service",
",",
"dataSynchronizer",
",",
"networkMonitor",
")",
";",
"}"
]
| Gets a collection, with a specific default document class.
@param collectionName the name of the collection to return
@param documentClass the default class to cast any documents returned from the database into.
@param <DocumentT> the type of the class to use instead of {@code Document}.
@return the collection | [
"Gets",
"a",
"collection",
"with",
"a",
"specific",
"default",
"document",
"class",
"."
]
| train | https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/internal/CoreRemoteMongoDatabaseImpl.java#L79-L90 |
jOOQ/jOOL | jOOL-java-8/src/main/java/org/jooq/lambda/Agg.java | Agg.minAll | public static <T> Collector<T, ?, Seq<T>> minAll(Comparator<? super T> comparator) {
"""
Get a {@link Collector} that calculates the <code>MIN()</code> function, producing multiple results.
"""
return minAllBy(t -> t, comparator);
} | java | public static <T> Collector<T, ?, Seq<T>> minAll(Comparator<? super T> comparator) {
return minAllBy(t -> t, comparator);
} | [
"public",
"static",
"<",
"T",
">",
"Collector",
"<",
"T",
",",
"?",
",",
"Seq",
"<",
"T",
">",
">",
"minAll",
"(",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comparator",
")",
"{",
"return",
"minAllBy",
"(",
"t",
"->",
"t",
",",
"comparator",
")",
";",
"}"
]
| Get a {@link Collector} that calculates the <code>MIN()</code> function, producing multiple results. | [
"Get",
"a",
"{"
]
| train | https://github.com/jOOQ/jOOL/blob/889d87c85ca57bafd4eddd78e0f7ae2804d2ee86/jOOL-java-8/src/main/java/org/jooq/lambda/Agg.java#L228-L230 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/jql/JQLChecker.java | JQLChecker.extractColumnsToInsertOrUpdate | public Set<String> extractColumnsToInsertOrUpdate(final JQLContext jqlContext, String jqlValue, final Finder<SQLProperty> entity) {
"""
Extract columns to insert or update.
@param jqlContext
the jql context
@param jqlValue
the jql value
@param entity
the entity
@return the sets the
"""
final Set<String> result = new LinkedHashSet<String>();
final One<Boolean> selectionOn = new One<Boolean>(null);
final One<Boolean> insertOn = new One<Boolean>(null);
// Column_name_set is needed for insert
// Columns_to_update is needed for update
analyzeInternal(jqlContext, jqlValue, new JqlBaseListener() {
@Override
public void enterColumn_name_set(Column_name_setContext ctx) {
if (insertOn.value0 == null) {
insertOn.value0 = true;
}
}
@Override
public void exitColumn_name_set(Column_name_setContext ctx) {
insertOn.value0 = false;
}
@Override
public void enterColumns_to_update(Columns_to_updateContext ctx) {
if (selectionOn.value0 == null) {
selectionOn.value0 = true;
}
}
@Override
public void exitColumns_to_update(Columns_to_updateContext ctx) {
selectionOn.value0 = false;
}
@Override
public void enterColumn_name(Column_nameContext ctx) {
// works for INSERTS
if (insertOn.value0 != null && insertOn.value0 == true) {
result.add(ctx.getText());
}
}
@Override
public void enterColumn_name_to_update(Column_name_to_updateContext ctx) {
result.add(ctx.getText());
}
});
return result;
} | java | public Set<String> extractColumnsToInsertOrUpdate(final JQLContext jqlContext, String jqlValue, final Finder<SQLProperty> entity) {
final Set<String> result = new LinkedHashSet<String>();
final One<Boolean> selectionOn = new One<Boolean>(null);
final One<Boolean> insertOn = new One<Boolean>(null);
// Column_name_set is needed for insert
// Columns_to_update is needed for update
analyzeInternal(jqlContext, jqlValue, new JqlBaseListener() {
@Override
public void enterColumn_name_set(Column_name_setContext ctx) {
if (insertOn.value0 == null) {
insertOn.value0 = true;
}
}
@Override
public void exitColumn_name_set(Column_name_setContext ctx) {
insertOn.value0 = false;
}
@Override
public void enterColumns_to_update(Columns_to_updateContext ctx) {
if (selectionOn.value0 == null) {
selectionOn.value0 = true;
}
}
@Override
public void exitColumns_to_update(Columns_to_updateContext ctx) {
selectionOn.value0 = false;
}
@Override
public void enterColumn_name(Column_nameContext ctx) {
// works for INSERTS
if (insertOn.value0 != null && insertOn.value0 == true) {
result.add(ctx.getText());
}
}
@Override
public void enterColumn_name_to_update(Column_name_to_updateContext ctx) {
result.add(ctx.getText());
}
});
return result;
} | [
"public",
"Set",
"<",
"String",
">",
"extractColumnsToInsertOrUpdate",
"(",
"final",
"JQLContext",
"jqlContext",
",",
"String",
"jqlValue",
",",
"final",
"Finder",
"<",
"SQLProperty",
">",
"entity",
")",
"{",
"final",
"Set",
"<",
"String",
">",
"result",
"=",
"new",
"LinkedHashSet",
"<",
"String",
">",
"(",
")",
";",
"final",
"One",
"<",
"Boolean",
">",
"selectionOn",
"=",
"new",
"One",
"<",
"Boolean",
">",
"(",
"null",
")",
";",
"final",
"One",
"<",
"Boolean",
">",
"insertOn",
"=",
"new",
"One",
"<",
"Boolean",
">",
"(",
"null",
")",
";",
"// Column_name_set is needed for insert",
"// Columns_to_update is needed for update",
"analyzeInternal",
"(",
"jqlContext",
",",
"jqlValue",
",",
"new",
"JqlBaseListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"enterColumn_name_set",
"(",
"Column_name_setContext",
"ctx",
")",
"{",
"if",
"(",
"insertOn",
".",
"value0",
"==",
"null",
")",
"{",
"insertOn",
".",
"value0",
"=",
"true",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"exitColumn_name_set",
"(",
"Column_name_setContext",
"ctx",
")",
"{",
"insertOn",
".",
"value0",
"=",
"false",
";",
"}",
"@",
"Override",
"public",
"void",
"enterColumns_to_update",
"(",
"Columns_to_updateContext",
"ctx",
")",
"{",
"if",
"(",
"selectionOn",
".",
"value0",
"==",
"null",
")",
"{",
"selectionOn",
".",
"value0",
"=",
"true",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"exitColumns_to_update",
"(",
"Columns_to_updateContext",
"ctx",
")",
"{",
"selectionOn",
".",
"value0",
"=",
"false",
";",
"}",
"@",
"Override",
"public",
"void",
"enterColumn_name",
"(",
"Column_nameContext",
"ctx",
")",
"{",
"// works for INSERTS",
"if",
"(",
"insertOn",
".",
"value0",
"!=",
"null",
"&&",
"insertOn",
".",
"value0",
"==",
"true",
")",
"{",
"result",
".",
"add",
"(",
"ctx",
".",
"getText",
"(",
")",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"enterColumn_name_to_update",
"(",
"Column_name_to_updateContext",
"ctx",
")",
"{",
"result",
".",
"add",
"(",
"ctx",
".",
"getText",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
";",
"}"
]
| Extract columns to insert or update.
@param jqlContext
the jql context
@param jqlValue
the jql value
@param entity
the entity
@return the sets the | [
"Extract",
"columns",
"to",
"insert",
"or",
"update",
"."
]
| train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/jql/JQLChecker.java#L330-L380 |
liferay/com-liferay-commerce | commerce-notification-api/src/main/java/com/liferay/commerce/notification/model/CommerceNotificationTemplateWrapper.java | CommerceNotificationTemplateWrapper.setSubjectMap | @Override
public void setSubjectMap(Map<java.util.Locale, String> subjectMap) {
"""
Sets the localized subjects of this commerce notification template from the map of locales and localized subjects.
@param subjectMap the locales and localized subjects of this commerce notification template
"""
_commerceNotificationTemplate.setSubjectMap(subjectMap);
} | java | @Override
public void setSubjectMap(Map<java.util.Locale, String> subjectMap) {
_commerceNotificationTemplate.setSubjectMap(subjectMap);
} | [
"@",
"Override",
"public",
"void",
"setSubjectMap",
"(",
"Map",
"<",
"java",
".",
"util",
".",
"Locale",
",",
"String",
">",
"subjectMap",
")",
"{",
"_commerceNotificationTemplate",
".",
"setSubjectMap",
"(",
"subjectMap",
")",
";",
"}"
]
| Sets the localized subjects of this commerce notification template from the map of locales and localized subjects.
@param subjectMap the locales and localized subjects of this commerce notification template | [
"Sets",
"the",
"localized",
"subjects",
"of",
"this",
"commerce",
"notification",
"template",
"from",
"the",
"map",
"of",
"locales",
"and",
"localized",
"subjects",
"."
]
| train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-notification-api/src/main/java/com/liferay/commerce/notification/model/CommerceNotificationTemplateWrapper.java#L996-L999 |
spring-projects/spring-android | spring-android-rest-template/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java | HttpComponentsClientHttpRequestFactory.createHttpUriRequest | protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
"""
Create a Commons HttpMethodBase object for the given HTTP method and URI
specification.
@param httpMethod the HTTP method
@param uri the URI
@return the Commons HttpMethodBase object
"""
switch (httpMethod) {
case GET:
return new HttpGetHC4(uri);
case DELETE:
return new HttpDeleteHC4(uri);
case HEAD:
return new HttpHeadHC4(uri);
case OPTIONS:
return new HttpOptionsHC4(uri);
case POST:
return new HttpPostHC4(uri);
case PUT:
return new HttpPutHC4(uri);
case TRACE:
return new HttpTraceHC4(uri);
case PATCH:
return new HttpPatch(uri);
default:
throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
}
} | java | protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
switch (httpMethod) {
case GET:
return new HttpGetHC4(uri);
case DELETE:
return new HttpDeleteHC4(uri);
case HEAD:
return new HttpHeadHC4(uri);
case OPTIONS:
return new HttpOptionsHC4(uri);
case POST:
return new HttpPostHC4(uri);
case PUT:
return new HttpPutHC4(uri);
case TRACE:
return new HttpTraceHC4(uri);
case PATCH:
return new HttpPatch(uri);
default:
throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
}
} | [
"protected",
"HttpUriRequest",
"createHttpUriRequest",
"(",
"HttpMethod",
"httpMethod",
",",
"URI",
"uri",
")",
"{",
"switch",
"(",
"httpMethod",
")",
"{",
"case",
"GET",
":",
"return",
"new",
"HttpGetHC4",
"(",
"uri",
")",
";",
"case",
"DELETE",
":",
"return",
"new",
"HttpDeleteHC4",
"(",
"uri",
")",
";",
"case",
"HEAD",
":",
"return",
"new",
"HttpHeadHC4",
"(",
"uri",
")",
";",
"case",
"OPTIONS",
":",
"return",
"new",
"HttpOptionsHC4",
"(",
"uri",
")",
";",
"case",
"POST",
":",
"return",
"new",
"HttpPostHC4",
"(",
"uri",
")",
";",
"case",
"PUT",
":",
"return",
"new",
"HttpPutHC4",
"(",
"uri",
")",
";",
"case",
"TRACE",
":",
"return",
"new",
"HttpTraceHC4",
"(",
"uri",
")",
";",
"case",
"PATCH",
":",
"return",
"new",
"HttpPatch",
"(",
"uri",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid HTTP method: \"",
"+",
"httpMethod",
")",
";",
"}",
"}"
]
| Create a Commons HttpMethodBase object for the given HTTP method and URI
specification.
@param httpMethod the HTTP method
@param uri the URI
@return the Commons HttpMethodBase object | [
"Create",
"a",
"Commons",
"HttpMethodBase",
"object",
"for",
"the",
"given",
"HTTP",
"method",
"and",
"URI",
"specification",
"."
]
| train | https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-rest-template/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java#L226-L247 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/parser/JSParser.java | JSParser.addRef | private static void addRef(Map refs, String key, JSDynamic unres) {
"""
Subroutine to enter a dangling "expected" reference in the refs map
"""
List thisKey = (List) refs.get(key);
if (thisKey == null) {
thisKey = new ArrayList();
refs.put(key, thisKey);
}
thisKey.add(unres);
} | java | private static void addRef(Map refs, String key, JSDynamic unres) {
List thisKey = (List) refs.get(key);
if (thisKey == null) {
thisKey = new ArrayList();
refs.put(key, thisKey);
}
thisKey.add(unres);
} | [
"private",
"static",
"void",
"addRef",
"(",
"Map",
"refs",
",",
"String",
"key",
",",
"JSDynamic",
"unres",
")",
"{",
"List",
"thisKey",
"=",
"(",
"List",
")",
"refs",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"thisKey",
"==",
"null",
")",
"{",
"thisKey",
"=",
"new",
"ArrayList",
"(",
")",
";",
"refs",
".",
"put",
"(",
"key",
",",
"thisKey",
")",
";",
"}",
"thisKey",
".",
"add",
"(",
"unres",
")",
";",
"}"
]
| Subroutine to enter a dangling "expected" reference in the refs map | [
"Subroutine",
"to",
"enter",
"a",
"dangling",
"expected",
"reference",
"in",
"the",
"refs",
"map"
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/parser/JSParser.java#L111-L118 |
jbundle/jbundle | base/message/trx/src/main/java/org/jbundle/base/message/trx/message/external/convert/jaxb/JaxbConvertToMessage.java | JaxbConvertToMessage.unmarshalRootElement | public Object unmarshalRootElement(Reader inStream, BaseXmlTrxMessageIn soapTrxMessage) throws Exception {
"""
Create the root element for this message.
You must override this.
@return The root element.
"""
try {
// create a JAXBContext capable of handling classes generated into
// the primer.po package
String strSOAPPackage = (String)((TrxMessageHeader)soapTrxMessage.getMessage().getMessageHeader()).get(SOAPMessageTransport.SOAP_PACKAGE);
if (strSOAPPackage != null)
{
Object obj = null;
Unmarshaller u = JaxbContexts.getJAXBContexts().getUnmarshaller(strSOAPPackage);
if (u == null)
return null;
synchronized(u)
{ // Since the marshaller is shared (may want to tweek this for multi-cpu implementations)
obj = u.unmarshal( inStream );
}
return obj;
}
//+ } catch (XMLStreamException ex) {
//+ ex.printStackTrace();
} catch (JAXBException ex) {
ex.printStackTrace();
}
return null;
} | java | public Object unmarshalRootElement(Reader inStream, BaseXmlTrxMessageIn soapTrxMessage) throws Exception
{
try {
// create a JAXBContext capable of handling classes generated into
// the primer.po package
String strSOAPPackage = (String)((TrxMessageHeader)soapTrxMessage.getMessage().getMessageHeader()).get(SOAPMessageTransport.SOAP_PACKAGE);
if (strSOAPPackage != null)
{
Object obj = null;
Unmarshaller u = JaxbContexts.getJAXBContexts().getUnmarshaller(strSOAPPackage);
if (u == null)
return null;
synchronized(u)
{ // Since the marshaller is shared (may want to tweek this for multi-cpu implementations)
obj = u.unmarshal( inStream );
}
return obj;
}
//+ } catch (XMLStreamException ex) {
//+ ex.printStackTrace();
} catch (JAXBException ex) {
ex.printStackTrace();
}
return null;
} | [
"public",
"Object",
"unmarshalRootElement",
"(",
"Reader",
"inStream",
",",
"BaseXmlTrxMessageIn",
"soapTrxMessage",
")",
"throws",
"Exception",
"{",
"try",
"{",
"// create a JAXBContext capable of handling classes generated into",
"// the primer.po package",
"String",
"strSOAPPackage",
"=",
"(",
"String",
")",
"(",
"(",
"TrxMessageHeader",
")",
"soapTrxMessage",
".",
"getMessage",
"(",
")",
".",
"getMessageHeader",
"(",
")",
")",
".",
"get",
"(",
"SOAPMessageTransport",
".",
"SOAP_PACKAGE",
")",
";",
"if",
"(",
"strSOAPPackage",
"!=",
"null",
")",
"{",
"Object",
"obj",
"=",
"null",
";",
"Unmarshaller",
"u",
"=",
"JaxbContexts",
".",
"getJAXBContexts",
"(",
")",
".",
"getUnmarshaller",
"(",
"strSOAPPackage",
")",
";",
"if",
"(",
"u",
"==",
"null",
")",
"return",
"null",
";",
"synchronized",
"(",
"u",
")",
"{",
"// Since the marshaller is shared (may want to tweek this for multi-cpu implementations)",
"obj",
"=",
"u",
".",
"unmarshal",
"(",
"inStream",
")",
";",
"}",
"return",
"obj",
";",
"}",
"//+ } catch (XMLStreamException ex) {",
"//+ ex.printStackTrace();",
"}",
"catch",
"(",
"JAXBException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Create the root element for this message.
You must override this.
@return The root element. | [
"Create",
"the",
"root",
"element",
"for",
"this",
"message",
".",
"You",
"must",
"override",
"this",
"."
]
| train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/trx/src/main/java/org/jbundle/base/message/trx/message/external/convert/jaxb/JaxbConvertToMessage.java#L67-L93 |
jroyalty/jglm | src/main/java/com/hackoeur/jglm/support/Precision.java | Precision.compareTo | public static int compareTo(final double x, final double y, final int maxUlps) {
"""
Compares two numbers given some amount of allowed error.
Two float numbers are considered equal if there are {@code (maxUlps - 1)}
(or fewer) floating point numbers between them, i.e. two adjacent floating
point numbers are considered equal.
Adapted from <a
href="http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm">
Bruce Dawson</a>
@param x first value
@param y second value
@param maxUlps {@code (maxUlps - 1)} is the number of floating point
values between {@code x} and {@code y}.
@return <ul><li>0 if {@link #equals(double, double, int) equals(x, y, maxUlps)}</li>
<li>< 0 if !{@link #equals(double, double, int) equals(x, y, maxUlps)} && x < y</li>
<li>> 0 if !{@link #equals(double, double, int) equals(x, y, maxUlps)} && x > y</li></ul>
"""
if (equals(x, y, maxUlps)) {
return 0;
} else if (x < y) {
return -1;
}
return 1;
} | java | public static int compareTo(final double x, final double y, final int maxUlps) {
if (equals(x, y, maxUlps)) {
return 0;
} else if (x < y) {
return -1;
}
return 1;
} | [
"public",
"static",
"int",
"compareTo",
"(",
"final",
"double",
"x",
",",
"final",
"double",
"y",
",",
"final",
"int",
"maxUlps",
")",
"{",
"if",
"(",
"equals",
"(",
"x",
",",
"y",
",",
"maxUlps",
")",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"x",
"<",
"y",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"1",
";",
"}"
]
| Compares two numbers given some amount of allowed error.
Two float numbers are considered equal if there are {@code (maxUlps - 1)}
(or fewer) floating point numbers between them, i.e. two adjacent floating
point numbers are considered equal.
Adapted from <a
href="http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm">
Bruce Dawson</a>
@param x first value
@param y second value
@param maxUlps {@code (maxUlps - 1)} is the number of floating point
values between {@code x} and {@code y}.
@return <ul><li>0 if {@link #equals(double, double, int) equals(x, y, maxUlps)}</li>
<li>< 0 if !{@link #equals(double, double, int) equals(x, y, maxUlps)} && x < y</li>
<li>> 0 if !{@link #equals(double, double, int) equals(x, y, maxUlps)} && x > y</li></ul> | [
"Compares",
"two",
"numbers",
"given",
"some",
"amount",
"of",
"allowed",
"error",
".",
"Two",
"float",
"numbers",
"are",
"considered",
"equal",
"if",
"there",
"are",
"{",
"@code",
"(",
"maxUlps",
"-",
"1",
")",
"}",
"(",
"or",
"fewer",
")",
"floating",
"point",
"numbers",
"between",
"them",
"i",
".",
"e",
".",
"two",
"adjacent",
"floating",
"point",
"numbers",
"are",
"considered",
"equal",
".",
"Adapted",
"from",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"cygnus",
"-",
"software",
".",
"com",
"/",
"papers",
"/",
"comparingfloats",
"/",
"comparingfloats",
".",
"htm",
">",
"Bruce",
"Dawson<",
"/",
"a",
">"
]
| train | https://github.com/jroyalty/jglm/blob/9397c2fcf0d4d62844c64d0b14065ee7bf8cafc6/src/main/java/com/hackoeur/jglm/support/Precision.java#L117-L124 |
cdk/cdk | base/standard/src/main/java/org/openscience/cdk/fingerprint/FingerprinterTool.java | FingerprinterTool.isSubset | public static boolean isSubset(BitSet bs1, BitSet bs2) {
"""
Checks whether all the positive bits in BitSet bs2 occur in BitSet bs1. If
so, the molecular structure from which bs2 was generated is a possible
substructure of bs1. <p>
Example: <pre>
Molecule mol = MoleculeFactory.makeIndole();
BitSet bs = Fingerprinter.getBitFingerprint(mol);
Molecule frag1 = MoleculeFactory.makePyrrole();
BitSet bs1 = Fingerprinter.getBitFingerprint(frag1);
if (Fingerprinter.isSubset(bs, bs1)) {
System.out.println("Pyrrole is subset of Indole.");
}
</pre>
@param bs1 The reference BitSet
@param bs2 The BitSet which is compared with bs1
@return True, if bs2 is a subset of bs1
@cdk.keyword substructure search
"""
BitSet clone = (BitSet) bs1.clone();
clone.and(bs2);
if (clone.equals(bs2)) {
return true;
}
return false;
} | java | public static boolean isSubset(BitSet bs1, BitSet bs2) {
BitSet clone = (BitSet) bs1.clone();
clone.and(bs2);
if (clone.equals(bs2)) {
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"isSubset",
"(",
"BitSet",
"bs1",
",",
"BitSet",
"bs2",
")",
"{",
"BitSet",
"clone",
"=",
"(",
"BitSet",
")",
"bs1",
".",
"clone",
"(",
")",
";",
"clone",
".",
"and",
"(",
"bs2",
")",
";",
"if",
"(",
"clone",
".",
"equals",
"(",
"bs2",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Checks whether all the positive bits in BitSet bs2 occur in BitSet bs1. If
so, the molecular structure from which bs2 was generated is a possible
substructure of bs1. <p>
Example: <pre>
Molecule mol = MoleculeFactory.makeIndole();
BitSet bs = Fingerprinter.getBitFingerprint(mol);
Molecule frag1 = MoleculeFactory.makePyrrole();
BitSet bs1 = Fingerprinter.getBitFingerprint(frag1);
if (Fingerprinter.isSubset(bs, bs1)) {
System.out.println("Pyrrole is subset of Indole.");
}
</pre>
@param bs1 The reference BitSet
@param bs2 The BitSet which is compared with bs1
@return True, if bs2 is a subset of bs1
@cdk.keyword substructure search | [
"Checks",
"whether",
"all",
"the",
"positive",
"bits",
"in",
"BitSet",
"bs2",
"occur",
"in",
"BitSet",
"bs1",
".",
"If",
"so",
"the",
"molecular",
"structure",
"from",
"which",
"bs2",
"was",
"generated",
"is",
"a",
"possible",
"substructure",
"of",
"bs1",
".",
"<p",
">"
]
| train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/standard/src/main/java/org/openscience/cdk/fingerprint/FingerprinterTool.java#L70-L77 |
actorapp/actor-platform | actor-sdk/sdk-core-android/android-sdk/src/main/java/android/support/v7/widget/ChatLinearLayoutManager.java | ChatLinearLayoutManager.findFirstVisibleChildClosestToStart | private View findFirstVisibleChildClosestToStart(boolean completelyVisible,
boolean acceptPartiallyVisible) {
"""
Convenience method to find the visible child closes to start. Caller should check if it has
enough children.
@param completelyVisible Whether child should be completely visible or not
@return The first visible child closest to start of the layout from user's perspective.
"""
if (mShouldReverseLayout) {
return findOneVisibleChild(getChildCount() - 1, -1, completelyVisible,
acceptPartiallyVisible);
} else {
return findOneVisibleChild(0, getChildCount(), completelyVisible,
acceptPartiallyVisible);
}
} | java | private View findFirstVisibleChildClosestToStart(boolean completelyVisible,
boolean acceptPartiallyVisible) {
if (mShouldReverseLayout) {
return findOneVisibleChild(getChildCount() - 1, -1, completelyVisible,
acceptPartiallyVisible);
} else {
return findOneVisibleChild(0, getChildCount(), completelyVisible,
acceptPartiallyVisible);
}
} | [
"private",
"View",
"findFirstVisibleChildClosestToStart",
"(",
"boolean",
"completelyVisible",
",",
"boolean",
"acceptPartiallyVisible",
")",
"{",
"if",
"(",
"mShouldReverseLayout",
")",
"{",
"return",
"findOneVisibleChild",
"(",
"getChildCount",
"(",
")",
"-",
"1",
",",
"-",
"1",
",",
"completelyVisible",
",",
"acceptPartiallyVisible",
")",
";",
"}",
"else",
"{",
"return",
"findOneVisibleChild",
"(",
"0",
",",
"getChildCount",
"(",
")",
",",
"completelyVisible",
",",
"acceptPartiallyVisible",
")",
";",
"}",
"}"
]
| Convenience method to find the visible child closes to start. Caller should check if it has
enough children.
@param completelyVisible Whether child should be completely visible or not
@return The first visible child closest to start of the layout from user's perspective. | [
"Convenience",
"method",
"to",
"find",
"the",
"visible",
"child",
"closes",
"to",
"start",
".",
"Caller",
"should",
"check",
"if",
"it",
"has",
"enough",
"children",
"."
]
| train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core-android/android-sdk/src/main/java/android/support/v7/widget/ChatLinearLayoutManager.java#L1489-L1498 |
dadoonet/fscrawler | elasticsearch-client/elasticsearch-client-base/src/main/java/fr/pilato/elasticsearch/crawler/fs/client/ElasticsearchClientUtil.java | ElasticsearchClientUtil.getInstance | public static ElasticsearchClient getInstance(Path config, FsSettings settings) {
"""
Try to find a client version in the classpath
@param config Path to FSCrawler configuration files (elasticsearch templates)
@param settings FSCrawler settings. Can not be null.
@return A Client instance
"""
Objects.requireNonNull(settings, "settings can not be null");
for (int i = 7; i >= 1; i--) {
logger.debug("Trying to find a client version {}", i);
try {
return getInstance(config, settings, i);
} catch (ClassNotFoundException ignored) {
}
}
throw new IllegalArgumentException("Can not find any ElasticsearchClient in the classpath. " +
"Did you forget to add the elasticsearch client library?");
} | java | public static ElasticsearchClient getInstance(Path config, FsSettings settings) {
Objects.requireNonNull(settings, "settings can not be null");
for (int i = 7; i >= 1; i--) {
logger.debug("Trying to find a client version {}", i);
try {
return getInstance(config, settings, i);
} catch (ClassNotFoundException ignored) {
}
}
throw new IllegalArgumentException("Can not find any ElasticsearchClient in the classpath. " +
"Did you forget to add the elasticsearch client library?");
} | [
"public",
"static",
"ElasticsearchClient",
"getInstance",
"(",
"Path",
"config",
",",
"FsSettings",
"settings",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"settings",
",",
"\"settings can not be null\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"7",
";",
"i",
">=",
"1",
";",
"i",
"--",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Trying to find a client version {}\"",
",",
"i",
")",
";",
"try",
"{",
"return",
"getInstance",
"(",
"config",
",",
"settings",
",",
"i",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"ignored",
")",
"{",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can not find any ElasticsearchClient in the classpath. \"",
"+",
"\"Did you forget to add the elasticsearch client library?\"",
")",
";",
"}"
]
| Try to find a client version in the classpath
@param config Path to FSCrawler configuration files (elasticsearch templates)
@param settings FSCrawler settings. Can not be null.
@return A Client instance | [
"Try",
"to",
"find",
"a",
"client",
"version",
"in",
"the",
"classpath"
]
| train | https://github.com/dadoonet/fscrawler/blob/cca00a14e21ef9986aa30e19b160463aed6bf921/elasticsearch-client/elasticsearch-client-base/src/main/java/fr/pilato/elasticsearch/crawler/fs/client/ElasticsearchClientUtil.java#L45-L60 |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapMultiPoint.java | MapMultiPoint.intersects | @Override
@Pure
public boolean intersects(Shape2D<?, ?, ?, ?, ?, ? extends Rectangle2afp<?, ?, ?, ?, ?, ?>> rectangle) {
"""
Replies if this element has an intersection
with the specified rectangle.
@return <code>true</code> if this MapElement is intersecting the specified area,
otherwise <code>false</code>
"""
if (boundsIntersects(rectangle)) {
for (final PointGroup grp : groups()) {
for (final Point2d pts : grp) {
if (rectangle.contains(pts)) {
return true;
}
}
}
}
return false;
} | java | @Override
@Pure
public boolean intersects(Shape2D<?, ?, ?, ?, ?, ? extends Rectangle2afp<?, ?, ?, ?, ?, ?>> rectangle) {
if (boundsIntersects(rectangle)) {
for (final PointGroup grp : groups()) {
for (final Point2d pts : grp) {
if (rectangle.contains(pts)) {
return true;
}
}
}
}
return false;
} | [
"@",
"Override",
"@",
"Pure",
"public",
"boolean",
"intersects",
"(",
"Shape2D",
"<",
"?",
",",
"?",
",",
"?",
",",
"?",
",",
"?",
",",
"?",
"extends",
"Rectangle2afp",
"<",
"?",
",",
"?",
",",
"?",
",",
"?",
",",
"?",
",",
"?",
">",
">",
"rectangle",
")",
"{",
"if",
"(",
"boundsIntersects",
"(",
"rectangle",
")",
")",
"{",
"for",
"(",
"final",
"PointGroup",
"grp",
":",
"groups",
"(",
")",
")",
"{",
"for",
"(",
"final",
"Point2d",
"pts",
":",
"grp",
")",
"{",
"if",
"(",
"rectangle",
".",
"contains",
"(",
"pts",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}",
"return",
"false",
";",
"}"
]
| Replies if this element has an intersection
with the specified rectangle.
@return <code>true</code> if this MapElement is intersecting the specified area,
otherwise <code>false</code> | [
"Replies",
"if",
"this",
"element",
"has",
"an",
"intersection",
"with",
"the",
"specified",
"rectangle",
"."
]
| train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapMultiPoint.java#L106-L119 |
aws/aws-sdk-java | aws-java-sdk-sns/src/main/java/com/amazonaws/services/sns/model/GetSMSAttributesResult.java | GetSMSAttributesResult.withAttributes | public GetSMSAttributesResult withAttributes(java.util.Map<String, String> attributes) {
"""
<p>
The SMS attribute names and their values.
</p>
@param attributes
The SMS attribute names and their values.
@return Returns a reference to this object so that method calls can be chained together.
"""
setAttributes(attributes);
return this;
} | java | public GetSMSAttributesResult withAttributes(java.util.Map<String, String> attributes) {
setAttributes(attributes);
return this;
} | [
"public",
"GetSMSAttributesResult",
"withAttributes",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"attributes",
")",
"{",
"setAttributes",
"(",
"attributes",
")",
";",
"return",
"this",
";",
"}"
]
| <p>
The SMS attribute names and their values.
</p>
@param attributes
The SMS attribute names and their values.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"SMS",
"attribute",
"names",
"and",
"their",
"values",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-sns/src/main/java/com/amazonaws/services/sns/model/GetSMSAttributesResult.java#L74-L77 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.downto | public static void downto(Float self, Number to, @ClosureParams(FirstParam.class) Closure closure) {
"""
Iterates from this number down to the given number, inclusive,
decrementing by one each time.
@param self a Float
@param to the end number
@param closure the code to execute for each number
@since 1.0
"""
float to1 = to.floatValue();
if (self >= to1) {
for (float i = self; i >= to1; i--) {
closure.call(i);
}
} else
throw new GroovyRuntimeException("The argument (" + to +
") to downto() cannot be greater than the value (" + self + ") it's called on."); } | java | public static void downto(Float self, Number to, @ClosureParams(FirstParam.class) Closure closure) {
float to1 = to.floatValue();
if (self >= to1) {
for (float i = self; i >= to1; i--) {
closure.call(i);
}
} else
throw new GroovyRuntimeException("The argument (" + to +
") to downto() cannot be greater than the value (" + self + ") it's called on."); } | [
"public",
"static",
"void",
"downto",
"(",
"Float",
"self",
",",
"Number",
"to",
",",
"@",
"ClosureParams",
"(",
"FirstParam",
".",
"class",
")",
"Closure",
"closure",
")",
"{",
"float",
"to1",
"=",
"to",
".",
"floatValue",
"(",
")",
";",
"if",
"(",
"self",
">=",
"to1",
")",
"{",
"for",
"(",
"float",
"i",
"=",
"self",
";",
"i",
">=",
"to1",
";",
"i",
"--",
")",
"{",
"closure",
".",
"call",
"(",
"i",
")",
";",
"}",
"}",
"else",
"throw",
"new",
"GroovyRuntimeException",
"(",
"\"The argument (\"",
"+",
"to",
"+",
"\") to downto() cannot be greater than the value (\"",
"+",
"self",
"+",
"\") it's called on.\"",
")",
";",
"}"
]
| Iterates from this number down to the given number, inclusive,
decrementing by one each time.
@param self a Float
@param to the end number
@param closure the code to execute for each number
@since 1.0 | [
"Iterates",
"from",
"this",
"number",
"down",
"to",
"the",
"given",
"number",
"inclusive",
"decrementing",
"by",
"one",
"each",
"time",
"."
]
| train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L15928-L15936 |
TrueNight/Utils | android-utils/src/main/java/xyz/truenight/utils/PermissionRequest.java | PermissionRequest.getPermission | public static void getPermission(@NonNull Activity context, @NonNull String[] permissions, @NonNull Response response) {
"""
Request Android Permissions.
@param context The Context of the Activity or the Fragment.
@param permissions The Permissions you are need.
@param response Result callback.
"""
if (Build.VERSION.SDK_INT < 23) {
response.permissionGranted();
} else {
HashSet<String> permissionSet = new HashSet<>();
for (String permission : permissions)
if (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
permissionSet.add(permission);
}
if (permissionSet.size() > 0) {
int id = 42167;
while (map.containsKey(id))
id = random.nextInt(Short.MAX_VALUE * 2);
map.put(id, new ResponseWrapper(response, permissions));
context.requestPermissions(permissionSet.toArray(new String[permissionSet.size()]), id);
} else {
response.permissionGranted();
}
}
} | java | public static void getPermission(@NonNull Activity context, @NonNull String[] permissions, @NonNull Response response) {
if (Build.VERSION.SDK_INT < 23) {
response.permissionGranted();
} else {
HashSet<String> permissionSet = new HashSet<>();
for (String permission : permissions)
if (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
permissionSet.add(permission);
}
if (permissionSet.size() > 0) {
int id = 42167;
while (map.containsKey(id))
id = random.nextInt(Short.MAX_VALUE * 2);
map.put(id, new ResponseWrapper(response, permissions));
context.requestPermissions(permissionSet.toArray(new String[permissionSet.size()]), id);
} else {
response.permissionGranted();
}
}
} | [
"public",
"static",
"void",
"getPermission",
"(",
"@",
"NonNull",
"Activity",
"context",
",",
"@",
"NonNull",
"String",
"[",
"]",
"permissions",
",",
"@",
"NonNull",
"Response",
"response",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
"<",
"23",
")",
"{",
"response",
".",
"permissionGranted",
"(",
")",
";",
"}",
"else",
"{",
"HashSet",
"<",
"String",
">",
"permissionSet",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"permission",
":",
"permissions",
")",
"if",
"(",
"ContextCompat",
".",
"checkSelfPermission",
"(",
"context",
",",
"permission",
")",
"!=",
"PackageManager",
".",
"PERMISSION_GRANTED",
")",
"{",
"permissionSet",
".",
"add",
"(",
"permission",
")",
";",
"}",
"if",
"(",
"permissionSet",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"int",
"id",
"=",
"42167",
";",
"while",
"(",
"map",
".",
"containsKey",
"(",
"id",
")",
")",
"id",
"=",
"random",
".",
"nextInt",
"(",
"Short",
".",
"MAX_VALUE",
"*",
"2",
")",
";",
"map",
".",
"put",
"(",
"id",
",",
"new",
"ResponseWrapper",
"(",
"response",
",",
"permissions",
")",
")",
";",
"context",
".",
"requestPermissions",
"(",
"permissionSet",
".",
"toArray",
"(",
"new",
"String",
"[",
"permissionSet",
".",
"size",
"(",
")",
"]",
")",
",",
"id",
")",
";",
"}",
"else",
"{",
"response",
".",
"permissionGranted",
"(",
")",
";",
"}",
"}",
"}"
]
| Request Android Permissions.
@param context The Context of the Activity or the Fragment.
@param permissions The Permissions you are need.
@param response Result callback. | [
"Request",
"Android",
"Permissions",
"."
]
| train | https://github.com/TrueNight/Utils/blob/78a11faa16258b09f08826797370310ab650530c/android-utils/src/main/java/xyz/truenight/utils/PermissionRequest.java#L137-L161 |
aoindustries/ao-encoding | src/main/java/com/aoindustries/encoding/ChainWriter.java | ChainWriter.writeTimeJavaScript | public ChainWriter writeTimeJavaScript(Date date, Sequence sequence, Appendable scriptOut) throws IOException {
"""
Writes a JavaScript script tag that a time in the user's locale. Prints <code>&#160;</code>
if the date is <code>null</code>.
Writes to the internal <code>PrintWriter</code>.
@see #writeTimeJavaScript(long,Appendable)
"""
writeTimeJavaScript(date, sequence, out, scriptOut);
return this;
} | java | public ChainWriter writeTimeJavaScript(Date date, Sequence sequence, Appendable scriptOut) throws IOException {
writeTimeJavaScript(date, sequence, out, scriptOut);
return this;
} | [
"public",
"ChainWriter",
"writeTimeJavaScript",
"(",
"Date",
"date",
",",
"Sequence",
"sequence",
",",
"Appendable",
"scriptOut",
")",
"throws",
"IOException",
"{",
"writeTimeJavaScript",
"(",
"date",
",",
"sequence",
",",
"out",
",",
"scriptOut",
")",
";",
"return",
"this",
";",
"}"
]
| Writes a JavaScript script tag that a time in the user's locale. Prints <code>&#160;</code>
if the date is <code>null</code>.
Writes to the internal <code>PrintWriter</code>.
@see #writeTimeJavaScript(long,Appendable) | [
"Writes",
"a",
"JavaScript",
"script",
"tag",
"that",
"a",
"time",
"in",
"the",
"user",
"s",
"locale",
".",
"Prints",
"<code",
">",
"&",
";",
"#160",
";",
"<",
"/",
"code",
">",
"if",
"the",
"date",
"is",
"<code",
">",
"null<",
"/",
"code",
">",
".",
"Writes",
"to",
"the",
"internal",
"<code",
">",
"PrintWriter<",
"/",
"code",
">",
"."
]
| train | https://github.com/aoindustries/ao-encoding/blob/54eeb8ff58ab7b44bb02549bbe2572625b449e4e/src/main/java/com/aoindustries/encoding/ChainWriter.java#L973-L976 |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/RowCursor.java | RowCursor.setObject | public void setObject(int index, Object value) {
"""
/*
public void setObject(int index, Object value)
{
try (OutputStream os = openOutputStream(index)) {
try (OutH3 out = getSerializerFactory().out(os)) {
Hessian2Output hOut = new Hessian2Output(os);
hOut.setSerializerFactory(getSerializerFactory());
hOut.writeObject(value);
hOut.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
"""
try (OutputStream os = openOutputStream(index)) {
try (OutH3 out = serializer().out(os)) {
out.writeObject(value);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
} | java | public void setObject(int index, Object value)
{
try (OutputStream os = openOutputStream(index)) {
try (OutH3 out = serializer().out(os)) {
out.writeObject(value);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
} | [
"public",
"void",
"setObject",
"(",
"int",
"index",
",",
"Object",
"value",
")",
"{",
"try",
"(",
"OutputStream",
"os",
"=",
"openOutputStream",
"(",
"index",
")",
")",
"{",
"try",
"(",
"OutH3",
"out",
"=",
"serializer",
"(",
")",
".",
"out",
"(",
"os",
")",
")",
"{",
"out",
".",
"writeObject",
"(",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
]
| /*
public void setObject(int index, Object value)
{
try (OutputStream os = openOutputStream(index)) {
try (OutH3 out = getSerializerFactory().out(os)) {
Hessian2Output hOut = new Hessian2Output(os);
hOut.setSerializerFactory(getSerializerFactory());
hOut.writeObject(value);
hOut.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
} | [
"/",
"*",
"public",
"void",
"setObject",
"(",
"int",
"index",
"Object",
"value",
")",
"{",
"try",
"(",
"OutputStream",
"os",
"=",
"openOutputStream",
"(",
"index",
"))",
"{",
"try",
"(",
"OutH3",
"out",
"=",
"getSerializerFactory",
"()",
".",
"out",
"(",
"os",
"))",
"{",
"Hessian2Output",
"hOut",
"=",
"new",
"Hessian2Output",
"(",
"os",
")",
";"
]
| train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/RowCursor.java#L460-L469 |
GenesysPureEngage/workspace-client-java | src/main/java/com/genesys/internal/workspace/api/StandardResponsesApi.java | StandardResponsesApi.reportStandareResponseUsage | public ApiSuccessResponse reportStandareResponseUsage(String id, ReportStandareResponseUsageData reportStandareResponseUsageData) throws ApiException {
"""
Specifies Usage of a Standard Response for an interaction.
@param id id of the Standard Response (required)
@param reportStandareResponseUsageData (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<ApiSuccessResponse> resp = reportStandareResponseUsageWithHttpInfo(id, reportStandareResponseUsageData);
return resp.getData();
} | java | public ApiSuccessResponse reportStandareResponseUsage(String id, ReportStandareResponseUsageData reportStandareResponseUsageData) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = reportStandareResponseUsageWithHttpInfo(id, reportStandareResponseUsageData);
return resp.getData();
} | [
"public",
"ApiSuccessResponse",
"reportStandareResponseUsage",
"(",
"String",
"id",
",",
"ReportStandareResponseUsageData",
"reportStandareResponseUsageData",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"ApiSuccessResponse",
">",
"resp",
"=",
"reportStandareResponseUsageWithHttpInfo",
"(",
"id",
",",
"reportStandareResponseUsageData",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
]
| Specifies Usage of a Standard Response for an interaction.
@param id id of the Standard Response (required)
@param reportStandareResponseUsageData (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Specifies",
"Usage",
"of",
"a",
"Standard",
"Response",
"for",
"an",
"interaction",
"."
]
| train | https://github.com/GenesysPureEngage/workspace-client-java/blob/509fdd9e89b9359d012f9a72be95037a3cef53e6/src/main/java/com/genesys/internal/workspace/api/StandardResponsesApi.java#L1280-L1283 |
groupon/odo | client/src/main/java/com/groupon/odo/client/Client.java | Client.filterHistory | public History[] filterHistory(String... filters) throws Exception {
"""
Retrieve the request History based on the specified filters.
If no filter is specified, return the default size history.
@param filters filters to be applied
@return array of History items
@throws Exception exception
"""
BasicNameValuePair[] params;
if (filters.length > 0) {
params = new BasicNameValuePair[filters.length];
for (int i = 0; i < filters.length; i++) {
params[i] = new BasicNameValuePair("source_uri[]", filters[i]);
}
} else {
return refreshHistory();
}
return constructHistory(params);
} | java | public History[] filterHistory(String... filters) throws Exception {
BasicNameValuePair[] params;
if (filters.length > 0) {
params = new BasicNameValuePair[filters.length];
for (int i = 0; i < filters.length; i++) {
params[i] = new BasicNameValuePair("source_uri[]", filters[i]);
}
} else {
return refreshHistory();
}
return constructHistory(params);
} | [
"public",
"History",
"[",
"]",
"filterHistory",
"(",
"String",
"...",
"filters",
")",
"throws",
"Exception",
"{",
"BasicNameValuePair",
"[",
"]",
"params",
";",
"if",
"(",
"filters",
".",
"length",
">",
"0",
")",
"{",
"params",
"=",
"new",
"BasicNameValuePair",
"[",
"filters",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"filters",
".",
"length",
";",
"i",
"++",
")",
"{",
"params",
"[",
"i",
"]",
"=",
"new",
"BasicNameValuePair",
"(",
"\"source_uri[]\"",
",",
"filters",
"[",
"i",
"]",
")",
";",
"}",
"}",
"else",
"{",
"return",
"refreshHistory",
"(",
")",
";",
"}",
"return",
"constructHistory",
"(",
"params",
")",
";",
"}"
]
| Retrieve the request History based on the specified filters.
If no filter is specified, return the default size history.
@param filters filters to be applied
@return array of History items
@throws Exception exception | [
"Retrieve",
"the",
"request",
"History",
"based",
"on",
"the",
"specified",
"filters",
".",
"If",
"no",
"filter",
"is",
"specified",
"return",
"the",
"default",
"size",
"history",
"."
]
| train | https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L224-L236 |
CenturyLinkCloud/clc-java-sdk | sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/group/GroupHierarchyConfig.java | GroupHierarchyConfig.collectConfigs | private void collectConfigs(GroupHierarchyConfig hierarchyConfig, List<CreateServerConfig> serverConfigs) {
"""
Collect server configs in current group
@param hierarchyConfig group hierarchy config
@param serverConfigs list with server configs
"""
hierarchyConfig.getSubitems().stream().forEach(config -> {
if (config instanceof ServerConfig) {
serverConfigs.addAll(Arrays.asList(((ServerConfig)config).getServerConfig()));
} else {
collectConfigs((GroupHierarchyConfig) config, serverConfigs);
}
});
} | java | private void collectConfigs(GroupHierarchyConfig hierarchyConfig, List<CreateServerConfig> serverConfigs) {
hierarchyConfig.getSubitems().stream().forEach(config -> {
if (config instanceof ServerConfig) {
serverConfigs.addAll(Arrays.asList(((ServerConfig)config).getServerConfig()));
} else {
collectConfigs((GroupHierarchyConfig) config, serverConfigs);
}
});
} | [
"private",
"void",
"collectConfigs",
"(",
"GroupHierarchyConfig",
"hierarchyConfig",
",",
"List",
"<",
"CreateServerConfig",
">",
"serverConfigs",
")",
"{",
"hierarchyConfig",
".",
"getSubitems",
"(",
")",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"config",
"->",
"{",
"if",
"(",
"config",
"instanceof",
"ServerConfig",
")",
"{",
"serverConfigs",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"(",
"(",
"ServerConfig",
")",
"config",
")",
".",
"getServerConfig",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"collectConfigs",
"(",
"(",
"GroupHierarchyConfig",
")",
"config",
",",
"serverConfigs",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Collect server configs in current group
@param hierarchyConfig group hierarchy config
@param serverConfigs list with server configs | [
"Collect",
"server",
"configs",
"in",
"current",
"group"
]
| train | https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/group/GroupHierarchyConfig.java#L123-L131 |
whitesource/agents | wss-agent-api/src/main/java/org/whitesource/agent/api/dispatch/RequestFactory.java | RequestFactory.newCheckPoliciesRequest | @Deprecated
public CheckPoliciesRequest newCheckPoliciesRequest(String orgToken, Collection<AgentProjectInfo> projects, String userKey) {
"""
Create new Check policies request.
@param orgToken WhiteSource organization token.
@param projects Projects status statement to check.
@param userKey user key uniquely identifying the account at white source.
@return Newly created request to check policies application.
"""
return newCheckPoliciesRequest(orgToken, null, null, projects, userKey, null);
} | java | @Deprecated
public CheckPoliciesRequest newCheckPoliciesRequest(String orgToken, Collection<AgentProjectInfo> projects, String userKey) {
return newCheckPoliciesRequest(orgToken, null, null, projects, userKey, null);
} | [
"@",
"Deprecated",
"public",
"CheckPoliciesRequest",
"newCheckPoliciesRequest",
"(",
"String",
"orgToken",
",",
"Collection",
"<",
"AgentProjectInfo",
">",
"projects",
",",
"String",
"userKey",
")",
"{",
"return",
"newCheckPoliciesRequest",
"(",
"orgToken",
",",
"null",
",",
"null",
",",
"projects",
",",
"userKey",
",",
"null",
")",
";",
"}"
]
| Create new Check policies request.
@param orgToken WhiteSource organization token.
@param projects Projects status statement to check.
@param userKey user key uniquely identifying the account at white source.
@return Newly created request to check policies application. | [
"Create",
"new",
"Check",
"policies",
"request",
"."
]
| train | https://github.com/whitesource/agents/blob/8a947a3dbad257aff70f23f79fb3a55ca90b765f/wss-agent-api/src/main/java/org/whitesource/agent/api/dispatch/RequestFactory.java#L308-L311 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java | GlobalUsersInner.beginStopEnvironment | public void beginStopEnvironment(String userName, String environmentId) {
"""
Stops an environment by stopping all resources inside the environment This operation can take a while to complete.
@param userName The name of the user.
@param environmentId The resourceId of the environment
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
beginStopEnvironmentWithServiceResponseAsync(userName, environmentId).toBlocking().single().body();
} | java | public void beginStopEnvironment(String userName, String environmentId) {
beginStopEnvironmentWithServiceResponseAsync(userName, environmentId).toBlocking().single().body();
} | [
"public",
"void",
"beginStopEnvironment",
"(",
"String",
"userName",
",",
"String",
"environmentId",
")",
"{",
"beginStopEnvironmentWithServiceResponseAsync",
"(",
"userName",
",",
"environmentId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
]
| Stops an environment by stopping all resources inside the environment This operation can take a while to complete.
@param userName The name of the user.
@param environmentId The resourceId of the environment
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Stops",
"an",
"environment",
"by",
"stopping",
"all",
"resources",
"inside",
"the",
"environment",
"This",
"operation",
"can",
"take",
"a",
"while",
"to",
"complete",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java#L1301-L1303 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/MeasureFormat.java | MeasureFormat.formatMeasurePerUnit | public StringBuilder formatMeasurePerUnit(
Measure measure,
MeasureUnit perUnit,
StringBuilder appendTo,
FieldPosition pos) {
"""
Formats a single measure per unit.
An example of such a formatted string is "3.5 meters per second."
@param measure the measure object. In above example, 3.5 meters.
@param perUnit the per unit. In above example, it is MeasureUnit.SECOND
@param appendTo formatted string appended here.
@param pos The field position.
@return appendTo.
"""
MeasureUnit resolvedUnit = MeasureUnit.resolveUnitPerUnit(
measure.getUnit(), perUnit);
if (resolvedUnit != null) {
Measure newMeasure = new Measure(measure.getNumber(), resolvedUnit);
return formatMeasure(newMeasure, numberFormat, appendTo, pos);
}
FieldPosition fpos = new FieldPosition(
pos.getFieldAttribute(), pos.getField());
int offset = withPerUnitAndAppend(
formatMeasure(measure, numberFormat, new StringBuilder(), fpos),
perUnit,
appendTo);
if (fpos.getBeginIndex() != 0 || fpos.getEndIndex() != 0) {
pos.setBeginIndex(fpos.getBeginIndex() + offset);
pos.setEndIndex(fpos.getEndIndex() + offset);
}
return appendTo;
} | java | public StringBuilder formatMeasurePerUnit(
Measure measure,
MeasureUnit perUnit,
StringBuilder appendTo,
FieldPosition pos) {
MeasureUnit resolvedUnit = MeasureUnit.resolveUnitPerUnit(
measure.getUnit(), perUnit);
if (resolvedUnit != null) {
Measure newMeasure = new Measure(measure.getNumber(), resolvedUnit);
return formatMeasure(newMeasure, numberFormat, appendTo, pos);
}
FieldPosition fpos = new FieldPosition(
pos.getFieldAttribute(), pos.getField());
int offset = withPerUnitAndAppend(
formatMeasure(measure, numberFormat, new StringBuilder(), fpos),
perUnit,
appendTo);
if (fpos.getBeginIndex() != 0 || fpos.getEndIndex() != 0) {
pos.setBeginIndex(fpos.getBeginIndex() + offset);
pos.setEndIndex(fpos.getEndIndex() + offset);
}
return appendTo;
} | [
"public",
"StringBuilder",
"formatMeasurePerUnit",
"(",
"Measure",
"measure",
",",
"MeasureUnit",
"perUnit",
",",
"StringBuilder",
"appendTo",
",",
"FieldPosition",
"pos",
")",
"{",
"MeasureUnit",
"resolvedUnit",
"=",
"MeasureUnit",
".",
"resolveUnitPerUnit",
"(",
"measure",
".",
"getUnit",
"(",
")",
",",
"perUnit",
")",
";",
"if",
"(",
"resolvedUnit",
"!=",
"null",
")",
"{",
"Measure",
"newMeasure",
"=",
"new",
"Measure",
"(",
"measure",
".",
"getNumber",
"(",
")",
",",
"resolvedUnit",
")",
";",
"return",
"formatMeasure",
"(",
"newMeasure",
",",
"numberFormat",
",",
"appendTo",
",",
"pos",
")",
";",
"}",
"FieldPosition",
"fpos",
"=",
"new",
"FieldPosition",
"(",
"pos",
".",
"getFieldAttribute",
"(",
")",
",",
"pos",
".",
"getField",
"(",
")",
")",
";",
"int",
"offset",
"=",
"withPerUnitAndAppend",
"(",
"formatMeasure",
"(",
"measure",
",",
"numberFormat",
",",
"new",
"StringBuilder",
"(",
")",
",",
"fpos",
")",
",",
"perUnit",
",",
"appendTo",
")",
";",
"if",
"(",
"fpos",
".",
"getBeginIndex",
"(",
")",
"!=",
"0",
"||",
"fpos",
".",
"getEndIndex",
"(",
")",
"!=",
"0",
")",
"{",
"pos",
".",
"setBeginIndex",
"(",
"fpos",
".",
"getBeginIndex",
"(",
")",
"+",
"offset",
")",
";",
"pos",
".",
"setEndIndex",
"(",
"fpos",
".",
"getEndIndex",
"(",
")",
"+",
"offset",
")",
";",
"}",
"return",
"appendTo",
";",
"}"
]
| Formats a single measure per unit.
An example of such a formatted string is "3.5 meters per second."
@param measure the measure object. In above example, 3.5 meters.
@param perUnit the per unit. In above example, it is MeasureUnit.SECOND
@param appendTo formatted string appended here.
@param pos The field position.
@return appendTo. | [
"Formats",
"a",
"single",
"measure",
"per",
"unit",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/MeasureFormat.java#L480-L502 |
twitter/cloudhopper-commons | ch-commons-util/src/main/java/com/cloudhopper/commons/util/DateTimeUtil.java | DateTimeUtil.floorToMinutePeriod | public static DateTime floorToMinutePeriod(DateTime value, int periodInMinutes) {
"""
Null-safe method that returns a new instance of a DateTime object rounded
downwards to the nearest specified period in minutes. For example, if
a period of 5 minutes is requested, a time of "2009-06-24 13:24:51.476 -8:00"
would return a datetime of "2009-06-24 13:20:00.000 -8:00". The time zone of the
returned DateTime instance will be the same as the argument. Similar to a
floor() function on a float.<br>
NOTE: While any period in minutes between 1 and 59 can be passed into this
method, its only useful if the value can be evenly divided into 60 to make
it as useful as possible.<br>
Examples:
<ul>
<li>null -> null
<li>5: "2009-06-24 13:39:51.476 -8:00" -> "2009-06-24 13:35:00.000 -8:00"
<li>10: "2009-06-24 13:39:51.476 -8:00" -> "2009-06-24 13:30:00.000 -8:00"
<li>15: "2009-06-24 13:39:51.476 -8:00" -> "2009-06-24 13:30:00.000 -8:00"
<li>20: "2009-06-24 13:39:51.476 UTC" -> "2009-06-24 13:20:00.000 UTC"
</ul>
@param value The DateTime value to round downward
@return Null if the argument is null or a new instance of the DateTime
value rounded downwards to the nearest period in minutes.
"""
if (value == null) {
return null;
}
if (periodInMinutes <= 0 || periodInMinutes > 59) {
throw new IllegalArgumentException("period in minutes must be > 0 and <= 59");
}
int min = value.getMinuteOfHour();
min = (min / periodInMinutes) * periodInMinutes;
return new DateTime(value.getYear(), value.getMonthOfYear(), value.getDayOfMonth(), value.getHourOfDay(), min, 0, 0, value.getZone());
} | java | public static DateTime floorToMinutePeriod(DateTime value, int periodInMinutes) {
if (value == null) {
return null;
}
if (periodInMinutes <= 0 || periodInMinutes > 59) {
throw new IllegalArgumentException("period in minutes must be > 0 and <= 59");
}
int min = value.getMinuteOfHour();
min = (min / periodInMinutes) * periodInMinutes;
return new DateTime(value.getYear(), value.getMonthOfYear(), value.getDayOfMonth(), value.getHourOfDay(), min, 0, 0, value.getZone());
} | [
"public",
"static",
"DateTime",
"floorToMinutePeriod",
"(",
"DateTime",
"value",
",",
"int",
"periodInMinutes",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"periodInMinutes",
"<=",
"0",
"||",
"periodInMinutes",
">",
"59",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"period in minutes must be > 0 and <= 59\"",
")",
";",
"}",
"int",
"min",
"=",
"value",
".",
"getMinuteOfHour",
"(",
")",
";",
"min",
"=",
"(",
"min",
"/",
"periodInMinutes",
")",
"*",
"periodInMinutes",
";",
"return",
"new",
"DateTime",
"(",
"value",
".",
"getYear",
"(",
")",
",",
"value",
".",
"getMonthOfYear",
"(",
")",
",",
"value",
".",
"getDayOfMonth",
"(",
")",
",",
"value",
".",
"getHourOfDay",
"(",
")",
",",
"min",
",",
"0",
",",
"0",
",",
"value",
".",
"getZone",
"(",
")",
")",
";",
"}"
]
| Null-safe method that returns a new instance of a DateTime object rounded
downwards to the nearest specified period in minutes. For example, if
a period of 5 minutes is requested, a time of "2009-06-24 13:24:51.476 -8:00"
would return a datetime of "2009-06-24 13:20:00.000 -8:00". The time zone of the
returned DateTime instance will be the same as the argument. Similar to a
floor() function on a float.<br>
NOTE: While any period in minutes between 1 and 59 can be passed into this
method, its only useful if the value can be evenly divided into 60 to make
it as useful as possible.<br>
Examples:
<ul>
<li>null -> null
<li>5: "2009-06-24 13:39:51.476 -8:00" -> "2009-06-24 13:35:00.000 -8:00"
<li>10: "2009-06-24 13:39:51.476 -8:00" -> "2009-06-24 13:30:00.000 -8:00"
<li>15: "2009-06-24 13:39:51.476 -8:00" -> "2009-06-24 13:30:00.000 -8:00"
<li>20: "2009-06-24 13:39:51.476 UTC" -> "2009-06-24 13:20:00.000 UTC"
</ul>
@param value The DateTime value to round downward
@return Null if the argument is null or a new instance of the DateTime
value rounded downwards to the nearest period in minutes. | [
"Null",
"-",
"safe",
"method",
"that",
"returns",
"a",
"new",
"instance",
"of",
"a",
"DateTime",
"object",
"rounded",
"downwards",
"to",
"the",
"nearest",
"specified",
"period",
"in",
"minutes",
".",
"For",
"example",
"if",
"a",
"period",
"of",
"5",
"minutes",
"is",
"requested",
"a",
"time",
"of",
"2009",
"-",
"06",
"-",
"24",
"13",
":",
"24",
":",
"51",
".",
"476",
"-",
"8",
":",
"00",
"would",
"return",
"a",
"datetime",
"of",
"2009",
"-",
"06",
"-",
"24",
"13",
":",
"20",
":",
"00",
".",
"000",
"-",
"8",
":",
"00",
".",
"The",
"time",
"zone",
"of",
"the",
"returned",
"DateTime",
"instance",
"will",
"be",
"the",
"same",
"as",
"the",
"argument",
".",
"Similar",
"to",
"a",
"floor",
"()",
"function",
"on",
"a",
"float",
".",
"<br",
">",
"NOTE",
":",
"While",
"any",
"period",
"in",
"minutes",
"between",
"1",
"and",
"59",
"can",
"be",
"passed",
"into",
"this",
"method",
"its",
"only",
"useful",
"if",
"the",
"value",
"can",
"be",
"evenly",
"divided",
"into",
"60",
"to",
"make",
"it",
"as",
"useful",
"as",
"possible",
".",
"<br",
">",
"Examples",
":",
"<ul",
">",
"<li",
">",
"null",
"-",
">",
"null",
"<li",
">",
"5",
":",
"2009",
"-",
"06",
"-",
"24",
"13",
":",
"39",
":",
"51",
".",
"476",
"-",
"8",
":",
"00",
"-",
">",
"2009",
"-",
"06",
"-",
"24",
"13",
":",
"35",
":",
"00",
".",
"000",
"-",
"8",
":",
"00",
"<li",
">",
"10",
":",
"2009",
"-",
"06",
"-",
"24",
"13",
":",
"39",
":",
"51",
".",
"476",
"-",
"8",
":",
"00",
"-",
">",
"2009",
"-",
"06",
"-",
"24",
"13",
":",
"30",
":",
"00",
".",
"000",
"-",
"8",
":",
"00",
"<li",
">",
"15",
":",
"2009",
"-",
"06",
"-",
"24",
"13",
":",
"39",
":",
"51",
".",
"476",
"-",
"8",
":",
"00",
"-",
">",
"2009",
"-",
"06",
"-",
"24",
"13",
":",
"30",
":",
"00",
".",
"000",
"-",
"8",
":",
"00",
"<li",
">",
"20",
":",
"2009",
"-",
"06",
"-",
"24",
"13",
":",
"39",
":",
"51",
".",
"476",
"UTC",
"-",
">",
"2009",
"-",
"06",
"-",
"24",
"13",
":",
"20",
":",
"00",
".",
"000",
"UTC",
"<",
"/",
"ul",
">"
]
| train | https://github.com/twitter/cloudhopper-commons/blob/b5bc397dbec4537e8149e7ec0733c1d7ed477499/ch-commons-util/src/main/java/com/cloudhopper/commons/util/DateTimeUtil.java#L335-L345 |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/upgrade/UpgradeScanner10.java | UpgradeScanner10.openRead | private ReadStream openRead(long address, int size) {
"""
Open a read stream to a segment.
@param address file address for the segment
@param size length of the segment
@return opened ReadStream
"""
InStore inStore = _store.openRead(address, size);
InStoreStream is = new InStoreStream(inStore, address, address + size);
return new ReadStream(new VfsStream(is));
} | java | private ReadStream openRead(long address, int size)
{
InStore inStore = _store.openRead(address, size);
InStoreStream is = new InStoreStream(inStore, address, address + size);
return new ReadStream(new VfsStream(is));
} | [
"private",
"ReadStream",
"openRead",
"(",
"long",
"address",
",",
"int",
"size",
")",
"{",
"InStore",
"inStore",
"=",
"_store",
".",
"openRead",
"(",
"address",
",",
"size",
")",
";",
"InStoreStream",
"is",
"=",
"new",
"InStoreStream",
"(",
"inStore",
",",
"address",
",",
"address",
"+",
"size",
")",
";",
"return",
"new",
"ReadStream",
"(",
"new",
"VfsStream",
"(",
"is",
")",
")",
";",
"}"
]
| Open a read stream to a segment.
@param address file address for the segment
@param size length of the segment
@return opened ReadStream | [
"Open",
"a",
"read",
"stream",
"to",
"a",
"segment",
"."
]
| train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/upgrade/UpgradeScanner10.java#L740-L747 |
zaproxy/zaproxy | src/org/zaproxy/zap/control/ExtensionFactory.java | ExtensionFactory.loadMessagesAndAddExtension | private static void loadMessagesAndAddExtension(ExtensionLoader extensionLoader, Extension extension) {
"""
Loads the messages of the {@code extension} and, if enabled, adds it to
the {@code extensionLoader} and loads the extension's help set.
@param extensionLoader the extension loader
@param extension the extension
@see #loadMessages(Extension)
@see ExtensionLoader#addExtension(Extension)
"""
loadMessages(extension);
if (!extension.isEnabled()) {
return;
}
if (!canBeLoaded(mapClassExtension, extension)) {
return;
}
if (extension.supportsDb(Model.getSingleton().getDb().getType()) &&
(extension.supportsLowMemory() || ! Constant.isLowMemoryOptionSet())) {
extensionLoader.addExtension(extension);
} else if (!extension.supportsDb(Model.getSingleton().getDb().getType())) {
log.debug("Not loading extension " + extension.getName() + ": doesnt support " + Model.getSingleton().getDb().getType());
extension.setEnabled(false);
} else if (extension.supportsLowMemory() || ! Constant.isLowMemoryOptionSet()) {
log.debug("Not loading extension " + extension.getName() + ": doesnt support low memory option");
extension.setEnabled(false);
}
} | java | private static void loadMessagesAndAddExtension(ExtensionLoader extensionLoader, Extension extension) {
loadMessages(extension);
if (!extension.isEnabled()) {
return;
}
if (!canBeLoaded(mapClassExtension, extension)) {
return;
}
if (extension.supportsDb(Model.getSingleton().getDb().getType()) &&
(extension.supportsLowMemory() || ! Constant.isLowMemoryOptionSet())) {
extensionLoader.addExtension(extension);
} else if (!extension.supportsDb(Model.getSingleton().getDb().getType())) {
log.debug("Not loading extension " + extension.getName() + ": doesnt support " + Model.getSingleton().getDb().getType());
extension.setEnabled(false);
} else if (extension.supportsLowMemory() || ! Constant.isLowMemoryOptionSet()) {
log.debug("Not loading extension " + extension.getName() + ": doesnt support low memory option");
extension.setEnabled(false);
}
} | [
"private",
"static",
"void",
"loadMessagesAndAddExtension",
"(",
"ExtensionLoader",
"extensionLoader",
",",
"Extension",
"extension",
")",
"{",
"loadMessages",
"(",
"extension",
")",
";",
"if",
"(",
"!",
"extension",
".",
"isEnabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"canBeLoaded",
"(",
"mapClassExtension",
",",
"extension",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"extension",
".",
"supportsDb",
"(",
"Model",
".",
"getSingleton",
"(",
")",
".",
"getDb",
"(",
")",
".",
"getType",
"(",
")",
")",
"&&",
"(",
"extension",
".",
"supportsLowMemory",
"(",
")",
"||",
"!",
"Constant",
".",
"isLowMemoryOptionSet",
"(",
")",
")",
")",
"{",
"extensionLoader",
".",
"addExtension",
"(",
"extension",
")",
";",
"}",
"else",
"if",
"(",
"!",
"extension",
".",
"supportsDb",
"(",
"Model",
".",
"getSingleton",
"(",
")",
".",
"getDb",
"(",
")",
".",
"getType",
"(",
")",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Not loading extension \"",
"+",
"extension",
".",
"getName",
"(",
")",
"+",
"\": doesnt support \"",
"+",
"Model",
".",
"getSingleton",
"(",
")",
".",
"getDb",
"(",
")",
".",
"getType",
"(",
")",
")",
";",
"extension",
".",
"setEnabled",
"(",
"false",
")",
";",
"}",
"else",
"if",
"(",
"extension",
".",
"supportsLowMemory",
"(",
")",
"||",
"!",
"Constant",
".",
"isLowMemoryOptionSet",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Not loading extension \"",
"+",
"extension",
".",
"getName",
"(",
")",
"+",
"\": doesnt support low memory option\"",
")",
";",
"extension",
".",
"setEnabled",
"(",
"false",
")",
";",
"}",
"}"
]
| Loads the messages of the {@code extension} and, if enabled, adds it to
the {@code extensionLoader} and loads the extension's help set.
@param extensionLoader the extension loader
@param extension the extension
@see #loadMessages(Extension)
@see ExtensionLoader#addExtension(Extension) | [
"Loads",
"the",
"messages",
"of",
"the",
"{",
"@code",
"extension",
"}",
"and",
"if",
"enabled",
"adds",
"it",
"to",
"the",
"{",
"@code",
"extensionLoader",
"}",
"and",
"loads",
"the",
"extension",
"s",
"help",
"set",
"."
]
| train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/control/ExtensionFactory.java#L142-L162 |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/TextureAtlas.java | TextureAtlas.intersectsOtherTexture | private boolean intersectsOtherTexture(RegionData data) {
"""
Checks to see if the provided {@link RegionData} intersects with any other region currently used by another texture.
@param data {@link RegionData}
@return true if it intersects another texture region
"""
final Rectangle rec1 = new Rectangle(data.x, data.y, data.width, data.height);
for (RegionData other : regions.values()) {
final Rectangle rec2 = new Rectangle(other.x, other.y, other.width, other.height);
if (rec1.intersects(rec2)) {
return true;
}
}
return false;
} | java | private boolean intersectsOtherTexture(RegionData data) {
final Rectangle rec1 = new Rectangle(data.x, data.y, data.width, data.height);
for (RegionData other : regions.values()) {
final Rectangle rec2 = new Rectangle(other.x, other.y, other.width, other.height);
if (rec1.intersects(rec2)) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"intersectsOtherTexture",
"(",
"RegionData",
"data",
")",
"{",
"final",
"Rectangle",
"rec1",
"=",
"new",
"Rectangle",
"(",
"data",
".",
"x",
",",
"data",
".",
"y",
",",
"data",
".",
"width",
",",
"data",
".",
"height",
")",
";",
"for",
"(",
"RegionData",
"other",
":",
"regions",
".",
"values",
"(",
")",
")",
"{",
"final",
"Rectangle",
"rec2",
"=",
"new",
"Rectangle",
"(",
"other",
".",
"x",
",",
"other",
".",
"y",
",",
"other",
".",
"width",
",",
"other",
".",
"height",
")",
";",
"if",
"(",
"rec1",
".",
"intersects",
"(",
"rec2",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Checks to see if the provided {@link RegionData} intersects with any other region currently used by another texture.
@param data {@link RegionData}
@return true if it intersects another texture region | [
"Checks",
"to",
"see",
"if",
"the",
"provided",
"{",
"@link",
"RegionData",
"}",
"intersects",
"with",
"any",
"other",
"region",
"currently",
"used",
"by",
"another",
"texture",
"."
]
| train | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/TextureAtlas.java#L128-L137 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/validation/beanvalidation/SheetBeanValidator.java | SheetBeanValidator.validate | @Override
public void validate(final Object targetObj, final SheetBindingErrors<?> errors, final Class<?>... groups) {
"""
グループを指定して検証を実行する。
@param targetObj 検証対象のオブジェクト。
@param errors エラーオブジェクト
@param groups BeanValiationのグループのクラス
"""
ArgUtils.notNull(targetObj, "targetObj");
ArgUtils.notNull(errors, "errors");
processConstraintViolation(getTargetValidator().validate(targetObj, groups), errors);
} | java | @Override
public void validate(final Object targetObj, final SheetBindingErrors<?> errors, final Class<?>... groups) {
ArgUtils.notNull(targetObj, "targetObj");
ArgUtils.notNull(errors, "errors");
processConstraintViolation(getTargetValidator().validate(targetObj, groups), errors);
} | [
"@",
"Override",
"public",
"void",
"validate",
"(",
"final",
"Object",
"targetObj",
",",
"final",
"SheetBindingErrors",
"<",
"?",
">",
"errors",
",",
"final",
"Class",
"<",
"?",
">",
"...",
"groups",
")",
"{",
"ArgUtils",
".",
"notNull",
"(",
"targetObj",
",",
"\"targetObj\"",
")",
";",
"ArgUtils",
".",
"notNull",
"(",
"errors",
",",
"\"errors\"",
")",
";",
"processConstraintViolation",
"(",
"getTargetValidator",
"(",
")",
".",
"validate",
"(",
"targetObj",
",",
"groups",
")",
",",
"errors",
")",
";",
"}"
]
| グループを指定して検証を実行する。
@param targetObj 検証対象のオブジェクト。
@param errors エラーオブジェクト
@param groups BeanValiationのグループのクラス | [
"グループを指定して検証を実行する。"
]
| train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/validation/beanvalidation/SheetBeanValidator.java#L88-L96 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/grid/DataRecordList.java | DataRecordList.bookmarkToIndex | public int bookmarkToIndex(Object bookmark, int iHandleType) {
"""
This method was created by a SmartGuide.
@return int index in table; or -1 if not found.
@param bookmark java.lang.Object
"""
int iTargetPosition;
DataRecord thisBookmark = null;
if (bookmark == null)
return -1;
//+ Not found, look through the recordlist
for (iTargetPosition = 0; iTargetPosition < m_iRecordListEnd; iTargetPosition += m_iRecordListStep)
{
thisBookmark = (DataRecord)this.elementAt(iTargetPosition);
if (bookmark.equals(thisBookmark.getHandle(iHandleType)))
return iTargetPosition;
}
//+ Still not found, do a binary search through the recordlist for a matching key
return -1; // Not found
} | java | public int bookmarkToIndex(Object bookmark, int iHandleType)
{
int iTargetPosition;
DataRecord thisBookmark = null;
if (bookmark == null)
return -1;
//+ Not found, look through the recordlist
for (iTargetPosition = 0; iTargetPosition < m_iRecordListEnd; iTargetPosition += m_iRecordListStep)
{
thisBookmark = (DataRecord)this.elementAt(iTargetPosition);
if (bookmark.equals(thisBookmark.getHandle(iHandleType)))
return iTargetPosition;
}
//+ Still not found, do a binary search through the recordlist for a matching key
return -1; // Not found
} | [
"public",
"int",
"bookmarkToIndex",
"(",
"Object",
"bookmark",
",",
"int",
"iHandleType",
")",
"{",
"int",
"iTargetPosition",
";",
"DataRecord",
"thisBookmark",
"=",
"null",
";",
"if",
"(",
"bookmark",
"==",
"null",
")",
"return",
"-",
"1",
";",
"//+ Not found, look through the recordlist",
"for",
"(",
"iTargetPosition",
"=",
"0",
";",
"iTargetPosition",
"<",
"m_iRecordListEnd",
";",
"iTargetPosition",
"+=",
"m_iRecordListStep",
")",
"{",
"thisBookmark",
"=",
"(",
"DataRecord",
")",
"this",
".",
"elementAt",
"(",
"iTargetPosition",
")",
";",
"if",
"(",
"bookmark",
".",
"equals",
"(",
"thisBookmark",
".",
"getHandle",
"(",
"iHandleType",
")",
")",
")",
"return",
"iTargetPosition",
";",
"}",
"//+ Still not found, do a binary search through the recordlist for a matching key",
"return",
"-",
"1",
";",
"// Not found",
"}"
]
| This method was created by a SmartGuide.
@return int index in table; or -1 if not found.
@param bookmark java.lang.Object | [
"This",
"method",
"was",
"created",
"by",
"a",
"SmartGuide",
"."
]
| train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/grid/DataRecordList.java#L25-L40 |
terrestris/shogun-core | src/shogun-core-main/src/main/java/de/terrestris/shoguncore/security/access/entity/UserPermissionEvaluator.java | UserPermissionEvaluator.hasPermission | @Override
public boolean hasPermission(User user, E entity, Permission permission) {
"""
Grants READ permission on the user object of the currently logged in
user. Uses default implementation otherwise.
"""
// always grant READ access to own user object (of the logged in user)
if (user != null && user.equals(entity)
&& permission.equals(Permission.READ)) {
LOG.trace("Granting READ access on own user object");
return true;
}
// call parent implementation
return super.hasPermission(user, entity, permission);
} | java | @Override
public boolean hasPermission(User user, E entity, Permission permission) {
// always grant READ access to own user object (of the logged in user)
if (user != null && user.equals(entity)
&& permission.equals(Permission.READ)) {
LOG.trace("Granting READ access on own user object");
return true;
}
// call parent implementation
return super.hasPermission(user, entity, permission);
} | [
"@",
"Override",
"public",
"boolean",
"hasPermission",
"(",
"User",
"user",
",",
"E",
"entity",
",",
"Permission",
"permission",
")",
"{",
"// always grant READ access to own user object (of the logged in user)",
"if",
"(",
"user",
"!=",
"null",
"&&",
"user",
".",
"equals",
"(",
"entity",
")",
"&&",
"permission",
".",
"equals",
"(",
"Permission",
".",
"READ",
")",
")",
"{",
"LOG",
".",
"trace",
"(",
"\"Granting READ access on own user object\"",
")",
";",
"return",
"true",
";",
"}",
"// call parent implementation",
"return",
"super",
".",
"hasPermission",
"(",
"user",
",",
"entity",
",",
"permission",
")",
";",
"}"
]
| Grants READ permission on the user object of the currently logged in
user. Uses default implementation otherwise. | [
"Grants",
"READ",
"permission",
"on",
"the",
"user",
"object",
"of",
"the",
"currently",
"logged",
"in",
"user",
".",
"Uses",
"default",
"implementation",
"otherwise",
"."
]
| train | https://github.com/terrestris/shogun-core/blob/3dbabda35ae63235265913c865dba389b050b6e6/src/shogun-core-main/src/main/java/de/terrestris/shoguncore/security/access/entity/UserPermissionEvaluator.java#L33-L45 |
mongodb/stitch-android-sdk | core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java | DataSynchronizer.updateOne | UpdateResult updateOne(final MongoNamespace namespace, final Bson filter, final Bson update) {
"""
Update a single document in the collection according to the specified arguments.
@param filter a document describing the query filter, which may not be null.
@param update a document describing the update, which may not be null. The update to
apply must include only update operators.
@return the result of the update one operation
"""
return updateOne(namespace, filter, update, new UpdateOptions());
} | java | UpdateResult updateOne(final MongoNamespace namespace, final Bson filter, final Bson update) {
return updateOne(namespace, filter, update, new UpdateOptions());
} | [
"UpdateResult",
"updateOne",
"(",
"final",
"MongoNamespace",
"namespace",
",",
"final",
"Bson",
"filter",
",",
"final",
"Bson",
"update",
")",
"{",
"return",
"updateOne",
"(",
"namespace",
",",
"filter",
",",
"update",
",",
"new",
"UpdateOptions",
"(",
")",
")",
";",
"}"
]
| Update a single document in the collection according to the specified arguments.
@param filter a document describing the query filter, which may not be null.
@param update a document describing the update, which may not be null. The update to
apply must include only update operators.
@return the result of the update one operation | [
"Update",
"a",
"single",
"document",
"in",
"the",
"collection",
"according",
"to",
"the",
"specified",
"arguments",
"."
]
| train | https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DataSynchronizer.java#L2335-L2337 |
aaberg/sql2o | core/src/main/java/org/sql2o/ArrayParameters.java | ArrayParameters.updateQueryAndParametersIndexes | static String updateQueryAndParametersIndexes(String parsedQuery,
Map<String, List<Integer>> parameterNamesToIndexes,
Map<String, Query.ParameterSetter> parameters,
boolean allowArrayParameters) {
"""
Update both the query and the parameter indexes to include the array parameters.
"""
List<ArrayParameter> arrayParametersSortedAsc = arrayParametersSortedAsc(parameterNamesToIndexes, parameters, allowArrayParameters);
if(arrayParametersSortedAsc.isEmpty()) {
return parsedQuery;
}
updateParameterNamesToIndexes(parameterNamesToIndexes, arrayParametersSortedAsc);
return updateQueryWithArrayParameters(parsedQuery, arrayParametersSortedAsc);
} | java | static String updateQueryAndParametersIndexes(String parsedQuery,
Map<String, List<Integer>> parameterNamesToIndexes,
Map<String, Query.ParameterSetter> parameters,
boolean allowArrayParameters) {
List<ArrayParameter> arrayParametersSortedAsc = arrayParametersSortedAsc(parameterNamesToIndexes, parameters, allowArrayParameters);
if(arrayParametersSortedAsc.isEmpty()) {
return parsedQuery;
}
updateParameterNamesToIndexes(parameterNamesToIndexes, arrayParametersSortedAsc);
return updateQueryWithArrayParameters(parsedQuery, arrayParametersSortedAsc);
} | [
"static",
"String",
"updateQueryAndParametersIndexes",
"(",
"String",
"parsedQuery",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"Integer",
">",
">",
"parameterNamesToIndexes",
",",
"Map",
"<",
"String",
",",
"Query",
".",
"ParameterSetter",
">",
"parameters",
",",
"boolean",
"allowArrayParameters",
")",
"{",
"List",
"<",
"ArrayParameter",
">",
"arrayParametersSortedAsc",
"=",
"arrayParametersSortedAsc",
"(",
"parameterNamesToIndexes",
",",
"parameters",
",",
"allowArrayParameters",
")",
";",
"if",
"(",
"arrayParametersSortedAsc",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"parsedQuery",
";",
"}",
"updateParameterNamesToIndexes",
"(",
"parameterNamesToIndexes",
",",
"arrayParametersSortedAsc",
")",
";",
"return",
"updateQueryWithArrayParameters",
"(",
"parsedQuery",
",",
"arrayParametersSortedAsc",
")",
";",
"}"
]
| Update both the query and the parameter indexes to include the array parameters. | [
"Update",
"both",
"the",
"query",
"and",
"the",
"parameter",
"indexes",
"to",
"include",
"the",
"array",
"parameters",
"."
]
| train | https://github.com/aaberg/sql2o/blob/01d3490a6d2440cf60f973d23508ac4ed57a8e20/core/src/main/java/org/sql2o/ArrayParameters.java#L32-L44 |
keenlabs/KeenClient-Java | query/src/main/java/io/keen/client/java/KeenQueryClient.java | KeenQueryClient.countUnique | public long countUnique(String eventCollection, String targetProperty, Timeframe timeframe) throws IOException {
"""
Count Unique query with only the required arguments.
Query API info here: https://keen.io/docs/api/#count-unique
@param eventCollection The name of the event collection you are analyzing.
@param targetProperty The name of the property you are analyzing.
@param timeframe The {@link RelativeTimeframe} or {@link AbsoluteTimeframe}.
@return The count unique query response.
@throws IOException If there was an error communicating with the server or
an error message received from the server.
"""
Query queryParams = new Query.Builder(QueryType.COUNT_UNIQUE)
.withEventCollection(eventCollection)
.withTargetProperty(targetProperty)
.withTimeframe(timeframe)
.build();
QueryResult result = execute(queryParams);
return queryResultToLong(result);
} | java | public long countUnique(String eventCollection, String targetProperty, Timeframe timeframe) throws IOException {
Query queryParams = new Query.Builder(QueryType.COUNT_UNIQUE)
.withEventCollection(eventCollection)
.withTargetProperty(targetProperty)
.withTimeframe(timeframe)
.build();
QueryResult result = execute(queryParams);
return queryResultToLong(result);
} | [
"public",
"long",
"countUnique",
"(",
"String",
"eventCollection",
",",
"String",
"targetProperty",
",",
"Timeframe",
"timeframe",
")",
"throws",
"IOException",
"{",
"Query",
"queryParams",
"=",
"new",
"Query",
".",
"Builder",
"(",
"QueryType",
".",
"COUNT_UNIQUE",
")",
".",
"withEventCollection",
"(",
"eventCollection",
")",
".",
"withTargetProperty",
"(",
"targetProperty",
")",
".",
"withTimeframe",
"(",
"timeframe",
")",
".",
"build",
"(",
")",
";",
"QueryResult",
"result",
"=",
"execute",
"(",
"queryParams",
")",
";",
"return",
"queryResultToLong",
"(",
"result",
")",
";",
"}"
]
| Count Unique query with only the required arguments.
Query API info here: https://keen.io/docs/api/#count-unique
@param eventCollection The name of the event collection you are analyzing.
@param targetProperty The name of the property you are analyzing.
@param timeframe The {@link RelativeTimeframe} or {@link AbsoluteTimeframe}.
@return The count unique query response.
@throws IOException If there was an error communicating with the server or
an error message received from the server. | [
"Count",
"Unique",
"query",
"with",
"only",
"the",
"required",
"arguments",
".",
"Query",
"API",
"info",
"here",
":",
"https",
":",
"//",
"keen",
".",
"io",
"/",
"docs",
"/",
"api",
"/",
"#count",
"-",
"unique"
]
| train | https://github.com/keenlabs/KeenClient-Java/blob/2ea021547b5338257c951a2596bd49749038d018/query/src/main/java/io/keen/client/java/KeenQueryClient.java#L95-L103 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java | ValueEnforcer.notNullNoNullValue | @CodingStyleguideUnaware
public static <T extends Map <?, ?>> T notNullNoNullValue (final T aValue, final String sName) {
"""
Check that the passed map is not <code>null</code> and that no
<code>null</code> value is contained.
@param <T>
Type to be checked and returned
@param aValue
The map to check.
@param sName
The name of the value (e.g. the parameter name)
@return The passed value.
@throws IllegalArgumentException
if the passed value is <code>null</code> or a <code>null</code>
value is contained
"""
if (isEnabled ())
return notNullNoNullValue (aValue, () -> sName);
return aValue;
} | java | @CodingStyleguideUnaware
public static <T extends Map <?, ?>> T notNullNoNullValue (final T aValue, final String sName)
{
if (isEnabled ())
return notNullNoNullValue (aValue, () -> sName);
return aValue;
} | [
"@",
"CodingStyleguideUnaware",
"public",
"static",
"<",
"T",
"extends",
"Map",
"<",
"?",
",",
"?",
">",
">",
"T",
"notNullNoNullValue",
"(",
"final",
"T",
"aValue",
",",
"final",
"String",
"sName",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
")",
"return",
"notNullNoNullValue",
"(",
"aValue",
",",
"(",
")",
"->",
"sName",
")",
";",
"return",
"aValue",
";",
"}"
]
| Check that the passed map is not <code>null</code> and that no
<code>null</code> value is contained.
@param <T>
Type to be checked and returned
@param aValue
The map to check.
@param sName
The name of the value (e.g. the parameter name)
@return The passed value.
@throws IllegalArgumentException
if the passed value is <code>null</code> or a <code>null</code>
value is contained | [
"Check",
"that",
"the",
"passed",
"map",
"is",
"not",
"<code",
">",
"null<",
"/",
"code",
">",
"and",
"that",
"no",
"<code",
">",
"null<",
"/",
"code",
">",
"value",
"is",
"contained",
"."
]
| train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java#L1133-L1139 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/interfaces/SubnetMatchInterfaceCriteria.java | SubnetMatchInterfaceCriteria.isAcceptable | @Override
protected InetAddress isAcceptable(NetworkInterface networkInterface, InetAddress address) throws SocketException {
"""
{@inheritDoc}
@return <code>address</code> if the <code>address</code> is on the correct subnet.
"""
return verifyAddressByMask(address.getAddress()) ? address : null;
} | java | @Override
protected InetAddress isAcceptable(NetworkInterface networkInterface, InetAddress address) throws SocketException {
return verifyAddressByMask(address.getAddress()) ? address : null;
} | [
"@",
"Override",
"protected",
"InetAddress",
"isAcceptable",
"(",
"NetworkInterface",
"networkInterface",
",",
"InetAddress",
"address",
")",
"throws",
"SocketException",
"{",
"return",
"verifyAddressByMask",
"(",
"address",
".",
"getAddress",
"(",
")",
")",
"?",
"address",
":",
"null",
";",
"}"
]
| {@inheritDoc}
@return <code>address</code> if the <code>address</code> is on the correct subnet. | [
"{",
"@inheritDoc",
"}"
]
| train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/interfaces/SubnetMatchInterfaceCriteria.java#L70-L73 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/core/Parser.java | Parser.parseReturningKeyword | public static boolean parseReturningKeyword(final char[] query, int offset) {
"""
Parse string to check presence of RETURNING keyword regardless of case.
@param query char[] of the query statement
@param offset position of query to start checking
@return boolean indicates presence of word
"""
if (query.length < (offset + 9)) {
return false;
}
return (query[offset] | 32) == 'r'
&& (query[offset + 1] | 32) == 'e'
&& (query[offset + 2] | 32) == 't'
&& (query[offset + 3] | 32) == 'u'
&& (query[offset + 4] | 32) == 'r'
&& (query[offset + 5] | 32) == 'n'
&& (query[offset + 6] | 32) == 'i'
&& (query[offset + 7] | 32) == 'n'
&& (query[offset + 8] | 32) == 'g';
} | java | public static boolean parseReturningKeyword(final char[] query, int offset) {
if (query.length < (offset + 9)) {
return false;
}
return (query[offset] | 32) == 'r'
&& (query[offset + 1] | 32) == 'e'
&& (query[offset + 2] | 32) == 't'
&& (query[offset + 3] | 32) == 'u'
&& (query[offset + 4] | 32) == 'r'
&& (query[offset + 5] | 32) == 'n'
&& (query[offset + 6] | 32) == 'i'
&& (query[offset + 7] | 32) == 'n'
&& (query[offset + 8] | 32) == 'g';
} | [
"public",
"static",
"boolean",
"parseReturningKeyword",
"(",
"final",
"char",
"[",
"]",
"query",
",",
"int",
"offset",
")",
"{",
"if",
"(",
"query",
".",
"length",
"<",
"(",
"offset",
"+",
"9",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"query",
"[",
"offset",
"]",
"|",
"32",
")",
"==",
"'",
"'",
"&&",
"(",
"query",
"[",
"offset",
"+",
"1",
"]",
"|",
"32",
")",
"==",
"'",
"'",
"&&",
"(",
"query",
"[",
"offset",
"+",
"2",
"]",
"|",
"32",
")",
"==",
"'",
"'",
"&&",
"(",
"query",
"[",
"offset",
"+",
"3",
"]",
"|",
"32",
")",
"==",
"'",
"'",
"&&",
"(",
"query",
"[",
"offset",
"+",
"4",
"]",
"|",
"32",
")",
"==",
"'",
"'",
"&&",
"(",
"query",
"[",
"offset",
"+",
"5",
"]",
"|",
"32",
")",
"==",
"'",
"'",
"&&",
"(",
"query",
"[",
"offset",
"+",
"6",
"]",
"|",
"32",
")",
"==",
"'",
"'",
"&&",
"(",
"query",
"[",
"offset",
"+",
"7",
"]",
"|",
"32",
")",
"==",
"'",
"'",
"&&",
"(",
"query",
"[",
"offset",
"+",
"8",
"]",
"|",
"32",
")",
"==",
"'",
"'",
";",
"}"
]
| Parse string to check presence of RETURNING keyword regardless of case.
@param query char[] of the query statement
@param offset position of query to start checking
@return boolean indicates presence of word | [
"Parse",
"string",
"to",
"check",
"presence",
"of",
"RETURNING",
"keyword",
"regardless",
"of",
"case",
"."
]
| train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/core/Parser.java#L620-L634 |
abel533/ECharts | src/main/java/com/github/abel533/echarts/series/Gauge.java | Gauge.radius | public Gauge radius(Object width, Object height) {
"""
半径,支持绝对值(px)和百分比,百分比计算比,min(width, height) / 2 * 75%,
传数组实现环形图,[内半径,外半径]
@param width
@param height
@return
"""
radius = new Object[]{width, height};
return this;
} | java | public Gauge radius(Object width, Object height) {
radius = new Object[]{width, height};
return this;
} | [
"public",
"Gauge",
"radius",
"(",
"Object",
"width",
",",
"Object",
"height",
")",
"{",
"radius",
"=",
"new",
"Object",
"[",
"]",
"{",
"width",
",",
"height",
"}",
";",
"return",
"this",
";",
"}"
]
| 半径,支持绝对值(px)和百分比,百分比计算比,min(width, height) / 2 * 75%,
传数组实现环形图,[内半径,外半径]
@param width
@param height
@return | [
"半径,支持绝对值(px)和百分比,百分比计算比,min",
"(",
"width",
"height",
")",
"/",
"2",
"*",
"75%,",
"传数组实现环形图,",
"[",
"内半径,外半径",
"]"
]
| train | https://github.com/abel533/ECharts/blob/73e031e51b75e67480701404ccf16e76fd5aa278/src/main/java/com/github/abel533/echarts/series/Gauge.java#L257-L260 |
apereo/cas | support/cas-server-support-saml-core-api/src/main/java/org/apereo/cas/support/saml/util/Saml10ObjectBuilder.java | Saml10ObjectBuilder.newSubject | public Subject newSubject(final String identifier, final String confirmationMethod) {
"""
New subject element with given confirmation method.
@param identifier the identifier
@param confirmationMethod the confirmation method
@return the subject
"""
val confirmation = newSamlObject(SubjectConfirmation.class);
val method = newSamlObject(ConfirmationMethod.class);
method.setConfirmationMethod(confirmationMethod);
confirmation.getConfirmationMethods().add(method);
val nameIdentifier = newSamlObject(NameIdentifier.class);
nameIdentifier.setValue(identifier);
val subject = newSamlObject(Subject.class);
subject.setNameIdentifier(nameIdentifier);
subject.setSubjectConfirmation(confirmation);
return subject;
} | java | public Subject newSubject(final String identifier, final String confirmationMethod) {
val confirmation = newSamlObject(SubjectConfirmation.class);
val method = newSamlObject(ConfirmationMethod.class);
method.setConfirmationMethod(confirmationMethod);
confirmation.getConfirmationMethods().add(method);
val nameIdentifier = newSamlObject(NameIdentifier.class);
nameIdentifier.setValue(identifier);
val subject = newSamlObject(Subject.class);
subject.setNameIdentifier(nameIdentifier);
subject.setSubjectConfirmation(confirmation);
return subject;
} | [
"public",
"Subject",
"newSubject",
"(",
"final",
"String",
"identifier",
",",
"final",
"String",
"confirmationMethod",
")",
"{",
"val",
"confirmation",
"=",
"newSamlObject",
"(",
"SubjectConfirmation",
".",
"class",
")",
";",
"val",
"method",
"=",
"newSamlObject",
"(",
"ConfirmationMethod",
".",
"class",
")",
";",
"method",
".",
"setConfirmationMethod",
"(",
"confirmationMethod",
")",
";",
"confirmation",
".",
"getConfirmationMethods",
"(",
")",
".",
"add",
"(",
"method",
")",
";",
"val",
"nameIdentifier",
"=",
"newSamlObject",
"(",
"NameIdentifier",
".",
"class",
")",
";",
"nameIdentifier",
".",
"setValue",
"(",
"identifier",
")",
";",
"val",
"subject",
"=",
"newSamlObject",
"(",
"Subject",
".",
"class",
")",
";",
"subject",
".",
"setNameIdentifier",
"(",
"nameIdentifier",
")",
";",
"subject",
".",
"setSubjectConfirmation",
"(",
"confirmation",
")",
";",
"return",
"subject",
";",
"}"
]
| New subject element with given confirmation method.
@param identifier the identifier
@param confirmationMethod the confirmation method
@return the subject | [
"New",
"subject",
"element",
"with",
"given",
"confirmation",
"method",
"."
]
| train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-saml-core-api/src/main/java/org/apereo/cas/support/saml/util/Saml10ObjectBuilder.java#L209-L220 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/abst/geo/bundle/SceneStructureMetric.java | SceneStructureMetric.initialize | public void initialize( int totalCameras , int totalViews , int totalPoints , int totalRigid ) {
"""
Call this function first. Specifies number of each type of data which is available.
@param totalCameras Number of cameras
@param totalViews Number of views
@param totalPoints Number of points
@param totalRigid Number of rigid objects
"""
cameras = new Camera[totalCameras];
views = new View[totalViews];
points = new Point[totalPoints];
rigids = new Rigid[totalRigid];
for (int i = 0; i < cameras.length; i++) {
cameras[i] = new Camera();
}
for (int i = 0; i < views.length; i++) {
views[i] = new View();
}
for (int i = 0; i < points.length; i++) {
points[i] = new Point(pointSize);
}
for (int i = 0; i < rigids.length; i++) {
rigids[i] = new Rigid();
}
// forget old assignments
lookupRigid = null;
} | java | public void initialize( int totalCameras , int totalViews , int totalPoints , int totalRigid ) {
cameras = new Camera[totalCameras];
views = new View[totalViews];
points = new Point[totalPoints];
rigids = new Rigid[totalRigid];
for (int i = 0; i < cameras.length; i++) {
cameras[i] = new Camera();
}
for (int i = 0; i < views.length; i++) {
views[i] = new View();
}
for (int i = 0; i < points.length; i++) {
points[i] = new Point(pointSize);
}
for (int i = 0; i < rigids.length; i++) {
rigids[i] = new Rigid();
}
// forget old assignments
lookupRigid = null;
} | [
"public",
"void",
"initialize",
"(",
"int",
"totalCameras",
",",
"int",
"totalViews",
",",
"int",
"totalPoints",
",",
"int",
"totalRigid",
")",
"{",
"cameras",
"=",
"new",
"Camera",
"[",
"totalCameras",
"]",
";",
"views",
"=",
"new",
"View",
"[",
"totalViews",
"]",
";",
"points",
"=",
"new",
"Point",
"[",
"totalPoints",
"]",
";",
"rigids",
"=",
"new",
"Rigid",
"[",
"totalRigid",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cameras",
".",
"length",
";",
"i",
"++",
")",
"{",
"cameras",
"[",
"i",
"]",
"=",
"new",
"Camera",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"views",
".",
"length",
";",
"i",
"++",
")",
"{",
"views",
"[",
"i",
"]",
"=",
"new",
"View",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"points",
".",
"length",
";",
"i",
"++",
")",
"{",
"points",
"[",
"i",
"]",
"=",
"new",
"Point",
"(",
"pointSize",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rigids",
".",
"length",
";",
"i",
"++",
")",
"{",
"rigids",
"[",
"i",
"]",
"=",
"new",
"Rigid",
"(",
")",
";",
"}",
"// forget old assignments",
"lookupRigid",
"=",
"null",
";",
"}"
]
| Call this function first. Specifies number of each type of data which is available.
@param totalCameras Number of cameras
@param totalViews Number of views
@param totalPoints Number of points
@param totalRigid Number of rigid objects | [
"Call",
"this",
"function",
"first",
".",
"Specifies",
"number",
"of",
"each",
"type",
"of",
"data",
"which",
"is",
"available",
"."
]
| train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/geo/bundle/SceneStructureMetric.java#L77-L98 |
spotify/styx | styx-common/src/main/java/com/spotify/styx/util/TimeUtil.java | TimeUtil.lastInstant | public static Instant lastInstant(Instant instant, Schedule schedule) {
"""
Gets the last execution instant for a {@link Schedule}, relative to a given instant. If
the given instant is exactly at an execution time of the schedule, it will be returned
as is.
<p>e.g. an hourly schedule has a last execution instant at 13:00 relative to 13:22.
@param instant The instant to calculate the last execution instant relative to
@param schedule The schedule of executions
@return an instant at the last execution time
"""
final ExecutionTime executionTime = ExecutionTime.forCron(cron(schedule));
final ZonedDateTime utcDateTime = instant.atZone(UTC);
// executionTime.isMatch ignores seconds for unix cron
// so we fail the check immediately if there is a sub-minute value
return (instant.truncatedTo(ChronoUnit.MINUTES).equals(instant)
&& executionTime.isMatch(utcDateTime))
? instant
: executionTime.lastExecution(utcDateTime)
.orElseThrow(IllegalArgumentException::new) // with unix cron, this should not happen
.toInstant();
} | java | public static Instant lastInstant(Instant instant, Schedule schedule) {
final ExecutionTime executionTime = ExecutionTime.forCron(cron(schedule));
final ZonedDateTime utcDateTime = instant.atZone(UTC);
// executionTime.isMatch ignores seconds for unix cron
// so we fail the check immediately if there is a sub-minute value
return (instant.truncatedTo(ChronoUnit.MINUTES).equals(instant)
&& executionTime.isMatch(utcDateTime))
? instant
: executionTime.lastExecution(utcDateTime)
.orElseThrow(IllegalArgumentException::new) // with unix cron, this should not happen
.toInstant();
} | [
"public",
"static",
"Instant",
"lastInstant",
"(",
"Instant",
"instant",
",",
"Schedule",
"schedule",
")",
"{",
"final",
"ExecutionTime",
"executionTime",
"=",
"ExecutionTime",
".",
"forCron",
"(",
"cron",
"(",
"schedule",
")",
")",
";",
"final",
"ZonedDateTime",
"utcDateTime",
"=",
"instant",
".",
"atZone",
"(",
"UTC",
")",
";",
"// executionTime.isMatch ignores seconds for unix cron",
"// so we fail the check immediately if there is a sub-minute value",
"return",
"(",
"instant",
".",
"truncatedTo",
"(",
"ChronoUnit",
".",
"MINUTES",
")",
".",
"equals",
"(",
"instant",
")",
"&&",
"executionTime",
".",
"isMatch",
"(",
"utcDateTime",
")",
")",
"?",
"instant",
":",
"executionTime",
".",
"lastExecution",
"(",
"utcDateTime",
")",
".",
"orElseThrow",
"(",
"IllegalArgumentException",
"::",
"new",
")",
"// with unix cron, this should not happen",
".",
"toInstant",
"(",
")",
";",
"}"
]
| Gets the last execution instant for a {@link Schedule}, relative to a given instant. If
the given instant is exactly at an execution time of the schedule, it will be returned
as is.
<p>e.g. an hourly schedule has a last execution instant at 13:00 relative to 13:22.
@param instant The instant to calculate the last execution instant relative to
@param schedule The schedule of executions
@return an instant at the last execution time | [
"Gets",
"the",
"last",
"execution",
"instant",
"for",
"a",
"{",
"@link",
"Schedule",
"}",
"relative",
"to",
"a",
"given",
"instant",
".",
"If",
"the",
"given",
"instant",
"is",
"exactly",
"at",
"an",
"execution",
"time",
"of",
"the",
"schedule",
"it",
"will",
"be",
"returned",
"as",
"is",
"."
]
| train | https://github.com/spotify/styx/blob/0d63999beeb93a17447e3bbccaa62175b74cf6e4/styx-common/src/main/java/com/spotify/styx/util/TimeUtil.java#L76-L88 |
snowflakedb/snowflake-jdbc | src/main/java/net/snowflake/client/jdbc/cloud/storage/StorageClientFactory.java | StorageClientFactory.createS3Client | private SnowflakeS3Client createS3Client(Map stageCredentials,
int parallel,
RemoteStoreFileEncryptionMaterial encMat,
String stageRegion)
throws SnowflakeSQLException {
"""
Creates a SnowflakeS3ClientObject which encapsulates
the Amazon S3 client
@param stageCredentials Map of stage credential properties
@param parallel degree of parallelism
@param encMat encryption material for the client
@param stageRegion the region where the stage is located
@return the SnowflakeS3Client instance created
@throws SnowflakeSQLException failure to create the S3 client
"""
final int S3_TRANSFER_MAX_RETRIES = 3;
logger.debug("createS3Client encryption={}", (encMat == null ? "no" : "yes"));
SnowflakeS3Client s3Client;
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setMaxConnections(parallel + 1);
clientConfig.setMaxErrorRetry(S3_TRANSFER_MAX_RETRIES);
clientConfig.setDisableSocketProxy(HttpUtil.isSocksProxyDisabled());
logger.debug("s3 client configuration: maxConnection={}, connectionTimeout={}, " +
"socketTimeout={}, maxErrorRetry={}",
clientConfig.getMaxConnections(),
clientConfig.getConnectionTimeout(),
clientConfig.getSocketTimeout(),
clientConfig.getMaxErrorRetry());
try
{
s3Client = new SnowflakeS3Client(stageCredentials, clientConfig, encMat, stageRegion);
}
catch (Exception ex)
{
logger.debug("Exception creating s3 client", ex);
throw ex;
}
logger.debug("s3 client created");
return s3Client;
} | java | private SnowflakeS3Client createS3Client(Map stageCredentials,
int parallel,
RemoteStoreFileEncryptionMaterial encMat,
String stageRegion)
throws SnowflakeSQLException
{
final int S3_TRANSFER_MAX_RETRIES = 3;
logger.debug("createS3Client encryption={}", (encMat == null ? "no" : "yes"));
SnowflakeS3Client s3Client;
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setMaxConnections(parallel + 1);
clientConfig.setMaxErrorRetry(S3_TRANSFER_MAX_RETRIES);
clientConfig.setDisableSocketProxy(HttpUtil.isSocksProxyDisabled());
logger.debug("s3 client configuration: maxConnection={}, connectionTimeout={}, " +
"socketTimeout={}, maxErrorRetry={}",
clientConfig.getMaxConnections(),
clientConfig.getConnectionTimeout(),
clientConfig.getSocketTimeout(),
clientConfig.getMaxErrorRetry());
try
{
s3Client = new SnowflakeS3Client(stageCredentials, clientConfig, encMat, stageRegion);
}
catch (Exception ex)
{
logger.debug("Exception creating s3 client", ex);
throw ex;
}
logger.debug("s3 client created");
return s3Client;
} | [
"private",
"SnowflakeS3Client",
"createS3Client",
"(",
"Map",
"stageCredentials",
",",
"int",
"parallel",
",",
"RemoteStoreFileEncryptionMaterial",
"encMat",
",",
"String",
"stageRegion",
")",
"throws",
"SnowflakeSQLException",
"{",
"final",
"int",
"S3_TRANSFER_MAX_RETRIES",
"=",
"3",
";",
"logger",
".",
"debug",
"(",
"\"createS3Client encryption={}\"",
",",
"(",
"encMat",
"==",
"null",
"?",
"\"no\"",
":",
"\"yes\"",
")",
")",
";",
"SnowflakeS3Client",
"s3Client",
";",
"ClientConfiguration",
"clientConfig",
"=",
"new",
"ClientConfiguration",
"(",
")",
";",
"clientConfig",
".",
"setMaxConnections",
"(",
"parallel",
"+",
"1",
")",
";",
"clientConfig",
".",
"setMaxErrorRetry",
"(",
"S3_TRANSFER_MAX_RETRIES",
")",
";",
"clientConfig",
".",
"setDisableSocketProxy",
"(",
"HttpUtil",
".",
"isSocksProxyDisabled",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"s3 client configuration: maxConnection={}, connectionTimeout={}, \"",
"+",
"\"socketTimeout={}, maxErrorRetry={}\"",
",",
"clientConfig",
".",
"getMaxConnections",
"(",
")",
",",
"clientConfig",
".",
"getConnectionTimeout",
"(",
")",
",",
"clientConfig",
".",
"getSocketTimeout",
"(",
")",
",",
"clientConfig",
".",
"getMaxErrorRetry",
"(",
")",
")",
";",
"try",
"{",
"s3Client",
"=",
"new",
"SnowflakeS3Client",
"(",
"stageCredentials",
",",
"clientConfig",
",",
"encMat",
",",
"stageRegion",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Exception creating s3 client\"",
",",
"ex",
")",
";",
"throw",
"ex",
";",
"}",
"logger",
".",
"debug",
"(",
"\"s3 client created\"",
")",
";",
"return",
"s3Client",
";",
"}"
]
| Creates a SnowflakeS3ClientObject which encapsulates
the Amazon S3 client
@param stageCredentials Map of stage credential properties
@param parallel degree of parallelism
@param encMat encryption material for the client
@param stageRegion the region where the stage is located
@return the SnowflakeS3Client instance created
@throws SnowflakeSQLException failure to create the S3 client | [
"Creates",
"a",
"SnowflakeS3ClientObject",
"which",
"encapsulates",
"the",
"Amazon",
"S3",
"client"
]
| train | https://github.com/snowflakedb/snowflake-jdbc/blob/98567b5a57753f29d51446809640b969a099658f/src/main/java/net/snowflake/client/jdbc/cloud/storage/StorageClientFactory.java#L92-L128 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.