repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/UserApi.java | UserApi.createCustomAttribute | public CustomAttribute createCustomAttribute(final Object userIdOrUsername, final String key, final String value) throws GitLabApiException {
"""
Creates custom attribute for the given user
@param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
@param key for the customAttribute
@param value or the customAttribute
@return the created CustomAttribute
@throws GitLabApiException on failure while setting customAttributes
"""
if (Objects.isNull(key) || key.trim().isEmpty()) {
throw new IllegalArgumentException("Key can't be null or empty");
}
if (Objects.isNull(value) || value.trim().isEmpty()) {
throw new IllegalArgumentException("Value can't be null or empty");
}
GitLabApiForm formData = new GitLabApiForm().withParam("value", value);
Response response = put(Response.Status.OK, formData.asMap(),
"users", getUserIdOrUsername(userIdOrUsername), "custom_attributes", key);
return (response.readEntity(CustomAttribute.class));
} | java | public CustomAttribute createCustomAttribute(final Object userIdOrUsername, final String key, final String value) throws GitLabApiException {
if (Objects.isNull(key) || key.trim().isEmpty()) {
throw new IllegalArgumentException("Key can't be null or empty");
}
if (Objects.isNull(value) || value.trim().isEmpty()) {
throw new IllegalArgumentException("Value can't be null or empty");
}
GitLabApiForm formData = new GitLabApiForm().withParam("value", value);
Response response = put(Response.Status.OK, formData.asMap(),
"users", getUserIdOrUsername(userIdOrUsername), "custom_attributes", key);
return (response.readEntity(CustomAttribute.class));
} | [
"public",
"CustomAttribute",
"createCustomAttribute",
"(",
"final",
"Object",
"userIdOrUsername",
",",
"final",
"String",
"key",
",",
"final",
"String",
"value",
")",
"throws",
"GitLabApiException",
"{",
"if",
"(",
"Objects",
".",
"isNull",
"(",
"key",
")",
"||",
"key",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Key can't be null or empty\"",
")",
";",
"}",
"if",
"(",
"Objects",
".",
"isNull",
"(",
"value",
")",
"||",
"value",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Value can't be null or empty\"",
")",
";",
"}",
"GitLabApiForm",
"formData",
"=",
"new",
"GitLabApiForm",
"(",
")",
".",
"withParam",
"(",
"\"value\"",
",",
"value",
")",
";",
"Response",
"response",
"=",
"put",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"formData",
".",
"asMap",
"(",
")",
",",
"\"users\"",
",",
"getUserIdOrUsername",
"(",
"userIdOrUsername",
")",
",",
"\"custom_attributes\"",
",",
"key",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"CustomAttribute",
".",
"class",
")",
")",
";",
"}"
] | Creates custom attribute for the given user
@param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
@param key for the customAttribute
@param value or the customAttribute
@return the created CustomAttribute
@throws GitLabApiException on failure while setting customAttributes | [
"Creates",
"custom",
"attribute",
"for",
"the",
"given",
"user"
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/UserApi.java#L911-L924 |
Deep-Symmetry/beat-link | src/main/java/org/deepsymmetry/beatlink/dbserver/Client.java | Client.menuRequest | @SuppressWarnings("SameParameterValue")
public Message menuRequest(Message.KnownType requestType, Message.MenuIdentifier targetMenu,
CdjStatus.TrackSourceSlot slot, Field... arguments)
throws IOException {
"""
Send a request for a menu that we will retrieve items from in subsequent requests. This variant works for
nearly all menus, but when you are trying to request metadata for an unanalyzed (non-rekordbox) track, you
need to use {@link #menuRequestTyped(Message.KnownType, Message.MenuIdentifier, CdjStatus.TrackSourceSlot, CdjStatus.TrackType, Field...)}
and specify the actual type of the track whose metadata you want to retrieve.
@param requestType identifies what kind of menu request to send
@param targetMenu the destination for the response to this query
@param slot the media library of interest for this query
@param arguments the additional arguments needed, if any, to complete the request
@return the {@link Message.KnownType#MENU_AVAILABLE} response reporting how many items are available in the menu
@throws IOException if there is a problem communicating, or if the requested menu is not available
@throws IllegalStateException if {@link #tryLockingForMenuOperations(long, TimeUnit)} was not called successfully
before attempting this call
"""
return menuRequestTyped(requestType, targetMenu, slot, CdjStatus.TrackType.REKORDBOX, arguments);
} | java | @SuppressWarnings("SameParameterValue")
public Message menuRequest(Message.KnownType requestType, Message.MenuIdentifier targetMenu,
CdjStatus.TrackSourceSlot slot, Field... arguments)
throws IOException {
return menuRequestTyped(requestType, targetMenu, slot, CdjStatus.TrackType.REKORDBOX, arguments);
} | [
"@",
"SuppressWarnings",
"(",
"\"SameParameterValue\"",
")",
"public",
"Message",
"menuRequest",
"(",
"Message",
".",
"KnownType",
"requestType",
",",
"Message",
".",
"MenuIdentifier",
"targetMenu",
",",
"CdjStatus",
".",
"TrackSourceSlot",
"slot",
",",
"Field",
"...",
"arguments",
")",
"throws",
"IOException",
"{",
"return",
"menuRequestTyped",
"(",
"requestType",
",",
"targetMenu",
",",
"slot",
",",
"CdjStatus",
".",
"TrackType",
".",
"REKORDBOX",
",",
"arguments",
")",
";",
"}"
] | Send a request for a menu that we will retrieve items from in subsequent requests. This variant works for
nearly all menus, but when you are trying to request metadata for an unanalyzed (non-rekordbox) track, you
need to use {@link #menuRequestTyped(Message.KnownType, Message.MenuIdentifier, CdjStatus.TrackSourceSlot, CdjStatus.TrackType, Field...)}
and specify the actual type of the track whose metadata you want to retrieve.
@param requestType identifies what kind of menu request to send
@param targetMenu the destination for the response to this query
@param slot the media library of interest for this query
@param arguments the additional arguments needed, if any, to complete the request
@return the {@link Message.KnownType#MENU_AVAILABLE} response reporting how many items are available in the menu
@throws IOException if there is a problem communicating, or if the requested menu is not available
@throws IllegalStateException if {@link #tryLockingForMenuOperations(long, TimeUnit)} was not called successfully
before attempting this call | [
"Send",
"a",
"request",
"for",
"a",
"menu",
"that",
"we",
"will",
"retrieve",
"items",
"from",
"in",
"subsequent",
"requests",
".",
"This",
"variant",
"works",
"for",
"nearly",
"all",
"menus",
"but",
"when",
"you",
"are",
"trying",
"to",
"request",
"metadata",
"for",
"an",
"unanalyzed",
"(",
"non",
"-",
"rekordbox",
")",
"track",
"you",
"need",
"to",
"use",
"{",
"@link",
"#menuRequestTyped",
"(",
"Message",
".",
"KnownType",
"Message",
".",
"MenuIdentifier",
"CdjStatus",
".",
"TrackSourceSlot",
"CdjStatus",
".",
"TrackType",
"Field",
"...",
")",
"}",
"and",
"specify",
"the",
"actual",
"type",
"of",
"the",
"track",
"whose",
"metadata",
"you",
"want",
"to",
"retrieve",
"."
] | train | https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/dbserver/Client.java#L380-L385 |
yavijava/yavijava | src/main/java/com/vmware/vim25/mo/VRPResourceManager.java | VRPResourceManager.undeployVM | public void undeployVM(String vrpId, VirtualMachine vm, ClusterComputeResource cluster) throws InvalidState, NotFound, RuntimeFault, RemoteException {
"""
Undeploy a VM in given VRP, hub pair.
@param vrpId The unique Id of the VRP.
@param vm VirtualMachine
@param cluster Cluster Object
@throws InvalidState
@throws NotFound
@throws RuntimeFault
@throws RemoteException
"""
getVimService().undeployVM(getMOR(), vrpId, vm.getMOR(), cluster.getMOR());
} | java | public void undeployVM(String vrpId, VirtualMachine vm, ClusterComputeResource cluster) throws InvalidState, NotFound, RuntimeFault, RemoteException {
getVimService().undeployVM(getMOR(), vrpId, vm.getMOR(), cluster.getMOR());
} | [
"public",
"void",
"undeployVM",
"(",
"String",
"vrpId",
",",
"VirtualMachine",
"vm",
",",
"ClusterComputeResource",
"cluster",
")",
"throws",
"InvalidState",
",",
"NotFound",
",",
"RuntimeFault",
",",
"RemoteException",
"{",
"getVimService",
"(",
")",
".",
"undeployVM",
"(",
"getMOR",
"(",
")",
",",
"vrpId",
",",
"vm",
".",
"getMOR",
"(",
")",
",",
"cluster",
".",
"getMOR",
"(",
")",
")",
";",
"}"
] | Undeploy a VM in given VRP, hub pair.
@param vrpId The unique Id of the VRP.
@param vm VirtualMachine
@param cluster Cluster Object
@throws InvalidState
@throws NotFound
@throws RuntimeFault
@throws RemoteException | [
"Undeploy",
"a",
"VM",
"in",
"given",
"VRP",
"hub",
"pair",
"."
] | train | https://github.com/yavijava/yavijava/blob/27fd2c5826115782d5eeb934f86e3e39240179cd/src/main/java/com/vmware/vim25/mo/VRPResourceManager.java#L195-L197 |
apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/job_catalog/NonObservingFSJobCatalog.java | NonObservingFSJobCatalog.remove | @Override
public synchronized void remove(URI jobURI) {
"""
Allow user to programmatically delete a new JobSpec.
This method is designed to be reentrant.
@param jobURI The relative Path that specified by user, need to make it into complete path.
"""
Preconditions.checkState(state() == State.RUNNING, String.format("%s is not running.", this.getClass().getName()));
try {
long startTime = System.currentTimeMillis();
JobSpec jobSpec = getJobSpec(jobURI);
Path jobSpecPath = getPathForURI(this.jobConfDirPath, jobURI);
if (fs.exists(jobSpecPath)) {
fs.delete(jobSpecPath, false);
this.mutableMetrics.updateRemoveJobTime(startTime);
this.listeners.onDeleteJob(jobURI, jobSpec.getVersion());
} else {
LOGGER.warn("No file with URI:" + jobSpecPath + " is found. Deletion failed.");
}
} catch (IOException e) {
throw new RuntimeException("When removing a JobConf. file, issues unexpected happen:" + e.getMessage());
} catch (SpecNotFoundException e) {
LOGGER.warn("No file with URI:" + jobURI + " is found. Deletion failed.");
}
} | java | @Override
public synchronized void remove(URI jobURI) {
Preconditions.checkState(state() == State.RUNNING, String.format("%s is not running.", this.getClass().getName()));
try {
long startTime = System.currentTimeMillis();
JobSpec jobSpec = getJobSpec(jobURI);
Path jobSpecPath = getPathForURI(this.jobConfDirPath, jobURI);
if (fs.exists(jobSpecPath)) {
fs.delete(jobSpecPath, false);
this.mutableMetrics.updateRemoveJobTime(startTime);
this.listeners.onDeleteJob(jobURI, jobSpec.getVersion());
} else {
LOGGER.warn("No file with URI:" + jobSpecPath + " is found. Deletion failed.");
}
} catch (IOException e) {
throw new RuntimeException("When removing a JobConf. file, issues unexpected happen:" + e.getMessage());
} catch (SpecNotFoundException e) {
LOGGER.warn("No file with URI:" + jobURI + " is found. Deletion failed.");
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"remove",
"(",
"URI",
"jobURI",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"state",
"(",
")",
"==",
"State",
".",
"RUNNING",
",",
"String",
".",
"format",
"(",
"\"%s is not running.\"",
",",
"this",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
";",
"try",
"{",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"JobSpec",
"jobSpec",
"=",
"getJobSpec",
"(",
"jobURI",
")",
";",
"Path",
"jobSpecPath",
"=",
"getPathForURI",
"(",
"this",
".",
"jobConfDirPath",
",",
"jobURI",
")",
";",
"if",
"(",
"fs",
".",
"exists",
"(",
"jobSpecPath",
")",
")",
"{",
"fs",
".",
"delete",
"(",
"jobSpecPath",
",",
"false",
")",
";",
"this",
".",
"mutableMetrics",
".",
"updateRemoveJobTime",
"(",
"startTime",
")",
";",
"this",
".",
"listeners",
".",
"onDeleteJob",
"(",
"jobURI",
",",
"jobSpec",
".",
"getVersion",
"(",
")",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"No file with URI:\"",
"+",
"jobSpecPath",
"+",
"\" is found. Deletion failed.\"",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"When removing a JobConf. file, issues unexpected happen:\"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"SpecNotFoundException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"No file with URI:\"",
"+",
"jobURI",
"+",
"\" is found. Deletion failed.\"",
")",
";",
"}",
"}"
] | Allow user to programmatically delete a new JobSpec.
This method is designed to be reentrant.
@param jobURI The relative Path that specified by user, need to make it into complete path. | [
"Allow",
"user",
"to",
"programmatically",
"delete",
"a",
"new",
"JobSpec",
".",
"This",
"method",
"is",
"designed",
"to",
"be",
"reentrant",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/job_catalog/NonObservingFSJobCatalog.java#L103-L123 |
querydsl/querydsl | querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java | Expressions.stringTemplate | public static StringTemplate stringTemplate(String template, List<?> args) {
"""
Create a new Template expression
@param template template
@param args template parameters
@return template expression
"""
return stringTemplate(createTemplate(template), args);
} | java | public static StringTemplate stringTemplate(String template, List<?> args) {
return stringTemplate(createTemplate(template), args);
} | [
"public",
"static",
"StringTemplate",
"stringTemplate",
"(",
"String",
"template",
",",
"List",
"<",
"?",
">",
"args",
")",
"{",
"return",
"stringTemplate",
"(",
"createTemplate",
"(",
"template",
")",
",",
"args",
")",
";",
"}"
] | Create a new Template expression
@param template template
@param args template parameters
@return template expression | [
"Create",
"a",
"new",
"Template",
"expression"
] | train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java#L913-L915 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRTransform.java | GVRTransform.rotate | public void rotate(float w, float x, float y, float z) {
"""
Modify the tranform's current rotation in quaternion terms.
@param w
'W' component of the quaternion.
@param x
'X' component of the quaternion.
@param y
'Y' component of the quaternion.
@param z
'Z' component of the quaternion.
"""
NativeTransform.rotate(getNative(), w, x, y, z);
} | java | public void rotate(float w, float x, float y, float z) {
NativeTransform.rotate(getNative(), w, x, y, z);
} | [
"public",
"void",
"rotate",
"(",
"float",
"w",
",",
"float",
"x",
",",
"float",
"y",
",",
"float",
"z",
")",
"{",
"NativeTransform",
".",
"rotate",
"(",
"getNative",
"(",
")",
",",
"w",
",",
"x",
",",
"y",
",",
"z",
")",
";",
"}"
] | Modify the tranform's current rotation in quaternion terms.
@param w
'W' component of the quaternion.
@param x
'X' component of the quaternion.
@param y
'Y' component of the quaternion.
@param z
'Z' component of the quaternion. | [
"Modify",
"the",
"tranform",
"s",
"current",
"rotation",
"in",
"quaternion",
"terms",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRTransform.java#L428-L430 |
jenkinsci/jenkins | core/src/main/java/hudson/security/TokenBasedRememberMeServices2.java | TokenBasedRememberMeServices2.secureCookie | private void secureCookie(Cookie cookie, HttpServletRequest request) {
"""
Force always the http-only flag and depending on the request, put also the secure flag.
"""
// if we can mark the cookie HTTP only, do so to protect this cookie even in case of XSS vulnerability.
if (SET_HTTP_ONLY!=null) {
try {
SET_HTTP_ONLY.invoke(cookie,true);
} catch (IllegalAccessException | InvocationTargetException e) {
// ignore
}
}
// if the user is running Jenkins over HTTPS, we also want to prevent the cookie from leaking in HTTP.
// whether the login is done over HTTPS or not would be a good enough approximation of whether Jenkins runs in
// HTTPS or not, so use that.
cookie.setSecure(request.isSecure());
} | java | private void secureCookie(Cookie cookie, HttpServletRequest request){
// if we can mark the cookie HTTP only, do so to protect this cookie even in case of XSS vulnerability.
if (SET_HTTP_ONLY!=null) {
try {
SET_HTTP_ONLY.invoke(cookie,true);
} catch (IllegalAccessException | InvocationTargetException e) {
// ignore
}
}
// if the user is running Jenkins over HTTPS, we also want to prevent the cookie from leaking in HTTP.
// whether the login is done over HTTPS or not would be a good enough approximation of whether Jenkins runs in
// HTTPS or not, so use that.
cookie.setSecure(request.isSecure());
} | [
"private",
"void",
"secureCookie",
"(",
"Cookie",
"cookie",
",",
"HttpServletRequest",
"request",
")",
"{",
"// if we can mark the cookie HTTP only, do so to protect this cookie even in case of XSS vulnerability.",
"if",
"(",
"SET_HTTP_ONLY",
"!=",
"null",
")",
"{",
"try",
"{",
"SET_HTTP_ONLY",
".",
"invoke",
"(",
"cookie",
",",
"true",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InvocationTargetException",
"e",
")",
"{",
"// ignore",
"}",
"}",
"// if the user is running Jenkins over HTTPS, we also want to prevent the cookie from leaking in HTTP.",
"// whether the login is done over HTTPS or not would be a good enough approximation of whether Jenkins runs in",
"// HTTPS or not, so use that.",
"cookie",
".",
"setSecure",
"(",
"request",
".",
"isSecure",
"(",
")",
")",
";",
"}"
] | Force always the http-only flag and depending on the request, put also the secure flag. | [
"Force",
"always",
"the",
"http",
"-",
"only",
"flag",
"and",
"depending",
"on",
"the",
"request",
"put",
"also",
"the",
"secure",
"flag",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/security/TokenBasedRememberMeServices2.java#L309-L323 |
redkale/redkale | src/org/redkale/util/ResourceFactory.java | ResourceFactory.register | public <A> A register(final String name, final Type clazz, final A rs) {
"""
将对象以指定资源名和类型注入到资源池中,并同步已被注入的资源
@param <A> 泛型
@param name 资源名
@param clazz 资源类型
@param rs 资源对象
@return 旧资源对象
"""
return register(true, name, clazz, rs);
} | java | public <A> A register(final String name, final Type clazz, final A rs) {
return register(true, name, clazz, rs);
} | [
"public",
"<",
"A",
">",
"A",
"register",
"(",
"final",
"String",
"name",
",",
"final",
"Type",
"clazz",
",",
"final",
"A",
"rs",
")",
"{",
"return",
"register",
"(",
"true",
",",
"name",
",",
"clazz",
",",
"rs",
")",
";",
"}"
] | 将对象以指定资源名和类型注入到资源池中,并同步已被注入的资源
@param <A> 泛型
@param name 资源名
@param clazz 资源类型
@param rs 资源对象
@return 旧资源对象 | [
"将对象以指定资源名和类型注入到资源池中,并同步已被注入的资源"
] | train | https://github.com/redkale/redkale/blob/ea5169b5c5ea7412fd762331c0c497165832e901/src/org/redkale/util/ResourceFactory.java#L386-L388 |
Deep-Symmetry/beat-link | src/main/java/org/deepsymmetry/beatlink/LifecycleParticipant.java | LifecycleParticipant.deliverLifecycleAnnouncement | protected void deliverLifecycleAnnouncement(final Logger logger, final boolean starting) {
"""
Send a lifecycle announcement to all registered listeners.
@param logger the logger to use, so the log entry shows as belonging to the proper subclass.
@param starting will be {@code true} if the DeviceFinder is starting, {@code false} if it is stopping.
"""
new Thread(new Runnable() {
@Override
public void run() {
for (final LifecycleListener listener : getLifecycleListeners()) {
try {
if (starting) {
listener.started(LifecycleParticipant.this);
} else {
listener.stopped(LifecycleParticipant.this);
}
} catch (Throwable t) {
logger.warn("Problem delivering lifecycle announcement to listener", t);
}
}
}
}, "Lifecycle announcement delivery").start();
} | java | protected void deliverLifecycleAnnouncement(final Logger logger, final boolean starting) {
new Thread(new Runnable() {
@Override
public void run() {
for (final LifecycleListener listener : getLifecycleListeners()) {
try {
if (starting) {
listener.started(LifecycleParticipant.this);
} else {
listener.stopped(LifecycleParticipant.this);
}
} catch (Throwable t) {
logger.warn("Problem delivering lifecycle announcement to listener", t);
}
}
}
}, "Lifecycle announcement delivery").start();
} | [
"protected",
"void",
"deliverLifecycleAnnouncement",
"(",
"final",
"Logger",
"logger",
",",
"final",
"boolean",
"starting",
")",
"{",
"new",
"Thread",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"for",
"(",
"final",
"LifecycleListener",
"listener",
":",
"getLifecycleListeners",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"starting",
")",
"{",
"listener",
".",
"started",
"(",
"LifecycleParticipant",
".",
"this",
")",
";",
"}",
"else",
"{",
"listener",
".",
"stopped",
"(",
"LifecycleParticipant",
".",
"this",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Problem delivering lifecycle announcement to listener\"",
",",
"t",
")",
";",
"}",
"}",
"}",
"}",
",",
"\"Lifecycle announcement delivery\"",
")",
".",
"start",
"(",
")",
";",
"}"
] | Send a lifecycle announcement to all registered listeners.
@param logger the logger to use, so the log entry shows as belonging to the proper subclass.
@param starting will be {@code true} if the DeviceFinder is starting, {@code false} if it is stopping. | [
"Send",
"a",
"lifecycle",
"announcement",
"to",
"all",
"registered",
"listeners",
"."
] | train | https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/LifecycleParticipant.java#L69-L86 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/SameDiff.java | SameDiff.putFunctionForId | public void putFunctionForId(String id, DifferentialFunction function) {
"""
Put the function for the given id
@param id the id of the function
@param function the function
"""
if (ops.containsKey(id) && ops.get(id).getOp() == null) {
throw new ND4JIllegalStateException("Function by id already exists!");
} else if (function instanceof SDVariable) {
throw new ND4JIllegalStateException("Function must not be a variable!");
}
if(ops.containsKey(id)){
} else {
ops.put(id, SameDiffOp.builder().name(id).op(function).build());
}
} | java | public void putFunctionForId(String id, DifferentialFunction function) {
if (ops.containsKey(id) && ops.get(id).getOp() == null) {
throw new ND4JIllegalStateException("Function by id already exists!");
} else if (function instanceof SDVariable) {
throw new ND4JIllegalStateException("Function must not be a variable!");
}
if(ops.containsKey(id)){
} else {
ops.put(id, SameDiffOp.builder().name(id).op(function).build());
}
} | [
"public",
"void",
"putFunctionForId",
"(",
"String",
"id",
",",
"DifferentialFunction",
"function",
")",
"{",
"if",
"(",
"ops",
".",
"containsKey",
"(",
"id",
")",
"&&",
"ops",
".",
"get",
"(",
"id",
")",
".",
"getOp",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"ND4JIllegalStateException",
"(",
"\"Function by id already exists!\"",
")",
";",
"}",
"else",
"if",
"(",
"function",
"instanceof",
"SDVariable",
")",
"{",
"throw",
"new",
"ND4JIllegalStateException",
"(",
"\"Function must not be a variable!\"",
")",
";",
"}",
"if",
"(",
"ops",
".",
"containsKey",
"(",
"id",
")",
")",
"{",
"}",
"else",
"{",
"ops",
".",
"put",
"(",
"id",
",",
"SameDiffOp",
".",
"builder",
"(",
")",
".",
"name",
"(",
"id",
")",
".",
"op",
"(",
"function",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"}"
] | Put the function for the given id
@param id the id of the function
@param function the function | [
"Put",
"the",
"function",
"for",
"the",
"given",
"id"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/SameDiff.java#L519-L531 |
jiaqi/jcli | src/main/java/org/cyclopsgroup/jcli/ArgumentProcessor.java | ArgumentProcessor.forType | public static <T> ArgumentProcessor<T> forType(Class<? extends T> beanType) {
"""
Create new instance with default parser, a {@link GnuParser}
@param <T> Type of the bean
@param beanType Type of the bean
@return Instance of an implementation of argument processor
"""
return newInstance(beanType, new GnuParser());
} | java | public static <T> ArgumentProcessor<T> forType(Class<? extends T> beanType) {
return newInstance(beanType, new GnuParser());
} | [
"public",
"static",
"<",
"T",
">",
"ArgumentProcessor",
"<",
"T",
">",
"forType",
"(",
"Class",
"<",
"?",
"extends",
"T",
">",
"beanType",
")",
"{",
"return",
"newInstance",
"(",
"beanType",
",",
"new",
"GnuParser",
"(",
")",
")",
";",
"}"
] | Create new instance with default parser, a {@link GnuParser}
@param <T> Type of the bean
@param beanType Type of the bean
@return Instance of an implementation of argument processor | [
"Create",
"new",
"instance",
"with",
"default",
"parser",
"a",
"{",
"@link",
"GnuParser",
"}"
] | train | https://github.com/jiaqi/jcli/blob/3854b3bb3c26bbe7407bf1b6600d8b25592d398e/src/main/java/org/cyclopsgroup/jcli/ArgumentProcessor.java#L25-L27 |
hdbeukel/james-extensions | src/main/java/org/jamesframework/ext/problems/objectives/WeightedIndex.java | WeightedIndex.addObjective | public void addObjective(Objective<? super SolutionType, ? super DataType> objective, double weight) {
"""
Add an objective with corresponding weight. Any objective designed for the solution type and data type of this
multi-objective (or for more general solution or data types) can be added. The specified weight should be strictly
positive, if not, an exception will be thrown.
@param objective objective to be added
@param weight corresponding weight (strictly positive)
@throws IllegalArgumentException if the specified weight is not strictly positive
"""
// check weight
if(weight > 0.0){
// add objective to map
weights.put(objective, weight);
} else {
throw new IllegalArgumentException("Error in weighted index: each objective's weight should be strictly positive.");
}
} | java | public void addObjective(Objective<? super SolutionType, ? super DataType> objective, double weight) {
// check weight
if(weight > 0.0){
// add objective to map
weights.put(objective, weight);
} else {
throw new IllegalArgumentException("Error in weighted index: each objective's weight should be strictly positive.");
}
} | [
"public",
"void",
"addObjective",
"(",
"Objective",
"<",
"?",
"super",
"SolutionType",
",",
"?",
"super",
"DataType",
">",
"objective",
",",
"double",
"weight",
")",
"{",
"// check weight",
"if",
"(",
"weight",
">",
"0.0",
")",
"{",
"// add objective to map",
"weights",
".",
"put",
"(",
"objective",
",",
"weight",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Error in weighted index: each objective's weight should be strictly positive.\"",
")",
";",
"}",
"}"
] | Add an objective with corresponding weight. Any objective designed for the solution type and data type of this
multi-objective (or for more general solution or data types) can be added. The specified weight should be strictly
positive, if not, an exception will be thrown.
@param objective objective to be added
@param weight corresponding weight (strictly positive)
@throws IllegalArgumentException if the specified weight is not strictly positive | [
"Add",
"an",
"objective",
"with",
"corresponding",
"weight",
".",
"Any",
"objective",
"designed",
"for",
"the",
"solution",
"type",
"and",
"data",
"type",
"of",
"this",
"multi",
"-",
"objective",
"(",
"or",
"for",
"more",
"general",
"solution",
"or",
"data",
"types",
")",
"can",
"be",
"added",
".",
"The",
"specified",
"weight",
"should",
"be",
"strictly",
"positive",
"if",
"not",
"an",
"exception",
"will",
"be",
"thrown",
"."
] | train | https://github.com/hdbeukel/james-extensions/blob/37a43aa6ac4d67575cabc7aed25fd96c91d4c7b2/src/main/java/org/jamesframework/ext/problems/objectives/WeightedIndex.java#L58-L66 |
Deep-Symmetry/beat-link | src/main/java/org/deepsymmetry/beatlink/data/WaveformPreviewComponent.java | WaveformPreviewComponent.updateWaveform | private void updateWaveform(WaveformPreview preview) {
"""
Create an image of the proper size to hold a new waveform preview image and draw it.
"""
this.preview.set(preview);
if (preview == null) {
waveformImage.set(null);
} else {
BufferedImage image = new BufferedImage(preview.segmentCount, preview.maxHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(Color.BLACK);
g.fillRect(0, 0, preview.segmentCount, preview.maxHeight);
for (int segment = 0; segment < preview.segmentCount; segment++) {
g.setColor(preview.segmentColor(segment, false));
g.drawLine(segment, preview.maxHeight, segment, preview.maxHeight - preview.segmentHeight(segment, false));
if (preview.isColor) { // We have a front color segment to draw on top.
g.setColor(preview.segmentColor(segment, true));
g.drawLine(segment, preview.maxHeight, segment, preview.maxHeight - preview.segmentHeight(segment, true));
}
}
waveformImage.set(image);
}
} | java | private void updateWaveform(WaveformPreview preview) {
this.preview.set(preview);
if (preview == null) {
waveformImage.set(null);
} else {
BufferedImage image = new BufferedImage(preview.segmentCount, preview.maxHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(Color.BLACK);
g.fillRect(0, 0, preview.segmentCount, preview.maxHeight);
for (int segment = 0; segment < preview.segmentCount; segment++) {
g.setColor(preview.segmentColor(segment, false));
g.drawLine(segment, preview.maxHeight, segment, preview.maxHeight - preview.segmentHeight(segment, false));
if (preview.isColor) { // We have a front color segment to draw on top.
g.setColor(preview.segmentColor(segment, true));
g.drawLine(segment, preview.maxHeight, segment, preview.maxHeight - preview.segmentHeight(segment, true));
}
}
waveformImage.set(image);
}
} | [
"private",
"void",
"updateWaveform",
"(",
"WaveformPreview",
"preview",
")",
"{",
"this",
".",
"preview",
".",
"set",
"(",
"preview",
")",
";",
"if",
"(",
"preview",
"==",
"null",
")",
"{",
"waveformImage",
".",
"set",
"(",
"null",
")",
";",
"}",
"else",
"{",
"BufferedImage",
"image",
"=",
"new",
"BufferedImage",
"(",
"preview",
".",
"segmentCount",
",",
"preview",
".",
"maxHeight",
",",
"BufferedImage",
".",
"TYPE_INT_RGB",
")",
";",
"Graphics",
"g",
"=",
"image",
".",
"getGraphics",
"(",
")",
";",
"g",
".",
"setColor",
"(",
"Color",
".",
"BLACK",
")",
";",
"g",
".",
"fillRect",
"(",
"0",
",",
"0",
",",
"preview",
".",
"segmentCount",
",",
"preview",
".",
"maxHeight",
")",
";",
"for",
"(",
"int",
"segment",
"=",
"0",
";",
"segment",
"<",
"preview",
".",
"segmentCount",
";",
"segment",
"++",
")",
"{",
"g",
".",
"setColor",
"(",
"preview",
".",
"segmentColor",
"(",
"segment",
",",
"false",
")",
")",
";",
"g",
".",
"drawLine",
"(",
"segment",
",",
"preview",
".",
"maxHeight",
",",
"segment",
",",
"preview",
".",
"maxHeight",
"-",
"preview",
".",
"segmentHeight",
"(",
"segment",
",",
"false",
")",
")",
";",
"if",
"(",
"preview",
".",
"isColor",
")",
"{",
"// We have a front color segment to draw on top.",
"g",
".",
"setColor",
"(",
"preview",
".",
"segmentColor",
"(",
"segment",
",",
"true",
")",
")",
";",
"g",
".",
"drawLine",
"(",
"segment",
",",
"preview",
".",
"maxHeight",
",",
"segment",
",",
"preview",
".",
"maxHeight",
"-",
"preview",
".",
"segmentHeight",
"(",
"segment",
",",
"true",
")",
")",
";",
"}",
"}",
"waveformImage",
".",
"set",
"(",
"image",
")",
";",
"}",
"}"
] | Create an image of the proper size to hold a new waveform preview image and draw it. | [
"Create",
"an",
"image",
"of",
"the",
"proper",
"size",
"to",
"hold",
"a",
"new",
"waveform",
"preview",
"image",
"and",
"draw",
"it",
"."
] | train | https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/data/WaveformPreviewComponent.java#L420-L439 |
google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.process | @Override
public void process(Node externs, Node root) {
"""
Traverses the root, removing all unused variables. Multiple traversals
may occur to ensure all unused variables are removed.
"""
checkState(compiler.getLifeCycleStage().isNormalized());
if (!allowRemovalOfExternProperties) {
referencedPropertyNames.addAll(compiler.getExternProperties());
}
traverseAndRemoveUnusedReferences(root);
// This pass may remove definitions of getter or setter properties.
GatherGettersAndSetterProperties.update(compiler, externs, root);
} | java | @Override
public void process(Node externs, Node root) {
checkState(compiler.getLifeCycleStage().isNormalized());
if (!allowRemovalOfExternProperties) {
referencedPropertyNames.addAll(compiler.getExternProperties());
}
traverseAndRemoveUnusedReferences(root);
// This pass may remove definitions of getter or setter properties.
GatherGettersAndSetterProperties.update(compiler, externs, root);
} | [
"@",
"Override",
"public",
"void",
"process",
"(",
"Node",
"externs",
",",
"Node",
"root",
")",
"{",
"checkState",
"(",
"compiler",
".",
"getLifeCycleStage",
"(",
")",
".",
"isNormalized",
"(",
")",
")",
";",
"if",
"(",
"!",
"allowRemovalOfExternProperties",
")",
"{",
"referencedPropertyNames",
".",
"addAll",
"(",
"compiler",
".",
"getExternProperties",
"(",
")",
")",
";",
"}",
"traverseAndRemoveUnusedReferences",
"(",
"root",
")",
";",
"// This pass may remove definitions of getter or setter properties.",
"GatherGettersAndSetterProperties",
".",
"update",
"(",
"compiler",
",",
"externs",
",",
"root",
")",
";",
"}"
] | Traverses the root, removing all unused variables. Multiple traversals
may occur to ensure all unused variables are removed. | [
"Traverses",
"the",
"root",
"removing",
"all",
"unused",
"variables",
".",
"Multiple",
"traversals",
"may",
"occur",
"to",
"ensure",
"all",
"unused",
"variables",
"are",
"removed",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L242-L251 |
before/uadetector | modules/uadetector-resources/src/main/java/net/sf/uadetector/service/UADetectorServiceFactory.java | UADetectorServiceFactory.getCachingAndUpdatingParser | public static UserAgentStringParser getCachingAndUpdatingParser(final URL dataUrl, final URL versionUrl, final URL fallbackDataURL, final URL fallbackVersionURL) {
"""
Returns an implementation of {@link UserAgentStringParser} which checks at regular intervals for new versions of
<em>UAS data</em> (also known as database). When newer data available, it automatically loads and updates it.
Additionally the loaded data are stored in a cache file.
<p>
At initialization time the returned parser will be loaded with the <em>UAS data</em> of the cache file. If the
cache file doesn't exist or is empty the data of this module will be loaded. The initialization is started only
when this method is called the first time.
<p>
The update of the data store runs as background task. With this feature we try to reduce the initialization time
of this <code>UserAgentStringParser</code>, because a network connection is involved and the remote system can be
not available or slow.
<p>
The static class definition {@code CachingAndUpdatingParserHolder} within this factory class is <em>not</em>
initialized until the JVM determines that {@code CachingAndUpdatingParserHolder} must be executed. The static
class {@code CachingAndUpdatingParserHolder} is only executed when the static method
{@code getOnlineUserAgentStringParser} is invoked on the class {@code UADetectorServiceFactory}, and the first
time this happens the JVM will load and initialize the {@code CachingAndUpdatingParserHolder} class.
<p>
If during the operation the Internet connection gets lost, then this instance continues to work properly (and
under correct log level settings you will get an corresponding log messages).
@param dataUrl
@param versionUrl
@param fallbackDataURL
@param fallbackVersionURL
@return an user agent string parser with updating service
"""
return CachingAndUpdatingParserHolder.getParser(dataUrl, versionUrl, getCustomFallbackXmlDataStore(fallbackDataURL, fallbackVersionURL));
} | java | public static UserAgentStringParser getCachingAndUpdatingParser(final URL dataUrl, final URL versionUrl, final URL fallbackDataURL, final URL fallbackVersionURL) {
return CachingAndUpdatingParserHolder.getParser(dataUrl, versionUrl, getCustomFallbackXmlDataStore(fallbackDataURL, fallbackVersionURL));
} | [
"public",
"static",
"UserAgentStringParser",
"getCachingAndUpdatingParser",
"(",
"final",
"URL",
"dataUrl",
",",
"final",
"URL",
"versionUrl",
",",
"final",
"URL",
"fallbackDataURL",
",",
"final",
"URL",
"fallbackVersionURL",
")",
"{",
"return",
"CachingAndUpdatingParserHolder",
".",
"getParser",
"(",
"dataUrl",
",",
"versionUrl",
",",
"getCustomFallbackXmlDataStore",
"(",
"fallbackDataURL",
",",
"fallbackVersionURL",
")",
")",
";",
"}"
] | Returns an implementation of {@link UserAgentStringParser} which checks at regular intervals for new versions of
<em>UAS data</em> (also known as database). When newer data available, it automatically loads and updates it.
Additionally the loaded data are stored in a cache file.
<p>
At initialization time the returned parser will be loaded with the <em>UAS data</em> of the cache file. If the
cache file doesn't exist or is empty the data of this module will be loaded. The initialization is started only
when this method is called the first time.
<p>
The update of the data store runs as background task. With this feature we try to reduce the initialization time
of this <code>UserAgentStringParser</code>, because a network connection is involved and the remote system can be
not available or slow.
<p>
The static class definition {@code CachingAndUpdatingParserHolder} within this factory class is <em>not</em>
initialized until the JVM determines that {@code CachingAndUpdatingParserHolder} must be executed. The static
class {@code CachingAndUpdatingParserHolder} is only executed when the static method
{@code getOnlineUserAgentStringParser} is invoked on the class {@code UADetectorServiceFactory}, and the first
time this happens the JVM will load and initialize the {@code CachingAndUpdatingParserHolder} class.
<p>
If during the operation the Internet connection gets lost, then this instance continues to work properly (and
under correct log level settings you will get an corresponding log messages).
@param dataUrl
@param versionUrl
@param fallbackDataURL
@param fallbackVersionURL
@return an user agent string parser with updating service | [
"Returns",
"an",
"implementation",
"of",
"{",
"@link",
"UserAgentStringParser",
"}",
"which",
"checks",
"at",
"regular",
"intervals",
"for",
"new",
"versions",
"of",
"<em",
">",
"UAS",
"data<",
"/",
"em",
">",
"(",
"also",
"known",
"as",
"database",
")",
".",
"When",
"newer",
"data",
"available",
"it",
"automatically",
"loads",
"and",
"updates",
"it",
".",
"Additionally",
"the",
"loaded",
"data",
"are",
"stored",
"in",
"a",
"cache",
"file",
"."
] | train | https://github.com/before/uadetector/blob/215fb652723c52866572cff885f52a3fe67b9db5/modules/uadetector-resources/src/main/java/net/sf/uadetector/service/UADetectorServiceFactory.java#L206-L208 |
pietermartin/sqlg | sqlg-core/src/main/java/org/umlg/sqlg/structure/topology/Partition.java | Partition.createRangeSubPartitionWithPartition | private static Partition createRangeSubPartitionWithPartition(
SqlgGraph sqlgGraph,
Partition parentPartition,
String name,
String from,
String to,
PartitionType partitionType,
String partitionExpression) {
"""
Create a range partition on an existing {@link Partition}
@param sqlgGraph
@param parentPartition
@param name
@param from
@param to
@return
"""
Preconditions.checkArgument(!parentPartition.getAbstractLabel().getSchema().isSqlgSchema(), "createRangeSubPartitionWithPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA);
Partition partition = new Partition(sqlgGraph, parentPartition, name, from, to, partitionType, partitionExpression);
partition.createRangePartitionOnDb();
TopologyManager.addSubPartition(sqlgGraph, partition);
partition.committed = false;
return partition;
} | java | private static Partition createRangeSubPartitionWithPartition(
SqlgGraph sqlgGraph,
Partition parentPartition,
String name,
String from,
String to,
PartitionType partitionType,
String partitionExpression) {
Preconditions.checkArgument(!parentPartition.getAbstractLabel().getSchema().isSqlgSchema(), "createRangeSubPartitionWithPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA);
Partition partition = new Partition(sqlgGraph, parentPartition, name, from, to, partitionType, partitionExpression);
partition.createRangePartitionOnDb();
TopologyManager.addSubPartition(sqlgGraph, partition);
partition.committed = false;
return partition;
} | [
"private",
"static",
"Partition",
"createRangeSubPartitionWithPartition",
"(",
"SqlgGraph",
"sqlgGraph",
",",
"Partition",
"parentPartition",
",",
"String",
"name",
",",
"String",
"from",
",",
"String",
"to",
",",
"PartitionType",
"partitionType",
",",
"String",
"partitionExpression",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"parentPartition",
".",
"getAbstractLabel",
"(",
")",
".",
"getSchema",
"(",
")",
".",
"isSqlgSchema",
"(",
")",
",",
"\"createRangeSubPartitionWithPartition may not be called for \\\"%s\\\"\"",
",",
"Topology",
".",
"SQLG_SCHEMA",
")",
";",
"Partition",
"partition",
"=",
"new",
"Partition",
"(",
"sqlgGraph",
",",
"parentPartition",
",",
"name",
",",
"from",
",",
"to",
",",
"partitionType",
",",
"partitionExpression",
")",
";",
"partition",
".",
"createRangePartitionOnDb",
"(",
")",
";",
"TopologyManager",
".",
"addSubPartition",
"(",
"sqlgGraph",
",",
"partition",
")",
";",
"partition",
".",
"committed",
"=",
"false",
";",
"return",
"partition",
";",
"}"
] | Create a range partition on an existing {@link Partition}
@param sqlgGraph
@param parentPartition
@param name
@param from
@param to
@return | [
"Create",
"a",
"range",
"partition",
"on",
"an",
"existing",
"{",
"@link",
"Partition",
"}"
] | train | https://github.com/pietermartin/sqlg/blob/c1845a1b31328a5ffda646873b0369ee72af56a7/sqlg-core/src/main/java/org/umlg/sqlg/structure/topology/Partition.java#L353-L368 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLDataSomeValuesFromImpl_CustomFieldSerializer.java | OWLDataSomeValuesFromImpl_CustomFieldSerializer.serializeInstance | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLDataSomeValuesFromImpl instance) throws SerializationException {
"""
Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful
"""
serialize(streamWriter, instance);
} | java | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLDataSomeValuesFromImpl instance) throws SerializationException {
serialize(streamWriter, instance);
} | [
"@",
"Override",
"public",
"void",
"serializeInstance",
"(",
"SerializationStreamWriter",
"streamWriter",
",",
"OWLDataSomeValuesFromImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"serialize",
"(",
"streamWriter",
",",
"instance",
")",
";",
"}"
] | Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful | [
"Serializes",
"the",
"content",
"of",
"the",
"object",
"into",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamWriter",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLDataSomeValuesFromImpl_CustomFieldSerializer.java#L72-L75 |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/files/FileUtils.java | FileUtils.asCompressedCharSource | public static CharSource asCompressedCharSource(File f, Charset charSet) throws IOException {
"""
Just like {@link Files#asCharSource(java.io.File, java.nio.charset.Charset)}, but decompresses
the incoming data using GZIP.
"""
return asCompressedByteSource(f).asCharSource(charSet);
} | java | public static CharSource asCompressedCharSource(File f, Charset charSet) throws IOException {
return asCompressedByteSource(f).asCharSource(charSet);
} | [
"public",
"static",
"CharSource",
"asCompressedCharSource",
"(",
"File",
"f",
",",
"Charset",
"charSet",
")",
"throws",
"IOException",
"{",
"return",
"asCompressedByteSource",
"(",
"f",
")",
".",
"asCharSource",
"(",
"charSet",
")",
";",
"}"
] | Just like {@link Files#asCharSource(java.io.File, java.nio.charset.Charset)}, but decompresses
the incoming data using GZIP. | [
"Just",
"like",
"{"
] | train | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/files/FileUtils.java#L816-L818 |
samskivert/samskivert | src/main/java/com/samskivert/util/ListUtil.java | ListUtil.removeRef | public static Object removeRef (Object[] list, Object element) {
"""
Removes the first element that is referentially equal to the
supplied element (<code>list[idx] == element</code>). The elements
after the removed element will be slid down the array one spot to
fill the place of the removed element.
@return the object that was removed from the array or null if no
matching object was found.
"""
return remove(REFERENCE_COMP, list, element);
} | java | public static Object removeRef (Object[] list, Object element)
{
return remove(REFERENCE_COMP, list, element);
} | [
"public",
"static",
"Object",
"removeRef",
"(",
"Object",
"[",
"]",
"list",
",",
"Object",
"element",
")",
"{",
"return",
"remove",
"(",
"REFERENCE_COMP",
",",
"list",
",",
"element",
")",
";",
"}"
] | Removes the first element that is referentially equal to the
supplied element (<code>list[idx] == element</code>). The elements
after the removed element will be slid down the array one spot to
fill the place of the removed element.
@return the object that was removed from the array or null if no
matching object was found. | [
"Removes",
"the",
"first",
"element",
"that",
"is",
"referentially",
"equal",
"to",
"the",
"supplied",
"element",
"(",
"<code",
">",
"list",
"[",
"idx",
"]",
"==",
"element<",
"/",
"code",
">",
")",
".",
"The",
"elements",
"after",
"the",
"removed",
"element",
"will",
"be",
"slid",
"down",
"the",
"array",
"one",
"spot",
"to",
"fill",
"the",
"place",
"of",
"the",
"removed",
"element",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ListUtil.java#L368-L371 |
ManfredTremmel/gwt-bean-validators | mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/impl/GtinValidator.java | GtinValidator.isValid | @Override
public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
"""
{@inheritDoc} check if given string is a valid gtin.
@see javax.validation.ConstraintValidator#isValid(java.lang.Object,
javax.validation.ConstraintValidatorContext)
"""
final String valueAsString = Objects.toString(pvalue, null);
if (StringUtils.isEmpty(valueAsString)) {
return true;
}
if (!StringUtils.isNumeric(valueAsString)) {
// EAN must be numeric, but that's handled by digits annotation
return true;
}
if (valueAsString.length() != Gtin8Validator.GTIN8_LENGTH
&& valueAsString.length() != Gtin13Validator.GTIN13_LENGTH) {
// EAN size is wrong, but that's handled by alternate size annotation
return true;
}
// calculate and check checksum (GTIN/EAN)
return CHECK_GTIN.isValid(valueAsString);
} | java | @Override
public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
final String valueAsString = Objects.toString(pvalue, null);
if (StringUtils.isEmpty(valueAsString)) {
return true;
}
if (!StringUtils.isNumeric(valueAsString)) {
// EAN must be numeric, but that's handled by digits annotation
return true;
}
if (valueAsString.length() != Gtin8Validator.GTIN8_LENGTH
&& valueAsString.length() != Gtin13Validator.GTIN13_LENGTH) {
// EAN size is wrong, but that's handled by alternate size annotation
return true;
}
// calculate and check checksum (GTIN/EAN)
return CHECK_GTIN.isValid(valueAsString);
} | [
"@",
"Override",
"public",
"final",
"boolean",
"isValid",
"(",
"final",
"Object",
"pvalue",
",",
"final",
"ConstraintValidatorContext",
"pcontext",
")",
"{",
"final",
"String",
"valueAsString",
"=",
"Objects",
".",
"toString",
"(",
"pvalue",
",",
"null",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"valueAsString",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"StringUtils",
".",
"isNumeric",
"(",
"valueAsString",
")",
")",
"{",
"// EAN must be numeric, but that's handled by digits annotation",
"return",
"true",
";",
"}",
"if",
"(",
"valueAsString",
".",
"length",
"(",
")",
"!=",
"Gtin8Validator",
".",
"GTIN8_LENGTH",
"&&",
"valueAsString",
".",
"length",
"(",
")",
"!=",
"Gtin13Validator",
".",
"GTIN13_LENGTH",
")",
"{",
"// EAN size is wrong, but that's handled by alternate size annotation",
"return",
"true",
";",
"}",
"// calculate and check checksum (GTIN/EAN)",
"return",
"CHECK_GTIN",
".",
"isValid",
"(",
"valueAsString",
")",
";",
"}"
] | {@inheritDoc} check if given string is a valid gtin.
@see javax.validation.ConstraintValidator#isValid(java.lang.Object,
javax.validation.ConstraintValidatorContext) | [
"{",
"@inheritDoc",
"}",
"check",
"if",
"given",
"string",
"is",
"a",
"valid",
"gtin",
"."
] | train | https://github.com/ManfredTremmel/gwt-bean-validators/blob/cff7a2c3d68c2d17bf9d3cc57c79cc16fa8b4d5c/mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/impl/GtinValidator.java#L57-L74 |
wellner/jcarafe | jcarafe-core/src/main/java/cern/colt/map/AbstractIntDoubleMap.java | AbstractIntDoubleMap.keyOf | public int keyOf(final double value) {
"""
Returns the first key the given value is associated with.
It is often a good idea to first check with {@link #containsValue(double)} whether there exists an association from a key to this value.
Search order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
@param value the value to search for.
@return the first key for which holds <tt>get(key) == value</tt>;
returns <tt>Integer.MIN_VALUE</tt> if no such key exists.
"""
final int[] foundKey = new int[1];
boolean notFound = forEachPair(
new IntDoubleProcedure() {
public boolean apply(int iterKey, double iterValue) {
boolean found = value == iterValue;
if (found) foundKey[0] = iterKey;
return !found;
}
}
);
if (notFound) return Integer.MIN_VALUE;
return foundKey[0];
} | java | public int keyOf(final double value) {
final int[] foundKey = new int[1];
boolean notFound = forEachPair(
new IntDoubleProcedure() {
public boolean apply(int iterKey, double iterValue) {
boolean found = value == iterValue;
if (found) foundKey[0] = iterKey;
return !found;
}
}
);
if (notFound) return Integer.MIN_VALUE;
return foundKey[0];
} | [
"public",
"int",
"keyOf",
"(",
"final",
"double",
"value",
")",
"{",
"final",
"int",
"[",
"]",
"foundKey",
"=",
"new",
"int",
"[",
"1",
"]",
";",
"boolean",
"notFound",
"=",
"forEachPair",
"(",
"new",
"IntDoubleProcedure",
"(",
")",
"{",
"public",
"boolean",
"apply",
"(",
"int",
"iterKey",
",",
"double",
"iterValue",
")",
"{",
"boolean",
"found",
"=",
"value",
"==",
"iterValue",
";",
"if",
"(",
"found",
")",
"foundKey",
"[",
"0",
"]",
"=",
"iterKey",
";",
"return",
"!",
"found",
";",
"}",
"}",
")",
";",
"if",
"(",
"notFound",
")",
"return",
"Integer",
".",
"MIN_VALUE",
";",
"return",
"foundKey",
"[",
"0",
"]",
";",
"}"
] | Returns the first key the given value is associated with.
It is often a good idea to first check with {@link #containsValue(double)} whether there exists an association from a key to this value.
Search order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
@param value the value to search for.
@return the first key for which holds <tt>get(key) == value</tt>;
returns <tt>Integer.MIN_VALUE</tt> if no such key exists. | [
"Returns",
"the",
"first",
"key",
"the",
"given",
"value",
"is",
"associated",
"with",
".",
"It",
"is",
"often",
"a",
"good",
"idea",
"to",
"first",
"check",
"with",
"{",
"@link",
"#containsValue",
"(",
"double",
")",
"}",
"whether",
"there",
"exists",
"an",
"association",
"from",
"a",
"key",
"to",
"this",
"value",
".",
"Search",
"order",
"is",
"guaranteed",
"to",
"be",
"<i",
">",
"identical<",
"/",
"i",
">",
"to",
"the",
"order",
"used",
"by",
"method",
"{",
"@link",
"#forEachKey",
"(",
"IntProcedure",
")",
"}",
"."
] | train | https://github.com/wellner/jcarafe/blob/ab8b0a83dbf600fe80c27711815c90bd3055b217/jcarafe-core/src/main/java/cern/colt/map/AbstractIntDoubleMap.java#L200-L213 |
ktoso/janbanery | janbanery-core/src/main/java/pl/project13/janbanery/core/JanbaneryFactory.java | JanbaneryFactory.connectAndKeepUsing | public Janbanery connectAndKeepUsing(String user, String password) throws ServerCommunicationException {
"""
This method will connect to kanbanery via basic user/pass authentication
<strong>and will keep using it until forced to switch modes!</strong>. This method is not encouraged,
you should use {@link JanbaneryFactory#connectUsing(String, String)} and allow Janbanery to switch to apiKey mode
as soon as it load's up to increase security over the wire.
@param user your kanbanery username (email)
@param password your kanbanery password for this user
@return an Janbanery instance setup using the API Key auth, which will be fetched during construction
@throws ServerCommunicationException
"""
DefaultConfiguration conf = new DefaultConfiguration(user, password);
RestClient restClient = getRestClient(conf);
return new Janbanery(conf, restClient);
} | java | public Janbanery connectAndKeepUsing(String user, String password) throws ServerCommunicationException {
DefaultConfiguration conf = new DefaultConfiguration(user, password);
RestClient restClient = getRestClient(conf);
return new Janbanery(conf, restClient);
} | [
"public",
"Janbanery",
"connectAndKeepUsing",
"(",
"String",
"user",
",",
"String",
"password",
")",
"throws",
"ServerCommunicationException",
"{",
"DefaultConfiguration",
"conf",
"=",
"new",
"DefaultConfiguration",
"(",
"user",
",",
"password",
")",
";",
"RestClient",
"restClient",
"=",
"getRestClient",
"(",
"conf",
")",
";",
"return",
"new",
"Janbanery",
"(",
"conf",
",",
"restClient",
")",
";",
"}"
] | This method will connect to kanbanery via basic user/pass authentication
<strong>and will keep using it until forced to switch modes!</strong>. This method is not encouraged,
you should use {@link JanbaneryFactory#connectUsing(String, String)} and allow Janbanery to switch to apiKey mode
as soon as it load's up to increase security over the wire.
@param user your kanbanery username (email)
@param password your kanbanery password for this user
@return an Janbanery instance setup using the API Key auth, which will be fetched during construction
@throws ServerCommunicationException | [
"This",
"method",
"will",
"connect",
"to",
"kanbanery",
"via",
"basic",
"user",
"/",
"pass",
"authentication",
"<strong",
">",
"and",
"will",
"keep",
"using",
"it",
"until",
"forced",
"to",
"switch",
"modes!<",
"/",
"strong",
">",
".",
"This",
"method",
"is",
"not",
"encouraged",
"you",
"should",
"use",
"{",
"@link",
"JanbaneryFactory#connectUsing",
"(",
"String",
"String",
")",
"}",
"and",
"allow",
"Janbanery",
"to",
"switch",
"to",
"apiKey",
"mode",
"as",
"soon",
"as",
"it",
"load",
"s",
"up",
"to",
"increase",
"security",
"over",
"the",
"wire",
"."
] | train | https://github.com/ktoso/janbanery/blob/cd77b774814c7fbb2a0c9c55d4c3f7e76affa636/janbanery-core/src/main/java/pl/project13/janbanery/core/JanbaneryFactory.java#L115-L119 |
virgo47/javasimon | core/src/main/java/org/javasimon/proxy/DelegatingProxyFactory.java | DelegatingProxyFactory.newProxy | public Object newProxy(ClassLoader classLoader, Class<?>... interfaces) {
"""
Create a proxy using given classloader and interfaces
@param classLoader Class loader
@param interfaces Interfaces to implement
@return Proxy
"""
return Proxy.newProxyInstance(classLoader, interfaces, this);
} | java | public Object newProxy(ClassLoader classLoader, Class<?>... interfaces) {
return Proxy.newProxyInstance(classLoader, interfaces, this);
} | [
"public",
"Object",
"newProxy",
"(",
"ClassLoader",
"classLoader",
",",
"Class",
"<",
"?",
">",
"...",
"interfaces",
")",
"{",
"return",
"Proxy",
".",
"newProxyInstance",
"(",
"classLoader",
",",
"interfaces",
",",
"this",
")",
";",
"}"
] | Create a proxy using given classloader and interfaces
@param classLoader Class loader
@param interfaces Interfaces to implement
@return Proxy | [
"Create",
"a",
"proxy",
"using",
"given",
"classloader",
"and",
"interfaces"
] | train | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/proxy/DelegatingProxyFactory.java#L56-L58 |
inkstand-io/scribble | scribble-file/src/main/java/io/inkstand/scribble/rules/TemporaryZipFile.java | TemporaryZipFile.addEntry | private void addEntry(final Path pathToFile, final URL resource) throws IOException {
"""
Creates an entry under the specifeid path with the content from the provided resource.
@param pathToFile
the path to the file in the zip file.
@param resource
the resource providing the content for the file. Must not be null.
@throws IOException
"""
final Path parent = pathToFile.getParent();
if (parent != null) {
addFolder(parent);
}
try (InputStream inputStream = resource.openStream()) {
Files.copy(inputStream, pathToFile);
}
} | java | private void addEntry(final Path pathToFile, final URL resource) throws IOException {
final Path parent = pathToFile.getParent();
if (parent != null) {
addFolder(parent);
}
try (InputStream inputStream = resource.openStream()) {
Files.copy(inputStream, pathToFile);
}
} | [
"private",
"void",
"addEntry",
"(",
"final",
"Path",
"pathToFile",
",",
"final",
"URL",
"resource",
")",
"throws",
"IOException",
"{",
"final",
"Path",
"parent",
"=",
"pathToFile",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"addFolder",
"(",
"parent",
")",
";",
"}",
"try",
"(",
"InputStream",
"inputStream",
"=",
"resource",
".",
"openStream",
"(",
")",
")",
"{",
"Files",
".",
"copy",
"(",
"inputStream",
",",
"pathToFile",
")",
";",
"}",
"}"
] | Creates an entry under the specifeid path with the content from the provided resource.
@param pathToFile
the path to the file in the zip file.
@param resource
the resource providing the content for the file. Must not be null.
@throws IOException | [
"Creates",
"an",
"entry",
"under",
"the",
"specifeid",
"path",
"with",
"the",
"content",
"from",
"the",
"provided",
"resource",
"."
] | train | https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-file/src/main/java/io/inkstand/scribble/rules/TemporaryZipFile.java#L146-L155 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/SweepHullDelaunay2D.java | SweepHullDelaunay2D.quadraticEuclidean | public static double quadraticEuclidean(double[] v1, double[] v2) {
"""
Squared euclidean distance. 2d.
@param v1 First double[]
@param v2 Second double[]
@return Quadratic distance
"""
final double d1 = v1[0] - v2[0], d2 = v1[1] - v2[1];
return (d1 * d1) + (d2 * d2);
} | java | public static double quadraticEuclidean(double[] v1, double[] v2) {
final double d1 = v1[0] - v2[0], d2 = v1[1] - v2[1];
return (d1 * d1) + (d2 * d2);
} | [
"public",
"static",
"double",
"quadraticEuclidean",
"(",
"double",
"[",
"]",
"v1",
",",
"double",
"[",
"]",
"v2",
")",
"{",
"final",
"double",
"d1",
"=",
"v1",
"[",
"0",
"]",
"-",
"v2",
"[",
"0",
"]",
",",
"d2",
"=",
"v1",
"[",
"1",
"]",
"-",
"v2",
"[",
"1",
"]",
";",
"return",
"(",
"d1",
"*",
"d1",
")",
"+",
"(",
"d2",
"*",
"d2",
")",
";",
"}"
] | Squared euclidean distance. 2d.
@param v1 First double[]
@param v2 Second double[]
@return Quadratic distance | [
"Squared",
"euclidean",
"distance",
".",
"2d",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/SweepHullDelaunay2D.java#L693-L696 |
banq/jdonframework | src/main/java/com/jdon/util/ObjectCreator.java | ObjectCreator.createObject | public static Object createObject(Class classObject, Object[] params) throws Exception {
"""
Instantaite an Object instance, requires a constractor with parameters
@param classObject
, Class object representing the object type to be instantiated
@param params
an array including the required parameters to instantaite the
object
@return the instantaied Object
@exception java.lang.Exception
if instantiation failed
"""
Constructor[] constructors = classObject.getConstructors();
Object object = null;
for (int counter = 0; counter < constructors.length; counter++) {
try {
object = constructors[counter].newInstance(params);
} catch (Exception e) {
if (e instanceof InvocationTargetException)
((InvocationTargetException) e).getTargetException().printStackTrace();
// do nothing, try the next constructor
}
}
if (object == null)
throw new InstantiationException();
return object;
} | java | public static Object createObject(Class classObject, Object[] params) throws Exception {
Constructor[] constructors = classObject.getConstructors();
Object object = null;
for (int counter = 0; counter < constructors.length; counter++) {
try {
object = constructors[counter].newInstance(params);
} catch (Exception e) {
if (e instanceof InvocationTargetException)
((InvocationTargetException) e).getTargetException().printStackTrace();
// do nothing, try the next constructor
}
}
if (object == null)
throw new InstantiationException();
return object;
} | [
"public",
"static",
"Object",
"createObject",
"(",
"Class",
"classObject",
",",
"Object",
"[",
"]",
"params",
")",
"throws",
"Exception",
"{",
"Constructor",
"[",
"]",
"constructors",
"=",
"classObject",
".",
"getConstructors",
"(",
")",
";",
"Object",
"object",
"=",
"null",
";",
"for",
"(",
"int",
"counter",
"=",
"0",
";",
"counter",
"<",
"constructors",
".",
"length",
";",
"counter",
"++",
")",
"{",
"try",
"{",
"object",
"=",
"constructors",
"[",
"counter",
"]",
".",
"newInstance",
"(",
"params",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"InvocationTargetException",
")",
"(",
"(",
"InvocationTargetException",
")",
"e",
")",
".",
"getTargetException",
"(",
")",
".",
"printStackTrace",
"(",
")",
";",
"// do nothing, try the next constructor\r",
"}",
"}",
"if",
"(",
"object",
"==",
"null",
")",
"throw",
"new",
"InstantiationException",
"(",
")",
";",
"return",
"object",
";",
"}"
] | Instantaite an Object instance, requires a constractor with parameters
@param classObject
, Class object representing the object type to be instantiated
@param params
an array including the required parameters to instantaite the
object
@return the instantaied Object
@exception java.lang.Exception
if instantiation failed | [
"Instantaite",
"an",
"Object",
"instance",
"requires",
"a",
"constractor",
"with",
"parameters"
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/ObjectCreator.java#L75-L90 |
Jasig/spring-portlet-contrib | spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/upload/CommonsPortlet2MultipartResolver.java | CommonsPortlet2MultipartResolver.parseRequest | protected MultipartParsingResult parseRequest(ResourceRequest request) throws MultipartException {
"""
<p>parseRequest.</p>
@param request a {@link javax.portlet.ResourceRequest} object.
@return a MultipartParsingResult object.
@throws org.springframework.web.multipart.MultipartException if any.
"""
String encoding = determineEncoding(request);
FileUpload fileUpload = prepareFileUpload(encoding);
try {
@SuppressWarnings("unchecked")
List<FileItem> fileItems = ((Portlet2FileUpload) fileUpload).parseRequest(request);
return parseFileItems(fileItems, encoding);
} catch (FileUploadBase.SizeLimitExceededException ex) {
throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
} catch (FileUploadException ex) {
throw new MultipartException("Could not parse multipart portlet request", ex);
}
} | java | protected MultipartParsingResult parseRequest(ResourceRequest request) throws MultipartException {
String encoding = determineEncoding(request);
FileUpload fileUpload = prepareFileUpload(encoding);
try {
@SuppressWarnings("unchecked")
List<FileItem> fileItems = ((Portlet2FileUpload) fileUpload).parseRequest(request);
return parseFileItems(fileItems, encoding);
} catch (FileUploadBase.SizeLimitExceededException ex) {
throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
} catch (FileUploadException ex) {
throw new MultipartException("Could not parse multipart portlet request", ex);
}
} | [
"protected",
"MultipartParsingResult",
"parseRequest",
"(",
"ResourceRequest",
"request",
")",
"throws",
"MultipartException",
"{",
"String",
"encoding",
"=",
"determineEncoding",
"(",
"request",
")",
";",
"FileUpload",
"fileUpload",
"=",
"prepareFileUpload",
"(",
"encoding",
")",
";",
"try",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"List",
"<",
"FileItem",
">",
"fileItems",
"=",
"(",
"(",
"Portlet2FileUpload",
")",
"fileUpload",
")",
".",
"parseRequest",
"(",
"request",
")",
";",
"return",
"parseFileItems",
"(",
"fileItems",
",",
"encoding",
")",
";",
"}",
"catch",
"(",
"FileUploadBase",
".",
"SizeLimitExceededException",
"ex",
")",
"{",
"throw",
"new",
"MaxUploadSizeExceededException",
"(",
"fileUpload",
".",
"getSizeMax",
"(",
")",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"FileUploadException",
"ex",
")",
"{",
"throw",
"new",
"MultipartException",
"(",
"\"Could not parse multipart portlet request\"",
",",
"ex",
")",
";",
"}",
"}"
] | <p>parseRequest.</p>
@param request a {@link javax.portlet.ResourceRequest} object.
@return a MultipartParsingResult object.
@throws org.springframework.web.multipart.MultipartException if any. | [
"<p",
">",
"parseRequest",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/upload/CommonsPortlet2MultipartResolver.java#L122-L134 |
sarxos/win-registry | src/main/java/com/github/sarxos/winreg/WindowsRegistry.java | WindowsRegistry.readString | public String readString(HKey hk, String key, String valueName, String charsetName) throws RegistryException {
"""
Read a value from key and value name
@param hk the HKEY
@param key the key
@param valueName the value name
@param charsetName which charset to use
@return String value
@throws RegistryException when something is not right
"""
try {
return ReflectedMethods.readString(hk.root(), hk.hex(), key, valueName, charsetName);
} catch (Exception e) {
throw new RegistryException("Cannot read " + valueName + " value from key " + key, e);
}
} | java | public String readString(HKey hk, String key, String valueName, String charsetName) throws RegistryException {
try {
return ReflectedMethods.readString(hk.root(), hk.hex(), key, valueName, charsetName);
} catch (Exception e) {
throw new RegistryException("Cannot read " + valueName + " value from key " + key, e);
}
} | [
"public",
"String",
"readString",
"(",
"HKey",
"hk",
",",
"String",
"key",
",",
"String",
"valueName",
",",
"String",
"charsetName",
")",
"throws",
"RegistryException",
"{",
"try",
"{",
"return",
"ReflectedMethods",
".",
"readString",
"(",
"hk",
".",
"root",
"(",
")",
",",
"hk",
".",
"hex",
"(",
")",
",",
"key",
",",
"valueName",
",",
"charsetName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RegistryException",
"(",
"\"Cannot read \"",
"+",
"valueName",
"+",
"\" value from key \"",
"+",
"key",
",",
"e",
")",
";",
"}",
"}"
] | Read a value from key and value name
@param hk the HKEY
@param key the key
@param valueName the value name
@param charsetName which charset to use
@return String value
@throws RegistryException when something is not right | [
"Read",
"a",
"value",
"from",
"key",
"and",
"value",
"name"
] | train | https://github.com/sarxos/win-registry/blob/5ccbe2157ae0ee894de7c41bec4bd7b1e0f5c437/src/main/java/com/github/sarxos/winreg/WindowsRegistry.java#L59-L65 |
Mozu/mozu-java | mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/CouponSetUrl.java | CouponSetUrl.getCouponSetsUrl | public static MozuUrl getCouponSetsUrl(String filter, Boolean includeCounts, Integer pageSize, String responseFields, String sortBy, Integer startIndex) {
"""
Get Resource Url for GetCouponSets
@param filter A set of filter expressions representing the search parameters for a query. This parameter is optional. Refer to [Sorting and Filtering](../../../../Developer/api-guides/sorting-filtering.htm) for a list of supported filters.
@param includeCounts Specifies whether to include the number of redeemed coupons, existing coupon codes, and assigned discounts in the response body.
@param pageSize When creating paged results from a query, this value indicates the zero-based offset in the complete result set where the returned entities begin. For example, with this parameter set to 25, to get the 51st through the 75th items, set startIndex to 50.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@param sortBy The element to sort the results by and the channel in which the results appear. Either ascending (a-z) or descending (z-a) channel. Optional. Refer to [Sorting and Filtering](../../../../Developer/api-guides/sorting-filtering.htm) for more information.
@param startIndex When creating paged results from a query, this value indicates the zero-based offset in the complete result set where the returned entities begin. For example, with pageSize set to 25, to get the 51st through the 75th items, set this parameter to 50.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/couponsets/?startIndex={startIndex}&pageSize={pageSize}&sortBy={sortBy}&filter={filter}&includeCounts={includeCounts}&responseFields={responseFields}");
formatter.formatUrl("filter", filter);
formatter.formatUrl("includeCounts", includeCounts);
formatter.formatUrl("pageSize", pageSize);
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("sortBy", sortBy);
formatter.formatUrl("startIndex", startIndex);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl getCouponSetsUrl(String filter, Boolean includeCounts, Integer pageSize, String responseFields, String sortBy, Integer startIndex)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/couponsets/?startIndex={startIndex}&pageSize={pageSize}&sortBy={sortBy}&filter={filter}&includeCounts={includeCounts}&responseFields={responseFields}");
formatter.formatUrl("filter", filter);
formatter.formatUrl("includeCounts", includeCounts);
formatter.formatUrl("pageSize", pageSize);
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("sortBy", sortBy);
formatter.formatUrl("startIndex", startIndex);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"getCouponSetsUrl",
"(",
"String",
"filter",
",",
"Boolean",
"includeCounts",
",",
"Integer",
"pageSize",
",",
"String",
"responseFields",
",",
"String",
"sortBy",
",",
"Integer",
"startIndex",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/catalog/admin/couponsets/?startIndex={startIndex}&pageSize={pageSize}&sortBy={sortBy}&filter={filter}&includeCounts={includeCounts}&responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"filter\"",
",",
"filter",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"includeCounts\"",
",",
"includeCounts",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"pageSize\"",
",",
"pageSize",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"sortBy\"",
",",
"sortBy",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"startIndex\"",
",",
"startIndex",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] | Get Resource Url for GetCouponSets
@param filter A set of filter expressions representing the search parameters for a query. This parameter is optional. Refer to [Sorting and Filtering](../../../../Developer/api-guides/sorting-filtering.htm) for a list of supported filters.
@param includeCounts Specifies whether to include the number of redeemed coupons, existing coupon codes, and assigned discounts in the response body.
@param pageSize When creating paged results from a query, this value indicates the zero-based offset in the complete result set where the returned entities begin. For example, with this parameter set to 25, to get the 51st through the 75th items, set startIndex to 50.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@param sortBy The element to sort the results by and the channel in which the results appear. Either ascending (a-z) or descending (z-a) channel. Optional. Refer to [Sorting and Filtering](../../../../Developer/api-guides/sorting-filtering.htm) for more information.
@param startIndex When creating paged results from a query, this value indicates the zero-based offset in the complete result set where the returned entities begin. For example, with pageSize set to 25, to get the 51st through the 75th items, set this parameter to 50.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"GetCouponSets"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/CouponSetUrl.java#L26-L36 |
netty/netty | microbench/src/main/java/io/netty/handler/codec/http2/HpackHeader.java | HpackHeader.createHeaders | static List<HpackHeader> createHeaders(int numHeaders, int nameLength, int valueLength,
boolean limitToAscii) {
"""
Creates a number of random headers with the given name/value lengths.
"""
List<HpackHeader> hpackHeaders = new ArrayList<HpackHeader>(numHeaders);
for (int i = 0; i < numHeaders; ++i) {
byte[] name = randomBytes(new byte[nameLength], limitToAscii);
byte[] value = randomBytes(new byte[valueLength], limitToAscii);
hpackHeaders.add(new HpackHeader(name, value));
}
return hpackHeaders;
} | java | static List<HpackHeader> createHeaders(int numHeaders, int nameLength, int valueLength,
boolean limitToAscii) {
List<HpackHeader> hpackHeaders = new ArrayList<HpackHeader>(numHeaders);
for (int i = 0; i < numHeaders; ++i) {
byte[] name = randomBytes(new byte[nameLength], limitToAscii);
byte[] value = randomBytes(new byte[valueLength], limitToAscii);
hpackHeaders.add(new HpackHeader(name, value));
}
return hpackHeaders;
} | [
"static",
"List",
"<",
"HpackHeader",
">",
"createHeaders",
"(",
"int",
"numHeaders",
",",
"int",
"nameLength",
",",
"int",
"valueLength",
",",
"boolean",
"limitToAscii",
")",
"{",
"List",
"<",
"HpackHeader",
">",
"hpackHeaders",
"=",
"new",
"ArrayList",
"<",
"HpackHeader",
">",
"(",
"numHeaders",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numHeaders",
";",
"++",
"i",
")",
"{",
"byte",
"[",
"]",
"name",
"=",
"randomBytes",
"(",
"new",
"byte",
"[",
"nameLength",
"]",
",",
"limitToAscii",
")",
";",
"byte",
"[",
"]",
"value",
"=",
"randomBytes",
"(",
"new",
"byte",
"[",
"valueLength",
"]",
",",
"limitToAscii",
")",
";",
"hpackHeaders",
".",
"add",
"(",
"new",
"HpackHeader",
"(",
"name",
",",
"value",
")",
")",
";",
"}",
"return",
"hpackHeaders",
";",
"}"
] | Creates a number of random headers with the given name/value lengths. | [
"Creates",
"a",
"number",
"of",
"random",
"headers",
"with",
"the",
"given",
"name",
"/",
"value",
"lengths",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/microbench/src/main/java/io/netty/handler/codec/http2/HpackHeader.java#L58-L67 |
playn/playn | scene/src/playn/scene/LayerUtil.java | LayerUtil.layerToScreen | public static Point layerToScreen(Layer layer, float x, float y) {
"""
Converts the supplied point from coordinates relative to the specified
layer to screen coordinates.
"""
Point into = new Point(x, y);
return layerToScreen(layer, into, into);
} | java | public static Point layerToScreen(Layer layer, float x, float y) {
Point into = new Point(x, y);
return layerToScreen(layer, into, into);
} | [
"public",
"static",
"Point",
"layerToScreen",
"(",
"Layer",
"layer",
",",
"float",
"x",
",",
"float",
"y",
")",
"{",
"Point",
"into",
"=",
"new",
"Point",
"(",
"x",
",",
"y",
")",
";",
"return",
"layerToScreen",
"(",
"layer",
",",
"into",
",",
"into",
")",
";",
"}"
] | Converts the supplied point from coordinates relative to the specified
layer to screen coordinates. | [
"Converts",
"the",
"supplied",
"point",
"from",
"coordinates",
"relative",
"to",
"the",
"specified",
"layer",
"to",
"screen",
"coordinates",
"."
] | train | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/LayerUtil.java#L44-L47 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java | CssSkinGenerator.getVariants | private Map<String, VariantSet> getVariants(ResourceBrowser rsBrowser, String rootDir, String defaultSkinName,
String defaultLocaleName, boolean mappingSkinLocale) {
"""
Initialize the skinMapping from the parent path
@param rsBrowser
the resource browser
@param rootDir
the skin root dir path
@param defaultSkinName
the default skin name
@param defaultLocaleName
the default locale name
"""
Set<String> paths = rsBrowser.getResourceNames(rootDir);
Set<String> skinNames = new HashSet<>();
Set<String> localeVariants = new HashSet<>();
for (Iterator<String> itPath = paths.iterator(); itPath.hasNext();) {
String path = rootDir + itPath.next();
if (rsBrowser.isDirectory(path)) {
String dirName = PathNormalizer.getPathName(path);
if (mappingSkinLocale) {
skinNames.add(dirName);
// check if there are locale variants for this skin,
// and update the localeVariants if needed
updateLocaleVariants(rsBrowser, path, localeVariants);
} else {
if (LocaleUtils.LOCALE_SUFFIXES.contains(dirName)) {
localeVariants.add(dirName);
// check if there are skin variants for this locales,
// and update the skinVariants if needed
updateSkinVariants(rsBrowser, path, skinNames);
}
}
}
}
// Initialize the variant mapping for the skin root directory
return getVariants(defaultSkinName, skinNames, defaultLocaleName, localeVariants);
} | java | private Map<String, VariantSet> getVariants(ResourceBrowser rsBrowser, String rootDir, String defaultSkinName,
String defaultLocaleName, boolean mappingSkinLocale) {
Set<String> paths = rsBrowser.getResourceNames(rootDir);
Set<String> skinNames = new HashSet<>();
Set<String> localeVariants = new HashSet<>();
for (Iterator<String> itPath = paths.iterator(); itPath.hasNext();) {
String path = rootDir + itPath.next();
if (rsBrowser.isDirectory(path)) {
String dirName = PathNormalizer.getPathName(path);
if (mappingSkinLocale) {
skinNames.add(dirName);
// check if there are locale variants for this skin,
// and update the localeVariants if needed
updateLocaleVariants(rsBrowser, path, localeVariants);
} else {
if (LocaleUtils.LOCALE_SUFFIXES.contains(dirName)) {
localeVariants.add(dirName);
// check if there are skin variants for this locales,
// and update the skinVariants if needed
updateSkinVariants(rsBrowser, path, skinNames);
}
}
}
}
// Initialize the variant mapping for the skin root directory
return getVariants(defaultSkinName, skinNames, defaultLocaleName, localeVariants);
} | [
"private",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"getVariants",
"(",
"ResourceBrowser",
"rsBrowser",
",",
"String",
"rootDir",
",",
"String",
"defaultSkinName",
",",
"String",
"defaultLocaleName",
",",
"boolean",
"mappingSkinLocale",
")",
"{",
"Set",
"<",
"String",
">",
"paths",
"=",
"rsBrowser",
".",
"getResourceNames",
"(",
"rootDir",
")",
";",
"Set",
"<",
"String",
">",
"skinNames",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"Set",
"<",
"String",
">",
"localeVariants",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"itPath",
"=",
"paths",
".",
"iterator",
"(",
")",
";",
"itPath",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"path",
"=",
"rootDir",
"+",
"itPath",
".",
"next",
"(",
")",
";",
"if",
"(",
"rsBrowser",
".",
"isDirectory",
"(",
"path",
")",
")",
"{",
"String",
"dirName",
"=",
"PathNormalizer",
".",
"getPathName",
"(",
"path",
")",
";",
"if",
"(",
"mappingSkinLocale",
")",
"{",
"skinNames",
".",
"add",
"(",
"dirName",
")",
";",
"// check if there are locale variants for this skin,",
"// and update the localeVariants if needed",
"updateLocaleVariants",
"(",
"rsBrowser",
",",
"path",
",",
"localeVariants",
")",
";",
"}",
"else",
"{",
"if",
"(",
"LocaleUtils",
".",
"LOCALE_SUFFIXES",
".",
"contains",
"(",
"dirName",
")",
")",
"{",
"localeVariants",
".",
"add",
"(",
"dirName",
")",
";",
"// check if there are skin variants for this locales,",
"// and update the skinVariants if needed",
"updateSkinVariants",
"(",
"rsBrowser",
",",
"path",
",",
"skinNames",
")",
";",
"}",
"}",
"}",
"}",
"// Initialize the variant mapping for the skin root directory",
"return",
"getVariants",
"(",
"defaultSkinName",
",",
"skinNames",
",",
"defaultLocaleName",
",",
"localeVariants",
")",
";",
"}"
] | Initialize the skinMapping from the parent path
@param rsBrowser
the resource browser
@param rootDir
the skin root dir path
@param defaultSkinName
the default skin name
@param defaultLocaleName
the default locale name | [
"Initialize",
"the",
"skinMapping",
"from",
"the",
"parent",
"path"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L504-L531 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/jfapchannel/impl/JFapUtils.java | JFapUtils.debugTraceWsByteBuffer | public static void debugTraceWsByteBuffer(Object _this, TraceComponent _tc, WsByteBuffer buffer, int amount, String comment) {
"""
Produces a debug trace entry for a WsByteBuffer. This should be used
as follows:
<code>
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) debugTraceWsByteBuffer(...);
</code>
@param _this Reference to the object invoking this method.
@param _tc Reference to TraceComponent to use for outputing trace entry.
@param buffer Buffer to trace.
@param amount Maximum amount of data from the buffer to trace.
@param comment A comment to associate with the trace entry.
"""
byte[] data = null;
int start;
int count = amount;
if (count > buffer.remaining()) count = buffer.remaining();
if (buffer.hasArray())
{
data = buffer.array();
start = buffer.arrayOffset() + buffer.position();;
}
else
{
data = new byte[count];
int pos = buffer.position();
buffer.get(data);
buffer.position(pos);
start = 0;
}
StringBuffer sb = new StringBuffer(comment);
sb.append("\nbuffer hashcode: ");
sb.append(buffer.hashCode());
sb.append("\nbuffer position: ");
sb.append(buffer.position());
sb.append("\nbuffer remaining: ");
sb.append(buffer.remaining());
sb.append("\n");
SibTr.debug(_this, _tc, sb.toString());
if (count > 0)
SibTr.bytes(_this, _tc, data, start, count, "First "+count+" bytes of buffer data:");
} | java | public static void debugTraceWsByteBuffer(Object _this, TraceComponent _tc, WsByteBuffer buffer, int amount, String comment)
{
byte[] data = null;
int start;
int count = amount;
if (count > buffer.remaining()) count = buffer.remaining();
if (buffer.hasArray())
{
data = buffer.array();
start = buffer.arrayOffset() + buffer.position();;
}
else
{
data = new byte[count];
int pos = buffer.position();
buffer.get(data);
buffer.position(pos);
start = 0;
}
StringBuffer sb = new StringBuffer(comment);
sb.append("\nbuffer hashcode: ");
sb.append(buffer.hashCode());
sb.append("\nbuffer position: ");
sb.append(buffer.position());
sb.append("\nbuffer remaining: ");
sb.append(buffer.remaining());
sb.append("\n");
SibTr.debug(_this, _tc, sb.toString());
if (count > 0)
SibTr.bytes(_this, _tc, data, start, count, "First "+count+" bytes of buffer data:");
} | [
"public",
"static",
"void",
"debugTraceWsByteBuffer",
"(",
"Object",
"_this",
",",
"TraceComponent",
"_tc",
",",
"WsByteBuffer",
"buffer",
",",
"int",
"amount",
",",
"String",
"comment",
")",
"{",
"byte",
"[",
"]",
"data",
"=",
"null",
";",
"int",
"start",
";",
"int",
"count",
"=",
"amount",
";",
"if",
"(",
"count",
">",
"buffer",
".",
"remaining",
"(",
")",
")",
"count",
"=",
"buffer",
".",
"remaining",
"(",
")",
";",
"if",
"(",
"buffer",
".",
"hasArray",
"(",
")",
")",
"{",
"data",
"=",
"buffer",
".",
"array",
"(",
")",
";",
"start",
"=",
"buffer",
".",
"arrayOffset",
"(",
")",
"+",
"buffer",
".",
"position",
"(",
")",
";",
";",
"}",
"else",
"{",
"data",
"=",
"new",
"byte",
"[",
"count",
"]",
";",
"int",
"pos",
"=",
"buffer",
".",
"position",
"(",
")",
";",
"buffer",
".",
"get",
"(",
"data",
")",
";",
"buffer",
".",
"position",
"(",
"pos",
")",
";",
"start",
"=",
"0",
";",
"}",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
"comment",
")",
";",
"sb",
".",
"append",
"(",
"\"\\nbuffer hashcode: \"",
")",
";",
"sb",
".",
"append",
"(",
"buffer",
".",
"hashCode",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"\\nbuffer position: \"",
")",
";",
"sb",
".",
"append",
"(",
"buffer",
".",
"position",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"\\nbuffer remaining: \"",
")",
";",
"sb",
".",
"append",
"(",
"buffer",
".",
"remaining",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"SibTr",
".",
"debug",
"(",
"_this",
",",
"_tc",
",",
"sb",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"count",
">",
"0",
")",
"SibTr",
".",
"bytes",
"(",
"_this",
",",
"_tc",
",",
"data",
",",
"start",
",",
"count",
",",
"\"First \"",
"+",
"count",
"+",
"\" bytes of buffer data:\"",
")",
";",
"}"
] | Produces a debug trace entry for a WsByteBuffer. This should be used
as follows:
<code>
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) debugTraceWsByteBuffer(...);
</code>
@param _this Reference to the object invoking this method.
@param _tc Reference to TraceComponent to use for outputing trace entry.
@param buffer Buffer to trace.
@param amount Maximum amount of data from the buffer to trace.
@param comment A comment to associate with the trace entry. | [
"Produces",
"a",
"debug",
"trace",
"entry",
"for",
"a",
"WsByteBuffer",
".",
"This",
"should",
"be",
"used",
"as",
"follows",
":",
"<code",
">",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"()",
"&&",
"tc",
".",
"isDebugEnabled",
"()",
")",
"debugTraceWsByteBuffer",
"(",
"...",
")",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/jfapchannel/impl/JFapUtils.java#L50-L82 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.getIntentSuggestionsAsync | public Observable<List<IntentsSuggestionExample>> getIntentSuggestionsAsync(UUID appId, String versionId, UUID intentId, GetIntentSuggestionsOptionalParameter getIntentSuggestionsOptionalParameter) {
"""
Suggests examples that would improve the accuracy of the intent model.
@param appId The application ID.
@param versionId The version ID.
@param intentId The intent classifier ID.
@param getIntentSuggestionsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<IntentsSuggestionExample> object
"""
return getIntentSuggestionsWithServiceResponseAsync(appId, versionId, intentId, getIntentSuggestionsOptionalParameter).map(new Func1<ServiceResponse<List<IntentsSuggestionExample>>, List<IntentsSuggestionExample>>() {
@Override
public List<IntentsSuggestionExample> call(ServiceResponse<List<IntentsSuggestionExample>> response) {
return response.body();
}
});
} | java | public Observable<List<IntentsSuggestionExample>> getIntentSuggestionsAsync(UUID appId, String versionId, UUID intentId, GetIntentSuggestionsOptionalParameter getIntentSuggestionsOptionalParameter) {
return getIntentSuggestionsWithServiceResponseAsync(appId, versionId, intentId, getIntentSuggestionsOptionalParameter).map(new Func1<ServiceResponse<List<IntentsSuggestionExample>>, List<IntentsSuggestionExample>>() {
@Override
public List<IntentsSuggestionExample> call(ServiceResponse<List<IntentsSuggestionExample>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"IntentsSuggestionExample",
">",
">",
"getIntentSuggestionsAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"intentId",
",",
"GetIntentSuggestionsOptionalParameter",
"getIntentSuggestionsOptionalParameter",
")",
"{",
"return",
"getIntentSuggestionsWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"intentId",
",",
"getIntentSuggestionsOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"IntentsSuggestionExample",
">",
">",
",",
"List",
"<",
"IntentsSuggestionExample",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"IntentsSuggestionExample",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"IntentsSuggestionExample",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Suggests examples that would improve the accuracy of the intent model.
@param appId The application ID.
@param versionId The version ID.
@param intentId The intent classifier ID.
@param getIntentSuggestionsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<IntentsSuggestionExample> object | [
"Suggests",
"examples",
"that",
"would",
"improve",
"the",
"accuracy",
"of",
"the",
"intent",
"model",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L5100-L5107 |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/metadata/ModificationBuilderTarget.java | ModificationBuilderTarget.modifyModule | public T modifyModule(final String moduleName, final String slot, final byte[] existingHash, final byte[] newHash) {
"""
Modify a module.
@param moduleName the module name
@param slot the module slot
@param existingHash the existing hash
@param newHash the new hash of the modified content
@return the builder
"""
final ContentItem item = createModuleItem(moduleName, slot, newHash);
addContentModification(createContentModification(item, ModificationType.MODIFY, existingHash));
return returnThis();
} | java | public T modifyModule(final String moduleName, final String slot, final byte[] existingHash, final byte[] newHash) {
final ContentItem item = createModuleItem(moduleName, slot, newHash);
addContentModification(createContentModification(item, ModificationType.MODIFY, existingHash));
return returnThis();
} | [
"public",
"T",
"modifyModule",
"(",
"final",
"String",
"moduleName",
",",
"final",
"String",
"slot",
",",
"final",
"byte",
"[",
"]",
"existingHash",
",",
"final",
"byte",
"[",
"]",
"newHash",
")",
"{",
"final",
"ContentItem",
"item",
"=",
"createModuleItem",
"(",
"moduleName",
",",
"slot",
",",
"newHash",
")",
";",
"addContentModification",
"(",
"createContentModification",
"(",
"item",
",",
"ModificationType",
".",
"MODIFY",
",",
"existingHash",
")",
")",
";",
"return",
"returnThis",
"(",
")",
";",
"}"
] | Modify a module.
@param moduleName the module name
@param slot the module slot
@param existingHash the existing hash
@param newHash the new hash of the modified content
@return the builder | [
"Modify",
"a",
"module",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/metadata/ModificationBuilderTarget.java#L189-L193 |
haifengl/smile | plot/src/main/java/smile/plot/PlotCanvas.java | PlotCanvas.screeplot | public static PlotCanvas screeplot(PCA pca) {
"""
Create a scree plot for PCA.
@param pca principal component analysis object.
"""
int n = pca.getVarianceProportion().length;
double[] lowerBound = {0, 0.0};
double[] upperBound = {n + 1, 1.0};
PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false);
canvas.setAxisLabels("Principal Component", "Proportion of Variance");
String[] labels = new String[n];
double[] x = new double[n];
double[][] data = new double[n][2];
double[][] data2 = new double[n][2];
for (int i = 0; i < n; i++) {
labels[i] = "PC" + (i + 1);
x[i] = i + 1;
data[i][0] = x[i];
data[i][1] = pca.getVarianceProportion()[i];
data2[i][0] = x[i];
data2[i][1] = pca.getCumulativeVarianceProportion()[i];
}
LinePlot plot = new LinePlot(data);
plot.setID("Variance");
plot.setColor(Color.RED);
plot.setLegend('@');
canvas.add(plot);
canvas.getAxis(0).addLabel(labels, x);
LinePlot plot2 = new LinePlot(data2);
plot2.setID("Cumulative Variance");
plot2.setColor(Color.BLUE);
plot2.setLegend('@');
canvas.add(plot2);
return canvas;
} | java | public static PlotCanvas screeplot(PCA pca) {
int n = pca.getVarianceProportion().length;
double[] lowerBound = {0, 0.0};
double[] upperBound = {n + 1, 1.0};
PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false);
canvas.setAxisLabels("Principal Component", "Proportion of Variance");
String[] labels = new String[n];
double[] x = new double[n];
double[][] data = new double[n][2];
double[][] data2 = new double[n][2];
for (int i = 0; i < n; i++) {
labels[i] = "PC" + (i + 1);
x[i] = i + 1;
data[i][0] = x[i];
data[i][1] = pca.getVarianceProportion()[i];
data2[i][0] = x[i];
data2[i][1] = pca.getCumulativeVarianceProportion()[i];
}
LinePlot plot = new LinePlot(data);
plot.setID("Variance");
plot.setColor(Color.RED);
plot.setLegend('@');
canvas.add(plot);
canvas.getAxis(0).addLabel(labels, x);
LinePlot plot2 = new LinePlot(data2);
plot2.setID("Cumulative Variance");
plot2.setColor(Color.BLUE);
plot2.setLegend('@');
canvas.add(plot2);
return canvas;
} | [
"public",
"static",
"PlotCanvas",
"screeplot",
"(",
"PCA",
"pca",
")",
"{",
"int",
"n",
"=",
"pca",
".",
"getVarianceProportion",
"(",
")",
".",
"length",
";",
"double",
"[",
"]",
"lowerBound",
"=",
"{",
"0",
",",
"0.0",
"}",
";",
"double",
"[",
"]",
"upperBound",
"=",
"{",
"n",
"+",
"1",
",",
"1.0",
"}",
";",
"PlotCanvas",
"canvas",
"=",
"new",
"PlotCanvas",
"(",
"lowerBound",
",",
"upperBound",
",",
"false",
")",
";",
"canvas",
".",
"setAxisLabels",
"(",
"\"Principal Component\"",
",",
"\"Proportion of Variance\"",
")",
";",
"String",
"[",
"]",
"labels",
"=",
"new",
"String",
"[",
"n",
"]",
";",
"double",
"[",
"]",
"x",
"=",
"new",
"double",
"[",
"n",
"]",
";",
"double",
"[",
"]",
"[",
"]",
"data",
"=",
"new",
"double",
"[",
"n",
"]",
"[",
"2",
"]",
";",
"double",
"[",
"]",
"[",
"]",
"data2",
"=",
"new",
"double",
"[",
"n",
"]",
"[",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"labels",
"[",
"i",
"]",
"=",
"\"PC\"",
"+",
"(",
"i",
"+",
"1",
")",
";",
"x",
"[",
"i",
"]",
"=",
"i",
"+",
"1",
";",
"data",
"[",
"i",
"]",
"[",
"0",
"]",
"=",
"x",
"[",
"i",
"]",
";",
"data",
"[",
"i",
"]",
"[",
"1",
"]",
"=",
"pca",
".",
"getVarianceProportion",
"(",
")",
"[",
"i",
"]",
";",
"data2",
"[",
"i",
"]",
"[",
"0",
"]",
"=",
"x",
"[",
"i",
"]",
";",
"data2",
"[",
"i",
"]",
"[",
"1",
"]",
"=",
"pca",
".",
"getCumulativeVarianceProportion",
"(",
")",
"[",
"i",
"]",
";",
"}",
"LinePlot",
"plot",
"=",
"new",
"LinePlot",
"(",
"data",
")",
";",
"plot",
".",
"setID",
"(",
"\"Variance\"",
")",
";",
"plot",
".",
"setColor",
"(",
"Color",
".",
"RED",
")",
";",
"plot",
".",
"setLegend",
"(",
"'",
"'",
")",
";",
"canvas",
".",
"add",
"(",
"plot",
")",
";",
"canvas",
".",
"getAxis",
"(",
"0",
")",
".",
"addLabel",
"(",
"labels",
",",
"x",
")",
";",
"LinePlot",
"plot2",
"=",
"new",
"LinePlot",
"(",
"data2",
")",
";",
"plot2",
".",
"setID",
"(",
"\"Cumulative Variance\"",
")",
";",
"plot2",
".",
"setColor",
"(",
"Color",
".",
"BLUE",
")",
";",
"plot2",
".",
"setLegend",
"(",
"'",
"'",
")",
";",
"canvas",
".",
"add",
"(",
"plot2",
")",
";",
"return",
"canvas",
";",
"}"
] | Create a scree plot for PCA.
@param pca principal component analysis object. | [
"Create",
"a",
"scree",
"plot",
"for",
"PCA",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/PlotCanvas.java#L2249-L2285 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/CFEndPointSerializer.java | CFEndPointSerializer.determineType | static private StringBuilder determineType(String name, Object o) {
"""
Determine the type of the Object passed in and add the XML format
for the result.
@param type
@param name
@param o
@return StringBuilder
"""
String value = null;
if (o instanceof String || o instanceof StringBuffer || o instanceof java.nio.CharBuffer || o instanceof Integer || o instanceof Long || o instanceof Byte
|| o instanceof Double || o instanceof Float || o instanceof Short || o instanceof BigInteger || o instanceof java.math.BigDecimal) {
value = o.toString();
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Skipping class: " + o.getClass());
}
return null;
}
// type="class" name="o"
StringBuilder buffer = new StringBuilder(48);
buffer.append(name);
buffer.append("type=\"");
// charbuffer is abstract so we might get HeapCharBuffer here, force it
// to the generic layer in the XML output
if (o instanceof java.nio.CharBuffer) {
buffer.append("java.nio.CharBuffer");
} else {
buffer.append(o.getClass().getName());
}
buffer.append("\" ");
buffer.append(name);
buffer.append("=\"");
buffer.append(value);
buffer.append("\"");
return buffer;
} | java | static private StringBuilder determineType(String name, Object o) {
String value = null;
if (o instanceof String || o instanceof StringBuffer || o instanceof java.nio.CharBuffer || o instanceof Integer || o instanceof Long || o instanceof Byte
|| o instanceof Double || o instanceof Float || o instanceof Short || o instanceof BigInteger || o instanceof java.math.BigDecimal) {
value = o.toString();
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Skipping class: " + o.getClass());
}
return null;
}
// type="class" name="o"
StringBuilder buffer = new StringBuilder(48);
buffer.append(name);
buffer.append("type=\"");
// charbuffer is abstract so we might get HeapCharBuffer here, force it
// to the generic layer in the XML output
if (o instanceof java.nio.CharBuffer) {
buffer.append("java.nio.CharBuffer");
} else {
buffer.append(o.getClass().getName());
}
buffer.append("\" ");
buffer.append(name);
buffer.append("=\"");
buffer.append(value);
buffer.append("\"");
return buffer;
} | [
"static",
"private",
"StringBuilder",
"determineType",
"(",
"String",
"name",
",",
"Object",
"o",
")",
"{",
"String",
"value",
"=",
"null",
";",
"if",
"(",
"o",
"instanceof",
"String",
"||",
"o",
"instanceof",
"StringBuffer",
"||",
"o",
"instanceof",
"java",
".",
"nio",
".",
"CharBuffer",
"||",
"o",
"instanceof",
"Integer",
"||",
"o",
"instanceof",
"Long",
"||",
"o",
"instanceof",
"Byte",
"||",
"o",
"instanceof",
"Double",
"||",
"o",
"instanceof",
"Float",
"||",
"o",
"instanceof",
"Short",
"||",
"o",
"instanceof",
"BigInteger",
"||",
"o",
"instanceof",
"java",
".",
"math",
".",
"BigDecimal",
")",
"{",
"value",
"=",
"o",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Skipping class: \"",
"+",
"o",
".",
"getClass",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}",
"// type=\"class\" name=\"o\"",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
"48",
")",
";",
"buffer",
".",
"append",
"(",
"name",
")",
";",
"buffer",
".",
"append",
"(",
"\"type=\\\"\"",
")",
";",
"// charbuffer is abstract so we might get HeapCharBuffer here, force it",
"// to the generic layer in the XML output",
"if",
"(",
"o",
"instanceof",
"java",
".",
"nio",
".",
"CharBuffer",
")",
"{",
"buffer",
".",
"append",
"(",
"\"java.nio.CharBuffer\"",
")",
";",
"}",
"else",
"{",
"buffer",
".",
"append",
"(",
"o",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"buffer",
".",
"append",
"(",
"\"\\\" \"",
")",
";",
"buffer",
".",
"append",
"(",
"name",
")",
";",
"buffer",
".",
"append",
"(",
"\"=\\\"\"",
")",
";",
"buffer",
".",
"append",
"(",
"value",
")",
";",
"buffer",
".",
"append",
"(",
"\"\\\"\"",
")",
";",
"return",
"buffer",
";",
"}"
] | Determine the type of the Object passed in and add the XML format
for the result.
@param type
@param name
@param o
@return StringBuilder | [
"Determine",
"the",
"type",
"of",
"the",
"Object",
"passed",
"in",
"and",
"add",
"the",
"XML",
"format",
"for",
"the",
"result",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/CFEndPointSerializer.java#L48-L77 |
JOML-CI/JOML | src/org/joml/Matrix4f.java | Matrix4f.lookAt | public Matrix4f lookAt(float eyeX, float eyeY, float eyeZ,
float centerX, float centerY, float centerZ,
float upX, float upY, float upZ, Matrix4f dest) {
"""
Apply a "lookat" transformation to this matrix for a right-handed coordinate system,
that aligns <code>-z</code> with <code>center - eye</code> and store the result in <code>dest</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>L</code> the lookat matrix,
then the new matrix will be <code>M * L</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * L * v</code>,
the lookat transformation will be applied first!
<p>
In order to set the matrix to a lookat transformation without post-multiplying it,
use {@link #setLookAt(float, float, float, float, float, float, float, float, float) setLookAt()}.
@see #lookAt(Vector3fc, Vector3fc, Vector3fc)
@see #setLookAt(float, float, float, float, float, float, float, float, float)
@param eyeX
the x-coordinate of the eye/camera location
@param eyeY
the y-coordinate of the eye/camera location
@param eyeZ
the z-coordinate of the eye/camera location
@param centerX
the x-coordinate of the point to look at
@param centerY
the y-coordinate of the point to look at
@param centerZ
the z-coordinate of the point to look at
@param upX
the x-coordinate of the up vector
@param upY
the y-coordinate of the up vector
@param upZ
the z-coordinate of the up vector
@param dest
will hold the result
@return dest
"""
if ((properties & PROPERTY_IDENTITY) != 0)
return dest.setLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
else if ((properties & PROPERTY_PERSPECTIVE) != 0)
return lookAtPerspective(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ, dest);
return lookAtGeneric(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ, dest);
} | java | public Matrix4f lookAt(float eyeX, float eyeY, float eyeZ,
float centerX, float centerY, float centerZ,
float upX, float upY, float upZ, Matrix4f dest) {
if ((properties & PROPERTY_IDENTITY) != 0)
return dest.setLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
else if ((properties & PROPERTY_PERSPECTIVE) != 0)
return lookAtPerspective(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ, dest);
return lookAtGeneric(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ, dest);
} | [
"public",
"Matrix4f",
"lookAt",
"(",
"float",
"eyeX",
",",
"float",
"eyeY",
",",
"float",
"eyeZ",
",",
"float",
"centerX",
",",
"float",
"centerY",
",",
"float",
"centerZ",
",",
"float",
"upX",
",",
"float",
"upY",
",",
"float",
"upZ",
",",
"Matrix4f",
"dest",
")",
"{",
"if",
"(",
"(",
"properties",
"&",
"PROPERTY_IDENTITY",
")",
"!=",
"0",
")",
"return",
"dest",
".",
"setLookAt",
"(",
"eyeX",
",",
"eyeY",
",",
"eyeZ",
",",
"centerX",
",",
"centerY",
",",
"centerZ",
",",
"upX",
",",
"upY",
",",
"upZ",
")",
";",
"else",
"if",
"(",
"(",
"properties",
"&",
"PROPERTY_PERSPECTIVE",
")",
"!=",
"0",
")",
"return",
"lookAtPerspective",
"(",
"eyeX",
",",
"eyeY",
",",
"eyeZ",
",",
"centerX",
",",
"centerY",
",",
"centerZ",
",",
"upX",
",",
"upY",
",",
"upZ",
",",
"dest",
")",
";",
"return",
"lookAtGeneric",
"(",
"eyeX",
",",
"eyeY",
",",
"eyeZ",
",",
"centerX",
",",
"centerY",
",",
"centerZ",
",",
"upX",
",",
"upY",
",",
"upZ",
",",
"dest",
")",
";",
"}"
] | Apply a "lookat" transformation to this matrix for a right-handed coordinate system,
that aligns <code>-z</code> with <code>center - eye</code> and store the result in <code>dest</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>L</code> the lookat matrix,
then the new matrix will be <code>M * L</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * L * v</code>,
the lookat transformation will be applied first!
<p>
In order to set the matrix to a lookat transformation without post-multiplying it,
use {@link #setLookAt(float, float, float, float, float, float, float, float, float) setLookAt()}.
@see #lookAt(Vector3fc, Vector3fc, Vector3fc)
@see #setLookAt(float, float, float, float, float, float, float, float, float)
@param eyeX
the x-coordinate of the eye/camera location
@param eyeY
the y-coordinate of the eye/camera location
@param eyeZ
the z-coordinate of the eye/camera location
@param centerX
the x-coordinate of the point to look at
@param centerY
the y-coordinate of the point to look at
@param centerZ
the z-coordinate of the point to look at
@param upX
the x-coordinate of the up vector
@param upY
the y-coordinate of the up vector
@param upZ
the z-coordinate of the up vector
@param dest
will hold the result
@return dest | [
"Apply",
"a",
"lookat",
"transformation",
"to",
"this",
"matrix",
"for",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"that",
"aligns",
"<code",
">",
"-",
"z<",
"/",
"code",
">",
"with",
"<code",
">",
"center",
"-",
"eye<",
"/",
"code",
">",
"and",
"store",
"the",
"result",
"in",
"<code",
">",
"dest<",
"/",
"code",
">",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"L<",
"/",
"code",
">",
"the",
"lookat",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"L<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"L",
"*",
"v<",
"/",
"code",
">",
"the",
"lookat",
"transformation",
"will",
"be",
"applied",
"first!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"lookat",
"transformation",
"without",
"post",
"-",
"multiplying",
"it",
"use",
"{",
"@link",
"#setLookAt",
"(",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
")",
"setLookAt",
"()",
"}",
"."
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4f.java#L8533-L8541 |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/coordinate/GISCoordinates.java | GISCoordinates.L93_WSG84 | @Pure
public static GeodesicPosition L93_WSG84(double x, double y) {
"""
This function convert France Lambert 93 coordinate to geographic WSG84 Data.
@param x is the coordinate in France Lambert 93
@param y is the coordinate in France Lambert 93
@return lambda and phi in geographic WSG84 in degrees.
"""
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
} | java | @Pure
public static GeodesicPosition L93_WSG84(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
} | [
"@",
"Pure",
"public",
"static",
"GeodesicPosition",
"L93_WSG84",
"(",
"double",
"x",
",",
"double",
"y",
")",
"{",
"final",
"Point2d",
"ntfLambdaPhi",
"=",
"NTFLambert_NTFLambdaPhi",
"(",
"x",
",",
"y",
",",
"LAMBERT_93_N",
",",
"LAMBERT_93_C",
",",
"LAMBERT_93_XS",
",",
"LAMBERT_93_YS",
")",
";",
"return",
"NTFLambdaPhi_WSG84",
"(",
"ntfLambdaPhi",
".",
"getX",
"(",
")",
",",
"ntfLambdaPhi",
".",
"getY",
"(",
")",
")",
";",
"}"
] | This function convert France Lambert 93 coordinate to geographic WSG84 Data.
@param x is the coordinate in France Lambert 93
@param y is the coordinate in France Lambert 93
@return lambda and phi in geographic WSG84 in degrees. | [
"This",
"function",
"convert",
"France",
"Lambert",
"93",
"coordinate",
"to",
"geographic",
"WSG84",
"Data",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/coordinate/GISCoordinates.java#L805-L813 |
javamelody/javamelody | javamelody-core/src/main/java/net/bull/javamelody/internal/model/LabradorRetriever.java | LabradorRetriever.read | private static Serializable read(URLConnection connection, InputStream inputStream)
throws IOException, ClassNotFoundException {
"""
Lit l'objet renvoyé dans le flux de réponse.
@return Object
@param connection URLConnection
@param inputStream InputStream à utiliser à la place de connection.getInputStream()
@throws IOException Exception de communication
@throws ClassNotFoundException Une classe transmise par le serveur n'a pas été trouvée
"""
InputStream input = inputStream;
try {
if ("gzip".equals(connection.getContentEncoding())) {
// si la taille du flux dépasse x Ko et que l'application a retourné un flux compressé
// alors on le décompresse
input = new GZIPInputStream(input);
}
final String contentType = connection.getContentType();
final TransportFormat transportFormat;
if (contentType != null) {
if (contentType.startsWith("text/xml")) {
transportFormat = TransportFormat.XML;
} else if (contentType.startsWith("text/html")) {
throw new IllegalStateException(
"Unexpected html content type, maybe not authentified");
} else {
transportFormat = TransportFormat.SERIALIZED;
}
} else {
transportFormat = TransportFormat.SERIALIZED;
}
return transportFormat.readSerializableFrom(input);
} finally {
try {
input.close();
} finally {
close(connection);
}
}
} | java | private static Serializable read(URLConnection connection, InputStream inputStream)
throws IOException, ClassNotFoundException {
InputStream input = inputStream;
try {
if ("gzip".equals(connection.getContentEncoding())) {
// si la taille du flux dépasse x Ko et que l'application a retourné un flux compressé
// alors on le décompresse
input = new GZIPInputStream(input);
}
final String contentType = connection.getContentType();
final TransportFormat transportFormat;
if (contentType != null) {
if (contentType.startsWith("text/xml")) {
transportFormat = TransportFormat.XML;
} else if (contentType.startsWith("text/html")) {
throw new IllegalStateException(
"Unexpected html content type, maybe not authentified");
} else {
transportFormat = TransportFormat.SERIALIZED;
}
} else {
transportFormat = TransportFormat.SERIALIZED;
}
return transportFormat.readSerializableFrom(input);
} finally {
try {
input.close();
} finally {
close(connection);
}
}
} | [
"private",
"static",
"Serializable",
"read",
"(",
"URLConnection",
"connection",
",",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"InputStream",
"input",
"=",
"inputStream",
";",
"try",
"{",
"if",
"(",
"\"gzip\"",
".",
"equals",
"(",
"connection",
".",
"getContentEncoding",
"(",
")",
")",
")",
"{",
"// si la taille du flux dépasse x Ko et que l'application a retourné un flux compressé\r",
"// alors on le décompresse\r",
"input",
"=",
"new",
"GZIPInputStream",
"(",
"input",
")",
";",
"}",
"final",
"String",
"contentType",
"=",
"connection",
".",
"getContentType",
"(",
")",
";",
"final",
"TransportFormat",
"transportFormat",
";",
"if",
"(",
"contentType",
"!=",
"null",
")",
"{",
"if",
"(",
"contentType",
".",
"startsWith",
"(",
"\"text/xml\"",
")",
")",
"{",
"transportFormat",
"=",
"TransportFormat",
".",
"XML",
";",
"}",
"else",
"if",
"(",
"contentType",
".",
"startsWith",
"(",
"\"text/html\"",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unexpected html content type, maybe not authentified\"",
")",
";",
"}",
"else",
"{",
"transportFormat",
"=",
"TransportFormat",
".",
"SERIALIZED",
";",
"}",
"}",
"else",
"{",
"transportFormat",
"=",
"TransportFormat",
".",
"SERIALIZED",
";",
"}",
"return",
"transportFormat",
".",
"readSerializableFrom",
"(",
"input",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"input",
".",
"close",
"(",
")",
";",
"}",
"finally",
"{",
"close",
"(",
"connection",
")",
";",
"}",
"}",
"}"
] | Lit l'objet renvoyé dans le flux de réponse.
@return Object
@param connection URLConnection
@param inputStream InputStream à utiliser à la place de connection.getInputStream()
@throws IOException Exception de communication
@throws ClassNotFoundException Une classe transmise par le serveur n'a pas été trouvée | [
"Lit",
"l",
"objet",
"renvoyé",
"dans",
"le",
"flux",
"de",
"réponse",
"."
] | train | https://github.com/javamelody/javamelody/blob/18ad583ddeb5dcadd797dfda295409c6983ffd71/javamelody-core/src/main/java/net/bull/javamelody/internal/model/LabradorRetriever.java#L320-L351 |
RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java | RoaringArray.appendCopy | protected void appendCopy(RoaringArray sa, int startingIndex, int end) {
"""
Append copies of the values from another array
@param sa other array
@param startingIndex starting index in the other array
@param end endingIndex (exclusive) in the other array
"""
extendArray(end - startingIndex);
for (int i = startingIndex; i < end; ++i) {
this.keys[this.size] = sa.keys[i];
this.values[this.size] = sa.values[i].clone();
this.size++;
}
} | java | protected void appendCopy(RoaringArray sa, int startingIndex, int end) {
extendArray(end - startingIndex);
for (int i = startingIndex; i < end; ++i) {
this.keys[this.size] = sa.keys[i];
this.values[this.size] = sa.values[i].clone();
this.size++;
}
} | [
"protected",
"void",
"appendCopy",
"(",
"RoaringArray",
"sa",
",",
"int",
"startingIndex",
",",
"int",
"end",
")",
"{",
"extendArray",
"(",
"end",
"-",
"startingIndex",
")",
";",
"for",
"(",
"int",
"i",
"=",
"startingIndex",
";",
"i",
"<",
"end",
";",
"++",
"i",
")",
"{",
"this",
".",
"keys",
"[",
"this",
".",
"size",
"]",
"=",
"sa",
".",
"keys",
"[",
"i",
"]",
";",
"this",
".",
"values",
"[",
"this",
".",
"size",
"]",
"=",
"sa",
".",
"values",
"[",
"i",
"]",
".",
"clone",
"(",
")",
";",
"this",
".",
"size",
"++",
";",
"}",
"}"
] | Append copies of the values from another array
@param sa other array
@param startingIndex starting index in the other array
@param end endingIndex (exclusive) in the other array | [
"Append",
"copies",
"of",
"the",
"values",
"from",
"another",
"array"
] | train | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java#L208-L215 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBMapperTableModel.java | DynamoDBMapperTableModel.createKey | public <H,R> T createKey(final H hashKey, final R rangeKey) {
"""
Creates a new object instance with the keys populated.
@param <H> The hash key type.
@param <R> The range key type.
@param hashKey The hash key.
@param rangeKey The range key (optional if not present on table).
@return The new instance.
"""
final T key = StandardBeanProperties.DeclaringReflect.<T>newInstance(targetType);
if (hashKey != null) {
final DynamoDBMapperFieldModel<T,H> hk = hashKey();
hk.set(key, hashKey);
}
if (rangeKey != null) {
final DynamoDBMapperFieldModel<T,R> rk = rangeKey();
rk.set(key, rangeKey);
}
return key;
} | java | public <H,R> T createKey(final H hashKey, final R rangeKey) {
final T key = StandardBeanProperties.DeclaringReflect.<T>newInstance(targetType);
if (hashKey != null) {
final DynamoDBMapperFieldModel<T,H> hk = hashKey();
hk.set(key, hashKey);
}
if (rangeKey != null) {
final DynamoDBMapperFieldModel<T,R> rk = rangeKey();
rk.set(key, rangeKey);
}
return key;
} | [
"public",
"<",
"H",
",",
"R",
">",
"T",
"createKey",
"(",
"final",
"H",
"hashKey",
",",
"final",
"R",
"rangeKey",
")",
"{",
"final",
"T",
"key",
"=",
"StandardBeanProperties",
".",
"DeclaringReflect",
".",
"<",
"T",
">",
"newInstance",
"(",
"targetType",
")",
";",
"if",
"(",
"hashKey",
"!=",
"null",
")",
"{",
"final",
"DynamoDBMapperFieldModel",
"<",
"T",
",",
"H",
">",
"hk",
"=",
"hashKey",
"(",
")",
";",
"hk",
".",
"set",
"(",
"key",
",",
"hashKey",
")",
";",
"}",
"if",
"(",
"rangeKey",
"!=",
"null",
")",
"{",
"final",
"DynamoDBMapperFieldModel",
"<",
"T",
",",
"R",
">",
"rk",
"=",
"rangeKey",
"(",
")",
";",
"rk",
".",
"set",
"(",
"key",
",",
"rangeKey",
")",
";",
"}",
"return",
"key",
";",
"}"
] | Creates a new object instance with the keys populated.
@param <H> The hash key type.
@param <R> The range key type.
@param hashKey The hash key.
@param rangeKey The range key (optional if not present on table).
@return The new instance. | [
"Creates",
"a",
"new",
"object",
"instance",
"with",
"the",
"keys",
"populated",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBMapperTableModel.java#L287-L298 |
josueeduardo/snappy | plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/MainClassFinder.java | MainClassFinder.findMainClass | public static String findMainClass(JarFile jarFile, String classesLocation)
throws IOException {
"""
Find the main class in a given jar file.
@param jarFile the jar file to search
@param classesLocation the location within the jar containing classes
@return the main class or {@code null}
@throws IOException if the jar file cannot be read
"""
return doWithMainClasses(jarFile, classesLocation,
new ClassNameCallback<String>() {
@Override
public String doWith(String className) {
return className;
}
});
} | java | public static String findMainClass(JarFile jarFile, String classesLocation)
throws IOException {
return doWithMainClasses(jarFile, classesLocation,
new ClassNameCallback<String>() {
@Override
public String doWith(String className) {
return className;
}
});
} | [
"public",
"static",
"String",
"findMainClass",
"(",
"JarFile",
"jarFile",
",",
"String",
"classesLocation",
")",
"throws",
"IOException",
"{",
"return",
"doWithMainClasses",
"(",
"jarFile",
",",
"classesLocation",
",",
"new",
"ClassNameCallback",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"doWith",
"(",
"String",
"className",
")",
"{",
"return",
"className",
";",
"}",
"}",
")",
";",
"}"
] | Find the main class in a given jar file.
@param jarFile the jar file to search
@param classesLocation the location within the jar containing classes
@return the main class or {@code null}
@throws IOException if the jar file cannot be read | [
"Find",
"the",
"main",
"class",
"in",
"a",
"given",
"jar",
"file",
"."
] | train | https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/MainClassFinder.java#L171-L180 |
haraldk/TwelveMonkeys | sandbox/sandbox-common/src/main/java/com/twelvemonkeys/net/NetUtil.java | NetUtil.getBytesHttp | public static byte[] getBytesHttp(String pURL, int pTimeout) throws IOException {
"""
Gets the content from a given URL, with the given timeout.
The timeout must be > 0. A timeout of zero is interpreted as an
infinite timeout. Supports basic HTTP
authentication, using a URL string similar to most browsers.
<P/>
<SMALL>Implementation note: If the timeout parameter is greater than 0,
this method uses my own implementation of
java.net.HttpURLConnection, that uses plain sockets, to create an
HTTP connection to the given URL. The {@code read} methods called
on the returned InputStream, will block only for the specified timeout.
If the timeout expires, a java.io.InterruptedIOException is raised.
<BR/>
</SMALL>
@param pURL the URL to get.
@param pTimeout the specified timeout, in milliseconds.
@return a byte array that is read from the socket connection, created
from the given URL.
@throws MalformedURLException if the url parameter specifies an
unknown protocol, or does not form a valid URL.
@throws UnknownHostException if the IP address for the given URL cannot
be resolved.
@throws FileNotFoundException if there is no file at the given URL.
@throws IOException if an error occurs during transfer.
@see #getBytesHttp(URL,int)
@see java.net.Socket
@see java.net.Socket#setSoTimeout(int) setSoTimeout
@see java.io.InterruptedIOException
@see <A href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC 2616</A>
"""
// Get the input stream from the url
InputStream in = new BufferedInputStream(getInputStreamHttp(pURL, pTimeout), BUF_SIZE * 2);
// Get all the bytes in loop
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
int count;
byte[] buffer = new byte[BUF_SIZE];
try {
while ((count = in.read(buffer)) != -1) {
// NOTE: According to the J2SE API doc, read(byte[]) will read
// at least 1 byte, or return -1, if end-of-file is reached.
bytes.write(buffer, 0, count);
}
}
finally {
// Close the buffer
in.close();
}
return bytes.toByteArray();
} | java | public static byte[] getBytesHttp(String pURL, int pTimeout) throws IOException {
// Get the input stream from the url
InputStream in = new BufferedInputStream(getInputStreamHttp(pURL, pTimeout), BUF_SIZE * 2);
// Get all the bytes in loop
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
int count;
byte[] buffer = new byte[BUF_SIZE];
try {
while ((count = in.read(buffer)) != -1) {
// NOTE: According to the J2SE API doc, read(byte[]) will read
// at least 1 byte, or return -1, if end-of-file is reached.
bytes.write(buffer, 0, count);
}
}
finally {
// Close the buffer
in.close();
}
return bytes.toByteArray();
} | [
"public",
"static",
"byte",
"[",
"]",
"getBytesHttp",
"(",
"String",
"pURL",
",",
"int",
"pTimeout",
")",
"throws",
"IOException",
"{",
"// Get the input stream from the url",
"InputStream",
"in",
"=",
"new",
"BufferedInputStream",
"(",
"getInputStreamHttp",
"(",
"pURL",
",",
"pTimeout",
")",
",",
"BUF_SIZE",
"*",
"2",
")",
";",
"// Get all the bytes in loop",
"ByteArrayOutputStream",
"bytes",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"int",
"count",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"BUF_SIZE",
"]",
";",
"try",
"{",
"while",
"(",
"(",
"count",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
")",
"!=",
"-",
"1",
")",
"{",
"// NOTE: According to the J2SE API doc, read(byte[]) will read",
"// at least 1 byte, or return -1, if end-of-file is reached.",
"bytes",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"count",
")",
";",
"}",
"}",
"finally",
"{",
"// Close the buffer",
"in",
".",
"close",
"(",
")",
";",
"}",
"return",
"bytes",
".",
"toByteArray",
"(",
")",
";",
"}"
] | Gets the content from a given URL, with the given timeout.
The timeout must be > 0. A timeout of zero is interpreted as an
infinite timeout. Supports basic HTTP
authentication, using a URL string similar to most browsers.
<P/>
<SMALL>Implementation note: If the timeout parameter is greater than 0,
this method uses my own implementation of
java.net.HttpURLConnection, that uses plain sockets, to create an
HTTP connection to the given URL. The {@code read} methods called
on the returned InputStream, will block only for the specified timeout.
If the timeout expires, a java.io.InterruptedIOException is raised.
<BR/>
</SMALL>
@param pURL the URL to get.
@param pTimeout the specified timeout, in milliseconds.
@return a byte array that is read from the socket connection, created
from the given URL.
@throws MalformedURLException if the url parameter specifies an
unknown protocol, or does not form a valid URL.
@throws UnknownHostException if the IP address for the given URL cannot
be resolved.
@throws FileNotFoundException if there is no file at the given URL.
@throws IOException if an error occurs during transfer.
@see #getBytesHttp(URL,int)
@see java.net.Socket
@see java.net.Socket#setSoTimeout(int) setSoTimeout
@see java.io.InterruptedIOException
@see <A href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC 2616</A> | [
"Gets",
"the",
"content",
"from",
"a",
"given",
"URL",
"with",
"the",
"given",
"timeout",
".",
"The",
"timeout",
"must",
"be",
">",
"0",
".",
"A",
"timeout",
"of",
"zero",
"is",
"interpreted",
"as",
"an",
"infinite",
"timeout",
".",
"Supports",
"basic",
"HTTP",
"authentication",
"using",
"a",
"URL",
"string",
"similar",
"to",
"most",
"browsers",
".",
"<P",
"/",
">",
"<SMALL",
">",
"Implementation",
"note",
":",
"If",
"the",
"timeout",
"parameter",
"is",
"greater",
"than",
"0",
"this",
"method",
"uses",
"my",
"own",
"implementation",
"of",
"java",
".",
"net",
".",
"HttpURLConnection",
"that",
"uses",
"plain",
"sockets",
"to",
"create",
"an",
"HTTP",
"connection",
"to",
"the",
"given",
"URL",
".",
"The",
"{",
"@code",
"read",
"}",
"methods",
"called",
"on",
"the",
"returned",
"InputStream",
"will",
"block",
"only",
"for",
"the",
"specified",
"timeout",
".",
"If",
"the",
"timeout",
"expires",
"a",
"java",
".",
"io",
".",
"InterruptedIOException",
"is",
"raised",
".",
"<BR",
"/",
">",
"<",
"/",
"SMALL",
">"
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/net/NetUtil.java#L967-L989 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.jms.2.0/src/com/ibm/ws/sib/api/jms/impl/MsgDestEncodingUtilsImpl.java | MsgDestEncodingUtilsImpl.decodeOtherProperties | private static void decodeOtherProperties(JmsDestination newDest, byte[] msgForm, int offset) throws JMSException {
"""
decodeOtherProperties
Decode the more interesting JmsDestination properties, which may or may not be included:
Queue/Topic name
TopicSpace
ReadAhead
Cluster properties
@param newDest The Destination to apply the properties to
@param msgForm The byte array containing the encoded Destination values
@param offset The current offset into msgForm
@exception JMSException Thrown if anything goes horribly wrong
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "decodeOtherProperties", new Object[]{newDest, msgForm, offset});
PropertyInputStream stream = new PropertyInputStream(msgForm, offset);
while (stream.hasMore()) {
String shortName = stream.readShortName();
String longName = reverseMap.get(shortName);
if (longName != null) {
PropertyEntry propEntry = propertyMap.get(longName); // This can't be null, as we just got the name from the reverseMap!
Object propValue = propEntry.getPropertyCoder().decodeProperty(stream);
setProperty(newDest, longName, propEntry.getIntValue(), propValue);
}
else {
// If there is no mapping for the short name, then the property is not known.
// The most likely situation is that we have been sent a property for a newer release.
//
throw (JMSException)JmsErrorUtils.newThrowable(JMSException.class
,"UNKNOWN_PROPERTY_CWSIA0363"
,new Object[] {shortName}
,null
,"MsgDestEncodingUtilsImpl.decodeOtherProperties#1"
,null
,tc);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "decodeOtherProperties");
} | java | private static void decodeOtherProperties(JmsDestination newDest, byte[] msgForm, int offset) throws JMSException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "decodeOtherProperties", new Object[]{newDest, msgForm, offset});
PropertyInputStream stream = new PropertyInputStream(msgForm, offset);
while (stream.hasMore()) {
String shortName = stream.readShortName();
String longName = reverseMap.get(shortName);
if (longName != null) {
PropertyEntry propEntry = propertyMap.get(longName); // This can't be null, as we just got the name from the reverseMap!
Object propValue = propEntry.getPropertyCoder().decodeProperty(stream);
setProperty(newDest, longName, propEntry.getIntValue(), propValue);
}
else {
// If there is no mapping for the short name, then the property is not known.
// The most likely situation is that we have been sent a property for a newer release.
//
throw (JMSException)JmsErrorUtils.newThrowable(JMSException.class
,"UNKNOWN_PROPERTY_CWSIA0363"
,new Object[] {shortName}
,null
,"MsgDestEncodingUtilsImpl.decodeOtherProperties#1"
,null
,tc);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "decodeOtherProperties");
} | [
"private",
"static",
"void",
"decodeOtherProperties",
"(",
"JmsDestination",
"newDest",
",",
"byte",
"[",
"]",
"msgForm",
",",
"int",
"offset",
")",
"throws",
"JMSException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"decodeOtherProperties\"",
",",
"new",
"Object",
"[",
"]",
"{",
"newDest",
",",
"msgForm",
",",
"offset",
"}",
")",
";",
"PropertyInputStream",
"stream",
"=",
"new",
"PropertyInputStream",
"(",
"msgForm",
",",
"offset",
")",
";",
"while",
"(",
"stream",
".",
"hasMore",
"(",
")",
")",
"{",
"String",
"shortName",
"=",
"stream",
".",
"readShortName",
"(",
")",
";",
"String",
"longName",
"=",
"reverseMap",
".",
"get",
"(",
"shortName",
")",
";",
"if",
"(",
"longName",
"!=",
"null",
")",
"{",
"PropertyEntry",
"propEntry",
"=",
"propertyMap",
".",
"get",
"(",
"longName",
")",
";",
"// This can't be null, as we just got the name from the reverseMap!",
"Object",
"propValue",
"=",
"propEntry",
".",
"getPropertyCoder",
"(",
")",
".",
"decodeProperty",
"(",
"stream",
")",
";",
"setProperty",
"(",
"newDest",
",",
"longName",
",",
"propEntry",
".",
"getIntValue",
"(",
")",
",",
"propValue",
")",
";",
"}",
"else",
"{",
"// If there is no mapping for the short name, then the property is not known.",
"// The most likely situation is that we have been sent a property for a newer release.",
"//",
"throw",
"(",
"JMSException",
")",
"JmsErrorUtils",
".",
"newThrowable",
"(",
"JMSException",
".",
"class",
",",
"\"UNKNOWN_PROPERTY_CWSIA0363\"",
",",
"new",
"Object",
"[",
"]",
"{",
"shortName",
"}",
",",
"null",
",",
"\"MsgDestEncodingUtilsImpl.decodeOtherProperties#1\"",
",",
"null",
",",
"tc",
")",
";",
"}",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"decodeOtherProperties\"",
")",
";",
"}"
] | decodeOtherProperties
Decode the more interesting JmsDestination properties, which may or may not be included:
Queue/Topic name
TopicSpace
ReadAhead
Cluster properties
@param newDest The Destination to apply the properties to
@param msgForm The byte array containing the encoded Destination values
@param offset The current offset into msgForm
@exception JMSException Thrown if anything goes horribly wrong | [
"decodeOtherProperties",
"Decode",
"the",
"more",
"interesting",
"JmsDestination",
"properties",
"which",
"may",
"or",
"may",
"not",
"be",
"included",
":",
"Queue",
"/",
"Topic",
"name",
"TopicSpace",
"ReadAhead",
"Cluster",
"properties"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.jms.2.0/src/com/ibm/ws/sib/api/jms/impl/MsgDestEncodingUtilsImpl.java#L760-L788 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/util/blockdata/BlockDataMessage.java | BlockDataMessage.sendBlockData | public static void sendBlockData(Chunk chunk, String identifier, ByteBuf data, EntityPlayerMP player) {
"""
Sends the data to the specified {@link EntityPlayerMP}.
@param chunk the chunk
@param identifier the identifier
@param data the data
@param player the player
"""
MalisisCore.network.sendTo(new Packet(chunk, identifier, data), player);
} | java | public static void sendBlockData(Chunk chunk, String identifier, ByteBuf data, EntityPlayerMP player)
{
MalisisCore.network.sendTo(new Packet(chunk, identifier, data), player);
} | [
"public",
"static",
"void",
"sendBlockData",
"(",
"Chunk",
"chunk",
",",
"String",
"identifier",
",",
"ByteBuf",
"data",
",",
"EntityPlayerMP",
"player",
")",
"{",
"MalisisCore",
".",
"network",
".",
"sendTo",
"(",
"new",
"Packet",
"(",
"chunk",
",",
"identifier",
",",
"data",
")",
",",
"player",
")",
";",
"}"
] | Sends the data to the specified {@link EntityPlayerMP}.
@param chunk the chunk
@param identifier the identifier
@param data the data
@param player the player | [
"Sends",
"the",
"data",
"to",
"the",
"specified",
"{",
"@link",
"EntityPlayerMP",
"}",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/blockdata/BlockDataMessage.java#L65-L68 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/requeststate/NameService.java | NameService.nameObject | public synchronized void nameObject(String namePrefix, INameable object) {
"""
This method will create a unique name for an INameable object. The name
will be unque within the session. This will throw an IllegalStateException
if INameable.setObjectName has previously been called on object.
@param namePrefix The prefix of the generated name.
@param object the INameable object.
@throws IllegalStateException if this method is called more than once for an object
"""
String name = namePrefix + Integer.toString(_nextValue++);
object.setObjectName(name);
} | java | public synchronized void nameObject(String namePrefix, INameable object)
{
String name = namePrefix + Integer.toString(_nextValue++);
object.setObjectName(name);
} | [
"public",
"synchronized",
"void",
"nameObject",
"(",
"String",
"namePrefix",
",",
"INameable",
"object",
")",
"{",
"String",
"name",
"=",
"namePrefix",
"+",
"Integer",
".",
"toString",
"(",
"_nextValue",
"++",
")",
";",
"object",
".",
"setObjectName",
"(",
"name",
")",
";",
"}"
] | This method will create a unique name for an INameable object. The name
will be unque within the session. This will throw an IllegalStateException
if INameable.setObjectName has previously been called on object.
@param namePrefix The prefix of the generated name.
@param object the INameable object.
@throws IllegalStateException if this method is called more than once for an object | [
"This",
"method",
"will",
"create",
"a",
"unique",
"name",
"for",
"an",
"INameable",
"object",
".",
"The",
"name",
"will",
"be",
"unque",
"within",
"the",
"session",
".",
"This",
"will",
"throw",
"an",
"IllegalStateException",
"if",
"INameable",
".",
"setObjectName",
"has",
"previously",
"been",
"called",
"on",
"object",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/requeststate/NameService.java#L160-L164 |
gallandarakhneorg/afc | advanced/dbasefile/src/main/java/org/arakhne/afc/io/dbase/DBaseFileReader.java | DBaseFileReader.read8ByteDoubleRecordValue | @SuppressWarnings("checkstyle:magicnumber")
private static int read8ByteDoubleRecordValue(DBaseFileField field, int nrecord, int nfield,
byte[] rawData, int rawOffset, OutputParameter<Double> value) throws IOException {
"""
Read a 8 BYTE DOUBLE record value.
@param field is the current parsed field.
@param nrecord is the number of the record
@param nfield is the number of the field
@param rawData raw data
@param rawOffset is the index at which the data could be obtained
@param value will be set with the value extracted from the dBASE file
@return the count of consumed bytes
@throws IOException in case of error.
"""
final double rawNumber = EndianNumbers.toLEDouble(
rawData[rawOffset], rawData[rawOffset + 1],
rawData[rawOffset + 2], rawData[rawOffset + 3],
rawData[rawOffset + 4], rawData[rawOffset + 5],
rawData[rawOffset + 6], rawData[rawOffset + 7]);
try {
value.set(new Double(rawNumber));
return 8;
} catch (NumberFormatException exception) {
throw new InvalidRawDataFormatException(nrecord, nfield, Double.toString(rawNumber));
}
} | java | @SuppressWarnings("checkstyle:magicnumber")
private static int read8ByteDoubleRecordValue(DBaseFileField field, int nrecord, int nfield,
byte[] rawData, int rawOffset, OutputParameter<Double> value) throws IOException {
final double rawNumber = EndianNumbers.toLEDouble(
rawData[rawOffset], rawData[rawOffset + 1],
rawData[rawOffset + 2], rawData[rawOffset + 3],
rawData[rawOffset + 4], rawData[rawOffset + 5],
rawData[rawOffset + 6], rawData[rawOffset + 7]);
try {
value.set(new Double(rawNumber));
return 8;
} catch (NumberFormatException exception) {
throw new InvalidRawDataFormatException(nrecord, nfield, Double.toString(rawNumber));
}
} | [
"@",
"SuppressWarnings",
"(",
"\"checkstyle:magicnumber\"",
")",
"private",
"static",
"int",
"read8ByteDoubleRecordValue",
"(",
"DBaseFileField",
"field",
",",
"int",
"nrecord",
",",
"int",
"nfield",
",",
"byte",
"[",
"]",
"rawData",
",",
"int",
"rawOffset",
",",
"OutputParameter",
"<",
"Double",
">",
"value",
")",
"throws",
"IOException",
"{",
"final",
"double",
"rawNumber",
"=",
"EndianNumbers",
".",
"toLEDouble",
"(",
"rawData",
"[",
"rawOffset",
"]",
",",
"rawData",
"[",
"rawOffset",
"+",
"1",
"]",
",",
"rawData",
"[",
"rawOffset",
"+",
"2",
"]",
",",
"rawData",
"[",
"rawOffset",
"+",
"3",
"]",
",",
"rawData",
"[",
"rawOffset",
"+",
"4",
"]",
",",
"rawData",
"[",
"rawOffset",
"+",
"5",
"]",
",",
"rawData",
"[",
"rawOffset",
"+",
"6",
"]",
",",
"rawData",
"[",
"rawOffset",
"+",
"7",
"]",
")",
";",
"try",
"{",
"value",
".",
"set",
"(",
"new",
"Double",
"(",
"rawNumber",
")",
")",
";",
"return",
"8",
";",
"}",
"catch",
"(",
"NumberFormatException",
"exception",
")",
"{",
"throw",
"new",
"InvalidRawDataFormatException",
"(",
"nrecord",
",",
"nfield",
",",
"Double",
".",
"toString",
"(",
"rawNumber",
")",
")",
";",
"}",
"}"
] | Read a 8 BYTE DOUBLE record value.
@param field is the current parsed field.
@param nrecord is the number of the record
@param nfield is the number of the field
@param rawData raw data
@param rawOffset is the index at which the data could be obtained
@param value will be set with the value extracted from the dBASE file
@return the count of consumed bytes
@throws IOException in case of error. | [
"Read",
"a",
"8",
"BYTE",
"DOUBLE",
"record",
"value",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/dbasefile/src/main/java/org/arakhne/afc/io/dbase/DBaseFileReader.java#L1224-L1238 |
liyiorg/weixin-popular | src/main/java/weixin/popular/util/PayUtil.java | PayUtil.generateMchAppData | public static MchPayApp generateMchAppData(String prepay_id, String appId, String partnerid, String key) {
"""
(MCH)生成支付APP请求数据
@param prepay_id
预支付订单号
@param appId
appId
@param partnerid
商户平台号
@param key
商户支付密钥
@return app data
"""
Map<String, String> wx_map = new LinkedHashMap<String, String>();
wx_map.put("appid", appId);
wx_map.put("partnerid", partnerid);
wx_map.put("prepayid", prepay_id);
wx_map.put("package", "Sign=WXPay");
wx_map.put("noncestr", UUID.randomUUID().toString().replace("-", ""));
wx_map.put("timestamp", System.currentTimeMillis() / 1000 + "");
String sign = SignatureUtil.generateSign(wx_map, key);
MchPayApp mchPayApp = new MchPayApp();
mchPayApp.setAppid(appId);
mchPayApp.setPartnerid(partnerid);
mchPayApp.setPrepayid(prepay_id);
mchPayApp.setPackage_(wx_map.get("package"));
mchPayApp.setNoncestr(wx_map.get("noncestr"));
mchPayApp.setTimestamp(wx_map.get("timestamp"));
mchPayApp.setSign(sign);
return mchPayApp;
} | java | public static MchPayApp generateMchAppData(String prepay_id, String appId, String partnerid, String key) {
Map<String, String> wx_map = new LinkedHashMap<String, String>();
wx_map.put("appid", appId);
wx_map.put("partnerid", partnerid);
wx_map.put("prepayid", prepay_id);
wx_map.put("package", "Sign=WXPay");
wx_map.put("noncestr", UUID.randomUUID().toString().replace("-", ""));
wx_map.put("timestamp", System.currentTimeMillis() / 1000 + "");
String sign = SignatureUtil.generateSign(wx_map, key);
MchPayApp mchPayApp = new MchPayApp();
mchPayApp.setAppid(appId);
mchPayApp.setPartnerid(partnerid);
mchPayApp.setPrepayid(prepay_id);
mchPayApp.setPackage_(wx_map.get("package"));
mchPayApp.setNoncestr(wx_map.get("noncestr"));
mchPayApp.setTimestamp(wx_map.get("timestamp"));
mchPayApp.setSign(sign);
return mchPayApp;
} | [
"public",
"static",
"MchPayApp",
"generateMchAppData",
"(",
"String",
"prepay_id",
",",
"String",
"appId",
",",
"String",
"partnerid",
",",
"String",
"key",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"wx_map",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"wx_map",
".",
"put",
"(",
"\"appid\"",
",",
"appId",
")",
";",
"wx_map",
".",
"put",
"(",
"\"partnerid\"",
",",
"partnerid",
")",
";",
"wx_map",
".",
"put",
"(",
"\"prepayid\"",
",",
"prepay_id",
")",
";",
"wx_map",
".",
"put",
"(",
"\"package\"",
",",
"\"Sign=WXPay\"",
")",
";",
"wx_map",
".",
"put",
"(",
"\"noncestr\"",
",",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"\"-\"",
",",
"\"\"",
")",
")",
";",
"wx_map",
".",
"put",
"(",
"\"timestamp\"",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"/",
"1000",
"+",
"\"\"",
")",
";",
"String",
"sign",
"=",
"SignatureUtil",
".",
"generateSign",
"(",
"wx_map",
",",
"key",
")",
";",
"MchPayApp",
"mchPayApp",
"=",
"new",
"MchPayApp",
"(",
")",
";",
"mchPayApp",
".",
"setAppid",
"(",
"appId",
")",
";",
"mchPayApp",
".",
"setPartnerid",
"(",
"partnerid",
")",
";",
"mchPayApp",
".",
"setPrepayid",
"(",
"prepay_id",
")",
";",
"mchPayApp",
".",
"setPackage_",
"(",
"wx_map",
".",
"get",
"(",
"\"package\"",
")",
")",
";",
"mchPayApp",
".",
"setNoncestr",
"(",
"wx_map",
".",
"get",
"(",
"\"noncestr\"",
")",
")",
";",
"mchPayApp",
".",
"setTimestamp",
"(",
"wx_map",
".",
"get",
"(",
"\"timestamp\"",
")",
")",
";",
"mchPayApp",
".",
"setSign",
"(",
"sign",
")",
";",
"return",
"mchPayApp",
";",
"}"
] | (MCH)生成支付APP请求数据
@param prepay_id
预支付订单号
@param appId
appId
@param partnerid
商户平台号
@param key
商户支付密钥
@return app data | [
"(",
"MCH",
")",
"生成支付APP请求数据"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/util/PayUtil.java#L108-L126 |
kiegroup/jbpm | jbpm-case-mgmt/jbpm-case-mgmt-impl/src/main/java/org/jbpm/casemgmt/impl/CaseRuntimeDataServiceImpl.java | CaseRuntimeDataServiceImpl.internalGetCaseStages | public List<CaseStageInstance> internalGetCaseStages(CaseDefinition caseDef, String caseId, boolean activeOnly, QueryContext queryContext) {
"""
/*
Helper methods to parse process and extract case related information
"""
CorrelationKey correlationKey = correlationKeyFactory.newCorrelationKey(caseId);
Collection<org.jbpm.services.api.model.NodeInstanceDesc> nodes = runtimeDataService.getNodeInstancesByCorrelationKeyNodeType(correlationKey,
Arrays.asList(ProcessInstance.STATE_ACTIVE),
Arrays.asList("DynamicNode"),
queryContext);
Collection<Long> completedNodes = nodes.stream().filter(n -> ((NodeInstanceDesc)n).getType() == 1).map(n -> n.getId()).collect(toList());
Map<String, CaseStage> stagesByName = caseDef.getCaseStages().stream()
.collect(toMap(CaseStage::getId, c -> c));
Predicate<org.jbpm.services.api.model.NodeInstanceDesc> filterNodes = null;
if (activeOnly) {
filterNodes = n -> ((NodeInstanceDesc)n).getType() == 0 && !completedNodes.contains(((NodeInstanceDesc)n).getId());
} else {
filterNodes = n -> ((NodeInstanceDesc)n).getType() == 0;
}
List<String> triggeredStages = new ArrayList<>();
List<CaseStageInstance> stages = new ArrayList<>();
nodes.stream()
.filter(filterNodes)
.map(n -> {
StageStatus status = StageStatus.Active;
if (completedNodes.contains(((NodeInstanceDesc)n).getId())) {
status = StageStatus.Completed;
}
Collection<org.jbpm.services.api.model.NodeInstanceDesc> activeNodes = getActiveNodesForCaseAndStage(caseId, n.getNodeId(), new QueryContext(0, 100));
return new CaseStageInstanceImpl(n.getNodeId(), n.getName(), stagesByName.get(n.getNodeId()).getAdHocFragments(), activeNodes, status);
})
.forEach(csi -> {
stages.add(csi);
triggeredStages.add(csi.getName());
});
if (!activeOnly) {
// add other stages that are present in the definition
caseDef.getCaseStages().stream()
.filter(cs -> !triggeredStages.contains(cs.getName()))
.map(cs -> new CaseStageInstanceImpl(cs.getId(), cs.getName(), cs.getAdHocFragments(), Collections.emptyList(), StageStatus.Available))
.forEach(csi -> stages.add(csi));
}
return stages;
} | java | public List<CaseStageInstance> internalGetCaseStages(CaseDefinition caseDef, String caseId, boolean activeOnly, QueryContext queryContext) {
CorrelationKey correlationKey = correlationKeyFactory.newCorrelationKey(caseId);
Collection<org.jbpm.services.api.model.NodeInstanceDesc> nodes = runtimeDataService.getNodeInstancesByCorrelationKeyNodeType(correlationKey,
Arrays.asList(ProcessInstance.STATE_ACTIVE),
Arrays.asList("DynamicNode"),
queryContext);
Collection<Long> completedNodes = nodes.stream().filter(n -> ((NodeInstanceDesc)n).getType() == 1).map(n -> n.getId()).collect(toList());
Map<String, CaseStage> stagesByName = caseDef.getCaseStages().stream()
.collect(toMap(CaseStage::getId, c -> c));
Predicate<org.jbpm.services.api.model.NodeInstanceDesc> filterNodes = null;
if (activeOnly) {
filterNodes = n -> ((NodeInstanceDesc)n).getType() == 0 && !completedNodes.contains(((NodeInstanceDesc)n).getId());
} else {
filterNodes = n -> ((NodeInstanceDesc)n).getType() == 0;
}
List<String> triggeredStages = new ArrayList<>();
List<CaseStageInstance> stages = new ArrayList<>();
nodes.stream()
.filter(filterNodes)
.map(n -> {
StageStatus status = StageStatus.Active;
if (completedNodes.contains(((NodeInstanceDesc)n).getId())) {
status = StageStatus.Completed;
}
Collection<org.jbpm.services.api.model.NodeInstanceDesc> activeNodes = getActiveNodesForCaseAndStage(caseId, n.getNodeId(), new QueryContext(0, 100));
return new CaseStageInstanceImpl(n.getNodeId(), n.getName(), stagesByName.get(n.getNodeId()).getAdHocFragments(), activeNodes, status);
})
.forEach(csi -> {
stages.add(csi);
triggeredStages.add(csi.getName());
});
if (!activeOnly) {
// add other stages that are present in the definition
caseDef.getCaseStages().stream()
.filter(cs -> !triggeredStages.contains(cs.getName()))
.map(cs -> new CaseStageInstanceImpl(cs.getId(), cs.getName(), cs.getAdHocFragments(), Collections.emptyList(), StageStatus.Available))
.forEach(csi -> stages.add(csi));
}
return stages;
} | [
"public",
"List",
"<",
"CaseStageInstance",
">",
"internalGetCaseStages",
"(",
"CaseDefinition",
"caseDef",
",",
"String",
"caseId",
",",
"boolean",
"activeOnly",
",",
"QueryContext",
"queryContext",
")",
"{",
"CorrelationKey",
"correlationKey",
"=",
"correlationKeyFactory",
".",
"newCorrelationKey",
"(",
"caseId",
")",
";",
"Collection",
"<",
"org",
".",
"jbpm",
".",
"services",
".",
"api",
".",
"model",
".",
"NodeInstanceDesc",
">",
"nodes",
"=",
"runtimeDataService",
".",
"getNodeInstancesByCorrelationKeyNodeType",
"(",
"correlationKey",
",",
"Arrays",
".",
"asList",
"(",
"ProcessInstance",
".",
"STATE_ACTIVE",
")",
",",
"Arrays",
".",
"asList",
"(",
"\"DynamicNode\"",
")",
",",
"queryContext",
")",
";",
"Collection",
"<",
"Long",
">",
"completedNodes",
"=",
"nodes",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"n",
"->",
"(",
"(",
"NodeInstanceDesc",
")",
"n",
")",
".",
"getType",
"(",
")",
"==",
"1",
")",
".",
"map",
"(",
"n",
"->",
"n",
".",
"getId",
"(",
")",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"CaseStage",
">",
"stagesByName",
"=",
"caseDef",
".",
"getCaseStages",
"(",
")",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"toMap",
"(",
"CaseStage",
"::",
"getId",
",",
"c",
"->",
"c",
")",
")",
";",
"Predicate",
"<",
"org",
".",
"jbpm",
".",
"services",
".",
"api",
".",
"model",
".",
"NodeInstanceDesc",
">",
"filterNodes",
"=",
"null",
";",
"if",
"(",
"activeOnly",
")",
"{",
"filterNodes",
"=",
"n",
"->",
"(",
"(",
"NodeInstanceDesc",
")",
"n",
")",
".",
"getType",
"(",
")",
"==",
"0",
"&&",
"!",
"completedNodes",
".",
"contains",
"(",
"(",
"(",
"NodeInstanceDesc",
")",
"n",
")",
".",
"getId",
"(",
")",
")",
";",
"}",
"else",
"{",
"filterNodes",
"=",
"n",
"->",
"(",
"(",
"NodeInstanceDesc",
")",
"n",
")",
".",
"getType",
"(",
")",
"==",
"0",
";",
"}",
"List",
"<",
"String",
">",
"triggeredStages",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"CaseStageInstance",
">",
"stages",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"nodes",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"filterNodes",
")",
".",
"map",
"(",
"n",
"->",
"{",
"StageStatus",
"status",
"=",
"StageStatus",
".",
"Active",
";",
"if",
"(",
"completedNodes",
".",
"contains",
"(",
"(",
"(",
"NodeInstanceDesc",
")",
"n",
")",
".",
"getId",
"(",
")",
")",
")",
"{",
"status",
"=",
"StageStatus",
".",
"Completed",
";",
"}",
"Collection",
"<",
"org",
".",
"jbpm",
".",
"services",
".",
"api",
".",
"model",
".",
"NodeInstanceDesc",
">",
"activeNodes",
"=",
"getActiveNodesForCaseAndStage",
"(",
"caseId",
",",
"n",
".",
"getNodeId",
"(",
")",
",",
"new",
"QueryContext",
"(",
"0",
",",
"100",
")",
")",
";",
"return",
"new",
"CaseStageInstanceImpl",
"(",
"n",
".",
"getNodeId",
"(",
")",
",",
"n",
".",
"getName",
"(",
")",
",",
"stagesByName",
".",
"get",
"(",
"n",
".",
"getNodeId",
"(",
")",
")",
".",
"getAdHocFragments",
"(",
")",
",",
"activeNodes",
",",
"status",
")",
";",
"}",
")",
".",
"forEach",
"(",
"csi",
"->",
"{",
"stages",
".",
"add",
"(",
"csi",
")",
";",
"triggeredStages",
".",
"add",
"(",
"csi",
".",
"getName",
"(",
")",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"activeOnly",
")",
"{",
"// add other stages that are present in the definition ",
"caseDef",
".",
"getCaseStages",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"cs",
"->",
"!",
"triggeredStages",
".",
"contains",
"(",
"cs",
".",
"getName",
"(",
")",
")",
")",
".",
"map",
"(",
"cs",
"->",
"new",
"CaseStageInstanceImpl",
"(",
"cs",
".",
"getId",
"(",
")",
",",
"cs",
".",
"getName",
"(",
")",
",",
"cs",
".",
"getAdHocFragments",
"(",
")",
",",
"Collections",
".",
"emptyList",
"(",
")",
",",
"StageStatus",
".",
"Available",
")",
")",
".",
"forEach",
"(",
"csi",
"->",
"stages",
".",
"add",
"(",
"csi",
")",
")",
";",
"}",
"return",
"stages",
";",
"}"
] | /*
Helper methods to parse process and extract case related information | [
"/",
"*",
"Helper",
"methods",
"to",
"parse",
"process",
"and",
"extract",
"case",
"related",
"information"
] | train | https://github.com/kiegroup/jbpm/blob/c3473c728aa382ebbea01e380c5e754a96647b82/jbpm-case-mgmt/jbpm-case-mgmt-impl/src/main/java/org/jbpm/casemgmt/impl/CaseRuntimeDataServiceImpl.java#L613-L659 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ExpressRouteCrossConnectionsInner.java | ExpressRouteCrossConnectionsInner.createOrUpdateAsync | public Observable<ExpressRouteCrossConnectionInner> createOrUpdateAsync(String resourceGroupName, String crossConnectionName, ExpressRouteCrossConnectionInner parameters) {
"""
Update the specified ExpressRouteCrossConnection.
@param resourceGroupName The name of the resource group.
@param crossConnectionName The name of the ExpressRouteCrossConnection.
@param parameters Parameters supplied to the update express route crossConnection operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, crossConnectionName, parameters).map(new Func1<ServiceResponse<ExpressRouteCrossConnectionInner>, ExpressRouteCrossConnectionInner>() {
@Override
public ExpressRouteCrossConnectionInner call(ServiceResponse<ExpressRouteCrossConnectionInner> response) {
return response.body();
}
});
} | java | public Observable<ExpressRouteCrossConnectionInner> createOrUpdateAsync(String resourceGroupName, String crossConnectionName, ExpressRouteCrossConnectionInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, crossConnectionName, parameters).map(new Func1<ServiceResponse<ExpressRouteCrossConnectionInner>, ExpressRouteCrossConnectionInner>() {
@Override
public ExpressRouteCrossConnectionInner call(ServiceResponse<ExpressRouteCrossConnectionInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ExpressRouteCrossConnectionInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"crossConnectionName",
",",
"ExpressRouteCrossConnectionInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"crossConnectionName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ExpressRouteCrossConnectionInner",
">",
",",
"ExpressRouteCrossConnectionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ExpressRouteCrossConnectionInner",
"call",
"(",
"ServiceResponse",
"<",
"ExpressRouteCrossConnectionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Update the specified ExpressRouteCrossConnection.
@param resourceGroupName The name of the resource group.
@param crossConnectionName The name of the ExpressRouteCrossConnection.
@param parameters Parameters supplied to the update express route crossConnection operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Update",
"the",
"specified",
"ExpressRouteCrossConnection",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ExpressRouteCrossConnectionsInner.java#L471-L478 |
landawn/AbacusUtil | src/com/landawn/abacus/util/TriIterator.java | TriIterator.forEachRemaining | @Override
@Deprecated
public void forEachRemaining(java.util.function.Consumer<? super Triple<A, B, C>> action) {
"""
It's preferred to call <code>forEachRemaining(Try.TriConsumer)</code> to avoid the create the unnecessary <code>Triple</code> Objects.
@deprecated
"""
super.forEachRemaining(action);
} | java | @Override
@Deprecated
public void forEachRemaining(java.util.function.Consumer<? super Triple<A, B, C>> action) {
super.forEachRemaining(action);
} | [
"@",
"Override",
"@",
"Deprecated",
"public",
"void",
"forEachRemaining",
"(",
"java",
".",
"util",
".",
"function",
".",
"Consumer",
"<",
"?",
"super",
"Triple",
"<",
"A",
",",
"B",
",",
"C",
">",
">",
"action",
")",
"{",
"super",
".",
"forEachRemaining",
"(",
"action",
")",
";",
"}"
] | It's preferred to call <code>forEachRemaining(Try.TriConsumer)</code> to avoid the create the unnecessary <code>Triple</code> Objects.
@deprecated | [
"It",
"s",
"preferred",
"to",
"call",
"<code",
">",
"forEachRemaining",
"(",
"Try",
".",
"TriConsumer",
")",
"<",
"/",
"code",
">",
"to",
"avoid",
"the",
"create",
"the",
"unnecessary",
"<code",
">",
"Triple<",
"/",
"code",
">",
"Objects",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/TriIterator.java#L369-L373 |
CODAIT/stocator | src/main/java/com/ibm/stocator/fs/common/StocatorPath.java | StocatorPath.modifyPathToFinalDestination | public Path modifyPathToFinalDestination(Path path) throws IOException {
"""
Accept temporary path and return a final destination path
@param path path name to modify
@return modified path name
@throws IOException if error
"""
String res;
if (tempFileOriginator.equals(DEFAULT_FOUTPUTCOMMITTER_V1)) {
res = parseHadoopOutputCommitter(path, true, hostNameScheme);
} else {
res = extractNameFromTempPath(path, true, hostNameScheme);
}
return new Path(hostNameScheme, res);
} | java | public Path modifyPathToFinalDestination(Path path) throws IOException {
String res;
if (tempFileOriginator.equals(DEFAULT_FOUTPUTCOMMITTER_V1)) {
res = parseHadoopOutputCommitter(path, true, hostNameScheme);
} else {
res = extractNameFromTempPath(path, true, hostNameScheme);
}
return new Path(hostNameScheme, res);
} | [
"public",
"Path",
"modifyPathToFinalDestination",
"(",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"String",
"res",
";",
"if",
"(",
"tempFileOriginator",
".",
"equals",
"(",
"DEFAULT_FOUTPUTCOMMITTER_V1",
")",
")",
"{",
"res",
"=",
"parseHadoopOutputCommitter",
"(",
"path",
",",
"true",
",",
"hostNameScheme",
")",
";",
"}",
"else",
"{",
"res",
"=",
"extractNameFromTempPath",
"(",
"path",
",",
"true",
",",
"hostNameScheme",
")",
";",
"}",
"return",
"new",
"Path",
"(",
"hostNameScheme",
",",
"res",
")",
";",
"}"
] | Accept temporary path and return a final destination path
@param path path name to modify
@return modified path name
@throws IOException if error | [
"Accept",
"temporary",
"path",
"and",
"return",
"a",
"final",
"destination",
"path"
] | train | https://github.com/CODAIT/stocator/blob/35969cadd2e8faa6fdac45e8bec1799fdd3d8299/src/main/java/com/ibm/stocator/fs/common/StocatorPath.java#L188-L197 |
Deep-Symmetry/beat-link | src/main/java/org/deepsymmetry/beatlink/Util.java | Util.bytesToNumberLittleEndian | @SuppressWarnings("SameParameterValue")
public static long bytesToNumberLittleEndian(byte[] buffer, int start, int length) {
"""
Reconstructs a number that is represented by more than one byte in a network packet in little-endian order, for
the very few protocol values that are sent in this quirky way.
@param buffer the byte array containing the packet data
@param start the index of the first byte containing a numeric value
@param length the number of bytes making up the value
@return the reconstructed number
"""
long result = 0;
for (int index = start + length - 1; index >= start; index--) {
result = (result << 8) + unsign(buffer[index]);
}
return result;
} | java | @SuppressWarnings("SameParameterValue")
public static long bytesToNumberLittleEndian(byte[] buffer, int start, int length) {
long result = 0;
for (int index = start + length - 1; index >= start; index--) {
result = (result << 8) + unsign(buffer[index]);
}
return result;
} | [
"@",
"SuppressWarnings",
"(",
"\"SameParameterValue\"",
")",
"public",
"static",
"long",
"bytesToNumberLittleEndian",
"(",
"byte",
"[",
"]",
"buffer",
",",
"int",
"start",
",",
"int",
"length",
")",
"{",
"long",
"result",
"=",
"0",
";",
"for",
"(",
"int",
"index",
"=",
"start",
"+",
"length",
"-",
"1",
";",
"index",
">=",
"start",
";",
"index",
"--",
")",
"{",
"result",
"=",
"(",
"result",
"<<",
"8",
")",
"+",
"unsign",
"(",
"buffer",
"[",
"index",
"]",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Reconstructs a number that is represented by more than one byte in a network packet in little-endian order, for
the very few protocol values that are sent in this quirky way.
@param buffer the byte array containing the packet data
@param start the index of the first byte containing a numeric value
@param length the number of bytes making up the value
@return the reconstructed number | [
"Reconstructs",
"a",
"number",
"that",
"is",
"represented",
"by",
"more",
"than",
"one",
"byte",
"in",
"a",
"network",
"packet",
"in",
"little",
"-",
"endian",
"order",
"for",
"the",
"very",
"few",
"protocol",
"values",
"that",
"are",
"sent",
"in",
"this",
"quirky",
"way",
"."
] | train | https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/Util.java#L259-L266 |
anotheria/moskito | moskito-extensions/moskito-php/src/main/java/net/anotheria/extensions/php/ConnectorsRegistry.java | ConnectorsRegistry.enableConnector | public void enableConnector(String connectorClass, Properties connectorInitProperties) throws ConnectorInitException {
"""
Makes enable connector with given class name if
it registered and not already enabled.
Non-existing or already enabled connectors be ignored
@param connectorClass connector class canonical name
@param connectorInitProperties initialization properties of connector
@throws ConnectorInitException
"""
ConnectorEntry connector = connectors.get(connectorClass);
if(connector != null)
connectors.get(connectorClass).enableConnector(connectorInitProperties);
} | java | public void enableConnector(String connectorClass, Properties connectorInitProperties) throws ConnectorInitException {
ConnectorEntry connector = connectors.get(connectorClass);
if(connector != null)
connectors.get(connectorClass).enableConnector(connectorInitProperties);
} | [
"public",
"void",
"enableConnector",
"(",
"String",
"connectorClass",
",",
"Properties",
"connectorInitProperties",
")",
"throws",
"ConnectorInitException",
"{",
"ConnectorEntry",
"connector",
"=",
"connectors",
".",
"get",
"(",
"connectorClass",
")",
";",
"if",
"(",
"connector",
"!=",
"null",
")",
"connectors",
".",
"get",
"(",
"connectorClass",
")",
".",
"enableConnector",
"(",
"connectorInitProperties",
")",
";",
"}"
] | Makes enable connector with given class name if
it registered and not already enabled.
Non-existing or already enabled connectors be ignored
@param connectorClass connector class canonical name
@param connectorInitProperties initialization properties of connector
@throws ConnectorInitException | [
"Makes",
"enable",
"connector",
"with",
"given",
"class",
"name",
"if",
"it",
"registered",
"and",
"not",
"already",
"enabled",
".",
"Non",
"-",
"existing",
"or",
"already",
"enabled",
"connectors",
"be",
"ignored"
] | train | https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-extensions/moskito-php/src/main/java/net/anotheria/extensions/php/ConnectorsRegistry.java#L50-L57 |
thrau/jarchivelib | src/main/java/org/rauschig/jarchivelib/IOUtils.java | IOUtils.requireDirectory | public static void requireDirectory(File destination) throws IOException, IllegalArgumentException {
"""
Makes sure that the given {@link File} is either a writable directory, or that it does not exist and a directory
can be created at its path.
<br>
Will throw an exception if the given {@link File} is actually an existing file, or the directory is not writable
@param destination the directory which to ensure its existence for
@throws IOException if an I/O error occurs e.g. when attempting to create the destination directory
@throws IllegalArgumentException if the destination is an existing file, or the directory is not writable
"""
if (destination.isFile()) {
throw new IllegalArgumentException(destination + " exists and is a file, directory or path expected.");
} else if (!destination.exists()) {
destination.mkdirs();
}
if (!destination.canWrite()) {
throw new IllegalArgumentException("Can not write to destination " + destination);
}
} | java | public static void requireDirectory(File destination) throws IOException, IllegalArgumentException {
if (destination.isFile()) {
throw new IllegalArgumentException(destination + " exists and is a file, directory or path expected.");
} else if (!destination.exists()) {
destination.mkdirs();
}
if (!destination.canWrite()) {
throw new IllegalArgumentException("Can not write to destination " + destination);
}
} | [
"public",
"static",
"void",
"requireDirectory",
"(",
"File",
"destination",
")",
"throws",
"IOException",
",",
"IllegalArgumentException",
"{",
"if",
"(",
"destination",
".",
"isFile",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"destination",
"+",
"\" exists and is a file, directory or path expected.\"",
")",
";",
"}",
"else",
"if",
"(",
"!",
"destination",
".",
"exists",
"(",
")",
")",
"{",
"destination",
".",
"mkdirs",
"(",
")",
";",
"}",
"if",
"(",
"!",
"destination",
".",
"canWrite",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can not write to destination \"",
"+",
"destination",
")",
";",
"}",
"}"
] | Makes sure that the given {@link File} is either a writable directory, or that it does not exist and a directory
can be created at its path.
<br>
Will throw an exception if the given {@link File} is actually an existing file, or the directory is not writable
@param destination the directory which to ensure its existence for
@throws IOException if an I/O error occurs e.g. when attempting to create the destination directory
@throws IllegalArgumentException if the destination is an existing file, or the directory is not writable | [
"Makes",
"sure",
"that",
"the",
"given",
"{",
"@link",
"File",
"}",
"is",
"either",
"a",
"writable",
"directory",
"or",
"that",
"it",
"does",
"not",
"exist",
"and",
"a",
"directory",
"can",
"be",
"created",
"at",
"its",
"path",
".",
"<br",
">",
"Will",
"throw",
"an",
"exception",
"if",
"the",
"given",
"{",
"@link",
"File",
"}",
"is",
"actually",
"an",
"existing",
"file",
"or",
"the",
"directory",
"is",
"not",
"writable"
] | train | https://github.com/thrau/jarchivelib/blob/8afee5124c588f589306796985b722d63572bbfa/src/main/java/org/rauschig/jarchivelib/IOUtils.java#L117-L126 |
zxing/zxing | core/src/main/java/com/google/zxing/common/BitMatrix.java | BitMatrix.getRow | public BitArray getRow(int y, BitArray row) {
"""
A fast method to retrieve one row of data from the matrix as a BitArray.
@param y The row to retrieve
@param row An optional caller-allocated BitArray, will be allocated if null or too small
@return The resulting BitArray - this reference should always be used even when passing
your own row
"""
if (row == null || row.getSize() < width) {
row = new BitArray(width);
} else {
row.clear();
}
int offset = y * rowSize;
for (int x = 0; x < rowSize; x++) {
row.setBulk(x * 32, bits[offset + x]);
}
return row;
} | java | public BitArray getRow(int y, BitArray row) {
if (row == null || row.getSize() < width) {
row = new BitArray(width);
} else {
row.clear();
}
int offset = y * rowSize;
for (int x = 0; x < rowSize; x++) {
row.setBulk(x * 32, bits[offset + x]);
}
return row;
} | [
"public",
"BitArray",
"getRow",
"(",
"int",
"y",
",",
"BitArray",
"row",
")",
"{",
"if",
"(",
"row",
"==",
"null",
"||",
"row",
".",
"getSize",
"(",
")",
"<",
"width",
")",
"{",
"row",
"=",
"new",
"BitArray",
"(",
"width",
")",
";",
"}",
"else",
"{",
"row",
".",
"clear",
"(",
")",
";",
"}",
"int",
"offset",
"=",
"y",
"*",
"rowSize",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"rowSize",
";",
"x",
"++",
")",
"{",
"row",
".",
"setBulk",
"(",
"x",
"*",
"32",
",",
"bits",
"[",
"offset",
"+",
"x",
"]",
")",
";",
"}",
"return",
"row",
";",
"}"
] | A fast method to retrieve one row of data from the matrix as a BitArray.
@param y The row to retrieve
@param row An optional caller-allocated BitArray, will be allocated if null or too small
@return The resulting BitArray - this reference should always be used even when passing
your own row | [
"A",
"fast",
"method",
"to",
"retrieve",
"one",
"row",
"of",
"data",
"from",
"the",
"matrix",
"as",
"a",
"BitArray",
"."
] | train | https://github.com/zxing/zxing/blob/653ac2a3beb11481eff82e7d5f2bab8a745f7fac/core/src/main/java/com/google/zxing/common/BitMatrix.java#L259-L270 |
haraldk/TwelveMonkeys | imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTUtil.java | PICTUtil.readColorPattern | public static Pattern readColorPattern(final DataInput pStream) throws IOException {
"""
/*
http://developer.apple.com/DOCUMENTATION/mac/QuickDraw/QuickDraw-461.html#MARKER-9-243
IF patType = ditherPat
THEN
PatType: word; {pattern type = 2}
Pat1Data: Pattern; {old pattern data}
RGB: RGBColor; {desired RGB for pattern}
ELSE
PatType: word; {pattern type = 1}
Pat1Data: Pattern; {old pattern data}
PixMap: PixMap;
ColorTable: ColorTable;
PixData: PixData;
END;
"""
short type = pStream.readShort();
Pattern pattern;
Pattern fallback = readPattern(pStream);
if (type == 1) {
// TODO: This is foobar...
// PixMap
// ColorTable
// PixData
throw new IIOException(String.format("QuickDraw pattern type '0x%04x' not implemented (yet)", type));
}
else if (type == 2) {
Color color = readRGBColor(pStream);
pattern = new PixMapPattern(color, fallback);
}
else {
throw new IIOException(String.format("Unknown QuickDraw pattern type '0x%04x'", type));
}
return pattern;
} | java | public static Pattern readColorPattern(final DataInput pStream) throws IOException {
short type = pStream.readShort();
Pattern pattern;
Pattern fallback = readPattern(pStream);
if (type == 1) {
// TODO: This is foobar...
// PixMap
// ColorTable
// PixData
throw new IIOException(String.format("QuickDraw pattern type '0x%04x' not implemented (yet)", type));
}
else if (type == 2) {
Color color = readRGBColor(pStream);
pattern = new PixMapPattern(color, fallback);
}
else {
throw new IIOException(String.format("Unknown QuickDraw pattern type '0x%04x'", type));
}
return pattern;
} | [
"public",
"static",
"Pattern",
"readColorPattern",
"(",
"final",
"DataInput",
"pStream",
")",
"throws",
"IOException",
"{",
"short",
"type",
"=",
"pStream",
".",
"readShort",
"(",
")",
";",
"Pattern",
"pattern",
";",
"Pattern",
"fallback",
"=",
"readPattern",
"(",
"pStream",
")",
";",
"if",
"(",
"type",
"==",
"1",
")",
"{",
"// TODO: This is foobar...",
"// PixMap",
"// ColorTable",
"// PixData",
"throw",
"new",
"IIOException",
"(",
"String",
".",
"format",
"(",
"\"QuickDraw pattern type '0x%04x' not implemented (yet)\"",
",",
"type",
")",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"2",
")",
"{",
"Color",
"color",
"=",
"readRGBColor",
"(",
"pStream",
")",
";",
"pattern",
"=",
"new",
"PixMapPattern",
"(",
"color",
",",
"fallback",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IIOException",
"(",
"String",
".",
"format",
"(",
"\"Unknown QuickDraw pattern type '0x%04x'\"",
",",
"type",
")",
")",
";",
"}",
"return",
"pattern",
";",
"}"
] | /*
http://developer.apple.com/DOCUMENTATION/mac/QuickDraw/QuickDraw-461.html#MARKER-9-243
IF patType = ditherPat
THEN
PatType: word; {pattern type = 2}
Pat1Data: Pattern; {old pattern data}
RGB: RGBColor; {desired RGB for pattern}
ELSE
PatType: word; {pattern type = 1}
Pat1Data: Pattern; {old pattern data}
PixMap: PixMap;
ColorTable: ColorTable;
PixData: PixData;
END; | [
"/",
"*",
"http",
":",
"//",
"developer",
".",
"apple",
".",
"com",
"/",
"DOCUMENTATION",
"/",
"mac",
"/",
"QuickDraw",
"/",
"QuickDraw",
"-",
"461",
".",
"html#MARKER",
"-",
"9",
"-",
"243",
"IF",
"patType",
"=",
"ditherPat",
"THEN",
"PatType",
":",
"word",
";",
"{",
"pattern",
"type",
"=",
"2",
"}",
"Pat1Data",
":",
"Pattern",
";",
"{",
"old",
"pattern",
"data",
"}",
"RGB",
":",
"RGBColor",
";",
"{",
"desired",
"RGB",
"for",
"pattern",
"}",
"ELSE",
"PatType",
":",
"word",
";",
"{",
"pattern",
"type",
"=",
"1",
"}",
"Pat1Data",
":",
"Pattern",
";",
"{",
"old",
"pattern",
"data",
"}",
"PixMap",
":",
"PixMap",
";",
"ColorTable",
":",
"ColorTable",
";",
"PixData",
":",
"PixData",
";",
"END",
";"
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTUtil.java#L182-L204 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/painter/util/ShapeGenerator.java | ShapeGenerator.createArrowLeft | public Shape createArrowLeft(final double x, final double y, final double w, final double h) {
"""
Return a path for an arrow pointing to the left.
@param x the X coordinate of the upper-left corner of the arrow
@param y the Y coordinate of the upper-left corner of the arrow
@param w the width of the arrow
@param h the height of the arrow
@return a path representing the shape.
"""
path.reset();
path.moveTo(x + w, y);
path.lineTo(x, y + h / 2.0);
path.lineTo(x + w, y + h);
path.closePath();
return path;
} | java | public Shape createArrowLeft(final double x, final double y, final double w, final double h) {
path.reset();
path.moveTo(x + w, y);
path.lineTo(x, y + h / 2.0);
path.lineTo(x + w, y + h);
path.closePath();
return path;
} | [
"public",
"Shape",
"createArrowLeft",
"(",
"final",
"double",
"x",
",",
"final",
"double",
"y",
",",
"final",
"double",
"w",
",",
"final",
"double",
"h",
")",
"{",
"path",
".",
"reset",
"(",
")",
";",
"path",
".",
"moveTo",
"(",
"x",
"+",
"w",
",",
"y",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
",",
"y",
"+",
"h",
"/",
"2.0",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"w",
",",
"y",
"+",
"h",
")",
";",
"path",
".",
"closePath",
"(",
")",
";",
"return",
"path",
";",
"}"
] | Return a path for an arrow pointing to the left.
@param x the X coordinate of the upper-left corner of the arrow
@param y the Y coordinate of the upper-left corner of the arrow
@param w the width of the arrow
@param h the height of the arrow
@return a path representing the shape. | [
"Return",
"a",
"path",
"for",
"an",
"arrow",
"pointing",
"to",
"the",
"left",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/util/ShapeGenerator.java#L304-L312 |
jboss/jboss-ejb-api_spec | src/main/java/javax/ejb/embeddable/EJBContainer.java | EJBContainer.createEJBContainer | public static EJBContainer createEJBContainer(Map<?, ?> properties)
throws EJBException {
"""
Create and initialize an embeddable EJB container with an
set of configuration properties and names of modules to be initialized.
@param properties One or more spec-defined or vendor-specific properties.
The spec reserves the prefix "javax.ejb." for spec-defined properties.
@return EJBContainer instance
@throws EJBException Thrown if the container or application could not
be successfully initialized.
"""
for(EJBContainerProvider factory : factories)
{
EJBContainer container = factory.createEJBContainer(properties);
if(container != null)
return container;
}
throw new EJBException("Unable to instantiate container with factories " + factories);
} | java | public static EJBContainer createEJBContainer(Map<?, ?> properties)
throws EJBException
{
for(EJBContainerProvider factory : factories)
{
EJBContainer container = factory.createEJBContainer(properties);
if(container != null)
return container;
}
throw new EJBException("Unable to instantiate container with factories " + factories);
} | [
"public",
"static",
"EJBContainer",
"createEJBContainer",
"(",
"Map",
"<",
"?",
",",
"?",
">",
"properties",
")",
"throws",
"EJBException",
"{",
"for",
"(",
"EJBContainerProvider",
"factory",
":",
"factories",
")",
"{",
"EJBContainer",
"container",
"=",
"factory",
".",
"createEJBContainer",
"(",
"properties",
")",
";",
"if",
"(",
"container",
"!=",
"null",
")",
"return",
"container",
";",
"}",
"throw",
"new",
"EJBException",
"(",
"\"Unable to instantiate container with factories \"",
"+",
"factories",
")",
";",
"}"
] | Create and initialize an embeddable EJB container with an
set of configuration properties and names of modules to be initialized.
@param properties One or more spec-defined or vendor-specific properties.
The spec reserves the prefix "javax.ejb." for spec-defined properties.
@return EJBContainer instance
@throws EJBException Thrown if the container or application could not
be successfully initialized. | [
"Create",
"and",
"initialize",
"an",
"embeddable",
"EJB",
"container",
"with",
"an",
"set",
"of",
"configuration",
"properties",
"and",
"names",
"of",
"modules",
"to",
"be",
"initialized",
"."
] | train | https://github.com/jboss/jboss-ejb-api_spec/blob/2efa693ed40cdfcf43bbd6cecbaf49039170bc3b/src/main/java/javax/ejb/embeddable/EJBContainer.java#L72-L82 |
alkacon/opencms-core | src/org/opencms/ui/A_CmsUI.java | A_CmsUI.openPageOrWarn | public void openPageOrWarn(String link, String target) {
"""
Tries to open a new browser window, and shows a warning if opening the window fails (usually because of popup blockers).<p>
@param link the URL to open in the new window
@param target the target window name
"""
openPageOrWarn(link, target, CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_POPUP_BLOCKED_0));
} | java | public void openPageOrWarn(String link, String target) {
openPageOrWarn(link, target, CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_POPUP_BLOCKED_0));
} | [
"public",
"void",
"openPageOrWarn",
"(",
"String",
"link",
",",
"String",
"target",
")",
"{",
"openPageOrWarn",
"(",
"link",
",",
"target",
",",
"CmsVaadinUtils",
".",
"getMessageText",
"(",
"org",
".",
"opencms",
".",
"ui",
".",
"Messages",
".",
"GUI_POPUP_BLOCKED_0",
")",
")",
";",
"}"
] | Tries to open a new browser window, and shows a warning if opening the window fails (usually because of popup blockers).<p>
@param link the URL to open in the new window
@param target the target window name | [
"Tries",
"to",
"open",
"a",
"new",
"browser",
"window",
"and",
"shows",
"a",
"warning",
"if",
"opening",
"the",
"window",
"fails",
"(",
"usually",
"because",
"of",
"popup",
"blockers",
")",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/A_CmsUI.java#L230-L233 |
loldevs/riotapi | rtmp/src/main/java/net/boreeas/riotapi/rtmp/services/SummonerTeamService.java | SummonerTeamService.kickPlayer | public Team kickPlayer(long summonerId, TeamId teamId) {
"""
Kick a player from the target team
@param summonerId The id of the player
@param teamId The id of the team
@return The new team state
"""
return client.sendRpcAndWait(SERVICE, "kickPlayer", summonerId, teamId);
} | java | public Team kickPlayer(long summonerId, TeamId teamId) {
return client.sendRpcAndWait(SERVICE, "kickPlayer", summonerId, teamId);
} | [
"public",
"Team",
"kickPlayer",
"(",
"long",
"summonerId",
",",
"TeamId",
"teamId",
")",
"{",
"return",
"client",
".",
"sendRpcAndWait",
"(",
"SERVICE",
",",
"\"kickPlayer\"",
",",
"summonerId",
",",
"teamId",
")",
";",
"}"
] | Kick a player from the target team
@param summonerId The id of the player
@param teamId The id of the team
@return The new team state | [
"Kick",
"a",
"player",
"from",
"the",
"target",
"team"
] | train | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/rtmp/src/main/java/net/boreeas/riotapi/rtmp/services/SummonerTeamService.java#L115-L117 |
kotcrab/vis-ui | ui/src/main/java/com/kotcrab/vis/ui/util/dialog/Dialogs.java | Dialogs.showOptionDialog | public static OptionDialog showOptionDialog (Stage stage, String title, String text, OptionDialogType type, OptionDialogListener listener) {
"""
Dialog with text and buttons like Yes, No, Cancel.
@param title dialog title
@param type specifies what types of buttons will this dialog have
@param listener dialog buttons listener.
@return dialog for the purpose of changing buttons text.
@see OptionDialog
@since 0.6.0
"""
OptionDialog dialog = new OptionDialog(title, text, type, listener);
stage.addActor(dialog.fadeIn());
return dialog;
} | java | public static OptionDialog showOptionDialog (Stage stage, String title, String text, OptionDialogType type, OptionDialogListener listener) {
OptionDialog dialog = new OptionDialog(title, text, type, listener);
stage.addActor(dialog.fadeIn());
return dialog;
} | [
"public",
"static",
"OptionDialog",
"showOptionDialog",
"(",
"Stage",
"stage",
",",
"String",
"title",
",",
"String",
"text",
",",
"OptionDialogType",
"type",
",",
"OptionDialogListener",
"listener",
")",
"{",
"OptionDialog",
"dialog",
"=",
"new",
"OptionDialog",
"(",
"title",
",",
"text",
",",
"type",
",",
"listener",
")",
";",
"stage",
".",
"addActor",
"(",
"dialog",
".",
"fadeIn",
"(",
")",
")",
";",
"return",
"dialog",
";",
"}"
] | Dialog with text and buttons like Yes, No, Cancel.
@param title dialog title
@param type specifies what types of buttons will this dialog have
@param listener dialog buttons listener.
@return dialog for the purpose of changing buttons text.
@see OptionDialog
@since 0.6.0 | [
"Dialog",
"with",
"text",
"and",
"buttons",
"like",
"Yes",
"No",
"Cancel",
"."
] | train | https://github.com/kotcrab/vis-ui/blob/3b68f82d94ae32bffa2a3399c63f432e0f4908e0/ui/src/main/java/com/kotcrab/vis/ui/util/dialog/Dialogs.java#L83-L87 |
languagetool-org/languagetool | languagetool-core/src/main/java/org/languagetool/rules/patterns/PatternRuleMatcher.java | PatternRuleMatcher.matchPreservesCase | private boolean matchPreservesCase(List<Match> suggestionMatches, String msg) {
"""
Checks if the suggestion starts with a match that is supposed to preserve
case. If it does not, perform the default conversion to uppercase.
@return true, if the match preserves the case of the token.
"""
if (suggestionMatches != null && !suggestionMatches.isEmpty()) {
//PatternRule rule = (PatternRule) this.rule;
int sugStart = msg.indexOf(SUGGESTION_START_TAG) + SUGGESTION_START_TAG.length();
for (Match sMatch : suggestionMatches) {
if (!sMatch.isInMessageOnly() && sMatch.convertsCase()
&& msg.charAt(sugStart) == '\\') {
return false;
}
}
}
return true;
} | java | private boolean matchPreservesCase(List<Match> suggestionMatches, String msg) {
if (suggestionMatches != null && !suggestionMatches.isEmpty()) {
//PatternRule rule = (PatternRule) this.rule;
int sugStart = msg.indexOf(SUGGESTION_START_TAG) + SUGGESTION_START_TAG.length();
for (Match sMatch : suggestionMatches) {
if (!sMatch.isInMessageOnly() && sMatch.convertsCase()
&& msg.charAt(sugStart) == '\\') {
return false;
}
}
}
return true;
} | [
"private",
"boolean",
"matchPreservesCase",
"(",
"List",
"<",
"Match",
">",
"suggestionMatches",
",",
"String",
"msg",
")",
"{",
"if",
"(",
"suggestionMatches",
"!=",
"null",
"&&",
"!",
"suggestionMatches",
".",
"isEmpty",
"(",
")",
")",
"{",
"//PatternRule rule = (PatternRule) this.rule;",
"int",
"sugStart",
"=",
"msg",
".",
"indexOf",
"(",
"SUGGESTION_START_TAG",
")",
"+",
"SUGGESTION_START_TAG",
".",
"length",
"(",
")",
";",
"for",
"(",
"Match",
"sMatch",
":",
"suggestionMatches",
")",
"{",
"if",
"(",
"!",
"sMatch",
".",
"isInMessageOnly",
"(",
")",
"&&",
"sMatch",
".",
"convertsCase",
"(",
")",
"&&",
"msg",
".",
"charAt",
"(",
"sugStart",
")",
"==",
"'",
"'",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks if the suggestion starts with a match that is supposed to preserve
case. If it does not, perform the default conversion to uppercase.
@return true, if the match preserves the case of the token. | [
"Checks",
"if",
"the",
"suggestion",
"starts",
"with",
"a",
"match",
"that",
"is",
"supposed",
"to",
"preserve",
"case",
".",
"If",
"it",
"does",
"not",
"perform",
"the",
"default",
"conversion",
"to",
"uppercase",
"."
] | train | https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/rules/patterns/PatternRuleMatcher.java#L261-L273 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java | ApiOvhDedicatedserver.serviceName_statistics_raid_unit_volume_volume_GET | public OvhRtmRaidVolume serviceName_statistics_raid_unit_volume_volume_GET(String serviceName, String unit, String volume) throws IOException {
"""
Get this object properties
REST: GET /dedicated/server/{serviceName}/statistics/raid/{unit}/volume/{volume}
@param serviceName [required] The internal name of your dedicated server
@param unit [required] Raid unit
@param volume [required] Raid volume name
"""
String qPath = "/dedicated/server/{serviceName}/statistics/raid/{unit}/volume/{volume}";
StringBuilder sb = path(qPath, serviceName, unit, volume);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhRtmRaidVolume.class);
} | java | public OvhRtmRaidVolume serviceName_statistics_raid_unit_volume_volume_GET(String serviceName, String unit, String volume) throws IOException {
String qPath = "/dedicated/server/{serviceName}/statistics/raid/{unit}/volume/{volume}";
StringBuilder sb = path(qPath, serviceName, unit, volume);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhRtmRaidVolume.class);
} | [
"public",
"OvhRtmRaidVolume",
"serviceName_statistics_raid_unit_volume_volume_GET",
"(",
"String",
"serviceName",
",",
"String",
"unit",
",",
"String",
"volume",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicated/server/{serviceName}/statistics/raid/{unit}/volume/{volume}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"unit",
",",
"volume",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhRtmRaidVolume",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /dedicated/server/{serviceName}/statistics/raid/{unit}/volume/{volume}
@param serviceName [required] The internal name of your dedicated server
@param unit [required] Raid unit
@param volume [required] Raid volume name | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java#L1401-L1406 |
kite-sdk/kite | kite-data/kite-data-core/src/main/java/org/kitesdk/data/spi/DataModelUtil.java | DataModelUtil.createRecord | @SuppressWarnings("unchecked")
public static <E> E createRecord(Class<E> type, Schema schema) {
"""
If E implements GenericRecord, but does not implement SpecificRecord, then
create a new instance of E using reflection so that GenericDataumReader
will use the expected type.
Implementations of GenericRecord that require a {@link Schema} parameter
in the constructor should implement SpecificData.SchemaConstructable.
Otherwise, your implementation must have a no-args constructor.
@param <E> The entity type
@param type The Java class of the entity type
@param schema The reader schema
@return An instance of E, or null if the data model is specific or reflect
"""
// Don't instantiate SpecificRecords or interfaces.
if (isGeneric(type) && !type.isInterface()) {
if (GenericData.Record.class.equals(type)) {
return (E) GenericData.get().newRecord(null, schema);
}
return (E) ReflectData.newInstance(type, schema);
}
return null;
} | java | @SuppressWarnings("unchecked")
public static <E> E createRecord(Class<E> type, Schema schema) {
// Don't instantiate SpecificRecords or interfaces.
if (isGeneric(type) && !type.isInterface()) {
if (GenericData.Record.class.equals(type)) {
return (E) GenericData.get().newRecord(null, schema);
}
return (E) ReflectData.newInstance(type, schema);
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"E",
">",
"E",
"createRecord",
"(",
"Class",
"<",
"E",
">",
"type",
",",
"Schema",
"schema",
")",
"{",
"// Don't instantiate SpecificRecords or interfaces.",
"if",
"(",
"isGeneric",
"(",
"type",
")",
"&&",
"!",
"type",
".",
"isInterface",
"(",
")",
")",
"{",
"if",
"(",
"GenericData",
".",
"Record",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"(",
"E",
")",
"GenericData",
".",
"get",
"(",
")",
".",
"newRecord",
"(",
"null",
",",
"schema",
")",
";",
"}",
"return",
"(",
"E",
")",
"ReflectData",
".",
"newInstance",
"(",
"type",
",",
"schema",
")",
";",
"}",
"return",
"null",
";",
"}"
] | If E implements GenericRecord, but does not implement SpecificRecord, then
create a new instance of E using reflection so that GenericDataumReader
will use the expected type.
Implementations of GenericRecord that require a {@link Schema} parameter
in the constructor should implement SpecificData.SchemaConstructable.
Otherwise, your implementation must have a no-args constructor.
@param <E> The entity type
@param type The Java class of the entity type
@param schema The reader schema
@return An instance of E, or null if the data model is specific or reflect | [
"If",
"E",
"implements",
"GenericRecord",
"but",
"does",
"not",
"implement",
"SpecificRecord",
"then",
"create",
"a",
"new",
"instance",
"of",
"E",
"using",
"reflection",
"so",
"that",
"GenericDataumReader",
"will",
"use",
"the",
"expected",
"type",
"."
] | train | https://github.com/kite-sdk/kite/blob/72bfb4b1a881af85808cd7f14bc3e15160a1e811/kite-data/kite-data-core/src/main/java/org/kitesdk/data/spi/DataModelUtil.java#L221-L232 |
Berico-Technologies/CLAVIN | src/main/java/com/bericotech/clavin/GeoParserFactory.java | GeoParserFactory.getDefault | public static GeoParser getDefault(String pathToLuceneIndex, LocationExtractor extractor, int maxHitDepth,
int maxContentWindow, boolean fuzzy) throws ClavinException {
"""
Get a GeoParser with defined values for maxHitDepth and
maxContentWindow, fuzzy matching explicitly turned on or off,
and a specific LocationExtractor to use.
@param pathToLuceneIndex Path to the local Lucene index.
@param extractor A specific implementation of LocationExtractor to be used
@param maxHitDepth Number of candidate matches to consider
@param maxContentWindow How much context to consider when resolving
@param fuzzy Should fuzzy matching be used?
@return GeoParser
@throws ClavinException If the index cannot be created.
"""
// instantiate new LuceneGazetteer
Gazetteer gazetteer = new LuceneGazetteer(new File(pathToLuceneIndex));
return new GeoParser(extractor, gazetteer, maxHitDepth, maxContentWindow, fuzzy);
} | java | public static GeoParser getDefault(String pathToLuceneIndex, LocationExtractor extractor, int maxHitDepth,
int maxContentWindow, boolean fuzzy) throws ClavinException {
// instantiate new LuceneGazetteer
Gazetteer gazetteer = new LuceneGazetteer(new File(pathToLuceneIndex));
return new GeoParser(extractor, gazetteer, maxHitDepth, maxContentWindow, fuzzy);
} | [
"public",
"static",
"GeoParser",
"getDefault",
"(",
"String",
"pathToLuceneIndex",
",",
"LocationExtractor",
"extractor",
",",
"int",
"maxHitDepth",
",",
"int",
"maxContentWindow",
",",
"boolean",
"fuzzy",
")",
"throws",
"ClavinException",
"{",
"// instantiate new LuceneGazetteer",
"Gazetteer",
"gazetteer",
"=",
"new",
"LuceneGazetteer",
"(",
"new",
"File",
"(",
"pathToLuceneIndex",
")",
")",
";",
"return",
"new",
"GeoParser",
"(",
"extractor",
",",
"gazetteer",
",",
"maxHitDepth",
",",
"maxContentWindow",
",",
"fuzzy",
")",
";",
"}"
] | Get a GeoParser with defined values for maxHitDepth and
maxContentWindow, fuzzy matching explicitly turned on or off,
and a specific LocationExtractor to use.
@param pathToLuceneIndex Path to the local Lucene index.
@param extractor A specific implementation of LocationExtractor to be used
@param maxHitDepth Number of candidate matches to consider
@param maxContentWindow How much context to consider when resolving
@param fuzzy Should fuzzy matching be used?
@return GeoParser
@throws ClavinException If the index cannot be created. | [
"Get",
"a",
"GeoParser",
"with",
"defined",
"values",
"for",
"maxHitDepth",
"and",
"maxContentWindow",
"fuzzy",
"matching",
"explicitly",
"turned",
"on",
"or",
"off",
"and",
"a",
"specific",
"LocationExtractor",
"to",
"use",
"."
] | train | https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/GeoParserFactory.java#L118-L123 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/coll/BOCSU.java | BOCSU.writeIdenticalLevelRun | public static int writeIdenticalLevelRun(int prev, CharSequence s, int i, int length, ByteArrayWrapper sink) {
"""
Encode the code points of a string as
a sequence of byte-encoded differences (slope detection),
preserving lexical order.
<p>Optimize the difference-taking for runs of Unicode text within
small scripts:
<p>Most small scripts are allocated within aligned 128-blocks of Unicode
code points. Lexical order is preserved if "prev" is always moved
into the middle of such a block.
<p>Additionally, "prev" is moved from anywhere in the Unihan
area into the middle of that area.
Note that the identical-level run in a sort key is generated from
NFD text - there are never Hangul characters included.
"""
while (i < length) {
// We must have capacity>=SLOPE_MAX_BYTES in case writeDiff() writes that much,
// but we do not want to force the sink to allocate
// for a large min_capacity because we might actually only write one byte.
ensureAppendCapacity(sink, 16, s.length() * 2);
byte[] buffer = sink.bytes;
int capacity = buffer.length;
int p = sink.size;
int lastSafe = capacity - SLOPE_MAX_BYTES_;
while (i < length && p <= lastSafe) {
if (prev < 0x4e00 || prev >= 0xa000) {
prev = (prev & ~0x7f) - SLOPE_REACH_NEG_1_;
} else {
// Unihan U+4e00..U+9fa5:
// double-bytes down from the upper end
prev = 0x9fff - SLOPE_REACH_POS_2_;
}
int c = Character.codePointAt(s, i);
i += Character.charCount(c);
if (c == 0xfffe) {
buffer[p++] = 2; // merge separator
prev = 0;
} else {
p = writeDiff(c - prev, buffer, p);
prev = c;
}
}
sink.size = p;
}
return prev;
} | java | public static int writeIdenticalLevelRun(int prev, CharSequence s, int i, int length, ByteArrayWrapper sink) {
while (i < length) {
// We must have capacity>=SLOPE_MAX_BYTES in case writeDiff() writes that much,
// but we do not want to force the sink to allocate
// for a large min_capacity because we might actually only write one byte.
ensureAppendCapacity(sink, 16, s.length() * 2);
byte[] buffer = sink.bytes;
int capacity = buffer.length;
int p = sink.size;
int lastSafe = capacity - SLOPE_MAX_BYTES_;
while (i < length && p <= lastSafe) {
if (prev < 0x4e00 || prev >= 0xa000) {
prev = (prev & ~0x7f) - SLOPE_REACH_NEG_1_;
} else {
// Unihan U+4e00..U+9fa5:
// double-bytes down from the upper end
prev = 0x9fff - SLOPE_REACH_POS_2_;
}
int c = Character.codePointAt(s, i);
i += Character.charCount(c);
if (c == 0xfffe) {
buffer[p++] = 2; // merge separator
prev = 0;
} else {
p = writeDiff(c - prev, buffer, p);
prev = c;
}
}
sink.size = p;
}
return prev;
} | [
"public",
"static",
"int",
"writeIdenticalLevelRun",
"(",
"int",
"prev",
",",
"CharSequence",
"s",
",",
"int",
"i",
",",
"int",
"length",
",",
"ByteArrayWrapper",
"sink",
")",
"{",
"while",
"(",
"i",
"<",
"length",
")",
"{",
"// We must have capacity>=SLOPE_MAX_BYTES in case writeDiff() writes that much,",
"// but we do not want to force the sink to allocate",
"// for a large min_capacity because we might actually only write one byte.",
"ensureAppendCapacity",
"(",
"sink",
",",
"16",
",",
"s",
".",
"length",
"(",
")",
"*",
"2",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"sink",
".",
"bytes",
";",
"int",
"capacity",
"=",
"buffer",
".",
"length",
";",
"int",
"p",
"=",
"sink",
".",
"size",
";",
"int",
"lastSafe",
"=",
"capacity",
"-",
"SLOPE_MAX_BYTES_",
";",
"while",
"(",
"i",
"<",
"length",
"&&",
"p",
"<=",
"lastSafe",
")",
"{",
"if",
"(",
"prev",
"<",
"0x4e00",
"||",
"prev",
">=",
"0xa000",
")",
"{",
"prev",
"=",
"(",
"prev",
"&",
"~",
"0x7f",
")",
"-",
"SLOPE_REACH_NEG_1_",
";",
"}",
"else",
"{",
"// Unihan U+4e00..U+9fa5:",
"// double-bytes down from the upper end",
"prev",
"=",
"0x9fff",
"-",
"SLOPE_REACH_POS_2_",
";",
"}",
"int",
"c",
"=",
"Character",
".",
"codePointAt",
"(",
"s",
",",
"i",
")",
";",
"i",
"+=",
"Character",
".",
"charCount",
"(",
"c",
")",
";",
"if",
"(",
"c",
"==",
"0xfffe",
")",
"{",
"buffer",
"[",
"p",
"++",
"]",
"=",
"2",
";",
"// merge separator",
"prev",
"=",
"0",
";",
"}",
"else",
"{",
"p",
"=",
"writeDiff",
"(",
"c",
"-",
"prev",
",",
"buffer",
",",
"p",
")",
";",
"prev",
"=",
"c",
";",
"}",
"}",
"sink",
".",
"size",
"=",
"p",
";",
"}",
"return",
"prev",
";",
"}"
] | Encode the code points of a string as
a sequence of byte-encoded differences (slope detection),
preserving lexical order.
<p>Optimize the difference-taking for runs of Unicode text within
small scripts:
<p>Most small scripts are allocated within aligned 128-blocks of Unicode
code points. Lexical order is preserved if "prev" is always moved
into the middle of such a block.
<p>Additionally, "prev" is moved from anywhere in the Unihan
area into the middle of that area.
Note that the identical-level run in a sort key is generated from
NFD text - there are never Hangul characters included. | [
"Encode",
"the",
"code",
"points",
"of",
"a",
"string",
"as",
"a",
"sequence",
"of",
"byte",
"-",
"encoded",
"differences",
"(",
"slope",
"detection",
")",
"preserving",
"lexical",
"order",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/coll/BOCSU.java#L103-L135 |
pressgang-ccms/PressGangCCMSCommonUtilities | src/main/java/org/jboss/pressgang/ccms/utils/common/ResourceUtilities.java | ResourceUtilities.resourceFileToXMLDocument | public static Document resourceFileToXMLDocument(final String location, final String fileName) {
"""
Reads a resource file and converts it into a XML based Document object.
@param location The location of the resource file.
@param fileName The name of the file.
@return The Document that represents the contents of the file or null if an error occurred.
"""
if (location == null || fileName == null) return null;
final InputStream in = ResourceUtilities.class.getResourceAsStream(location + fileName);
if (in == null) return null;
final DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder dBuilder;
Document doc = null;
try {
dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(in);
} catch (Exception e) {
LOG.error("Failed to parse the resource as XML.", e);
} finally {
try {
in.close();
} catch (IOException e) {
LOG.error("Failed to close the InputStream", e);
}
}
return doc;
} | java | public static Document resourceFileToXMLDocument(final String location, final String fileName) {
if (location == null || fileName == null) return null;
final InputStream in = ResourceUtilities.class.getResourceAsStream(location + fileName);
if (in == null) return null;
final DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder dBuilder;
Document doc = null;
try {
dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(in);
} catch (Exception e) {
LOG.error("Failed to parse the resource as XML.", e);
} finally {
try {
in.close();
} catch (IOException e) {
LOG.error("Failed to close the InputStream", e);
}
}
return doc;
} | [
"public",
"static",
"Document",
"resourceFileToXMLDocument",
"(",
"final",
"String",
"location",
",",
"final",
"String",
"fileName",
")",
"{",
"if",
"(",
"location",
"==",
"null",
"||",
"fileName",
"==",
"null",
")",
"return",
"null",
";",
"final",
"InputStream",
"in",
"=",
"ResourceUtilities",
".",
"class",
".",
"getResourceAsStream",
"(",
"location",
"+",
"fileName",
")",
";",
"if",
"(",
"in",
"==",
"null",
")",
"return",
"null",
";",
"final",
"DocumentBuilderFactory",
"dbFactory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"final",
"DocumentBuilder",
"dBuilder",
";",
"Document",
"doc",
"=",
"null",
";",
"try",
"{",
"dBuilder",
"=",
"dbFactory",
".",
"newDocumentBuilder",
"(",
")",
";",
"doc",
"=",
"dBuilder",
".",
"parse",
"(",
"in",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to parse the resource as XML.\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to close the InputStream\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"doc",
";",
"}"
] | Reads a resource file and converts it into a XML based Document object.
@param location The location of the resource file.
@param fileName The name of the file.
@return The Document that represents the contents of the file or null if an error occurred. | [
"Reads",
"a",
"resource",
"file",
"and",
"converts",
"it",
"into",
"a",
"XML",
"based",
"Document",
"object",
"."
] | train | https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/ResourceUtilities.java#L84-L106 |
unbescape/unbescape | src/main/java/org/unbescape/csv/CsvEscape.java | CsvEscape.escapeCsv | public static void escapeCsv(final Reader reader, final Writer writer)
throws IOException {
"""
<p>
Perform a CSV <strong>escape</strong> operation on a <tt>Reader</tt> input, writing results to
a <tt>Writer</tt>.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param reader the <tt>Reader</tt> reading the text to be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@throws IOException if an input/output exception occurs
@since 1.1.2
"""
if (writer == null) {
throw new IllegalArgumentException("Argument 'writer' cannot be null");
}
CsvEscapeUtil.escape(reader, writer);
} | java | public static void escapeCsv(final Reader reader, final Writer writer)
throws IOException {
if (writer == null) {
throw new IllegalArgumentException("Argument 'writer' cannot be null");
}
CsvEscapeUtil.escape(reader, writer);
} | [
"public",
"static",
"void",
"escapeCsv",
"(",
"final",
"Reader",
"reader",
",",
"final",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"if",
"(",
"writer",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument 'writer' cannot be null\"",
")",
";",
"}",
"CsvEscapeUtil",
".",
"escape",
"(",
"reader",
",",
"writer",
")",
";",
"}"
] | <p>
Perform a CSV <strong>escape</strong> operation on a <tt>Reader</tt> input, writing results to
a <tt>Writer</tt>.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param reader the <tt>Reader</tt> reading the text to be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@throws IOException if an input/output exception occurs
@since 1.1.2 | [
"<p",
">",
"Perform",
"a",
"CSV",
"<strong",
">",
"escape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"Reader<",
"/",
"tt",
">",
"input",
"writing",
"results",
"to",
"a",
"<tt",
">",
"Writer<",
"/",
"tt",
">",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"is",
"<strong",
">",
"thread",
"-",
"safe<",
"/",
"strong",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/csv/CsvEscape.java#L184-L192 |
haraldk/TwelveMonkeys | sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/TypedMap.java | TypedMap.put | public V put(K pKey, V pValue) {
"""
Associates the specified value with the specified key in this map.
If the map previously contained a mapping for
the key, the old value is replaced.
@param pKey key with which the specified value is to be associated.
@param pValue value to be associated with the specified key.
@return previous value associated with specified key, or {@code null}
if there was no mapping for key. A {@code null} return can
also indicate that the map previously associated {@code null}
with the specified pKey, if the implementation supports
{@code null} values.
@throws IllegalArgumentException if the value is not compatible with the
key.
@see TypedMap.Key
"""
if (!pKey.isCompatibleValue(pValue)) {
throw new IllegalArgumentException("incompatible value for key");
}
return entries.put(pKey, pValue);
} | java | public V put(K pKey, V pValue) {
if (!pKey.isCompatibleValue(pValue)) {
throw new IllegalArgumentException("incompatible value for key");
}
return entries.put(pKey, pValue);
} | [
"public",
"V",
"put",
"(",
"K",
"pKey",
",",
"V",
"pValue",
")",
"{",
"if",
"(",
"!",
"pKey",
".",
"isCompatibleValue",
"(",
"pValue",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"incompatible value for key\"",
")",
";",
"}",
"return",
"entries",
".",
"put",
"(",
"pKey",
",",
"pValue",
")",
";",
"}"
] | Associates the specified value with the specified key in this map.
If the map previously contained a mapping for
the key, the old value is replaced.
@param pKey key with which the specified value is to be associated.
@param pValue value to be associated with the specified key.
@return previous value associated with specified key, or {@code null}
if there was no mapping for key. A {@code null} return can
also indicate that the map previously associated {@code null}
with the specified pKey, if the implementation supports
{@code null} values.
@throws IllegalArgumentException if the value is not compatible with the
key.
@see TypedMap.Key | [
"Associates",
"the",
"specified",
"value",
"with",
"the",
"specified",
"key",
"in",
"this",
"map",
".",
"If",
"the",
"map",
"previously",
"contained",
"a",
"mapping",
"for",
"the",
"key",
"the",
"old",
"value",
"is",
"replaced",
"."
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/TypedMap.java#L202-L207 |
authlete/authlete-java-common | src/main/java/com/authlete/common/web/URLCoder.java | URLCoder.formUrlEncode | public static String formUrlEncode(Map<String, ?> parameters) {
"""
Convert the given map to a string in {@code x-www-form-urlencoded} format.
@param parameters
Pairs of key and values. The type of values must be either
{@code String[]} or {@code List<String>}.
@return
A string in {@code x-www-form-urlencoded} format.
{@code null} is returned if {@code parameters} is {@code null}.
@since 1.24
"""
if (parameters == null)
{
return null;
}
StringBuilder sb = new StringBuilder();
// For each key-values pair.
for (Map.Entry<String, ?> entry : parameters.entrySet())
{
String key = entry.getKey();
Object values = entry.getValue();
if (values instanceof List)
{
List<?> list = (List<?>)values;
values = list.toArray(new String[list.size()]);
}
appendParameters(sb, key, (String[])values);
}
if (sb.length() != 0)
{
// Drop the last &.
sb.setLength(sb.length() - 1);
}
return sb.toString();
} | java | public static String formUrlEncode(Map<String, ?> parameters)
{
if (parameters == null)
{
return null;
}
StringBuilder sb = new StringBuilder();
// For each key-values pair.
for (Map.Entry<String, ?> entry : parameters.entrySet())
{
String key = entry.getKey();
Object values = entry.getValue();
if (values instanceof List)
{
List<?> list = (List<?>)values;
values = list.toArray(new String[list.size()]);
}
appendParameters(sb, key, (String[])values);
}
if (sb.length() != 0)
{
// Drop the last &.
sb.setLength(sb.length() - 1);
}
return sb.toString();
} | [
"public",
"static",
"String",
"formUrlEncode",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"parameters",
")",
"{",
"if",
"(",
"parameters",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"// For each key-values pair.\r",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"?",
">",
"entry",
":",
"parameters",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"Object",
"values",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"values",
"instanceof",
"List",
")",
"{",
"List",
"<",
"?",
">",
"list",
"=",
"(",
"List",
"<",
"?",
">",
")",
"values",
";",
"values",
"=",
"list",
".",
"toArray",
"(",
"new",
"String",
"[",
"list",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"appendParameters",
"(",
"sb",
",",
"key",
",",
"(",
"String",
"[",
"]",
")",
"values",
")",
";",
"}",
"if",
"(",
"sb",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"// Drop the last &.\r",
"sb",
".",
"setLength",
"(",
"sb",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Convert the given map to a string in {@code x-www-form-urlencoded} format.
@param parameters
Pairs of key and values. The type of values must be either
{@code String[]} or {@code List<String>}.
@return
A string in {@code x-www-form-urlencoded} format.
{@code null} is returned if {@code parameters} is {@code null}.
@since 1.24 | [
"Convert",
"the",
"given",
"map",
"to",
"a",
"string",
"in",
"{",
"@code",
"x",
"-",
"www",
"-",
"form",
"-",
"urlencoded",
"}",
"format",
"."
] | train | https://github.com/authlete/authlete-java-common/blob/49c94c483713cbf5a04d805ff7dbd83766c9c964/src/main/java/com/authlete/common/web/URLCoder.java#L92-L123 |
strator-dev/greenpepper-open | extensions-external/php/src/main/java/com/greenpepper/phpsud/fixtures/PHPFixture.java | PHPFixture.findMethod | public static PHPMethodDescriptor findMethod(PHPClassDescriptor desc, String methodName) {
"""
<p>findMethod.</p>
@param desc a {@link com.greenpepper.phpsud.container.PHPClassDescriptor} object.
@param methodName a {@link java.lang.String} object.
@return a {@link com.greenpepper.phpsud.container.PHPMethodDescriptor} object.
"""
PHPMethodDescriptor meth;
meth = desc.getMethod(Helper.formatProcedureName(methodName));
if (meth != null) {
return meth;
}
meth = desc.getMethod("get" + Helper.formatProcedureName(methodName));
if (meth != null) {
return meth;
}
return null;
} | java | public static PHPMethodDescriptor findMethod(PHPClassDescriptor desc, String methodName) {
PHPMethodDescriptor meth;
meth = desc.getMethod(Helper.formatProcedureName(methodName));
if (meth != null) {
return meth;
}
meth = desc.getMethod("get" + Helper.formatProcedureName(methodName));
if (meth != null) {
return meth;
}
return null;
} | [
"public",
"static",
"PHPMethodDescriptor",
"findMethod",
"(",
"PHPClassDescriptor",
"desc",
",",
"String",
"methodName",
")",
"{",
"PHPMethodDescriptor",
"meth",
";",
"meth",
"=",
"desc",
".",
"getMethod",
"(",
"Helper",
".",
"formatProcedureName",
"(",
"methodName",
")",
")",
";",
"if",
"(",
"meth",
"!=",
"null",
")",
"{",
"return",
"meth",
";",
"}",
"meth",
"=",
"desc",
".",
"getMethod",
"(",
"\"get\"",
"+",
"Helper",
".",
"formatProcedureName",
"(",
"methodName",
")",
")",
";",
"if",
"(",
"meth",
"!=",
"null",
")",
"{",
"return",
"meth",
";",
"}",
"return",
"null",
";",
"}"
] | <p>findMethod.</p>
@param desc a {@link com.greenpepper.phpsud.container.PHPClassDescriptor} object.
@param methodName a {@link java.lang.String} object.
@return a {@link com.greenpepper.phpsud.container.PHPMethodDescriptor} object. | [
"<p",
">",
"findMethod",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/strator-dev/greenpepper-open/blob/71fd244b4989e9cd2d07ae62dd954a1f2a269a92/extensions-external/php/src/main/java/com/greenpepper/phpsud/fixtures/PHPFixture.java#L88-L99 |
spotify/styx | styx-common/src/main/java/com/spotify/styx/util/TimeUtil.java | TimeUtil.nextInstant | public static Instant nextInstant(Instant instant, Schedule schedule) {
"""
Gets the next execution instant for a {@link Schedule}, relative to a given instant.
<p>e.g. an hourly schedule has a next execution instant at 14:00 relative to 13:22.
@param instant The instant to calculate the next execution instant relative to
@param schedule The schedule of executions
@return an instant at the next execution time
"""
final ExecutionTime executionTime = ExecutionTime.forCron(cron(schedule));
final ZonedDateTime utcDateTime = instant.atZone(UTC);
return executionTime.nextExecution(utcDateTime)
.orElseThrow(IllegalArgumentException::new) // with unix cron, this should not happen
.toInstant();
} | java | public static Instant nextInstant(Instant instant, Schedule schedule) {
final ExecutionTime executionTime = ExecutionTime.forCron(cron(schedule));
final ZonedDateTime utcDateTime = instant.atZone(UTC);
return executionTime.nextExecution(utcDateTime)
.orElseThrow(IllegalArgumentException::new) // with unix cron, this should not happen
.toInstant();
} | [
"public",
"static",
"Instant",
"nextInstant",
"(",
"Instant",
"instant",
",",
"Schedule",
"schedule",
")",
"{",
"final",
"ExecutionTime",
"executionTime",
"=",
"ExecutionTime",
".",
"forCron",
"(",
"cron",
"(",
"schedule",
")",
")",
";",
"final",
"ZonedDateTime",
"utcDateTime",
"=",
"instant",
".",
"atZone",
"(",
"UTC",
")",
";",
"return",
"executionTime",
".",
"nextExecution",
"(",
"utcDateTime",
")",
".",
"orElseThrow",
"(",
"IllegalArgumentException",
"::",
"new",
")",
"// with unix cron, this should not happen",
".",
"toInstant",
"(",
")",
";",
"}"
] | Gets the next execution instant for a {@link Schedule}, relative to a given instant.
<p>e.g. an hourly schedule has a next execution instant at 14:00 relative to 13:22.
@param instant The instant to calculate the next execution instant relative to
@param schedule The schedule of executions
@return an instant at the next execution time | [
"Gets",
"the",
"next",
"execution",
"instant",
"for",
"a",
"{",
"@link",
"Schedule",
"}",
"relative",
"to",
"a",
"given",
"instant",
"."
] | train | https://github.com/spotify/styx/blob/0d63999beeb93a17447e3bbccaa62175b74cf6e4/styx-common/src/main/java/com/spotify/styx/util/TimeUtil.java#L108-L115 |
nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java | Config.getPropertyDouble | public static Double getPropertyDouble(Class<?> cls, String key) {
"""
Get a double property
@param cls the class associated with the property
@param key the property key name
@return the double property value
"""
return getSettings().getPropertyDouble(cls, key);
} | java | public static Double getPropertyDouble(Class<?> cls, String key)
{
return getSettings().getPropertyDouble(cls, key);
} | [
"public",
"static",
"Double",
"getPropertyDouble",
"(",
"Class",
"<",
"?",
">",
"cls",
",",
"String",
"key",
")",
"{",
"return",
"getSettings",
"(",
")",
".",
"getPropertyDouble",
"(",
"cls",
",",
"key",
")",
";",
"}"
] | Get a double property
@param cls the class associated with the property
@param key the property key name
@return the double property value | [
"Get",
"a",
"double",
"property"
] | train | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java#L316-L320 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildErrorSummary | public void buildErrorSummary(XMLNode node, Content packageSummaryContentTree) {
"""
Build the summary for the errors in the package.
@param node the XML element that specifies which components to document
@param packageSummaryContentTree the tree to which the error summary will
be added
"""
String errorTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Error_Summary"),
configuration.getText("doclet.errors"));
String[] errorTableHeader = new String[] {
configuration.getText("doclet.Error"),
configuration.getText("doclet.Description")
};
ClassDoc[] errors = pkg.errors();
if (errors.length > 0) {
profileWriter.addClassesSummary(
errors,
configuration.getText("doclet.Error_Summary"),
errorTableSummary, errorTableHeader, packageSummaryContentTree);
}
} | java | public void buildErrorSummary(XMLNode node, Content packageSummaryContentTree) {
String errorTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Error_Summary"),
configuration.getText("doclet.errors"));
String[] errorTableHeader = new String[] {
configuration.getText("doclet.Error"),
configuration.getText("doclet.Description")
};
ClassDoc[] errors = pkg.errors();
if (errors.length > 0) {
profileWriter.addClassesSummary(
errors,
configuration.getText("doclet.Error_Summary"),
errorTableSummary, errorTableHeader, packageSummaryContentTree);
}
} | [
"public",
"void",
"buildErrorSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"packageSummaryContentTree",
")",
"{",
"String",
"errorTableSummary",
"=",
"configuration",
".",
"getText",
"(",
"\"doclet.Member_Table_Summary\"",
",",
"configuration",
".",
"getText",
"(",
"\"doclet.Error_Summary\"",
")",
",",
"configuration",
".",
"getText",
"(",
"\"doclet.errors\"",
")",
")",
";",
"String",
"[",
"]",
"errorTableHeader",
"=",
"new",
"String",
"[",
"]",
"{",
"configuration",
".",
"getText",
"(",
"\"doclet.Error\"",
")",
",",
"configuration",
".",
"getText",
"(",
"\"doclet.Description\"",
")",
"}",
";",
"ClassDoc",
"[",
"]",
"errors",
"=",
"pkg",
".",
"errors",
"(",
")",
";",
"if",
"(",
"errors",
".",
"length",
">",
"0",
")",
"{",
"profileWriter",
".",
"addClassesSummary",
"(",
"errors",
",",
"configuration",
".",
"getText",
"(",
"\"doclet.Error_Summary\"",
")",
",",
"errorTableSummary",
",",
"errorTableHeader",
",",
"packageSummaryContentTree",
")",
";",
"}",
"}"
] | Build the summary for the errors in the package.
@param node the XML element that specifies which components to document
@param packageSummaryContentTree the tree to which the error summary will
be added | [
"Build",
"the",
"summary",
"for",
"the",
"errors",
"in",
"the",
"package",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L285-L301 |
geomajas/geomajas-project-client-gwt | common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java | HtmlBuilder.openTagClassHtmlContent | public static String openTagClassHtmlContent(String tag, String clazz, String... content) {
"""
Build a String containing a HTML opening tag with given CSS class and concatenates the given HTML content.
@param tag String name of HTML tag
@param clazz CSS class of the tag
@param content content string
@return HTML tag element as string
"""
return openTagHtmlContent(tag, clazz, null, content);
} | java | public static String openTagClassHtmlContent(String tag, String clazz, String... content) {
return openTagHtmlContent(tag, clazz, null, content);
} | [
"public",
"static",
"String",
"openTagClassHtmlContent",
"(",
"String",
"tag",
",",
"String",
"clazz",
",",
"String",
"...",
"content",
")",
"{",
"return",
"openTagHtmlContent",
"(",
"tag",
",",
"clazz",
",",
"null",
",",
"content",
")",
";",
"}"
] | Build a String containing a HTML opening tag with given CSS class and concatenates the given HTML content.
@param tag String name of HTML tag
@param clazz CSS class of the tag
@param content content string
@return HTML tag element as string | [
"Build",
"a",
"String",
"containing",
"a",
"HTML",
"opening",
"tag",
"with",
"given",
"CSS",
"class",
"and",
"concatenates",
"the",
"given",
"HTML",
"content",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java#L350-L352 |
apache/incubator-atlas | typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java | TypeSystem.createTransientTypeSystem | public TransientTypeSystem createTransientTypeSystem(TypesDef typesDef, boolean isUpdate) throws AtlasException {
"""
Create an instance of {@link TransientTypeSystem} with the types defined in the {@link TypesDef}.
As part of this, a set of verifications are run on the types defined.
@param typesDef The new list of types to be created or updated.
@param isUpdate True, if types are updated, false otherwise.
@return {@link TransientTypeSystem} that holds the newly added types.
@throws AtlasException
"""
ImmutableList<EnumTypeDefinition> enumDefs = ImmutableList.copyOf(typesDef.enumTypesAsJavaList());
ImmutableList<StructTypeDefinition> structDefs = ImmutableList.copyOf(typesDef.structTypesAsJavaList());
ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs =
ImmutableList.copyOf(typesDef.traitTypesAsJavaList());
ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs =
ImmutableList.copyOf(typesDef.classTypesAsJavaList());
TransientTypeSystem transientTypeSystem = new TransientTypeSystem(enumDefs, structDefs, traitDefs, classDefs);
transientTypeSystem.verifyTypes(isUpdate);
return transientTypeSystem;
} | java | public TransientTypeSystem createTransientTypeSystem(TypesDef typesDef, boolean isUpdate) throws AtlasException {
ImmutableList<EnumTypeDefinition> enumDefs = ImmutableList.copyOf(typesDef.enumTypesAsJavaList());
ImmutableList<StructTypeDefinition> structDefs = ImmutableList.copyOf(typesDef.structTypesAsJavaList());
ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs =
ImmutableList.copyOf(typesDef.traitTypesAsJavaList());
ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs =
ImmutableList.copyOf(typesDef.classTypesAsJavaList());
TransientTypeSystem transientTypeSystem = new TransientTypeSystem(enumDefs, structDefs, traitDefs, classDefs);
transientTypeSystem.verifyTypes(isUpdate);
return transientTypeSystem;
} | [
"public",
"TransientTypeSystem",
"createTransientTypeSystem",
"(",
"TypesDef",
"typesDef",
",",
"boolean",
"isUpdate",
")",
"throws",
"AtlasException",
"{",
"ImmutableList",
"<",
"EnumTypeDefinition",
">",
"enumDefs",
"=",
"ImmutableList",
".",
"copyOf",
"(",
"typesDef",
".",
"enumTypesAsJavaList",
"(",
")",
")",
";",
"ImmutableList",
"<",
"StructTypeDefinition",
">",
"structDefs",
"=",
"ImmutableList",
".",
"copyOf",
"(",
"typesDef",
".",
"structTypesAsJavaList",
"(",
")",
")",
";",
"ImmutableList",
"<",
"HierarchicalTypeDefinition",
"<",
"TraitType",
">",
">",
"traitDefs",
"=",
"ImmutableList",
".",
"copyOf",
"(",
"typesDef",
".",
"traitTypesAsJavaList",
"(",
")",
")",
";",
"ImmutableList",
"<",
"HierarchicalTypeDefinition",
"<",
"ClassType",
">",
">",
"classDefs",
"=",
"ImmutableList",
".",
"copyOf",
"(",
"typesDef",
".",
"classTypesAsJavaList",
"(",
")",
")",
";",
"TransientTypeSystem",
"transientTypeSystem",
"=",
"new",
"TransientTypeSystem",
"(",
"enumDefs",
",",
"structDefs",
",",
"traitDefs",
",",
"classDefs",
")",
";",
"transientTypeSystem",
".",
"verifyTypes",
"(",
"isUpdate",
")",
";",
"return",
"transientTypeSystem",
";",
"}"
] | Create an instance of {@link TransientTypeSystem} with the types defined in the {@link TypesDef}.
As part of this, a set of verifications are run on the types defined.
@param typesDef The new list of types to be created or updated.
@param isUpdate True, if types are updated, false otherwise.
@return {@link TransientTypeSystem} that holds the newly added types.
@throws AtlasException | [
"Create",
"an",
"instance",
"of",
"{",
"@link",
"TransientTypeSystem",
"}",
"with",
"the",
"types",
"defined",
"in",
"the",
"{",
"@link",
"TypesDef",
"}",
"."
] | train | https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java#L343-L353 |
b3log/latke | latke-core/src/main/java/org/json/JSONArray.java | JSONArray.optBigInteger | public BigInteger optBigInteger(int index, BigInteger defaultValue) {
"""
Get the optional BigInteger value associated with an index. The
defaultValue is returned if there is no value for the index, or if the
value is not a number and cannot be converted to a number.
@param index
The index must be between 0 and length() - 1.
@param defaultValue
The default value.
@return The value.
"""
Object val = this.opt(index);
return JSONObject.objectToBigInteger(val, defaultValue);
} | java | public BigInteger optBigInteger(int index, BigInteger defaultValue) {
Object val = this.opt(index);
return JSONObject.objectToBigInteger(val, defaultValue);
} | [
"public",
"BigInteger",
"optBigInteger",
"(",
"int",
"index",
",",
"BigInteger",
"defaultValue",
")",
"{",
"Object",
"val",
"=",
"this",
".",
"opt",
"(",
"index",
")",
";",
"return",
"JSONObject",
".",
"objectToBigInteger",
"(",
"val",
",",
"defaultValue",
")",
";",
"}"
] | Get the optional BigInteger value associated with an index. The
defaultValue is returned if there is no value for the index, or if the
value is not a number and cannot be converted to a number.
@param index
The index must be between 0 and length() - 1.
@param defaultValue
The default value.
@return The value. | [
"Get",
"the",
"optional",
"BigInteger",
"value",
"associated",
"with",
"an",
"index",
".",
"The",
"defaultValue",
"is",
"returned",
"if",
"there",
"is",
"no",
"value",
"for",
"the",
"index",
"or",
"if",
"the",
"value",
"is",
"not",
"a",
"number",
"and",
"cannot",
"be",
"converted",
"to",
"a",
"number",
"."
] | train | https://github.com/b3log/latke/blob/f7e08a47eeecea5f7c94006382c24f353585de33/latke-core/src/main/java/org/json/JSONArray.java#L709-L712 |
janus-project/guava.janusproject.io | guava/src/com/google/common/base/CharMatcher.java | CharMatcher.inRange | public static CharMatcher inRange(final char startInclusive, final char endInclusive) {
"""
Returns a {@code char} matcher that matches any character in a given range (both endpoints are
inclusive). For example, to match any lowercase letter of the English alphabet, use {@code
CharMatcher.inRange('a', 'z')}.
@throws IllegalArgumentException if {@code endInclusive < startInclusive}
"""
checkArgument(endInclusive >= startInclusive);
return new FastMatcher() {
@Override public boolean matches(char c) {
return startInclusive <= c && c <= endInclusive;
}
@GwtIncompatible("java.util.BitSet")
@Override void setBits(BitSet table) {
table.set(startInclusive, endInclusive + 1);
}
@Override public String toString() {
return "CharMatcher.inRange('" + showCharacter(startInclusive)
+ "', '" + showCharacter(endInclusive) + "')";
}
};
} | java | public static CharMatcher inRange(final char startInclusive, final char endInclusive) {
checkArgument(endInclusive >= startInclusive);
return new FastMatcher() {
@Override public boolean matches(char c) {
return startInclusive <= c && c <= endInclusive;
}
@GwtIncompatible("java.util.BitSet")
@Override void setBits(BitSet table) {
table.set(startInclusive, endInclusive + 1);
}
@Override public String toString() {
return "CharMatcher.inRange('" + showCharacter(startInclusive)
+ "', '" + showCharacter(endInclusive) + "')";
}
};
} | [
"public",
"static",
"CharMatcher",
"inRange",
"(",
"final",
"char",
"startInclusive",
",",
"final",
"char",
"endInclusive",
")",
"{",
"checkArgument",
"(",
"endInclusive",
">=",
"startInclusive",
")",
";",
"return",
"new",
"FastMatcher",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"matches",
"(",
"char",
"c",
")",
"{",
"return",
"startInclusive",
"<=",
"c",
"&&",
"c",
"<=",
"endInclusive",
";",
"}",
"@",
"GwtIncompatible",
"(",
"\"java.util.BitSet\"",
")",
"@",
"Override",
"void",
"setBits",
"(",
"BitSet",
"table",
")",
"{",
"table",
".",
"set",
"(",
"startInclusive",
",",
"endInclusive",
"+",
"1",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"CharMatcher.inRange('\"",
"+",
"showCharacter",
"(",
"startInclusive",
")",
"+",
"\"', '\"",
"+",
"showCharacter",
"(",
"endInclusive",
")",
"+",
"\"')\"",
";",
"}",
"}",
";",
"}"
] | Returns a {@code char} matcher that matches any character in a given range (both endpoints are
inclusive). For example, to match any lowercase letter of the English alphabet, use {@code
CharMatcher.inRange('a', 'z')}.
@throws IllegalArgumentException if {@code endInclusive < startInclusive} | [
"Returns",
"a",
"{",
"@code",
"char",
"}",
"matcher",
"that",
"matches",
"any",
"character",
"in",
"a",
"given",
"range",
"(",
"both",
"endpoints",
"are",
"inclusive",
")",
".",
"For",
"example",
"to",
"match",
"any",
"lowercase",
"letter",
"of",
"the",
"English",
"alphabet",
"use",
"{",
"@code",
"CharMatcher",
".",
"inRange",
"(",
"a",
"z",
")",
"}",
"."
] | train | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/base/CharMatcher.java#L587-L604 |
JM-Lab/utils-java8 | src/main/java/kr/jm/utils/helper/JMThread.java | JMThread.getLimitedBlockingQueue | public static <E> BlockingQueue<E> getLimitedBlockingQueue(int maxQueue) {
"""
Gets limited blocking queue.
@param <E> the type parameter
@param maxQueue the max queue
@return the limited blocking queue
"""
return new LinkedBlockingQueue<E>(maxQueue) {
@Override
public boolean offer(E e) {
return putInsteadOfOffer(this, e);
}
};
} | java | public static <E> BlockingQueue<E> getLimitedBlockingQueue(int maxQueue) {
return new LinkedBlockingQueue<E>(maxQueue) {
@Override
public boolean offer(E e) {
return putInsteadOfOffer(this, e);
}
};
} | [
"public",
"static",
"<",
"E",
">",
"BlockingQueue",
"<",
"E",
">",
"getLimitedBlockingQueue",
"(",
"int",
"maxQueue",
")",
"{",
"return",
"new",
"LinkedBlockingQueue",
"<",
"E",
">",
"(",
"maxQueue",
")",
"{",
"@",
"Override",
"public",
"boolean",
"offer",
"(",
"E",
"e",
")",
"{",
"return",
"putInsteadOfOffer",
"(",
"this",
",",
"e",
")",
";",
"}",
"}",
";",
"}"
] | Gets limited blocking queue.
@param <E> the type parameter
@param maxQueue the max queue
@return the limited blocking queue | [
"Gets",
"limited",
"blocking",
"queue",
"."
] | train | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L598-L605 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/DateField.java | DateField.moveSQLToField | public void moveSQLToField(ResultSet resultset, int iColumn) throws SQLException {
"""
Move the physical binary data to this SQL parameter row.
@param resultset The resultset to get the SQL data from.
@param iColumn the column in the resultset that has my data.
@exception SQLException From SQL calls.
"""
java.util.Date dateResult = resultset.getDate(iColumn);
if (resultset.wasNull())
this.setString(Constants.BLANK, false, DBConstants.READ_MOVE); // Null value
else
this.setValue((double)dateResult.getTime(), false, DBConstants.READ_MOVE);
} | java | public void moveSQLToField(ResultSet resultset, int iColumn) throws SQLException
{
java.util.Date dateResult = resultset.getDate(iColumn);
if (resultset.wasNull())
this.setString(Constants.BLANK, false, DBConstants.READ_MOVE); // Null value
else
this.setValue((double)dateResult.getTime(), false, DBConstants.READ_MOVE);
} | [
"public",
"void",
"moveSQLToField",
"(",
"ResultSet",
"resultset",
",",
"int",
"iColumn",
")",
"throws",
"SQLException",
"{",
"java",
".",
"util",
".",
"Date",
"dateResult",
"=",
"resultset",
".",
"getDate",
"(",
"iColumn",
")",
";",
"if",
"(",
"resultset",
".",
"wasNull",
"(",
")",
")",
"this",
".",
"setString",
"(",
"Constants",
".",
"BLANK",
",",
"false",
",",
"DBConstants",
".",
"READ_MOVE",
")",
";",
"// Null value",
"else",
"this",
".",
"setValue",
"(",
"(",
"double",
")",
"dateResult",
".",
"getTime",
"(",
")",
",",
"false",
",",
"DBConstants",
".",
"READ_MOVE",
")",
";",
"}"
] | Move the physical binary data to this SQL parameter row.
@param resultset The resultset to get the SQL data from.
@param iColumn the column in the resultset that has my data.
@exception SQLException From SQL calls. | [
"Move",
"the",
"physical",
"binary",
"data",
"to",
"this",
"SQL",
"parameter",
"row",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/DateField.java#L173-L180 |
groupe-sii/ogham | ogham-sms-cloudhopper/src/main/java/fr/sii/ogham/sms/sender/impl/cloudhopper/MapCloudhopperCharsetHandler.java | MapCloudhopperCharsetHandler.addCharset | public void addCharset(String nioCharsetName, Charset cloudhopperCharset) {
"""
Add a charset mapping.
@param nioCharsetName
Java NIO charset name
@param cloudhopperCharset
Cloudhopper charset
"""
LOG.debug("Added charset mapping nio {} -> {}", nioCharsetName, cloudhopperCharset);
mapCloudhopperCharsetByNioCharsetName.put(nioCharsetName, cloudhopperCharset);
} | java | public void addCharset(String nioCharsetName, Charset cloudhopperCharset) {
LOG.debug("Added charset mapping nio {} -> {}", nioCharsetName, cloudhopperCharset);
mapCloudhopperCharsetByNioCharsetName.put(nioCharsetName, cloudhopperCharset);
} | [
"public",
"void",
"addCharset",
"(",
"String",
"nioCharsetName",
",",
"Charset",
"cloudhopperCharset",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Added charset mapping nio {} -> {}\"",
",",
"nioCharsetName",
",",
"cloudhopperCharset",
")",
";",
"mapCloudhopperCharsetByNioCharsetName",
".",
"put",
"(",
"nioCharsetName",
",",
"cloudhopperCharset",
")",
";",
"}"
] | Add a charset mapping.
@param nioCharsetName
Java NIO charset name
@param cloudhopperCharset
Cloudhopper charset | [
"Add",
"a",
"charset",
"mapping",
"."
] | train | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-sms-cloudhopper/src/main/java/fr/sii/ogham/sms/sender/impl/cloudhopper/MapCloudhopperCharsetHandler.java#L87-L90 |
ManfredTremmel/gwt-bean-validators | mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/impl/IsinValidator.java | IsinValidator.isValid | @Override
public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
"""
{@inheritDoc} check if given string is a valid isin.
@see javax.validation.ConstraintValidator#isValid(java.lang.Object,
javax.validation.ConstraintValidatorContext)
"""
final String valueAsString = Objects.toString(pvalue, null);
if (StringUtils.isEmpty(valueAsString)) {
return true;
}
if (valueAsString.length() != ISIN_LENGTH) {
// ISIN size is wrong, but that's handled by size annotation
return true;
}
// calculate and check checksum (ISIN)
return CHECK_ISIN.isValid(valueAsString);
} | java | @Override
public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
final String valueAsString = Objects.toString(pvalue, null);
if (StringUtils.isEmpty(valueAsString)) {
return true;
}
if (valueAsString.length() != ISIN_LENGTH) {
// ISIN size is wrong, but that's handled by size annotation
return true;
}
// calculate and check checksum (ISIN)
return CHECK_ISIN.isValid(valueAsString);
} | [
"@",
"Override",
"public",
"final",
"boolean",
"isValid",
"(",
"final",
"Object",
"pvalue",
",",
"final",
"ConstraintValidatorContext",
"pcontext",
")",
"{",
"final",
"String",
"valueAsString",
"=",
"Objects",
".",
"toString",
"(",
"pvalue",
",",
"null",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"valueAsString",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"valueAsString",
".",
"length",
"(",
")",
"!=",
"ISIN_LENGTH",
")",
"{",
"// ISIN size is wrong, but that's handled by size annotation",
"return",
"true",
";",
"}",
"// calculate and check checksum (ISIN)",
"return",
"CHECK_ISIN",
".",
"isValid",
"(",
"valueAsString",
")",
";",
"}"
] | {@inheritDoc} check if given string is a valid isin.
@see javax.validation.ConstraintValidator#isValid(java.lang.Object,
javax.validation.ConstraintValidatorContext) | [
"{",
"@inheritDoc",
"}",
"check",
"if",
"given",
"string",
"is",
"a",
"valid",
"isin",
"."
] | train | https://github.com/ManfredTremmel/gwt-bean-validators/blob/cff7a2c3d68c2d17bf9d3cc57c79cc16fa8b4d5c/mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/impl/IsinValidator.java#L61-L73 |
Impetus/Kundera | examples/polyglot/kvapps/src/main/java/com/impetus/kvapps/runner/ExecutorService.java | ExecutorService.findByKey | static User findByKey(final EntityManager em, final String userId) {
"""
On find by user id.
@param em entity manager instance.
@param userId user id.
"""
User user = em.find(User.class, userId);
logger.info("[On Find by key]");
System.out.println("#######################START##########################################");
logger.info("\n");
logger.info("\t\t User's first name:" + user.getFirstName());
logger.info("\t\t User's emailId:" + user.getEmailId());
logger.info("\t\t User's Personal Details:" + user.getPersonalDetail().getName());
logger.info("\t\t User's Personal Details:" + user.getPersonalDetail().getPassword());
logger.info("\t\t User's total tweets:" + user.getTweets().size());
logger.info("\n");
System.out.println("#######################END############################################");
logger.info("\n");
return user;
} | java | static User findByKey(final EntityManager em, final String userId)
{
User user = em.find(User.class, userId);
logger.info("[On Find by key]");
System.out.println("#######################START##########################################");
logger.info("\n");
logger.info("\t\t User's first name:" + user.getFirstName());
logger.info("\t\t User's emailId:" + user.getEmailId());
logger.info("\t\t User's Personal Details:" + user.getPersonalDetail().getName());
logger.info("\t\t User's Personal Details:" + user.getPersonalDetail().getPassword());
logger.info("\t\t User's total tweets:" + user.getTweets().size());
logger.info("\n");
System.out.println("#######################END############################################");
logger.info("\n");
return user;
} | [
"static",
"User",
"findByKey",
"(",
"final",
"EntityManager",
"em",
",",
"final",
"String",
"userId",
")",
"{",
"User",
"user",
"=",
"em",
".",
"find",
"(",
"User",
".",
"class",
",",
"userId",
")",
";",
"logger",
".",
"info",
"(",
"\"[On Find by key]\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"#######################START##########################################\"",
")",
";",
"logger",
".",
"info",
"(",
"\"\\n\"",
")",
";",
"logger",
".",
"info",
"(",
"\"\\t\\t User's first name:\"",
"+",
"user",
".",
"getFirstName",
"(",
")",
")",
";",
"logger",
".",
"info",
"(",
"\"\\t\\t User's emailId:\"",
"+",
"user",
".",
"getEmailId",
"(",
")",
")",
";",
"logger",
".",
"info",
"(",
"\"\\t\\t User's Personal Details:\"",
"+",
"user",
".",
"getPersonalDetail",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"logger",
".",
"info",
"(",
"\"\\t\\t User's Personal Details:\"",
"+",
"user",
".",
"getPersonalDetail",
"(",
")",
".",
"getPassword",
"(",
")",
")",
";",
"logger",
".",
"info",
"(",
"\"\\t\\t User's total tweets:\"",
"+",
"user",
".",
"getTweets",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"logger",
".",
"info",
"(",
"\"\\n\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"#######################END############################################\"",
")",
";",
"logger",
".",
"info",
"(",
"\"\\n\"",
")",
";",
"return",
"user",
";",
"}"
] | On find by user id.
@param em entity manager instance.
@param userId user id. | [
"On",
"find",
"by",
"user",
"id",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/examples/polyglot/kvapps/src/main/java/com/impetus/kvapps/runner/ExecutorService.java#L96-L111 |
RuedigerMoeller/kontraktor | modules/service-suppport/src/main/java/org/nustaq/kontraktor/services/ServiceActor.java | ServiceActor.RunTCP | public static ServiceActor RunTCP( String args[], Class<? extends ServiceActor> serviceClazz, Class<? extends ServiceArgs> argsClazz) {
"""
run & connect a service with given cmdline args and classes
@param args
@param serviceClazz
@param argsClazz
@return
@throws IllegalAccessException
@throws InstantiationException
"""
ServiceActor myService = AsActor(serviceClazz);
ServiceArgs options = null;
try {
options = ServiceRegistry.parseCommandLine(args, null, argsClazz.newInstance());
} catch (Exception e) {
FSTUtil.rethrow(e);
}
TCPConnectable connectable = new TCPConnectable(ServiceRegistry.class, options.getRegistryHost(), options.getRegistryPort());
myService.init( connectable, options, true).await(30_000);
Log.Info(myService.getClass(), "Init finished");
return myService;
} | java | public static ServiceActor RunTCP( String args[], Class<? extends ServiceActor> serviceClazz, Class<? extends ServiceArgs> argsClazz) {
ServiceActor myService = AsActor(serviceClazz);
ServiceArgs options = null;
try {
options = ServiceRegistry.parseCommandLine(args, null, argsClazz.newInstance());
} catch (Exception e) {
FSTUtil.rethrow(e);
}
TCPConnectable connectable = new TCPConnectable(ServiceRegistry.class, options.getRegistryHost(), options.getRegistryPort());
myService.init( connectable, options, true).await(30_000);
Log.Info(myService.getClass(), "Init finished");
return myService;
} | [
"public",
"static",
"ServiceActor",
"RunTCP",
"(",
"String",
"args",
"[",
"]",
",",
"Class",
"<",
"?",
"extends",
"ServiceActor",
">",
"serviceClazz",
",",
"Class",
"<",
"?",
"extends",
"ServiceArgs",
">",
"argsClazz",
")",
"{",
"ServiceActor",
"myService",
"=",
"AsActor",
"(",
"serviceClazz",
")",
";",
"ServiceArgs",
"options",
"=",
"null",
";",
"try",
"{",
"options",
"=",
"ServiceRegistry",
".",
"parseCommandLine",
"(",
"args",
",",
"null",
",",
"argsClazz",
".",
"newInstance",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"FSTUtil",
".",
"rethrow",
"(",
"e",
")",
";",
"}",
"TCPConnectable",
"connectable",
"=",
"new",
"TCPConnectable",
"(",
"ServiceRegistry",
".",
"class",
",",
"options",
".",
"getRegistryHost",
"(",
")",
",",
"options",
".",
"getRegistryPort",
"(",
")",
")",
";",
"myService",
".",
"init",
"(",
"connectable",
",",
"options",
",",
"true",
")",
".",
"await",
"(",
"30_000",
")",
";",
"Log",
".",
"Info",
"(",
"myService",
".",
"getClass",
"(",
")",
",",
"\"Init finished\"",
")",
";",
"return",
"myService",
";",
"}"
] | run & connect a service with given cmdline args and classes
@param args
@param serviceClazz
@param argsClazz
@return
@throws IllegalAccessException
@throws InstantiationException | [
"run",
"&",
"connect",
"a",
"service",
"with",
"given",
"cmdline",
"args",
"and",
"classes"
] | train | https://github.com/RuedigerMoeller/kontraktor/blob/d5f3817f9476f3786187b8ef00400b7a4f25a404/modules/service-suppport/src/main/java/org/nustaq/kontraktor/services/ServiceActor.java#L36-L50 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/core/util/MimeTypeUtil.java | MimeTypeUtil.getMimeType | public static MimeType getMimeType(String name, Property property) {
"""
Detects the mime type of a binary property in the context of the nodes name.
@param name the name of the node which defines the binary resource (probably a file name)
@param property the binary property (for stream parsing)
@return he detected mime type or 'null' if the detection was not successful
"""
MimeType result = null;
try {
Binary binary = property != null ? property.getBinary() : null;
if (binary != null) {
try {
InputStream input = binary.getStream();
try {
MediaType mediaType = getMediaType(input, name);
if (mediaType != null) {
try {
result = getMimeTypes().forName(mediaType.toString());
} catch (MimeTypeException e1) {
// detection not successful
}
}
} finally {
try {
input.close();
} catch (IOException ioex) {
LOG.error(ioex.toString());
}
}
} finally {
binary.dispose();
}
}
} catch (RepositoryException rex) {
LOG.error(rex.toString());
}
return result;
} | java | public static MimeType getMimeType(String name, Property property) {
MimeType result = null;
try {
Binary binary = property != null ? property.getBinary() : null;
if (binary != null) {
try {
InputStream input = binary.getStream();
try {
MediaType mediaType = getMediaType(input, name);
if (mediaType != null) {
try {
result = getMimeTypes().forName(mediaType.toString());
} catch (MimeTypeException e1) {
// detection not successful
}
}
} finally {
try {
input.close();
} catch (IOException ioex) {
LOG.error(ioex.toString());
}
}
} finally {
binary.dispose();
}
}
} catch (RepositoryException rex) {
LOG.error(rex.toString());
}
return result;
} | [
"public",
"static",
"MimeType",
"getMimeType",
"(",
"String",
"name",
",",
"Property",
"property",
")",
"{",
"MimeType",
"result",
"=",
"null",
";",
"try",
"{",
"Binary",
"binary",
"=",
"property",
"!=",
"null",
"?",
"property",
".",
"getBinary",
"(",
")",
":",
"null",
";",
"if",
"(",
"binary",
"!=",
"null",
")",
"{",
"try",
"{",
"InputStream",
"input",
"=",
"binary",
".",
"getStream",
"(",
")",
";",
"try",
"{",
"MediaType",
"mediaType",
"=",
"getMediaType",
"(",
"input",
",",
"name",
")",
";",
"if",
"(",
"mediaType",
"!=",
"null",
")",
"{",
"try",
"{",
"result",
"=",
"getMimeTypes",
"(",
")",
".",
"forName",
"(",
"mediaType",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"MimeTypeException",
"e1",
")",
"{",
"// detection not successful",
"}",
"}",
"}",
"finally",
"{",
"try",
"{",
"input",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioex",
")",
"{",
"LOG",
".",
"error",
"(",
"ioex",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"finally",
"{",
"binary",
".",
"dispose",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"RepositoryException",
"rex",
")",
"{",
"LOG",
".",
"error",
"(",
"rex",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Detects the mime type of a binary property in the context of the nodes name.
@param name the name of the node which defines the binary resource (probably a file name)
@param property the binary property (for stream parsing)
@return he detected mime type or 'null' if the detection was not successful | [
"Detects",
"the",
"mime",
"type",
"of",
"a",
"binary",
"property",
"in",
"the",
"context",
"of",
"the",
"nodes",
"name",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/util/MimeTypeUtil.java#L139-L170 |
pravega/pravega | segmentstore/server/src/main/java/io/pravega/segmentstore/server/writer/StorageWriter.java | StorageWriter.getProcessor | private CompletableFuture<ProcessorCollection> getProcessor(long streamSegmentId) {
"""
Gets, or creates, a SegmentAggregator for the given StorageOperation.
@param streamSegmentId The Id of the StreamSegment to get the aggregator for.
"""
ProcessorCollection existingProcessor = this.processors.getOrDefault(streamSegmentId, null);
if (existingProcessor != null) {
if (closeIfNecessary(existingProcessor).isClosed()) {
// Existing SegmentAggregator has become stale (most likely due to its SegmentMetadata being evicted),
// so it has been closed and we need to create a new one.
this.processors.remove(streamSegmentId);
} else {
return CompletableFuture.completedFuture(existingProcessor);
}
}
// Get the SegmentAggregator's Metadata.
UpdateableSegmentMetadata segmentMetadata = this.dataSource.getStreamSegmentMetadata(streamSegmentId);
if (segmentMetadata == null) {
return Futures.failedFuture(new DataCorruptionException(String.format(
"No StreamSegment with id '%d' is registered in the metadata.", streamSegmentId)));
}
// Then create the aggregator, and only register it after a successful initialization. Otherwise we risk
// having a registered aggregator that is not initialized.
SegmentAggregator newAggregator = new SegmentAggregator(segmentMetadata, this.dataSource, this.storage, this.config, this.timer, this.executor);
ProcessorCollection pc = new ProcessorCollection(newAggregator, this.createProcessors.apply(segmentMetadata));
try {
CompletableFuture<Void> init = newAggregator.initialize(this.config.getFlushTimeout());
Futures.exceptionListener(init, ex -> newAggregator.close());
return init.thenApply(ignored -> {
this.processors.put(streamSegmentId, pc);
return pc;
});
} catch (Exception ex) {
pc.close();
throw ex;
}
} | java | private CompletableFuture<ProcessorCollection> getProcessor(long streamSegmentId) {
ProcessorCollection existingProcessor = this.processors.getOrDefault(streamSegmentId, null);
if (existingProcessor != null) {
if (closeIfNecessary(existingProcessor).isClosed()) {
// Existing SegmentAggregator has become stale (most likely due to its SegmentMetadata being evicted),
// so it has been closed and we need to create a new one.
this.processors.remove(streamSegmentId);
} else {
return CompletableFuture.completedFuture(existingProcessor);
}
}
// Get the SegmentAggregator's Metadata.
UpdateableSegmentMetadata segmentMetadata = this.dataSource.getStreamSegmentMetadata(streamSegmentId);
if (segmentMetadata == null) {
return Futures.failedFuture(new DataCorruptionException(String.format(
"No StreamSegment with id '%d' is registered in the metadata.", streamSegmentId)));
}
// Then create the aggregator, and only register it after a successful initialization. Otherwise we risk
// having a registered aggregator that is not initialized.
SegmentAggregator newAggregator = new SegmentAggregator(segmentMetadata, this.dataSource, this.storage, this.config, this.timer, this.executor);
ProcessorCollection pc = new ProcessorCollection(newAggregator, this.createProcessors.apply(segmentMetadata));
try {
CompletableFuture<Void> init = newAggregator.initialize(this.config.getFlushTimeout());
Futures.exceptionListener(init, ex -> newAggregator.close());
return init.thenApply(ignored -> {
this.processors.put(streamSegmentId, pc);
return pc;
});
} catch (Exception ex) {
pc.close();
throw ex;
}
} | [
"private",
"CompletableFuture",
"<",
"ProcessorCollection",
">",
"getProcessor",
"(",
"long",
"streamSegmentId",
")",
"{",
"ProcessorCollection",
"existingProcessor",
"=",
"this",
".",
"processors",
".",
"getOrDefault",
"(",
"streamSegmentId",
",",
"null",
")",
";",
"if",
"(",
"existingProcessor",
"!=",
"null",
")",
"{",
"if",
"(",
"closeIfNecessary",
"(",
"existingProcessor",
")",
".",
"isClosed",
"(",
")",
")",
"{",
"// Existing SegmentAggregator has become stale (most likely due to its SegmentMetadata being evicted),",
"// so it has been closed and we need to create a new one.",
"this",
".",
"processors",
".",
"remove",
"(",
"streamSegmentId",
")",
";",
"}",
"else",
"{",
"return",
"CompletableFuture",
".",
"completedFuture",
"(",
"existingProcessor",
")",
";",
"}",
"}",
"// Get the SegmentAggregator's Metadata.",
"UpdateableSegmentMetadata",
"segmentMetadata",
"=",
"this",
".",
"dataSource",
".",
"getStreamSegmentMetadata",
"(",
"streamSegmentId",
")",
";",
"if",
"(",
"segmentMetadata",
"==",
"null",
")",
"{",
"return",
"Futures",
".",
"failedFuture",
"(",
"new",
"DataCorruptionException",
"(",
"String",
".",
"format",
"(",
"\"No StreamSegment with id '%d' is registered in the metadata.\"",
",",
"streamSegmentId",
")",
")",
")",
";",
"}",
"// Then create the aggregator, and only register it after a successful initialization. Otherwise we risk",
"// having a registered aggregator that is not initialized.",
"SegmentAggregator",
"newAggregator",
"=",
"new",
"SegmentAggregator",
"(",
"segmentMetadata",
",",
"this",
".",
"dataSource",
",",
"this",
".",
"storage",
",",
"this",
".",
"config",
",",
"this",
".",
"timer",
",",
"this",
".",
"executor",
")",
";",
"ProcessorCollection",
"pc",
"=",
"new",
"ProcessorCollection",
"(",
"newAggregator",
",",
"this",
".",
"createProcessors",
".",
"apply",
"(",
"segmentMetadata",
")",
")",
";",
"try",
"{",
"CompletableFuture",
"<",
"Void",
">",
"init",
"=",
"newAggregator",
".",
"initialize",
"(",
"this",
".",
"config",
".",
"getFlushTimeout",
"(",
")",
")",
";",
"Futures",
".",
"exceptionListener",
"(",
"init",
",",
"ex",
"->",
"newAggregator",
".",
"close",
"(",
")",
")",
";",
"return",
"init",
".",
"thenApply",
"(",
"ignored",
"->",
"{",
"this",
".",
"processors",
".",
"put",
"(",
"streamSegmentId",
",",
"pc",
")",
";",
"return",
"pc",
";",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"pc",
".",
"close",
"(",
")",
";",
"throw",
"ex",
";",
"}",
"}"
] | Gets, or creates, a SegmentAggregator for the given StorageOperation.
@param streamSegmentId The Id of the StreamSegment to get the aggregator for. | [
"Gets",
"or",
"creates",
"a",
"SegmentAggregator",
"for",
"the",
"given",
"StorageOperation",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/writer/StorageWriter.java#L378-L412 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java | Section508Compliance.processSetColorOps | private void processSetColorOps(String methodName) throws ClassNotFoundException {
"""
looks for calls to set the color of components where the color isn't from UIManager
@param methodName
the method that is called
@throws ClassNotFoundException
if the gui component class can't be found
"""
if ("setBackground".equals(methodName) || "setForeground".equals(methodName)) {
int argCount = SignatureUtils.getNumParameters(getSigConstantOperand());
if (stack.getStackDepth() > argCount) {
OpcodeStack.Item item = stack.getStackItem(0);
if (S508UserValue.FROM_UIMANAGER != item.getUserValue()) {
item = stack.getStackItem(argCount);
JavaClass cls = item.getJavaClass();
if (((jcomponentClass != null) && cls.instanceOf(jcomponentClass)) || ((componentClass != null) && cls.instanceOf(componentClass))) {
bugReporter.reportBug(
new BugInstance(this, BugType.S508C_SET_COMP_COLOR.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
}
}
}
}
} | java | private void processSetColorOps(String methodName) throws ClassNotFoundException {
if ("setBackground".equals(methodName) || "setForeground".equals(methodName)) {
int argCount = SignatureUtils.getNumParameters(getSigConstantOperand());
if (stack.getStackDepth() > argCount) {
OpcodeStack.Item item = stack.getStackItem(0);
if (S508UserValue.FROM_UIMANAGER != item.getUserValue()) {
item = stack.getStackItem(argCount);
JavaClass cls = item.getJavaClass();
if (((jcomponentClass != null) && cls.instanceOf(jcomponentClass)) || ((componentClass != null) && cls.instanceOf(componentClass))) {
bugReporter.reportBug(
new BugInstance(this, BugType.S508C_SET_COMP_COLOR.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
}
}
}
}
} | [
"private",
"void",
"processSetColorOps",
"(",
"String",
"methodName",
")",
"throws",
"ClassNotFoundException",
"{",
"if",
"(",
"\"setBackground\"",
".",
"equals",
"(",
"methodName",
")",
"||",
"\"setForeground\"",
".",
"equals",
"(",
"methodName",
")",
")",
"{",
"int",
"argCount",
"=",
"SignatureUtils",
".",
"getNumParameters",
"(",
"getSigConstantOperand",
"(",
")",
")",
";",
"if",
"(",
"stack",
".",
"getStackDepth",
"(",
")",
">",
"argCount",
")",
"{",
"OpcodeStack",
".",
"Item",
"item",
"=",
"stack",
".",
"getStackItem",
"(",
"0",
")",
";",
"if",
"(",
"S508UserValue",
".",
"FROM_UIMANAGER",
"!=",
"item",
".",
"getUserValue",
"(",
")",
")",
"{",
"item",
"=",
"stack",
".",
"getStackItem",
"(",
"argCount",
")",
";",
"JavaClass",
"cls",
"=",
"item",
".",
"getJavaClass",
"(",
")",
";",
"if",
"(",
"(",
"(",
"jcomponentClass",
"!=",
"null",
")",
"&&",
"cls",
".",
"instanceOf",
"(",
"jcomponentClass",
")",
")",
"||",
"(",
"(",
"componentClass",
"!=",
"null",
")",
"&&",
"cls",
".",
"instanceOf",
"(",
"componentClass",
")",
")",
")",
"{",
"bugReporter",
".",
"reportBug",
"(",
"new",
"BugInstance",
"(",
"this",
",",
"BugType",
".",
"S508C_SET_COMP_COLOR",
".",
"name",
"(",
")",
",",
"NORMAL_PRIORITY",
")",
".",
"addClass",
"(",
"this",
")",
".",
"addMethod",
"(",
"this",
")",
".",
"addSourceLine",
"(",
"this",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | looks for calls to set the color of components where the color isn't from UIManager
@param methodName
the method that is called
@throws ClassNotFoundException
if the gui component class can't be found | [
"looks",
"for",
"calls",
"to",
"set",
"the",
"color",
"of",
"components",
"where",
"the",
"color",
"isn",
"t",
"from",
"UIManager"
] | train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java#L382-L397 |
voldemort/voldemort | src/java/voldemort/routing/StoreRoutingPlan.java | StoreRoutingPlan.getNodesPartitionIdForKey | public Integer getNodesPartitionIdForKey(int nodeId, final byte[] key) {
"""
Determines the partition ID that replicates the key on the given node.
@param nodeId of the node
@param key to look up.
@return partitionId if found, otherwise null.
"""
// this is all the partitions the key replicates to.
List<Integer> partitionIds = getReplicatingPartitionList(key);
for(Integer partitionId: partitionIds) {
// check which of the replicating partitions belongs to the node in
// question
if(getNodeIdForPartitionId(partitionId) == nodeId) {
return partitionId;
}
}
return null;
} | java | public Integer getNodesPartitionIdForKey(int nodeId, final byte[] key) {
// this is all the partitions the key replicates to.
List<Integer> partitionIds = getReplicatingPartitionList(key);
for(Integer partitionId: partitionIds) {
// check which of the replicating partitions belongs to the node in
// question
if(getNodeIdForPartitionId(partitionId) == nodeId) {
return partitionId;
}
}
return null;
} | [
"public",
"Integer",
"getNodesPartitionIdForKey",
"(",
"int",
"nodeId",
",",
"final",
"byte",
"[",
"]",
"key",
")",
"{",
"// this is all the partitions the key replicates to.",
"List",
"<",
"Integer",
">",
"partitionIds",
"=",
"getReplicatingPartitionList",
"(",
"key",
")",
";",
"for",
"(",
"Integer",
"partitionId",
":",
"partitionIds",
")",
"{",
"// check which of the replicating partitions belongs to the node in",
"// question",
"if",
"(",
"getNodeIdForPartitionId",
"(",
"partitionId",
")",
"==",
"nodeId",
")",
"{",
"return",
"partitionId",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Determines the partition ID that replicates the key on the given node.
@param nodeId of the node
@param key to look up.
@return partitionId if found, otherwise null. | [
"Determines",
"the",
"partition",
"ID",
"that",
"replicates",
"the",
"key",
"on",
"the",
"given",
"node",
"."
] | train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/routing/StoreRoutingPlan.java#L214-L225 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jca.inbound.security/src/com/ibm/ws/jca/security/internal/J2CSecurityHelper.java | J2CSecurityHelper.updateCustomHashtable | private static void updateCustomHashtable(Hashtable<String, Object> credData, String realmName, String uniqueId, String securityName, List<?> groupList) {
"""
This method updates the hashtable provided with the information that is required for custom hashtable
login. The hashtable should contain the following parameters for this to succeed.
Key: com.ibm.wsspi.security.cred.uniqueId, Value: user: ldap.austin.ibm.com:389/cn=pbirk,o=ibm,c=us
Key: com.ibm.wsspi.security.cred.realm, Value: ldap.austin.ibm.com:389
Key: com.ibm.wsspi.security.cred.securityName, Value: pbirk
Key: com.ibm.wsspi.security.cred.longSecurityName, Value: cn=pbirk,o=ibm,c=us (Optional)
Key: com.ibm.wsspi.security.cred.groups, Value: group:cn=group1,o=ibm,c=us| group:cn=group2,o=ibm,c=us|group:cn=group3,o=ibm,c=us
Key: com.ibm.wsspi.security.cred.cacheKey, Value: Location:9.43.21.23 (note: accessID gets appended to this value for cache lookup).
@param credData The hashtable that we are going to populate with the required properties
@param realmName The name of the realm that this user belongs to
@param uniqueId The uniqueId of the user
@param securityName The securityName of the user.
@param groupList The list of groups that this user belongs to.
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "updateCustomHashtable", new Object[] { credData, realmName, uniqueId, securityName, groupList });
}
String cacheKey = getCacheKey(uniqueId, realmName);
credData.put(AttributeNameConstants.WSCREDENTIAL_CACHE_KEY, cacheKey);
credData.put(AttributeNameConstants.WSCREDENTIAL_REALM, realmName);
credData.put(AttributeNameConstants.WSCREDENTIAL_SECURITYNAME, securityName);
if (uniqueId != null) {
credData.put(AttributeNameConstants.WSCREDENTIAL_UNIQUEID, uniqueId);
}
// If uniqueId is not set then the login will fail later and the work will not execute
if (groupList != null && !groupList.isEmpty()) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Adding groups found in registry", groupList);
}
credData.put(AttributeNameConstants.WSCREDENTIAL_GROUPS, groupList);
} else {
credData.put(AttributeNameConstants.WSCREDENTIAL_GROUPS, new ArrayList<String>());
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "updateCustomHashtable");
}
} | java | private static void updateCustomHashtable(Hashtable<String, Object> credData, String realmName, String uniqueId, String securityName, List<?> groupList) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "updateCustomHashtable", new Object[] { credData, realmName, uniqueId, securityName, groupList });
}
String cacheKey = getCacheKey(uniqueId, realmName);
credData.put(AttributeNameConstants.WSCREDENTIAL_CACHE_KEY, cacheKey);
credData.put(AttributeNameConstants.WSCREDENTIAL_REALM, realmName);
credData.put(AttributeNameConstants.WSCREDENTIAL_SECURITYNAME, securityName);
if (uniqueId != null) {
credData.put(AttributeNameConstants.WSCREDENTIAL_UNIQUEID, uniqueId);
}
// If uniqueId is not set then the login will fail later and the work will not execute
if (groupList != null && !groupList.isEmpty()) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Adding groups found in registry", groupList);
}
credData.put(AttributeNameConstants.WSCREDENTIAL_GROUPS, groupList);
} else {
credData.put(AttributeNameConstants.WSCREDENTIAL_GROUPS, new ArrayList<String>());
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "updateCustomHashtable");
}
} | [
"private",
"static",
"void",
"updateCustomHashtable",
"(",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"credData",
",",
"String",
"realmName",
",",
"String",
"uniqueId",
",",
"String",
"securityName",
",",
"List",
"<",
"?",
">",
"groupList",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"updateCustomHashtable\"",
",",
"new",
"Object",
"[",
"]",
"{",
"credData",
",",
"realmName",
",",
"uniqueId",
",",
"securityName",
",",
"groupList",
"}",
")",
";",
"}",
"String",
"cacheKey",
"=",
"getCacheKey",
"(",
"uniqueId",
",",
"realmName",
")",
";",
"credData",
".",
"put",
"(",
"AttributeNameConstants",
".",
"WSCREDENTIAL_CACHE_KEY",
",",
"cacheKey",
")",
";",
"credData",
".",
"put",
"(",
"AttributeNameConstants",
".",
"WSCREDENTIAL_REALM",
",",
"realmName",
")",
";",
"credData",
".",
"put",
"(",
"AttributeNameConstants",
".",
"WSCREDENTIAL_SECURITYNAME",
",",
"securityName",
")",
";",
"if",
"(",
"uniqueId",
"!=",
"null",
")",
"{",
"credData",
".",
"put",
"(",
"AttributeNameConstants",
".",
"WSCREDENTIAL_UNIQUEID",
",",
"uniqueId",
")",
";",
"}",
"// If uniqueId is not set then the login will fail later and the work will not execute",
"if",
"(",
"groupList",
"!=",
"null",
"&&",
"!",
"groupList",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Adding groups found in registry\"",
",",
"groupList",
")",
";",
"}",
"credData",
".",
"put",
"(",
"AttributeNameConstants",
".",
"WSCREDENTIAL_GROUPS",
",",
"groupList",
")",
";",
"}",
"else",
"{",
"credData",
".",
"put",
"(",
"AttributeNameConstants",
".",
"WSCREDENTIAL_GROUPS",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"updateCustomHashtable\"",
")",
";",
"}",
"}"
] | This method updates the hashtable provided with the information that is required for custom hashtable
login. The hashtable should contain the following parameters for this to succeed.
Key: com.ibm.wsspi.security.cred.uniqueId, Value: user: ldap.austin.ibm.com:389/cn=pbirk,o=ibm,c=us
Key: com.ibm.wsspi.security.cred.realm, Value: ldap.austin.ibm.com:389
Key: com.ibm.wsspi.security.cred.securityName, Value: pbirk
Key: com.ibm.wsspi.security.cred.longSecurityName, Value: cn=pbirk,o=ibm,c=us (Optional)
Key: com.ibm.wsspi.security.cred.groups, Value: group:cn=group1,o=ibm,c=us| group:cn=group2,o=ibm,c=us|group:cn=group3,o=ibm,c=us
Key: com.ibm.wsspi.security.cred.cacheKey, Value: Location:9.43.21.23 (note: accessID gets appended to this value for cache lookup).
@param credData The hashtable that we are going to populate with the required properties
@param realmName The name of the realm that this user belongs to
@param uniqueId The uniqueId of the user
@param securityName The securityName of the user.
@param groupList The list of groups that this user belongs to. | [
"This",
"method",
"updates",
"the",
"hashtable",
"provided",
"with",
"the",
"information",
"that",
"is",
"required",
"for",
"custom",
"hashtable",
"login",
".",
"The",
"hashtable",
"should",
"contain",
"the",
"following",
"parameters",
"for",
"this",
"to",
"succeed",
".",
"Key",
":",
"com",
".",
"ibm",
".",
"wsspi",
".",
"security",
".",
"cred",
".",
"uniqueId",
"Value",
":",
"user",
":",
"ldap",
".",
"austin",
".",
"ibm",
".",
"com",
":",
"389",
"/",
"cn",
"=",
"pbirk",
"o",
"=",
"ibm",
"c",
"=",
"us",
"Key",
":",
"com",
".",
"ibm",
".",
"wsspi",
".",
"security",
".",
"cred",
".",
"realm",
"Value",
":",
"ldap",
".",
"austin",
".",
"ibm",
".",
"com",
":",
"389",
"Key",
":",
"com",
".",
"ibm",
".",
"wsspi",
".",
"security",
".",
"cred",
".",
"securityName",
"Value",
":",
"pbirk",
"Key",
":",
"com",
".",
"ibm",
".",
"wsspi",
".",
"security",
".",
"cred",
".",
"longSecurityName",
"Value",
":",
"cn",
"=",
"pbirk",
"o",
"=",
"ibm",
"c",
"=",
"us",
"(",
"Optional",
")",
"Key",
":",
"com",
".",
"ibm",
".",
"wsspi",
".",
"security",
".",
"cred",
".",
"groups",
"Value",
":",
"group",
":",
"cn",
"=",
"group1",
"o",
"=",
"ibm",
"c",
"=",
"us|",
"group",
":",
"cn",
"=",
"group2",
"o",
"=",
"ibm",
"c",
"=",
"us|group",
":",
"cn",
"=",
"group3",
"o",
"=",
"ibm",
"c",
"=",
"us",
"Key",
":",
"com",
".",
"ibm",
".",
"wsspi",
".",
"security",
".",
"cred",
".",
"cacheKey",
"Value",
":",
"Location",
":",
"9",
".",
"43",
".",
"21",
".",
"23",
"(",
"note",
":",
"accessID",
"gets",
"appended",
"to",
"this",
"value",
"for",
"cache",
"lookup",
")",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jca.inbound.security/src/com/ibm/ws/jca/security/internal/J2CSecurityHelper.java#L82-L105 |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/pattern/Patterns.java | Patterns.times | public static Pattern times(final int min, final int max, final CharPredicate predicate) {
"""
Returns a {@link Pattern} that matches at least {@code min} and up to {@code max} number of characters satisfying
{@code predicate},
@since 2.2
"""
Checks.checkMinMax(min, max);
return new Pattern() {
@Override
public int match(CharSequence src, int begin, int end) {
int minLen = RepeatCharPredicatePattern.matchRepeat(min, predicate, src, end, begin, 0);
if (minLen == MISMATCH)
return MISMATCH;
return matchSome(max - min, predicate, src, end, begin + minLen, minLen);
}
};
} | java | public static Pattern times(final int min, final int max, final CharPredicate predicate) {
Checks.checkMinMax(min, max);
return new Pattern() {
@Override
public int match(CharSequence src, int begin, int end) {
int minLen = RepeatCharPredicatePattern.matchRepeat(min, predicate, src, end, begin, 0);
if (minLen == MISMATCH)
return MISMATCH;
return matchSome(max - min, predicate, src, end, begin + minLen, minLen);
}
};
} | [
"public",
"static",
"Pattern",
"times",
"(",
"final",
"int",
"min",
",",
"final",
"int",
"max",
",",
"final",
"CharPredicate",
"predicate",
")",
"{",
"Checks",
".",
"checkMinMax",
"(",
"min",
",",
"max",
")",
";",
"return",
"new",
"Pattern",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"match",
"(",
"CharSequence",
"src",
",",
"int",
"begin",
",",
"int",
"end",
")",
"{",
"int",
"minLen",
"=",
"RepeatCharPredicatePattern",
".",
"matchRepeat",
"(",
"min",
",",
"predicate",
",",
"src",
",",
"end",
",",
"begin",
",",
"0",
")",
";",
"if",
"(",
"minLen",
"==",
"MISMATCH",
")",
"return",
"MISMATCH",
";",
"return",
"matchSome",
"(",
"max",
"-",
"min",
",",
"predicate",
",",
"src",
",",
"end",
",",
"begin",
"+",
"minLen",
",",
"minLen",
")",
";",
"}",
"}",
";",
"}"
] | Returns a {@link Pattern} that matches at least {@code min} and up to {@code max} number of characters satisfying
{@code predicate},
@since 2.2 | [
"Returns",
"a",
"{",
"@link",
"Pattern",
"}",
"that",
"matches",
"at",
"least",
"{",
"@code",
"min",
"}",
"and",
"up",
"to",
"{",
"@code",
"max",
"}",
"number",
"of",
"characters",
"satisfying",
"{",
"@code",
"predicate",
"}"
] | train | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/pattern/Patterns.java#L411-L422 |
grails/gorm-hibernate5 | grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateCriteriaBuilder.java | AbstractHibernateCriteriaBuilder.sqlGroupProjection | protected void sqlGroupProjection(String sql, String groupBy, List<String> columnAliases, List<Type> types) {
"""
Adds a sql projection to the criteria
@param sql SQL projecting
@param groupBy group by clause
@param columnAliases List of column aliases for the projected values
@param types List of types for the projected values
"""
projectionList.add(Projections.sqlGroupProjection(sql, groupBy, columnAliases.toArray(new String[columnAliases.size()]), types.toArray(new Type[types.size()])));
} | java | protected void sqlGroupProjection(String sql, String groupBy, List<String> columnAliases, List<Type> types) {
projectionList.add(Projections.sqlGroupProjection(sql, groupBy, columnAliases.toArray(new String[columnAliases.size()]), types.toArray(new Type[types.size()])));
} | [
"protected",
"void",
"sqlGroupProjection",
"(",
"String",
"sql",
",",
"String",
"groupBy",
",",
"List",
"<",
"String",
">",
"columnAliases",
",",
"List",
"<",
"Type",
">",
"types",
")",
"{",
"projectionList",
".",
"add",
"(",
"Projections",
".",
"sqlGroupProjection",
"(",
"sql",
",",
"groupBy",
",",
"columnAliases",
".",
"toArray",
"(",
"new",
"String",
"[",
"columnAliases",
".",
"size",
"(",
")",
"]",
")",
",",
"types",
".",
"toArray",
"(",
"new",
"Type",
"[",
"types",
".",
"size",
"(",
")",
"]",
")",
")",
")",
";",
"}"
] | Adds a sql projection to the criteria
@param sql SQL projecting
@param groupBy group by clause
@param columnAliases List of column aliases for the projected values
@param types List of types for the projected values | [
"Adds",
"a",
"sql",
"projection",
"to",
"the",
"criteria"
] | train | https://github.com/grails/gorm-hibernate5/blob/0ebb80cd769ef2bea955723d4543828a3e9542ef/grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateCriteriaBuilder.java#L186-L188 |
bigdata-mx/factura-electronica | src/main/java/mx/bigdata/sat/security/PrivateKeyLoader.java | PrivateKeyLoader.setPrivateKey | public void setPrivateKey(String privateKeyLocation, String keyPassword) {
"""
@param privateKeyLocation private key located in filesystem
@param keyPassword private key password
@throws KeyException thrown when any security exception occurs
"""
InputStream privateKeyInputStream = null;
try {
privateKeyInputStream = new FileInputStream(privateKeyLocation);
}catch (FileNotFoundException fnfe){
throw new KeyException("La ubicación del archivo de la llave privada es incorrecta", fnfe.getCause());
}
this.setPrivateKey(privateKeyInputStream, keyPassword);
} | java | public void setPrivateKey(String privateKeyLocation, String keyPassword) {
InputStream privateKeyInputStream = null;
try {
privateKeyInputStream = new FileInputStream(privateKeyLocation);
}catch (FileNotFoundException fnfe){
throw new KeyException("La ubicación del archivo de la llave privada es incorrecta", fnfe.getCause());
}
this.setPrivateKey(privateKeyInputStream, keyPassword);
} | [
"public",
"void",
"setPrivateKey",
"(",
"String",
"privateKeyLocation",
",",
"String",
"keyPassword",
")",
"{",
"InputStream",
"privateKeyInputStream",
"=",
"null",
";",
"try",
"{",
"privateKeyInputStream",
"=",
"new",
"FileInputStream",
"(",
"privateKeyLocation",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"fnfe",
")",
"{",
"throw",
"new",
"KeyException",
"(",
"\"La ubicación del archivo de la llave privada es incorrecta\",",
" ",
"nfe.",
"g",
"etCause(",
")",
")",
";",
"",
"}",
"this",
".",
"setPrivateKey",
"(",
"privateKeyInputStream",
",",
"keyPassword",
")",
";",
"}"
] | @param privateKeyLocation private key located in filesystem
@param keyPassword private key password
@throws KeyException thrown when any security exception occurs | [
"@param",
"privateKeyLocation",
"private",
"key",
"located",
"in",
"filesystem",
"@param",
"keyPassword",
"private",
"key",
"password"
] | train | https://github.com/bigdata-mx/factura-electronica/blob/ca9b06039075bc3b06e64b080c3545c937e35003/src/main/java/mx/bigdata/sat/security/PrivateKeyLoader.java#L44-L55 |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.serializeConfiguredHashinator | public static HashinatorSnapshotData serializeConfiguredHashinator()
throws IOException {
"""
Get optimized configuration data for wire serialization.
@return optimized configuration data
@throws IOException
"""
Pair<Long, ? extends TheHashinator> currentInstance = instance.get();
byte[] cookedData = currentInstance.getSecond().getCookedBytes();
return new HashinatorSnapshotData(cookedData, currentInstance.getFirst());
} | java | public static HashinatorSnapshotData serializeConfiguredHashinator()
throws IOException
{
Pair<Long, ? extends TheHashinator> currentInstance = instance.get();
byte[] cookedData = currentInstance.getSecond().getCookedBytes();
return new HashinatorSnapshotData(cookedData, currentInstance.getFirst());
} | [
"public",
"static",
"HashinatorSnapshotData",
"serializeConfiguredHashinator",
"(",
")",
"throws",
"IOException",
"{",
"Pair",
"<",
"Long",
",",
"?",
"extends",
"TheHashinator",
">",
"currentInstance",
"=",
"instance",
".",
"get",
"(",
")",
";",
"byte",
"[",
"]",
"cookedData",
"=",
"currentInstance",
".",
"getSecond",
"(",
")",
".",
"getCookedBytes",
"(",
")",
";",
"return",
"new",
"HashinatorSnapshotData",
"(",
"cookedData",
",",
"currentInstance",
".",
"getFirst",
"(",
")",
")",
";",
"}"
] | Get optimized configuration data for wire serialization.
@return optimized configuration data
@throws IOException | [
"Get",
"optimized",
"configuration",
"data",
"for",
"wire",
"serialization",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L427-L433 |
alibaba/jstorm | jstorm-on-yarn/src/main/java/com/alibaba/jstorm/yarn/utils/JstormYarnUtils.java | JstormYarnUtils.isPortAvailable | public static boolean isPortAvailable(String host, int port) {
"""
See if a port is available for listening on by trying connect to it
and seeing if that works or fails
@param host
@param port
@return
"""
try {
Socket socket = new Socket(host, port);
socket.close();
return false;
} catch (IOException e) {
return true;
}
} | java | public static boolean isPortAvailable(String host, int port) {
try {
Socket socket = new Socket(host, port);
socket.close();
return false;
} catch (IOException e) {
return true;
}
} | [
"public",
"static",
"boolean",
"isPortAvailable",
"(",
"String",
"host",
",",
"int",
"port",
")",
"{",
"try",
"{",
"Socket",
"socket",
"=",
"new",
"Socket",
"(",
"host",
",",
"port",
")",
";",
"socket",
".",
"close",
"(",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"true",
";",
"}",
"}"
] | See if a port is available for listening on by trying connect to it
and seeing if that works or fails
@param host
@param port
@return | [
"See",
"if",
"a",
"port",
"is",
"available",
"for",
"listening",
"on",
"by",
"trying",
"connect",
"to",
"it",
"and",
"seeing",
"if",
"that",
"works",
"or",
"fails"
] | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-on-yarn/src/main/java/com/alibaba/jstorm/yarn/utils/JstormYarnUtils.java#L121-L129 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/processor/XSLTElementDef.java | XSLTElementDef.equalsMayBeNullOrZeroLen | private static boolean equalsMayBeNullOrZeroLen(String s1, String s2) {
"""
Tell if the two string refs are equal,
equality being defined as:
1) Both strings are null.
2) One string is null and the other is empty.
3) Both strings are non-null, and equal.
@param s1 A reference to the first string, or null.
@param s2 A reference to the second string, or null.
@return true if Both strings are null, or if
one string is null and the other is empty, or if
both strings are non-null, and equal because
s1.equals(s2) returns true.
"""
int len1 = (s1 == null) ? 0 : s1.length();
int len2 = (s2 == null) ? 0 : s2.length();
return (len1 != len2) ? false
: (len1 == 0) ? true
: s1.equals(s2);
} | java | private static boolean equalsMayBeNullOrZeroLen(String s1, String s2)
{
int len1 = (s1 == null) ? 0 : s1.length();
int len2 = (s2 == null) ? 0 : s2.length();
return (len1 != len2) ? false
: (len1 == 0) ? true
: s1.equals(s2);
} | [
"private",
"static",
"boolean",
"equalsMayBeNullOrZeroLen",
"(",
"String",
"s1",
",",
"String",
"s2",
")",
"{",
"int",
"len1",
"=",
"(",
"s1",
"==",
"null",
")",
"?",
"0",
":",
"s1",
".",
"length",
"(",
")",
";",
"int",
"len2",
"=",
"(",
"s2",
"==",
"null",
")",
"?",
"0",
":",
"s2",
".",
"length",
"(",
")",
";",
"return",
"(",
"len1",
"!=",
"len2",
")",
"?",
"false",
":",
"(",
"len1",
"==",
"0",
")",
"?",
"true",
":",
"s1",
".",
"equals",
"(",
"s2",
")",
";",
"}"
] | Tell if the two string refs are equal,
equality being defined as:
1) Both strings are null.
2) One string is null and the other is empty.
3) Both strings are non-null, and equal.
@param s1 A reference to the first string, or null.
@param s2 A reference to the second string, or null.
@return true if Both strings are null, or if
one string is null and the other is empty, or if
both strings are non-null, and equal because
s1.equals(s2) returns true. | [
"Tell",
"if",
"the",
"two",
"string",
"refs",
"are",
"equal",
"equality",
"being",
"defined",
"as",
":",
"1",
")",
"Both",
"strings",
"are",
"null",
".",
"2",
")",
"One",
"string",
"is",
"null",
"and",
"the",
"other",
"is",
"empty",
".",
"3",
")",
"Both",
"strings",
"are",
"non",
"-",
"null",
"and",
"equal",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/processor/XSLTElementDef.java#L326-L335 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/SeaGlassLookAndFeel.java | SeaGlassLookAndFeel.definePanels | private void definePanels(UIDefaults d) {
"""
Initialize the panel settings.
@param d the UI defaults map.
"""
String p = "Panel";
d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
d.put(p + ".background", new ColorUIResource((Color) d.get("control")));
d.put(p + ".opaque", Boolean.TRUE);
} | java | private void definePanels(UIDefaults d) {
String p = "Panel";
d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
d.put(p + ".background", new ColorUIResource((Color) d.get("control")));
d.put(p + ".opaque", Boolean.TRUE);
} | [
"private",
"void",
"definePanels",
"(",
"UIDefaults",
"d",
")",
"{",
"String",
"p",
"=",
"\"Panel\"",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".contentMargins\"",
",",
"new",
"InsetsUIResource",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".background\"",
",",
"new",
"ColorUIResource",
"(",
"(",
"Color",
")",
"d",
".",
"get",
"(",
"\"control\"",
")",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".opaque\"",
",",
"Boolean",
".",
"TRUE",
")",
";",
"}"
] | Initialize the panel settings.
@param d the UI defaults map. | [
"Initialize",
"the",
"panel",
"settings",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/SeaGlassLookAndFeel.java#L1560-L1565 |
forge/furnace | container-api/src/main/java/org/jboss/forge/furnace/util/Strings.java | Strings.rangeOf | public static Range rangeOf(final String beginToken, final String endToken,
final String string) {
"""
Return the range from a begining token to an ending token.
@param beginToken String to indicate begining of range.
@param endToken String to indicate ending of range.
@param string String to look for range in.
@return (begin index, end index) or <i>null</i>.
"""
return rangeOf(beginToken, endToken, string, 0);
} | java | public static Range rangeOf(final String beginToken, final String endToken,
final String string)
{
return rangeOf(beginToken, endToken, string, 0);
} | [
"public",
"static",
"Range",
"rangeOf",
"(",
"final",
"String",
"beginToken",
",",
"final",
"String",
"endToken",
",",
"final",
"String",
"string",
")",
"{",
"return",
"rangeOf",
"(",
"beginToken",
",",
"endToken",
",",
"string",
",",
"0",
")",
";",
"}"
] | Return the range from a begining token to an ending token.
@param beginToken String to indicate begining of range.
@param endToken String to indicate ending of range.
@param string String to look for range in.
@return (begin index, end index) or <i>null</i>. | [
"Return",
"the",
"range",
"from",
"a",
"begining",
"token",
"to",
"an",
"ending",
"token",
"."
] | train | https://github.com/forge/furnace/blob/bbe6deaa3c0d85ba43daa3e2f7d486f2dad21e0a/container-api/src/main/java/org/jboss/forge/furnace/util/Strings.java#L384-L388 |
boncey/Flickr4Java | src/main/java/com/flickr4java/flickr/photos/SearchParameters.java | SearchParameters.setMedia | public void setMedia(String media) throws FlickrException {
"""
Filter results by media type. Possible values are all (default), photos or videos.
@param media
"""
if (media.equals("all") || media.equals("photos") || media.equals("videos")) {
this.media = media;
} else {
throw new FlickrException("0", "Media type is not valid.");
}
} | java | public void setMedia(String media) throws FlickrException {
if (media.equals("all") || media.equals("photos") || media.equals("videos")) {
this.media = media;
} else {
throw new FlickrException("0", "Media type is not valid.");
}
} | [
"public",
"void",
"setMedia",
"(",
"String",
"media",
")",
"throws",
"FlickrException",
"{",
"if",
"(",
"media",
".",
"equals",
"(",
"\"all\"",
")",
"||",
"media",
".",
"equals",
"(",
"\"photos\"",
")",
"||",
"media",
".",
"equals",
"(",
"\"videos\"",
")",
")",
"{",
"this",
".",
"media",
"=",
"media",
";",
"}",
"else",
"{",
"throw",
"new",
"FlickrException",
"(",
"\"0\"",
",",
"\"Media type is not valid.\"",
")",
";",
"}",
"}"
] | Filter results by media type. Possible values are all (default), photos or videos.
@param media | [
"Filter",
"results",
"by",
"media",
"type",
".",
"Possible",
"values",
"are",
"all",
"(",
"default",
")",
"photos",
"or",
"videos",
"."
] | train | https://github.com/boncey/Flickr4Java/blob/f66987ba0e360e5fb7730efbbb8c51f3d978fc25/src/main/java/com/flickr4java/flickr/photos/SearchParameters.java#L457-L463 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.