repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
Omertron/api-rottentomatoes | src/main/java/com/omertron/rottentomatoesapi/RottenTomatoesApi.java | RottenTomatoesApi.getInTheaters | public List<RTMovie> getInTheaters(String country) throws RottenTomatoesException {
"""
Retrieves movies currently in theaters
@param country Provides localized data for the selected country
@return
@throws RottenTomatoesException
"""
return getInTheaters(country, DEFAULT_PAGE, DEFAULT_PAGE_LIMIT);
} | java | public List<RTMovie> getInTheaters(String country) throws RottenTomatoesException {
return getInTheaters(country, DEFAULT_PAGE, DEFAULT_PAGE_LIMIT);
} | [
"public",
"List",
"<",
"RTMovie",
">",
"getInTheaters",
"(",
"String",
"country",
")",
"throws",
"RottenTomatoesException",
"{",
"return",
"getInTheaters",
"(",
"country",
",",
"DEFAULT_PAGE",
",",
"DEFAULT_PAGE_LIMIT",
")",
";",
"}"
]
| Retrieves movies currently in theaters
@param country Provides localized data for the selected country
@return
@throws RottenTomatoesException | [
"Retrieves",
"movies",
"currently",
"in",
"theaters"
]
| train | https://github.com/Omertron/api-rottentomatoes/blob/abaf1833acafc6ada593d52b14ff1bacb4e441ee/src/main/java/com/omertron/rottentomatoesapi/RottenTomatoesApi.java#L218-L220 |
roboconf/roboconf-platform | core/roboconf-dm-rest-commons/src/main/java/net/roboconf/dm/rest/commons/security/AuthenticationManager.java | AuthenticationManager.login | public String login( String user, String pwd ) {
"""
Authenticates a user and creates a new session.
@param user a user name
@param pwd a pass word
@return a token if authentication worked, null if it failed
"""
String token = null;
try {
this.authService.authenticate( user, pwd );
token = UUID.randomUUID().toString();
Long now = new Date().getTime();
this.tokenToLoginTime.put( token, now );
this.tokenToUsername.put( token, user );
} catch( LoginException e ) {
this.logger.severe( "Invalid login attempt by user " + user );
}
return token;
} | java | public String login( String user, String pwd ) {
String token = null;
try {
this.authService.authenticate( user, pwd );
token = UUID.randomUUID().toString();
Long now = new Date().getTime();
this.tokenToLoginTime.put( token, now );
this.tokenToUsername.put( token, user );
} catch( LoginException e ) {
this.logger.severe( "Invalid login attempt by user " + user );
}
return token;
} | [
"public",
"String",
"login",
"(",
"String",
"user",
",",
"String",
"pwd",
")",
"{",
"String",
"token",
"=",
"null",
";",
"try",
"{",
"this",
".",
"authService",
".",
"authenticate",
"(",
"user",
",",
"pwd",
")",
";",
"token",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"Long",
"now",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"this",
".",
"tokenToLoginTime",
".",
"put",
"(",
"token",
",",
"now",
")",
";",
"this",
".",
"tokenToUsername",
".",
"put",
"(",
"token",
",",
"user",
")",
";",
"}",
"catch",
"(",
"LoginException",
"e",
")",
"{",
"this",
".",
"logger",
".",
"severe",
"(",
"\"Invalid login attempt by user \"",
"+",
"user",
")",
";",
"}",
"return",
"token",
";",
"}"
]
| Authenticates a user and creates a new session.
@param user a user name
@param pwd a pass word
@return a token if authentication worked, null if it failed | [
"Authenticates",
"a",
"user",
"and",
"creates",
"a",
"new",
"session",
"."
]
| train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm-rest-commons/src/main/java/net/roboconf/dm/rest/commons/security/AuthenticationManager.java#L103-L119 |
google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.trackMessage | private void trackMessage(
NodeTraversal t, JsMessage message, String msgName,
Node msgNode, boolean isUnnamedMessage) {
"""
Track a message for later retrieval.
This is used for tracking duplicates, and for figuring out message
fallback. Not all message types are trackable, because that would
require a more sophisticated analysis. e.g.,
function f(s) { s.MSG_UNNAMED_X = 'Some untrackable message'; }
"""
if (!isUnnamedMessage) {
MessageLocation location = new MessageLocation(message, msgNode);
messageNames.put(msgName, location);
} else {
Var var = t.getScope().getVar(msgName);
if (var != null) {
unnamedMessages.put(var, message);
}
}
} | java | private void trackMessage(
NodeTraversal t, JsMessage message, String msgName,
Node msgNode, boolean isUnnamedMessage) {
if (!isUnnamedMessage) {
MessageLocation location = new MessageLocation(message, msgNode);
messageNames.put(msgName, location);
} else {
Var var = t.getScope().getVar(msgName);
if (var != null) {
unnamedMessages.put(var, message);
}
}
} | [
"private",
"void",
"trackMessage",
"(",
"NodeTraversal",
"t",
",",
"JsMessage",
"message",
",",
"String",
"msgName",
",",
"Node",
"msgNode",
",",
"boolean",
"isUnnamedMessage",
")",
"{",
"if",
"(",
"!",
"isUnnamedMessage",
")",
"{",
"MessageLocation",
"location",
"=",
"new",
"MessageLocation",
"(",
"message",
",",
"msgNode",
")",
";",
"messageNames",
".",
"put",
"(",
"msgName",
",",
"location",
")",
";",
"}",
"else",
"{",
"Var",
"var",
"=",
"t",
".",
"getScope",
"(",
")",
".",
"getVar",
"(",
"msgName",
")",
";",
"if",
"(",
"var",
"!=",
"null",
")",
"{",
"unnamedMessages",
".",
"put",
"(",
"var",
",",
"message",
")",
";",
"}",
"}",
"}"
]
| Track a message for later retrieval.
This is used for tracking duplicates, and for figuring out message
fallback. Not all message types are trackable, because that would
require a more sophisticated analysis. e.g.,
function f(s) { s.MSG_UNNAMED_X = 'Some untrackable message'; } | [
"Track",
"a",
"message",
"for",
"later",
"retrieval",
"."
]
| train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L346-L358 |
artikcloud/artikcloud-java | src/main/java/cloud/artik/api/DevicesManagementApi.java | DevicesManagementApi.getStatusesHistory | public TaskStatusesHistoryEnvelope getStatusesHistory(String tid, String did) throws ApiException {
"""
Returns the history of the status changes for a specific task id, or for a specific device id in that task.
Returns the history of the status changes for a specific task id, or for a specific device id in that task.
@param tid Task ID. (required)
@param did Device ID. Optional. (optional)
@return TaskStatusesHistoryEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<TaskStatusesHistoryEnvelope> resp = getStatusesHistoryWithHttpInfo(tid, did);
return resp.getData();
} | java | public TaskStatusesHistoryEnvelope getStatusesHistory(String tid, String did) throws ApiException {
ApiResponse<TaskStatusesHistoryEnvelope> resp = getStatusesHistoryWithHttpInfo(tid, did);
return resp.getData();
} | [
"public",
"TaskStatusesHistoryEnvelope",
"getStatusesHistory",
"(",
"String",
"tid",
",",
"String",
"did",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"TaskStatusesHistoryEnvelope",
">",
"resp",
"=",
"getStatusesHistoryWithHttpInfo",
"(",
"tid",
",",
"did",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
]
| Returns the history of the status changes for a specific task id, or for a specific device id in that task.
Returns the history of the status changes for a specific task id, or for a specific device id in that task.
@param tid Task ID. (required)
@param did Device ID. Optional. (optional)
@return TaskStatusesHistoryEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Returns",
"the",
"history",
"of",
"the",
"status",
"changes",
"for",
"a",
"specific",
"task",
"id",
"or",
"for",
"a",
"specific",
"device",
"id",
"in",
"that",
"task",
".",
"Returns",
"the",
"history",
"of",
"the",
"status",
"changes",
"for",
"a",
"specific",
"task",
"id",
"or",
"for",
"a",
"specific",
"device",
"id",
"in",
"that",
"task",
"."
]
| train | https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/DevicesManagementApi.java#L1023-L1026 |
gosu-lang/gosu-lang | gosu-core-api/src/main/java/gw/lang/reflect/BeanInfoUtil.java | BeanInfoUtil.buildScriptableMethodDescriptorNoArgs | public static MethodDescriptor buildScriptableMethodDescriptorNoArgs( Class actionClass, String methodName ) {
"""
Builds a no-arg method descriptor that is exposed for scripting everywhere.
"""
MethodDescriptor md = _buildMethodDescriptor( actionClass, methodName, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_CLASS_ARRAY );
makeScriptable( md );
return md;
} | java | public static MethodDescriptor buildScriptableMethodDescriptorNoArgs( Class actionClass, String methodName )
{
MethodDescriptor md = _buildMethodDescriptor( actionClass, methodName, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_CLASS_ARRAY );
makeScriptable( md );
return md;
} | [
"public",
"static",
"MethodDescriptor",
"buildScriptableMethodDescriptorNoArgs",
"(",
"Class",
"actionClass",
",",
"String",
"methodName",
")",
"{",
"MethodDescriptor",
"md",
"=",
"_buildMethodDescriptor",
"(",
"actionClass",
",",
"methodName",
",",
"EMPTY_STRING_ARRAY",
",",
"EMPTY_CLASS_ARRAY",
",",
"EMPTY_CLASS_ARRAY",
")",
";",
"makeScriptable",
"(",
"md",
")",
";",
"return",
"md",
";",
"}"
]
| Builds a no-arg method descriptor that is exposed for scripting everywhere. | [
"Builds",
"a",
"no",
"-",
"arg",
"method",
"descriptor",
"that",
"is",
"exposed",
"for",
"scripting",
"everywhere",
"."
]
| train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/lang/reflect/BeanInfoUtil.java#L33-L38 |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/view/StripeEditText.java | StripeEditText.setHintDelayed | public void setHintDelayed(@StringRes final int hintResource, long delayMilliseconds) {
"""
Change the hint value of this control after a delay.
@param hintResource the string resource for the hint to be set
@param delayMilliseconds a delay period, measured in milliseconds
"""
final Runnable hintRunnable = new Runnable() {
@Override
public void run() {
setHint(hintResource);
}
};
mHandler.postDelayed(hintRunnable, delayMilliseconds);
} | java | public void setHintDelayed(@StringRes final int hintResource, long delayMilliseconds) {
final Runnable hintRunnable = new Runnable() {
@Override
public void run() {
setHint(hintResource);
}
};
mHandler.postDelayed(hintRunnable, delayMilliseconds);
} | [
"public",
"void",
"setHintDelayed",
"(",
"@",
"StringRes",
"final",
"int",
"hintResource",
",",
"long",
"delayMilliseconds",
")",
"{",
"final",
"Runnable",
"hintRunnable",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"setHint",
"(",
"hintResource",
")",
";",
"}",
"}",
";",
"mHandler",
".",
"postDelayed",
"(",
"hintRunnable",
",",
"delayMilliseconds",
")",
";",
"}"
]
| Change the hint value of this control after a delay.
@param hintResource the string resource for the hint to be set
@param delayMilliseconds a delay period, measured in milliseconds | [
"Change",
"the",
"hint",
"value",
"of",
"this",
"control",
"after",
"a",
"delay",
"."
]
| train | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/view/StripeEditText.java#L140-L148 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.getRequestParameterValue | public static String getRequestParameterValue(final HttpServletRequest request, final String key) {
"""
Get a value for a request parameter allowing for multi part form fields.
@param request the request being processed
@param key the parameter key to return
@return the parameter value
"""
String[] values = getRequestParameterValues(request, key);
return values == null || values.length == 0 ? null : values[0];
} | java | public static String getRequestParameterValue(final HttpServletRequest request, final String key) {
String[] values = getRequestParameterValues(request, key);
return values == null || values.length == 0 ? null : values[0];
} | [
"public",
"static",
"String",
"getRequestParameterValue",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"String",
"key",
")",
"{",
"String",
"[",
"]",
"values",
"=",
"getRequestParameterValues",
"(",
"request",
",",
"key",
")",
";",
"return",
"values",
"==",
"null",
"||",
"values",
".",
"length",
"==",
"0",
"?",
"null",
":",
"values",
"[",
"0",
"]",
";",
"}"
]
| Get a value for a request parameter allowing for multi part form fields.
@param request the request being processed
@param key the parameter key to return
@return the parameter value | [
"Get",
"a",
"value",
"for",
"a",
"request",
"parameter",
"allowing",
"for",
"multi",
"part",
"form",
"fields",
"."
]
| train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L545-L548 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java | AllClassesFrameWriter.addAllClasses | protected void addAllClasses(Content content, boolean wantFrames) {
"""
Use the sorted index of all the classes and add all the classes to the
content list.
@param content HtmlTree content to which all classes information will be added
@param wantFrames True if we want frames.
"""
for (Character unicode : indexbuilder.index()) {
addContents(indexbuilder.getMemberList(unicode), wantFrames, content);
}
} | java | protected void addAllClasses(Content content, boolean wantFrames) {
for (Character unicode : indexbuilder.index()) {
addContents(indexbuilder.getMemberList(unicode), wantFrames, content);
}
} | [
"protected",
"void",
"addAllClasses",
"(",
"Content",
"content",
",",
"boolean",
"wantFrames",
")",
"{",
"for",
"(",
"Character",
"unicode",
":",
"indexbuilder",
".",
"index",
"(",
")",
")",
"{",
"addContents",
"(",
"indexbuilder",
".",
"getMemberList",
"(",
"unicode",
")",
",",
"wantFrames",
",",
"content",
")",
";",
"}",
"}"
]
| Use the sorted index of all the classes and add all the classes to the
content list.
@param content HtmlTree content to which all classes information will be added
@param wantFrames True if we want frames. | [
"Use",
"the",
"sorted",
"index",
"of",
"all",
"the",
"classes",
"and",
"add",
"all",
"the",
"classes",
"to",
"the",
"content",
"list",
"."
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java#L137-L141 |
Netflix/ribbon | ribbon-loadbalancer/src/main/java/com/netflix/client/AbstractLoadBalancerAwareClient.java | AbstractLoadBalancerAwareClient.executeWithLoadBalancer | public T executeWithLoadBalancer(final S request, final IClientConfig requestConfig) throws ClientException {
"""
This method should be used when the caller wants to dispatch the request to a server chosen by
the load balancer, instead of specifying the server in the request's URI.
It calculates the final URI by calling {@link #reconstructURIWithServer(com.netflix.loadbalancer.Server, java.net.URI)}
and then calls {@link #executeWithLoadBalancer(ClientRequest, com.netflix.client.config.IClientConfig)}.
@param request request to be dispatched to a server chosen by the load balancer. The URI can be a partial
URI which does not contain the host name or the protocol.
"""
LoadBalancerCommand<T> command = buildLoadBalancerCommand(request, requestConfig);
try {
return command.submit(
new ServerOperation<T>() {
@Override
public Observable<T> call(Server server) {
URI finalUri = reconstructURIWithServer(server, request.getUri());
S requestForServer = (S) request.replaceUri(finalUri);
try {
return Observable.just(AbstractLoadBalancerAwareClient.this.execute(requestForServer, requestConfig));
}
catch (Exception e) {
return Observable.error(e);
}
}
})
.toBlocking()
.single();
} catch (Exception e) {
Throwable t = e.getCause();
if (t instanceof ClientException) {
throw (ClientException) t;
} else {
throw new ClientException(e);
}
}
} | java | public T executeWithLoadBalancer(final S request, final IClientConfig requestConfig) throws ClientException {
LoadBalancerCommand<T> command = buildLoadBalancerCommand(request, requestConfig);
try {
return command.submit(
new ServerOperation<T>() {
@Override
public Observable<T> call(Server server) {
URI finalUri = reconstructURIWithServer(server, request.getUri());
S requestForServer = (S) request.replaceUri(finalUri);
try {
return Observable.just(AbstractLoadBalancerAwareClient.this.execute(requestForServer, requestConfig));
}
catch (Exception e) {
return Observable.error(e);
}
}
})
.toBlocking()
.single();
} catch (Exception e) {
Throwable t = e.getCause();
if (t instanceof ClientException) {
throw (ClientException) t;
} else {
throw new ClientException(e);
}
}
} | [
"public",
"T",
"executeWithLoadBalancer",
"(",
"final",
"S",
"request",
",",
"final",
"IClientConfig",
"requestConfig",
")",
"throws",
"ClientException",
"{",
"LoadBalancerCommand",
"<",
"T",
">",
"command",
"=",
"buildLoadBalancerCommand",
"(",
"request",
",",
"requestConfig",
")",
";",
"try",
"{",
"return",
"command",
".",
"submit",
"(",
"new",
"ServerOperation",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"T",
">",
"call",
"(",
"Server",
"server",
")",
"{",
"URI",
"finalUri",
"=",
"reconstructURIWithServer",
"(",
"server",
",",
"request",
".",
"getUri",
"(",
")",
")",
";",
"S",
"requestForServer",
"=",
"(",
"S",
")",
"request",
".",
"replaceUri",
"(",
"finalUri",
")",
";",
"try",
"{",
"return",
"Observable",
".",
"just",
"(",
"AbstractLoadBalancerAwareClient",
".",
"this",
".",
"execute",
"(",
"requestForServer",
",",
"requestConfig",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"Observable",
".",
"error",
"(",
"e",
")",
";",
"}",
"}",
"}",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Throwable",
"t",
"=",
"e",
".",
"getCause",
"(",
")",
";",
"if",
"(",
"t",
"instanceof",
"ClientException",
")",
"{",
"throw",
"(",
"ClientException",
")",
"t",
";",
"}",
"else",
"{",
"throw",
"new",
"ClientException",
"(",
"e",
")",
";",
"}",
"}",
"}"
]
| This method should be used when the caller wants to dispatch the request to a server chosen by
the load balancer, instead of specifying the server in the request's URI.
It calculates the final URI by calling {@link #reconstructURIWithServer(com.netflix.loadbalancer.Server, java.net.URI)}
and then calls {@link #executeWithLoadBalancer(ClientRequest, com.netflix.client.config.IClientConfig)}.
@param request request to be dispatched to a server chosen by the load balancer. The URI can be a partial
URI which does not contain the host name or the protocol. | [
"This",
"method",
"should",
"be",
"used",
"when",
"the",
"caller",
"wants",
"to",
"dispatch",
"the",
"request",
"to",
"a",
"server",
"chosen",
"by",
"the",
"load",
"balancer",
"instead",
"of",
"specifying",
"the",
"server",
"in",
"the",
"request",
"s",
"URI",
".",
"It",
"calculates",
"the",
"final",
"URI",
"by",
"calling",
"{",
"@link",
"#reconstructURIWithServer",
"(",
"com",
".",
"netflix",
".",
"loadbalancer",
".",
"Server",
"java",
".",
"net",
".",
"URI",
")",
"}",
"and",
"then",
"calls",
"{",
"@link",
"#executeWithLoadBalancer",
"(",
"ClientRequest",
"com",
".",
"netflix",
".",
"client",
".",
"config",
".",
"IClientConfig",
")",
"}",
"."
]
| train | https://github.com/Netflix/ribbon/blob/d15cd7715b0bf2f64ae6ca98c5e4d184f178e261/ribbon-loadbalancer/src/main/java/com/netflix/client/AbstractLoadBalancerAwareClient.java#L93-L122 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/Instant.java | Instant.create | private static Instant create(long seconds, int nanoOfSecond) {
"""
Obtains an instance of {@code Instant} using seconds and nanoseconds.
@param seconds the length of the duration in seconds
@param nanoOfSecond the nano-of-second, from 0 to 999,999,999
@throws DateTimeException if the instant exceeds the maximum or minimum instant
"""
if ((seconds | nanoOfSecond) == 0) {
return EPOCH;
}
if (seconds < MIN_SECOND || seconds > MAX_SECOND) {
throw new DateTimeException("Instant exceeds minimum or maximum instant");
}
return new Instant(seconds, nanoOfSecond);
} | java | private static Instant create(long seconds, int nanoOfSecond) {
if ((seconds | nanoOfSecond) == 0) {
return EPOCH;
}
if (seconds < MIN_SECOND || seconds > MAX_SECOND) {
throw new DateTimeException("Instant exceeds minimum or maximum instant");
}
return new Instant(seconds, nanoOfSecond);
} | [
"private",
"static",
"Instant",
"create",
"(",
"long",
"seconds",
",",
"int",
"nanoOfSecond",
")",
"{",
"if",
"(",
"(",
"seconds",
"|",
"nanoOfSecond",
")",
"==",
"0",
")",
"{",
"return",
"EPOCH",
";",
"}",
"if",
"(",
"seconds",
"<",
"MIN_SECOND",
"||",
"seconds",
">",
"MAX_SECOND",
")",
"{",
"throw",
"new",
"DateTimeException",
"(",
"\"Instant exceeds minimum or maximum instant\"",
")",
";",
"}",
"return",
"new",
"Instant",
"(",
"seconds",
",",
"nanoOfSecond",
")",
";",
"}"
]
| Obtains an instance of {@code Instant} using seconds and nanoseconds.
@param seconds the length of the duration in seconds
@param nanoOfSecond the nano-of-second, from 0 to 999,999,999
@throws DateTimeException if the instant exceeds the maximum or minimum instant | [
"Obtains",
"an",
"instance",
"of",
"{",
"@code",
"Instant",
"}",
"using",
"seconds",
"and",
"nanoseconds",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/Instant.java#L400-L408 |
greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.writeLog | public void writeLog(LogInfo info, Cause cause, String causeReason, Account account, double amount, Currency currency, String worldName) {
"""
Write a transaction to the Log.
@param info The type of transaction to log.
@param cause The cause of the transaction.
@param causeReason The reason of the cause
@param account The account being impacted by the change
@param amount The amount of money in this transaction.
@param currency The currency associated with this transaction
@param worldName The world name associated with this transaction
"""
if (getMainConfig().getBoolean("System.Logging.Enabled")) {
getStorageHandler().getStorageEngine().saveLog(info, cause, causeReason, account, amount, currency, worldName);
}
} | java | public void writeLog(LogInfo info, Cause cause, String causeReason, Account account, double amount, Currency currency, String worldName) {
if (getMainConfig().getBoolean("System.Logging.Enabled")) {
getStorageHandler().getStorageEngine().saveLog(info, cause, causeReason, account, amount, currency, worldName);
}
} | [
"public",
"void",
"writeLog",
"(",
"LogInfo",
"info",
",",
"Cause",
"cause",
",",
"String",
"causeReason",
",",
"Account",
"account",
",",
"double",
"amount",
",",
"Currency",
"currency",
",",
"String",
"worldName",
")",
"{",
"if",
"(",
"getMainConfig",
"(",
")",
".",
"getBoolean",
"(",
"\"System.Logging.Enabled\"",
")",
")",
"{",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"saveLog",
"(",
"info",
",",
"cause",
",",
"causeReason",
",",
"account",
",",
"amount",
",",
"currency",
",",
"worldName",
")",
";",
"}",
"}"
]
| Write a transaction to the Log.
@param info The type of transaction to log.
@param cause The cause of the transaction.
@param causeReason The reason of the cause
@param account The account being impacted by the change
@param amount The amount of money in this transaction.
@param currency The currency associated with this transaction
@param worldName The world name associated with this transaction | [
"Write",
"a",
"transaction",
"to",
"the",
"Log",
"."
]
| train | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L503-L507 |
sonatype/sisu | examples/guice-rcp/guice-rcp-plugin/src/org/sonatype/examples/guice/rcp/NavigationView.java | NavigationView.createPartControl | public void createPartControl(Composite parent) {
"""
This is a callback that will allow us to create the viewer and initialize
it.
"""
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setInput(createDummyModel());
} | java | public void createPartControl(Composite parent) {
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setInput(createDummyModel());
} | [
"public",
"void",
"createPartControl",
"(",
"Composite",
"parent",
")",
"{",
"viewer",
"=",
"new",
"TreeViewer",
"(",
"parent",
",",
"SWT",
".",
"MULTI",
"|",
"SWT",
".",
"H_SCROLL",
"|",
"SWT",
".",
"V_SCROLL",
"|",
"SWT",
".",
"BORDER",
")",
";",
"viewer",
".",
"setContentProvider",
"(",
"new",
"ViewContentProvider",
"(",
")",
")",
";",
"viewer",
".",
"setLabelProvider",
"(",
"new",
"ViewLabelProvider",
"(",
")",
")",
";",
"viewer",
".",
"setInput",
"(",
"createDummyModel",
"(",
")",
")",
";",
"}"
]
| This is a callback that will allow us to create the viewer and initialize
it. | [
"This",
"is",
"a",
"callback",
"that",
"will",
"allow",
"us",
"to",
"create",
"the",
"viewer",
"and",
"initialize",
"it",
"."
]
| train | https://github.com/sonatype/sisu/blob/a3dd122e19a5c3bc3266b9196fe47a3ea664a289/examples/guice-rcp/guice-rcp-plugin/src/org/sonatype/examples/guice/rcp/NavigationView.java#L148-L153 |
graphql-java/graphql-java | src/main/java/graphql/language/AstSignature.java | AstSignature.signatureQuery | public Document signatureQuery(Document document, String operationName) {
"""
This can produce a "signature" canonical AST that conforms to the algorithm as outlined
<a href="https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/signature.ts">here</a>
which removes excess operations, removes any field aliases, hides literal values and sorts the result into a canonical
query
@param document the document to make a signature query from
@param operationName the name of the operation to do it for (since only one query can be run at a time)
@return the signature query in document form
"""
return sortAST(
removeAliases(
hideLiterals(
dropUnusedQueryDefinitions(document, operationName)))
);
} | java | public Document signatureQuery(Document document, String operationName) {
return sortAST(
removeAliases(
hideLiterals(
dropUnusedQueryDefinitions(document, operationName)))
);
} | [
"public",
"Document",
"signatureQuery",
"(",
"Document",
"document",
",",
"String",
"operationName",
")",
"{",
"return",
"sortAST",
"(",
"removeAliases",
"(",
"hideLiterals",
"(",
"dropUnusedQueryDefinitions",
"(",
"document",
",",
"operationName",
")",
")",
")",
")",
";",
"}"
]
| This can produce a "signature" canonical AST that conforms to the algorithm as outlined
<a href="https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/signature.ts">here</a>
which removes excess operations, removes any field aliases, hides literal values and sorts the result into a canonical
query
@param document the document to make a signature query from
@param operationName the name of the operation to do it for (since only one query can be run at a time)
@return the signature query in document form | [
"This",
"can",
"produce",
"a",
"signature",
"canonical",
"AST",
"that",
"conforms",
"to",
"the",
"algorithm",
"as",
"outlined",
"<a",
"href",
"=",
"https",
":",
"//",
"github",
".",
"com",
"/",
"apollographql",
"/",
"apollo",
"-",
"server",
"/",
"blob",
"/",
"master",
"/",
"packages",
"/",
"apollo",
"-",
"engine",
"-",
"reporting",
"/",
"src",
"/",
"signature",
".",
"ts",
">",
"here<",
"/",
"a",
">",
"which",
"removes",
"excess",
"operations",
"removes",
"any",
"field",
"aliases",
"hides",
"literal",
"values",
"and",
"sorts",
"the",
"result",
"into",
"a",
"canonical",
"query"
]
| train | https://github.com/graphql-java/graphql-java/blob/9214b6044317849388bd88a14b54fc1c18c9f29f/src/main/java/graphql/language/AstSignature.java#L35-L41 |
kite-sdk/kite | kite-minicluster/src/main/java/org/apache/flume/sink/kite/KerberosUtil.java | KerberosUtil.runPrivileged | public static <T> T runPrivileged(UserGroupInformation login,
PrivilegedExceptionAction<T> action) {
"""
Allow methods to act with the privileges of a login.
If the login is null, the current privileges will be used.
@param <T> The return type of the action
@param login UserGroupInformation credentials to use for action
@param action A PrivilegedExceptionAction to perform as another user
@return the T value returned by action.run()
"""
try {
if (login == null) {
return action.run();
} else {
return login.doAs(action);
}
} catch (IOException ex) {
throw new DatasetIOException("Privileged action failed", ex);
} catch (InterruptedException ex) {
Thread.interrupted();
throw new DatasetException(ex);
} catch (Exception ex) {
throw Throwables.propagate(ex);
}
} | java | public static <T> T runPrivileged(UserGroupInformation login,
PrivilegedExceptionAction<T> action) {
try {
if (login == null) {
return action.run();
} else {
return login.doAs(action);
}
} catch (IOException ex) {
throw new DatasetIOException("Privileged action failed", ex);
} catch (InterruptedException ex) {
Thread.interrupted();
throw new DatasetException(ex);
} catch (Exception ex) {
throw Throwables.propagate(ex);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"runPrivileged",
"(",
"UserGroupInformation",
"login",
",",
"PrivilegedExceptionAction",
"<",
"T",
">",
"action",
")",
"{",
"try",
"{",
"if",
"(",
"login",
"==",
"null",
")",
"{",
"return",
"action",
".",
"run",
"(",
")",
";",
"}",
"else",
"{",
"return",
"login",
".",
"doAs",
"(",
"action",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"DatasetIOException",
"(",
"\"Privileged action failed\"",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"ex",
")",
"{",
"Thread",
".",
"interrupted",
"(",
")",
";",
"throw",
"new",
"DatasetException",
"(",
"ex",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"Throwables",
".",
"propagate",
"(",
"ex",
")",
";",
"}",
"}"
]
| Allow methods to act with the privileges of a login.
If the login is null, the current privileges will be used.
@param <T> The return type of the action
@param login UserGroupInformation credentials to use for action
@param action A PrivilegedExceptionAction to perform as another user
@return the T value returned by action.run() | [
"Allow",
"methods",
"to",
"act",
"with",
"the",
"privileges",
"of",
"a",
"login",
"."
]
| train | https://github.com/kite-sdk/kite/blob/72bfb4b1a881af85808cd7f14bc3e15160a1e811/kite-minicluster/src/main/java/org/apache/flume/sink/kite/KerberosUtil.java#L159-L175 |
ironjacamar/ironjacamar | core/src/main/java/org/ironjacamar/core/tracer/Tracer.java | Tracer.returnConnection | public static synchronized void returnConnection(String poolName, Object mcp, Object cl, Object connection) {
"""
Return connection
@param poolName The name of the pool
@param mcp The managed connection pool
@param cl The connection listener
@param connection The connection
"""
log.tracef("%s", new TraceEvent(poolName,
Integer.toHexString(System.identityHashCode(mcp)),
TraceEvent.RETURN_CONNECTION,
Integer.toHexString(System.identityHashCode(cl)),
Integer.toHexString(System.identityHashCode(connection))));
} | java | public static synchronized void returnConnection(String poolName, Object mcp, Object cl, Object connection)
{
log.tracef("%s", new TraceEvent(poolName,
Integer.toHexString(System.identityHashCode(mcp)),
TraceEvent.RETURN_CONNECTION,
Integer.toHexString(System.identityHashCode(cl)),
Integer.toHexString(System.identityHashCode(connection))));
} | [
"public",
"static",
"synchronized",
"void",
"returnConnection",
"(",
"String",
"poolName",
",",
"Object",
"mcp",
",",
"Object",
"cl",
",",
"Object",
"connection",
")",
"{",
"log",
".",
"tracef",
"(",
"\"%s\"",
",",
"new",
"TraceEvent",
"(",
"poolName",
",",
"Integer",
".",
"toHexString",
"(",
"System",
".",
"identityHashCode",
"(",
"mcp",
")",
")",
",",
"TraceEvent",
".",
"RETURN_CONNECTION",
",",
"Integer",
".",
"toHexString",
"(",
"System",
".",
"identityHashCode",
"(",
"cl",
")",
")",
",",
"Integer",
".",
"toHexString",
"(",
"System",
".",
"identityHashCode",
"(",
"connection",
")",
")",
")",
")",
";",
"}"
]
| Return connection
@param poolName The name of the pool
@param mcp The managed connection pool
@param cl The connection listener
@param connection The connection | [
"Return",
"connection"
]
| train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/core/src/main/java/org/ironjacamar/core/tracer/Tracer.java#L389-L396 |
to2mbn/JMCCC | jmccc/src/main/java/org/to2mbn/jmccc/util/ExtraArgumentsTemplates.java | ExtraArgumentsTemplates.OSX_DOCK_ICON | public static String OSX_DOCK_ICON(MinecraftDirectory minecraftDir, Set<Asset> assetIndex) {
"""
Caution: This option is available only on OSX.
@param minecraftDir the minecraft directory
@param assetIndex the asset index
@return a <code>-Xdock:icon</code> option, null if the assets cannot be resolved
@see #OSX_DOCK_ICON(MinecraftDirectory, Version)
@see #OSX_DOCK_NAME
"""
Objects.requireNonNull(minecraftDir);
Objects.requireNonNull(assetIndex);
for (Asset asset : assetIndex) {
if ("icons/minecraft.icns".equals(asset.getVirtualPath())) {
return "-Xdock:icon=" + minecraftDir.getAsset(asset).getAbsolutePath();
}
}
return null;
} | java | public static String OSX_DOCK_ICON(MinecraftDirectory minecraftDir, Set<Asset> assetIndex) {
Objects.requireNonNull(minecraftDir);
Objects.requireNonNull(assetIndex);
for (Asset asset : assetIndex) {
if ("icons/minecraft.icns".equals(asset.getVirtualPath())) {
return "-Xdock:icon=" + minecraftDir.getAsset(asset).getAbsolutePath();
}
}
return null;
} | [
"public",
"static",
"String",
"OSX_DOCK_ICON",
"(",
"MinecraftDirectory",
"minecraftDir",
",",
"Set",
"<",
"Asset",
">",
"assetIndex",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"minecraftDir",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"assetIndex",
")",
";",
"for",
"(",
"Asset",
"asset",
":",
"assetIndex",
")",
"{",
"if",
"(",
"\"icons/minecraft.icns\"",
".",
"equals",
"(",
"asset",
".",
"getVirtualPath",
"(",
")",
")",
")",
"{",
"return",
"\"-Xdock:icon=\"",
"+",
"minecraftDir",
".",
"getAsset",
"(",
"asset",
")",
".",
"getAbsolutePath",
"(",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Caution: This option is available only on OSX.
@param minecraftDir the minecraft directory
@param assetIndex the asset index
@return a <code>-Xdock:icon</code> option, null if the assets cannot be resolved
@see #OSX_DOCK_ICON(MinecraftDirectory, Version)
@see #OSX_DOCK_NAME | [
"Caution",
":",
"This",
"option",
"is",
"available",
"only",
"on",
"OSX",
"."
]
| train | https://github.com/to2mbn/JMCCC/blob/17e5b1b56ff18255cfd60976dca1a24598946647/jmccc/src/main/java/org/to2mbn/jmccc/util/ExtraArgumentsTemplates.java#L42-L51 |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamIterationHead.java | StreamIterationHead.createBrokerIdString | public static String createBrokerIdString(JobID jid, String iterationID, int subtaskIndex) {
"""
Creates the identification string with which head and tail task find the shared blocking
queue for the back channel. The identification string is unique per parallel head/tail pair
per iteration per job.
@param jid The job ID.
@param iterationID The id of the iteration in the job.
@param subtaskIndex The parallel subtask number
@return The identification string.
"""
return jid + "-" + iterationID + "-" + subtaskIndex;
} | java | public static String createBrokerIdString(JobID jid, String iterationID, int subtaskIndex) {
return jid + "-" + iterationID + "-" + subtaskIndex;
} | [
"public",
"static",
"String",
"createBrokerIdString",
"(",
"JobID",
"jid",
",",
"String",
"iterationID",
",",
"int",
"subtaskIndex",
")",
"{",
"return",
"jid",
"+",
"\"-\"",
"+",
"iterationID",
"+",
"\"-\"",
"+",
"subtaskIndex",
";",
"}"
]
| Creates the identification string with which head and tail task find the shared blocking
queue for the back channel. The identification string is unique per parallel head/tail pair
per iteration per job.
@param jid The job ID.
@param iterationID The id of the iteration in the job.
@param subtaskIndex The parallel subtask number
@return The identification string. | [
"Creates",
"the",
"identification",
"string",
"with",
"which",
"head",
"and",
"tail",
"task",
"find",
"the",
"shared",
"blocking",
"queue",
"for",
"the",
"back",
"channel",
".",
"The",
"identification",
"string",
"is",
"unique",
"per",
"parallel",
"head",
"/",
"tail",
"pair",
"per",
"iteration",
"per",
"job",
"."
]
| train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamIterationHead.java#L142-L144 |
JavaMoney/jsr354-ri-bp | src/main/java/org/javamoney/moneta/function/MonetaryFunctions.java | MonetaryFunctions.sortValuable | public static Comparator<? super MonetaryAmount> sortValuable(
final ExchangeRateProvider provider) {
"""
comparator to sort the {@link MonetaryAmount} considering the
{@link ExchangeRate}
@param provider the rate provider to be used.
@return the sort of {@link MonetaryAmount} using {@link ExchangeRate}
"""
return new Comparator<MonetaryAmount>() {
@Override
public int compare(MonetaryAmount m1, MonetaryAmount m2) {
CurrencyConversion conversor = provider.getCurrencyConversion(m1
.getCurrency());
return m1.compareTo(conversor.apply(m2));
}
};
} | java | public static Comparator<? super MonetaryAmount> sortValuable(
final ExchangeRateProvider provider) {
return new Comparator<MonetaryAmount>() {
@Override
public int compare(MonetaryAmount m1, MonetaryAmount m2) {
CurrencyConversion conversor = provider.getCurrencyConversion(m1
.getCurrency());
return m1.compareTo(conversor.apply(m2));
}
};
} | [
"public",
"static",
"Comparator",
"<",
"?",
"super",
"MonetaryAmount",
">",
"sortValuable",
"(",
"final",
"ExchangeRateProvider",
"provider",
")",
"{",
"return",
"new",
"Comparator",
"<",
"MonetaryAmount",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"MonetaryAmount",
"m1",
",",
"MonetaryAmount",
"m2",
")",
"{",
"CurrencyConversion",
"conversor",
"=",
"provider",
".",
"getCurrencyConversion",
"(",
"m1",
".",
"getCurrency",
"(",
")",
")",
";",
"return",
"m1",
".",
"compareTo",
"(",
"conversor",
".",
"apply",
"(",
"m2",
")",
")",
";",
"}",
"}",
";",
"}"
]
| comparator to sort the {@link MonetaryAmount} considering the
{@link ExchangeRate}
@param provider the rate provider to be used.
@return the sort of {@link MonetaryAmount} using {@link ExchangeRate} | [
"comparator",
"to",
"sort",
"the",
"{"
]
| train | https://github.com/JavaMoney/jsr354-ri-bp/blob/9c147ef5623d8032a6dc4c0e5eefdfb41641a9a2/src/main/java/org/javamoney/moneta/function/MonetaryFunctions.java#L66-L76 |
finmath/finmath-lib | src/main/java6/net/finmath/montecarlo/interestrate/products/components/Cashflow.java | Cashflow.getValue | @Override
public RandomVariableInterface getValue(double evaluationTime, LIBORModelMonteCarloSimulationInterface model) throws CalculationException {
"""
This method returns the value random variable of the product within the specified model, evaluated at a given evalutationTime.
Note: For a lattice this is often the value conditional to evalutationTime, for a Monte-Carlo simulation this is the (sum of) value discounted to evaluation time.
cash-flows prior evaluationTime are not considered.
@param evaluationTime The time on which this products value should be observed.
@param model The model used to price the product.
@return The random variable representing the value of the product discounted to evaluation time
@throws net.finmath.exception.CalculationException Thrown if the valuation fails, specific cause may be available via the <code>cause()</code> method.
"""
// Note: We use > here. To distinguish an end of day valuation use hour of day for cash flows and evaluation date.
if(evaluationTime > flowDate) {
return model.getRandomVariableForConstant(0.0);
}
RandomVariableInterface values = model.getRandomVariableForConstant(flowAmount);
if(isPayer) {
values = values.mult(-1.0);
}
// Rebase to evaluationTime
if(flowDate != evaluationTime) {
// Get random variables
RandomVariableInterface numeraire = model.getNumeraire(flowDate);
RandomVariableInterface numeraireAtEval = model.getNumeraire(evaluationTime);
// RandomVariableInterface monteCarloProbabilities = model.getMonteCarloWeights(getPaymentDate());
values = values.div(numeraire).mult(numeraireAtEval);
}
// Return values
return values;
} | java | @Override
public RandomVariableInterface getValue(double evaluationTime, LIBORModelMonteCarloSimulationInterface model) throws CalculationException {
// Note: We use > here. To distinguish an end of day valuation use hour of day for cash flows and evaluation date.
if(evaluationTime > flowDate) {
return model.getRandomVariableForConstant(0.0);
}
RandomVariableInterface values = model.getRandomVariableForConstant(flowAmount);
if(isPayer) {
values = values.mult(-1.0);
}
// Rebase to evaluationTime
if(flowDate != evaluationTime) {
// Get random variables
RandomVariableInterface numeraire = model.getNumeraire(flowDate);
RandomVariableInterface numeraireAtEval = model.getNumeraire(evaluationTime);
// RandomVariableInterface monteCarloProbabilities = model.getMonteCarloWeights(getPaymentDate());
values = values.div(numeraire).mult(numeraireAtEval);
}
// Return values
return values;
} | [
"@",
"Override",
"public",
"RandomVariableInterface",
"getValue",
"(",
"double",
"evaluationTime",
",",
"LIBORModelMonteCarloSimulationInterface",
"model",
")",
"throws",
"CalculationException",
"{",
"// Note: We use > here. To distinguish an end of day valuation use hour of day for cash flows and evaluation date.",
"if",
"(",
"evaluationTime",
">",
"flowDate",
")",
"{",
"return",
"model",
".",
"getRandomVariableForConstant",
"(",
"0.0",
")",
";",
"}",
"RandomVariableInterface",
"values",
"=",
"model",
".",
"getRandomVariableForConstant",
"(",
"flowAmount",
")",
";",
"if",
"(",
"isPayer",
")",
"{",
"values",
"=",
"values",
".",
"mult",
"(",
"-",
"1.0",
")",
";",
"}",
"// Rebase to evaluationTime",
"if",
"(",
"flowDate",
"!=",
"evaluationTime",
")",
"{",
"// Get random variables",
"RandomVariableInterface",
"numeraire",
"=",
"model",
".",
"getNumeraire",
"(",
"flowDate",
")",
";",
"RandomVariableInterface",
"numeraireAtEval",
"=",
"model",
".",
"getNumeraire",
"(",
"evaluationTime",
")",
";",
"// RandomVariableInterface\tmonteCarloProbabilities\t= model.getMonteCarloWeights(getPaymentDate());",
"values",
"=",
"values",
".",
"div",
"(",
"numeraire",
")",
".",
"mult",
"(",
"numeraireAtEval",
")",
";",
"}",
"// Return values",
"return",
"values",
";",
"}"
]
| This method returns the value random variable of the product within the specified model, evaluated at a given evalutationTime.
Note: For a lattice this is often the value conditional to evalutationTime, for a Monte-Carlo simulation this is the (sum of) value discounted to evaluation time.
cash-flows prior evaluationTime are not considered.
@param evaluationTime The time on which this products value should be observed.
@param model The model used to price the product.
@return The random variable representing the value of the product discounted to evaluation time
@throws net.finmath.exception.CalculationException Thrown if the valuation fails, specific cause may be available via the <code>cause()</code> method. | [
"This",
"method",
"returns",
"the",
"value",
"random",
"variable",
"of",
"the",
"product",
"within",
"the",
"specified",
"model",
"evaluated",
"at",
"a",
"given",
"evalutationTime",
".",
"Note",
":",
"For",
"a",
"lattice",
"this",
"is",
"often",
"the",
"value",
"conditional",
"to",
"evalutationTime",
"for",
"a",
"Monte",
"-",
"Carlo",
"simulation",
"this",
"is",
"the",
"(",
"sum",
"of",
")",
"value",
"discounted",
"to",
"evaluation",
"time",
".",
"cash",
"-",
"flows",
"prior",
"evaluationTime",
"are",
"not",
"considered",
"."
]
| train | https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java6/net/finmath/montecarlo/interestrate/products/components/Cashflow.java#L67-L91 |
fcrepo3/fcrepo | fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/Attribute.java | Attribute.put | public String put(String optionName, String optionValue) {
"""
Add or update a config item for this attribute
@param optionName
@param optionValue
@return String option value
"""
options.put(optionName, optionValue);
return optionValue;
} | java | public String put(String optionName, String optionValue) {
options.put(optionName, optionValue);
return optionValue;
} | [
"public",
"String",
"put",
"(",
"String",
"optionName",
",",
"String",
"optionValue",
")",
"{",
"options",
".",
"put",
"(",
"optionName",
",",
"optionValue",
")",
";",
"return",
"optionValue",
";",
"}"
]
| Add or update a config item for this attribute
@param optionName
@param optionValue
@return String option value | [
"Add",
"or",
"update",
"a",
"config",
"item",
"for",
"this",
"attribute"
]
| train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/Attribute.java#L37-L40 |
jenkinsci/favorite-plugin | src/main/java/hudson/plugins/favorite/Favorites.java | Favorites.removeFavorite | public static void removeFavorite(@Nonnull User user, @Nonnull Item item) throws FavoriteException {
"""
Remove an item as a favorite for a user
Fires {@link FavoriteListener#fireOnRemoveFavourite(Item, User)}
@param user to remove the favorite from
@param item to favorite
@throws FavoriteException
"""
try {
if (isFavorite(user, item)) {
FavoriteUserProperty fup = user.getProperty(FavoriteUserProperty.class);
fup.removeFavorite(item.getFullName());
FavoriteListener.fireOnRemoveFavourite(item, user);
} else {
throw new FavoriteException("Favourite is already unset for User: <" + user.getFullName() + "> Item: <" + item.getFullName() + ">");
}
} catch (IOException e) {
throw new FavoriteException("Could not remove Favorite. User: <" + user.getFullName() + "> Item: <" + item.getFullName() + ">", e);
}
} | java | public static void removeFavorite(@Nonnull User user, @Nonnull Item item) throws FavoriteException {
try {
if (isFavorite(user, item)) {
FavoriteUserProperty fup = user.getProperty(FavoriteUserProperty.class);
fup.removeFavorite(item.getFullName());
FavoriteListener.fireOnRemoveFavourite(item, user);
} else {
throw new FavoriteException("Favourite is already unset for User: <" + user.getFullName() + "> Item: <" + item.getFullName() + ">");
}
} catch (IOException e) {
throw new FavoriteException("Could not remove Favorite. User: <" + user.getFullName() + "> Item: <" + item.getFullName() + ">", e);
}
} | [
"public",
"static",
"void",
"removeFavorite",
"(",
"@",
"Nonnull",
"User",
"user",
",",
"@",
"Nonnull",
"Item",
"item",
")",
"throws",
"FavoriteException",
"{",
"try",
"{",
"if",
"(",
"isFavorite",
"(",
"user",
",",
"item",
")",
")",
"{",
"FavoriteUserProperty",
"fup",
"=",
"user",
".",
"getProperty",
"(",
"FavoriteUserProperty",
".",
"class",
")",
";",
"fup",
".",
"removeFavorite",
"(",
"item",
".",
"getFullName",
"(",
")",
")",
";",
"FavoriteListener",
".",
"fireOnRemoveFavourite",
"(",
"item",
",",
"user",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"FavoriteException",
"(",
"\"Favourite is already unset for User: <\"",
"+",
"user",
".",
"getFullName",
"(",
")",
"+",
"\"> Item: <\"",
"+",
"item",
".",
"getFullName",
"(",
")",
"+",
"\">\"",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"FavoriteException",
"(",
"\"Could not remove Favorite. User: <\"",
"+",
"user",
".",
"getFullName",
"(",
")",
"+",
"\"> Item: <\"",
"+",
"item",
".",
"getFullName",
"(",
")",
"+",
"\">\"",
",",
"e",
")",
";",
"}",
"}"
]
| Remove an item as a favorite for a user
Fires {@link FavoriteListener#fireOnRemoveFavourite(Item, User)}
@param user to remove the favorite from
@param item to favorite
@throws FavoriteException | [
"Remove",
"an",
"item",
"as",
"a",
"favorite",
"for",
"a",
"user",
"Fires",
"{"
]
| train | https://github.com/jenkinsci/favorite-plugin/blob/4ce9b195b4d888190fe12c92d546d64f22728c22/src/main/java/hudson/plugins/favorite/Favorites.java#L93-L105 |
venkatramanm/swf-all | swf-db/src/main/java/com/venky/swf/db/table/Table.java | Table._runDML | private boolean _runDML(DataManupulationStatement q, boolean isDDL) {
"""
RReturn true if modification was done..
@param q
@param isDDL
@return
"""
boolean readOnly = ConnectionManager.instance().isPoolReadOnly(getPool());
Transaction txn = Database.getInstance().getCurrentTransaction();
if (!readOnly) {
q.executeUpdate();
if (Database.getJdbcTypeHelper(getPool()).isAutoCommitOnDDL()) {
txn.registerCommit();
}else {
txn.commit();
}
}else {
cat.fine("Pool " + getPool() +" Skipped running" + q.getRealSQL());
}
return !readOnly;
} | java | private boolean _runDML(DataManupulationStatement q, boolean isDDL){
boolean readOnly = ConnectionManager.instance().isPoolReadOnly(getPool());
Transaction txn = Database.getInstance().getCurrentTransaction();
if (!readOnly) {
q.executeUpdate();
if (Database.getJdbcTypeHelper(getPool()).isAutoCommitOnDDL()) {
txn.registerCommit();
}else {
txn.commit();
}
}else {
cat.fine("Pool " + getPool() +" Skipped running" + q.getRealSQL());
}
return !readOnly;
} | [
"private",
"boolean",
"_runDML",
"(",
"DataManupulationStatement",
"q",
",",
"boolean",
"isDDL",
")",
"{",
"boolean",
"readOnly",
"=",
"ConnectionManager",
".",
"instance",
"(",
")",
".",
"isPoolReadOnly",
"(",
"getPool",
"(",
")",
")",
";",
"Transaction",
"txn",
"=",
"Database",
".",
"getInstance",
"(",
")",
".",
"getCurrentTransaction",
"(",
")",
";",
"if",
"(",
"!",
"readOnly",
")",
"{",
"q",
".",
"executeUpdate",
"(",
")",
";",
"if",
"(",
"Database",
".",
"getJdbcTypeHelper",
"(",
"getPool",
"(",
")",
")",
".",
"isAutoCommitOnDDL",
"(",
")",
")",
"{",
"txn",
".",
"registerCommit",
"(",
")",
";",
"}",
"else",
"{",
"txn",
".",
"commit",
"(",
")",
";",
"}",
"}",
"else",
"{",
"cat",
".",
"fine",
"(",
"\"Pool \"",
"+",
"getPool",
"(",
")",
"+",
"\" Skipped running\"",
"+",
"q",
".",
"getRealSQL",
"(",
")",
")",
";",
"}",
"return",
"!",
"readOnly",
";",
"}"
]
| RReturn true if modification was done..
@param q
@param isDDL
@return | [
"RReturn",
"true",
"if",
"modification",
"was",
"done",
".."
]
| train | https://github.com/venkatramanm/swf-all/blob/e6ca342df0645bf1122d81e302575014ad565b69/swf-db/src/main/java/com/venky/swf/db/table/Table.java#L197-L212 |
networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/InstrumentedExecutors.java | InstrumentedExecutors.newFixedThreadPool | public static InstrumentedExecutorService newFixedThreadPool(int nThreads, MetricRegistry registry) {
"""
Creates an instrumented thread pool that reuses a fixed number of threads
operating off a shared unbounded queue. At any point, at most
{@code nThreads} threads will be active processing tasks.
If additional tasks are submitted when all threads are active,
they will wait in the queue until a thread is available.
If any thread terminates due to a failure during execution
prior to shutdown, a new one will take its place if needed to
execute subsequent tasks. The threads in the pool will exist
until it is explicitly {@link java.util.concurrent.ExecutorService#shutdown shutdown}.
@param nThreads the number of threads in the pool
@param registry the {@link MetricRegistry} that will contain the metrics.
@return the newly created thread pool
@throws IllegalArgumentException if {@code nThreads <= 0}
@see Executors#newFixedThreadPool(int)
"""
return new InstrumentedExecutorService(Executors.newFixedThreadPool(nThreads), registry);
} | java | public static InstrumentedExecutorService newFixedThreadPool(int nThreads, MetricRegistry registry) {
return new InstrumentedExecutorService(Executors.newFixedThreadPool(nThreads), registry);
} | [
"public",
"static",
"InstrumentedExecutorService",
"newFixedThreadPool",
"(",
"int",
"nThreads",
",",
"MetricRegistry",
"registry",
")",
"{",
"return",
"new",
"InstrumentedExecutorService",
"(",
"Executors",
".",
"newFixedThreadPool",
"(",
"nThreads",
")",
",",
"registry",
")",
";",
"}"
]
| Creates an instrumented thread pool that reuses a fixed number of threads
operating off a shared unbounded queue. At any point, at most
{@code nThreads} threads will be active processing tasks.
If additional tasks are submitted when all threads are active,
they will wait in the queue until a thread is available.
If any thread terminates due to a failure during execution
prior to shutdown, a new one will take its place if needed to
execute subsequent tasks. The threads in the pool will exist
until it is explicitly {@link java.util.concurrent.ExecutorService#shutdown shutdown}.
@param nThreads the number of threads in the pool
@param registry the {@link MetricRegistry} that will contain the metrics.
@return the newly created thread pool
@throws IllegalArgumentException if {@code nThreads <= 0}
@see Executors#newFixedThreadPool(int) | [
"Creates",
"an",
"instrumented",
"thread",
"pool",
"that",
"reuses",
"a",
"fixed",
"number",
"of",
"threads",
"operating",
"off",
"a",
"shared",
"unbounded",
"queue",
".",
"At",
"any",
"point",
"at",
"most",
"{",
"@code",
"nThreads",
"}",
"threads",
"will",
"be",
"active",
"processing",
"tasks",
".",
"If",
"additional",
"tasks",
"are",
"submitted",
"when",
"all",
"threads",
"are",
"active",
"they",
"will",
"wait",
"in",
"the",
"queue",
"until",
"a",
"thread",
"is",
"available",
".",
"If",
"any",
"thread",
"terminates",
"due",
"to",
"a",
"failure",
"during",
"execution",
"prior",
"to",
"shutdown",
"a",
"new",
"one",
"will",
"take",
"its",
"place",
"if",
"needed",
"to",
"execute",
"subsequent",
"tasks",
".",
"The",
"threads",
"in",
"the",
"pool",
"will",
"exist",
"until",
"it",
"is",
"explicitly",
"{",
"@link",
"java",
".",
"util",
".",
"concurrent",
".",
"ExecutorService#shutdown",
"shutdown",
"}",
"."
]
| train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/InstrumentedExecutors.java#L82-L84 |
hypfvieh/java-utils | src/main/java/com/github/hypfvieh/util/SslTlsUtil.java | SslTlsUtil.initializeTrustManagers | public static TrustManager[] initializeTrustManagers(File _trustStoreFile, String _trustStorePassword) throws IOException {
"""
Initialization of trustStoreManager used to provide access to the configured trustStore.
@param _trustStoreFile trust store file
@param _trustStorePassword trust store password
@return TrustManager array or null
@throws IOException on error
"""
if (_trustStoreFile == null) {
return null;
}
String storeType = getStoreTypeByFileName(_trustStoreFile);
boolean derEncoded = storeType == STORETYPE_DER_ENCODED;
if (derEncoded) {
storeType = STORETYPE_JKS;
}
String trustStorePwd = StringUtil.defaultIfBlank(_trustStorePassword, System.getProperty("javax.net.ssl.trustStorePassword"));
LOGGER.debug("Creating trust store of type '" + storeType + "' from " + (derEncoded ? "DER-encoded" : "") + " file '" + _trustStoreFile + "'");
try {
TrustManagerFactory trustMgrFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore trustStore = KeyStore.getInstance(storeType);
if (derEncoded) {
FileInputStream fis = new FileInputStream(_trustStoreFile);
X509Certificate certificate = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(fis);
trustStore.load(null, null);
trustStore.setCertificateEntry("[der_cert_alias]", certificate);
} else {
trustStore.load(new FileInputStream(_trustStoreFile), trustStorePwd != null ? trustStorePwd.toCharArray() : null);
}
trustMgrFactory.init(trustStore);
return trustMgrFactory.getTrustManagers();
} catch (GeneralSecurityException _ex) {
throw new IOException("Error while setting up trustStore", _ex);
}
} | java | public static TrustManager[] initializeTrustManagers(File _trustStoreFile, String _trustStorePassword) throws IOException {
if (_trustStoreFile == null) {
return null;
}
String storeType = getStoreTypeByFileName(_trustStoreFile);
boolean derEncoded = storeType == STORETYPE_DER_ENCODED;
if (derEncoded) {
storeType = STORETYPE_JKS;
}
String trustStorePwd = StringUtil.defaultIfBlank(_trustStorePassword, System.getProperty("javax.net.ssl.trustStorePassword"));
LOGGER.debug("Creating trust store of type '" + storeType + "' from " + (derEncoded ? "DER-encoded" : "") + " file '" + _trustStoreFile + "'");
try {
TrustManagerFactory trustMgrFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore trustStore = KeyStore.getInstance(storeType);
if (derEncoded) {
FileInputStream fis = new FileInputStream(_trustStoreFile);
X509Certificate certificate = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(fis);
trustStore.load(null, null);
trustStore.setCertificateEntry("[der_cert_alias]", certificate);
} else {
trustStore.load(new FileInputStream(_trustStoreFile), trustStorePwd != null ? trustStorePwd.toCharArray() : null);
}
trustMgrFactory.init(trustStore);
return trustMgrFactory.getTrustManagers();
} catch (GeneralSecurityException _ex) {
throw new IOException("Error while setting up trustStore", _ex);
}
} | [
"public",
"static",
"TrustManager",
"[",
"]",
"initializeTrustManagers",
"(",
"File",
"_trustStoreFile",
",",
"String",
"_trustStorePassword",
")",
"throws",
"IOException",
"{",
"if",
"(",
"_trustStoreFile",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"String",
"storeType",
"=",
"getStoreTypeByFileName",
"(",
"_trustStoreFile",
")",
";",
"boolean",
"derEncoded",
"=",
"storeType",
"==",
"STORETYPE_DER_ENCODED",
";",
"if",
"(",
"derEncoded",
")",
"{",
"storeType",
"=",
"STORETYPE_JKS",
";",
"}",
"String",
"trustStorePwd",
"=",
"StringUtil",
".",
"defaultIfBlank",
"(",
"_trustStorePassword",
",",
"System",
".",
"getProperty",
"(",
"\"javax.net.ssl.trustStorePassword\"",
")",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Creating trust store of type '\"",
"+",
"storeType",
"+",
"\"' from \"",
"+",
"(",
"derEncoded",
"?",
"\"DER-encoded\"",
":",
"\"\"",
")",
"+",
"\" file '\"",
"+",
"_trustStoreFile",
"+",
"\"'\"",
")",
";",
"try",
"{",
"TrustManagerFactory",
"trustMgrFactory",
"=",
"TrustManagerFactory",
".",
"getInstance",
"(",
"TrustManagerFactory",
".",
"getDefaultAlgorithm",
"(",
")",
")",
";",
"KeyStore",
"trustStore",
"=",
"KeyStore",
".",
"getInstance",
"(",
"storeType",
")",
";",
"if",
"(",
"derEncoded",
")",
"{",
"FileInputStream",
"fis",
"=",
"new",
"FileInputStream",
"(",
"_trustStoreFile",
")",
";",
"X509Certificate",
"certificate",
"=",
"(",
"X509Certificate",
")",
"CertificateFactory",
".",
"getInstance",
"(",
"\"X.509\"",
")",
".",
"generateCertificate",
"(",
"fis",
")",
";",
"trustStore",
".",
"load",
"(",
"null",
",",
"null",
")",
";",
"trustStore",
".",
"setCertificateEntry",
"(",
"\"[der_cert_alias]\"",
",",
"certificate",
")",
";",
"}",
"else",
"{",
"trustStore",
".",
"load",
"(",
"new",
"FileInputStream",
"(",
"_trustStoreFile",
")",
",",
"trustStorePwd",
"!=",
"null",
"?",
"trustStorePwd",
".",
"toCharArray",
"(",
")",
":",
"null",
")",
";",
"}",
"trustMgrFactory",
".",
"init",
"(",
"trustStore",
")",
";",
"return",
"trustMgrFactory",
".",
"getTrustManagers",
"(",
")",
";",
"}",
"catch",
"(",
"GeneralSecurityException",
"_ex",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Error while setting up trustStore\"",
",",
"_ex",
")",
";",
"}",
"}"
]
| Initialization of trustStoreManager used to provide access to the configured trustStore.
@param _trustStoreFile trust store file
@param _trustStorePassword trust store password
@return TrustManager array or null
@throws IOException on error | [
"Initialization",
"of",
"trustStoreManager",
"used",
"to",
"provide",
"access",
"to",
"the",
"configured",
"trustStore",
"."
]
| train | https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SslTlsUtil.java#L47-L80 |
jhunters/jprotobuf | v3/src/main/java/com/baidu/bjf/remoting/protobuf/code/CodedConstant.java | CodedConstant.getMapKVMessageElements | private static MessageElement getMapKVMessageElements(String name, MapType mapType) {
"""
Gets the map kv message elements.
@param name the name
@param mapType the map type
@return the map kv message elements
"""
MessageElement.Builder ret = MessageElement.builder();
ret.name(name);
DataType keyType = mapType.keyType();
Builder fieldBuilder = FieldElement.builder().name("key").tag(1);
fieldBuilder.type(keyType).label(FieldElement.Label.OPTIONAL);
ret.addField(fieldBuilder.build());
DataType valueType = mapType.valueType();
fieldBuilder = FieldElement.builder().name("value").tag(2);
fieldBuilder.type(valueType).label(FieldElement.Label.OPTIONAL);
ret.addField(fieldBuilder.build());
return ret.build();
} | java | private static MessageElement getMapKVMessageElements(String name, MapType mapType) {
MessageElement.Builder ret = MessageElement.builder();
ret.name(name);
DataType keyType = mapType.keyType();
Builder fieldBuilder = FieldElement.builder().name("key").tag(1);
fieldBuilder.type(keyType).label(FieldElement.Label.OPTIONAL);
ret.addField(fieldBuilder.build());
DataType valueType = mapType.valueType();
fieldBuilder = FieldElement.builder().name("value").tag(2);
fieldBuilder.type(valueType).label(FieldElement.Label.OPTIONAL);
ret.addField(fieldBuilder.build());
return ret.build();
} | [
"private",
"static",
"MessageElement",
"getMapKVMessageElements",
"(",
"String",
"name",
",",
"MapType",
"mapType",
")",
"{",
"MessageElement",
".",
"Builder",
"ret",
"=",
"MessageElement",
".",
"builder",
"(",
")",
";",
"ret",
".",
"name",
"(",
"name",
")",
";",
"DataType",
"keyType",
"=",
"mapType",
".",
"keyType",
"(",
")",
";",
"Builder",
"fieldBuilder",
"=",
"FieldElement",
".",
"builder",
"(",
")",
".",
"name",
"(",
"\"key\"",
")",
".",
"tag",
"(",
"1",
")",
";",
"fieldBuilder",
".",
"type",
"(",
"keyType",
")",
".",
"label",
"(",
"FieldElement",
".",
"Label",
".",
"OPTIONAL",
")",
";",
"ret",
".",
"addField",
"(",
"fieldBuilder",
".",
"build",
"(",
")",
")",
";",
"DataType",
"valueType",
"=",
"mapType",
".",
"valueType",
"(",
")",
";",
"fieldBuilder",
"=",
"FieldElement",
".",
"builder",
"(",
")",
".",
"name",
"(",
"\"value\"",
")",
".",
"tag",
"(",
"2",
")",
";",
"fieldBuilder",
".",
"type",
"(",
"valueType",
")",
".",
"label",
"(",
"FieldElement",
".",
"Label",
".",
"OPTIONAL",
")",
";",
"ret",
".",
"addField",
"(",
"fieldBuilder",
".",
"build",
"(",
")",
")",
";",
"return",
"ret",
".",
"build",
"(",
")",
";",
"}"
]
| Gets the map kv message elements.
@param name the name
@param mapType the map type
@return the map kv message elements | [
"Gets",
"the",
"map",
"kv",
"message",
"elements",
"."
]
| train | https://github.com/jhunters/jprotobuf/blob/55832c9b4792afb128e5b35139d8a3891561d8a3/v3/src/main/java/com/baidu/bjf/remoting/protobuf/code/CodedConstant.java#L1567-L1582 |
wcm-io/wcm-io-handler | link/src/main/java/io/wcm/handler/link/type/helpers/InternalLinkResolver.java | InternalLinkResolver.getTargetPage | private Page getTargetPage(String targetPath, InternalLinkResolverOptions options) {
"""
Returns the target page for the given internal content link reference.
Checks validity of page.
@param targetPath Repository path
@return Target page or null if target reference is invalid.
"""
if (StringUtils.isEmpty(targetPath)) {
return null;
}
// Rewrite target to current site context
String rewrittenPath;
if (options.isRewritePathToContext() && !useTargetContext(options)) {
rewrittenPath = urlHandler.rewritePathToContext(SyntheticNavigatableResource.get(targetPath, resourceResolver));
}
else {
rewrittenPath = targetPath;
}
if (StringUtils.isEmpty(rewrittenPath)) {
return null;
}
// Get target page referenced by target path and check for acceptance
Page targetPage = pageManager.getPage(rewrittenPath);
if (acceptPage(targetPage, options)) {
return targetPage;
}
else {
return null;
}
} | java | private Page getTargetPage(String targetPath, InternalLinkResolverOptions options) {
if (StringUtils.isEmpty(targetPath)) {
return null;
}
// Rewrite target to current site context
String rewrittenPath;
if (options.isRewritePathToContext() && !useTargetContext(options)) {
rewrittenPath = urlHandler.rewritePathToContext(SyntheticNavigatableResource.get(targetPath, resourceResolver));
}
else {
rewrittenPath = targetPath;
}
if (StringUtils.isEmpty(rewrittenPath)) {
return null;
}
// Get target page referenced by target path and check for acceptance
Page targetPage = pageManager.getPage(rewrittenPath);
if (acceptPage(targetPage, options)) {
return targetPage;
}
else {
return null;
}
} | [
"private",
"Page",
"getTargetPage",
"(",
"String",
"targetPath",
",",
"InternalLinkResolverOptions",
"options",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"targetPath",
")",
")",
"{",
"return",
"null",
";",
"}",
"// Rewrite target to current site context",
"String",
"rewrittenPath",
";",
"if",
"(",
"options",
".",
"isRewritePathToContext",
"(",
")",
"&&",
"!",
"useTargetContext",
"(",
"options",
")",
")",
"{",
"rewrittenPath",
"=",
"urlHandler",
".",
"rewritePathToContext",
"(",
"SyntheticNavigatableResource",
".",
"get",
"(",
"targetPath",
",",
"resourceResolver",
")",
")",
";",
"}",
"else",
"{",
"rewrittenPath",
"=",
"targetPath",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"rewrittenPath",
")",
")",
"{",
"return",
"null",
";",
"}",
"// Get target page referenced by target path and check for acceptance",
"Page",
"targetPage",
"=",
"pageManager",
".",
"getPage",
"(",
"rewrittenPath",
")",
";",
"if",
"(",
"acceptPage",
"(",
"targetPage",
",",
"options",
")",
")",
"{",
"return",
"targetPage",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
]
| Returns the target page for the given internal content link reference.
Checks validity of page.
@param targetPath Repository path
@return Target page or null if target reference is invalid. | [
"Returns",
"the",
"target",
"page",
"for",
"the",
"given",
"internal",
"content",
"link",
"reference",
".",
"Checks",
"validity",
"of",
"page",
"."
]
| train | https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/link/src/main/java/io/wcm/handler/link/type/helpers/InternalLinkResolver.java#L244-L270 |
igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoStore.java | OmemoStore.isAvailableDeviceId | boolean isAvailableDeviceId(OmemoDevice userDevice, int id) {
"""
Check, if our freshly generated deviceId is available (unique) in our deviceList.
@param userDevice our current device.
@param id deviceId to check for.
@return true if list did not contain our id, else false
"""
LOGGER.log(Level.INFO, "Check if id " + id + " is available...");
// Lookup local cached device list
BareJid ownJid = userDevice.getJid();
OmemoCachedDeviceList cachedDeviceList;
cachedDeviceList = loadCachedDeviceList(userDevice, ownJid);
if (cachedDeviceList == null) {
cachedDeviceList = new OmemoCachedDeviceList();
}
// Does the list already contain that id?
return !cachedDeviceList.contains(id);
} | java | boolean isAvailableDeviceId(OmemoDevice userDevice, int id) {
LOGGER.log(Level.INFO, "Check if id " + id + " is available...");
// Lookup local cached device list
BareJid ownJid = userDevice.getJid();
OmemoCachedDeviceList cachedDeviceList;
cachedDeviceList = loadCachedDeviceList(userDevice, ownJid);
if (cachedDeviceList == null) {
cachedDeviceList = new OmemoCachedDeviceList();
}
// Does the list already contain that id?
return !cachedDeviceList.contains(id);
} | [
"boolean",
"isAvailableDeviceId",
"(",
"OmemoDevice",
"userDevice",
",",
"int",
"id",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Check if id \"",
"+",
"id",
"+",
"\" is available...\"",
")",
";",
"// Lookup local cached device list",
"BareJid",
"ownJid",
"=",
"userDevice",
".",
"getJid",
"(",
")",
";",
"OmemoCachedDeviceList",
"cachedDeviceList",
";",
"cachedDeviceList",
"=",
"loadCachedDeviceList",
"(",
"userDevice",
",",
"ownJid",
")",
";",
"if",
"(",
"cachedDeviceList",
"==",
"null",
")",
"{",
"cachedDeviceList",
"=",
"new",
"OmemoCachedDeviceList",
"(",
")",
";",
"}",
"// Does the list already contain that id?",
"return",
"!",
"cachedDeviceList",
".",
"contains",
"(",
"id",
")",
";",
"}"
]
| Check, if our freshly generated deviceId is available (unique) in our deviceList.
@param userDevice our current device.
@param id deviceId to check for.
@return true if list did not contain our id, else false | [
"Check",
"if",
"our",
"freshly",
"generated",
"deviceId",
"is",
"available",
"(",
"unique",
")",
"in",
"our",
"deviceList",
"."
]
| train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoStore.java#L81-L95 |
virgo47/javasimon | core/src/main/java/org/javasimon/utils/SimonUtils.java | SimonUtils.doWithStopwatch | public static <T> T doWithStopwatch(String name, Callable<T> callable) throws Exception {
"""
Calls a block of code with stopwatch around and returns result.
@param name name of the Stopwatch
@param callable callable block of code
@param <T> return type
@return whatever block of code returns
@throws Exception whatever block of code throws
@since 3.0
"""
try (Split split = SimonManager.getStopwatch(name).start()) {
return callable.call();
}
} | java | public static <T> T doWithStopwatch(String name, Callable<T> callable) throws Exception {
try (Split split = SimonManager.getStopwatch(name).start()) {
return callable.call();
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"doWithStopwatch",
"(",
"String",
"name",
",",
"Callable",
"<",
"T",
">",
"callable",
")",
"throws",
"Exception",
"{",
"try",
"(",
"Split",
"split",
"=",
"SimonManager",
".",
"getStopwatch",
"(",
"name",
")",
".",
"start",
"(",
")",
")",
"{",
"return",
"callable",
".",
"call",
"(",
")",
";",
"}",
"}"
]
| Calls a block of code with stopwatch around and returns result.
@param name name of the Stopwatch
@param callable callable block of code
@param <T> return type
@return whatever block of code returns
@throws Exception whatever block of code throws
@since 3.0 | [
"Calls",
"a",
"block",
"of",
"code",
"with",
"stopwatch",
"around",
"and",
"returns",
"result",
"."
]
| train | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/utils/SimonUtils.java#L344-L348 |
real-logic/simple-binary-encoding | sbe-tool/src/main/java/uk/co/real_logic/sbe/otf/OtfHeaderDecoder.java | OtfHeaderDecoder.getSchemaVersion | public int getSchemaVersion(final DirectBuffer buffer, final int bufferOffset) {
"""
Get the schema version number from the message header.
@param buffer from which to read the value.
@param bufferOffset in the buffer at which the message header begins.
@return the value of the schema version number.
"""
return Types.getInt(buffer, bufferOffset + schemaVersionOffset, schemaVersionType, schemaVersionByteOrder);
} | java | public int getSchemaVersion(final DirectBuffer buffer, final int bufferOffset)
{
return Types.getInt(buffer, bufferOffset + schemaVersionOffset, schemaVersionType, schemaVersionByteOrder);
} | [
"public",
"int",
"getSchemaVersion",
"(",
"final",
"DirectBuffer",
"buffer",
",",
"final",
"int",
"bufferOffset",
")",
"{",
"return",
"Types",
".",
"getInt",
"(",
"buffer",
",",
"bufferOffset",
"+",
"schemaVersionOffset",
",",
"schemaVersionType",
",",
"schemaVersionByteOrder",
")",
";",
"}"
]
| Get the schema version number from the message header.
@param buffer from which to read the value.
@param bufferOffset in the buffer at which the message header begins.
@return the value of the schema version number. | [
"Get",
"the",
"schema",
"version",
"number",
"from",
"the",
"message",
"header",
"."
]
| train | https://github.com/real-logic/simple-binary-encoding/blob/9a7be490c86d98f0e430e4189bc6c8c4fbef658b/sbe-tool/src/main/java/uk/co/real_logic/sbe/otf/OtfHeaderDecoder.java#L130-L133 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/functions/FunctionOneArg.java | FunctionOneArg.fixupVariables | public void fixupVariables(java.util.Vector vars, int globalsSize) {
"""
This function is used to fixup variables from QNames to stack frame
indexes at stylesheet build time.
@param vars List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame).
"""
if(null != m_arg0)
m_arg0.fixupVariables(vars, globalsSize);
} | java | public void fixupVariables(java.util.Vector vars, int globalsSize)
{
if(null != m_arg0)
m_arg0.fixupVariables(vars, globalsSize);
} | [
"public",
"void",
"fixupVariables",
"(",
"java",
".",
"util",
".",
"Vector",
"vars",
",",
"int",
"globalsSize",
")",
"{",
"if",
"(",
"null",
"!=",
"m_arg0",
")",
"m_arg0",
".",
"fixupVariables",
"(",
"vars",
",",
"globalsSize",
")",
";",
"}"
]
| This function is used to fixup variables from QNames to stack frame
indexes at stylesheet build time.
@param vars List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame). | [
"This",
"function",
"is",
"used",
"to",
"fixup",
"variables",
"from",
"QNames",
"to",
"stack",
"frame",
"indexes",
"at",
"stylesheet",
"build",
"time",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/functions/FunctionOneArg.java#L118-L122 |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java | GraphsHandler.addModuleToGraph | private void addModuleToGraph(final DbModule module, final AbstractGraph graph, final int depth) {
"""
Manage the artifact add to the Module AbstractGraph
@param graph
@param depth
"""
if (graph.isTreated(graph.getId(module))) {
return;
}
final String moduleElementId = graph.getId(module);
graph.addElement(moduleElementId, module.getVersion(), depth == 0);
if (filters.getDepthHandler().shouldGoDeeper(depth)) {
for (final DbDependency dep : DataUtils.getAllDbDependencies(module)) {
if(filters.shouldBeInReport(dep)){
addDependencyToGraph(dep, graph, depth + 1, moduleElementId);
}
}
}
} | java | private void addModuleToGraph(final DbModule module, final AbstractGraph graph, final int depth) {
if (graph.isTreated(graph.getId(module))) {
return;
}
final String moduleElementId = graph.getId(module);
graph.addElement(moduleElementId, module.getVersion(), depth == 0);
if (filters.getDepthHandler().shouldGoDeeper(depth)) {
for (final DbDependency dep : DataUtils.getAllDbDependencies(module)) {
if(filters.shouldBeInReport(dep)){
addDependencyToGraph(dep, graph, depth + 1, moduleElementId);
}
}
}
} | [
"private",
"void",
"addModuleToGraph",
"(",
"final",
"DbModule",
"module",
",",
"final",
"AbstractGraph",
"graph",
",",
"final",
"int",
"depth",
")",
"{",
"if",
"(",
"graph",
".",
"isTreated",
"(",
"graph",
".",
"getId",
"(",
"module",
")",
")",
")",
"{",
"return",
";",
"}",
"final",
"String",
"moduleElementId",
"=",
"graph",
".",
"getId",
"(",
"module",
")",
";",
"graph",
".",
"addElement",
"(",
"moduleElementId",
",",
"module",
".",
"getVersion",
"(",
")",
",",
"depth",
"==",
"0",
")",
";",
"if",
"(",
"filters",
".",
"getDepthHandler",
"(",
")",
".",
"shouldGoDeeper",
"(",
"depth",
")",
")",
"{",
"for",
"(",
"final",
"DbDependency",
"dep",
":",
"DataUtils",
".",
"getAllDbDependencies",
"(",
"module",
")",
")",
"{",
"if",
"(",
"filters",
".",
"shouldBeInReport",
"(",
"dep",
")",
")",
"{",
"addDependencyToGraph",
"(",
"dep",
",",
"graph",
",",
"depth",
"+",
"1",
",",
"moduleElementId",
")",
";",
"}",
"}",
"}",
"}"
]
| Manage the artifact add to the Module AbstractGraph
@param graph
@param depth | [
"Manage",
"the",
"artifact",
"add",
"to",
"the",
"Module",
"AbstractGraph"
]
| train | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java#L64-L79 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/rules/constraint/Constraints.java | Constraints.ifTrue | public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint,
PropertyConstraint elseConstraint) {
"""
Returns a ConditionalPropertyConstraint: one property will trigger the
validation of another.
@see ConditionalPropertyConstraint
"""
return new ConditionalPropertyConstraint(ifConstraint, thenConstraint, elseConstraint);
} | java | public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint,
PropertyConstraint elseConstraint) {
return new ConditionalPropertyConstraint(ifConstraint, thenConstraint, elseConstraint);
} | [
"public",
"PropertyConstraint",
"ifTrue",
"(",
"PropertyConstraint",
"ifConstraint",
",",
"PropertyConstraint",
"thenConstraint",
",",
"PropertyConstraint",
"elseConstraint",
")",
"{",
"return",
"new",
"ConditionalPropertyConstraint",
"(",
"ifConstraint",
",",
"thenConstraint",
",",
"elseConstraint",
")",
";",
"}"
]
| Returns a ConditionalPropertyConstraint: one property will trigger the
validation of another.
@see ConditionalPropertyConstraint | [
"Returns",
"a",
"ConditionalPropertyConstraint",
":",
"one",
"property",
"will",
"trigger",
"the",
"validation",
"of",
"another",
"."
]
| train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/rules/constraint/Constraints.java#L328-L331 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/GregorianCalendar.java | GregorianCalendar.getWeekNumber | private int getWeekNumber(long fixedDay1, long fixedDate) {
"""
Returns the number of weeks in a period between fixedDay1 and
fixedDate. The getFirstDayOfWeek-getMinimalDaysInFirstWeek rule
is applied to calculate the number of weeks.
@param fixedDay1 the fixed date of the first day of the period
@param fixedDate the fixed date of the last day of the period
@return the number of weeks of the given period
"""
// We can always use `gcal' since Julian and Gregorian are the
// same thing for this calculation.
long fixedDay1st = Gregorian.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
getFirstDayOfWeek());
int ndays = (int)(fixedDay1st - fixedDay1);
assert ndays <= 7;
if (ndays >= getMinimalDaysInFirstWeek()) {
fixedDay1st -= 7;
}
int normalizedDayOfPeriod = (int)(fixedDate - fixedDay1st);
if (normalizedDayOfPeriod >= 0) {
return normalizedDayOfPeriod / 7 + 1;
}
return CalendarUtils.floorDivide(normalizedDayOfPeriod, 7) + 1;
} | java | private int getWeekNumber(long fixedDay1, long fixedDate) {
// We can always use `gcal' since Julian and Gregorian are the
// same thing for this calculation.
long fixedDay1st = Gregorian.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
getFirstDayOfWeek());
int ndays = (int)(fixedDay1st - fixedDay1);
assert ndays <= 7;
if (ndays >= getMinimalDaysInFirstWeek()) {
fixedDay1st -= 7;
}
int normalizedDayOfPeriod = (int)(fixedDate - fixedDay1st);
if (normalizedDayOfPeriod >= 0) {
return normalizedDayOfPeriod / 7 + 1;
}
return CalendarUtils.floorDivide(normalizedDayOfPeriod, 7) + 1;
} | [
"private",
"int",
"getWeekNumber",
"(",
"long",
"fixedDay1",
",",
"long",
"fixedDate",
")",
"{",
"// We can always use `gcal' since Julian and Gregorian are the",
"// same thing for this calculation.",
"long",
"fixedDay1st",
"=",
"Gregorian",
".",
"getDayOfWeekDateOnOrBefore",
"(",
"fixedDay1",
"+",
"6",
",",
"getFirstDayOfWeek",
"(",
")",
")",
";",
"int",
"ndays",
"=",
"(",
"int",
")",
"(",
"fixedDay1st",
"-",
"fixedDay1",
")",
";",
"assert",
"ndays",
"<=",
"7",
";",
"if",
"(",
"ndays",
">=",
"getMinimalDaysInFirstWeek",
"(",
")",
")",
"{",
"fixedDay1st",
"-=",
"7",
";",
"}",
"int",
"normalizedDayOfPeriod",
"=",
"(",
"int",
")",
"(",
"fixedDate",
"-",
"fixedDay1st",
")",
";",
"if",
"(",
"normalizedDayOfPeriod",
">=",
"0",
")",
"{",
"return",
"normalizedDayOfPeriod",
"/",
"7",
"+",
"1",
";",
"}",
"return",
"CalendarUtils",
".",
"floorDivide",
"(",
"normalizedDayOfPeriod",
",",
"7",
")",
"+",
"1",
";",
"}"
]
| Returns the number of weeks in a period between fixedDay1 and
fixedDate. The getFirstDayOfWeek-getMinimalDaysInFirstWeek rule
is applied to calculate the number of weeks.
@param fixedDay1 the fixed date of the first day of the period
@param fixedDate the fixed date of the last day of the period
@return the number of weeks of the given period | [
"Returns",
"the",
"number",
"of",
"weeks",
"in",
"a",
"period",
"between",
"fixedDay1",
"and",
"fixedDate",
".",
"The",
"getFirstDayOfWeek",
"-",
"getMinimalDaysInFirstWeek",
"rule",
"is",
"applied",
"to",
"calculate",
"the",
"number",
"of",
"weeks",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/GregorianCalendar.java#L2598-L2613 |
netty/netty | transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueStreamChannel.java | AbstractKQueueStreamChannel.writeBytes | private int writeBytes(ChannelOutboundBuffer in, ByteBuf buf) throws Exception {
"""
Write bytes form the given {@link ByteBuf} to the underlying {@link java.nio.channels.Channel}.
@param in the collection which contains objects to write.
@param buf the {@link ByteBuf} from which the bytes should be written
@return The value that should be decremented from the write quantum which starts at
{@link ChannelConfig#getWriteSpinCount()}. The typical use cases are as follows:
<ul>
<li>0 - if no write was attempted. This is appropriate if an empty {@link ByteBuf} (or other empty content)
is encountered</li>
<li>1 - if a single call to write data was made to the OS</li>
<li>{@link ChannelUtils#WRITE_STATUS_SNDBUF_FULL} - if an attempt to write data was made to the OS, but no
data was accepted</li>
</ul>
"""
int readableBytes = buf.readableBytes();
if (readableBytes == 0) {
in.remove();
return 0;
}
if (buf.hasMemoryAddress() || buf.nioBufferCount() == 1) {
return doWriteBytes(in, buf);
} else {
ByteBuffer[] nioBuffers = buf.nioBuffers();
return writeBytesMultiple(in, nioBuffers, nioBuffers.length, readableBytes,
config().getMaxBytesPerGatheringWrite());
}
} | java | private int writeBytes(ChannelOutboundBuffer in, ByteBuf buf) throws Exception {
int readableBytes = buf.readableBytes();
if (readableBytes == 0) {
in.remove();
return 0;
}
if (buf.hasMemoryAddress() || buf.nioBufferCount() == 1) {
return doWriteBytes(in, buf);
} else {
ByteBuffer[] nioBuffers = buf.nioBuffers();
return writeBytesMultiple(in, nioBuffers, nioBuffers.length, readableBytes,
config().getMaxBytesPerGatheringWrite());
}
} | [
"private",
"int",
"writeBytes",
"(",
"ChannelOutboundBuffer",
"in",
",",
"ByteBuf",
"buf",
")",
"throws",
"Exception",
"{",
"int",
"readableBytes",
"=",
"buf",
".",
"readableBytes",
"(",
")",
";",
"if",
"(",
"readableBytes",
"==",
"0",
")",
"{",
"in",
".",
"remove",
"(",
")",
";",
"return",
"0",
";",
"}",
"if",
"(",
"buf",
".",
"hasMemoryAddress",
"(",
")",
"||",
"buf",
".",
"nioBufferCount",
"(",
")",
"==",
"1",
")",
"{",
"return",
"doWriteBytes",
"(",
"in",
",",
"buf",
")",
";",
"}",
"else",
"{",
"ByteBuffer",
"[",
"]",
"nioBuffers",
"=",
"buf",
".",
"nioBuffers",
"(",
")",
";",
"return",
"writeBytesMultiple",
"(",
"in",
",",
"nioBuffers",
",",
"nioBuffers",
".",
"length",
",",
"readableBytes",
",",
"config",
"(",
")",
".",
"getMaxBytesPerGatheringWrite",
"(",
")",
")",
";",
"}",
"}"
]
| Write bytes form the given {@link ByteBuf} to the underlying {@link java.nio.channels.Channel}.
@param in the collection which contains objects to write.
@param buf the {@link ByteBuf} from which the bytes should be written
@return The value that should be decremented from the write quantum which starts at
{@link ChannelConfig#getWriteSpinCount()}. The typical use cases are as follows:
<ul>
<li>0 - if no write was attempted. This is appropriate if an empty {@link ByteBuf} (or other empty content)
is encountered</li>
<li>1 - if a single call to write data was made to the OS</li>
<li>{@link ChannelUtils#WRITE_STATUS_SNDBUF_FULL} - if an attempt to write data was made to the OS, but no
data was accepted</li>
</ul> | [
"Write",
"bytes",
"form",
"the",
"given",
"{"
]
| train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueStreamChannel.java#L103-L117 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/Calendar.java | Calendar.getInstanceInternal | private static Calendar getInstanceInternal(TimeZone tz, ULocale locale) {
"""
/*
All getInstance implementations call this private method to create a new
Calendar instance.
"""
if (locale == null) {
locale = ULocale.getDefault(Category.FORMAT);
}
if (tz == null) {
tz = TimeZone.getDefault();
}
Calendar cal = createInstance(locale);
cal.setTimeZone(tz);
cal.setTimeInMillis(System.currentTimeMillis());
return cal;
} | java | private static Calendar getInstanceInternal(TimeZone tz, ULocale locale) {
if (locale == null) {
locale = ULocale.getDefault(Category.FORMAT);
}
if (tz == null) {
tz = TimeZone.getDefault();
}
Calendar cal = createInstance(locale);
cal.setTimeZone(tz);
cal.setTimeInMillis(System.currentTimeMillis());
return cal;
} | [
"private",
"static",
"Calendar",
"getInstanceInternal",
"(",
"TimeZone",
"tz",
",",
"ULocale",
"locale",
")",
"{",
"if",
"(",
"locale",
"==",
"null",
")",
"{",
"locale",
"=",
"ULocale",
".",
"getDefault",
"(",
"Category",
".",
"FORMAT",
")",
";",
"}",
"if",
"(",
"tz",
"==",
"null",
")",
"{",
"tz",
"=",
"TimeZone",
".",
"getDefault",
"(",
")",
";",
"}",
"Calendar",
"cal",
"=",
"createInstance",
"(",
"locale",
")",
";",
"cal",
".",
"setTimeZone",
"(",
"tz",
")",
";",
"cal",
".",
"setTimeInMillis",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"return",
"cal",
";",
"}"
]
| /*
All getInstance implementations call this private method to create a new
Calendar instance. | [
"/",
"*",
"All",
"getInstance",
"implementations",
"call",
"this",
"private",
"method",
"to",
"create",
"a",
"new",
"Calendar",
"instance",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/Calendar.java#L1685-L1697 |
primefaces-extensions/core | src/main/java/org/primefaces/extensions/util/JavascriptVarBuilder.java | JavascriptVarBuilder.appendRowColProperty | public JavascriptVarBuilder appendRowColProperty(final int row, final int col, final String propertyValue, final boolean quoted) {
"""
appends a property with the name "rYY_cXX" where YY is the row and XX is he column.
@param row
@param col
@param propertyValue
@param quoted
@return
"""
return appendProperty("r" + row + "_c" + col, propertyValue, quoted);
} | java | public JavascriptVarBuilder appendRowColProperty(final int row, final int col, final String propertyValue, final boolean quoted) {
return appendProperty("r" + row + "_c" + col, propertyValue, quoted);
} | [
"public",
"JavascriptVarBuilder",
"appendRowColProperty",
"(",
"final",
"int",
"row",
",",
"final",
"int",
"col",
",",
"final",
"String",
"propertyValue",
",",
"final",
"boolean",
"quoted",
")",
"{",
"return",
"appendProperty",
"(",
"\"r\"",
"+",
"row",
"+",
"\"_c\"",
"+",
"col",
",",
"propertyValue",
",",
"quoted",
")",
";",
"}"
]
| appends a property with the name "rYY_cXX" where YY is the row and XX is he column.
@param row
@param col
@param propertyValue
@param quoted
@return | [
"appends",
"a",
"property",
"with",
"the",
"name",
"rYY_cXX",
"where",
"YY",
"is",
"the",
"row",
"and",
"XX",
"is",
"he",
"column",
"."
]
| train | https://github.com/primefaces-extensions/core/blob/afdbca591f60f47898e3517e1e939bc2f63d5355/src/main/java/org/primefaces/extensions/util/JavascriptVarBuilder.java#L95-L97 |
FasterXML/woodstox | src/main/java/com/ctc/wstx/util/PrefixedName.java | PrefixedName.isXmlReservedAttr | public boolean isXmlReservedAttr(boolean nsAware, String localName) {
"""
Method used to check for xml reserved attribute names, like
"xml:space" and "xml:id".
<p>
Note: it is assumed that the passed-in localName is also
interned.
"""
if (nsAware) {
if ("xml" == mPrefix) {
return mLocalName == localName;
}
} else {
if (mLocalName.length() == (4 + localName.length())) {
return (mLocalName.startsWith("xml:")
&& mLocalName.endsWith(localName));
}
}
return false;
} | java | public boolean isXmlReservedAttr(boolean nsAware, String localName)
{
if (nsAware) {
if ("xml" == mPrefix) {
return mLocalName == localName;
}
} else {
if (mLocalName.length() == (4 + localName.length())) {
return (mLocalName.startsWith("xml:")
&& mLocalName.endsWith(localName));
}
}
return false;
} | [
"public",
"boolean",
"isXmlReservedAttr",
"(",
"boolean",
"nsAware",
",",
"String",
"localName",
")",
"{",
"if",
"(",
"nsAware",
")",
"{",
"if",
"(",
"\"xml\"",
"==",
"mPrefix",
")",
"{",
"return",
"mLocalName",
"==",
"localName",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"mLocalName",
".",
"length",
"(",
")",
"==",
"(",
"4",
"+",
"localName",
".",
"length",
"(",
")",
")",
")",
"{",
"return",
"(",
"mLocalName",
".",
"startsWith",
"(",
"\"xml:\"",
")",
"&&",
"mLocalName",
".",
"endsWith",
"(",
"localName",
")",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Method used to check for xml reserved attribute names, like
"xml:space" and "xml:id".
<p>
Note: it is assumed that the passed-in localName is also
interned. | [
"Method",
"used",
"to",
"check",
"for",
"xml",
"reserved",
"attribute",
"names",
"like",
"xml",
":",
"space",
"and",
"xml",
":",
"id",
".",
"<p",
">",
"Note",
":",
"it",
"is",
"assumed",
"that",
"the",
"passed",
"-",
"in",
"localName",
"is",
"also",
"interned",
"."
]
| train | https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/util/PrefixedName.java#L100-L113 |
lettuce-io/lettuce-core | src/main/java/io/lettuce/core/masterslave/MasterSlaveUtils.java | MasterSlaveUtils.findNodeByHostAndPort | static RedisNodeDescription findNodeByHostAndPort(Collection<RedisNodeDescription> nodes, String host, int port) {
"""
Lookup a {@link RedisNodeDescription} by {@code host} and {@code port}.
@param nodes
@param host
@param port
@return the {@link RedisNodeDescription} or {@literal null}
"""
for (RedisNodeDescription node : nodes) {
RedisURI nodeUri = node.getUri();
if (nodeUri.getHost().equals(host) && nodeUri.getPort() == port) {
return node;
}
}
return null;
} | java | static RedisNodeDescription findNodeByHostAndPort(Collection<RedisNodeDescription> nodes, String host, int port) {
for (RedisNodeDescription node : nodes) {
RedisURI nodeUri = node.getUri();
if (nodeUri.getHost().equals(host) && nodeUri.getPort() == port) {
return node;
}
}
return null;
} | [
"static",
"RedisNodeDescription",
"findNodeByHostAndPort",
"(",
"Collection",
"<",
"RedisNodeDescription",
">",
"nodes",
",",
"String",
"host",
",",
"int",
"port",
")",
"{",
"for",
"(",
"RedisNodeDescription",
"node",
":",
"nodes",
")",
"{",
"RedisURI",
"nodeUri",
"=",
"node",
".",
"getUri",
"(",
")",
";",
"if",
"(",
"nodeUri",
".",
"getHost",
"(",
")",
".",
"equals",
"(",
"host",
")",
"&&",
"nodeUri",
".",
"getPort",
"(",
")",
"==",
"port",
")",
"{",
"return",
"node",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Lookup a {@link RedisNodeDescription} by {@code host} and {@code port}.
@param nodes
@param host
@param port
@return the {@link RedisNodeDescription} or {@literal null} | [
"Lookup",
"a",
"{",
"@link",
"RedisNodeDescription",
"}",
"by",
"{",
"@code",
"host",
"}",
"and",
"{",
"@code",
"port",
"}",
"."
]
| train | https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/masterslave/MasterSlaveUtils.java#L72-L80 |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/internal/security/ldap/TimebasedOrderFilter.java | TimebasedOrderFilter.addIds | public static void addIds(List<Entry> entries, boolean updateRdn) {
"""
Iterates over entries and adds a timebased uuid to each entry. If updateRdn is true, the uuid becomes the rdn.
Use this to handle duplicates.
"""
for (Entry entry : entries) {
addId(entry, updateRdn);
}
} | java | public static void addIds(List<Entry> entries, boolean updateRdn) {
for (Entry entry : entries) {
addId(entry, updateRdn);
}
} | [
"public",
"static",
"void",
"addIds",
"(",
"List",
"<",
"Entry",
">",
"entries",
",",
"boolean",
"updateRdn",
")",
"{",
"for",
"(",
"Entry",
"entry",
":",
"entries",
")",
"{",
"addId",
"(",
"entry",
",",
"updateRdn",
")",
";",
"}",
"}"
]
| Iterates over entries and adds a timebased uuid to each entry. If updateRdn is true, the uuid becomes the rdn.
Use this to handle duplicates. | [
"Iterates",
"over",
"entries",
"and",
"adds",
"a",
"timebased",
"uuid",
"to",
"each",
"entry",
".",
"If",
"updateRdn",
"is",
"true",
"the",
"uuid",
"becomes",
"the",
"rdn",
".",
"Use",
"this",
"to",
"handle",
"duplicates",
"."
]
| train | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/internal/security/ldap/TimebasedOrderFilter.java#L75-L79 |
google/gson | gson/src/main/java/com/google/gson/Gson.java | Gson.toJson | public void toJson(Object src, Appendable writer) throws JsonIOException {
"""
This method serializes the specified object into its equivalent Json representation.
This method should be used when the specified object is not a generic type. This method uses
{@link Class#getClass()} to get the type for the specified object, but the
{@code getClass()} loses the generic type information because of the Type Erasure feature
of Java. Note that this method works fine if the any of the object fields are of generic type,
just the object itself should not be of a generic type. If the object is of generic type, use
{@link #toJson(Object, Type, Appendable)} instead.
@param src the object for which Json representation is to be created setting for Gson
@param writer Writer to which the Json representation needs to be written
@throws JsonIOException if there was a problem writing to the writer
@since 1.2
"""
if (src != null) {
toJson(src, src.getClass(), writer);
} else {
toJson(JsonNull.INSTANCE, writer);
}
} | java | public void toJson(Object src, Appendable writer) throws JsonIOException {
if (src != null) {
toJson(src, src.getClass(), writer);
} else {
toJson(JsonNull.INSTANCE, writer);
}
} | [
"public",
"void",
"toJson",
"(",
"Object",
"src",
",",
"Appendable",
"writer",
")",
"throws",
"JsonIOException",
"{",
"if",
"(",
"src",
"!=",
"null",
")",
"{",
"toJson",
"(",
"src",
",",
"src",
".",
"getClass",
"(",
")",
",",
"writer",
")",
";",
"}",
"else",
"{",
"toJson",
"(",
"JsonNull",
".",
"INSTANCE",
",",
"writer",
")",
";",
"}",
"}"
]
| This method serializes the specified object into its equivalent Json representation.
This method should be used when the specified object is not a generic type. This method uses
{@link Class#getClass()} to get the type for the specified object, but the
{@code getClass()} loses the generic type information because of the Type Erasure feature
of Java. Note that this method works fine if the any of the object fields are of generic type,
just the object itself should not be of a generic type. If the object is of generic type, use
{@link #toJson(Object, Type, Appendable)} instead.
@param src the object for which Json representation is to be created setting for Gson
@param writer Writer to which the Json representation needs to be written
@throws JsonIOException if there was a problem writing to the writer
@since 1.2 | [
"This",
"method",
"serializes",
"the",
"specified",
"object",
"into",
"its",
"equivalent",
"Json",
"representation",
".",
"This",
"method",
"should",
"be",
"used",
"when",
"the",
"specified",
"object",
"is",
"not",
"a",
"generic",
"type",
".",
"This",
"method",
"uses",
"{",
"@link",
"Class#getClass",
"()",
"}",
"to",
"get",
"the",
"type",
"for",
"the",
"specified",
"object",
"but",
"the",
"{",
"@code",
"getClass",
"()",
"}",
"loses",
"the",
"generic",
"type",
"information",
"because",
"of",
"the",
"Type",
"Erasure",
"feature",
"of",
"Java",
".",
"Note",
"that",
"this",
"method",
"works",
"fine",
"if",
"the",
"any",
"of",
"the",
"object",
"fields",
"are",
"of",
"generic",
"type",
"just",
"the",
"object",
"itself",
"should",
"not",
"be",
"of",
"a",
"generic",
"type",
".",
"If",
"the",
"object",
"is",
"of",
"generic",
"type",
"use",
"{",
"@link",
"#toJson",
"(",
"Object",
"Type",
"Appendable",
")",
"}",
"instead",
"."
]
| train | https://github.com/google/gson/blob/63ee47cb642c8018e5cddd639aa2be143220ad4b/gson/src/main/java/com/google/gson/Gson.java#L656-L662 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/URI.java | URI.setHost | public void setHost(String p_host) throws MalformedURIException {
"""
Set the host for this URI. If null is passed in, the userinfo
field is also set to null and the port is set to -1.
@param p_host the host for this URI
@throws MalformedURIException if p_host is not a valid IP
address or DNS hostname.
"""
if (p_host == null || p_host.trim().length() == 0)
{
m_host = p_host;
m_userinfo = null;
m_port = -1;
}
else if (!isWellFormedAddress(p_host))
{
throw new MalformedURIException(XMLMessages.createXMLMessage(XMLErrorResources.ER_HOST_ADDRESS_NOT_WELLFORMED, null)); //"Host is not a well formed address!");
}
m_host = p_host;
} | java | public void setHost(String p_host) throws MalformedURIException
{
if (p_host == null || p_host.trim().length() == 0)
{
m_host = p_host;
m_userinfo = null;
m_port = -1;
}
else if (!isWellFormedAddress(p_host))
{
throw new MalformedURIException(XMLMessages.createXMLMessage(XMLErrorResources.ER_HOST_ADDRESS_NOT_WELLFORMED, null)); //"Host is not a well formed address!");
}
m_host = p_host;
} | [
"public",
"void",
"setHost",
"(",
"String",
"p_host",
")",
"throws",
"MalformedURIException",
"{",
"if",
"(",
"p_host",
"==",
"null",
"||",
"p_host",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"m_host",
"=",
"p_host",
";",
"m_userinfo",
"=",
"null",
";",
"m_port",
"=",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"!",
"isWellFormedAddress",
"(",
"p_host",
")",
")",
"{",
"throw",
"new",
"MalformedURIException",
"(",
"XMLMessages",
".",
"createXMLMessage",
"(",
"XMLErrorResources",
".",
"ER_HOST_ADDRESS_NOT_WELLFORMED",
",",
"null",
")",
")",
";",
"//\"Host is not a well formed address!\");",
"}",
"m_host",
"=",
"p_host",
";",
"}"
]
| Set the host for this URI. If null is passed in, the userinfo
field is also set to null and the port is set to -1.
@param p_host the host for this URI
@throws MalformedURIException if p_host is not a valid IP
address or DNS hostname. | [
"Set",
"the",
"host",
"for",
"this",
"URI",
".",
"If",
"null",
"is",
"passed",
"in",
"the",
"userinfo",
"field",
"is",
"also",
"set",
"to",
"null",
"and",
"the",
"port",
"is",
"set",
"to",
"-",
"1",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/URI.java#L1118-L1133 |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/mgmt/HostControllerRegistrationHandler.java | HostControllerRegistrationHandler.sendResponse | static void sendResponse(final ManagementRequestContext<RegistrationContext> context, final byte responseType, final ModelNode response) throws IOException {
"""
Send an operation response.
@param context the request context
@param responseType the response type
@param response the operation response
@throws IOException for any error
"""
final ManagementResponseHeader header = ManagementResponseHeader.create(context.getRequestHeader());
final FlushableDataOutput output = context.writeMessage(header);
try {
sendResponse(output, responseType, response);
} finally {
StreamUtils.safeClose(output);
}
} | java | static void sendResponse(final ManagementRequestContext<RegistrationContext> context, final byte responseType, final ModelNode response) throws IOException {
final ManagementResponseHeader header = ManagementResponseHeader.create(context.getRequestHeader());
final FlushableDataOutput output = context.writeMessage(header);
try {
sendResponse(output, responseType, response);
} finally {
StreamUtils.safeClose(output);
}
} | [
"static",
"void",
"sendResponse",
"(",
"final",
"ManagementRequestContext",
"<",
"RegistrationContext",
">",
"context",
",",
"final",
"byte",
"responseType",
",",
"final",
"ModelNode",
"response",
")",
"throws",
"IOException",
"{",
"final",
"ManagementResponseHeader",
"header",
"=",
"ManagementResponseHeader",
".",
"create",
"(",
"context",
".",
"getRequestHeader",
"(",
")",
")",
";",
"final",
"FlushableDataOutput",
"output",
"=",
"context",
".",
"writeMessage",
"(",
"header",
")",
";",
"try",
"{",
"sendResponse",
"(",
"output",
",",
"responseType",
",",
"response",
")",
";",
"}",
"finally",
"{",
"StreamUtils",
".",
"safeClose",
"(",
"output",
")",
";",
"}",
"}"
]
| Send an operation response.
@param context the request context
@param responseType the response type
@param response the operation response
@throws IOException for any error | [
"Send",
"an",
"operation",
"response",
"."
]
| train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/mgmt/HostControllerRegistrationHandler.java#L715-L723 |
knowm/XChange | xchange-wex/src/main/java/org/knowm/xchange/wex/v3/WexAdapters.java | WexAdapters.adaptOrder | public static LimitOrder adaptOrder(
BigDecimal amount,
BigDecimal price,
CurrencyPair currencyPair,
OrderType orderType,
String id) {
"""
Adapts a WexOrder to a LimitOrder
@param amount
@param price
@param currencyPair
@param orderType
@param id
@return
"""
return new LimitOrder(orderType, amount, currencyPair, id, null, price);
} | java | public static LimitOrder adaptOrder(
BigDecimal amount,
BigDecimal price,
CurrencyPair currencyPair,
OrderType orderType,
String id) {
return new LimitOrder(orderType, amount, currencyPair, id, null, price);
} | [
"public",
"static",
"LimitOrder",
"adaptOrder",
"(",
"BigDecimal",
"amount",
",",
"BigDecimal",
"price",
",",
"CurrencyPair",
"currencyPair",
",",
"OrderType",
"orderType",
",",
"String",
"id",
")",
"{",
"return",
"new",
"LimitOrder",
"(",
"orderType",
",",
"amount",
",",
"currencyPair",
",",
"id",
",",
"null",
",",
"price",
")",
";",
"}"
]
| Adapts a WexOrder to a LimitOrder
@param amount
@param price
@param currencyPair
@param orderType
@param id
@return | [
"Adapts",
"a",
"WexOrder",
"to",
"a",
"LimitOrder"
]
| train | https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-wex/src/main/java/org/knowm/xchange/wex/v3/WexAdapters.java#L86-L94 |
apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/util/JobStateToJsonConverter.java | JobStateToJsonConverter.writeJobStates | private void writeJobStates(JsonWriter jsonWriter, List<? extends JobState> jobStates) throws IOException {
"""
Write a list of {@link JobState}s to json document.
@param jsonWriter {@link com.google.gson.stream.JsonWriter}
@param jobStates list of {@link JobState}s to write to json document
@throws IOException
"""
jsonWriter.beginArray();
for (JobState jobState : jobStates) {
writeJobState(jsonWriter, jobState);
}
jsonWriter.endArray();
} | java | private void writeJobStates(JsonWriter jsonWriter, List<? extends JobState> jobStates) throws IOException {
jsonWriter.beginArray();
for (JobState jobState : jobStates) {
writeJobState(jsonWriter, jobState);
}
jsonWriter.endArray();
} | [
"private",
"void",
"writeJobStates",
"(",
"JsonWriter",
"jsonWriter",
",",
"List",
"<",
"?",
"extends",
"JobState",
">",
"jobStates",
")",
"throws",
"IOException",
"{",
"jsonWriter",
".",
"beginArray",
"(",
")",
";",
"for",
"(",
"JobState",
"jobState",
":",
"jobStates",
")",
"{",
"writeJobState",
"(",
"jsonWriter",
",",
"jobState",
")",
";",
"}",
"jsonWriter",
".",
"endArray",
"(",
")",
";",
"}"
]
| Write a list of {@link JobState}s to json document.
@param jsonWriter {@link com.google.gson.stream.JsonWriter}
@param jobStates list of {@link JobState}s to write to json document
@throws IOException | [
"Write",
"a",
"list",
"of",
"{",
"@link",
"JobState",
"}",
"s",
"to",
"json",
"document",
"."
]
| train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/util/JobStateToJsonConverter.java#L148-L154 |
ysc/HtmlExtractor | html-extractor/src/main/java/org/apdplat/extractor/html/impl/ExtractFunctionExecutor.java | ExtractFunctionExecutor.execute | public static String execute(String text, Document doc, CssPath cssPath, String parseExpression) {
"""
执行抽取函数
@param text CSS路径抽取出来的文本
@param doc 根文档
@param cssPath CSS路径对象
@param parseExpression 抽取函数
@return 抽取函数处理之后的文本
"""
if (parseExpression.startsWith("deleteChild")) {
return executeDeleteChild(text, doc, cssPath, parseExpression);
}
if (parseExpression.startsWith("removeText")) {
return executeRemoveText(text, parseExpression);
}
if (parseExpression.startsWith("substring")) {
return executeSubstring(text, parseExpression);
}
return null;
} | java | public static String execute(String text, Document doc, CssPath cssPath, String parseExpression) {
if (parseExpression.startsWith("deleteChild")) {
return executeDeleteChild(text, doc, cssPath, parseExpression);
}
if (parseExpression.startsWith("removeText")) {
return executeRemoveText(text, parseExpression);
}
if (parseExpression.startsWith("substring")) {
return executeSubstring(text, parseExpression);
}
return null;
} | [
"public",
"static",
"String",
"execute",
"(",
"String",
"text",
",",
"Document",
"doc",
",",
"CssPath",
"cssPath",
",",
"String",
"parseExpression",
")",
"{",
"if",
"(",
"parseExpression",
".",
"startsWith",
"(",
"\"deleteChild\"",
")",
")",
"{",
"return",
"executeDeleteChild",
"(",
"text",
",",
"doc",
",",
"cssPath",
",",
"parseExpression",
")",
";",
"}",
"if",
"(",
"parseExpression",
".",
"startsWith",
"(",
"\"removeText\"",
")",
")",
"{",
"return",
"executeRemoveText",
"(",
"text",
",",
"parseExpression",
")",
";",
"}",
"if",
"(",
"parseExpression",
".",
"startsWith",
"(",
"\"substring\"",
")",
")",
"{",
"return",
"executeSubstring",
"(",
"text",
",",
"parseExpression",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| 执行抽取函数
@param text CSS路径抽取出来的文本
@param doc 根文档
@param cssPath CSS路径对象
@param parseExpression 抽取函数
@return 抽取函数处理之后的文本 | [
"执行抽取函数"
]
| train | https://github.com/ysc/HtmlExtractor/blob/5378bc5f94138562c55506cf81de1ffe72ab701e/html-extractor/src/main/java/org/apdplat/extractor/html/impl/ExtractFunctionExecutor.java#L52-L64 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.replaceOptAln | public static AFPChain replaceOptAln(int[][][] newAlgn, AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException {
"""
It replaces an optimal alignment of an AFPChain and calculates all the new alignment scores and variables.
"""
//The order is the number of groups in the newAlgn
int order = newAlgn.length;
//Calculate the alignment length from all the subunits lengths
int[] optLens = new int[order];
for(int s=0;s<order;s++) {
optLens[s] = newAlgn[s][0].length;
}
int optLength = 0;
for(int s=0;s<order;s++) {
optLength += optLens[s];
}
//Create a copy of the original AFPChain and set everything needed for the structure update
AFPChain copyAFP = (AFPChain) afpChain.clone();
//Set the new parameters of the optimal alignment
copyAFP.setOptLength(optLength);
copyAFP.setOptLen(optLens);
copyAFP.setOptAln(newAlgn);
//Set the block information of the new alignment
copyAFP.setBlockNum(order);
copyAFP.setBlockSize(optLens);
copyAFP.setBlockResList(newAlgn);
copyAFP.setBlockResSize(optLens);
copyAFP.setBlockGap(calculateBlockGap(newAlgn));
//Recalculate properties: superposition, tm-score, etc
Atom[] ca2clone = StructureTools.cloneAtomArray(ca2); // don't modify ca2 positions
AlignmentTools.updateSuperposition(copyAFP, ca1, ca2clone);
//It re-does the sequence alignment strings from the OptAlgn information only
copyAFP.setAlnsymb(null);
AFPAlignmentDisplay.getAlign(copyAFP, ca1, ca2clone);
return copyAFP;
} | java | public static AFPChain replaceOptAln(int[][][] newAlgn, AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException {
//The order is the number of groups in the newAlgn
int order = newAlgn.length;
//Calculate the alignment length from all the subunits lengths
int[] optLens = new int[order];
for(int s=0;s<order;s++) {
optLens[s] = newAlgn[s][0].length;
}
int optLength = 0;
for(int s=0;s<order;s++) {
optLength += optLens[s];
}
//Create a copy of the original AFPChain and set everything needed for the structure update
AFPChain copyAFP = (AFPChain) afpChain.clone();
//Set the new parameters of the optimal alignment
copyAFP.setOptLength(optLength);
copyAFP.setOptLen(optLens);
copyAFP.setOptAln(newAlgn);
//Set the block information of the new alignment
copyAFP.setBlockNum(order);
copyAFP.setBlockSize(optLens);
copyAFP.setBlockResList(newAlgn);
copyAFP.setBlockResSize(optLens);
copyAFP.setBlockGap(calculateBlockGap(newAlgn));
//Recalculate properties: superposition, tm-score, etc
Atom[] ca2clone = StructureTools.cloneAtomArray(ca2); // don't modify ca2 positions
AlignmentTools.updateSuperposition(copyAFP, ca1, ca2clone);
//It re-does the sequence alignment strings from the OptAlgn information only
copyAFP.setAlnsymb(null);
AFPAlignmentDisplay.getAlign(copyAFP, ca1, ca2clone);
return copyAFP;
} | [
"public",
"static",
"AFPChain",
"replaceOptAln",
"(",
"int",
"[",
"]",
"[",
"]",
"[",
"]",
"newAlgn",
",",
"AFPChain",
"afpChain",
",",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
")",
"throws",
"StructureException",
"{",
"//The order is the number of groups in the newAlgn",
"int",
"order",
"=",
"newAlgn",
".",
"length",
";",
"//Calculate the alignment length from all the subunits lengths",
"int",
"[",
"]",
"optLens",
"=",
"new",
"int",
"[",
"order",
"]",
";",
"for",
"(",
"int",
"s",
"=",
"0",
";",
"s",
"<",
"order",
";",
"s",
"++",
")",
"{",
"optLens",
"[",
"s",
"]",
"=",
"newAlgn",
"[",
"s",
"]",
"[",
"0",
"]",
".",
"length",
";",
"}",
"int",
"optLength",
"=",
"0",
";",
"for",
"(",
"int",
"s",
"=",
"0",
";",
"s",
"<",
"order",
";",
"s",
"++",
")",
"{",
"optLength",
"+=",
"optLens",
"[",
"s",
"]",
";",
"}",
"//Create a copy of the original AFPChain and set everything needed for the structure update",
"AFPChain",
"copyAFP",
"=",
"(",
"AFPChain",
")",
"afpChain",
".",
"clone",
"(",
")",
";",
"//Set the new parameters of the optimal alignment",
"copyAFP",
".",
"setOptLength",
"(",
"optLength",
")",
";",
"copyAFP",
".",
"setOptLen",
"(",
"optLens",
")",
";",
"copyAFP",
".",
"setOptAln",
"(",
"newAlgn",
")",
";",
"//Set the block information of the new alignment",
"copyAFP",
".",
"setBlockNum",
"(",
"order",
")",
";",
"copyAFP",
".",
"setBlockSize",
"(",
"optLens",
")",
";",
"copyAFP",
".",
"setBlockResList",
"(",
"newAlgn",
")",
";",
"copyAFP",
".",
"setBlockResSize",
"(",
"optLens",
")",
";",
"copyAFP",
".",
"setBlockGap",
"(",
"calculateBlockGap",
"(",
"newAlgn",
")",
")",
";",
"//Recalculate properties: superposition, tm-score, etc",
"Atom",
"[",
"]",
"ca2clone",
"=",
"StructureTools",
".",
"cloneAtomArray",
"(",
"ca2",
")",
";",
"// don't modify ca2 positions",
"AlignmentTools",
".",
"updateSuperposition",
"(",
"copyAFP",
",",
"ca1",
",",
"ca2clone",
")",
";",
"//It re-does the sequence alignment strings from the OptAlgn information only",
"copyAFP",
".",
"setAlnsymb",
"(",
"null",
")",
";",
"AFPAlignmentDisplay",
".",
"getAlign",
"(",
"copyAFP",
",",
"ca1",
",",
"ca2clone",
")",
";",
"return",
"copyAFP",
";",
"}"
]
| It replaces an optimal alignment of an AFPChain and calculates all the new alignment scores and variables. | [
"It",
"replaces",
"an",
"optimal",
"alignment",
"of",
"an",
"AFPChain",
"and",
"calculates",
"all",
"the",
"new",
"alignment",
"scores",
"and",
"variables",
"."
]
| train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L698-L737 |
webmetrics/browsermob-proxy | src/main/java/org/browsermob/proxy/jetty/util/TempByteHolder.java | TempByteHolder.writeTo | public void writeTo(java.io.OutputStream os, int start_offset, int length) throws IOException {
"""
Writes efficiently part of the content to output stream.
@param os OutputStream to write to
@param start_offset Offset of data fragment to be written
@param length Length of data fragment to be written
@throws IOException
"""
int towrite = min(length, _write_pos-start_offset);
int writeoff = start_offset;
if (towrite > 0) {
while (towrite >= _window_size) {
moveWindow(writeoff);
os.write(_memory_buffer,0,_window_size);
towrite -= _window_size;
writeoff += _window_size;
}
if (towrite > 0) {
moveWindow(writeoff);
os.write(_memory_buffer,0,towrite);
}
}
} | java | public void writeTo(java.io.OutputStream os, int start_offset, int length) throws IOException {
int towrite = min(length, _write_pos-start_offset);
int writeoff = start_offset;
if (towrite > 0) {
while (towrite >= _window_size) {
moveWindow(writeoff);
os.write(_memory_buffer,0,_window_size);
towrite -= _window_size;
writeoff += _window_size;
}
if (towrite > 0) {
moveWindow(writeoff);
os.write(_memory_buffer,0,towrite);
}
}
} | [
"public",
"void",
"writeTo",
"(",
"java",
".",
"io",
".",
"OutputStream",
"os",
",",
"int",
"start_offset",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"int",
"towrite",
"=",
"min",
"(",
"length",
",",
"_write_pos",
"-",
"start_offset",
")",
";",
"int",
"writeoff",
"=",
"start_offset",
";",
"if",
"(",
"towrite",
">",
"0",
")",
"{",
"while",
"(",
"towrite",
">=",
"_window_size",
")",
"{",
"moveWindow",
"(",
"writeoff",
")",
";",
"os",
".",
"write",
"(",
"_memory_buffer",
",",
"0",
",",
"_window_size",
")",
";",
"towrite",
"-=",
"_window_size",
";",
"writeoff",
"+=",
"_window_size",
";",
"}",
"if",
"(",
"towrite",
">",
"0",
")",
"{",
"moveWindow",
"(",
"writeoff",
")",
";",
"os",
".",
"write",
"(",
"_memory_buffer",
",",
"0",
",",
"towrite",
")",
";",
"}",
"}",
"}"
]
| Writes efficiently part of the content to output stream.
@param os OutputStream to write to
@param start_offset Offset of data fragment to be written
@param length Length of data fragment to be written
@throws IOException | [
"Writes",
"efficiently",
"part",
"of",
"the",
"content",
"to",
"output",
"stream",
"."
]
| train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/browsermob/proxy/jetty/util/TempByteHolder.java#L286-L301 |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/DateUtil.java | DateUtil.addMinutes | public static Date addMinutes(Date d, int minutes) {
"""
Add minutes to a date
@param d date
@param minutes minutes
@return new date
"""
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(Calendar.MINUTE, minutes);
return cal.getTime();
} | java | public static Date addMinutes(Date d, int minutes) {
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(Calendar.MINUTE, minutes);
return cal.getTime();
} | [
"public",
"static",
"Date",
"addMinutes",
"(",
"Date",
"d",
",",
"int",
"minutes",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"d",
")",
";",
"cal",
".",
"add",
"(",
"Calendar",
".",
"MINUTE",
",",
"minutes",
")",
";",
"return",
"cal",
".",
"getTime",
"(",
")",
";",
"}"
]
| Add minutes to a date
@param d date
@param minutes minutes
@return new date | [
"Add",
"minutes",
"to",
"a",
"date"
]
| train | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L431-L436 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/IntersectionImpl.java | IntersectionImpl.initNewHeapInstance | static IntersectionImpl initNewHeapInstance(final long seed) {
"""
Construct a new Intersection target on the java heap.
@param seed <a href="{@docRoot}/resources/dictionary.html#seed">See Seed</a>
@return a new IntersectionImpl on the Java heap
"""
final IntersectionImpl impl = new IntersectionImpl(null, seed, false);
impl.lgArrLongs_ = 0;
impl.curCount_ = -1; //Universal Set is true
impl.thetaLong_ = Long.MAX_VALUE;
impl.empty_ = false; //A virgin intersection represents the Universal Set so empty is FALSE!
impl.hashTable_ = null;
return impl;
} | java | static IntersectionImpl initNewHeapInstance(final long seed) {
final IntersectionImpl impl = new IntersectionImpl(null, seed, false);
impl.lgArrLongs_ = 0;
impl.curCount_ = -1; //Universal Set is true
impl.thetaLong_ = Long.MAX_VALUE;
impl.empty_ = false; //A virgin intersection represents the Universal Set so empty is FALSE!
impl.hashTable_ = null;
return impl;
} | [
"static",
"IntersectionImpl",
"initNewHeapInstance",
"(",
"final",
"long",
"seed",
")",
"{",
"final",
"IntersectionImpl",
"impl",
"=",
"new",
"IntersectionImpl",
"(",
"null",
",",
"seed",
",",
"false",
")",
";",
"impl",
".",
"lgArrLongs_",
"=",
"0",
";",
"impl",
".",
"curCount_",
"=",
"-",
"1",
";",
"//Universal Set is true",
"impl",
".",
"thetaLong_",
"=",
"Long",
".",
"MAX_VALUE",
";",
"impl",
".",
"empty_",
"=",
"false",
";",
"//A virgin intersection represents the Universal Set so empty is FALSE!",
"impl",
".",
"hashTable_",
"=",
"null",
";",
"return",
"impl",
";",
"}"
]
| Construct a new Intersection target on the java heap.
@param seed <a href="{@docRoot}/resources/dictionary.html#seed">See Seed</a>
@return a new IntersectionImpl on the Java heap | [
"Construct",
"a",
"new",
"Intersection",
"target",
"on",
"the",
"java",
"heap",
"."
]
| train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/IntersectionImpl.java#L54-L62 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java | EscapedFunctions2.sqltimestampadd | public static void sqltimestampadd(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
"""
time stamp add
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens
"""
if (parsedArgs.size() != 3) {
throw new PSQLException(
GT.tr("{0} function takes three and only three arguments.", "timestampadd"),
PSQLState.SYNTAX_ERROR);
}
buf.append('(');
appendInterval(buf, parsedArgs.get(0).toString(), parsedArgs.get(1).toString());
buf.append('+').append(parsedArgs.get(2)).append(')');
} | java | public static void sqltimestampadd(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
if (parsedArgs.size() != 3) {
throw new PSQLException(
GT.tr("{0} function takes three and only three arguments.", "timestampadd"),
PSQLState.SYNTAX_ERROR);
}
buf.append('(');
appendInterval(buf, parsedArgs.get(0).toString(), parsedArgs.get(1).toString());
buf.append('+').append(parsedArgs.get(2)).append(')');
} | [
"public",
"static",
"void",
"sqltimestampadd",
"(",
"StringBuilder",
"buf",
",",
"List",
"<",
"?",
"extends",
"CharSequence",
">",
"parsedArgs",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"parsedArgs",
".",
"size",
"(",
")",
"!=",
"3",
")",
"{",
"throw",
"new",
"PSQLException",
"(",
"GT",
".",
"tr",
"(",
"\"{0} function takes three and only three arguments.\"",
",",
"\"timestampadd\"",
")",
",",
"PSQLState",
".",
"SYNTAX_ERROR",
")",
";",
"}",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"appendInterval",
"(",
"buf",
",",
"parsedArgs",
".",
"get",
"(",
"0",
")",
".",
"toString",
"(",
")",
",",
"parsedArgs",
".",
"get",
"(",
"1",
")",
".",
"toString",
"(",
")",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"parsedArgs",
".",
"get",
"(",
"2",
")",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}"
]
| time stamp add
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens | [
"time",
"stamp",
"add"
]
| train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java#L497-L506 |
aws/aws-sdk-java | aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/transfer/internal/CopyCallable.java | CopyCallable.copyInParts | private void copyInParts() throws Exception {
"""
Performs the copy of an Amazon S3 object from source bucket to
destination bucket as multiple copy part requests. The information about
the part to be copied is specified in the request as a byte range
(first-last)
@throws Exception
Any Exception that occurs while carrying out the request.
"""
multipartUploadId = initiateMultipartUpload(copyObjectRequest);
long optimalPartSize = getOptimalPartSize(metadata.getContentLength());
try {
CopyPartRequestFactory requestFactory = new CopyPartRequestFactory(
copyObjectRequest, multipartUploadId, optimalPartSize,
metadata.getContentLength());
copyPartsInParallel(requestFactory);
} catch (Exception e) {
publishProgress(listenerChain, ProgressEventType.TRANSFER_FAILED_EVENT);
abortMultipartCopy();
throw new RuntimeException("Unable to perform multipart copy", e);
}
} | java | private void copyInParts() throws Exception {
multipartUploadId = initiateMultipartUpload(copyObjectRequest);
long optimalPartSize = getOptimalPartSize(metadata.getContentLength());
try {
CopyPartRequestFactory requestFactory = new CopyPartRequestFactory(
copyObjectRequest, multipartUploadId, optimalPartSize,
metadata.getContentLength());
copyPartsInParallel(requestFactory);
} catch (Exception e) {
publishProgress(listenerChain, ProgressEventType.TRANSFER_FAILED_EVENT);
abortMultipartCopy();
throw new RuntimeException("Unable to perform multipart copy", e);
}
} | [
"private",
"void",
"copyInParts",
"(",
")",
"throws",
"Exception",
"{",
"multipartUploadId",
"=",
"initiateMultipartUpload",
"(",
"copyObjectRequest",
")",
";",
"long",
"optimalPartSize",
"=",
"getOptimalPartSize",
"(",
"metadata",
".",
"getContentLength",
"(",
")",
")",
";",
"try",
"{",
"CopyPartRequestFactory",
"requestFactory",
"=",
"new",
"CopyPartRequestFactory",
"(",
"copyObjectRequest",
",",
"multipartUploadId",
",",
"optimalPartSize",
",",
"metadata",
".",
"getContentLength",
"(",
")",
")",
";",
"copyPartsInParallel",
"(",
"requestFactory",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"publishProgress",
"(",
"listenerChain",
",",
"ProgressEventType",
".",
"TRANSFER_FAILED_EVENT",
")",
";",
"abortMultipartCopy",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to perform multipart copy\"",
",",
"e",
")",
";",
"}",
"}"
]
| Performs the copy of an Amazon S3 object from source bucket to
destination bucket as multiple copy part requests. The information about
the part to be copied is specified in the request as a byte range
(first-last)
@throws Exception
Any Exception that occurs while carrying out the request. | [
"Performs",
"the",
"copy",
"of",
"an",
"Amazon",
"S3",
"object",
"from",
"source",
"bucket",
"to",
"destination",
"bucket",
"as",
"multiple",
"copy",
"part",
"requests",
".",
"The",
"information",
"about",
"the",
"part",
"to",
"be",
"copied",
"is",
"specified",
"in",
"the",
"request",
"as",
"a",
"byte",
"range",
"(",
"first",
"-",
"last",
")"
]
| train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/transfer/internal/CopyCallable.java#L167-L182 |
lessthanoptimal/BoofCV | main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java | ConvertBufferedImage.checkCopy | public static BufferedImage checkCopy( BufferedImage original , BufferedImage output ) {
"""
Copies the original image into the output image. If it can't do a copy a new image is created and returned
@param original Original image
@param output (Optional) Storage for copy.
@return The copied image. May be a new instance
"""
ColorModel cm = original.getColorModel();
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
if( output == null || original.getWidth() != output.getWidth() || original.getHeight() != output.getHeight() ||
original.getType() != output.getType() ) {
WritableRaster raster = original.copyData(original.getRaster().createCompatibleWritableRaster());
return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
original.copyData(output.getRaster());
return output;
} | java | public static BufferedImage checkCopy( BufferedImage original , BufferedImage output ) {
ColorModel cm = original.getColorModel();
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
if( output == null || original.getWidth() != output.getWidth() || original.getHeight() != output.getHeight() ||
original.getType() != output.getType() ) {
WritableRaster raster = original.copyData(original.getRaster().createCompatibleWritableRaster());
return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
original.copyData(output.getRaster());
return output;
} | [
"public",
"static",
"BufferedImage",
"checkCopy",
"(",
"BufferedImage",
"original",
",",
"BufferedImage",
"output",
")",
"{",
"ColorModel",
"cm",
"=",
"original",
".",
"getColorModel",
"(",
")",
";",
"boolean",
"isAlphaPremultiplied",
"=",
"cm",
".",
"isAlphaPremultiplied",
"(",
")",
";",
"if",
"(",
"output",
"==",
"null",
"||",
"original",
".",
"getWidth",
"(",
")",
"!=",
"output",
".",
"getWidth",
"(",
")",
"||",
"original",
".",
"getHeight",
"(",
")",
"!=",
"output",
".",
"getHeight",
"(",
")",
"||",
"original",
".",
"getType",
"(",
")",
"!=",
"output",
".",
"getType",
"(",
")",
")",
"{",
"WritableRaster",
"raster",
"=",
"original",
".",
"copyData",
"(",
"original",
".",
"getRaster",
"(",
")",
".",
"createCompatibleWritableRaster",
"(",
")",
")",
";",
"return",
"new",
"BufferedImage",
"(",
"cm",
",",
"raster",
",",
"isAlphaPremultiplied",
",",
"null",
")",
";",
"}",
"original",
".",
"copyData",
"(",
"output",
".",
"getRaster",
"(",
")",
")",
";",
"return",
"output",
";",
"}"
]
| Copies the original image into the output image. If it can't do a copy a new image is created and returned
@param original Original image
@param output (Optional) Storage for copy.
@return The copied image. May be a new instance | [
"Copies",
"the",
"original",
"image",
"into",
"the",
"output",
"image",
".",
"If",
"it",
"can",
"t",
"do",
"a",
"copy",
"a",
"new",
"image",
"is",
"created",
"and",
"returned"
]
| train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java#L79-L91 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/locator/TokenMetadata.java | TokenMetadata.cloneOnlyTokenMap | public TokenMetadata cloneOnlyTokenMap() {
"""
Create a copy of TokenMetadata with only tokenToEndpointMap. That is, pending ranges,
bootstrap tokens and leaving endpoints are not included in the copy.
"""
lock.readLock().lock();
try
{
return new TokenMetadata(SortedBiMultiValMap.<Token, InetAddress>create(tokenToEndpointMap, null, inetaddressCmp),
HashBiMap.create(endpointToHostIdMap),
new Topology(topology));
}
finally
{
lock.readLock().unlock();
}
} | java | public TokenMetadata cloneOnlyTokenMap()
{
lock.readLock().lock();
try
{
return new TokenMetadata(SortedBiMultiValMap.<Token, InetAddress>create(tokenToEndpointMap, null, inetaddressCmp),
HashBiMap.create(endpointToHostIdMap),
new Topology(topology));
}
finally
{
lock.readLock().unlock();
}
} | [
"public",
"TokenMetadata",
"cloneOnlyTokenMap",
"(",
")",
"{",
"lock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"return",
"new",
"TokenMetadata",
"(",
"SortedBiMultiValMap",
".",
"<",
"Token",
",",
"InetAddress",
">",
"create",
"(",
"tokenToEndpointMap",
",",
"null",
",",
"inetaddressCmp",
")",
",",
"HashBiMap",
".",
"create",
"(",
"endpointToHostIdMap",
")",
",",
"new",
"Topology",
"(",
"topology",
")",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"readLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
]
| Create a copy of TokenMetadata with only tokenToEndpointMap. That is, pending ranges,
bootstrap tokens and leaving endpoints are not included in the copy. | [
"Create",
"a",
"copy",
"of",
"TokenMetadata",
"with",
"only",
"tokenToEndpointMap",
".",
"That",
"is",
"pending",
"ranges",
"bootstrap",
"tokens",
"and",
"leaving",
"endpoints",
"are",
"not",
"included",
"in",
"the",
"copy",
"."
]
| train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/locator/TokenMetadata.java#L517-L530 |
liferay/com-liferay-commerce | commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationAttachmentPersistenceImpl.java | CommerceNotificationAttachmentPersistenceImpl.findByUuid_C | @Override
public List<CommerceNotificationAttachment> findByUuid_C(String uuid,
long companyId, int start, int end) {
"""
Returns a range of all the commerce notification attachments where uuid = ? and companyId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceNotificationAttachmentModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param uuid the uuid
@param companyId the company ID
@param start the lower bound of the range of commerce notification attachments
@param end the upper bound of the range of commerce notification attachments (not inclusive)
@return the range of matching commerce notification attachments
"""
return findByUuid_C(uuid, companyId, start, end, null);
} | java | @Override
public List<CommerceNotificationAttachment> findByUuid_C(String uuid,
long companyId, int start, int end) {
return findByUuid_C(uuid, companyId, start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceNotificationAttachment",
">",
"findByUuid_C",
"(",
"String",
"uuid",
",",
"long",
"companyId",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findByUuid_C",
"(",
"uuid",
",",
"companyId",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
]
| Returns a range of all the commerce notification attachments where uuid = ? and companyId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceNotificationAttachmentModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param uuid the uuid
@param companyId the company ID
@param start the lower bound of the range of commerce notification attachments
@param end the upper bound of the range of commerce notification attachments (not inclusive)
@return the range of matching commerce notification attachments | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"notification",
"attachments",
"where",
"uuid",
"=",
"?",
";",
"and",
"companyId",
"=",
"?",
";",
"."
]
| train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationAttachmentPersistenceImpl.java#L964-L968 |
aws/aws-sdk-java | aws-java-sdk-core/src/main/java/com/amazonaws/util/URLEncodedUtils.java | URLEncodedUtils.encodeFormFields | private static String encodeFormFields(final String content, final String charset) {
"""
Encode/escape www-url-form-encoded content.
<p>
Uses the {@link #URLENCODER} set of characters, rather than
the {@link #UNRSERVED} set; this is for compatibilty with previous
releases, URLEncoder.encode() and most browsers.
@param content the content to encode, will convert space to '+'
@param charset the charset to use
@return encoded string
"""
if (content == null) {
return null;
}
return urlEncode(content, charset != null ? Charset.forName(charset) : StringUtils.UTF8, URLENCODER, true);
} | java | private static String encodeFormFields(final String content, final String charset) {
if (content == null) {
return null;
}
return urlEncode(content, charset != null ? Charset.forName(charset) : StringUtils.UTF8, URLENCODER, true);
} | [
"private",
"static",
"String",
"encodeFormFields",
"(",
"final",
"String",
"content",
",",
"final",
"String",
"charset",
")",
"{",
"if",
"(",
"content",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"urlEncode",
"(",
"content",
",",
"charset",
"!=",
"null",
"?",
"Charset",
".",
"forName",
"(",
"charset",
")",
":",
"StringUtils",
".",
"UTF8",
",",
"URLENCODER",
",",
"true",
")",
";",
"}"
]
| Encode/escape www-url-form-encoded content.
<p>
Uses the {@link #URLENCODER} set of characters, rather than
the {@link #UNRSERVED} set; this is for compatibilty with previous
releases, URLEncoder.encode() and most browsers.
@param content the content to encode, will convert space to '+'
@param charset the charset to use
@return encoded string | [
"Encode",
"/",
"escape",
"www",
"-",
"url",
"-",
"form",
"-",
"encoded",
"content",
".",
"<p",
">",
"Uses",
"the",
"{",
"@link",
"#URLENCODER",
"}",
"set",
"of",
"characters",
"rather",
"than",
"the",
"{",
"@link",
"#UNRSERVED",
"}",
"set",
";",
"this",
"is",
"for",
"compatibilty",
"with",
"previous",
"releases",
"URLEncoder",
".",
"encode",
"()",
"and",
"most",
"browsers",
"."
]
| train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-core/src/main/java/com/amazonaws/util/URLEncodedUtils.java#L284-L289 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/Network.java | Network.createSubnetwork | public Operation createSubnetwork(
SubnetworkId subnetworkId, String ipRange, OperationOption... options) {
"""
Creates a subnetwork for this network given its identity and the range of IPv4 addresses in
CIDR format. Subnetwork creation is only supported for networks in "custom subnet mode" (i.e.
{@link #getConfiguration()} returns a {@link SubnetNetworkConfiguration}) with automatic
creation of subnetworks disabled (i.e. {@link
SubnetNetworkConfiguration#autoCreateSubnetworks()} returns {@code false}).
@return an operation object if creation request was successfully sent
@throws ComputeException upon failure
@see <a href="https://wikipedia.org/wiki/Classless_Inter-Domain_Routing">CIDR</a>
"""
return compute.create(SubnetworkInfo.of(subnetworkId, getNetworkId(), ipRange), options);
} | java | public Operation createSubnetwork(
SubnetworkId subnetworkId, String ipRange, OperationOption... options) {
return compute.create(SubnetworkInfo.of(subnetworkId, getNetworkId(), ipRange), options);
} | [
"public",
"Operation",
"createSubnetwork",
"(",
"SubnetworkId",
"subnetworkId",
",",
"String",
"ipRange",
",",
"OperationOption",
"...",
"options",
")",
"{",
"return",
"compute",
".",
"create",
"(",
"SubnetworkInfo",
".",
"of",
"(",
"subnetworkId",
",",
"getNetworkId",
"(",
")",
",",
"ipRange",
")",
",",
"options",
")",
";",
"}"
]
| Creates a subnetwork for this network given its identity and the range of IPv4 addresses in
CIDR format. Subnetwork creation is only supported for networks in "custom subnet mode" (i.e.
{@link #getConfiguration()} returns a {@link SubnetNetworkConfiguration}) with automatic
creation of subnetworks disabled (i.e. {@link
SubnetNetworkConfiguration#autoCreateSubnetworks()} returns {@code false}).
@return an operation object if creation request was successfully sent
@throws ComputeException upon failure
@see <a href="https://wikipedia.org/wiki/Classless_Inter-Domain_Routing">CIDR</a> | [
"Creates",
"a",
"subnetwork",
"for",
"this",
"network",
"given",
"its",
"identity",
"and",
"the",
"range",
"of",
"IPv4",
"addresses",
"in",
"CIDR",
"format",
".",
"Subnetwork",
"creation",
"is",
"only",
"supported",
"for",
"networks",
"in",
"custom",
"subnet",
"mode",
"(",
"i",
".",
"e",
".",
"{",
"@link",
"#getConfiguration",
"()",
"}",
"returns",
"a",
"{",
"@link",
"SubnetNetworkConfiguration",
"}",
")",
"with",
"automatic",
"creation",
"of",
"subnetworks",
"disabled",
"(",
"i",
".",
"e",
".",
"{",
"@link",
"SubnetNetworkConfiguration#autoCreateSubnetworks",
"()",
"}",
"returns",
"{",
"@code",
"false",
"}",
")",
"."
]
| train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/Network.java#L148-L151 |
Deep-Symmetry/beat-link | src/main/java/org/deepsymmetry/beatlink/dbserver/Client.java | Client.buildRMST | public NumberField buildRMST(Message.MenuIdentifier targetMenu, CdjStatus.TrackSourceSlot slot) {
"""
<p>Build the <em>R:M:S:T</em> parameter that begins many queries.</p>
<p>Many request messages take, as their first argument, a 4-byte value where each byte has a special meaning.
The first byte is the player number of the requesting player. The second identifies the menu into which
the response is being loaded, as described by {@link Message.MenuIdentifier}. The third specifies the media
slot from which information is desired, as described by {@link CdjStatus.TrackSourceSlot}, and the fourth
byte identifies the type of track about which information is being requested; in most requests this has the
value 1, which corresponds to rekordbox tracks, and this version of the function assumes that.</p>
@param targetMenu the destination for the response to this query
@param slot the media library of interest for this query
@return the first argument to send with the query in order to obtain the desired information
"""
return buildRMST(posingAsPlayer, targetMenu, slot, CdjStatus.TrackType.REKORDBOX);
} | java | public NumberField buildRMST(Message.MenuIdentifier targetMenu, CdjStatus.TrackSourceSlot slot) {
return buildRMST(posingAsPlayer, targetMenu, slot, CdjStatus.TrackType.REKORDBOX);
} | [
"public",
"NumberField",
"buildRMST",
"(",
"Message",
".",
"MenuIdentifier",
"targetMenu",
",",
"CdjStatus",
".",
"TrackSourceSlot",
"slot",
")",
"{",
"return",
"buildRMST",
"(",
"posingAsPlayer",
",",
"targetMenu",
",",
"slot",
",",
"CdjStatus",
".",
"TrackType",
".",
"REKORDBOX",
")",
";",
"}"
]
| <p>Build the <em>R:M:S:T</em> parameter that begins many queries.</p>
<p>Many request messages take, as their first argument, a 4-byte value where each byte has a special meaning.
The first byte is the player number of the requesting player. The second identifies the menu into which
the response is being loaded, as described by {@link Message.MenuIdentifier}. The third specifies the media
slot from which information is desired, as described by {@link CdjStatus.TrackSourceSlot}, and the fourth
byte identifies the type of track about which information is being requested; in most requests this has the
value 1, which corresponds to rekordbox tracks, and this version of the function assumes that.</p>
@param targetMenu the destination for the response to this query
@param slot the media library of interest for this query
@return the first argument to send with the query in order to obtain the desired information | [
"<p",
">",
"Build",
"the",
"<em",
">",
"R",
":",
"M",
":",
"S",
":",
"T<",
"/",
"em",
">",
"parameter",
"that",
"begins",
"many",
"queries",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/dbserver/Client.java#L308-L310 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/zookeeper/ZooKeeperUtilityFactory.java | ZooKeeperUtilityFactory.createSharedCount | public ZooKeeperSharedCount createSharedCount(String path, int seedCount) {
"""
Creates a {@link ZooKeeperSharedCount} to store a shared count between multiple instances.
@param path to the shared count in ZooKeeper
@param seedCount for the shared count
@return a shared count
"""
return new ZooKeeperSharedCount(
new SharedCount(
facade,
path,
seedCount));
} | java | public ZooKeeperSharedCount createSharedCount(String path, int seedCount) {
return new ZooKeeperSharedCount(
new SharedCount(
facade,
path,
seedCount));
} | [
"public",
"ZooKeeperSharedCount",
"createSharedCount",
"(",
"String",
"path",
",",
"int",
"seedCount",
")",
"{",
"return",
"new",
"ZooKeeperSharedCount",
"(",
"new",
"SharedCount",
"(",
"facade",
",",
"path",
",",
"seedCount",
")",
")",
";",
"}"
]
| Creates a {@link ZooKeeperSharedCount} to store a shared count between multiple instances.
@param path to the shared count in ZooKeeper
@param seedCount for the shared count
@return a shared count | [
"Creates",
"a",
"{",
"@link",
"ZooKeeperSharedCount",
"}",
"to",
"store",
"a",
"shared",
"count",
"between",
"multiple",
"instances",
"."
]
| train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/zookeeper/ZooKeeperUtilityFactory.java#L111-L117 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java | TrainingsImpl.updateProjectAsync | public Observable<Project> updateProjectAsync(UUID projectId, Project updatedProject) {
"""
Update a specific project.
@param projectId The id of the project to update
@param updatedProject The updated project model
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the Project object
"""
return updateProjectWithServiceResponseAsync(projectId, updatedProject).map(new Func1<ServiceResponse<Project>, Project>() {
@Override
public Project call(ServiceResponse<Project> response) {
return response.body();
}
});
} | java | public Observable<Project> updateProjectAsync(UUID projectId, Project updatedProject) {
return updateProjectWithServiceResponseAsync(projectId, updatedProject).map(new Func1<ServiceResponse<Project>, Project>() {
@Override
public Project call(ServiceResponse<Project> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Project",
">",
"updateProjectAsync",
"(",
"UUID",
"projectId",
",",
"Project",
"updatedProject",
")",
"{",
"return",
"updateProjectWithServiceResponseAsync",
"(",
"projectId",
",",
"updatedProject",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Project",
">",
",",
"Project",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Project",
"call",
"(",
"ServiceResponse",
"<",
"Project",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Update a specific project.
@param projectId The id of the project to update
@param updatedProject The updated project model
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the Project object | [
"Update",
"a",
"specific",
"project",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L2148-L2155 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/event/EventUtils.java | EventUtils.bindEventsToMethod | public static <L> void bindEventsToMethod(final Object target, final String methodName, final Object eventSource,
final Class<L> listenerType, final String... eventTypes) {
"""
Binds an event listener to a specific method on a specific object.
@param <L> the event listener type
@param target the target object
@param methodName the name of the method to be called
@param eventSource the object which is generating events (JButton, JList, etc.)
@param listenerType the listener interface (ActionListener.class, SelectionListener.class, etc.)
@param eventTypes the event types (method names) from the listener interface (if none specified, all will be
supported)
"""
final L listener = listenerType.cast(Proxy.newProxyInstance(target.getClass().getClassLoader(),
new Class[] { listenerType }, new EventBindingInvocationHandler(target, methodName, eventTypes)));
addEventListener(eventSource, listenerType, listener);
} | java | public static <L> void bindEventsToMethod(final Object target, final String methodName, final Object eventSource,
final Class<L> listenerType, final String... eventTypes) {
final L listener = listenerType.cast(Proxy.newProxyInstance(target.getClass().getClassLoader(),
new Class[] { listenerType }, new EventBindingInvocationHandler(target, methodName, eventTypes)));
addEventListener(eventSource, listenerType, listener);
} | [
"public",
"static",
"<",
"L",
">",
"void",
"bindEventsToMethod",
"(",
"final",
"Object",
"target",
",",
"final",
"String",
"methodName",
",",
"final",
"Object",
"eventSource",
",",
"final",
"Class",
"<",
"L",
">",
"listenerType",
",",
"final",
"String",
"...",
"eventTypes",
")",
"{",
"final",
"L",
"listener",
"=",
"listenerType",
".",
"cast",
"(",
"Proxy",
".",
"newProxyInstance",
"(",
"target",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
",",
"new",
"Class",
"[",
"]",
"{",
"listenerType",
"}",
",",
"new",
"EventBindingInvocationHandler",
"(",
"target",
",",
"methodName",
",",
"eventTypes",
")",
")",
")",
";",
"addEventListener",
"(",
"eventSource",
",",
"listenerType",
",",
"listener",
")",
";",
"}"
]
| Binds an event listener to a specific method on a specific object.
@param <L> the event listener type
@param target the target object
@param methodName the name of the method to be called
@param eventSource the object which is generating events (JButton, JList, etc.)
@param listenerType the listener interface (ActionListener.class, SelectionListener.class, etc.)
@param eventTypes the event types (method names) from the listener interface (if none specified, all will be
supported) | [
"Binds",
"an",
"event",
"listener",
"to",
"a",
"specific",
"method",
"on",
"a",
"specific",
"object",
"."
]
| train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/event/EventUtils.java#L77-L82 |
SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java | CountTreeBitsCollection.readBranchCounts | protected BranchCounts readBranchCounts(final BitInputStream in,
final Bits code, final long size) throws IOException {
"""
Read branch counts branch counts.
@param in the in
@param code the code
@param size the size
@return the branch counts
@throws IOException the io exception
"""
final BranchCounts branchCounts = new BranchCounts(code, size);
final CodeType currentCodeType = this.getType(code);
long maximum = size;
// Get terminals
if (currentCodeType == CodeType.Unknown) {
branchCounts.terminals = this.readTerminalCount(in, maximum);
}
else if (currentCodeType == CodeType.Terminal) {
branchCounts.terminals = size;
}
else {
branchCounts.terminals = 0;
}
maximum -= branchCounts.terminals;
// Get zero-suffixed primary
if (maximum > 0) {
assert Thread.currentThread().getStackTrace().length < 100;
branchCounts.zeroCount = this.readZeroBranchSize(in, maximum, code);
}
maximum -= branchCounts.zeroCount;
branchCounts.oneCount = maximum;
return branchCounts;
} | java | protected BranchCounts readBranchCounts(final BitInputStream in,
final Bits code, final long size) throws IOException {
final BranchCounts branchCounts = new BranchCounts(code, size);
final CodeType currentCodeType = this.getType(code);
long maximum = size;
// Get terminals
if (currentCodeType == CodeType.Unknown) {
branchCounts.terminals = this.readTerminalCount(in, maximum);
}
else if (currentCodeType == CodeType.Terminal) {
branchCounts.terminals = size;
}
else {
branchCounts.terminals = 0;
}
maximum -= branchCounts.terminals;
// Get zero-suffixed primary
if (maximum > 0) {
assert Thread.currentThread().getStackTrace().length < 100;
branchCounts.zeroCount = this.readZeroBranchSize(in, maximum, code);
}
maximum -= branchCounts.zeroCount;
branchCounts.oneCount = maximum;
return branchCounts;
} | [
"protected",
"BranchCounts",
"readBranchCounts",
"(",
"final",
"BitInputStream",
"in",
",",
"final",
"Bits",
"code",
",",
"final",
"long",
"size",
")",
"throws",
"IOException",
"{",
"final",
"BranchCounts",
"branchCounts",
"=",
"new",
"BranchCounts",
"(",
"code",
",",
"size",
")",
";",
"final",
"CodeType",
"currentCodeType",
"=",
"this",
".",
"getType",
"(",
"code",
")",
";",
"long",
"maximum",
"=",
"size",
";",
"// Get terminals",
"if",
"(",
"currentCodeType",
"==",
"CodeType",
".",
"Unknown",
")",
"{",
"branchCounts",
".",
"terminals",
"=",
"this",
".",
"readTerminalCount",
"(",
"in",
",",
"maximum",
")",
";",
"}",
"else",
"if",
"(",
"currentCodeType",
"==",
"CodeType",
".",
"Terminal",
")",
"{",
"branchCounts",
".",
"terminals",
"=",
"size",
";",
"}",
"else",
"{",
"branchCounts",
".",
"terminals",
"=",
"0",
";",
"}",
"maximum",
"-=",
"branchCounts",
".",
"terminals",
";",
"// Get zero-suffixed primary",
"if",
"(",
"maximum",
">",
"0",
")",
"{",
"assert",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getStackTrace",
"(",
")",
".",
"length",
"<",
"100",
";",
"branchCounts",
".",
"zeroCount",
"=",
"this",
".",
"readZeroBranchSize",
"(",
"in",
",",
"maximum",
",",
"code",
")",
";",
"}",
"maximum",
"-=",
"branchCounts",
".",
"zeroCount",
";",
"branchCounts",
".",
"oneCount",
"=",
"maximum",
";",
"return",
"branchCounts",
";",
"}"
]
| Read branch counts branch counts.
@param in the in
@param code the code
@param size the size
@return the branch counts
@throws IOException the io exception | [
"Read",
"branch",
"counts",
"branch",
"counts",
"."
]
| train | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java#L191-L217 |
socialsensor/socialsensor-framework-common | src/main/java/eu/socialsensor/framework/common/repositories/InfluentialContributorSet.java | InfluentialContributorSet.isTwitterJsonStringRelatedTo | public boolean isTwitterJsonStringRelatedTo(String tweet, boolean sender,boolean userMentions, boolean retweetOrigin) {
"""
Determines whether the Twitter status is related to one of the users in the
set of influential contributors.
@param sender
if the person who created the status is in the ids set, return
true
@param userMentions
if the status contains a user mention that is contained in the ids
set, return true
@param retweetOrigin
if the status is a retweet that was originated by a user in the
ids set, return true
@returns true if one of the ids in the input parameter matches an id found
in the tweet
"""
StatusRepresentation s = new StatusRepresentation();
s.init(null, tweet);
boolean matches = s.isRelatedTo(this, true, true, true);
return matches;
} | java | public boolean isTwitterJsonStringRelatedTo(String tweet, boolean sender,boolean userMentions, boolean retweetOrigin) {
StatusRepresentation s = new StatusRepresentation();
s.init(null, tweet);
boolean matches = s.isRelatedTo(this, true, true, true);
return matches;
} | [
"public",
"boolean",
"isTwitterJsonStringRelatedTo",
"(",
"String",
"tweet",
",",
"boolean",
"sender",
",",
"boolean",
"userMentions",
",",
"boolean",
"retweetOrigin",
")",
"{",
"StatusRepresentation",
"s",
"=",
"new",
"StatusRepresentation",
"(",
")",
";",
"s",
".",
"init",
"(",
"null",
",",
"tweet",
")",
";",
"boolean",
"matches",
"=",
"s",
".",
"isRelatedTo",
"(",
"this",
",",
"true",
",",
"true",
",",
"true",
")",
";",
"return",
"matches",
";",
"}"
]
| Determines whether the Twitter status is related to one of the users in the
set of influential contributors.
@param sender
if the person who created the status is in the ids set, return
true
@param userMentions
if the status contains a user mention that is contained in the ids
set, return true
@param retweetOrigin
if the status is a retweet that was originated by a user in the
ids set, return true
@returns true if one of the ids in the input parameter matches an id found
in the tweet | [
"Determines",
"whether",
"the",
"Twitter",
"status",
"is",
"related",
"to",
"one",
"of",
"the",
"users",
"in",
"the",
"set",
"of",
"influential",
"contributors",
"."
]
| train | https://github.com/socialsensor/socialsensor-framework-common/blob/b69e7c47f3e0a9062c373aaec7cb2ba1e19c6ce0/src/main/java/eu/socialsensor/framework/common/repositories/InfluentialContributorSet.java#L89-L94 |
astefanutti/camel-cdi | maven/src/main/java/org/apache/camel/maven/RunMojo.java | RunMojo.addRelevantProjectDependenciesToClasspath | private void addRelevantProjectDependenciesToClasspath(Set<URL> path) throws MojoExecutionException {
"""
Add any relevant project dependencies to the classpath. Takes
includeProjectDependencies into consideration.
@param path classpath of {@link java.net.URL} objects
@throws MojoExecutionException
"""
if (this.includeProjectDependencies) {
try {
getLog().debug("Project Dependencies will be included.");
URL mainClasses = new File(project.getBuild().getOutputDirectory()).toURI().toURL();
getLog().debug("Adding to classpath : " + mainClasses);
path.add(mainClasses);
Set<Artifact> dependencies = CastUtils.cast(project.getArtifacts());
// system scope dependencies are not returned by maven 2.0. See
// MEXEC-17
dependencies.addAll(getAllNonTestScopedDependencies());
Iterator<Artifact> iter = dependencies.iterator();
while (iter.hasNext()) {
Artifact classPathElement = iter.next();
getLog().debug("Adding project dependency artifact: " + classPathElement.getArtifactId()
+ " to classpath");
File file = classPathElement.getFile();
if (file != null) {
path.add(file.toURI().toURL());
}
}
} catch (MalformedURLException e) {
throw new MojoExecutionException("Error during setting up classpath", e);
}
} else {
getLog().debug("Project Dependencies will be excluded.");
}
} | java | private void addRelevantProjectDependenciesToClasspath(Set<URL> path) throws MojoExecutionException {
if (this.includeProjectDependencies) {
try {
getLog().debug("Project Dependencies will be included.");
URL mainClasses = new File(project.getBuild().getOutputDirectory()).toURI().toURL();
getLog().debug("Adding to classpath : " + mainClasses);
path.add(mainClasses);
Set<Artifact> dependencies = CastUtils.cast(project.getArtifacts());
// system scope dependencies are not returned by maven 2.0. See
// MEXEC-17
dependencies.addAll(getAllNonTestScopedDependencies());
Iterator<Artifact> iter = dependencies.iterator();
while (iter.hasNext()) {
Artifact classPathElement = iter.next();
getLog().debug("Adding project dependency artifact: " + classPathElement.getArtifactId()
+ " to classpath");
File file = classPathElement.getFile();
if (file != null) {
path.add(file.toURI().toURL());
}
}
} catch (MalformedURLException e) {
throw new MojoExecutionException("Error during setting up classpath", e);
}
} else {
getLog().debug("Project Dependencies will be excluded.");
}
} | [
"private",
"void",
"addRelevantProjectDependenciesToClasspath",
"(",
"Set",
"<",
"URL",
">",
"path",
")",
"throws",
"MojoExecutionException",
"{",
"if",
"(",
"this",
".",
"includeProjectDependencies",
")",
"{",
"try",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Project Dependencies will be included.\"",
")",
";",
"URL",
"mainClasses",
"=",
"new",
"File",
"(",
"project",
".",
"getBuild",
"(",
")",
".",
"getOutputDirectory",
"(",
")",
")",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
";",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Adding to classpath : \"",
"+",
"mainClasses",
")",
";",
"path",
".",
"add",
"(",
"mainClasses",
")",
";",
"Set",
"<",
"Artifact",
">",
"dependencies",
"=",
"CastUtils",
".",
"cast",
"(",
"project",
".",
"getArtifacts",
"(",
")",
")",
";",
"// system scope dependencies are not returned by maven 2.0. See",
"// MEXEC-17",
"dependencies",
".",
"addAll",
"(",
"getAllNonTestScopedDependencies",
"(",
")",
")",
";",
"Iterator",
"<",
"Artifact",
">",
"iter",
"=",
"dependencies",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"Artifact",
"classPathElement",
"=",
"iter",
".",
"next",
"(",
")",
";",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Adding project dependency artifact: \"",
"+",
"classPathElement",
".",
"getArtifactId",
"(",
")",
"+",
"\" to classpath\"",
")",
";",
"File",
"file",
"=",
"classPathElement",
".",
"getFile",
"(",
")",
";",
"if",
"(",
"file",
"!=",
"null",
")",
"{",
"path",
".",
"add",
"(",
"file",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Error during setting up classpath\"",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Project Dependencies will be excluded.\"",
")",
";",
"}",
"}"
]
| Add any relevant project dependencies to the classpath. Takes
includeProjectDependencies into consideration.
@param path classpath of {@link java.net.URL} objects
@throws MojoExecutionException | [
"Add",
"any",
"relevant",
"project",
"dependencies",
"to",
"the",
"classpath",
".",
"Takes",
"includeProjectDependencies",
"into",
"consideration",
"."
]
| train | https://github.com/astefanutti/camel-cdi/blob/686c7f5fe3a706f47378e0c49c323040795ddff8/maven/src/main/java/org/apache/camel/maven/RunMojo.java#L807-L840 |
tango-controls/JTango | server/src/main/java/org/tango/server/admin/AdminDevice.java | AdminDevice.getPollStatus | @Command(name = "DevPollStatus", inTypeDesc = DEVICE_NAME, outTypeDesc = "Device polling status")
public String[] getPollStatus(final String deviceName) throws DevFailed {
"""
get the polling status
@param deviceName Device name
@return Device polling status
@throws DevFailed
"""
xlogger.entry(deviceName);
String[] ret = new PollStatusCommand(deviceName, classList).call();
xlogger.exit(ret);
return ret;
} | java | @Command(name = "DevPollStatus", inTypeDesc = DEVICE_NAME, outTypeDesc = "Device polling status")
public String[] getPollStatus(final String deviceName) throws DevFailed {
xlogger.entry(deviceName);
String[] ret = new PollStatusCommand(deviceName, classList).call();
xlogger.exit(ret);
return ret;
} | [
"@",
"Command",
"(",
"name",
"=",
"\"DevPollStatus\"",
",",
"inTypeDesc",
"=",
"DEVICE_NAME",
",",
"outTypeDesc",
"=",
"\"Device polling status\"",
")",
"public",
"String",
"[",
"]",
"getPollStatus",
"(",
"final",
"String",
"deviceName",
")",
"throws",
"DevFailed",
"{",
"xlogger",
".",
"entry",
"(",
"deviceName",
")",
";",
"String",
"[",
"]",
"ret",
"=",
"new",
"PollStatusCommand",
"(",
"deviceName",
",",
"classList",
")",
".",
"call",
"(",
")",
";",
"xlogger",
".",
"exit",
"(",
"ret",
")",
";",
"return",
"ret",
";",
"}"
]
| get the polling status
@param deviceName Device name
@return Device polling status
@throws DevFailed | [
"get",
"the",
"polling",
"status"
]
| train | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/admin/AdminDevice.java#L149-L156 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/MultiColumnText.java | MultiColumnText.getHeight | private float getHeight(float[] left, float[] right) {
"""
Figure out the height of a column from the border extents
@param left left border
@param right right border
@return height
"""
float max = Float.MIN_VALUE;
float min = Float.MAX_VALUE;
for (int i = 0; i < left.length; i += 2) {
min = Math.min(min, left[i + 1]);
max = Math.max(max, left[i + 1]);
}
for (int i = 0; i < right.length; i += 2) {
min = Math.min(min, right[i + 1]);
max = Math.max(max, right[i + 1]);
}
return max - min;
} | java | private float getHeight(float[] left, float[] right) {
float max = Float.MIN_VALUE;
float min = Float.MAX_VALUE;
for (int i = 0; i < left.length; i += 2) {
min = Math.min(min, left[i + 1]);
max = Math.max(max, left[i + 1]);
}
for (int i = 0; i < right.length; i += 2) {
min = Math.min(min, right[i + 1]);
max = Math.max(max, right[i + 1]);
}
return max - min;
} | [
"private",
"float",
"getHeight",
"(",
"float",
"[",
"]",
"left",
",",
"float",
"[",
"]",
"right",
")",
"{",
"float",
"max",
"=",
"Float",
".",
"MIN_VALUE",
";",
"float",
"min",
"=",
"Float",
".",
"MAX_VALUE",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"left",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"min",
"=",
"Math",
".",
"min",
"(",
"min",
",",
"left",
"[",
"i",
"+",
"1",
"]",
")",
";",
"max",
"=",
"Math",
".",
"max",
"(",
"max",
",",
"left",
"[",
"i",
"+",
"1",
"]",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"right",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"min",
"=",
"Math",
".",
"min",
"(",
"min",
",",
"right",
"[",
"i",
"+",
"1",
"]",
")",
";",
"max",
"=",
"Math",
".",
"max",
"(",
"max",
",",
"right",
"[",
"i",
"+",
"1",
"]",
")",
";",
"}",
"return",
"max",
"-",
"min",
";",
"}"
]
| Figure out the height of a column from the border extents
@param left left border
@param right right border
@return height | [
"Figure",
"out",
"the",
"height",
"of",
"a",
"column",
"from",
"the",
"border",
"extents"
]
| train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/MultiColumnText.java#L371-L383 |
Jasig/uPortal | uPortal-layout/uPortal-layout-impl/src/main/java/org/apereo/portal/layout/dlm/ParameterEditManager.java | ParameterEditManager.removeParmEditDirective | public static void removeParmEditDirective(String targetId, String name, IPerson person)
throws PortalException {
"""
Remove a parameter edit directive from the parameter edits set for applying user specified
values to a named parameter of an incorporated channel represented by the passed-in target
id. If one doesn't exists for that node and that name then this call returns without any
effects.
"""
Document plf = (Document) person.getAttribute(Constants.PLF);
Element parmSet = getParmEditSet(plf, person, false);
if (parmSet == null) return; // no set so no edit to remove
NodeList edits = parmSet.getChildNodes();
for (int i = 0; i < edits.getLength(); i++) {
Element edit = (Element) edits.item(i);
if (edit.getAttribute(Constants.ATT_TARGET).equals(targetId)
&& edit.getAttribute(Constants.ATT_NAME).equals(name)) {
parmSet.removeChild(edit);
break;
}
}
if (parmSet.getChildNodes().getLength() == 0) // no more edits, remove
{
Node parent = parmSet.getParentNode();
parent.removeChild(parmSet);
}
} | java | public static void removeParmEditDirective(String targetId, String name, IPerson person)
throws PortalException {
Document plf = (Document) person.getAttribute(Constants.PLF);
Element parmSet = getParmEditSet(plf, person, false);
if (parmSet == null) return; // no set so no edit to remove
NodeList edits = parmSet.getChildNodes();
for (int i = 0; i < edits.getLength(); i++) {
Element edit = (Element) edits.item(i);
if (edit.getAttribute(Constants.ATT_TARGET).equals(targetId)
&& edit.getAttribute(Constants.ATT_NAME).equals(name)) {
parmSet.removeChild(edit);
break;
}
}
if (parmSet.getChildNodes().getLength() == 0) // no more edits, remove
{
Node parent = parmSet.getParentNode();
parent.removeChild(parmSet);
}
} | [
"public",
"static",
"void",
"removeParmEditDirective",
"(",
"String",
"targetId",
",",
"String",
"name",
",",
"IPerson",
"person",
")",
"throws",
"PortalException",
"{",
"Document",
"plf",
"=",
"(",
"Document",
")",
"person",
".",
"getAttribute",
"(",
"Constants",
".",
"PLF",
")",
";",
"Element",
"parmSet",
"=",
"getParmEditSet",
"(",
"plf",
",",
"person",
",",
"false",
")",
";",
"if",
"(",
"parmSet",
"==",
"null",
")",
"return",
";",
"// no set so no edit to remove",
"NodeList",
"edits",
"=",
"parmSet",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"edits",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Element",
"edit",
"=",
"(",
"Element",
")",
"edits",
".",
"item",
"(",
"i",
")",
";",
"if",
"(",
"edit",
".",
"getAttribute",
"(",
"Constants",
".",
"ATT_TARGET",
")",
".",
"equals",
"(",
"targetId",
")",
"&&",
"edit",
".",
"getAttribute",
"(",
"Constants",
".",
"ATT_NAME",
")",
".",
"equals",
"(",
"name",
")",
")",
"{",
"parmSet",
".",
"removeChild",
"(",
"edit",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"parmSet",
".",
"getChildNodes",
"(",
")",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"// no more edits, remove",
"{",
"Node",
"parent",
"=",
"parmSet",
".",
"getParentNode",
"(",
")",
";",
"parent",
".",
"removeChild",
"(",
"parmSet",
")",
";",
"}",
"}"
]
| Remove a parameter edit directive from the parameter edits set for applying user specified
values to a named parameter of an incorporated channel represented by the passed-in target
id. If one doesn't exists for that node and that name then this call returns without any
effects. | [
"Remove",
"a",
"parameter",
"edit",
"directive",
"from",
"the",
"parameter",
"edits",
"set",
"for",
"applying",
"user",
"specified",
"values",
"to",
"a",
"named",
"parameter",
"of",
"an",
"incorporated",
"channel",
"represented",
"by",
"the",
"passed",
"-",
"in",
"target",
"id",
".",
"If",
"one",
"doesn",
"t",
"exists",
"for",
"that",
"node",
"and",
"that",
"name",
"then",
"this",
"call",
"returns",
"without",
"any",
"effects",
"."
]
| train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-layout/uPortal-layout-impl/src/main/java/org/apereo/portal/layout/dlm/ParameterEditManager.java#L275-L297 |
elki-project/elki | elki/src/main/java/de/lmu/ifi/dbs/elki/application/greedyensemble/ComputeKNNOutlierScores.java | ComputeKNNOutlierScores.runForEachK | private void runForEachK(String prefix, int mink, int maxk, IntFunction<OutlierResult> runner, BiConsumer<String, OutlierResult> out) {
"""
Iterate over the k range.
@param prefix Prefix string
@param mink Minimum value of k for this method
@param maxk Maximum value of k for this method
@param runner Runner to run
@param out Output function
"""
if(isDisabled(prefix)) {
LOG.verbose("Skipping (disabled): " + prefix);
return; // Disabled
}
LOG.verbose("Running " + prefix);
final int digits = (int) FastMath.ceil(FastMath.log10(krange.getMax() + 1));
final String format = "%s-%0" + digits + "d";
krange.forEach(k -> {
if(k >= mink && k <= maxk) {
Duration time = LOG.newDuration(this.getClass().getCanonicalName() + "." + prefix + ".k" + k + ".runtime").begin();
OutlierResult result = runner.apply(k);
LOG.statistics(time.end());
if(result != null) {
out.accept(String.format(Locale.ROOT, format, prefix, k), result);
result.getHierarchy().removeSubtree(result);
}
}
});
} | java | private void runForEachK(String prefix, int mink, int maxk, IntFunction<OutlierResult> runner, BiConsumer<String, OutlierResult> out) {
if(isDisabled(prefix)) {
LOG.verbose("Skipping (disabled): " + prefix);
return; // Disabled
}
LOG.verbose("Running " + prefix);
final int digits = (int) FastMath.ceil(FastMath.log10(krange.getMax() + 1));
final String format = "%s-%0" + digits + "d";
krange.forEach(k -> {
if(k >= mink && k <= maxk) {
Duration time = LOG.newDuration(this.getClass().getCanonicalName() + "." + prefix + ".k" + k + ".runtime").begin();
OutlierResult result = runner.apply(k);
LOG.statistics(time.end());
if(result != null) {
out.accept(String.format(Locale.ROOT, format, prefix, k), result);
result.getHierarchy().removeSubtree(result);
}
}
});
} | [
"private",
"void",
"runForEachK",
"(",
"String",
"prefix",
",",
"int",
"mink",
",",
"int",
"maxk",
",",
"IntFunction",
"<",
"OutlierResult",
">",
"runner",
",",
"BiConsumer",
"<",
"String",
",",
"OutlierResult",
">",
"out",
")",
"{",
"if",
"(",
"isDisabled",
"(",
"prefix",
")",
")",
"{",
"LOG",
".",
"verbose",
"(",
"\"Skipping (disabled): \"",
"+",
"prefix",
")",
";",
"return",
";",
"// Disabled",
"}",
"LOG",
".",
"verbose",
"(",
"\"Running \"",
"+",
"prefix",
")",
";",
"final",
"int",
"digits",
"=",
"(",
"int",
")",
"FastMath",
".",
"ceil",
"(",
"FastMath",
".",
"log10",
"(",
"krange",
".",
"getMax",
"(",
")",
"+",
"1",
")",
")",
";",
"final",
"String",
"format",
"=",
"\"%s-%0\"",
"+",
"digits",
"+",
"\"d\"",
";",
"krange",
".",
"forEach",
"(",
"k",
"->",
"{",
"if",
"(",
"k",
">=",
"mink",
"&&",
"k",
"<=",
"maxk",
")",
"{",
"Duration",
"time",
"=",
"LOG",
".",
"newDuration",
"(",
"this",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
"+",
"\".\"",
"+",
"prefix",
"+",
"\".k\"",
"+",
"k",
"+",
"\".runtime\"",
")",
".",
"begin",
"(",
")",
";",
"OutlierResult",
"result",
"=",
"runner",
".",
"apply",
"(",
"k",
")",
";",
"LOG",
".",
"statistics",
"(",
"time",
".",
"end",
"(",
")",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"out",
".",
"accept",
"(",
"String",
".",
"format",
"(",
"Locale",
".",
"ROOT",
",",
"format",
",",
"prefix",
",",
"k",
")",
",",
"result",
")",
";",
"result",
".",
"getHierarchy",
"(",
")",
".",
"removeSubtree",
"(",
"result",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
]
| Iterate over the k range.
@param prefix Prefix string
@param mink Minimum value of k for this method
@param maxk Maximum value of k for this method
@param runner Runner to run
@param out Output function | [
"Iterate",
"over",
"the",
"k",
"range",
"."
]
| train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/application/greedyensemble/ComputeKNNOutlierScores.java#L359-L378 |
SonarSource/sonarqube | server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java | SourceService.getLines | public Optional<Iterable<DbFileSources.Line>> getLines(DbSession dbSession, String fileUuid, int from, int toInclusive) {
"""
Returns a range of lines as raw db data. User permission is not verified.
@param from starts from 1
@param toInclusive starts from 1, must be greater than or equal param {@code from}
"""
return getLines(dbSession, fileUuid, from, toInclusive, Function.identity());
} | java | public Optional<Iterable<DbFileSources.Line>> getLines(DbSession dbSession, String fileUuid, int from, int toInclusive) {
return getLines(dbSession, fileUuid, from, toInclusive, Function.identity());
} | [
"public",
"Optional",
"<",
"Iterable",
"<",
"DbFileSources",
".",
"Line",
">",
">",
"getLines",
"(",
"DbSession",
"dbSession",
",",
"String",
"fileUuid",
",",
"int",
"from",
",",
"int",
"toInclusive",
")",
"{",
"return",
"getLines",
"(",
"dbSession",
",",
"fileUuid",
",",
"from",
",",
"toInclusive",
",",
"Function",
".",
"identity",
"(",
")",
")",
";",
"}"
]
| Returns a range of lines as raw db data. User permission is not verified.
@param from starts from 1
@param toInclusive starts from 1, must be greater than or equal param {@code from} | [
"Returns",
"a",
"range",
"of",
"lines",
"as",
"raw",
"db",
"data",
".",
"User",
"permission",
"is",
"not",
"verified",
"."
]
| train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java#L49-L51 |
alkacon/opencms-core | src/org/opencms/ui/components/CmsErrorDialog.java | CmsErrorDialog.showErrorDialog | public static void showErrorDialog(Throwable t, Runnable onClose) {
"""
Shows the error dialog.<p>
@param t the error to be displayed
@param onClose executed on close
"""
showErrorDialog(t.getLocalizedMessage(), t, onClose);
} | java | public static void showErrorDialog(Throwable t, Runnable onClose) {
showErrorDialog(t.getLocalizedMessage(), t, onClose);
} | [
"public",
"static",
"void",
"showErrorDialog",
"(",
"Throwable",
"t",
",",
"Runnable",
"onClose",
")",
"{",
"showErrorDialog",
"(",
"t",
".",
"getLocalizedMessage",
"(",
")",
",",
"t",
",",
"onClose",
")",
";",
"}"
]
| Shows the error dialog.<p>
@param t the error to be displayed
@param onClose executed on close | [
"Shows",
"the",
"error",
"dialog",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/components/CmsErrorDialog.java#L191-L194 |
HeidelTime/heideltime | src/jvntextpro/util/StringUtils.java | StringUtils.findLastNotOf | public static int findLastNotOf(String container, String charSeq, int end) {
"""
Find last not of.
@param container the container
@param charSeq the char seq
@param end the end
@return the int
"""
for (int i = end; i < container.length() && i >= 0; --i){
if (!charSeq.contains("" + container.charAt(i)))
return i;
}
return -1;
} | java | public static int findLastNotOf(String container, String charSeq, int end){
for (int i = end; i < container.length() && i >= 0; --i){
if (!charSeq.contains("" + container.charAt(i)))
return i;
}
return -1;
} | [
"public",
"static",
"int",
"findLastNotOf",
"(",
"String",
"container",
",",
"String",
"charSeq",
",",
"int",
"end",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"end",
";",
"i",
"<",
"container",
".",
"length",
"(",
")",
"&&",
"i",
">=",
"0",
";",
"--",
"i",
")",
"{",
"if",
"(",
"!",
"charSeq",
".",
"contains",
"(",
"\"\"",
"+",
"container",
".",
"charAt",
"(",
"i",
")",
")",
")",
"return",
"i",
";",
"}",
"return",
"-",
"1",
";",
"}"
]
| Find last not of.
@param container the container
@param charSeq the char seq
@param end the end
@return the int | [
"Find",
"last",
"not",
"of",
"."
]
| train | https://github.com/HeidelTime/heideltime/blob/4ef5002eb5ecfeb818086ff7e394e792ee360335/src/jvntextpro/util/StringUtils.java#L102-L108 |
lastaflute/lasta-thymeleaf | src/main/java/org/lastaflute/thymeleaf/ThymeleafHtmlRenderer.java | ThymeleafHtmlRenderer.checkRegisteredDataUsingReservedWord | protected void checkRegisteredDataUsingReservedWord(ActionRuntime runtime, WebContext context, String varKey) {
"""
Thymeleaf's reserved words are already checked in Thymeleaf process so no check them here
"""
if (isSuppressRegisteredDataUsingReservedWordCheck()) {
return;
}
if (context.getVariableNames().contains(varKey)) {
throwThymeleafRegisteredDataUsingReservedWordException(runtime, context, varKey);
}
} | java | protected void checkRegisteredDataUsingReservedWord(ActionRuntime runtime, WebContext context, String varKey) {
if (isSuppressRegisteredDataUsingReservedWordCheck()) {
return;
}
if (context.getVariableNames().contains(varKey)) {
throwThymeleafRegisteredDataUsingReservedWordException(runtime, context, varKey);
}
} | [
"protected",
"void",
"checkRegisteredDataUsingReservedWord",
"(",
"ActionRuntime",
"runtime",
",",
"WebContext",
"context",
",",
"String",
"varKey",
")",
"{",
"if",
"(",
"isSuppressRegisteredDataUsingReservedWordCheck",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"context",
".",
"getVariableNames",
"(",
")",
".",
"contains",
"(",
"varKey",
")",
")",
"{",
"throwThymeleafRegisteredDataUsingReservedWordException",
"(",
"runtime",
",",
"context",
",",
"varKey",
")",
";",
"}",
"}"
]
| Thymeleaf's reserved words are already checked in Thymeleaf process so no check them here | [
"Thymeleaf",
"s",
"reserved",
"words",
"are",
"already",
"checked",
"in",
"Thymeleaf",
"process",
"so",
"no",
"check",
"them",
"here"
]
| train | https://github.com/lastaflute/lasta-thymeleaf/blob/d340a6e7eeddfcc9177052958c383fecd4a7fefa/src/main/java/org/lastaflute/thymeleaf/ThymeleafHtmlRenderer.java#L178-L185 |
jhg023/SimpleNet | src/main/java/simplenet/Server.java | Server.writeAndFlushToAllExcept | public final void writeAndFlushToAllExcept(Packet packet, Collection<? extends Client> clients) {
"""
Queues a {@link Packet} to a one or more {@link Client}s and calls {@link Client#flush()}, flushing all
previously-queued packets as well.
@param clients A {@link Collection} of {@link Client}s to exclude from receiving the {@link Packet}.
"""
writeHelper(packet::writeAndFlush, clients);
} | java | public final void writeAndFlushToAllExcept(Packet packet, Collection<? extends Client> clients) {
writeHelper(packet::writeAndFlush, clients);
} | [
"public",
"final",
"void",
"writeAndFlushToAllExcept",
"(",
"Packet",
"packet",
",",
"Collection",
"<",
"?",
"extends",
"Client",
">",
"clients",
")",
"{",
"writeHelper",
"(",
"packet",
"::",
"writeAndFlush",
",",
"clients",
")",
";",
"}"
]
| Queues a {@link Packet} to a one or more {@link Client}s and calls {@link Client#flush()}, flushing all
previously-queued packets as well.
@param clients A {@link Collection} of {@link Client}s to exclude from receiving the {@link Packet}. | [
"Queues",
"a",
"{",
"@link",
"Packet",
"}",
"to",
"a",
"one",
"or",
"more",
"{",
"@link",
"Client",
"}",
"s",
"and",
"calls",
"{",
"@link",
"Client#flush",
"()",
"}",
"flushing",
"all",
"previously",
"-",
"queued",
"packets",
"as",
"well",
"."
]
| train | https://github.com/jhg023/SimpleNet/blob/a5b55cbfe1768c6a28874f12adac3c748f2b509a/src/main/java/simplenet/Server.java#L294-L296 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/journal/JournalCreator.java | JournalCreator.modifyDatastreamByReference | public Date modifyDatastreamByReference(Context context,
String pid,
String datastreamID,
String[] altIDs,
String dsLabel,
String mimeType,
String formatURI,
String dsLocation,
String checksumType,
String checksum,
String logMessage,
Date lastModifiedDate)
throws ServerException {
"""
Create a journal entry, add the arguments, and invoke the method.
"""
try {
CreatorJournalEntry cje =
new CreatorJournalEntry(METHOD_MODIFY_DATASTREAM_BY_REFERENCE,
context);
cje.addArgument(ARGUMENT_NAME_PID, pid);
cje.addArgument(ARGUMENT_NAME_DS_ID, datastreamID);
cje.addArgument(ARGUMENT_NAME_ALT_IDS, altIDs);
cje.addArgument(ARGUMENT_NAME_DS_LABEL, dsLabel);
cje.addArgument(ARGUMENT_NAME_MIME_TYPE, mimeType);
cje.addArgument(ARGUMENT_NAME_FORMAT_URI, formatURI);
cje.addArgument(ARGUMENT_NAME_DS_LOCATION, dsLocation);
cje.addArgument(ARGUMENT_NAME_CHECKSUM_TYPE, checksumType);
cje.addArgument(ARGUMENT_NAME_CHECKSUM, checksum);
cje.addArgument(ARGUMENT_NAME_LOG_MESSAGE, logMessage);
cje.addArgument(ARGUMENT_NAME_LAST_MODIFIED_DATE, lastModifiedDate);
return (Date) cje.invokeAndClose(delegate, writer);
} catch (JournalException e) {
throw new GeneralException("Problem creating the Journal", e);
}
} | java | public Date modifyDatastreamByReference(Context context,
String pid,
String datastreamID,
String[] altIDs,
String dsLabel,
String mimeType,
String formatURI,
String dsLocation,
String checksumType,
String checksum,
String logMessage,
Date lastModifiedDate)
throws ServerException {
try {
CreatorJournalEntry cje =
new CreatorJournalEntry(METHOD_MODIFY_DATASTREAM_BY_REFERENCE,
context);
cje.addArgument(ARGUMENT_NAME_PID, pid);
cje.addArgument(ARGUMENT_NAME_DS_ID, datastreamID);
cje.addArgument(ARGUMENT_NAME_ALT_IDS, altIDs);
cje.addArgument(ARGUMENT_NAME_DS_LABEL, dsLabel);
cje.addArgument(ARGUMENT_NAME_MIME_TYPE, mimeType);
cje.addArgument(ARGUMENT_NAME_FORMAT_URI, formatURI);
cje.addArgument(ARGUMENT_NAME_DS_LOCATION, dsLocation);
cje.addArgument(ARGUMENT_NAME_CHECKSUM_TYPE, checksumType);
cje.addArgument(ARGUMENT_NAME_CHECKSUM, checksum);
cje.addArgument(ARGUMENT_NAME_LOG_MESSAGE, logMessage);
cje.addArgument(ARGUMENT_NAME_LAST_MODIFIED_DATE, lastModifiedDate);
return (Date) cje.invokeAndClose(delegate, writer);
} catch (JournalException e) {
throw new GeneralException("Problem creating the Journal", e);
}
} | [
"public",
"Date",
"modifyDatastreamByReference",
"(",
"Context",
"context",
",",
"String",
"pid",
",",
"String",
"datastreamID",
",",
"String",
"[",
"]",
"altIDs",
",",
"String",
"dsLabel",
",",
"String",
"mimeType",
",",
"String",
"formatURI",
",",
"String",
"dsLocation",
",",
"String",
"checksumType",
",",
"String",
"checksum",
",",
"String",
"logMessage",
",",
"Date",
"lastModifiedDate",
")",
"throws",
"ServerException",
"{",
"try",
"{",
"CreatorJournalEntry",
"cje",
"=",
"new",
"CreatorJournalEntry",
"(",
"METHOD_MODIFY_DATASTREAM_BY_REFERENCE",
",",
"context",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_PID",
",",
"pid",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_DS_ID",
",",
"datastreamID",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_ALT_IDS",
",",
"altIDs",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_DS_LABEL",
",",
"dsLabel",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_MIME_TYPE",
",",
"mimeType",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_FORMAT_URI",
",",
"formatURI",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_DS_LOCATION",
",",
"dsLocation",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_CHECKSUM_TYPE",
",",
"checksumType",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_CHECKSUM",
",",
"checksum",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_LOG_MESSAGE",
",",
"logMessage",
")",
";",
"cje",
".",
"addArgument",
"(",
"ARGUMENT_NAME_LAST_MODIFIED_DATE",
",",
"lastModifiedDate",
")",
";",
"return",
"(",
"Date",
")",
"cje",
".",
"invokeAndClose",
"(",
"delegate",
",",
"writer",
")",
";",
"}",
"catch",
"(",
"JournalException",
"e",
")",
"{",
"throw",
"new",
"GeneralException",
"(",
"\"Problem creating the Journal\"",
",",
"e",
")",
";",
"}",
"}"
]
| Create a journal entry, add the arguments, and invoke the method. | [
"Create",
"a",
"journal",
"entry",
"add",
"the",
"arguments",
"and",
"invoke",
"the",
"method",
"."
]
| train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/JournalCreator.java#L240-L272 |
jhunters/jprotobuf | src/main/java/com/baidu/bjf/remoting/protobuf/ProtobufIDLProxy.java | ProtobufIDLProxy.createSingle | public static IDLProxyObject createSingle(InputStream is, boolean debug) throws IOException {
"""
Creates the single.
@param is the is
@param debug the debug
@return the IDL proxy object
@throws IOException Signals that an I/O exception has occurred.
"""
return createSingle(is, debug, null, true);
} | java | public static IDLProxyObject createSingle(InputStream is, boolean debug) throws IOException {
return createSingle(is, debug, null, true);
} | [
"public",
"static",
"IDLProxyObject",
"createSingle",
"(",
"InputStream",
"is",
",",
"boolean",
"debug",
")",
"throws",
"IOException",
"{",
"return",
"createSingle",
"(",
"is",
",",
"debug",
",",
"null",
",",
"true",
")",
";",
"}"
]
| Creates the single.
@param is the is
@param debug the debug
@return the IDL proxy object
@throws IOException Signals that an I/O exception has occurred. | [
"Creates",
"the",
"single",
"."
]
| train | https://github.com/jhunters/jprotobuf/blob/55832c9b4792afb128e5b35139d8a3891561d8a3/src/main/java/com/baidu/bjf/remoting/protobuf/ProtobufIDLProxy.java#L976-L978 |
google/error-prone | check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java | ASTHelpers.hasAnnotation | public static boolean hasAnnotation(
Tree tree, Class<? extends Annotation> annotationClass, VisitorState state) {
"""
Check for the presence of an annotation, considering annotation inheritance.
@return true if the tree is annotated with given type.
"""
return hasAnnotation(tree, annotationClass.getName(), state);
} | java | public static boolean hasAnnotation(
Tree tree, Class<? extends Annotation> annotationClass, VisitorState state) {
return hasAnnotation(tree, annotationClass.getName(), state);
} | [
"public",
"static",
"boolean",
"hasAnnotation",
"(",
"Tree",
"tree",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
",",
"VisitorState",
"state",
")",
"{",
"return",
"hasAnnotation",
"(",
"tree",
",",
"annotationClass",
".",
"getName",
"(",
")",
",",
"state",
")",
";",
"}"
]
| Check for the presence of an annotation, considering annotation inheritance.
@return true if the tree is annotated with given type. | [
"Check",
"for",
"the",
"presence",
"of",
"an",
"annotation",
"considering",
"annotation",
"inheritance",
"."
]
| train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L727-L730 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/lss/LssClient.java | LssClient.resumeDomainStream | public ResumeDomainStreamResponse resumeDomainStream(ResumeDomainStreamRequest request) {
"""
pause domain's stream in the live stream service.
@param request The request object containing all options for pause a domain's stream
@return the response
"""
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty.");
checkStringNotEmpty(request.getApp(), "App should NOT be empty.");
checkStringNotEmpty(request.getStream(), "Stream should NOT be empty.");
InternalRequest internalRequest = createRequest(HttpMethodName.PUT,
request, LIVE_DOMAIN, request.getDomain(),
LIVE_APP, request.getApp(),
LIVE_STREAM, request.getStream());
internalRequest.addParameter(RESUME, null);
return invokeHttpClient(internalRequest, ResumeDomainStreamResponse.class);
} | java | public ResumeDomainStreamResponse resumeDomainStream(ResumeDomainStreamRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty.");
checkStringNotEmpty(request.getApp(), "App should NOT be empty.");
checkStringNotEmpty(request.getStream(), "Stream should NOT be empty.");
InternalRequest internalRequest = createRequest(HttpMethodName.PUT,
request, LIVE_DOMAIN, request.getDomain(),
LIVE_APP, request.getApp(),
LIVE_STREAM, request.getStream());
internalRequest.addParameter(RESUME, null);
return invokeHttpClient(internalRequest, ResumeDomainStreamResponse.class);
} | [
"public",
"ResumeDomainStreamResponse",
"resumeDomainStream",
"(",
"ResumeDomainStreamRequest",
"request",
")",
"{",
"checkNotNull",
"(",
"request",
",",
"\"The parameter request should NOT be null.\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getDomain",
"(",
")",
",",
"\"Domain should NOT be empty.\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getApp",
"(",
")",
",",
"\"App should NOT be empty.\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getStream",
"(",
")",
",",
"\"Stream should NOT be empty.\"",
")",
";",
"InternalRequest",
"internalRequest",
"=",
"createRequest",
"(",
"HttpMethodName",
".",
"PUT",
",",
"request",
",",
"LIVE_DOMAIN",
",",
"request",
".",
"getDomain",
"(",
")",
",",
"LIVE_APP",
",",
"request",
".",
"getApp",
"(",
")",
",",
"LIVE_STREAM",
",",
"request",
".",
"getStream",
"(",
")",
")",
";",
"internalRequest",
".",
"addParameter",
"(",
"RESUME",
",",
"null",
")",
";",
"return",
"invokeHttpClient",
"(",
"internalRequest",
",",
"ResumeDomainStreamResponse",
".",
"class",
")",
";",
"}"
]
| pause domain's stream in the live stream service.
@param request The request object containing all options for pause a domain's stream
@return the response | [
"pause",
"domain",
"s",
"stream",
"in",
"the",
"live",
"stream",
"service",
"."
]
| train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/lss/LssClient.java#L1533-L1546 |
TestFX/Monocle | src/main/java/com/sun/glass/ui/monocle/MonocleView.java | MonocleView.notifyMenu | @Override
protected void notifyMenu(int x, int y, int xAbs, int yAbs, boolean isKeyboardTrigger) {
"""
Menu event - i.e context menu hint (usually mouse right click)
"""
super.notifyMenu(x, y, xAbs, yAbs, isKeyboardTrigger);
} | java | @Override
protected void notifyMenu(int x, int y, int xAbs, int yAbs, boolean isKeyboardTrigger) {
super.notifyMenu(x, y, xAbs, yAbs, isKeyboardTrigger);
} | [
"@",
"Override",
"protected",
"void",
"notifyMenu",
"(",
"int",
"x",
",",
"int",
"y",
",",
"int",
"xAbs",
",",
"int",
"yAbs",
",",
"boolean",
"isKeyboardTrigger",
")",
"{",
"super",
".",
"notifyMenu",
"(",
"x",
",",
"y",
",",
"xAbs",
",",
"yAbs",
",",
"isKeyboardTrigger",
")",
";",
"}"
]
| Menu event - i.e context menu hint (usually mouse right click) | [
"Menu",
"event",
"-",
"i",
".",
"e",
"context",
"menu",
"hint",
"(",
"usually",
"mouse",
"right",
"click",
")"
]
| train | https://github.com/TestFX/Monocle/blob/267ccba8889cab244bf8c562dbaa0345a612874c/src/main/java/com/sun/glass/ui/monocle/MonocleView.java#L174-L177 |
bwkimmel/jdcp | jdcp-server/src/main/java/ca/eandb/jdcp/server/classmanager/FileClassManager.java | FileClassManager.writeClass | private void writeClass(File directory, String name, ByteBuffer def, byte[] digest) {
"""
Writes a class definition.
@param directory The directory under which to write the class
definition.
@param name The fully qualified name of the class.
@param def A <code>ByteBuffer</code> containing the class definition.
@param digest The MD5 digest of the class definition.
"""
String baseName = getBaseFileName(name);
File classFile = new File(directory, baseName + CLASS_EXTENSION);
File digestFile = new File(directory, baseName + DIGEST_EXTENSION);
try {
FileUtil.setFileContents(classFile, def, true);
FileUtil.setFileContents(digestFile, digest, true);
} catch (IOException e) {
e.printStackTrace();
classFile.delete();
digestFile.delete();
}
} | java | private void writeClass(File directory, String name, ByteBuffer def, byte[] digest) {
String baseName = getBaseFileName(name);
File classFile = new File(directory, baseName + CLASS_EXTENSION);
File digestFile = new File(directory, baseName + DIGEST_EXTENSION);
try {
FileUtil.setFileContents(classFile, def, true);
FileUtil.setFileContents(digestFile, digest, true);
} catch (IOException e) {
e.printStackTrace();
classFile.delete();
digestFile.delete();
}
} | [
"private",
"void",
"writeClass",
"(",
"File",
"directory",
",",
"String",
"name",
",",
"ByteBuffer",
"def",
",",
"byte",
"[",
"]",
"digest",
")",
"{",
"String",
"baseName",
"=",
"getBaseFileName",
"(",
"name",
")",
";",
"File",
"classFile",
"=",
"new",
"File",
"(",
"directory",
",",
"baseName",
"+",
"CLASS_EXTENSION",
")",
";",
"File",
"digestFile",
"=",
"new",
"File",
"(",
"directory",
",",
"baseName",
"+",
"DIGEST_EXTENSION",
")",
";",
"try",
"{",
"FileUtil",
".",
"setFileContents",
"(",
"classFile",
",",
"def",
",",
"true",
")",
";",
"FileUtil",
".",
"setFileContents",
"(",
"digestFile",
",",
"digest",
",",
"true",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"classFile",
".",
"delete",
"(",
")",
";",
"digestFile",
".",
"delete",
"(",
")",
";",
"}",
"}"
]
| Writes a class definition.
@param directory The directory under which to write the class
definition.
@param name The fully qualified name of the class.
@param def A <code>ByteBuffer</code> containing the class definition.
@param digest The MD5 digest of the class definition. | [
"Writes",
"a",
"class",
"definition",
"."
]
| train | https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-server/src/main/java/ca/eandb/jdcp/server/classmanager/FileClassManager.java#L178-L191 |
jbundle/jbundle | base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java | AnalysisScreen.isKeyField | public boolean isKeyField(BaseField field, int iSourceFieldSeq) {
"""
This is field a potential index for analysis.
(Override this to allow number fields to be keys).
@param field The field to check.
@return True if this is a potential key field.
"""
if (field instanceof DateTimeField)
return true;
if (field instanceof NumberField)
return false;
if (iSourceFieldSeq == 0)
return false; // You must have at least one key field.
return true; // Typically any non-number is a key.
} | java | public boolean isKeyField(BaseField field, int iSourceFieldSeq)
{
if (field instanceof DateTimeField)
return true;
if (field instanceof NumberField)
return false;
if (iSourceFieldSeq == 0)
return false; // You must have at least one key field.
return true; // Typically any non-number is a key.
} | [
"public",
"boolean",
"isKeyField",
"(",
"BaseField",
"field",
",",
"int",
"iSourceFieldSeq",
")",
"{",
"if",
"(",
"field",
"instanceof",
"DateTimeField",
")",
"return",
"true",
";",
"if",
"(",
"field",
"instanceof",
"NumberField",
")",
"return",
"false",
";",
"if",
"(",
"iSourceFieldSeq",
"==",
"0",
")",
"return",
"false",
";",
"// You must have at least one key field.",
"return",
"true",
";",
"// Typically any non-number is a key.",
"}"
]
| This is field a potential index for analysis.
(Override this to allow number fields to be keys).
@param field The field to check.
@return True if this is a potential key field. | [
"This",
"is",
"field",
"a",
"potential",
"index",
"for",
"analysis",
".",
"(",
"Override",
"this",
"to",
"allow",
"number",
"fields",
"to",
"be",
"keys",
")",
"."
]
| train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/AnalysisScreen.java#L343-L352 |
umeding/fuzzer | src/main/java/com/uwemeding/fuzzer/Variable.java | Variable.getMember | public Member getMember(String hedgeName, String memberName) {
"""
Get a hedged member.
<p>
@param hedgeName is the hedge name
@param memberName is the member name
@return the member
"""
String fullName = hedgeName + "$" + memberName;
return getMember(fullName);
} | java | public Member getMember(String hedgeName, String memberName) {
String fullName = hedgeName + "$" + memberName;
return getMember(fullName);
} | [
"public",
"Member",
"getMember",
"(",
"String",
"hedgeName",
",",
"String",
"memberName",
")",
"{",
"String",
"fullName",
"=",
"hedgeName",
"+",
"\"$\"",
"+",
"memberName",
";",
"return",
"getMember",
"(",
"fullName",
")",
";",
"}"
]
| Get a hedged member.
<p>
@param hedgeName is the hedge name
@param memberName is the member name
@return the member | [
"Get",
"a",
"hedged",
"member",
".",
"<p",
">"
]
| train | https://github.com/umeding/fuzzer/blob/e8aa46313bb1d1328865f26f99455124aede828c/src/main/java/com/uwemeding/fuzzer/Variable.java#L200-L203 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java | WWindow.preparePaintComponent | @Override
protected void preparePaintComponent(final Request request) {
"""
Override preparePaintComponent to clear the scratch map before the window content is being painted.
@param request the request being responded to.
"""
super.preparePaintComponent(request);
// Check if window in request (might not have gone through handle request, eg Step error)
boolean targeted = isPresent(request);
setTargeted(targeted);
if (getState() == ACTIVE_STATE && isTargeted()) {
getComponentModel().wrappedContent.preparePaint(request);
}
} | java | @Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
// Check if window in request (might not have gone through handle request, eg Step error)
boolean targeted = isPresent(request);
setTargeted(targeted);
if (getState() == ACTIVE_STATE && isTargeted()) {
getComponentModel().wrappedContent.preparePaint(request);
}
} | [
"@",
"Override",
"protected",
"void",
"preparePaintComponent",
"(",
"final",
"Request",
"request",
")",
"{",
"super",
".",
"preparePaintComponent",
"(",
"request",
")",
";",
"// Check if window in request (might not have gone through handle request, eg Step error)",
"boolean",
"targeted",
"=",
"isPresent",
"(",
"request",
")",
";",
"setTargeted",
"(",
"targeted",
")",
";",
"if",
"(",
"getState",
"(",
")",
"==",
"ACTIVE_STATE",
"&&",
"isTargeted",
"(",
")",
")",
"{",
"getComponentModel",
"(",
")",
".",
"wrappedContent",
".",
"preparePaint",
"(",
"request",
")",
";",
"}",
"}"
]
| Override preparePaintComponent to clear the scratch map before the window content is being painted.
@param request the request being responded to. | [
"Override",
"preparePaintComponent",
"to",
"clear",
"the",
"scratch",
"map",
"before",
"the",
"window",
"content",
"is",
"being",
"painted",
"."
]
| train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java#L409-L420 |
GeoLatte/geolatte-common | src/main/java/org/geolatte/common/expressions/Expressions.java | Expressions.isLessThanOrEqual | public static IsLessThanOrEqual isLessThanOrEqual(NumberExpression left, Object constant) {
"""
Creates an IsLessThanOrEqual expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a Number).
@throws IllegalArgumentException If the constant is not a Number
@return A new is less than binary expression.
"""
if (!(constant instanceof Number))
throw new IllegalArgumentException("constant is not a Number");
return new IsLessThanOrEqual(left, constant((Number)constant));
} | java | public static IsLessThanOrEqual isLessThanOrEqual(NumberExpression left, Object constant) {
if (!(constant instanceof Number))
throw new IllegalArgumentException("constant is not a Number");
return new IsLessThanOrEqual(left, constant((Number)constant));
} | [
"public",
"static",
"IsLessThanOrEqual",
"isLessThanOrEqual",
"(",
"NumberExpression",
"left",
",",
"Object",
"constant",
")",
"{",
"if",
"(",
"!",
"(",
"constant",
"instanceof",
"Number",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"constant is not a Number\"",
")",
";",
"return",
"new",
"IsLessThanOrEqual",
"(",
"left",
",",
"constant",
"(",
"(",
"Number",
")",
"constant",
")",
")",
";",
"}"
]
| Creates an IsLessThanOrEqual expression from the given expression and constant.
@param left The left expression.
@param constant The constant to compare to (must be a Number).
@throws IllegalArgumentException If the constant is not a Number
@return A new is less than binary expression. | [
"Creates",
"an",
"IsLessThanOrEqual",
"expression",
"from",
"the",
"given",
"expression",
"and",
"constant",
"."
]
| train | https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L416-L422 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/Dict.java | Dict.parseBean | public <T> Dict parseBean(T bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
"""
将值对象转换为Dict<br>
类名会被当作表名,小写第一个字母
@param <T> Bean类型
@param bean 值对象
@param isToUnderlineCase 是否转换为下划线模式
@param ignoreNullValue 是否忽略值为空的字段
@return 自己
"""
Assert.notNull(bean, "Bean class must be not null");
this.putAll(BeanUtil.beanToMap(bean, isToUnderlineCase, ignoreNullValue));
return this;
} | java | public <T> Dict parseBean(T bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
Assert.notNull(bean, "Bean class must be not null");
this.putAll(BeanUtil.beanToMap(bean, isToUnderlineCase, ignoreNullValue));
return this;
} | [
"public",
"<",
"T",
">",
"Dict",
"parseBean",
"(",
"T",
"bean",
",",
"boolean",
"isToUnderlineCase",
",",
"boolean",
"ignoreNullValue",
")",
"{",
"Assert",
".",
"notNull",
"(",
"bean",
",",
"\"Bean class must be not null\"",
")",
";",
"this",
".",
"putAll",
"(",
"BeanUtil",
".",
"beanToMap",
"(",
"bean",
",",
"isToUnderlineCase",
",",
"ignoreNullValue",
")",
")",
";",
"return",
"this",
";",
"}"
]
| 将值对象转换为Dict<br>
类名会被当作表名,小写第一个字母
@param <T> Bean类型
@param bean 值对象
@param isToUnderlineCase 是否转换为下划线模式
@param ignoreNullValue 是否忽略值为空的字段
@return 自己 | [
"将值对象转换为Dict<br",
">",
"类名会被当作表名,小写第一个字母"
]
| train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Dict.java#L181-L185 |
hyunjun19/axu4j | axu4j-tag/src/main/java/com/axisj/axu4j/tags/TagUtils.java | TagUtils.getElValue | public static Object getElValue(JspContext context, String elName) {
"""
"${...}" EL 명을 Object 값으로 변환한다.
@param context
@param elName
@return
"""
VariableResolver variableResolver = context.getVariableResolver();
Object var = null;
try {
elName = TagUtils.getElName(elName);
var = variableResolver.resolveVariable(elName);
logger.debug("ExpressionLanguage variable {} is [{}]", elName, var);
} catch (ELException e) {
logger.error("ExpressionLanguage Error", e);
}
return var;
} | java | public static Object getElValue(JspContext context, String elName) {
VariableResolver variableResolver = context.getVariableResolver();
Object var = null;
try {
elName = TagUtils.getElName(elName);
var = variableResolver.resolveVariable(elName);
logger.debug("ExpressionLanguage variable {} is [{}]", elName, var);
} catch (ELException e) {
logger.error("ExpressionLanguage Error", e);
}
return var;
} | [
"public",
"static",
"Object",
"getElValue",
"(",
"JspContext",
"context",
",",
"String",
"elName",
")",
"{",
"VariableResolver",
"variableResolver",
"=",
"context",
".",
"getVariableResolver",
"(",
")",
";",
"Object",
"var",
"=",
"null",
";",
"try",
"{",
"elName",
"=",
"TagUtils",
".",
"getElName",
"(",
"elName",
")",
";",
"var",
"=",
"variableResolver",
".",
"resolveVariable",
"(",
"elName",
")",
";",
"logger",
".",
"debug",
"(",
"\"ExpressionLanguage variable {} is [{}]\"",
",",
"elName",
",",
"var",
")",
";",
"}",
"catch",
"(",
"ELException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"ExpressionLanguage Error\"",
",",
"e",
")",
";",
"}",
"return",
"var",
";",
"}"
]
| "${...}" EL 명을 Object 값으로 변환한다.
@param context
@param elName
@return | [
"$",
"{",
"...",
"}",
"EL",
"명을",
"Object",
"값으로",
"변환한다",
"."
]
| train | https://github.com/hyunjun19/axu4j/blob/a7eaf698a4ebe160b4ba22789fc543cdc50b3d64/axu4j-tag/src/main/java/com/axisj/axu4j/tags/TagUtils.java#L86-L98 |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java | SARLJvmModelInferrer.cloneWithTypeParametersAndProxies | protected JvmTypeReference cloneWithTypeParametersAndProxies(JvmTypeReference type, JvmExecutable forExecutable) {
"""
Clone the given type reference that for being link to the given executable component.
<p>The proxies are not resolved, and the type parameters are clone when they are
related to the type parameter of the executable or the type container.
@param type the source type.
@param forExecutable the executable component that will contain the result type.
@return the result type, i.e. a copy of the source type.
"""
// Ensure that the executable is inside a container. Otherwise, the cloning function will fail.
assert forExecutable.getDeclaringType() != null;
// Get the type parameter mapping that is a consequence of the super type extension within the container.
final Map<String, JvmTypeReference> superTypeParameterMapping = new HashMap<>();
Utils.getSuperTypeParameterMap(forExecutable.getDeclaringType(), superTypeParameterMapping);
// Do the cloning
return Utils.cloneWithTypeParametersAndProxies(
type,
forExecutable.getTypeParameters(),
superTypeParameterMapping,
this._typeReferenceBuilder,
this.typeBuilder, this.typeReferences, this.typesFactory);
} | java | protected JvmTypeReference cloneWithTypeParametersAndProxies(JvmTypeReference type, JvmExecutable forExecutable) {
// Ensure that the executable is inside a container. Otherwise, the cloning function will fail.
assert forExecutable.getDeclaringType() != null;
// Get the type parameter mapping that is a consequence of the super type extension within the container.
final Map<String, JvmTypeReference> superTypeParameterMapping = new HashMap<>();
Utils.getSuperTypeParameterMap(forExecutable.getDeclaringType(), superTypeParameterMapping);
// Do the cloning
return Utils.cloneWithTypeParametersAndProxies(
type,
forExecutable.getTypeParameters(),
superTypeParameterMapping,
this._typeReferenceBuilder,
this.typeBuilder, this.typeReferences, this.typesFactory);
} | [
"protected",
"JvmTypeReference",
"cloneWithTypeParametersAndProxies",
"(",
"JvmTypeReference",
"type",
",",
"JvmExecutable",
"forExecutable",
")",
"{",
"// Ensure that the executable is inside a container. Otherwise, the cloning function will fail.",
"assert",
"forExecutable",
".",
"getDeclaringType",
"(",
")",
"!=",
"null",
";",
"// Get the type parameter mapping that is a consequence of the super type extension within the container.",
"final",
"Map",
"<",
"String",
",",
"JvmTypeReference",
">",
"superTypeParameterMapping",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Utils",
".",
"getSuperTypeParameterMap",
"(",
"forExecutable",
".",
"getDeclaringType",
"(",
")",
",",
"superTypeParameterMapping",
")",
";",
"// Do the cloning",
"return",
"Utils",
".",
"cloneWithTypeParametersAndProxies",
"(",
"type",
",",
"forExecutable",
".",
"getTypeParameters",
"(",
")",
",",
"superTypeParameterMapping",
",",
"this",
".",
"_typeReferenceBuilder",
",",
"this",
".",
"typeBuilder",
",",
"this",
".",
"typeReferences",
",",
"this",
".",
"typesFactory",
")",
";",
"}"
]
| Clone the given type reference that for being link to the given executable component.
<p>The proxies are not resolved, and the type parameters are clone when they are
related to the type parameter of the executable or the type container.
@param type the source type.
@param forExecutable the executable component that will contain the result type.
@return the result type, i.e. a copy of the source type. | [
"Clone",
"the",
"given",
"type",
"reference",
"that",
"for",
"being",
"link",
"to",
"the",
"given",
"executable",
"component",
"."
]
| train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L3296-L3309 |
magro/memcached-session-manager | javolution-serializer/src/main/java/de/javakaffee/web/msm/serializer/javolution/JavolutionTranscoder.java | JavolutionTranscoder.deserializeAttributes | @Override
public ConcurrentMap<String, Object> deserializeAttributes(final byte[] in ) {
"""
Get the object represented by the given serialized bytes.
@param in
the bytes to deserialize
@return the resulting object
"""
if ( LOG.isDebugEnabled() ) {
LOG.debug( "Reading serialized data:\n" + new String( in ) );
}
return doDeserialize( in, "attributes" );
} | java | @Override
public ConcurrentMap<String, Object> deserializeAttributes(final byte[] in ) {
if ( LOG.isDebugEnabled() ) {
LOG.debug( "Reading serialized data:\n" + new String( in ) );
}
return doDeserialize( in, "attributes" );
} | [
"@",
"Override",
"public",
"ConcurrentMap",
"<",
"String",
",",
"Object",
">",
"deserializeAttributes",
"(",
"final",
"byte",
"[",
"]",
"in",
")",
"{",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Reading serialized data:\\n\"",
"+",
"new",
"String",
"(",
"in",
")",
")",
";",
"}",
"return",
"doDeserialize",
"(",
"in",
",",
"\"attributes\"",
")",
";",
"}"
]
| Get the object represented by the given serialized bytes.
@param in
the bytes to deserialize
@return the resulting object | [
"Get",
"the",
"object",
"represented",
"by",
"the",
"given",
"serialized",
"bytes",
"."
]
| train | https://github.com/magro/memcached-session-manager/blob/716e147c9840ab10298c4d2b9edd0662058331e6/javolution-serializer/src/main/java/de/javakaffee/web/msm/serializer/javolution/JavolutionTranscoder.java#L154-L162 |
apache/flink | flink-core/src/main/java/org/apache/flink/types/parser/FieldParser.java | FieldParser.nextStringEndPos | protected final int nextStringEndPos(byte[] bytes, int startPos, int limit, byte[] delimiter) {
"""
Returns the end position of a string. Sets the error state if the column is empty.
@return the end position of the string or -1 if an error occurred
"""
int endPos = startPos;
final int delimLimit = limit - delimiter.length + 1;
while (endPos < limit) {
if (endPos < delimLimit && delimiterNext(bytes, endPos, delimiter)) {
break;
}
endPos++;
}
if (endPos == startPos) {
setErrorState(ParseErrorState.EMPTY_COLUMN);
return -1;
}
return endPos;
} | java | protected final int nextStringEndPos(byte[] bytes, int startPos, int limit, byte[] delimiter) {
int endPos = startPos;
final int delimLimit = limit - delimiter.length + 1;
while (endPos < limit) {
if (endPos < delimLimit && delimiterNext(bytes, endPos, delimiter)) {
break;
}
endPos++;
}
if (endPos == startPos) {
setErrorState(ParseErrorState.EMPTY_COLUMN);
return -1;
}
return endPos;
} | [
"protected",
"final",
"int",
"nextStringEndPos",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"startPos",
",",
"int",
"limit",
",",
"byte",
"[",
"]",
"delimiter",
")",
"{",
"int",
"endPos",
"=",
"startPos",
";",
"final",
"int",
"delimLimit",
"=",
"limit",
"-",
"delimiter",
".",
"length",
"+",
"1",
";",
"while",
"(",
"endPos",
"<",
"limit",
")",
"{",
"if",
"(",
"endPos",
"<",
"delimLimit",
"&&",
"delimiterNext",
"(",
"bytes",
",",
"endPos",
",",
"delimiter",
")",
")",
"{",
"break",
";",
"}",
"endPos",
"++",
";",
"}",
"if",
"(",
"endPos",
"==",
"startPos",
")",
"{",
"setErrorState",
"(",
"ParseErrorState",
".",
"EMPTY_COLUMN",
")",
";",
"return",
"-",
"1",
";",
"}",
"return",
"endPos",
";",
"}"
]
| Returns the end position of a string. Sets the error state if the column is empty.
@return the end position of the string or -1 if an error occurred | [
"Returns",
"the",
"end",
"position",
"of",
"a",
"string",
".",
"Sets",
"the",
"error",
"state",
"if",
"the",
"column",
"is",
"empty",
"."
]
| train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/parser/FieldParser.java#L206-L223 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/filter/FilterBlur.java | FilterBlur.checkEdge | private static int checkEdge(int width, int x, int col, int edge) {
"""
Check the edge value.
@param width The image width.
@param x The current horizontal pixel.
@param col The column size.
@param edge The edge flag.
@return The edge offset.
"""
int ix = x + col;
if (ix < 0)
{
if (edge == CLAMP_EDGES)
{
ix = 0;
}
else
{
ix = (x + width) % width;
}
}
else if (ix >= width)
{
if (edge == CLAMP_EDGES)
{
ix = width - 1;
}
else
{
ix = (x + width) % width;
}
}
return ix;
} | java | private static int checkEdge(int width, int x, int col, int edge)
{
int ix = x + col;
if (ix < 0)
{
if (edge == CLAMP_EDGES)
{
ix = 0;
}
else
{
ix = (x + width) % width;
}
}
else if (ix >= width)
{
if (edge == CLAMP_EDGES)
{
ix = width - 1;
}
else
{
ix = (x + width) % width;
}
}
return ix;
} | [
"private",
"static",
"int",
"checkEdge",
"(",
"int",
"width",
",",
"int",
"x",
",",
"int",
"col",
",",
"int",
"edge",
")",
"{",
"int",
"ix",
"=",
"x",
"+",
"col",
";",
"if",
"(",
"ix",
"<",
"0",
")",
"{",
"if",
"(",
"edge",
"==",
"CLAMP_EDGES",
")",
"{",
"ix",
"=",
"0",
";",
"}",
"else",
"{",
"ix",
"=",
"(",
"x",
"+",
"width",
")",
"%",
"width",
";",
"}",
"}",
"else",
"if",
"(",
"ix",
">=",
"width",
")",
"{",
"if",
"(",
"edge",
"==",
"CLAMP_EDGES",
")",
"{",
"ix",
"=",
"width",
"-",
"1",
";",
"}",
"else",
"{",
"ix",
"=",
"(",
"x",
"+",
"width",
")",
"%",
"width",
";",
"}",
"}",
"return",
"ix",
";",
"}"
]
| Check the edge value.
@param width The image width.
@param x The current horizontal pixel.
@param col The column size.
@param edge The edge flag.
@return The edge offset. | [
"Check",
"the",
"edge",
"value",
"."
]
| train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/filter/FilterBlur.java#L138-L164 |
couchbase/couchbase-jvm-core | src/main/java/com/couchbase/client/core/message/analytics/GenericAnalyticsRequest.java | GenericAnalyticsRequest.jsonQuery | public static GenericAnalyticsRequest jsonQuery(String jsonQuery, String bucket, String username, String password, InetAddress targetNode) {
"""
Create a {@link GenericAnalyticsRequest} and mark it as containing a full Analytics query in Json form
(including additional query parameters).
The simplest form of such a query is a single statement encapsulated in a json query object:
<pre>{"statement":"SELECT * FROM default"}</pre>.
@param jsonQuery the Analytics query in json form.
@param bucket the bucket on which to perform the query.
@param username the username authorized for bucket access.
@param password the password for the user.
@param targetNode the node on which to execute this request (or null to let the core locate and choose one).
@return a {@link GenericAnalyticsRequest} for this full query.
"""
return new GenericAnalyticsRequest(jsonQuery, true, bucket, username, password, targetNode, NO_PRIORITY);
} | java | public static GenericAnalyticsRequest jsonQuery(String jsonQuery, String bucket, String username, String password, InetAddress targetNode) {
return new GenericAnalyticsRequest(jsonQuery, true, bucket, username, password, targetNode, NO_PRIORITY);
} | [
"public",
"static",
"GenericAnalyticsRequest",
"jsonQuery",
"(",
"String",
"jsonQuery",
",",
"String",
"bucket",
",",
"String",
"username",
",",
"String",
"password",
",",
"InetAddress",
"targetNode",
")",
"{",
"return",
"new",
"GenericAnalyticsRequest",
"(",
"jsonQuery",
",",
"true",
",",
"bucket",
",",
"username",
",",
"password",
",",
"targetNode",
",",
"NO_PRIORITY",
")",
";",
"}"
]
| Create a {@link GenericAnalyticsRequest} and mark it as containing a full Analytics query in Json form
(including additional query parameters).
The simplest form of such a query is a single statement encapsulated in a json query object:
<pre>{"statement":"SELECT * FROM default"}</pre>.
@param jsonQuery the Analytics query in json form.
@param bucket the bucket on which to perform the query.
@param username the username authorized for bucket access.
@param password the password for the user.
@param targetNode the node on which to execute this request (or null to let the core locate and choose one).
@return a {@link GenericAnalyticsRequest} for this full query. | [
"Create",
"a",
"{",
"@link",
"GenericAnalyticsRequest",
"}",
"and",
"mark",
"it",
"as",
"containing",
"a",
"full",
"Analytics",
"query",
"in",
"Json",
"form",
"(",
"including",
"additional",
"query",
"parameters",
")",
"."
]
| train | https://github.com/couchbase/couchbase-jvm-core/blob/97f0427112c2168fee1d6499904f5fa0e24c6797/src/main/java/com/couchbase/client/core/message/analytics/GenericAnalyticsRequest.java#L150-L152 |
jfinal/jfinal | src/main/java/com/jfinal/plugin/redis/Cache.java | Cache.zadd | public Long zadd(Object key, double score, Object member) {
"""
将一个或多个 member 元素及其 score 值加入到有序集 key 当中。
如果某个 member 已经是有序集的成员,那么更新这个 member 的 score 值,
并通过重新插入这个 member 元素,来保证该 member 在正确的位置上。
"""
Jedis jedis = getJedis();
try {
return jedis.zadd(keyToBytes(key), score, valueToBytes(member));
}
finally {close(jedis);}
} | java | public Long zadd(Object key, double score, Object member) {
Jedis jedis = getJedis();
try {
return jedis.zadd(keyToBytes(key), score, valueToBytes(member));
}
finally {close(jedis);}
} | [
"public",
"Long",
"zadd",
"(",
"Object",
"key",
",",
"double",
"score",
",",
"Object",
"member",
")",
"{",
"Jedis",
"jedis",
"=",
"getJedis",
"(",
")",
";",
"try",
"{",
"return",
"jedis",
".",
"zadd",
"(",
"keyToBytes",
"(",
"key",
")",
",",
"score",
",",
"valueToBytes",
"(",
"member",
")",
")",
";",
"}",
"finally",
"{",
"close",
"(",
"jedis",
")",
";",
"}",
"}"
]
| 将一个或多个 member 元素及其 score 值加入到有序集 key 当中。
如果某个 member 已经是有序集的成员,那么更新这个 member 的 score 值,
并通过重新插入这个 member 元素,来保证该 member 在正确的位置上。 | [
"将一个或多个",
"member",
"元素及其",
"score",
"值加入到有序集",
"key",
"当中。",
"如果某个",
"member",
"已经是有序集的成员,那么更新这个",
"member",
"的",
"score",
"值,",
"并通过重新插入这个",
"member",
"元素,来保证该",
"member",
"在正确的位置上。"
]
| train | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/redis/Cache.java#L996-L1002 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.encryptAsync | public Observable<KeyOperationResult> encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) {
"""
Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault.
The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/encypt permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param keyName The name of the key.
@param keyVersion The version of the key.
@param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5'
@param value the Base64Url value
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the KeyOperationResult object
"""
return encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1<ServiceResponse<KeyOperationResult>, KeyOperationResult>() {
@Override
public KeyOperationResult call(ServiceResponse<KeyOperationResult> response) {
return response.body();
}
});
} | java | public Observable<KeyOperationResult> encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) {
return encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1<ServiceResponse<KeyOperationResult>, KeyOperationResult>() {
@Override
public KeyOperationResult call(ServiceResponse<KeyOperationResult> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"KeyOperationResult",
">",
"encryptAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"keyName",
",",
"String",
"keyVersion",
",",
"JsonWebKeyEncryptionAlgorithm",
"algorithm",
",",
"byte",
"[",
"]",
"value",
")",
"{",
"return",
"encryptWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"keyName",
",",
"keyVersion",
",",
"algorithm",
",",
"value",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"KeyOperationResult",
">",
",",
"KeyOperationResult",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"KeyOperationResult",
"call",
"(",
"ServiceResponse",
"<",
"KeyOperationResult",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault.
The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/encypt permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param keyName The name of the key.
@param keyVersion The version of the key.
@param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5'
@param value the Base64Url value
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the KeyOperationResult object | [
"Encrypts",
"an",
"arbitrary",
"sequence",
"of",
"bytes",
"using",
"an",
"encryption",
"key",
"that",
"is",
"stored",
"in",
"a",
"key",
"vault",
".",
"The",
"ENCRYPT",
"operation",
"encrypts",
"an",
"arbitrary",
"sequence",
"of",
"bytes",
"using",
"an",
"encryption",
"key",
"that",
"is",
"stored",
"in",
"Azure",
"Key",
"Vault",
".",
"Note",
"that",
"the",
"ENCRYPT",
"operation",
"only",
"supports",
"a",
"single",
"block",
"of",
"data",
"the",
"size",
"of",
"which",
"is",
"dependent",
"on",
"the",
"target",
"key",
"and",
"the",
"encryption",
"algorithm",
"to",
"be",
"used",
".",
"The",
"ENCRYPT",
"operation",
"is",
"only",
"strictly",
"necessary",
"for",
"symmetric",
"keys",
"stored",
"in",
"Azure",
"Key",
"Vault",
"since",
"protection",
"with",
"an",
"asymmetric",
"key",
"can",
"be",
"performed",
"using",
"public",
"portion",
"of",
"the",
"key",
".",
"This",
"operation",
"is",
"supported",
"for",
"asymmetric",
"keys",
"as",
"a",
"convenience",
"for",
"callers",
"that",
"have",
"a",
"key",
"-",
"reference",
"but",
"do",
"not",
"have",
"access",
"to",
"the",
"public",
"key",
"material",
".",
"This",
"operation",
"requires",
"the",
"keys",
"/",
"encypt",
"permission",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L2179-L2186 |
jhg023/SimpleNet | src/main/java/simplenet/Server.java | Server.writeToAllExcept | @SafeVarargs
public final <T extends Client> void writeToAllExcept(Packet packet, T... clients) {
"""
Queues a {@link Packet} to all connected {@link Client}s except the one(s) specified.
<br><br>
No {@link Client} will receive this {@link Packet} until {@link Client#flush()} is called for that respective
{@link Client}.
@param <T> A {@link Client} or any of its children.
@param clients A variable amount of {@link Client}s to exclude from receiving the {@link Packet}.
"""
writeHelper(packet::write, clients);
} | java | @SafeVarargs
public final <T extends Client> void writeToAllExcept(Packet packet, T... clients) {
writeHelper(packet::write, clients);
} | [
"@",
"SafeVarargs",
"public",
"final",
"<",
"T",
"extends",
"Client",
">",
"void",
"writeToAllExcept",
"(",
"Packet",
"packet",
",",
"T",
"...",
"clients",
")",
"{",
"writeHelper",
"(",
"packet",
"::",
"write",
",",
"clients",
")",
";",
"}"
]
| Queues a {@link Packet} to all connected {@link Client}s except the one(s) specified.
<br><br>
No {@link Client} will receive this {@link Packet} until {@link Client#flush()} is called for that respective
{@link Client}.
@param <T> A {@link Client} or any of its children.
@param clients A variable amount of {@link Client}s to exclude from receiving the {@link Packet}. | [
"Queues",
"a",
"{",
"@link",
"Packet",
"}",
"to",
"all",
"connected",
"{",
"@link",
"Client",
"}",
"s",
"except",
"the",
"one",
"(",
"s",
")",
"specified",
".",
"<br",
">",
"<br",
">",
"No",
"{",
"@link",
"Client",
"}",
"will",
"receive",
"this",
"{",
"@link",
"Packet",
"}",
"until",
"{",
"@link",
"Client#flush",
"()",
"}",
"is",
"called",
"for",
"that",
"respective",
"{",
"@link",
"Client",
"}",
"."
]
| train | https://github.com/jhg023/SimpleNet/blob/a5b55cbfe1768c6a28874f12adac3c748f2b509a/src/main/java/simplenet/Server.java#L239-L242 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/base64/Base64.java | Base64.safeDecode | @Nullable
@ReturnsMutableCopy
public static byte [] safeDecode (@Nullable final byte [] aEncodedBytes,
@Nonnegative final int nOfs,
@Nonnegative final int nLen,
final int nOptions) {
"""
Decode the byte array.
@param aEncodedBytes
The encoded byte array.
@param nOfs
The offset of where to begin decoding
@param nLen
The number of characters to decode
@param nOptions
Decoding options.
@return <code>null</code> if decoding failed.
"""
if (aEncodedBytes != null)
try
{
return decode (aEncodedBytes, nOfs, nLen, nOptions);
}
catch (final IOException | IllegalArgumentException ex)
{
// fall through
}
return null;
} | java | @Nullable
@ReturnsMutableCopy
public static byte [] safeDecode (@Nullable final byte [] aEncodedBytes,
@Nonnegative final int nOfs,
@Nonnegative final int nLen,
final int nOptions)
{
if (aEncodedBytes != null)
try
{
return decode (aEncodedBytes, nOfs, nLen, nOptions);
}
catch (final IOException | IllegalArgumentException ex)
{
// fall through
}
return null;
} | [
"@",
"Nullable",
"@",
"ReturnsMutableCopy",
"public",
"static",
"byte",
"[",
"]",
"safeDecode",
"(",
"@",
"Nullable",
"final",
"byte",
"[",
"]",
"aEncodedBytes",
",",
"@",
"Nonnegative",
"final",
"int",
"nOfs",
",",
"@",
"Nonnegative",
"final",
"int",
"nLen",
",",
"final",
"int",
"nOptions",
")",
"{",
"if",
"(",
"aEncodedBytes",
"!=",
"null",
")",
"try",
"{",
"return",
"decode",
"(",
"aEncodedBytes",
",",
"nOfs",
",",
"nLen",
",",
"nOptions",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"|",
"IllegalArgumentException",
"ex",
")",
"{",
"// fall through",
"}",
"return",
"null",
";",
"}"
]
| Decode the byte array.
@param aEncodedBytes
The encoded byte array.
@param nOfs
The offset of where to begin decoding
@param nLen
The number of characters to decode
@param nOptions
Decoding options.
@return <code>null</code> if decoding failed. | [
"Decode",
"the",
"byte",
"array",
"."
]
| train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/base64/Base64.java#L2636-L2653 |
SvenEwald/xmlbeam | src/main/java/org/xmlbeam/io/UrlIO.java | UrlIO.evalXPath | @Override
@Scope(DocScope.IO)
public XPathEvaluator evalXPath(final String xpath) {
"""
Evaluate XPath on the url document.
@param xpath
@return xpath evaluator
@see org.xmlbeam.evaluation.CanEvaluate#evalXPath(java.lang.String)
"""
return new DefaultXPathEvaluator(projector, new DocumentResolver() {
@Override
public Document resolve(final Class<?>... resourceAwareClasses) throws IOException {
return IOHelper.getDocumentFromURL(projector.config().createDocumentBuilder(), url, requestProperties, resourceAwareClasses);
}
}, xpath);
} | java | @Override
@Scope(DocScope.IO)
public XPathEvaluator evalXPath(final String xpath) {
return new DefaultXPathEvaluator(projector, new DocumentResolver() {
@Override
public Document resolve(final Class<?>... resourceAwareClasses) throws IOException {
return IOHelper.getDocumentFromURL(projector.config().createDocumentBuilder(), url, requestProperties, resourceAwareClasses);
}
}, xpath);
} | [
"@",
"Override",
"@",
"Scope",
"(",
"DocScope",
".",
"IO",
")",
"public",
"XPathEvaluator",
"evalXPath",
"(",
"final",
"String",
"xpath",
")",
"{",
"return",
"new",
"DefaultXPathEvaluator",
"(",
"projector",
",",
"new",
"DocumentResolver",
"(",
")",
"{",
"@",
"Override",
"public",
"Document",
"resolve",
"(",
"final",
"Class",
"<",
"?",
">",
"...",
"resourceAwareClasses",
")",
"throws",
"IOException",
"{",
"return",
"IOHelper",
".",
"getDocumentFromURL",
"(",
"projector",
".",
"config",
"(",
")",
".",
"createDocumentBuilder",
"(",
")",
",",
"url",
",",
"requestProperties",
",",
"resourceAwareClasses",
")",
";",
"}",
"}",
",",
"xpath",
")",
";",
"}"
]
| Evaluate XPath on the url document.
@param xpath
@return xpath evaluator
@see org.xmlbeam.evaluation.CanEvaluate#evalXPath(java.lang.String) | [
"Evaluate",
"XPath",
"on",
"the",
"url",
"document",
"."
]
| train | https://github.com/SvenEwald/xmlbeam/blob/acaac1b8fa28d246f17187f5e3c6696458a0b447/src/main/java/org/xmlbeam/io/UrlIO.java#L124-L133 |
roboconf/roboconf-platform | core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java | DockerUtils.getContainerState | public static ContainerState getContainerState( String containerId, DockerClient dockerClient ) {
"""
Gets the state of a container.
@param containerId the container ID
@param dockerClient the Docker client
@return a container state, or null if the container was not found
"""
ContainerState result = null;
try {
InspectContainerResponse resp = dockerClient.inspectContainerCmd( containerId ).exec();
if( resp != null )
result = resp.getState();
} catch( Exception e ) {
// nothing
}
return result;
} | java | public static ContainerState getContainerState( String containerId, DockerClient dockerClient ) {
ContainerState result = null;
try {
InspectContainerResponse resp = dockerClient.inspectContainerCmd( containerId ).exec();
if( resp != null )
result = resp.getState();
} catch( Exception e ) {
// nothing
}
return result;
} | [
"public",
"static",
"ContainerState",
"getContainerState",
"(",
"String",
"containerId",
",",
"DockerClient",
"dockerClient",
")",
"{",
"ContainerState",
"result",
"=",
"null",
";",
"try",
"{",
"InspectContainerResponse",
"resp",
"=",
"dockerClient",
".",
"inspectContainerCmd",
"(",
"containerId",
")",
".",
"exec",
"(",
")",
";",
"if",
"(",
"resp",
"!=",
"null",
")",
"result",
"=",
"resp",
".",
"getState",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// nothing",
"}",
"return",
"result",
";",
"}"
]
| Gets the state of a container.
@param containerId the container ID
@param dockerClient the Docker client
@return a container state, or null if the container was not found | [
"Gets",
"the",
"state",
"of",
"a",
"container",
"."
]
| train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L213-L226 |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/natures/SARLProjectConfigurator.java | SARLProjectConfigurator.safeRefresh | @SuppressWarnings("static-method")
protected void safeRefresh(IProject project, IProgressMonitor monitor) {
"""
Refresh the project file hierarchy.
@param project the project.
@param monitor the progress monitor.
"""
try {
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (CoreException exception) {
SARLEclipsePlugin.getDefault().log(exception);
}
} | java | @SuppressWarnings("static-method")
protected void safeRefresh(IProject project, IProgressMonitor monitor) {
try {
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (CoreException exception) {
SARLEclipsePlugin.getDefault().log(exception);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"void",
"safeRefresh",
"(",
"IProject",
"project",
",",
"IProgressMonitor",
"monitor",
")",
"{",
"try",
"{",
"project",
".",
"refreshLocal",
"(",
"IResource",
".",
"DEPTH_INFINITE",
",",
"monitor",
")",
";",
"}",
"catch",
"(",
"CoreException",
"exception",
")",
"{",
"SARLEclipsePlugin",
".",
"getDefault",
"(",
")",
".",
"log",
"(",
"exception",
")",
";",
"}",
"}"
]
| Refresh the project file hierarchy.
@param project the project.
@param monitor the progress monitor. | [
"Refresh",
"the",
"project",
"file",
"hierarchy",
"."
]
| train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/natures/SARLProjectConfigurator.java#L197-L204 |
wildfly/wildfly-core | launcher/src/main/java/org/wildfly/core/launcher/CliCommandBuilder.java | CliCommandBuilder.setController | public CliCommandBuilder setController(final String protocol, final String hostname, final int port) {
"""
Sets the protocol, hostname and port to connect to.
@param protocol the protocol to use
@param hostname the host name
@param port the port
@return the builder
"""
setController(formatAddress(protocol, hostname, port));
return this;
} | java | public CliCommandBuilder setController(final String protocol, final String hostname, final int port) {
setController(formatAddress(protocol, hostname, port));
return this;
} | [
"public",
"CliCommandBuilder",
"setController",
"(",
"final",
"String",
"protocol",
",",
"final",
"String",
"hostname",
",",
"final",
"int",
"port",
")",
"{",
"setController",
"(",
"formatAddress",
"(",
"protocol",
",",
"hostname",
",",
"port",
")",
")",
";",
"return",
"this",
";",
"}"
]
| Sets the protocol, hostname and port to connect to.
@param protocol the protocol to use
@param hostname the host name
@param port the port
@return the builder | [
"Sets",
"the",
"protocol",
"hostname",
"and",
"port",
"to",
"connect",
"to",
"."
]
| train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/launcher/src/main/java/org/wildfly/core/launcher/CliCommandBuilder.java#L213-L216 |
actframework/actframework | src/main/java/act/event/EventBus.java | EventBus.bindAsync | public EventBus bindAsync(Class<? extends EventObject> eventType, ActEventListener eventListener) {
"""
Bind a {@link ActEventListener eventListener} to an event type extended
from {@link EventObject} asynchronously.
@param eventType
the target event type - should be a sub class of {@link EventObject}
@param eventListener
the listener - an instance of {@link ActEventListener} or it's sub class
@return this event bus instance
@see #bind(Class, ActEventListener)
"""
return _bind(asyncActEventListeners, eventType, eventListener, 0);
} | java | public EventBus bindAsync(Class<? extends EventObject> eventType, ActEventListener eventListener) {
return _bind(asyncActEventListeners, eventType, eventListener, 0);
} | [
"public",
"EventBus",
"bindAsync",
"(",
"Class",
"<",
"?",
"extends",
"EventObject",
">",
"eventType",
",",
"ActEventListener",
"eventListener",
")",
"{",
"return",
"_bind",
"(",
"asyncActEventListeners",
",",
"eventType",
",",
"eventListener",
",",
"0",
")",
";",
"}"
]
| Bind a {@link ActEventListener eventListener} to an event type extended
from {@link EventObject} asynchronously.
@param eventType
the target event type - should be a sub class of {@link EventObject}
@param eventListener
the listener - an instance of {@link ActEventListener} or it's sub class
@return this event bus instance
@see #bind(Class, ActEventListener) | [
"Bind",
"a",
"{",
"@link",
"ActEventListener",
"eventListener",
"}",
"to",
"an",
"event",
"type",
"extended",
"from",
"{",
"@link",
"EventObject",
"}",
"asynchronously",
"."
]
| train | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/event/EventBus.java#L711-L713 |
kejunxia/AndroidMvc | library/android-mvc/src/main/java/com/shipdream/lib/android/mvc/MvcFragment.java | MvcFragment.onCreateView | @Override
final public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
"""
This Android lifecycle callback is sealed. {@link MvcFragment} will always use the
layout returned by {@link #getLayoutResId()} to inflate the view. Instead, do actions to
prepare views in {@link #onViewReady(View, Bundle, Reason)} where all injected dependencies
and all restored state will be ready to use.
@param inflater The inflater
@param container The container
@param savedInstanceState The savedInstanceState
@return The view for the fragment
"""
injectDependencies();
return inflater.inflate(getLayoutResId(), container, false);
} | java | @Override
final public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
injectDependencies();
return inflater.inflate(getLayoutResId(), container, false);
} | [
"@",
"Override",
"final",
"public",
"View",
"onCreateView",
"(",
"LayoutInflater",
"inflater",
",",
"ViewGroup",
"container",
",",
"Bundle",
"savedInstanceState",
")",
"{",
"injectDependencies",
"(",
")",
";",
"return",
"inflater",
".",
"inflate",
"(",
"getLayoutResId",
"(",
")",
",",
"container",
",",
"false",
")",
";",
"}"
]
| This Android lifecycle callback is sealed. {@link MvcFragment} will always use the
layout returned by {@link #getLayoutResId()} to inflate the view. Instead, do actions to
prepare views in {@link #onViewReady(View, Bundle, Reason)} where all injected dependencies
and all restored state will be ready to use.
@param inflater The inflater
@param container The container
@param savedInstanceState The savedInstanceState
@return The view for the fragment | [
"This",
"Android",
"lifecycle",
"callback",
"is",
"sealed",
".",
"{",
"@link",
"MvcFragment",
"}",
"will",
"always",
"use",
"the",
"layout",
"returned",
"by",
"{",
"@link",
"#getLayoutResId",
"()",
"}",
"to",
"inflate",
"the",
"view",
".",
"Instead",
"do",
"actions",
"to",
"prepare",
"views",
"in",
"{",
"@link",
"#onViewReady",
"(",
"View",
"Bundle",
"Reason",
")",
"}",
"where",
"all",
"injected",
"dependencies",
"and",
"all",
"restored",
"state",
"will",
"be",
"ready",
"to",
"use",
"."
]
| train | https://github.com/kejunxia/AndroidMvc/blob/c7893f0a13119d64297b9eb2988f7323b7da5bbc/library/android-mvc/src/main/java/com/shipdream/lib/android/mvc/MvcFragment.java#L195-L199 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-extension/xwiki-commons-extension-api/src/main/java/org/xwiki/extension/job/internal/AbstractInstallPlanJob.java | AbstractInstallPlanJob.installExtension | protected void installExtension(ExtensionId extensionId, boolean dependency, String namespace,
DefaultExtensionPlanTree parentBranch) throws InstallException {
"""
Install provided extension.
@param extensionId the identifier of the extension to install
@param dependency indicate if the extension is installed as a dependency
@param namespace the namespace where to install the extension
@param parentBranch the children of the parent {@link DefaultExtensionPlanNode}
@throws InstallException error when trying to install provided extension
"""
if (getRequest().isVerbose()) {
if (namespace != null) {
this.logger.info(LOG_RESOLVE_NAMESPACE, "Resolving extension [{}] on namespace [{}]", extensionId,
namespace);
} else {
this.logger.info(LOG_RESOLVE, "Resolving extension [{}] on all namespaces", extensionId);
}
}
// Check if the feature is already in the install plan
if (checkExistingPlanNodeExtension(extensionId, true, namespace)) {
return;
}
// Check if the feature is a core extension
checkCoreExtension(extensionId.getId());
ModifableExtensionPlanNode node = installExtension(extensionId, dependency, namespace);
addExtensionNode(node);
parentBranch.add(node);
} | java | protected void installExtension(ExtensionId extensionId, boolean dependency, String namespace,
DefaultExtensionPlanTree parentBranch) throws InstallException
{
if (getRequest().isVerbose()) {
if (namespace != null) {
this.logger.info(LOG_RESOLVE_NAMESPACE, "Resolving extension [{}] on namespace [{}]", extensionId,
namespace);
} else {
this.logger.info(LOG_RESOLVE, "Resolving extension [{}] on all namespaces", extensionId);
}
}
// Check if the feature is already in the install plan
if (checkExistingPlanNodeExtension(extensionId, true, namespace)) {
return;
}
// Check if the feature is a core extension
checkCoreExtension(extensionId.getId());
ModifableExtensionPlanNode node = installExtension(extensionId, dependency, namespace);
addExtensionNode(node);
parentBranch.add(node);
} | [
"protected",
"void",
"installExtension",
"(",
"ExtensionId",
"extensionId",
",",
"boolean",
"dependency",
",",
"String",
"namespace",
",",
"DefaultExtensionPlanTree",
"parentBranch",
")",
"throws",
"InstallException",
"{",
"if",
"(",
"getRequest",
"(",
")",
".",
"isVerbose",
"(",
")",
")",
"{",
"if",
"(",
"namespace",
"!=",
"null",
")",
"{",
"this",
".",
"logger",
".",
"info",
"(",
"LOG_RESOLVE_NAMESPACE",
",",
"\"Resolving extension [{}] on namespace [{}]\"",
",",
"extensionId",
",",
"namespace",
")",
";",
"}",
"else",
"{",
"this",
".",
"logger",
".",
"info",
"(",
"LOG_RESOLVE",
",",
"\"Resolving extension [{}] on all namespaces\"",
",",
"extensionId",
")",
";",
"}",
"}",
"// Check if the feature is already in the install plan",
"if",
"(",
"checkExistingPlanNodeExtension",
"(",
"extensionId",
",",
"true",
",",
"namespace",
")",
")",
"{",
"return",
";",
"}",
"// Check if the feature is a core extension",
"checkCoreExtension",
"(",
"extensionId",
".",
"getId",
"(",
")",
")",
";",
"ModifableExtensionPlanNode",
"node",
"=",
"installExtension",
"(",
"extensionId",
",",
"dependency",
",",
"namespace",
")",
";",
"addExtensionNode",
"(",
"node",
")",
";",
"parentBranch",
".",
"add",
"(",
"node",
")",
";",
"}"
]
| Install provided extension.
@param extensionId the identifier of the extension to install
@param dependency indicate if the extension is installed as a dependency
@param namespace the namespace where to install the extension
@param parentBranch the children of the parent {@link DefaultExtensionPlanNode}
@throws InstallException error when trying to install provided extension | [
"Install",
"provided",
"extension",
"."
]
| train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-extension/xwiki-commons-extension-api/src/main/java/org/xwiki/extension/job/internal/AbstractInstallPlanJob.java#L297-L321 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.