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
|
---|---|---|---|---|---|---|---|---|---|---|
Cornutum/tcases
|
tcases-lib/src/main/java/org/cornutum/tcases/conditions/Conditions.java
|
Conditions.betweenExclusiveMax
|
public static Between betweenExclusiveMax( String property, int minimum, int maximum) {
"""
Returns a {@link ICondition condition} that is satisfied by a {@link org.cornutum.tcases.PropertySet} that contains
between a specified minimum (inclusive) and maximum (exclusive) number of instances of a property.
"""
return new Between( notLessThan( property, minimum), lessThan( property, maximum));
}
|
java
|
public static Between betweenExclusiveMax( String property, int minimum, int maximum)
{
return new Between( notLessThan( property, minimum), lessThan( property, maximum));
}
|
[
"public",
"static",
"Between",
"betweenExclusiveMax",
"(",
"String",
"property",
",",
"int",
"minimum",
",",
"int",
"maximum",
")",
"{",
"return",
"new",
"Between",
"(",
"notLessThan",
"(",
"property",
",",
"minimum",
")",
",",
"lessThan",
"(",
"property",
",",
"maximum",
")",
")",
";",
"}"
] |
Returns a {@link ICondition condition} that is satisfied by a {@link org.cornutum.tcases.PropertySet} that contains
between a specified minimum (inclusive) and maximum (exclusive) number of instances of a property.
|
[
"Returns",
"a",
"{"
] |
train
|
https://github.com/Cornutum/tcases/blob/21e15cf107fa149620c40f4bda1829c1224fcfb1/tcases-lib/src/main/java/org/cornutum/tcases/conditions/Conditions.java#L163-L166
|
spring-projects/spring-security-oauth
|
spring-security-oauth/src/main/java/org/springframework/security/oauth/consumer/filter/OAuthConsumerContextFilter.java
|
OAuthConsumerContextFilter.getUserAuthorizationRedirectURL
|
protected String getUserAuthorizationRedirectURL(ProtectedResourceDetails details, OAuthConsumerToken requestToken, String callbackURL) {
"""
Get the URL to which to redirect the user for authorization of protected resources.
@param details The resource for which to get the authorization url.
@param requestToken The request token.
@param callbackURL The callback URL.
@return The URL.
"""
try {
String baseURL = details.getUserAuthorizationURL();
StringBuilder builder = new StringBuilder(baseURL);
char appendChar = baseURL.indexOf('?') < 0 ? '?' : '&';
builder.append(appendChar).append("oauth_token=");
builder.append(URLEncoder.encode(requestToken.getValue(), "UTF-8"));
if (!details.isUse10a()) {
builder.append('&').append("oauth_callback=");
builder.append(URLEncoder.encode(callbackURL, "UTF-8"));
}
return builder.toString();
}
catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
|
java
|
protected String getUserAuthorizationRedirectURL(ProtectedResourceDetails details, OAuthConsumerToken requestToken, String callbackURL) {
try {
String baseURL = details.getUserAuthorizationURL();
StringBuilder builder = new StringBuilder(baseURL);
char appendChar = baseURL.indexOf('?') < 0 ? '?' : '&';
builder.append(appendChar).append("oauth_token=");
builder.append(URLEncoder.encode(requestToken.getValue(), "UTF-8"));
if (!details.isUse10a()) {
builder.append('&').append("oauth_callback=");
builder.append(URLEncoder.encode(callbackURL, "UTF-8"));
}
return builder.toString();
}
catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
|
[
"protected",
"String",
"getUserAuthorizationRedirectURL",
"(",
"ProtectedResourceDetails",
"details",
",",
"OAuthConsumerToken",
"requestToken",
",",
"String",
"callbackURL",
")",
"{",
"try",
"{",
"String",
"baseURL",
"=",
"details",
".",
"getUserAuthorizationURL",
"(",
")",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"baseURL",
")",
";",
"char",
"appendChar",
"=",
"baseURL",
".",
"indexOf",
"(",
"'",
"'",
")",
"<",
"0",
"?",
"'",
"'",
":",
"'",
"'",
";",
"builder",
".",
"append",
"(",
"appendChar",
")",
".",
"append",
"(",
"\"oauth_token=\"",
")",
";",
"builder",
".",
"append",
"(",
"URLEncoder",
".",
"encode",
"(",
"requestToken",
".",
"getValue",
"(",
")",
",",
"\"UTF-8\"",
")",
")",
";",
"if",
"(",
"!",
"details",
".",
"isUse10a",
"(",
")",
")",
"{",
"builder",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"\"oauth_callback=\"",
")",
";",
"builder",
".",
"append",
"(",
"URLEncoder",
".",
"encode",
"(",
"callbackURL",
",",
"\"UTF-8\"",
")",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}"
] |
Get the URL to which to redirect the user for authorization of protected resources.
@param details The resource for which to get the authorization url.
@param requestToken The request token.
@param callbackURL The callback URL.
@return The URL.
|
[
"Get",
"the",
"URL",
"to",
"which",
"to",
"redirect",
"the",
"user",
"for",
"authorization",
"of",
"protected",
"resources",
"."
] |
train
|
https://github.com/spring-projects/spring-security-oauth/blob/bbae0027eceb2c74a21ac26bbc86142dc732ffbe/spring-security-oauth/src/main/java/org/springframework/security/oauth/consumer/filter/OAuthConsumerContextFilter.java#L302-L318
|
stratosphere/stratosphere
|
stratosphere-runtime/src/main/java/eu/stratosphere/nephele/jobgraph/AbstractJobVertex.java
|
AbstractJobVertex.connectTo
|
public void connectTo(final AbstractJobVertex vertex, final int indexOfOutputGate, final int indexOfInputGate)
throws JobGraphDefinitionException {
"""
Connects the job vertex to the specified job vertex.
@param vertex
the vertex this vertex should connect to
@param indexOfOutputGate
index of the producing task's output gate to be used, <code>-1</code> will determine the next free index
number
@param indexOfInputGate
index of the consuming task's input gate to be used, <code>-1</code> will determine the next free index
number
@throws JobGraphDefinitionException
thrown if the given vertex cannot be connected to <code>vertex</code> in the requested manner
"""
this.connectTo(vertex, null, indexOfOutputGate, indexOfInputGate, DistributionPattern.BIPARTITE);
}
|
java
|
public void connectTo(final AbstractJobVertex vertex, final int indexOfOutputGate, final int indexOfInputGate)
throws JobGraphDefinitionException {
this.connectTo(vertex, null, indexOfOutputGate, indexOfInputGate, DistributionPattern.BIPARTITE);
}
|
[
"public",
"void",
"connectTo",
"(",
"final",
"AbstractJobVertex",
"vertex",
",",
"final",
"int",
"indexOfOutputGate",
",",
"final",
"int",
"indexOfInputGate",
")",
"throws",
"JobGraphDefinitionException",
"{",
"this",
".",
"connectTo",
"(",
"vertex",
",",
"null",
",",
"indexOfOutputGate",
",",
"indexOfInputGate",
",",
"DistributionPattern",
".",
"BIPARTITE",
")",
";",
"}"
] |
Connects the job vertex to the specified job vertex.
@param vertex
the vertex this vertex should connect to
@param indexOfOutputGate
index of the producing task's output gate to be used, <code>-1</code> will determine the next free index
number
@param indexOfInputGate
index of the consuming task's input gate to be used, <code>-1</code> will determine the next free index
number
@throws JobGraphDefinitionException
thrown if the given vertex cannot be connected to <code>vertex</code> in the requested manner
|
[
"Connects",
"the",
"job",
"vertex",
"to",
"the",
"specified",
"job",
"vertex",
"."
] |
train
|
https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-runtime/src/main/java/eu/stratosphere/nephele/jobgraph/AbstractJobVertex.java#L141-L144
|
kiswanij/jk-util
|
src/main/java/com/jk/util/JKDateTimeUtil.java
|
JKDateTimeUtil.isDate
|
public static boolean isDate(String strDate, String pattern) {
"""
Checks if is date.
@param strDate the str date
@param pattern the pattern
@return true, if is date
"""
try {
parseDate(strDate, pattern);
return true;
} catch (Exception e) {
return false;
}
}
|
java
|
public static boolean isDate(String strDate, String pattern) {
try {
parseDate(strDate, pattern);
return true;
} catch (Exception e) {
return false;
}
}
|
[
"public",
"static",
"boolean",
"isDate",
"(",
"String",
"strDate",
",",
"String",
"pattern",
")",
"{",
"try",
"{",
"parseDate",
"(",
"strDate",
",",
"pattern",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Checks if is date.
@param strDate the str date
@param pattern the pattern
@return true, if is date
|
[
"Checks",
"if",
"is",
"date",
"."
] |
train
|
https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/JKDateTimeUtil.java#L236-L243
|
icode/ameba
|
src/main/java/ameba/core/Requests.java
|
Requests.setRequestUri
|
public static void setRequestUri(URI baseUri, URI requestUri) throws IllegalStateException {
"""
<p>setRequestUri.</p>
@param baseUri a {@link java.net.URI} object.
@param requestUri a {@link java.net.URI} object.
@throws java.lang.IllegalStateException if any.
"""
getRequest().setRequestUri(baseUri, requestUri);
}
|
java
|
public static void setRequestUri(URI baseUri, URI requestUri) throws IllegalStateException {
getRequest().setRequestUri(baseUri, requestUri);
}
|
[
"public",
"static",
"void",
"setRequestUri",
"(",
"URI",
"baseUri",
",",
"URI",
"requestUri",
")",
"throws",
"IllegalStateException",
"{",
"getRequest",
"(",
")",
".",
"setRequestUri",
"(",
"baseUri",
",",
"requestUri",
")",
";",
"}"
] |
<p>setRequestUri.</p>
@param baseUri a {@link java.net.URI} object.
@param requestUri a {@link java.net.URI} object.
@throws java.lang.IllegalStateException if any.
|
[
"<p",
">",
"setRequestUri",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/core/Requests.java#L798-L800
|
twilio/twilio-java
|
src/main/java/com/twilio/jwt/validation/ValidationToken.java
|
ValidationToken.fromHttpRequest
|
public static ValidationToken fromHttpRequest(
String accountSid,
String credentialSid,
String signingKeySid,
PrivateKey privateKey,
HttpRequest request,
List<String> signedHeaders
) throws IOException {
"""
Create a ValidationToken from an HTTP Request.
@param accountSid Twilio Account SID
@param credentialSid Twilio Credential SID
@param signingKeySid Twilio Signing Key SID
@param privateKey Private Key
@param request HTTP Request
@param signedHeaders Headers to sign
@throws IOException when unable to generate
@return The ValidationToken generated from the HttpRequest
"""
Builder builder = new Builder(accountSid, credentialSid, signingKeySid, privateKey);
String method = request.getRequestLine().getMethod();
builder.method(method);
String uri = request.getRequestLine().getUri();
if (uri.contains("?")) {
String[] uriParts = uri.split("\\?");
builder.uri(uriParts[0]);
builder.queryString(uriParts[1]);
} else {
builder.uri(uri);
}
builder.headers(request.getAllHeaders());
builder.signedHeaders(signedHeaders);
/**
* If the request encloses an "entity", use it for the body. Note that this is dependent on several factors
* during request building and is not solely based on the specified method.
*
* @see org.apache.http.client.methods.RequestBuilder#build
*/
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
builder.requestBody(CharStreams.toString(new InputStreamReader(entity.getContent(), Charsets.UTF_8)));
}
return builder.build();
}
|
java
|
public static ValidationToken fromHttpRequest(
String accountSid,
String credentialSid,
String signingKeySid,
PrivateKey privateKey,
HttpRequest request,
List<String> signedHeaders
) throws IOException {
Builder builder = new Builder(accountSid, credentialSid, signingKeySid, privateKey);
String method = request.getRequestLine().getMethod();
builder.method(method);
String uri = request.getRequestLine().getUri();
if (uri.contains("?")) {
String[] uriParts = uri.split("\\?");
builder.uri(uriParts[0]);
builder.queryString(uriParts[1]);
} else {
builder.uri(uri);
}
builder.headers(request.getAllHeaders());
builder.signedHeaders(signedHeaders);
/**
* If the request encloses an "entity", use it for the body. Note that this is dependent on several factors
* during request building and is not solely based on the specified method.
*
* @see org.apache.http.client.methods.RequestBuilder#build
*/
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
builder.requestBody(CharStreams.toString(new InputStreamReader(entity.getContent(), Charsets.UTF_8)));
}
return builder.build();
}
|
[
"public",
"static",
"ValidationToken",
"fromHttpRequest",
"(",
"String",
"accountSid",
",",
"String",
"credentialSid",
",",
"String",
"signingKeySid",
",",
"PrivateKey",
"privateKey",
",",
"HttpRequest",
"request",
",",
"List",
"<",
"String",
">",
"signedHeaders",
")",
"throws",
"IOException",
"{",
"Builder",
"builder",
"=",
"new",
"Builder",
"(",
"accountSid",
",",
"credentialSid",
",",
"signingKeySid",
",",
"privateKey",
")",
";",
"String",
"method",
"=",
"request",
".",
"getRequestLine",
"(",
")",
".",
"getMethod",
"(",
")",
";",
"builder",
".",
"method",
"(",
"method",
")",
";",
"String",
"uri",
"=",
"request",
".",
"getRequestLine",
"(",
")",
".",
"getUri",
"(",
")",
";",
"if",
"(",
"uri",
".",
"contains",
"(",
"\"?\"",
")",
")",
"{",
"String",
"[",
"]",
"uriParts",
"=",
"uri",
".",
"split",
"(",
"\"\\\\?\"",
")",
";",
"builder",
".",
"uri",
"(",
"uriParts",
"[",
"0",
"]",
")",
";",
"builder",
".",
"queryString",
"(",
"uriParts",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"builder",
".",
"uri",
"(",
"uri",
")",
";",
"}",
"builder",
".",
"headers",
"(",
"request",
".",
"getAllHeaders",
"(",
")",
")",
";",
"builder",
".",
"signedHeaders",
"(",
"signedHeaders",
")",
";",
"/**\n * If the request encloses an \"entity\", use it for the body. Note that this is dependent on several factors\n * during request building and is not solely based on the specified method.\n *\n * @see org.apache.http.client.methods.RequestBuilder#build\n */",
"if",
"(",
"request",
"instanceof",
"HttpEntityEnclosingRequest",
")",
"{",
"HttpEntity",
"entity",
"=",
"(",
"(",
"HttpEntityEnclosingRequest",
")",
"request",
")",
".",
"getEntity",
"(",
")",
";",
"builder",
".",
"requestBody",
"(",
"CharStreams",
".",
"toString",
"(",
"new",
"InputStreamReader",
"(",
"entity",
".",
"getContent",
"(",
")",
",",
"Charsets",
".",
"UTF_8",
")",
")",
")",
";",
"}",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] |
Create a ValidationToken from an HTTP Request.
@param accountSid Twilio Account SID
@param credentialSid Twilio Credential SID
@param signingKeySid Twilio Signing Key SID
@param privateKey Private Key
@param request HTTP Request
@param signedHeaders Headers to sign
@throws IOException when unable to generate
@return The ValidationToken generated from the HttpRequest
|
[
"Create",
"a",
"ValidationToken",
"from",
"an",
"HTTP",
"Request",
"."
] |
train
|
https://github.com/twilio/twilio-java/blob/0318974c0a6a152994af167d430255684d5e9b9f/src/main/java/com/twilio/jwt/validation/ValidationToken.java#L102-L139
|
eclipse/xtext-extras
|
org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/imports/NonOverridableTypesProvider.java
|
NonOverridableTypesProvider.getVisibleType
|
public JvmIdentifiableElement getVisibleType(JvmMember context, String name) {
"""
Returns a type with the given name that is reachable in the context.
If the context is <code>null</code>, it is assumed that no type is visible.
@return the visible type or <code>null</code>
"""
if (context == null)
return null;
Map<String, JvmIdentifiableElement> map = visibleElements.get(context);
if (map == null) {
map = create(context);
}
return map.get(name);
}
|
java
|
public JvmIdentifiableElement getVisibleType(JvmMember context, String name) {
if (context == null)
return null;
Map<String, JvmIdentifiableElement> map = visibleElements.get(context);
if (map == null) {
map = create(context);
}
return map.get(name);
}
|
[
"public",
"JvmIdentifiableElement",
"getVisibleType",
"(",
"JvmMember",
"context",
",",
"String",
"name",
")",
"{",
"if",
"(",
"context",
"==",
"null",
")",
"return",
"null",
";",
"Map",
"<",
"String",
",",
"JvmIdentifiableElement",
">",
"map",
"=",
"visibleElements",
".",
"get",
"(",
"context",
")",
";",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"map",
"=",
"create",
"(",
"context",
")",
";",
"}",
"return",
"map",
".",
"get",
"(",
"name",
")",
";",
"}"
] |
Returns a type with the given name that is reachable in the context.
If the context is <code>null</code>, it is assumed that no type is visible.
@return the visible type or <code>null</code>
|
[
"Returns",
"a",
"type",
"with",
"the",
"given",
"name",
"that",
"is",
"reachable",
"in",
"the",
"context",
".",
"If",
"the",
"context",
"is",
"<code",
">",
"null<",
"/",
"code",
">",
"it",
"is",
"assumed",
"that",
"no",
"type",
"is",
"visible",
"."
] |
train
|
https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/imports/NonOverridableTypesProvider.java#L48-L56
|
Red5/red5-server-common
|
src/main/java/org/red5/server/net/rtmp/RTMPHandshake.java
|
RTMPHandshake.calculateSwfVerification
|
public void calculateSwfVerification(byte[] handshakeMessage, byte[] swfHash, int swfSize) {
"""
Calculates the swf verification token.
@param handshakeMessage servers handshake bytes
@param swfHash hash of swf
@param swfSize size of swf
"""
// SHA256 HMAC hash of decompressed SWF, key are the last 32 bytes of the server handshake
byte[] swfHashKey = new byte[DIGEST_LENGTH];
System.arraycopy(handshakeMessage, Constants.HANDSHAKE_SIZE - DIGEST_LENGTH, swfHashKey, 0, DIGEST_LENGTH);
byte[] bytesFromServerHash = new byte[DIGEST_LENGTH];
calculateHMAC_SHA256(swfHash, 0, swfHash.length, swfHashKey, DIGEST_LENGTH, bytesFromServerHash, 0);
// construct SWF verification pong payload
ByteBuffer swfv = ByteBuffer.allocate(42);
swfv.put((byte) 0x01);
swfv.put((byte) 0x01);
swfv.putInt(swfSize);
swfv.putInt(swfSize);
swfv.put(bytesFromServerHash);
swfv.flip();
swfVerificationBytes = new byte[42];
swfv.get(swfVerificationBytes);
log.debug("initialized swf verification response from swfSize: {} swfHash:\n{}\n{}", swfSize, Hex.encodeHexString(swfHash), Hex.encodeHexString(swfVerificationBytes));
}
|
java
|
public void calculateSwfVerification(byte[] handshakeMessage, byte[] swfHash, int swfSize) {
// SHA256 HMAC hash of decompressed SWF, key are the last 32 bytes of the server handshake
byte[] swfHashKey = new byte[DIGEST_LENGTH];
System.arraycopy(handshakeMessage, Constants.HANDSHAKE_SIZE - DIGEST_LENGTH, swfHashKey, 0, DIGEST_LENGTH);
byte[] bytesFromServerHash = new byte[DIGEST_LENGTH];
calculateHMAC_SHA256(swfHash, 0, swfHash.length, swfHashKey, DIGEST_LENGTH, bytesFromServerHash, 0);
// construct SWF verification pong payload
ByteBuffer swfv = ByteBuffer.allocate(42);
swfv.put((byte) 0x01);
swfv.put((byte) 0x01);
swfv.putInt(swfSize);
swfv.putInt(swfSize);
swfv.put(bytesFromServerHash);
swfv.flip();
swfVerificationBytes = new byte[42];
swfv.get(swfVerificationBytes);
log.debug("initialized swf verification response from swfSize: {} swfHash:\n{}\n{}", swfSize, Hex.encodeHexString(swfHash), Hex.encodeHexString(swfVerificationBytes));
}
|
[
"public",
"void",
"calculateSwfVerification",
"(",
"byte",
"[",
"]",
"handshakeMessage",
",",
"byte",
"[",
"]",
"swfHash",
",",
"int",
"swfSize",
")",
"{",
"// SHA256 HMAC hash of decompressed SWF, key are the last 32 bytes of the server handshake\r",
"byte",
"[",
"]",
"swfHashKey",
"=",
"new",
"byte",
"[",
"DIGEST_LENGTH",
"]",
";",
"System",
".",
"arraycopy",
"(",
"handshakeMessage",
",",
"Constants",
".",
"HANDSHAKE_SIZE",
"-",
"DIGEST_LENGTH",
",",
"swfHashKey",
",",
"0",
",",
"DIGEST_LENGTH",
")",
";",
"byte",
"[",
"]",
"bytesFromServerHash",
"=",
"new",
"byte",
"[",
"DIGEST_LENGTH",
"]",
";",
"calculateHMAC_SHA256",
"(",
"swfHash",
",",
"0",
",",
"swfHash",
".",
"length",
",",
"swfHashKey",
",",
"DIGEST_LENGTH",
",",
"bytesFromServerHash",
",",
"0",
")",
";",
"// construct SWF verification pong payload\r",
"ByteBuffer",
"swfv",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"42",
")",
";",
"swfv",
".",
"put",
"(",
"(",
"byte",
")",
"0x01",
")",
";",
"swfv",
".",
"put",
"(",
"(",
"byte",
")",
"0x01",
")",
";",
"swfv",
".",
"putInt",
"(",
"swfSize",
")",
";",
"swfv",
".",
"putInt",
"(",
"swfSize",
")",
";",
"swfv",
".",
"put",
"(",
"bytesFromServerHash",
")",
";",
"swfv",
".",
"flip",
"(",
")",
";",
"swfVerificationBytes",
"=",
"new",
"byte",
"[",
"42",
"]",
";",
"swfv",
".",
"get",
"(",
"swfVerificationBytes",
")",
";",
"log",
".",
"debug",
"(",
"\"initialized swf verification response from swfSize: {} swfHash:\\n{}\\n{}\"",
",",
"swfSize",
",",
"Hex",
".",
"encodeHexString",
"(",
"swfHash",
")",
",",
"Hex",
".",
"encodeHexString",
"(",
"swfVerificationBytes",
")",
")",
";",
"}"
] |
Calculates the swf verification token.
@param handshakeMessage servers handshake bytes
@param swfHash hash of swf
@param swfSize size of swf
|
[
"Calculates",
"the",
"swf",
"verification",
"token",
"."
] |
train
|
https://github.com/Red5/red5-server-common/blob/39ae73710c25bda86d70b13ef37ae707962217b9/src/main/java/org/red5/server/net/rtmp/RTMPHandshake.java#L400-L417
|
datasift/datasift-java
|
src/main/java/com/datasift/client/DataSiftConfig.java
|
DataSiftConfig.baseURL
|
public URI baseURL() {
"""
/*
@return A base URL to the DataSift API. e.g. https://api.datasift.com/v1/
"""
StringBuilder b = new StringBuilder()
.append(protocol())
.append(host())
.append(":")
.append(port())
.append("/")
.append(versionPrefix())
.append("/");
try {
return new URI(b.toString());
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Unable to construct a base URL for the API", e);
}
}
|
java
|
public URI baseURL() {
StringBuilder b = new StringBuilder()
.append(protocol())
.append(host())
.append(":")
.append(port())
.append("/")
.append(versionPrefix())
.append("/");
try {
return new URI(b.toString());
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Unable to construct a base URL for the API", e);
}
}
|
[
"public",
"URI",
"baseURL",
"(",
")",
"{",
"StringBuilder",
"b",
"=",
"new",
"StringBuilder",
"(",
")",
".",
"append",
"(",
"protocol",
"(",
")",
")",
".",
"append",
"(",
"host",
"(",
")",
")",
".",
"append",
"(",
"\":\"",
")",
".",
"append",
"(",
"port",
"(",
")",
")",
".",
"append",
"(",
"\"/\"",
")",
".",
"append",
"(",
"versionPrefix",
"(",
")",
")",
".",
"append",
"(",
"\"/\"",
")",
";",
"try",
"{",
"return",
"new",
"URI",
"(",
"b",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unable to construct a base URL for the API\"",
",",
"e",
")",
";",
"}",
"}"
] |
/*
@return A base URL to the DataSift API. e.g. https://api.datasift.com/v1/
|
[
"/",
"*"
] |
train
|
https://github.com/datasift/datasift-java/blob/09de124f2a1a507ff6181e59875c6f325290850e/src/main/java/com/datasift/client/DataSiftConfig.java#L166-L180
|
Azure/azure-sdk-for-java
|
batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java
|
ComputeNodesImpl.listAsync
|
public Observable<Page<ComputeNode>> listAsync(final String poolId, final ComputeNodeListOptions computeNodeListOptions) {
"""
Lists the compute nodes in the specified pool.
@param poolId The ID of the pool from which you want to list nodes.
@param computeNodeListOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ComputeNode> object
"""
return listWithServiceResponseAsync(poolId, computeNodeListOptions)
.map(new Func1<ServiceResponseWithHeaders<Page<ComputeNode>, ComputeNodeListHeaders>, Page<ComputeNode>>() {
@Override
public Page<ComputeNode> call(ServiceResponseWithHeaders<Page<ComputeNode>, ComputeNodeListHeaders> response) {
return response.body();
}
});
}
|
java
|
public Observable<Page<ComputeNode>> listAsync(final String poolId, final ComputeNodeListOptions computeNodeListOptions) {
return listWithServiceResponseAsync(poolId, computeNodeListOptions)
.map(new Func1<ServiceResponseWithHeaders<Page<ComputeNode>, ComputeNodeListHeaders>, Page<ComputeNode>>() {
@Override
public Page<ComputeNode> call(ServiceResponseWithHeaders<Page<ComputeNode>, ComputeNodeListHeaders> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"Page",
"<",
"ComputeNode",
">",
">",
"listAsync",
"(",
"final",
"String",
"poolId",
",",
"final",
"ComputeNodeListOptions",
"computeNodeListOptions",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"poolId",
",",
"computeNodeListOptions",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"ComputeNode",
">",
",",
"ComputeNodeListHeaders",
">",
",",
"Page",
"<",
"ComputeNode",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"ComputeNode",
">",
"call",
"(",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"ComputeNode",
">",
",",
"ComputeNodeListHeaders",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Lists the compute nodes in the specified pool.
@param poolId The ID of the pool from which you want to list nodes.
@param computeNodeListOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ComputeNode> object
|
[
"Lists",
"the",
"compute",
"nodes",
"in",
"the",
"specified",
"pool",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java#L2779-L2787
|
overturetool/overture
|
core/ast/src/main/java/org/overture/ast/factory/AstFactory.java
|
AstFactory.initPattern
|
private static void initPattern(PPattern result, ILexLocation location) {
"""
/*
Init Methods - correspond to constructors of the abstract classes, e.g. Definition, Pattern, Type, etc.
"""
result.setLocation(location);
result.setResolved(false);
}
|
java
|
private static void initPattern(PPattern result, ILexLocation location)
{
result.setLocation(location);
result.setResolved(false);
}
|
[
"private",
"static",
"void",
"initPattern",
"(",
"PPattern",
"result",
",",
"ILexLocation",
"location",
")",
"{",
"result",
".",
"setLocation",
"(",
"location",
")",
";",
"result",
".",
"setResolved",
"(",
"false",
")",
";",
"}"
] |
/*
Init Methods - correspond to constructors of the abstract classes, e.g. Definition, Pattern, Type, etc.
|
[
"/",
"*",
"Init",
"Methods",
"-",
"correspond",
"to",
"constructors",
"of",
"the",
"abstract",
"classes",
"e",
".",
"g",
".",
"Definition",
"Pattern",
"Type",
"etc",
"."
] |
train
|
https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/ast/src/main/java/org/overture/ast/factory/AstFactory.java#L249-L254
|
js-lib-com/template.xhtml
|
src/main/java/js/template/xhtml/IfOperator.java
|
IfOperator.doExec
|
@Override
protected Object doExec(Element element, Object scope, String expression, Object... arguments) throws TemplateException {
"""
Execute IF operator. Evaluate given <code>expression</code> and return evaluation result. Returned value acts as branch
enabled flag.
@param element context element, unused,
@param scope scope object,
@param expression conditional expression,
@param arguments optional arguments, not used.
@return true if <code>element</code> and all its descendants should be included in processed document.
@throws TemplateException if content value is undefined.
"""
ConditionalExpression conditionalExpression = new ConditionalExpression(content, scope, expression);
return conditionalExpression.value();
}
|
java
|
@Override
protected Object doExec(Element element, Object scope, String expression, Object... arguments) throws TemplateException {
ConditionalExpression conditionalExpression = new ConditionalExpression(content, scope, expression);
return conditionalExpression.value();
}
|
[
"@",
"Override",
"protected",
"Object",
"doExec",
"(",
"Element",
"element",
",",
"Object",
"scope",
",",
"String",
"expression",
",",
"Object",
"...",
"arguments",
")",
"throws",
"TemplateException",
"{",
"ConditionalExpression",
"conditionalExpression",
"=",
"new",
"ConditionalExpression",
"(",
"content",
",",
"scope",
",",
"expression",
")",
";",
"return",
"conditionalExpression",
".",
"value",
"(",
")",
";",
"}"
] |
Execute IF operator. Evaluate given <code>expression</code> and return evaluation result. Returned value acts as branch
enabled flag.
@param element context element, unused,
@param scope scope object,
@param expression conditional expression,
@param arguments optional arguments, not used.
@return true if <code>element</code> and all its descendants should be included in processed document.
@throws TemplateException if content value is undefined.
|
[
"Execute",
"IF",
"operator",
".",
"Evaluate",
"given",
"<code",
">",
"expression<",
"/",
"code",
">",
"and",
"return",
"evaluation",
"result",
".",
"Returned",
"value",
"acts",
"as",
"branch",
"enabled",
"flag",
"."
] |
train
|
https://github.com/js-lib-com/template.xhtml/blob/d50cec08aca9ab9680baebe2a26a341c096564fb/src/main/java/js/template/xhtml/IfOperator.java#L69-L73
|
googleapis/google-cloud-java
|
google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/DiskId.java
|
DiskId.of
|
public static DiskId of(ZoneId zoneId, String disk) {
"""
Returns a disk identity given the zone identity and the disk name. The disk name must be 1-63
characters long and comply with RFC1035. Specifically, the name must match the regular
expression {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a
lowercase letter, and all following characters must be a dash, lowercase letter, or digit,
except the last character, which cannot be a dash.
@see <a href="https://www.ietf.org/rfc/rfc1035.txt">RFC1035</a>
"""
return new DiskId(zoneId.getProject(), zoneId.getZone(), disk);
}
|
java
|
public static DiskId of(ZoneId zoneId, String disk) {
return new DiskId(zoneId.getProject(), zoneId.getZone(), disk);
}
|
[
"public",
"static",
"DiskId",
"of",
"(",
"ZoneId",
"zoneId",
",",
"String",
"disk",
")",
"{",
"return",
"new",
"DiskId",
"(",
"zoneId",
".",
"getProject",
"(",
")",
",",
"zoneId",
".",
"getZone",
"(",
")",
",",
"disk",
")",
";",
"}"
] |
Returns a disk identity given the zone identity and the disk name. The disk name must be 1-63
characters long and comply with RFC1035. Specifically, the name must match the regular
expression {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a
lowercase letter, and all following characters must be a dash, lowercase letter, or digit,
except the last character, which cannot be a dash.
@see <a href="https://www.ietf.org/rfc/rfc1035.txt">RFC1035</a>
|
[
"Returns",
"a",
"disk",
"identity",
"given",
"the",
"zone",
"identity",
"and",
"the",
"disk",
"name",
".",
"The",
"disk",
"name",
"must",
"be",
"1",
"-",
"63",
"characters",
"long",
"and",
"comply",
"with",
"RFC1035",
".",
"Specifically",
"the",
"name",
"must",
"match",
"the",
"regular",
"expression",
"{",
"@code",
"[",
"a",
"-",
"z",
"]",
"(",
"[",
"-",
"a",
"-",
"z0",
"-",
"9",
"]",
"*",
"[",
"a",
"-",
"z0",
"-",
"9",
"]",
")",
"?",
"}",
"which",
"means",
"the",
"first",
"character",
"must",
"be",
"a",
"lowercase",
"letter",
"and",
"all",
"following",
"characters",
"must",
"be",
"a",
"dash",
"lowercase",
"letter",
"or",
"digit",
"except",
"the",
"last",
"character",
"which",
"cannot",
"be",
"a",
"dash",
"."
] |
train
|
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/DiskId.java#L110-L112
|
spring-projects/spring-android
|
spring-android-rest-template/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java
|
HierarchicalUriComponents.encodeUriComponent
|
static String encodeUriComponent(String source, String encoding, Type type) throws UnsupportedEncodingException {
"""
Encodes the given source into an encoded String using the rules specified
by the given component and with the given options.
@param source the source string
@param encoding the encoding of the source string
@param type the URI component for the source
@return the encoded URI
@throws IllegalArgumentException when the given uri parameter is not a valid URI
"""
if (source == null) {
return null;
}
Assert.hasLength(encoding, "Encoding must not be empty");
byte[] bytes = encodeBytes(source.getBytes(encoding), type);
return new String(bytes, "US-ASCII");
}
|
java
|
static String encodeUriComponent(String source, String encoding, Type type) throws UnsupportedEncodingException {
if (source == null) {
return null;
}
Assert.hasLength(encoding, "Encoding must not be empty");
byte[] bytes = encodeBytes(source.getBytes(encoding), type);
return new String(bytes, "US-ASCII");
}
|
[
"static",
"String",
"encodeUriComponent",
"(",
"String",
"source",
",",
"String",
"encoding",
",",
"Type",
"type",
")",
"throws",
"UnsupportedEncodingException",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Assert",
".",
"hasLength",
"(",
"encoding",
",",
"\"Encoding must not be empty\"",
")",
";",
"byte",
"[",
"]",
"bytes",
"=",
"encodeBytes",
"(",
"source",
".",
"getBytes",
"(",
"encoding",
")",
",",
"type",
")",
";",
"return",
"new",
"String",
"(",
"bytes",
",",
"\"US-ASCII\"",
")",
";",
"}"
] |
Encodes the given source into an encoded String using the rules specified
by the given component and with the given options.
@param source the source string
@param encoding the encoding of the source string
@param type the URI component for the source
@return the encoded URI
@throws IllegalArgumentException when the given uri parameter is not a valid URI
|
[
"Encodes",
"the",
"given",
"source",
"into",
"an",
"encoded",
"String",
"using",
"the",
"rules",
"specified",
"by",
"the",
"given",
"component",
"and",
"with",
"the",
"given",
"options",
"."
] |
train
|
https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-rest-template/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java#L220-L227
|
jaredrummler/ColorPicker
|
library/src/main/java/com/jaredrummler/android/colorpicker/ColorPickerView.java
|
ColorPickerView.setColor
|
public void setColor(int color, boolean callback) {
"""
Set the color this view should show.
@param color The color that should be selected. #argb
@param callback If you want to get a callback to your OnColorChangedListener.
"""
int alpha = Color.alpha(color);
int red = Color.red(color);
int blue = Color.blue(color);
int green = Color.green(color);
float[] hsv = new float[3];
Color.RGBToHSV(red, green, blue, hsv);
this.alpha = alpha;
hue = hsv[0];
sat = hsv[1];
val = hsv[2];
if (callback && onColorChangedListener != null) {
onColorChangedListener.onColorChanged(Color.HSVToColor(this.alpha, new float[] { hue, sat, val }));
}
invalidate();
}
|
java
|
public void setColor(int color, boolean callback) {
int alpha = Color.alpha(color);
int red = Color.red(color);
int blue = Color.blue(color);
int green = Color.green(color);
float[] hsv = new float[3];
Color.RGBToHSV(red, green, blue, hsv);
this.alpha = alpha;
hue = hsv[0];
sat = hsv[1];
val = hsv[2];
if (callback && onColorChangedListener != null) {
onColorChangedListener.onColorChanged(Color.HSVToColor(this.alpha, new float[] { hue, sat, val }));
}
invalidate();
}
|
[
"public",
"void",
"setColor",
"(",
"int",
"color",
",",
"boolean",
"callback",
")",
"{",
"int",
"alpha",
"=",
"Color",
".",
"alpha",
"(",
"color",
")",
";",
"int",
"red",
"=",
"Color",
".",
"red",
"(",
"color",
")",
";",
"int",
"blue",
"=",
"Color",
".",
"blue",
"(",
"color",
")",
";",
"int",
"green",
"=",
"Color",
".",
"green",
"(",
"color",
")",
";",
"float",
"[",
"]",
"hsv",
"=",
"new",
"float",
"[",
"3",
"]",
";",
"Color",
".",
"RGBToHSV",
"(",
"red",
",",
"green",
",",
"blue",
",",
"hsv",
")",
";",
"this",
".",
"alpha",
"=",
"alpha",
";",
"hue",
"=",
"hsv",
"[",
"0",
"]",
";",
"sat",
"=",
"hsv",
"[",
"1",
"]",
";",
"val",
"=",
"hsv",
"[",
"2",
"]",
";",
"if",
"(",
"callback",
"&&",
"onColorChangedListener",
"!=",
"null",
")",
"{",
"onColorChangedListener",
".",
"onColorChanged",
"(",
"Color",
".",
"HSVToColor",
"(",
"this",
".",
"alpha",
",",
"new",
"float",
"[",
"]",
"{",
"hue",
",",
"sat",
",",
"val",
"}",
")",
")",
";",
"}",
"invalidate",
"(",
")",
";",
"}"
] |
Set the color this view should show.
@param color The color that should be selected. #argb
@param callback If you want to get a callback to your OnColorChangedListener.
|
[
"Set",
"the",
"color",
"this",
"view",
"should",
"show",
"."
] |
train
|
https://github.com/jaredrummler/ColorPicker/blob/ab06208ddcfbd7ab1b1fde140f10b3ca06d8175a/library/src/main/java/com/jaredrummler/android/colorpicker/ColorPickerView.java#L835-L856
|
interedition/collatex
|
collatex-core/src/main/java/eu/interedition/collatex/suffixarray/SuffixArrays.java
|
SuffixArrays.createWithLCP
|
public static <T> SuffixData createWithLCP(T[] input, ISuffixArrayBuilder builder, Comparator<? super T> comparator) {
"""
Create a suffix array and an LCP array for a given generic array and a
custom suffix array building strategy, using the given T object
comparator.
"""
final GenericArrayAdapter adapter = new GenericArrayAdapter(builder, comparator);
final int[] sa = adapter.buildSuffixArray(input);
final int[] lcp = computeLCP(adapter.input, 0, input.length, sa);
return new SuffixData(sa, lcp);
}
|
java
|
public static <T> SuffixData createWithLCP(T[] input, ISuffixArrayBuilder builder, Comparator<? super T> comparator) {
final GenericArrayAdapter adapter = new GenericArrayAdapter(builder, comparator);
final int[] sa = adapter.buildSuffixArray(input);
final int[] lcp = computeLCP(adapter.input, 0, input.length, sa);
return new SuffixData(sa, lcp);
}
|
[
"public",
"static",
"<",
"T",
">",
"SuffixData",
"createWithLCP",
"(",
"T",
"[",
"]",
"input",
",",
"ISuffixArrayBuilder",
"builder",
",",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comparator",
")",
"{",
"final",
"GenericArrayAdapter",
"adapter",
"=",
"new",
"GenericArrayAdapter",
"(",
"builder",
",",
"comparator",
")",
";",
"final",
"int",
"[",
"]",
"sa",
"=",
"adapter",
".",
"buildSuffixArray",
"(",
"input",
")",
";",
"final",
"int",
"[",
"]",
"lcp",
"=",
"computeLCP",
"(",
"adapter",
".",
"input",
",",
"0",
",",
"input",
".",
"length",
",",
"sa",
")",
";",
"return",
"new",
"SuffixData",
"(",
"sa",
",",
"lcp",
")",
";",
"}"
] |
Create a suffix array and an LCP array for a given generic array and a
custom suffix array building strategy, using the given T object
comparator.
|
[
"Create",
"a",
"suffix",
"array",
"and",
"an",
"LCP",
"array",
"for",
"a",
"given",
"generic",
"array",
"and",
"a",
"custom",
"suffix",
"array",
"building",
"strategy",
"using",
"the",
"given",
"T",
"object",
"comparator",
"."
] |
train
|
https://github.com/interedition/collatex/blob/76dd1fcc36047bc66a87d31142e72e98b5347821/collatex-core/src/main/java/eu/interedition/collatex/suffixarray/SuffixArrays.java#L106-L111
|
hawkular/hawkular-apm
|
client/opentracing/src/main/java/io/opentracing/impl/APMSpan.java
|
APMSpan.processRemainingReferences
|
protected void processRemainingReferences(APMSpanBuilder builder, Reference primaryRef) {
"""
This method processes the remaining references by creating appropriate correlation ids
against the current node.
@param builder The span builder
@param primaryRef The primary reference, if null if one was not found
"""
// Check if other references
for (Reference ref : builder.references) {
if (primaryRef == ref) {
continue;
}
// Setup correlation ids for other references
if (ref.getReferredTo() instanceof APMSpan) {
APMSpan referenced = (APMSpan) ref.getReferredTo();
String nodeId = referenced.getNodePath();
getNodeBuilder().addCorrelationId(new CorrelationIdentifier(Scope.CausedBy, nodeId));
} else if (ref.getReferredTo() instanceof APMSpanBuilder
&& ((APMSpanBuilder) ref.getReferredTo()).state().containsKey(Constants.HAWKULAR_APM_ID)) {
getNodeBuilder().addCorrelationId(new CorrelationIdentifier(Scope.Interaction,
((APMSpanBuilder) ref.getReferredTo()).state().get(Constants.HAWKULAR_APM_ID).toString()));
}
}
}
|
java
|
protected void processRemainingReferences(APMSpanBuilder builder, Reference primaryRef) {
// Check if other references
for (Reference ref : builder.references) {
if (primaryRef == ref) {
continue;
}
// Setup correlation ids for other references
if (ref.getReferredTo() instanceof APMSpan) {
APMSpan referenced = (APMSpan) ref.getReferredTo();
String nodeId = referenced.getNodePath();
getNodeBuilder().addCorrelationId(new CorrelationIdentifier(Scope.CausedBy, nodeId));
} else if (ref.getReferredTo() instanceof APMSpanBuilder
&& ((APMSpanBuilder) ref.getReferredTo()).state().containsKey(Constants.HAWKULAR_APM_ID)) {
getNodeBuilder().addCorrelationId(new CorrelationIdentifier(Scope.Interaction,
((APMSpanBuilder) ref.getReferredTo()).state().get(Constants.HAWKULAR_APM_ID).toString()));
}
}
}
|
[
"protected",
"void",
"processRemainingReferences",
"(",
"APMSpanBuilder",
"builder",
",",
"Reference",
"primaryRef",
")",
"{",
"// Check if other references",
"for",
"(",
"Reference",
"ref",
":",
"builder",
".",
"references",
")",
"{",
"if",
"(",
"primaryRef",
"==",
"ref",
")",
"{",
"continue",
";",
"}",
"// Setup correlation ids for other references",
"if",
"(",
"ref",
".",
"getReferredTo",
"(",
")",
"instanceof",
"APMSpan",
")",
"{",
"APMSpan",
"referenced",
"=",
"(",
"APMSpan",
")",
"ref",
".",
"getReferredTo",
"(",
")",
";",
"String",
"nodeId",
"=",
"referenced",
".",
"getNodePath",
"(",
")",
";",
"getNodeBuilder",
"(",
")",
".",
"addCorrelationId",
"(",
"new",
"CorrelationIdentifier",
"(",
"Scope",
".",
"CausedBy",
",",
"nodeId",
")",
")",
";",
"}",
"else",
"if",
"(",
"ref",
".",
"getReferredTo",
"(",
")",
"instanceof",
"APMSpanBuilder",
"&&",
"(",
"(",
"APMSpanBuilder",
")",
"ref",
".",
"getReferredTo",
"(",
")",
")",
".",
"state",
"(",
")",
".",
"containsKey",
"(",
"Constants",
".",
"HAWKULAR_APM_ID",
")",
")",
"{",
"getNodeBuilder",
"(",
")",
".",
"addCorrelationId",
"(",
"new",
"CorrelationIdentifier",
"(",
"Scope",
".",
"Interaction",
",",
"(",
"(",
"APMSpanBuilder",
")",
"ref",
".",
"getReferredTo",
"(",
")",
")",
".",
"state",
"(",
")",
".",
"get",
"(",
"Constants",
".",
"HAWKULAR_APM_ID",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] |
This method processes the remaining references by creating appropriate correlation ids
against the current node.
@param builder The span builder
@param primaryRef The primary reference, if null if one was not found
|
[
"This",
"method",
"processes",
"the",
"remaining",
"references",
"by",
"creating",
"appropriate",
"correlation",
"ids",
"against",
"the",
"current",
"node",
"."
] |
train
|
https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/client/opentracing/src/main/java/io/opentracing/impl/APMSpan.java#L295-L314
|
demidenko05/beigesoft-orm
|
src/main/java/org/beigesoft/orm/service/ASrvOrm.java
|
ASrvOrm.retrieveListWithConditions
|
@Override
public final <T> List<T> retrieveListWithConditions(
final Map<String, Object> pAddParam,
final Class<T> pEntityClass,
final String pQueryConditions) throws Exception {
"""
<p>Retrieve a list of entities.</p>
@param <T> - type of business object,
@param pAddParam additional param, e.g. already retrieved TableSql
@param pEntityClass entity class
@param pQueryConditions Not NULL e.g. "where name='U1' ORDER BY id"
@return list of business objects or empty list, not null
@throws Exception - an exception
"""
if (pQueryConditions == null) {
throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
"param_null_not_accepted");
}
String query = evalSqlSelect(pAddParam, pEntityClass) + " "
+ pQueryConditions + ";\n";
return retrieveListByQuery(pAddParam, pEntityClass, query);
}
|
java
|
@Override
public final <T> List<T> retrieveListWithConditions(
final Map<String, Object> pAddParam,
final Class<T> pEntityClass,
final String pQueryConditions) throws Exception {
if (pQueryConditions == null) {
throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
"param_null_not_accepted");
}
String query = evalSqlSelect(pAddParam, pEntityClass) + " "
+ pQueryConditions + ";\n";
return retrieveListByQuery(pAddParam, pEntityClass, query);
}
|
[
"@",
"Override",
"public",
"final",
"<",
"T",
">",
"List",
"<",
"T",
">",
"retrieveListWithConditions",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"pAddParam",
",",
"final",
"Class",
"<",
"T",
">",
"pEntityClass",
",",
"final",
"String",
"pQueryConditions",
")",
"throws",
"Exception",
"{",
"if",
"(",
"pQueryConditions",
"==",
"null",
")",
"{",
"throw",
"new",
"ExceptionWithCode",
"(",
"ExceptionWithCode",
".",
"WRONG_PARAMETER",
",",
"\"param_null_not_accepted\"",
")",
";",
"}",
"String",
"query",
"=",
"evalSqlSelect",
"(",
"pAddParam",
",",
"pEntityClass",
")",
"+",
"\" \"",
"+",
"pQueryConditions",
"+",
"\";\\n\"",
";",
"return",
"retrieveListByQuery",
"(",
"pAddParam",
",",
"pEntityClass",
",",
"query",
")",
";",
"}"
] |
<p>Retrieve a list of entities.</p>
@param <T> - type of business object,
@param pAddParam additional param, e.g. already retrieved TableSql
@param pEntityClass entity class
@param pQueryConditions Not NULL e.g. "where name='U1' ORDER BY id"
@return list of business objects or empty list, not null
@throws Exception - an exception
|
[
"<p",
">",
"Retrieve",
"a",
"list",
"of",
"entities",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/demidenko05/beigesoft-orm/blob/f1b2c70701a111741a436911ca24ef9d38eba0b9/src/main/java/org/beigesoft/orm/service/ASrvOrm.java#L355-L367
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java
|
ModelsImpl.deleteExplicitListItemAsync
|
public Observable<OperationStatus> deleteExplicitListItemAsync(UUID appId, String versionId, UUID entityId, long itemId) {
"""
Delete the explicit list item from the Pattern.any explicit list.
@param appId The application ID.
@param versionId The version ID.
@param entityId The pattern.any entity id.
@param itemId The explicit list item which will be deleted.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object
"""
return deleteExplicitListItemWithServiceResponseAsync(appId, versionId, entityId, itemId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
}
|
java
|
public Observable<OperationStatus> deleteExplicitListItemAsync(UUID appId, String versionId, UUID entityId, long itemId) {
return deleteExplicitListItemWithServiceResponseAsync(appId, versionId, entityId, itemId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"OperationStatus",
">",
"deleteExplicitListItemAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"entityId",
",",
"long",
"itemId",
")",
"{",
"return",
"deleteExplicitListItemWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"entityId",
",",
"itemId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OperationStatus",
">",
",",
"OperationStatus",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OperationStatus",
"call",
"(",
"ServiceResponse",
"<",
"OperationStatus",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Delete the explicit list item from the Pattern.any explicit list.
@param appId The application ID.
@param versionId The version ID.
@param entityId The pattern.any entity id.
@param itemId The explicit list item which will be deleted.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object
|
[
"Delete",
"the",
"explicit",
"list",
"item",
"from",
"the",
"Pattern",
".",
"any",
"explicit",
"list",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L14291-L14298
|
cvut/JCOP
|
src/main/java/cz/cvut/felk/cig/jcop/solver/BaseSolver.java
|
BaseSolver.optimize
|
protected ResultEntry optimize(ObjectiveProblem objectiveProblem, Algorithm algorithm) {
"""
Applies one algorithm on one problem until any condition is met or exception is raised.
<p/>
This method just removes code duplicities since most solvers has identical this part of solving. It is not
obligatory to use this method however, change it if necessary (for example algorithm switching on simple
problem).
@param objectiveProblem problem to be solved
@param algorithm algorithm to be used during solving
@return result entry for this optimization
"""
PreciseTimestamp startPreciseTimestamp = null;
Exception algorithmException = null;
Configuration bestConfiguration = null;
int optimizeCounter = 0;
try {
startPreciseTimestamp = new PreciseTimestamp();
algorithm.init(objectiveProblem);
this.sendMessage(new MessageSolverStart(algorithm, objectiveProblem));
logger.info("Started optimize, {} on {}.", algorithm, objectiveProblem);
do {
algorithm.optimize();
this.sendMessage(new MessageOptimize());
optimizeCounter++;
if (algorithm.getBestConfiguration() != null
&& (bestConfiguration == null || !bestConfiguration.equals(algorithm.getBestConfiguration()))) {
logger.debug("Better solution {}, {}, {}",
algorithm.getBestFitness(), optimizeCounter, algorithm.getBestConfiguration());
bestConfiguration = algorithm.getBestConfiguration();
this.sendMessage(new MessageBetterConfigurationFound(bestConfiguration, algorithm.getBestFitness()));
if (objectiveProblem.isSolution(bestConfiguration))
this.sendMessage(new MessageSolutionFound(bestConfiguration, algorithm.getBestFitness()));
}
if (this.isConditionMet()) break;
} while (true);
} catch (Exception e) {
logger.warn("Got exception {}.", e.getClass().getSimpleName());
algorithmException = e;
}
this.sendMessage(new MessageSolverStop(algorithm, objectiveProblem));
logger.info("Stopped optimize.");
algorithm.cleanUp();
return new ResultEntry(algorithm, objectiveProblem, bestConfiguration, algorithm.getBestFitness(),
optimizeCounter, algorithmException, startPreciseTimestamp);
}
|
java
|
protected ResultEntry optimize(ObjectiveProblem objectiveProblem, Algorithm algorithm) {
PreciseTimestamp startPreciseTimestamp = null;
Exception algorithmException = null;
Configuration bestConfiguration = null;
int optimizeCounter = 0;
try {
startPreciseTimestamp = new PreciseTimestamp();
algorithm.init(objectiveProblem);
this.sendMessage(new MessageSolverStart(algorithm, objectiveProblem));
logger.info("Started optimize, {} on {}.", algorithm, objectiveProblem);
do {
algorithm.optimize();
this.sendMessage(new MessageOptimize());
optimizeCounter++;
if (algorithm.getBestConfiguration() != null
&& (bestConfiguration == null || !bestConfiguration.equals(algorithm.getBestConfiguration()))) {
logger.debug("Better solution {}, {}, {}",
algorithm.getBestFitness(), optimizeCounter, algorithm.getBestConfiguration());
bestConfiguration = algorithm.getBestConfiguration();
this.sendMessage(new MessageBetterConfigurationFound(bestConfiguration, algorithm.getBestFitness()));
if (objectiveProblem.isSolution(bestConfiguration))
this.sendMessage(new MessageSolutionFound(bestConfiguration, algorithm.getBestFitness()));
}
if (this.isConditionMet()) break;
} while (true);
} catch (Exception e) {
logger.warn("Got exception {}.", e.getClass().getSimpleName());
algorithmException = e;
}
this.sendMessage(new MessageSolverStop(algorithm, objectiveProblem));
logger.info("Stopped optimize.");
algorithm.cleanUp();
return new ResultEntry(algorithm, objectiveProblem, bestConfiguration, algorithm.getBestFitness(),
optimizeCounter, algorithmException, startPreciseTimestamp);
}
|
[
"protected",
"ResultEntry",
"optimize",
"(",
"ObjectiveProblem",
"objectiveProblem",
",",
"Algorithm",
"algorithm",
")",
"{",
"PreciseTimestamp",
"startPreciseTimestamp",
"=",
"null",
";",
"Exception",
"algorithmException",
"=",
"null",
";",
"Configuration",
"bestConfiguration",
"=",
"null",
";",
"int",
"optimizeCounter",
"=",
"0",
";",
"try",
"{",
"startPreciseTimestamp",
"=",
"new",
"PreciseTimestamp",
"(",
")",
";",
"algorithm",
".",
"init",
"(",
"objectiveProblem",
")",
";",
"this",
".",
"sendMessage",
"(",
"new",
"MessageSolverStart",
"(",
"algorithm",
",",
"objectiveProblem",
")",
")",
";",
"logger",
".",
"info",
"(",
"\"Started optimize, {} on {}.\"",
",",
"algorithm",
",",
"objectiveProblem",
")",
";",
"do",
"{",
"algorithm",
".",
"optimize",
"(",
")",
";",
"this",
".",
"sendMessage",
"(",
"new",
"MessageOptimize",
"(",
")",
")",
";",
"optimizeCounter",
"++",
";",
"if",
"(",
"algorithm",
".",
"getBestConfiguration",
"(",
")",
"!=",
"null",
"&&",
"(",
"bestConfiguration",
"==",
"null",
"||",
"!",
"bestConfiguration",
".",
"equals",
"(",
"algorithm",
".",
"getBestConfiguration",
"(",
")",
")",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Better solution {}, {}, {}\"",
",",
"algorithm",
".",
"getBestFitness",
"(",
")",
",",
"optimizeCounter",
",",
"algorithm",
".",
"getBestConfiguration",
"(",
")",
")",
";",
"bestConfiguration",
"=",
"algorithm",
".",
"getBestConfiguration",
"(",
")",
";",
"this",
".",
"sendMessage",
"(",
"new",
"MessageBetterConfigurationFound",
"(",
"bestConfiguration",
",",
"algorithm",
".",
"getBestFitness",
"(",
")",
")",
")",
";",
"if",
"(",
"objectiveProblem",
".",
"isSolution",
"(",
"bestConfiguration",
")",
")",
"this",
".",
"sendMessage",
"(",
"new",
"MessageSolutionFound",
"(",
"bestConfiguration",
",",
"algorithm",
".",
"getBestFitness",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"this",
".",
"isConditionMet",
"(",
")",
")",
"break",
";",
"}",
"while",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Got exception {}.\"",
",",
"e",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"algorithmException",
"=",
"e",
";",
"}",
"this",
".",
"sendMessage",
"(",
"new",
"MessageSolverStop",
"(",
"algorithm",
",",
"objectiveProblem",
")",
")",
";",
"logger",
".",
"info",
"(",
"\"Stopped optimize.\"",
")",
";",
"algorithm",
".",
"cleanUp",
"(",
")",
";",
"return",
"new",
"ResultEntry",
"(",
"algorithm",
",",
"objectiveProblem",
",",
"bestConfiguration",
",",
"algorithm",
".",
"getBestFitness",
"(",
")",
",",
"optimizeCounter",
",",
"algorithmException",
",",
"startPreciseTimestamp",
")",
";",
"}"
] |
Applies one algorithm on one problem until any condition is met or exception is raised.
<p/>
This method just removes code duplicities since most solvers has identical this part of solving. It is not
obligatory to use this method however, change it if necessary (for example algorithm switching on simple
problem).
@param objectiveProblem problem to be solved
@param algorithm algorithm to be used during solving
@return result entry for this optimization
|
[
"Applies",
"one",
"algorithm",
"on",
"one",
"problem",
"until",
"any",
"condition",
"is",
"met",
"or",
"exception",
"is",
"raised",
".",
"<p",
"/",
">",
"This",
"method",
"just",
"removes",
"code",
"duplicities",
"since",
"most",
"solvers",
"has",
"identical",
"this",
"part",
"of",
"solving",
".",
"It",
"is",
"not",
"obligatory",
"to",
"use",
"this",
"method",
"however",
"change",
"it",
"if",
"necessary",
"(",
"for",
"example",
"algorithm",
"switching",
"on",
"simple",
"problem",
")",
"."
] |
train
|
https://github.com/cvut/JCOP/blob/2ec18315a9a452e5f4e3d07cccfde0310adc465a/src/main/java/cz/cvut/felk/cig/jcop/solver/BaseSolver.java#L136-L181
|
peholmst/vaadin4spring
|
addons/i18n/src/main/java/org/vaadin/spring/i18n/I18N.java
|
I18N.getWithDefault
|
public String getWithDefault(String code, String defaultMessage, Object... arguments) {
"""
Tries to resolve the specified message for the current locale.
@param code the code to lookup up, such as 'calculator.noRateSet', never {@code null}.
@param defaultMessage string to return if the lookup fails, never {@code null}.
@param arguments Array of arguments that will be filled in for params within the message (params look like "{0}",
"{1,date}", "{2,time}"), or {@code null} if none.
@return the resolved message, or the {@code defaultMessage} if the lookup fails.
@see #getLocale()
"""
try {
return getMessage(code, null, arguments);
} catch (NoSuchMessageException ex) {
return defaultMessage;
}
}
|
java
|
public String getWithDefault(String code, String defaultMessage, Object... arguments) {
try {
return getMessage(code, null, arguments);
} catch (NoSuchMessageException ex) {
return defaultMessage;
}
}
|
[
"public",
"String",
"getWithDefault",
"(",
"String",
"code",
",",
"String",
"defaultMessage",
",",
"Object",
"...",
"arguments",
")",
"{",
"try",
"{",
"return",
"getMessage",
"(",
"code",
",",
"null",
",",
"arguments",
")",
";",
"}",
"catch",
"(",
"NoSuchMessageException",
"ex",
")",
"{",
"return",
"defaultMessage",
";",
"}",
"}"
] |
Tries to resolve the specified message for the current locale.
@param code the code to lookup up, such as 'calculator.noRateSet', never {@code null}.
@param defaultMessage string to return if the lookup fails, never {@code null}.
@param arguments Array of arguments that will be filled in for params within the message (params look like "{0}",
"{1,date}", "{2,time}"), or {@code null} if none.
@return the resolved message, or the {@code defaultMessage} if the lookup fails.
@see #getLocale()
|
[
"Tries",
"to",
"resolve",
"the",
"specified",
"message",
"for",
"the",
"current",
"locale",
"."
] |
train
|
https://github.com/peholmst/vaadin4spring/blob/ea896012f15d6abea6e6391def9a0001113a1f7a/addons/i18n/src/main/java/org/vaadin/spring/i18n/I18N.java#L153-L159
|
SimplicityApks/ReminderDatePicker
|
lib/src/main/java/com/simplicityapks/reminderdatepicker/lib/DateSpinner.java
|
DateSpinner.setMaxDate
|
public void setMaxDate(@Nullable Calendar maxDate) {
"""
Sets the maximum allowed date.
Spinner items and dates in the date picker after the given date will get disabled.
@param maxDate The maximum date, or null to clear the previous max date.
"""
this.maxDate = maxDate;
// update the date picker (even if it is not used right now)
if(maxDate == null)
datePickerDialog.setMaxDate(null);
else if(minDate != null && compareCalendarDates(minDate, maxDate) > 0)
throw new IllegalArgumentException("Maximum date must be after minimum date!");
else
datePickerDialog.setMaxDate(new CalendarDay(maxDate));
updateEnabledItems();
}
|
java
|
public void setMaxDate(@Nullable Calendar maxDate) {
this.maxDate = maxDate;
// update the date picker (even if it is not used right now)
if(maxDate == null)
datePickerDialog.setMaxDate(null);
else if(minDate != null && compareCalendarDates(minDate, maxDate) > 0)
throw new IllegalArgumentException("Maximum date must be after minimum date!");
else
datePickerDialog.setMaxDate(new CalendarDay(maxDate));
updateEnabledItems();
}
|
[
"public",
"void",
"setMaxDate",
"(",
"@",
"Nullable",
"Calendar",
"maxDate",
")",
"{",
"this",
".",
"maxDate",
"=",
"maxDate",
";",
"// update the date picker (even if it is not used right now)",
"if",
"(",
"maxDate",
"==",
"null",
")",
"datePickerDialog",
".",
"setMaxDate",
"(",
"null",
")",
";",
"else",
"if",
"(",
"minDate",
"!=",
"null",
"&&",
"compareCalendarDates",
"(",
"minDate",
",",
"maxDate",
")",
">",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Maximum date must be after minimum date!\"",
")",
";",
"else",
"datePickerDialog",
".",
"setMaxDate",
"(",
"new",
"CalendarDay",
"(",
"maxDate",
")",
")",
";",
"updateEnabledItems",
"(",
")",
";",
"}"
] |
Sets the maximum allowed date.
Spinner items and dates in the date picker after the given date will get disabled.
@param maxDate The maximum date, or null to clear the previous max date.
|
[
"Sets",
"the",
"maximum",
"allowed",
"date",
".",
"Spinner",
"items",
"and",
"dates",
"in",
"the",
"date",
"picker",
"after",
"the",
"given",
"date",
"will",
"get",
"disabled",
"."
] |
train
|
https://github.com/SimplicityApks/ReminderDatePicker/blob/7596fbac77a5d26f687fec11758935a2b7db156f/lib/src/main/java/com/simplicityapks/reminderdatepicker/lib/DateSpinner.java#L384-L394
|
ironjacamar/ironjacamar
|
codegenerator/src/main/java/org/ironjacamar/codegenerator/code/CciConnCodeGen.java
|
CciConnCodeGen.writeClassBody
|
@Override
public void writeClassBody(Definition def, Writer out) throws IOException {
"""
Output ResourceAdapater class
@param def definition
@param out Writer
@throws IOException ioException
"""
out.write("public class " + getClassName(def) + " implements Connection");
writeLeftCurlyBracket(out, 0);
int indent = 1;
writeDefaultConstructor(def, out, indent);
//constructor
writeWithIndent(out, indent, "/**\n");
writeWithIndent(out, indent, " * Default constructor\n");
writeWithIndent(out, indent, " * @param connSpec ConnectionSpec\n");
writeWithIndent(out, indent, " */\n");
writeWithIndent(out, indent, "public " + getClassName(def) + "(ConnectionSpec connSpec)");
writeLeftCurlyBracket(out, indent);
writeRightCurlyBracket(out, indent);
writeEol(out);
writeClose(def, out, indent);
writeInteraction(def, out, indent);
writeLocalTransaction(def, out, indent);
writeMetaData(def, out, indent);
writeResultSetInfo(def, out, indent);
writeEol(out);
writeWithIndent(out, indent, "/**\n");
writeWithIndent(out, indent, " * Set ManagedConnection\n");
writeWithIndent(out, indent, " */\n");
writeWithIndent(out, indent,
"void setManagedConnection(" + def.getMcfDefs().get(getNumOfMcf()).getMcClass() + " mc)");
writeLeftCurlyBracket(out, indent);
writeRightCurlyBracket(out, indent);
writeRightCurlyBracket(out, 0);
}
|
java
|
@Override
public void writeClassBody(Definition def, Writer out) throws IOException
{
out.write("public class " + getClassName(def) + " implements Connection");
writeLeftCurlyBracket(out, 0);
int indent = 1;
writeDefaultConstructor(def, out, indent);
//constructor
writeWithIndent(out, indent, "/**\n");
writeWithIndent(out, indent, " * Default constructor\n");
writeWithIndent(out, indent, " * @param connSpec ConnectionSpec\n");
writeWithIndent(out, indent, " */\n");
writeWithIndent(out, indent, "public " + getClassName(def) + "(ConnectionSpec connSpec)");
writeLeftCurlyBracket(out, indent);
writeRightCurlyBracket(out, indent);
writeEol(out);
writeClose(def, out, indent);
writeInteraction(def, out, indent);
writeLocalTransaction(def, out, indent);
writeMetaData(def, out, indent);
writeResultSetInfo(def, out, indent);
writeEol(out);
writeWithIndent(out, indent, "/**\n");
writeWithIndent(out, indent, " * Set ManagedConnection\n");
writeWithIndent(out, indent, " */\n");
writeWithIndent(out, indent,
"void setManagedConnection(" + def.getMcfDefs().get(getNumOfMcf()).getMcClass() + " mc)");
writeLeftCurlyBracket(out, indent);
writeRightCurlyBracket(out, indent);
writeRightCurlyBracket(out, 0);
}
|
[
"@",
"Override",
"public",
"void",
"writeClassBody",
"(",
"Definition",
"def",
",",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"out",
".",
"write",
"(",
"\"public class \"",
"+",
"getClassName",
"(",
"def",
")",
"+",
"\" implements Connection\"",
")",
";",
"writeLeftCurlyBracket",
"(",
"out",
",",
"0",
")",
";",
"int",
"indent",
"=",
"1",
";",
"writeDefaultConstructor",
"(",
"def",
",",
"out",
",",
"indent",
")",
";",
"//constructor",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"/**\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * Default constructor\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * @param connSpec ConnectionSpec\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" */\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"public \"",
"+",
"getClassName",
"(",
"def",
")",
"+",
"\"(ConnectionSpec connSpec)\"",
")",
";",
"writeLeftCurlyBracket",
"(",
"out",
",",
"indent",
")",
";",
"writeRightCurlyBracket",
"(",
"out",
",",
"indent",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeClose",
"(",
"def",
",",
"out",
",",
"indent",
")",
";",
"writeInteraction",
"(",
"def",
",",
"out",
",",
"indent",
")",
";",
"writeLocalTransaction",
"(",
"def",
",",
"out",
",",
"indent",
")",
";",
"writeMetaData",
"(",
"def",
",",
"out",
",",
"indent",
")",
";",
"writeResultSetInfo",
"(",
"def",
",",
"out",
",",
"indent",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"/**\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * Set ManagedConnection\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" */\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"void setManagedConnection(\"",
"+",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"getNumOfMcf",
"(",
")",
")",
".",
"getMcClass",
"(",
")",
"+",
"\" mc)\"",
")",
";",
"writeLeftCurlyBracket",
"(",
"out",
",",
"indent",
")",
";",
"writeRightCurlyBracket",
"(",
"out",
",",
"indent",
")",
";",
"writeRightCurlyBracket",
"(",
"out",
",",
"0",
")",
";",
"}"
] |
Output ResourceAdapater class
@param def definition
@param out Writer
@throws IOException ioException
|
[
"Output",
"ResourceAdapater",
"class"
] |
train
|
https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/code/CciConnCodeGen.java#L43-L80
|
docusign/docusign-java-client
|
src/main/java/com/docusign/esign/api/EnvelopesApi.java
|
EnvelopesApi.updateChunkedUpload
|
public ChunkedUploadResponse updateChunkedUpload(String accountId, String chunkedUploadId) throws ApiException {
"""
Integrity-Check and Commit a ChunkedUpload, readying it for use elsewhere.
@param accountId The external account number (int) or account ID Guid. (required)
@param chunkedUploadId (required)
@return ChunkedUploadResponse
"""
return updateChunkedUpload(accountId, chunkedUploadId, null);
}
|
java
|
public ChunkedUploadResponse updateChunkedUpload(String accountId, String chunkedUploadId) throws ApiException {
return updateChunkedUpload(accountId, chunkedUploadId, null);
}
|
[
"public",
"ChunkedUploadResponse",
"updateChunkedUpload",
"(",
"String",
"accountId",
",",
"String",
"chunkedUploadId",
")",
"throws",
"ApiException",
"{",
"return",
"updateChunkedUpload",
"(",
"accountId",
",",
"chunkedUploadId",
",",
"null",
")",
";",
"}"
] |
Integrity-Check and Commit a ChunkedUpload, readying it for use elsewhere.
@param accountId The external account number (int) or account ID Guid. (required)
@param chunkedUploadId (required)
@return ChunkedUploadResponse
|
[
"Integrity",
"-",
"Check",
"and",
"Commit",
"a",
"ChunkedUpload",
"readying",
"it",
"for",
"use",
"elsewhere",
"."
] |
train
|
https://github.com/docusign/docusign-java-client/blob/17ae82ace0f023e98edf813be832950568212e34/src/main/java/com/docusign/esign/api/EnvelopesApi.java#L4782-L4784
|
TheHortonMachine/hortonmachine
|
gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java
|
CoverageUtilities.colRowFromCoordinate
|
public static int[] colRowFromCoordinate( Coordinate coordinate, GridGeometry2D gridGeometry, Point point ) {
"""
Utility method to get col and row of a coordinate from a {@link GridGeometry2D}.
@param coordinate the coordinate to transform.
@param gridGeometry the gridgeometry to use.
@param point if not <code>null</code>, the row col values are put inside the supplied point's x and y.
@return the array with [col, row] or <code>null</code> if something went wrong.
"""
try {
DirectPosition pos = new DirectPosition2D(coordinate.x, coordinate.y);
GridCoordinates2D worldToGrid = gridGeometry.worldToGrid(pos);
if (point != null) {
point.x = worldToGrid.x;
point.y = worldToGrid.y;
}
return new int[]{worldToGrid.x, worldToGrid.y};
} catch (InvalidGridGeometryException e) {
e.printStackTrace();
} catch (TransformException e) {
e.printStackTrace();
}
point.x = Integer.MAX_VALUE;
point.y = Integer.MAX_VALUE;
return null;
}
|
java
|
public static int[] colRowFromCoordinate( Coordinate coordinate, GridGeometry2D gridGeometry, Point point ) {
try {
DirectPosition pos = new DirectPosition2D(coordinate.x, coordinate.y);
GridCoordinates2D worldToGrid = gridGeometry.worldToGrid(pos);
if (point != null) {
point.x = worldToGrid.x;
point.y = worldToGrid.y;
}
return new int[]{worldToGrid.x, worldToGrid.y};
} catch (InvalidGridGeometryException e) {
e.printStackTrace();
} catch (TransformException e) {
e.printStackTrace();
}
point.x = Integer.MAX_VALUE;
point.y = Integer.MAX_VALUE;
return null;
}
|
[
"public",
"static",
"int",
"[",
"]",
"colRowFromCoordinate",
"(",
"Coordinate",
"coordinate",
",",
"GridGeometry2D",
"gridGeometry",
",",
"Point",
"point",
")",
"{",
"try",
"{",
"DirectPosition",
"pos",
"=",
"new",
"DirectPosition2D",
"(",
"coordinate",
".",
"x",
",",
"coordinate",
".",
"y",
")",
";",
"GridCoordinates2D",
"worldToGrid",
"=",
"gridGeometry",
".",
"worldToGrid",
"(",
"pos",
")",
";",
"if",
"(",
"point",
"!=",
"null",
")",
"{",
"point",
".",
"x",
"=",
"worldToGrid",
".",
"x",
";",
"point",
".",
"y",
"=",
"worldToGrid",
".",
"y",
";",
"}",
"return",
"new",
"int",
"[",
"]",
"{",
"worldToGrid",
".",
"x",
",",
"worldToGrid",
".",
"y",
"}",
";",
"}",
"catch",
"(",
"InvalidGridGeometryException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"TransformException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"point",
".",
"x",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"point",
".",
"y",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"return",
"null",
";",
"}"
] |
Utility method to get col and row of a coordinate from a {@link GridGeometry2D}.
@param coordinate the coordinate to transform.
@param gridGeometry the gridgeometry to use.
@param point if not <code>null</code>, the row col values are put inside the supplied point's x and y.
@return the array with [col, row] or <code>null</code> if something went wrong.
|
[
"Utility",
"method",
"to",
"get",
"col",
"and",
"row",
"of",
"a",
"coordinate",
"from",
"a",
"{",
"@link",
"GridGeometry2D",
"}",
"."
] |
train
|
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L1317-L1335
|
virgo47/javasimon
|
core/src/main/java/org/javasimon/EnabledManager.java
|
EnabledManager.createSimon
|
private synchronized Simon createSimon(String name, Class<? extends AbstractSimon> simonClass) {
"""
Even with ConcurrentHashMap we want to synchronize here, so newly created Simons can be fully
set up with {@link Callback#onSimonCreated(Simon)}. ConcurrentHashMap still works fine for
listing Simons, etc.
"""
AbstractSimon simon = allSimons.get(name);
if (simon == null) {
SimonUtils.validateSimonName(name);
simon = newSimon(name, simonClass);
} else if (simon instanceof UnknownSimon) {
simon = replaceUnknownSimon(simon, simonClass);
}
callback.onSimonCreated(simon);
return simon;
}
|
java
|
private synchronized Simon createSimon(String name, Class<? extends AbstractSimon> simonClass) {
AbstractSimon simon = allSimons.get(name);
if (simon == null) {
SimonUtils.validateSimonName(name);
simon = newSimon(name, simonClass);
} else if (simon instanceof UnknownSimon) {
simon = replaceUnknownSimon(simon, simonClass);
}
callback.onSimonCreated(simon);
return simon;
}
|
[
"private",
"synchronized",
"Simon",
"createSimon",
"(",
"String",
"name",
",",
"Class",
"<",
"?",
"extends",
"AbstractSimon",
">",
"simonClass",
")",
"{",
"AbstractSimon",
"simon",
"=",
"allSimons",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"simon",
"==",
"null",
")",
"{",
"SimonUtils",
".",
"validateSimonName",
"(",
"name",
")",
";",
"simon",
"=",
"newSimon",
"(",
"name",
",",
"simonClass",
")",
";",
"}",
"else",
"if",
"(",
"simon",
"instanceof",
"UnknownSimon",
")",
"{",
"simon",
"=",
"replaceUnknownSimon",
"(",
"simon",
",",
"simonClass",
")",
";",
"}",
"callback",
".",
"onSimonCreated",
"(",
"simon",
")",
";",
"return",
"simon",
";",
"}"
] |
Even with ConcurrentHashMap we want to synchronize here, so newly created Simons can be fully
set up with {@link Callback#onSimonCreated(Simon)}. ConcurrentHashMap still works fine for
listing Simons, etc.
|
[
"Even",
"with",
"ConcurrentHashMap",
"we",
"want",
"to",
"synchronize",
"here",
"so",
"newly",
"created",
"Simons",
"can",
"be",
"fully",
"set",
"up",
"with",
"{"
] |
train
|
https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/EnabledManager.java#L134-L144
|
Whiley/WhileyCompiler
|
src/main/java/wyc/io/WhileyFileParser.java
|
WhileyFileParser.parseUnicodeString
|
protected byte[] parseUnicodeString(Token token) {
"""
Parse a string constant whilst interpreting all escape characters.
@param v
@return
"""
String v = token.text;
/*
* Parsing a string requires several steps to be taken. First, we need
* to strip quotes from the ends of the string.
*/
v = v.substring(1, v.length() - 1);
StringBuffer result = new StringBuffer();
// Second, step through the string and replace escaped characters
for (int i = 0; i < v.length(); i++) {
if (v.charAt(i) == '\\') {
if (v.length() <= i + 1) {
throw new RuntimeException("unexpected end-of-string");
} else {
char replace = 0;
int len = 2;
switch (v.charAt(i + 1)) {
case 'b':
replace = '\b';
break;
case 't':
replace = '\t';
break;
case 'n':
replace = '\n';
break;
case 'f':
replace = '\f';
break;
case 'r':
replace = '\r';
break;
case '"':
replace = '\"';
break;
case '\'':
replace = '\'';
break;
case '\\':
replace = '\\';
break;
case 'u':
len = 6; // unicode escapes are six digits long,
// including "slash u"
String unicode = v.substring(i + 2, i + 6);
replace = (char) Integer.parseInt(unicode, 16); // unicode
i = i + 5;
break;
default:
throw new RuntimeException("unknown escape character");
}
result.append(replace);
i = i + 1;
}
} else {
result.append(v.charAt(i));
}
}
try {
// Now, convert string into a sequence of UTF8 bytes.
return result.toString().getBytes("UTF8");
} catch (UnsupportedEncodingException e) {
// This really should be deadcode
syntaxError("invalid unicode string", token);
return null; // deadcode
}
}
|
java
|
protected byte[] parseUnicodeString(Token token) {
String v = token.text;
/*
* Parsing a string requires several steps to be taken. First, we need
* to strip quotes from the ends of the string.
*/
v = v.substring(1, v.length() - 1);
StringBuffer result = new StringBuffer();
// Second, step through the string and replace escaped characters
for (int i = 0; i < v.length(); i++) {
if (v.charAt(i) == '\\') {
if (v.length() <= i + 1) {
throw new RuntimeException("unexpected end-of-string");
} else {
char replace = 0;
int len = 2;
switch (v.charAt(i + 1)) {
case 'b':
replace = '\b';
break;
case 't':
replace = '\t';
break;
case 'n':
replace = '\n';
break;
case 'f':
replace = '\f';
break;
case 'r':
replace = '\r';
break;
case '"':
replace = '\"';
break;
case '\'':
replace = '\'';
break;
case '\\':
replace = '\\';
break;
case 'u':
len = 6; // unicode escapes are six digits long,
// including "slash u"
String unicode = v.substring(i + 2, i + 6);
replace = (char) Integer.parseInt(unicode, 16); // unicode
i = i + 5;
break;
default:
throw new RuntimeException("unknown escape character");
}
result.append(replace);
i = i + 1;
}
} else {
result.append(v.charAt(i));
}
}
try {
// Now, convert string into a sequence of UTF8 bytes.
return result.toString().getBytes("UTF8");
} catch (UnsupportedEncodingException e) {
// This really should be deadcode
syntaxError("invalid unicode string", token);
return null; // deadcode
}
}
|
[
"protected",
"byte",
"[",
"]",
"parseUnicodeString",
"(",
"Token",
"token",
")",
"{",
"String",
"v",
"=",
"token",
".",
"text",
";",
"/*\n\t\t * Parsing a string requires several steps to be taken. First, we need\n\t\t * to strip quotes from the ends of the string.\n\t\t */",
"v",
"=",
"v",
".",
"substring",
"(",
"1",
",",
"v",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"// Second, step through the string and replace escaped characters",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"v",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"v",
".",
"charAt",
"(",
"i",
")",
"==",
"'",
"'",
")",
"{",
"if",
"(",
"v",
".",
"length",
"(",
")",
"<=",
"i",
"+",
"1",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"unexpected end-of-string\"",
")",
";",
"}",
"else",
"{",
"char",
"replace",
"=",
"0",
";",
"int",
"len",
"=",
"2",
";",
"switch",
"(",
"v",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
")",
"{",
"case",
"'",
"'",
":",
"replace",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"replace",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"replace",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"replace",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"replace",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"replace",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"replace",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"replace",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"len",
"=",
"6",
";",
"// unicode escapes are six digits long,",
"// including \"slash u\"",
"String",
"unicode",
"=",
"v",
".",
"substring",
"(",
"i",
"+",
"2",
",",
"i",
"+",
"6",
")",
";",
"replace",
"=",
"(",
"char",
")",
"Integer",
".",
"parseInt",
"(",
"unicode",
",",
"16",
")",
";",
"// unicode",
"i",
"=",
"i",
"+",
"5",
";",
"break",
";",
"default",
":",
"throw",
"new",
"RuntimeException",
"(",
"\"unknown escape character\"",
")",
";",
"}",
"result",
".",
"append",
"(",
"replace",
")",
";",
"i",
"=",
"i",
"+",
"1",
";",
"}",
"}",
"else",
"{",
"result",
".",
"append",
"(",
"v",
".",
"charAt",
"(",
"i",
")",
")",
";",
"}",
"}",
"try",
"{",
"// Now, convert string into a sequence of UTF8 bytes.",
"return",
"result",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
"\"UTF8\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"// This really should be deadcode",
"syntaxError",
"(",
"\"invalid unicode string\"",
",",
"token",
")",
";",
"return",
"null",
";",
"// deadcode",
"}",
"}"
] |
Parse a string constant whilst interpreting all escape characters.
@param v
@return
|
[
"Parse",
"a",
"string",
"constant",
"whilst",
"interpreting",
"all",
"escape",
"characters",
"."
] |
train
|
https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyc/io/WhileyFileParser.java#L4496-L4563
|
alibaba/jstorm
|
jstorm-core/src/main/java/storm/trident/Stream.java
|
Stream.minBy
|
public <T> Stream minBy(String inputFieldName, Comparator<T> comparator) {
"""
This aggregator operation computes the minimum of tuples by the given {@code inputFieldName} in a stream by
using the given {@code comparator}. If the value of tuple with field {@code inputFieldName} is not an
instance of {@code T} then it throws {@code ClassCastException}
@param inputFieldName input field name
@param comparator comparator used in for finding minimum of two tuple values of {@code inputFieldName}.
@param <T> type of tuple's given input field value.
@return the new stream with this operation.
"""
Aggregator<ComparisonAggregator.State> min = new MinWithComparator<>(inputFieldName, comparator);
return comparableAggregateStream(inputFieldName, min);
}
|
java
|
public <T> Stream minBy(String inputFieldName, Comparator<T> comparator) {
Aggregator<ComparisonAggregator.State> min = new MinWithComparator<>(inputFieldName, comparator);
return comparableAggregateStream(inputFieldName, min);
}
|
[
"public",
"<",
"T",
">",
"Stream",
"minBy",
"(",
"String",
"inputFieldName",
",",
"Comparator",
"<",
"T",
">",
"comparator",
")",
"{",
"Aggregator",
"<",
"ComparisonAggregator",
".",
"State",
">",
"min",
"=",
"new",
"MinWithComparator",
"<>",
"(",
"inputFieldName",
",",
"comparator",
")",
";",
"return",
"comparableAggregateStream",
"(",
"inputFieldName",
",",
"min",
")",
";",
"}"
] |
This aggregator operation computes the minimum of tuples by the given {@code inputFieldName} in a stream by
using the given {@code comparator}. If the value of tuple with field {@code inputFieldName} is not an
instance of {@code T} then it throws {@code ClassCastException}
@param inputFieldName input field name
@param comparator comparator used in for finding minimum of two tuple values of {@code inputFieldName}.
@param <T> type of tuple's given input field value.
@return the new stream with this operation.
|
[
"This",
"aggregator",
"operation",
"computes",
"the",
"minimum",
"of",
"tuples",
"by",
"the",
"given",
"{",
"@code",
"inputFieldName",
"}",
"in",
"a",
"stream",
"by",
"using",
"the",
"given",
"{",
"@code",
"comparator",
"}",
".",
"If",
"the",
"value",
"of",
"tuple",
"with",
"field",
"{",
"@code",
"inputFieldName",
"}",
"is",
"not",
"an",
"instance",
"of",
"{",
"@code",
"T",
"}",
"then",
"it",
"throws",
"{",
"@code",
"ClassCastException",
"}"
] |
train
|
https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/storm/trident/Stream.java#L497-L500
|
loadimpact/loadimpact-sdk-java
|
src/main/java/com/loadimpact/util/ListUtils.java
|
ListUtils.reduce
|
public static <Accumulator, Value> Accumulator reduce(List<Value> list, Accumulator init, ReduceClosure<Accumulator,Value> f) {
"""
Applies a binary function between each element of the given list.
@param list list of elements
@param init initial value for the accumulator
@param f accumulator expression to apply
@param <Accumulator> binary function
@param <Value> element type
@return an accumulated/aggregated value
"""
Accumulator accumulator = init;
for (Value value : list) {
accumulator = f.eval(accumulator, value);
}
return accumulator;
}
|
java
|
public static <Accumulator, Value> Accumulator reduce(List<Value> list, Accumulator init, ReduceClosure<Accumulator,Value> f) {
Accumulator accumulator = init;
for (Value value : list) {
accumulator = f.eval(accumulator, value);
}
return accumulator;
}
|
[
"public",
"static",
"<",
"Accumulator",
",",
"Value",
">",
"Accumulator",
"reduce",
"(",
"List",
"<",
"Value",
">",
"list",
",",
"Accumulator",
"init",
",",
"ReduceClosure",
"<",
"Accumulator",
",",
"Value",
">",
"f",
")",
"{",
"Accumulator",
"accumulator",
"=",
"init",
";",
"for",
"(",
"Value",
"value",
":",
"list",
")",
"{",
"accumulator",
"=",
"f",
".",
"eval",
"(",
"accumulator",
",",
"value",
")",
";",
"}",
"return",
"accumulator",
";",
"}"
] |
Applies a binary function between each element of the given list.
@param list list of elements
@param init initial value for the accumulator
@param f accumulator expression to apply
@param <Accumulator> binary function
@param <Value> element type
@return an accumulated/aggregated value
|
[
"Applies",
"a",
"binary",
"function",
"between",
"each",
"element",
"of",
"the",
"given",
"list",
"."
] |
train
|
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/util/ListUtils.java#L103-L109
|
google/j2objc
|
jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java
|
BigDecimal.roundedTenPower
|
private static BigDecimal roundedTenPower(int qsign, int raise, int scale, int preferredScale) {
"""
/*
calculate divideAndRound for ldividend*10^raise / divisor
when abs(dividend)==abs(divisor);
"""
if (scale > preferredScale) {
int diff = scale - preferredScale;
if(diff < raise) {
return scaledTenPow(raise - diff, qsign, preferredScale);
} else {
return valueOf(qsign,scale-raise);
}
} else {
return scaledTenPow(raise, qsign, scale);
}
}
|
java
|
private static BigDecimal roundedTenPower(int qsign, int raise, int scale, int preferredScale) {
if (scale > preferredScale) {
int diff = scale - preferredScale;
if(diff < raise) {
return scaledTenPow(raise - diff, qsign, preferredScale);
} else {
return valueOf(qsign,scale-raise);
}
} else {
return scaledTenPow(raise, qsign, scale);
}
}
|
[
"private",
"static",
"BigDecimal",
"roundedTenPower",
"(",
"int",
"qsign",
",",
"int",
"raise",
",",
"int",
"scale",
",",
"int",
"preferredScale",
")",
"{",
"if",
"(",
"scale",
">",
"preferredScale",
")",
"{",
"int",
"diff",
"=",
"scale",
"-",
"preferredScale",
";",
"if",
"(",
"diff",
"<",
"raise",
")",
"{",
"return",
"scaledTenPow",
"(",
"raise",
"-",
"diff",
",",
"qsign",
",",
"preferredScale",
")",
";",
"}",
"else",
"{",
"return",
"valueOf",
"(",
"qsign",
",",
"scale",
"-",
"raise",
")",
";",
"}",
"}",
"else",
"{",
"return",
"scaledTenPow",
"(",
"raise",
",",
"qsign",
",",
"scale",
")",
";",
"}",
"}"
] |
/*
calculate divideAndRound for ldividend*10^raise / divisor
when abs(dividend)==abs(divisor);
|
[
"/",
"*",
"calculate",
"divideAndRound",
"for",
"ldividend",
"*",
"10^raise",
"/",
"divisor",
"when",
"abs",
"(",
"dividend",
")",
"==",
"abs",
"(",
"divisor",
")",
";"
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java#L4884-L4895
|
powermock/powermock
|
powermock-api/powermock-api-support/src/main/java/org/powermock/api/support/SuppressCode.java
|
SuppressCode.suppressMethod
|
public static synchronized void suppressMethod(Class<?> clazz, String[] methodNames) {
"""
Suppress multiple methods for a class.
@param clazz
The class whose methods will be suppressed.
@param methodNames
Methods to suppress in class {@code clazz}.
"""
for (Method method : Whitebox.getMethods(clazz, methodNames)) {
MockRepository.addMethodToSuppress(method);
}
}
|
java
|
public static synchronized void suppressMethod(Class<?> clazz, String[] methodNames) {
for (Method method : Whitebox.getMethods(clazz, methodNames)) {
MockRepository.addMethodToSuppress(method);
}
}
|
[
"public",
"static",
"synchronized",
"void",
"suppressMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"[",
"]",
"methodNames",
")",
"{",
"for",
"(",
"Method",
"method",
":",
"Whitebox",
".",
"getMethods",
"(",
"clazz",
",",
"methodNames",
")",
")",
"{",
"MockRepository",
".",
"addMethodToSuppress",
"(",
"method",
")",
";",
"}",
"}"
] |
Suppress multiple methods for a class.
@param clazz
The class whose methods will be suppressed.
@param methodNames
Methods to suppress in class {@code clazz}.
|
[
"Suppress",
"multiple",
"methods",
"for",
"a",
"class",
"."
] |
train
|
https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-api/powermock-api-support/src/main/java/org/powermock/api/support/SuppressCode.java#L204-L208
|
GenesysPureEngage/workspace-client-java
|
src/main/java/com/genesys/internal/workspace/api/ChatApi.java
|
ChatApi.removeFromConference
|
public ApiSuccessResponse removeFromConference(String id, RemoveFromConferenceData removeFromConferenceData) throws ApiException {
"""
Remove an agent from a chat conference
Remove the specified agent from the chat conference.
@param id The ID of the chat interaction. (required)
@param removeFromConferenceData (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<ApiSuccessResponse> resp = removeFromConferenceWithHttpInfo(id, removeFromConferenceData);
return resp.getData();
}
|
java
|
public ApiSuccessResponse removeFromConference(String id, RemoveFromConferenceData removeFromConferenceData) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = removeFromConferenceWithHttpInfo(id, removeFromConferenceData);
return resp.getData();
}
|
[
"public",
"ApiSuccessResponse",
"removeFromConference",
"(",
"String",
"id",
",",
"RemoveFromConferenceData",
"removeFromConferenceData",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"ApiSuccessResponse",
">",
"resp",
"=",
"removeFromConferenceWithHttpInfo",
"(",
"id",
",",
"removeFromConferenceData",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] |
Remove an agent from a chat conference
Remove the specified agent from the chat conference.
@param id The ID of the chat interaction. (required)
@param removeFromConferenceData (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
[
"Remove",
"an",
"agent",
"from",
"a",
"chat",
"conference",
"Remove",
"the",
"specified",
"agent",
"from",
"the",
"chat",
"conference",
"."
] |
train
|
https://github.com/GenesysPureEngage/workspace-client-java/blob/509fdd9e89b9359d012f9a72be95037a3cef53e6/src/main/java/com/genesys/internal/workspace/api/ChatApi.java#L1318-L1321
|
google/closure-compiler
|
src/com/google/javascript/jscomp/RewriteAsyncIteration.java
|
RewriteAsyncIteration.convertAwaitOfAsyncGenerator
|
private void convertAwaitOfAsyncGenerator(NodeTraversal t, LexicalContext ctx, Node awaitNode) {
"""
Converts an await into a yield of an ActionRecord to perform "AWAIT".
<pre>{@code await myPromise}</pre>
<p>becomes
<pre>{@code yield new ActionRecord(ActionEnum.AWAIT_VALUE, myPromise)}</pre>
@param awaitNode the original await Node to be converted
"""
checkNotNull(awaitNode);
checkState(awaitNode.isAwait());
checkState(ctx != null && ctx.function != null);
checkState(ctx.function.isAsyncGeneratorFunction());
Node expression = awaitNode.removeFirstChild();
checkNotNull(expression, "await needs an expression");
Node newActionRecord =
astFactory.createNewNode(
astFactory.createQName(t.getScope(), ACTION_RECORD_NAME),
astFactory.createQName(t.getScope(), ACTION_ENUM_AWAIT),
expression);
newActionRecord.useSourceInfoIfMissingFromForTree(awaitNode);
awaitNode.addChildToFront(newActionRecord);
awaitNode.setToken(Token.YIELD);
}
|
java
|
private void convertAwaitOfAsyncGenerator(NodeTraversal t, LexicalContext ctx, Node awaitNode) {
checkNotNull(awaitNode);
checkState(awaitNode.isAwait());
checkState(ctx != null && ctx.function != null);
checkState(ctx.function.isAsyncGeneratorFunction());
Node expression = awaitNode.removeFirstChild();
checkNotNull(expression, "await needs an expression");
Node newActionRecord =
astFactory.createNewNode(
astFactory.createQName(t.getScope(), ACTION_RECORD_NAME),
astFactory.createQName(t.getScope(), ACTION_ENUM_AWAIT),
expression);
newActionRecord.useSourceInfoIfMissingFromForTree(awaitNode);
awaitNode.addChildToFront(newActionRecord);
awaitNode.setToken(Token.YIELD);
}
|
[
"private",
"void",
"convertAwaitOfAsyncGenerator",
"(",
"NodeTraversal",
"t",
",",
"LexicalContext",
"ctx",
",",
"Node",
"awaitNode",
")",
"{",
"checkNotNull",
"(",
"awaitNode",
")",
";",
"checkState",
"(",
"awaitNode",
".",
"isAwait",
"(",
")",
")",
";",
"checkState",
"(",
"ctx",
"!=",
"null",
"&&",
"ctx",
".",
"function",
"!=",
"null",
")",
";",
"checkState",
"(",
"ctx",
".",
"function",
".",
"isAsyncGeneratorFunction",
"(",
")",
")",
";",
"Node",
"expression",
"=",
"awaitNode",
".",
"removeFirstChild",
"(",
")",
";",
"checkNotNull",
"(",
"expression",
",",
"\"await needs an expression\"",
")",
";",
"Node",
"newActionRecord",
"=",
"astFactory",
".",
"createNewNode",
"(",
"astFactory",
".",
"createQName",
"(",
"t",
".",
"getScope",
"(",
")",
",",
"ACTION_RECORD_NAME",
")",
",",
"astFactory",
".",
"createQName",
"(",
"t",
".",
"getScope",
"(",
")",
",",
"ACTION_ENUM_AWAIT",
")",
",",
"expression",
")",
";",
"newActionRecord",
".",
"useSourceInfoIfMissingFromForTree",
"(",
"awaitNode",
")",
";",
"awaitNode",
".",
"addChildToFront",
"(",
"newActionRecord",
")",
";",
"awaitNode",
".",
"setToken",
"(",
"Token",
".",
"YIELD",
")",
";",
"}"
] |
Converts an await into a yield of an ActionRecord to perform "AWAIT".
<pre>{@code await myPromise}</pre>
<p>becomes
<pre>{@code yield new ActionRecord(ActionEnum.AWAIT_VALUE, myPromise)}</pre>
@param awaitNode the original await Node to be converted
|
[
"Converts",
"an",
"await",
"into",
"a",
"yield",
"of",
"an",
"ActionRecord",
"to",
"perform",
"AWAIT",
"."
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RewriteAsyncIteration.java#L411-L427
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/BatchUpdateDaemon.java
|
BatchUpdateDaemon.invalidateById
|
public void invalidateById(Object id, int causeOfInvalidation, boolean waitOnInvalidation, DCache cache, boolean checkPreInvalidationListener) {
"""
This invalidates a cache entry in all
caches (with the same cache name)
whose cache id or data id is specified.
@param id The id (cache id or data id) that is used to to
invalidate fragments.
@param waitOnInvalidation True indicates that this method should
not return until all invalidations have taken effect.
False indicates that the invalidations will take effect the next
time the BatchUpdateDaemon wakes.
@param causeOfInvalidation The cause of this invalidation.
@param checkPreInvalidationListener true indicates that we will verify with the preInvalidationListener
prior to invalidating. False means we will bypass this check.
"""
invalidateById(id, causeOfInvalidation, CachePerf.LOCAL, waitOnInvalidation, InvalidateByIdEvent.INVOKE_INTERNAL_INVALIDATE_BY_ID, InvalidateByIdEvent.INVOKE_DRS_RENOUNCE,
cache, checkPreInvalidationListener);
}
|
java
|
public void invalidateById(Object id, int causeOfInvalidation, boolean waitOnInvalidation, DCache cache, boolean checkPreInvalidationListener) {
invalidateById(id, causeOfInvalidation, CachePerf.LOCAL, waitOnInvalidation, InvalidateByIdEvent.INVOKE_INTERNAL_INVALIDATE_BY_ID, InvalidateByIdEvent.INVOKE_DRS_RENOUNCE,
cache, checkPreInvalidationListener);
}
|
[
"public",
"void",
"invalidateById",
"(",
"Object",
"id",
",",
"int",
"causeOfInvalidation",
",",
"boolean",
"waitOnInvalidation",
",",
"DCache",
"cache",
",",
"boolean",
"checkPreInvalidationListener",
")",
"{",
"invalidateById",
"(",
"id",
",",
"causeOfInvalidation",
",",
"CachePerf",
".",
"LOCAL",
",",
"waitOnInvalidation",
",",
"InvalidateByIdEvent",
".",
"INVOKE_INTERNAL_INVALIDATE_BY_ID",
",",
"InvalidateByIdEvent",
".",
"INVOKE_DRS_RENOUNCE",
",",
"cache",
",",
"checkPreInvalidationListener",
")",
";",
"}"
] |
This invalidates a cache entry in all
caches (with the same cache name)
whose cache id or data id is specified.
@param id The id (cache id or data id) that is used to to
invalidate fragments.
@param waitOnInvalidation True indicates that this method should
not return until all invalidations have taken effect.
False indicates that the invalidations will take effect the next
time the BatchUpdateDaemon wakes.
@param causeOfInvalidation The cause of this invalidation.
@param checkPreInvalidationListener true indicates that we will verify with the preInvalidationListener
prior to invalidating. False means we will bypass this check.
|
[
"This",
"invalidates",
"a",
"cache",
"entry",
"in",
"all",
"caches",
"(",
"with",
"the",
"same",
"cache",
"name",
")",
"whose",
"cache",
"id",
"or",
"data",
"id",
"is",
"specified",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/BatchUpdateDaemon.java#L140-L143
|
square/okhttp
|
mockwebserver/src/main/java/okhttp3/mockwebserver/MockResponse.java
|
MockResponse.addHeaderLenient
|
public MockResponse addHeaderLenient(String name, Object value) {
"""
Adds a new header with the name and value. This may be used to add multiple headers with the
same name. Unlike {@link #addHeader(String, Object)} this does not validate the name and
value.
"""
InternalKtKt.addHeaderLenient(headers, name, String.valueOf(value));
return this;
}
|
java
|
public MockResponse addHeaderLenient(String name, Object value) {
InternalKtKt.addHeaderLenient(headers, name, String.valueOf(value));
return this;
}
|
[
"public",
"MockResponse",
"addHeaderLenient",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"InternalKtKt",
".",
"addHeaderLenient",
"(",
"headers",
",",
"name",
",",
"String",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a new header with the name and value. This may be used to add multiple headers with the
same name. Unlike {@link #addHeader(String, Object)} this does not validate the name and
value.
|
[
"Adds",
"a",
"new",
"header",
"with",
"the",
"name",
"and",
"value",
".",
"This",
"may",
"be",
"used",
"to",
"add",
"multiple",
"headers",
"with",
"the",
"same",
"name",
".",
"Unlike",
"{"
] |
train
|
https://github.com/square/okhttp/blob/a8c65a822dd6cadd2de7d115bf94adf312e67868/mockwebserver/src/main/java/okhttp3/mockwebserver/MockResponse.java#L140-L143
|
kenyee/android-ddp-client
|
src/com/keysolutions/ddpclient/android/DDPStateSingleton.java
|
DDPStateSingleton.initInstance
|
public static void initInstance(Context context, String meteorServerHostname, boolean useSsl) {
"""
Initializes instance to connect to given Meteor server
@param context Android context
@param meteorServerHostname Meteor hostname/IP
@param useSsl whether to use SSL for connection
"""
initInstance(context, meteorServerHostname, sMeteorPort, useSsl);
}
|
java
|
public static void initInstance(Context context, String meteorServerHostname, boolean useSsl) {
initInstance(context, meteorServerHostname, sMeteorPort, useSsl);
}
|
[
"public",
"static",
"void",
"initInstance",
"(",
"Context",
"context",
",",
"String",
"meteorServerHostname",
",",
"boolean",
"useSsl",
")",
"{",
"initInstance",
"(",
"context",
",",
"meteorServerHostname",
",",
"sMeteorPort",
",",
"useSsl",
")",
";",
"}"
] |
Initializes instance to connect to given Meteor server
@param context Android context
@param meteorServerHostname Meteor hostname/IP
@param useSsl whether to use SSL for connection
|
[
"Initializes",
"instance",
"to",
"connect",
"to",
"given",
"Meteor",
"server"
] |
train
|
https://github.com/kenyee/android-ddp-client/blob/6ab416e415570a03f96c383497144dd742de3f08/src/com/keysolutions/ddpclient/android/DDPStateSingleton.java#L166-L168
|
smanikandan14/ThinDownloadManager
|
ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java
|
DownloadRequestQueue.checkResumableDownloadEnabled
|
private void checkResumableDownloadEnabled(int downloadId) {
"""
This is called by methods that want to throw an exception if the {@link DownloadRequest}
hasn't enable isResumable feature.
"""
synchronized (mCurrentRequests) {
for (DownloadRequest request : mCurrentRequests) {
if (downloadId == -1 && !request.isResumable()) {
Log.e("ThinDownloadManager",
String.format(Locale.getDefault(), "This request has not enabled resume feature hence request will be cancelled. Request Id: %d", request.getDownloadId()));
} else if ((request.getDownloadId() == downloadId && !request.isResumable())) {
throw new IllegalStateException("You cannot pause the download, unless you have enabled Resume feature in DownloadRequest.");
} else {
//ignored, It can not be a scenario to happen.
}
}
}
}
|
java
|
private void checkResumableDownloadEnabled(int downloadId) {
synchronized (mCurrentRequests) {
for (DownloadRequest request : mCurrentRequests) {
if (downloadId == -1 && !request.isResumable()) {
Log.e("ThinDownloadManager",
String.format(Locale.getDefault(), "This request has not enabled resume feature hence request will be cancelled. Request Id: %d", request.getDownloadId()));
} else if ((request.getDownloadId() == downloadId && !request.isResumable())) {
throw new IllegalStateException("You cannot pause the download, unless you have enabled Resume feature in DownloadRequest.");
} else {
//ignored, It can not be a scenario to happen.
}
}
}
}
|
[
"private",
"void",
"checkResumableDownloadEnabled",
"(",
"int",
"downloadId",
")",
"{",
"synchronized",
"(",
"mCurrentRequests",
")",
"{",
"for",
"(",
"DownloadRequest",
"request",
":",
"mCurrentRequests",
")",
"{",
"if",
"(",
"downloadId",
"==",
"-",
"1",
"&&",
"!",
"request",
".",
"isResumable",
"(",
")",
")",
"{",
"Log",
".",
"e",
"(",
"\"ThinDownloadManager\"",
",",
"String",
".",
"format",
"(",
"Locale",
".",
"getDefault",
"(",
")",
",",
"\"This request has not enabled resume feature hence request will be cancelled. Request Id: %d\"",
",",
"request",
".",
"getDownloadId",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"(",
"request",
".",
"getDownloadId",
"(",
")",
"==",
"downloadId",
"&&",
"!",
"request",
".",
"isResumable",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"You cannot pause the download, unless you have enabled Resume feature in DownloadRequest.\"",
")",
";",
"}",
"else",
"{",
"//ignored, It can not be a scenario to happen.",
"}",
"}",
"}",
"}"
] |
This is called by methods that want to throw an exception if the {@link DownloadRequest}
hasn't enable isResumable feature.
|
[
"This",
"is",
"called",
"by",
"methods",
"that",
"want",
"to",
"throw",
"an",
"exception",
"if",
"the",
"{"
] |
train
|
https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L233-L246
|
LearnLib/automatalib
|
core/src/main/java/net/automatalib/modelchecking/modelchecker/cache/SizeModelCheckerCache.java
|
SizeModelCheckerCache.findCounterExample
|
@Nullable
@Override
public R findCounterExample(A automaton, Collection<? extends I> inputs, P property) {
"""
The cached implementation for finding counter examples.
@see ModelChecker#findCounterExample(Object, Collection, Object)
"""
if (automaton.size() > size) {
counterExamples.clear();
}
size = automaton.size();
return counterExamples.computeIfAbsent(
Pair.of(inputs, property),
key -> Optional.ofNullable(modelChecker.findCounterExample(automaton, inputs, property))).orElse(null);
}
|
java
|
@Nullable
@Override
public R findCounterExample(A automaton, Collection<? extends I> inputs, P property) {
if (automaton.size() > size) {
counterExamples.clear();
}
size = automaton.size();
return counterExamples.computeIfAbsent(
Pair.of(inputs, property),
key -> Optional.ofNullable(modelChecker.findCounterExample(automaton, inputs, property))).orElse(null);
}
|
[
"@",
"Nullable",
"@",
"Override",
"public",
"R",
"findCounterExample",
"(",
"A",
"automaton",
",",
"Collection",
"<",
"?",
"extends",
"I",
">",
"inputs",
",",
"P",
"property",
")",
"{",
"if",
"(",
"automaton",
".",
"size",
"(",
")",
">",
"size",
")",
"{",
"counterExamples",
".",
"clear",
"(",
")",
";",
"}",
"size",
"=",
"automaton",
".",
"size",
"(",
")",
";",
"return",
"counterExamples",
".",
"computeIfAbsent",
"(",
"Pair",
".",
"of",
"(",
"inputs",
",",
"property",
")",
",",
"key",
"->",
"Optional",
".",
"ofNullable",
"(",
"modelChecker",
".",
"findCounterExample",
"(",
"automaton",
",",
"inputs",
",",
"property",
")",
")",
")",
".",
"orElse",
"(",
"null",
")",
";",
"}"
] |
The cached implementation for finding counter examples.
@see ModelChecker#findCounterExample(Object, Collection, Object)
|
[
"The",
"cached",
"implementation",
"for",
"finding",
"counter",
"examples",
"."
] |
train
|
https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/core/src/main/java/net/automatalib/modelchecking/modelchecker/cache/SizeModelCheckerCache.java#L77-L89
|
gallandarakhneorg/afc
|
core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java
|
FileSystem.addExtension
|
@Pure
public static File addExtension(File filename, String extension) {
"""
Add the extension of to specified filename.
If the filename has already the given extension, the filename is not changed.
If the filename has no extension or an other extension, the specified one is added.
@param filename is the filename to parse.
@param extension is the extension to remove if it is existing.
@return the filename with the extension.
@since 6.0
"""
if (filename != null && !hasExtension(filename, extension)) {
String extent = extension;
if (!"".equals(extent) && !extent.startsWith(EXTENSION_SEPARATOR)) { //$NON-NLS-1$
extent = EXTENSION_SEPARATOR + extent;
}
return new File(filename.getParentFile(), filename.getName() + extent);
}
return filename;
}
|
java
|
@Pure
public static File addExtension(File filename, String extension) {
if (filename != null && !hasExtension(filename, extension)) {
String extent = extension;
if (!"".equals(extent) && !extent.startsWith(EXTENSION_SEPARATOR)) { //$NON-NLS-1$
extent = EXTENSION_SEPARATOR + extent;
}
return new File(filename.getParentFile(), filename.getName() + extent);
}
return filename;
}
|
[
"@",
"Pure",
"public",
"static",
"File",
"addExtension",
"(",
"File",
"filename",
",",
"String",
"extension",
")",
"{",
"if",
"(",
"filename",
"!=",
"null",
"&&",
"!",
"hasExtension",
"(",
"filename",
",",
"extension",
")",
")",
"{",
"String",
"extent",
"=",
"extension",
";",
"if",
"(",
"!",
"\"\"",
".",
"equals",
"(",
"extent",
")",
"&&",
"!",
"extent",
".",
"startsWith",
"(",
"EXTENSION_SEPARATOR",
")",
")",
"{",
"//$NON-NLS-1$",
"extent",
"=",
"EXTENSION_SEPARATOR",
"+",
"extent",
";",
"}",
"return",
"new",
"File",
"(",
"filename",
".",
"getParentFile",
"(",
")",
",",
"filename",
".",
"getName",
"(",
")",
"+",
"extent",
")",
";",
"}",
"return",
"filename",
";",
"}"
] |
Add the extension of to specified filename.
If the filename has already the given extension, the filename is not changed.
If the filename has no extension or an other extension, the specified one is added.
@param filename is the filename to parse.
@param extension is the extension to remove if it is existing.
@return the filename with the extension.
@since 6.0
|
[
"Add",
"the",
"extension",
"of",
"to",
"specified",
"filename",
".",
"If",
"the",
"filename",
"has",
"already",
"the",
"given",
"extension",
"the",
"filename",
"is",
"not",
"changed",
".",
"If",
"the",
"filename",
"has",
"no",
"extension",
"or",
"an",
"other",
"extension",
"the",
"specified",
"one",
"is",
"added",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java#L1397-L1407
|
line/armeria
|
core/src/main/java/com/linecorp/armeria/internal/ArmeriaHttpUtil.java
|
ArmeriaHttpUtil.toArmeria
|
public static HttpHeaders toArmeria(Http2Headers headers, boolean endOfStream) {
"""
Converts the specified Netty HTTP/2 into Armeria HTTP/2 headers.
"""
final HttpHeaders converted = new DefaultHttpHeaders(false, headers.size(), endOfStream);
StringJoiner cookieJoiner = null;
for (Entry<CharSequence, CharSequence> e : headers) {
final AsciiString name = HttpHeaderNames.of(e.getKey());
final CharSequence value = e.getValue();
// Cookies must be concatenated into a single octet string.
// https://tools.ietf.org/html/rfc7540#section-8.1.2.5
if (name.equals(HttpHeaderNames.COOKIE)) {
if (cookieJoiner == null) {
cookieJoiner = new StringJoiner(COOKIE_SEPARATOR);
}
COOKIE_SPLITTER.split(value).forEach(cookieJoiner::add);
} else {
converted.add(name, convertHeaderValue(name, value));
}
}
if (cookieJoiner != null && cookieJoiner.length() != 0) {
converted.add(HttpHeaderNames.COOKIE, cookieJoiner.toString());
}
return converted;
}
|
java
|
public static HttpHeaders toArmeria(Http2Headers headers, boolean endOfStream) {
final HttpHeaders converted = new DefaultHttpHeaders(false, headers.size(), endOfStream);
StringJoiner cookieJoiner = null;
for (Entry<CharSequence, CharSequence> e : headers) {
final AsciiString name = HttpHeaderNames.of(e.getKey());
final CharSequence value = e.getValue();
// Cookies must be concatenated into a single octet string.
// https://tools.ietf.org/html/rfc7540#section-8.1.2.5
if (name.equals(HttpHeaderNames.COOKIE)) {
if (cookieJoiner == null) {
cookieJoiner = new StringJoiner(COOKIE_SEPARATOR);
}
COOKIE_SPLITTER.split(value).forEach(cookieJoiner::add);
} else {
converted.add(name, convertHeaderValue(name, value));
}
}
if (cookieJoiner != null && cookieJoiner.length() != 0) {
converted.add(HttpHeaderNames.COOKIE, cookieJoiner.toString());
}
return converted;
}
|
[
"public",
"static",
"HttpHeaders",
"toArmeria",
"(",
"Http2Headers",
"headers",
",",
"boolean",
"endOfStream",
")",
"{",
"final",
"HttpHeaders",
"converted",
"=",
"new",
"DefaultHttpHeaders",
"(",
"false",
",",
"headers",
".",
"size",
"(",
")",
",",
"endOfStream",
")",
";",
"StringJoiner",
"cookieJoiner",
"=",
"null",
";",
"for",
"(",
"Entry",
"<",
"CharSequence",
",",
"CharSequence",
">",
"e",
":",
"headers",
")",
"{",
"final",
"AsciiString",
"name",
"=",
"HttpHeaderNames",
".",
"of",
"(",
"e",
".",
"getKey",
"(",
")",
")",
";",
"final",
"CharSequence",
"value",
"=",
"e",
".",
"getValue",
"(",
")",
";",
"// Cookies must be concatenated into a single octet string.",
"// https://tools.ietf.org/html/rfc7540#section-8.1.2.5",
"if",
"(",
"name",
".",
"equals",
"(",
"HttpHeaderNames",
".",
"COOKIE",
")",
")",
"{",
"if",
"(",
"cookieJoiner",
"==",
"null",
")",
"{",
"cookieJoiner",
"=",
"new",
"StringJoiner",
"(",
"COOKIE_SEPARATOR",
")",
";",
"}",
"COOKIE_SPLITTER",
".",
"split",
"(",
"value",
")",
".",
"forEach",
"(",
"cookieJoiner",
"::",
"add",
")",
";",
"}",
"else",
"{",
"converted",
".",
"add",
"(",
"name",
",",
"convertHeaderValue",
"(",
"name",
",",
"value",
")",
")",
";",
"}",
"}",
"if",
"(",
"cookieJoiner",
"!=",
"null",
"&&",
"cookieJoiner",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"converted",
".",
"add",
"(",
"HttpHeaderNames",
".",
"COOKIE",
",",
"cookieJoiner",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"converted",
";",
"}"
] |
Converts the specified Netty HTTP/2 into Armeria HTTP/2 headers.
|
[
"Converts",
"the",
"specified",
"Netty",
"HTTP",
"/",
"2",
"into",
"Armeria",
"HTTP",
"/",
"2",
"headers",
"."
] |
train
|
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/internal/ArmeriaHttpUtil.java#L492-L516
|
orbisgis/h2gis
|
h2gis-functions/src/main/java/org/h2gis/functions/io/kml/AltitudeMode.java
|
AltitudeMode.append
|
public static void append(int altitudeMode, StringBuilder sb) {
"""
Generate a string value corresponding to the altitude mode.
@param altitudeMode
@param sb
"""
switch (altitudeMode) {
case KML_CLAMPTOGROUND:
sb.append("<kml:altitudeMode>clampToGround</kml:altitudeMode>");
return;
case KML_RELATIVETOGROUND:
sb.append("<kml:altitudeMode>relativeToGround</kml:altitudeMode>");
return;
case KML_ABSOLUTE:
sb.append("<kml:altitudeMode>absolute</kml:altitudeMode>");
return;
case GX_CLAMPTOSEAFLOOR:
sb.append("<gx:altitudeMode>clampToSeaFloor</gx:altitudeMode>");
return;
case GX_RELATIVETOSEAFLOOR:
sb.append("<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>");
return;
case NONE:
return;
default:
throw new IllegalArgumentException("Supported altitude modes are: \n"
+ " For KML profils: CLAMPTOGROUND = 1; RELATIVETOGROUND = 2; ABSOLUTE = 4;\n"
+ "For GX profils: CLAMPTOSEAFLOOR = 8; RELATIVETOSEAFLOOR = 16; \n"
+ " No altitude: NONE = 0");
}
}
|
java
|
public static void append(int altitudeMode, StringBuilder sb) {
switch (altitudeMode) {
case KML_CLAMPTOGROUND:
sb.append("<kml:altitudeMode>clampToGround</kml:altitudeMode>");
return;
case KML_RELATIVETOGROUND:
sb.append("<kml:altitudeMode>relativeToGround</kml:altitudeMode>");
return;
case KML_ABSOLUTE:
sb.append("<kml:altitudeMode>absolute</kml:altitudeMode>");
return;
case GX_CLAMPTOSEAFLOOR:
sb.append("<gx:altitudeMode>clampToSeaFloor</gx:altitudeMode>");
return;
case GX_RELATIVETOSEAFLOOR:
sb.append("<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>");
return;
case NONE:
return;
default:
throw new IllegalArgumentException("Supported altitude modes are: \n"
+ " For KML profils: CLAMPTOGROUND = 1; RELATIVETOGROUND = 2; ABSOLUTE = 4;\n"
+ "For GX profils: CLAMPTOSEAFLOOR = 8; RELATIVETOSEAFLOOR = 16; \n"
+ " No altitude: NONE = 0");
}
}
|
[
"public",
"static",
"void",
"append",
"(",
"int",
"altitudeMode",
",",
"StringBuilder",
"sb",
")",
"{",
"switch",
"(",
"altitudeMode",
")",
"{",
"case",
"KML_CLAMPTOGROUND",
":",
"sb",
".",
"append",
"(",
"\"<kml:altitudeMode>clampToGround</kml:altitudeMode>\"",
")",
";",
"return",
";",
"case",
"KML_RELATIVETOGROUND",
":",
"sb",
".",
"append",
"(",
"\"<kml:altitudeMode>relativeToGround</kml:altitudeMode>\"",
")",
";",
"return",
";",
"case",
"KML_ABSOLUTE",
":",
"sb",
".",
"append",
"(",
"\"<kml:altitudeMode>absolute</kml:altitudeMode>\"",
")",
";",
"return",
";",
"case",
"GX_CLAMPTOSEAFLOOR",
":",
"sb",
".",
"append",
"(",
"\"<gx:altitudeMode>clampToSeaFloor</gx:altitudeMode>\"",
")",
";",
"return",
";",
"case",
"GX_RELATIVETOSEAFLOOR",
":",
"sb",
".",
"append",
"(",
"\"<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>\"",
")",
";",
"return",
";",
"case",
"NONE",
":",
"return",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Supported altitude modes are: \\n\"",
"+",
"\" For KML profils: CLAMPTOGROUND = 1; RELATIVETOGROUND = 2; ABSOLUTE = 4;\\n\"",
"+",
"\"For GX profils: CLAMPTOSEAFLOOR = 8; RELATIVETOSEAFLOOR = 16; \\n\"",
"+",
"\" No altitude: NONE = 0\"",
")",
";",
"}",
"}"
] |
Generate a string value corresponding to the altitude mode.
@param altitudeMode
@param sb
|
[
"Generate",
"a",
"string",
"value",
"corresponding",
"to",
"the",
"altitude",
"mode",
"."
] |
train
|
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/kml/AltitudeMode.java#L73-L98
|
QSFT/Doradus
|
doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java
|
SpiderTransaction.addShardedLinkValue
|
public void addShardedLinkValue(String ownerObjID, FieldDefinition linkDef, String targetObjID, int targetShardNo) {
"""
Add a link value column on behalf of the given owner object, referencing the given
target object ID. This is used when a link is sharded and the owner's shard number
is > 0. The link value column is added to a special term record.
@param ownerObjID Object ID of object owns the link field.
@param linkDef {@link FieldDefinition} of the link field.
@param targetObjID Referenced (target) object ID (owning table is sharded).
@param targetShardNo Shard number of the target object. Must be > 0.
"""
assert linkDef.isSharded();
assert targetShardNo > 0;
addColumn(SpiderService.termsStoreName(linkDef.getTableDef()),
SpiderService.shardedLinkTermRowKey(linkDef, ownerObjID, targetShardNo),
targetObjID);
}
|
java
|
public void addShardedLinkValue(String ownerObjID, FieldDefinition linkDef, String targetObjID, int targetShardNo) {
assert linkDef.isSharded();
assert targetShardNo > 0;
addColumn(SpiderService.termsStoreName(linkDef.getTableDef()),
SpiderService.shardedLinkTermRowKey(linkDef, ownerObjID, targetShardNo),
targetObjID);
}
|
[
"public",
"void",
"addShardedLinkValue",
"(",
"String",
"ownerObjID",
",",
"FieldDefinition",
"linkDef",
",",
"String",
"targetObjID",
",",
"int",
"targetShardNo",
")",
"{",
"assert",
"linkDef",
".",
"isSharded",
"(",
")",
";",
"assert",
"targetShardNo",
">",
"0",
";",
"addColumn",
"(",
"SpiderService",
".",
"termsStoreName",
"(",
"linkDef",
".",
"getTableDef",
"(",
")",
")",
",",
"SpiderService",
".",
"shardedLinkTermRowKey",
"(",
"linkDef",
",",
"ownerObjID",
",",
"targetShardNo",
")",
",",
"targetObjID",
")",
";",
"}"
] |
Add a link value column on behalf of the given owner object, referencing the given
target object ID. This is used when a link is sharded and the owner's shard number
is > 0. The link value column is added to a special term record.
@param ownerObjID Object ID of object owns the link field.
@param linkDef {@link FieldDefinition} of the link field.
@param targetObjID Referenced (target) object ID (owning table is sharded).
@param targetShardNo Shard number of the target object. Must be > 0.
|
[
"Add",
"a",
"link",
"value",
"column",
"on",
"behalf",
"of",
"the",
"given",
"owner",
"object",
"referencing",
"the",
"given",
"target",
"object",
"ID",
".",
"This",
"is",
"used",
"when",
"a",
"link",
"is",
"sharded",
"and",
"the",
"owner",
"s",
"shard",
"number",
"is",
">",
"0",
".",
"The",
"link",
"value",
"column",
"is",
"added",
"to",
"a",
"special",
"term",
"record",
"."
] |
train
|
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L284-L290
|
apache/flink
|
flink-optimizer/src/main/java/org/apache/flink/optimizer/DataStatistics.java
|
DataStatistics.cacheBaseStatistics
|
public void cacheBaseStatistics(BaseStatistics statistics, String identifier) {
"""
Caches the given statistics. They are later retrievable under the given identifier.
@param statistics The statistics to cache.
@param identifier The identifier which may be later used to retrieve the statistics.
"""
synchronized (this.baseStatisticsCache) {
this.baseStatisticsCache.put(identifier, statistics);
}
}
|
java
|
public void cacheBaseStatistics(BaseStatistics statistics, String identifier) {
synchronized (this.baseStatisticsCache) {
this.baseStatisticsCache.put(identifier, statistics);
}
}
|
[
"public",
"void",
"cacheBaseStatistics",
"(",
"BaseStatistics",
"statistics",
",",
"String",
"identifier",
")",
"{",
"synchronized",
"(",
"this",
".",
"baseStatisticsCache",
")",
"{",
"this",
".",
"baseStatisticsCache",
".",
"put",
"(",
"identifier",
",",
"statistics",
")",
";",
"}",
"}"
] |
Caches the given statistics. They are later retrievable under the given identifier.
@param statistics The statistics to cache.
@param identifier The identifier which may be later used to retrieve the statistics.
|
[
"Caches",
"the",
"given",
"statistics",
".",
"They",
"are",
"later",
"retrievable",
"under",
"the",
"given",
"identifier",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-optimizer/src/main/java/org/apache/flink/optimizer/DataStatistics.java#L64-L68
|
matthewhorridge/owlapi-gwt
|
owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLSameIndividualAxiomImpl_CustomFieldSerializer.java
|
OWLSameIndividualAxiomImpl_CustomFieldSerializer.deserializeInstance
|
@Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLSameIndividualAxiomImpl instance) throws SerializationException {
"""
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
"""
deserialize(streamReader, instance);
}
|
java
|
@Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLSameIndividualAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
}
|
[
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLSameIndividualAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
] |
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
|
[
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] |
train
|
https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLSameIndividualAxiomImpl_CustomFieldSerializer.java#L95-L98
|
DataSketches/sketches-core
|
src/main/java/com/yahoo/sketches/sampling/ReservoirLongsSketch.java
|
ReservoirLongsSketch.insertValueAtPosition
|
void insertValueAtPosition(final long value, final int pos) {
"""
Useful during union operation to force-insert a value into the union gadget. Does <em>NOT</em>
increment count of items seen. Cannot insert beyond current number of samples; if reservoir is
not full, use update().
@param value The entry to store in the reservoir
@param pos The position at which to store the entry
"""
if ((pos < 0) || (pos >= getNumSamples())) {
throw new SketchesArgumentException("Insert position must be between 0 and " + getNumSamples()
+ ", inclusive. Received: " + pos);
}
data_[pos] = value;
}
|
java
|
void insertValueAtPosition(final long value, final int pos) {
if ((pos < 0) || (pos >= getNumSamples())) {
throw new SketchesArgumentException("Insert position must be between 0 and " + getNumSamples()
+ ", inclusive. Received: " + pos);
}
data_[pos] = value;
}
|
[
"void",
"insertValueAtPosition",
"(",
"final",
"long",
"value",
",",
"final",
"int",
"pos",
")",
"{",
"if",
"(",
"(",
"pos",
"<",
"0",
")",
"||",
"(",
"pos",
">=",
"getNumSamples",
"(",
")",
")",
")",
"{",
"throw",
"new",
"SketchesArgumentException",
"(",
"\"Insert position must be between 0 and \"",
"+",
"getNumSamples",
"(",
")",
"+",
"\", inclusive. Received: \"",
"+",
"pos",
")",
";",
"}",
"data_",
"[",
"pos",
"]",
"=",
"value",
";",
"}"
] |
Useful during union operation to force-insert a value into the union gadget. Does <em>NOT</em>
increment count of items seen. Cannot insert beyond current number of samples; if reservoir is
not full, use update().
@param value The entry to store in the reservoir
@param pos The position at which to store the entry
|
[
"Useful",
"during",
"union",
"operation",
"to",
"force",
"-",
"insert",
"a",
"value",
"into",
"the",
"union",
"gadget",
".",
"Does",
"<em",
">",
"NOT<",
"/",
"em",
">",
"increment",
"count",
"of",
"items",
"seen",
".",
"Cannot",
"insert",
"beyond",
"current",
"number",
"of",
"samples",
";",
"if",
"reservoir",
"is",
"not",
"full",
"use",
"update",
"()",
"."
] |
train
|
https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/ReservoirLongsSketch.java#L494-L501
|
codeprimate-software/cp-elements
|
src/main/java/org/cp/elements/lang/reflect/MethodInvocation.java
|
MethodInvocation.newMethodInvocation
|
public static MethodInvocation newMethodInvocation(Class<?> type, String methodName, Object... args) {
"""
Factory method used to construct an instance of {@link MethodInvocation} initialized with the given
{@link Class type} on which the {@code methodName named} {@link Method} accepting the given
array of {@link Object arguments} is declared.
The {@link String named} {@link Method} is expected to be a {@link java.lang.reflect.Modifier#STATIC},
{@link Class} member {@link Method}.
@param type {@link Class type} declaring the {@link Method}.
@param methodName {@link String name} of the {@link Method}.
@param args array of {@link Object arguments} passed to the {@link Method}.
@return an instance of {@link MethodInvocation} encapsulating all the necessary details to invoke
the {@link java.lang.reflect.Modifier#STATIC} {@link Method}.
@throws IllegalArgumentException if the {@link Class type} is {@literal null}.
@see #MethodInvocation(Object, Method, Object...)
@see java.lang.Class
"""
Assert.notNull(type, "Class type cannot be null");
return new MethodInvocation(null, ClassUtils.findMethod(type, methodName, args), args);
}
|
java
|
public static MethodInvocation newMethodInvocation(Class<?> type, String methodName, Object... args) {
Assert.notNull(type, "Class type cannot be null");
return new MethodInvocation(null, ClassUtils.findMethod(type, methodName, args), args);
}
|
[
"public",
"static",
"MethodInvocation",
"newMethodInvocation",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"String",
"methodName",
",",
"Object",
"...",
"args",
")",
"{",
"Assert",
".",
"notNull",
"(",
"type",
",",
"\"Class type cannot be null\"",
")",
";",
"return",
"new",
"MethodInvocation",
"(",
"null",
",",
"ClassUtils",
".",
"findMethod",
"(",
"type",
",",
"methodName",
",",
"args",
")",
",",
"args",
")",
";",
"}"
] |
Factory method used to construct an instance of {@link MethodInvocation} initialized with the given
{@link Class type} on which the {@code methodName named} {@link Method} accepting the given
array of {@link Object arguments} is declared.
The {@link String named} {@link Method} is expected to be a {@link java.lang.reflect.Modifier#STATIC},
{@link Class} member {@link Method}.
@param type {@link Class type} declaring the {@link Method}.
@param methodName {@link String name} of the {@link Method}.
@param args array of {@link Object arguments} passed to the {@link Method}.
@return an instance of {@link MethodInvocation} encapsulating all the necessary details to invoke
the {@link java.lang.reflect.Modifier#STATIC} {@link Method}.
@throws IllegalArgumentException if the {@link Class type} is {@literal null}.
@see #MethodInvocation(Object, Method, Object...)
@see java.lang.Class
|
[
"Factory",
"method",
"used",
"to",
"construct",
"an",
"instance",
"of",
"{",
"@link",
"MethodInvocation",
"}",
"initialized",
"with",
"the",
"given",
"{",
"@link",
"Class",
"type",
"}",
"on",
"which",
"the",
"{",
"@code",
"methodName",
"named",
"}",
"{",
"@link",
"Method",
"}",
"accepting",
"the",
"given",
"array",
"of",
"{",
"@link",
"Object",
"arguments",
"}",
"is",
"declared",
"."
] |
train
|
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/reflect/MethodInvocation.java#L99-L103
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/Period.java
|
Period.normalizedStandard
|
public Period normalizedStandard(PeriodType type) {
"""
Normalizes this period using standard rules, assuming a 12 month year,
7 day week, 24 hour day, 60 minute hour and 60 second minute,
providing control over how the result is split into fields.
<p>
This method allows you to normalize a period.
However to achieve this it makes the assumption that all years are
12 months, all weeks are 7 days, all days are 24 hours,
all hours are 60 minutes and all minutes are 60 seconds. This is not
true when daylight savings time is considered, and may also not be true
for some chronologies. However, it is included as it is a useful operation
for many applications and business rules.
<p>
If the period contains years or months, then the months will be
normalized to be between 0 and 11. The days field and below will be
normalized as necessary, however this will not overflow into the months
field. Thus a period of 1 year 15 months will normalize to 2 years 3 months.
But a period of 1 month 40 days will remain as 1 month 40 days.
<p>
The PeriodType parameter controls how the result is created. It allows
you to omit certain fields from the result if desired. For example,
you may not want the result to include weeks, in which case you pass
in <code>PeriodType.yearMonthDayTime()</code>.
@param type the period type of the new period, null means standard type
@return a normalized period equivalent to this period
@throws ArithmeticException if any field is too large to be represented
@throws UnsupportedOperationException if this period contains non-zero
years or months but the specified period type does not support them
@since 1.5
"""
type = DateTimeUtils.getPeriodType(type);
long millis = getMillis(); // no overflow can happen, even with Integer.MAX_VALUEs
millis += (((long) getSeconds()) * ((long) DateTimeConstants.MILLIS_PER_SECOND));
millis += (((long) getMinutes()) * ((long) DateTimeConstants.MILLIS_PER_MINUTE));
millis += (((long) getHours()) * ((long) DateTimeConstants.MILLIS_PER_HOUR));
millis += (((long) getDays()) * ((long) DateTimeConstants.MILLIS_PER_DAY));
millis += (((long) getWeeks()) * ((long) DateTimeConstants.MILLIS_PER_WEEK));
Period result = new Period(millis, type, ISOChronology.getInstanceUTC());
int years = getYears();
int months = getMonths();
if (years != 0 || months != 0) {
long totalMonths = years * 12L + months;
if (type.isSupported(DurationFieldType.YEARS_TYPE)) {
int normalizedYears = FieldUtils.safeToInt(totalMonths / 12);
result = result.withYears(normalizedYears);
totalMonths = totalMonths - (normalizedYears * 12);
}
if (type.isSupported(DurationFieldType.MONTHS_TYPE)) {
int normalizedMonths = FieldUtils.safeToInt(totalMonths);
result = result.withMonths(normalizedMonths);
totalMonths = totalMonths - normalizedMonths;
}
if (totalMonths != 0) {
throw new UnsupportedOperationException("Unable to normalize as PeriodType is missing either years or months but period has a month/year amount: " + toString());
}
}
return result;
}
|
java
|
public Period normalizedStandard(PeriodType type) {
type = DateTimeUtils.getPeriodType(type);
long millis = getMillis(); // no overflow can happen, even with Integer.MAX_VALUEs
millis += (((long) getSeconds()) * ((long) DateTimeConstants.MILLIS_PER_SECOND));
millis += (((long) getMinutes()) * ((long) DateTimeConstants.MILLIS_PER_MINUTE));
millis += (((long) getHours()) * ((long) DateTimeConstants.MILLIS_PER_HOUR));
millis += (((long) getDays()) * ((long) DateTimeConstants.MILLIS_PER_DAY));
millis += (((long) getWeeks()) * ((long) DateTimeConstants.MILLIS_PER_WEEK));
Period result = new Period(millis, type, ISOChronology.getInstanceUTC());
int years = getYears();
int months = getMonths();
if (years != 0 || months != 0) {
long totalMonths = years * 12L + months;
if (type.isSupported(DurationFieldType.YEARS_TYPE)) {
int normalizedYears = FieldUtils.safeToInt(totalMonths / 12);
result = result.withYears(normalizedYears);
totalMonths = totalMonths - (normalizedYears * 12);
}
if (type.isSupported(DurationFieldType.MONTHS_TYPE)) {
int normalizedMonths = FieldUtils.safeToInt(totalMonths);
result = result.withMonths(normalizedMonths);
totalMonths = totalMonths - normalizedMonths;
}
if (totalMonths != 0) {
throw new UnsupportedOperationException("Unable to normalize as PeriodType is missing either years or months but period has a month/year amount: " + toString());
}
}
return result;
}
|
[
"public",
"Period",
"normalizedStandard",
"(",
"PeriodType",
"type",
")",
"{",
"type",
"=",
"DateTimeUtils",
".",
"getPeriodType",
"(",
"type",
")",
";",
"long",
"millis",
"=",
"getMillis",
"(",
")",
";",
"// no overflow can happen, even with Integer.MAX_VALUEs",
"millis",
"+=",
"(",
"(",
"(",
"long",
")",
"getSeconds",
"(",
")",
")",
"*",
"(",
"(",
"long",
")",
"DateTimeConstants",
".",
"MILLIS_PER_SECOND",
")",
")",
";",
"millis",
"+=",
"(",
"(",
"(",
"long",
")",
"getMinutes",
"(",
")",
")",
"*",
"(",
"(",
"long",
")",
"DateTimeConstants",
".",
"MILLIS_PER_MINUTE",
")",
")",
";",
"millis",
"+=",
"(",
"(",
"(",
"long",
")",
"getHours",
"(",
")",
")",
"*",
"(",
"(",
"long",
")",
"DateTimeConstants",
".",
"MILLIS_PER_HOUR",
")",
")",
";",
"millis",
"+=",
"(",
"(",
"(",
"long",
")",
"getDays",
"(",
")",
")",
"*",
"(",
"(",
"long",
")",
"DateTimeConstants",
".",
"MILLIS_PER_DAY",
")",
")",
";",
"millis",
"+=",
"(",
"(",
"(",
"long",
")",
"getWeeks",
"(",
")",
")",
"*",
"(",
"(",
"long",
")",
"DateTimeConstants",
".",
"MILLIS_PER_WEEK",
")",
")",
";",
"Period",
"result",
"=",
"new",
"Period",
"(",
"millis",
",",
"type",
",",
"ISOChronology",
".",
"getInstanceUTC",
"(",
")",
")",
";",
"int",
"years",
"=",
"getYears",
"(",
")",
";",
"int",
"months",
"=",
"getMonths",
"(",
")",
";",
"if",
"(",
"years",
"!=",
"0",
"||",
"months",
"!=",
"0",
")",
"{",
"long",
"totalMonths",
"=",
"years",
"*",
"12L",
"+",
"months",
";",
"if",
"(",
"type",
".",
"isSupported",
"(",
"DurationFieldType",
".",
"YEARS_TYPE",
")",
")",
"{",
"int",
"normalizedYears",
"=",
"FieldUtils",
".",
"safeToInt",
"(",
"totalMonths",
"/",
"12",
")",
";",
"result",
"=",
"result",
".",
"withYears",
"(",
"normalizedYears",
")",
";",
"totalMonths",
"=",
"totalMonths",
"-",
"(",
"normalizedYears",
"*",
"12",
")",
";",
"}",
"if",
"(",
"type",
".",
"isSupported",
"(",
"DurationFieldType",
".",
"MONTHS_TYPE",
")",
")",
"{",
"int",
"normalizedMonths",
"=",
"FieldUtils",
".",
"safeToInt",
"(",
"totalMonths",
")",
";",
"result",
"=",
"result",
".",
"withMonths",
"(",
"normalizedMonths",
")",
";",
"totalMonths",
"=",
"totalMonths",
"-",
"normalizedMonths",
";",
"}",
"if",
"(",
"totalMonths",
"!=",
"0",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Unable to normalize as PeriodType is missing either years or months but period has a month/year amount: \"",
"+",
"toString",
"(",
")",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Normalizes this period using standard rules, assuming a 12 month year,
7 day week, 24 hour day, 60 minute hour and 60 second minute,
providing control over how the result is split into fields.
<p>
This method allows you to normalize a period.
However to achieve this it makes the assumption that all years are
12 months, all weeks are 7 days, all days are 24 hours,
all hours are 60 minutes and all minutes are 60 seconds. This is not
true when daylight savings time is considered, and may also not be true
for some chronologies. However, it is included as it is a useful operation
for many applications and business rules.
<p>
If the period contains years or months, then the months will be
normalized to be between 0 and 11. The days field and below will be
normalized as necessary, however this will not overflow into the months
field. Thus a period of 1 year 15 months will normalize to 2 years 3 months.
But a period of 1 month 40 days will remain as 1 month 40 days.
<p>
The PeriodType parameter controls how the result is created. It allows
you to omit certain fields from the result if desired. For example,
you may not want the result to include weeks, in which case you pass
in <code>PeriodType.yearMonthDayTime()</code>.
@param type the period type of the new period, null means standard type
@return a normalized period equivalent to this period
@throws ArithmeticException if any field is too large to be represented
@throws UnsupportedOperationException if this period contains non-zero
years or months but the specified period type does not support them
@since 1.5
|
[
"Normalizes",
"this",
"period",
"using",
"standard",
"rules",
"assuming",
"a",
"12",
"month",
"year",
"7",
"day",
"week",
"24",
"hour",
"day",
"60",
"minute",
"hour",
"and",
"60",
"second",
"minute",
"providing",
"control",
"over",
"how",
"the",
"result",
"is",
"split",
"into",
"fields",
".",
"<p",
">",
"This",
"method",
"allows",
"you",
"to",
"normalize",
"a",
"period",
".",
"However",
"to",
"achieve",
"this",
"it",
"makes",
"the",
"assumption",
"that",
"all",
"years",
"are",
"12",
"months",
"all",
"weeks",
"are",
"7",
"days",
"all",
"days",
"are",
"24",
"hours",
"all",
"hours",
"are",
"60",
"minutes",
"and",
"all",
"minutes",
"are",
"60",
"seconds",
".",
"This",
"is",
"not",
"true",
"when",
"daylight",
"savings",
"time",
"is",
"considered",
"and",
"may",
"also",
"not",
"be",
"true",
"for",
"some",
"chronologies",
".",
"However",
"it",
"is",
"included",
"as",
"it",
"is",
"a",
"useful",
"operation",
"for",
"many",
"applications",
"and",
"business",
"rules",
".",
"<p",
">",
"If",
"the",
"period",
"contains",
"years",
"or",
"months",
"then",
"the",
"months",
"will",
"be",
"normalized",
"to",
"be",
"between",
"0",
"and",
"11",
".",
"The",
"days",
"field",
"and",
"below",
"will",
"be",
"normalized",
"as",
"necessary",
"however",
"this",
"will",
"not",
"overflow",
"into",
"the",
"months",
"field",
".",
"Thus",
"a",
"period",
"of",
"1",
"year",
"15",
"months",
"will",
"normalize",
"to",
"2",
"years",
"3",
"months",
".",
"But",
"a",
"period",
"of",
"1",
"month",
"40",
"days",
"will",
"remain",
"as",
"1",
"month",
"40",
"days",
".",
"<p",
">",
"The",
"PeriodType",
"parameter",
"controls",
"how",
"the",
"result",
"is",
"created",
".",
"It",
"allows",
"you",
"to",
"omit",
"certain",
"fields",
"from",
"the",
"result",
"if",
"desired",
".",
"For",
"example",
"you",
"may",
"not",
"want",
"the",
"result",
"to",
"include",
"weeks",
"in",
"which",
"case",
"you",
"pass",
"in",
"<code",
">",
"PeriodType",
".",
"yearMonthDayTime",
"()",
"<",
"/",
"code",
">",
"."
] |
train
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Period.java#L1636-L1664
|
googleapis/cloud-bigtable-client
|
bigtable-client-core-parent/bigtable-hbase/src/main/java/org/apache/hadoop/hbase/client/AbstractBigtableAdmin.java
|
AbstractBigtableAdmin.createTable
|
protected void createTable(TableName tableName, CreateTableRequest request)
throws IOException {
"""
Creates a Table.
@param tableName a {@link TableName} object.
@param request a {@link CreateTableRequest} object to send.
@throws java.io.IOException if any.
"""
try {
tableAdminClientWrapper.createTable(request);
} catch (Throwable throwable) {
throw convertToTableExistsException(tableName, throwable);
}
}
|
java
|
protected void createTable(TableName tableName, CreateTableRequest request)
throws IOException {
try {
tableAdminClientWrapper.createTable(request);
} catch (Throwable throwable) {
throw convertToTableExistsException(tableName, throwable);
}
}
|
[
"protected",
"void",
"createTable",
"(",
"TableName",
"tableName",
",",
"CreateTableRequest",
"request",
")",
"throws",
"IOException",
"{",
"try",
"{",
"tableAdminClientWrapper",
".",
"createTable",
"(",
"request",
")",
";",
"}",
"catch",
"(",
"Throwable",
"throwable",
")",
"{",
"throw",
"convertToTableExistsException",
"(",
"tableName",
",",
"throwable",
")",
";",
"}",
"}"
] |
Creates a Table.
@param tableName a {@link TableName} object.
@param request a {@link CreateTableRequest} object to send.
@throws java.io.IOException if any.
|
[
"Creates",
"a",
"Table",
"."
] |
train
|
https://github.com/googleapis/cloud-bigtable-client/blob/53543f36e4d6f9ed1963640d91a35be2a2047656/bigtable-client-core-parent/bigtable-hbase/src/main/java/org/apache/hadoop/hbase/client/AbstractBigtableAdmin.java#L332-L339
|
ops4j/org.ops4j.pax.logging
|
pax-logging-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
|
AbstractLogger.throwing
|
protected <T extends Throwable> T throwing(final String fqcn, final Level level, final T t) {
"""
Logs a Throwable to be thrown.
@param <T> the type of the Throwable.
@param fqcn the fully qualified class name of this Logger implementation.
@param level The logging Level.
@param t The Throwable.
@return the Throwable.
"""
if (isEnabled(level, THROWING_MARKER, (Object) null, null)) {
logMessageSafely(fqcn, level, THROWING_MARKER, throwingMsg(t), t);
}
return t;
}
|
java
|
protected <T extends Throwable> T throwing(final String fqcn, final Level level, final T t) {
if (isEnabled(level, THROWING_MARKER, (Object) null, null)) {
logMessageSafely(fqcn, level, THROWING_MARKER, throwingMsg(t), t);
}
return t;
}
|
[
"protected",
"<",
"T",
"extends",
"Throwable",
">",
"T",
"throwing",
"(",
"final",
"String",
"fqcn",
",",
"final",
"Level",
"level",
",",
"final",
"T",
"t",
")",
"{",
"if",
"(",
"isEnabled",
"(",
"level",
",",
"THROWING_MARKER",
",",
"(",
"Object",
")",
"null",
",",
"null",
")",
")",
"{",
"logMessageSafely",
"(",
"fqcn",
",",
"level",
",",
"THROWING_MARKER",
",",
"throwingMsg",
"(",
"t",
")",
",",
"t",
")",
";",
"}",
"return",
"t",
";",
"}"
] |
Logs a Throwable to be thrown.
@param <T> the type of the Throwable.
@param fqcn the fully qualified class name of this Logger implementation.
@param level The logging Level.
@param t The Throwable.
@return the Throwable.
|
[
"Logs",
"a",
"Throwable",
"to",
"be",
"thrown",
"."
] |
train
|
https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java#L2160-L2165
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-ip/src/main/java/net/minidev/ovh/api/ApiOvhIp.java
|
ApiOvhIp.ip_firewall_ipOnFirewall_GET
|
public OvhFirewallIp ip_firewall_ipOnFirewall_GET(String ip, String ipOnFirewall) throws IOException {
"""
Get this object properties
REST: GET /ip/{ip}/firewall/{ipOnFirewall}
@param ip [required]
@param ipOnFirewall [required]
"""
String qPath = "/ip/{ip}/firewall/{ipOnFirewall}";
StringBuilder sb = path(qPath, ip, ipOnFirewall);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFirewallIp.class);
}
|
java
|
public OvhFirewallIp ip_firewall_ipOnFirewall_GET(String ip, String ipOnFirewall) throws IOException {
String qPath = "/ip/{ip}/firewall/{ipOnFirewall}";
StringBuilder sb = path(qPath, ip, ipOnFirewall);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFirewallIp.class);
}
|
[
"public",
"OvhFirewallIp",
"ip_firewall_ipOnFirewall_GET",
"(",
"String",
"ip",
",",
"String",
"ipOnFirewall",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/ip/{ip}/firewall/{ipOnFirewall}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"ip",
",",
"ipOnFirewall",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhFirewallIp",
".",
"class",
")",
";",
"}"
] |
Get this object properties
REST: GET /ip/{ip}/firewall/{ipOnFirewall}
@param ip [required]
@param ipOnFirewall [required]
|
[
"Get",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-ip/src/main/java/net/minidev/ovh/api/ApiOvhIp.java#L1005-L1010
|
alrocar/POIProxy
|
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/configuration/ServiceConfigurationManager.java
|
ServiceConfigurationManager.getServiceAsJSON
|
public String getServiceAsJSON(String id) {
"""
Returns the content of the json document describing a service given its
id
@param id
The id of the service. Usually the name of the json document
@return The content of the json document
"""
String path = this.registeredConfigurations.get(id);
if (path == null) {
return null;
}
// cargar fichero de disco obtener el json y parsearlo
File f = new File(CONFIGURATION_DIR + File.separator + path);
FileInputStream fis = null;
InputStream in = null;
OutputStream out = null;
String res = null;
try {
fis = new FileInputStream(f);
in = new BufferedInputStream(fis, Constants.IO_BUFFER_SIZE);
final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
out = new BufferedOutputStream(dataStream, Constants.IO_BUFFER_SIZE);
byte[] b = new byte[8 * 1024];
int read;
while ((read = in.read(b)) != -1) {
out.write(b, 0, read);
}
out.flush();
res = new String(dataStream.toByteArray());
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
Constants.closeStream(fis);
Constants.closeStream(in);
Constants.closeStream(out);
}
return res;
}
|
java
|
public String getServiceAsJSON(String id) {
String path = this.registeredConfigurations.get(id);
if (path == null) {
return null;
}
// cargar fichero de disco obtener el json y parsearlo
File f = new File(CONFIGURATION_DIR + File.separator + path);
FileInputStream fis = null;
InputStream in = null;
OutputStream out = null;
String res = null;
try {
fis = new FileInputStream(f);
in = new BufferedInputStream(fis, Constants.IO_BUFFER_SIZE);
final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
out = new BufferedOutputStream(dataStream, Constants.IO_BUFFER_SIZE);
byte[] b = new byte[8 * 1024];
int read;
while ((read = in.read(b)) != -1) {
out.write(b, 0, read);
}
out.flush();
res = new String(dataStream.toByteArray());
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
Constants.closeStream(fis);
Constants.closeStream(in);
Constants.closeStream(out);
}
return res;
}
|
[
"public",
"String",
"getServiceAsJSON",
"(",
"String",
"id",
")",
"{",
"String",
"path",
"=",
"this",
".",
"registeredConfigurations",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// cargar fichero de disco obtener el json y parsearlo",
"File",
"f",
"=",
"new",
"File",
"(",
"CONFIGURATION_DIR",
"+",
"File",
".",
"separator",
"+",
"path",
")",
";",
"FileInputStream",
"fis",
"=",
"null",
";",
"InputStream",
"in",
"=",
"null",
";",
"OutputStream",
"out",
"=",
"null",
";",
"String",
"res",
"=",
"null",
";",
"try",
"{",
"fis",
"=",
"new",
"FileInputStream",
"(",
"f",
")",
";",
"in",
"=",
"new",
"BufferedInputStream",
"(",
"fis",
",",
"Constants",
".",
"IO_BUFFER_SIZE",
")",
";",
"final",
"ByteArrayOutputStream",
"dataStream",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"out",
"=",
"new",
"BufferedOutputStream",
"(",
"dataStream",
",",
"Constants",
".",
"IO_BUFFER_SIZE",
")",
";",
"byte",
"[",
"]",
"b",
"=",
"new",
"byte",
"[",
"8",
"*",
"1024",
"]",
";",
"int",
"read",
";",
"while",
"(",
"(",
"read",
"=",
"in",
".",
"read",
"(",
"b",
")",
")",
"!=",
"-",
"1",
")",
"{",
"out",
".",
"write",
"(",
"b",
",",
"0",
",",
"read",
")",
";",
"}",
"out",
".",
"flush",
"(",
")",
";",
"res",
"=",
"new",
"String",
"(",
"dataStream",
".",
"toByteArray",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"null",
";",
"}",
"finally",
"{",
"Constants",
".",
"closeStream",
"(",
"fis",
")",
";",
"Constants",
".",
"closeStream",
"(",
"in",
")",
";",
"Constants",
".",
"closeStream",
"(",
"out",
")",
";",
"}",
"return",
"res",
";",
"}"
] |
Returns the content of the json document describing a service given its
id
@param id
The id of the service. Usually the name of the json document
@return The content of the json document
|
[
"Returns",
"the",
"content",
"of",
"the",
"json",
"document",
"describing",
"a",
"service",
"given",
"its",
"id"
] |
train
|
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/configuration/ServiceConfigurationManager.java#L198-L234
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java
|
VirtualNetworkGatewaysInner.getVpnclientIpsecParameters
|
public VpnClientIPsecParametersInner getVpnclientIpsecParameters(String resourceGroupName, String virtualNetworkGatewayName) {
"""
The Get VpnclientIpsecParameters operation retrieves information about the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The virtual network gateway name.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VpnClientIPsecParametersInner object if successful.
"""
return getVpnclientIpsecParametersWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).toBlocking().last().body();
}
|
java
|
public VpnClientIPsecParametersInner getVpnclientIpsecParameters(String resourceGroupName, String virtualNetworkGatewayName) {
return getVpnclientIpsecParametersWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).toBlocking().last().body();
}
|
[
"public",
"VpnClientIPsecParametersInner",
"getVpnclientIpsecParameters",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayName",
")",
"{",
"return",
"getVpnclientIpsecParametersWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayName",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
The Get VpnclientIpsecParameters operation retrieves information about the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The virtual network gateway name.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VpnClientIPsecParametersInner object if successful.
|
[
"The",
"Get",
"VpnclientIpsecParameters",
"operation",
"retrieves",
"information",
"about",
"the",
"vpnclient",
"ipsec",
"policy",
"for",
"P2S",
"client",
"of",
"virtual",
"network",
"gateway",
"in",
"the",
"specified",
"resource",
"group",
"through",
"Network",
"resource",
"provider",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java#L2826-L2828
|
mapbox/mapbox-navigation-android
|
libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/MapboxOfflineRouter.java
|
MapboxOfflineRouter.downloadTiles
|
public void downloadTiles(OfflineTiles offlineTiles, RouteTileDownloadListener listener) {
"""
Starts the download of tiles specified by the provided {@link OfflineTiles} object.
@param offlineTiles object specifying parameters for the tile request
@param listener which is updated on error, on progress update and on completion
"""
new RouteTileDownloader(offlineNavigator, tilePath, listener).startDownload(offlineTiles);
}
|
java
|
public void downloadTiles(OfflineTiles offlineTiles, RouteTileDownloadListener listener) {
new RouteTileDownloader(offlineNavigator, tilePath, listener).startDownload(offlineTiles);
}
|
[
"public",
"void",
"downloadTiles",
"(",
"OfflineTiles",
"offlineTiles",
",",
"RouteTileDownloadListener",
"listener",
")",
"{",
"new",
"RouteTileDownloader",
"(",
"offlineNavigator",
",",
"tilePath",
",",
"listener",
")",
".",
"startDownload",
"(",
"offlineTiles",
")",
";",
"}"
] |
Starts the download of tiles specified by the provided {@link OfflineTiles} object.
@param offlineTiles object specifying parameters for the tile request
@param listener which is updated on error, on progress update and on completion
|
[
"Starts",
"the",
"download",
"of",
"tiles",
"specified",
"by",
"the",
"provided",
"{",
"@link",
"OfflineTiles",
"}",
"object",
"."
] |
train
|
https://github.com/mapbox/mapbox-navigation-android/blob/375a89c017d360b9defc2c90d0c03468165162ec/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/MapboxOfflineRouter.java#L77-L79
|
xwiki/xwiki-commons
|
xwiki-commons-core/xwiki-commons-extension/xwiki-commons-extension-api/src/main/java/org/xwiki/extension/repository/internal/AbstractCachedExtensionRepository.java
|
AbstractCachedExtensionRepository.addCachedExtensionVersion
|
protected void addCachedExtensionVersion(String feature, E extension) {
"""
Register extension in all caches.
@param feature the feature
@param extension the extension
"""
// versions
List<E> versions = this.extensionsVersions.get(feature);
if (versions == null) {
versions = new ArrayList<E>();
this.extensionsVersions.put(feature, versions);
versions.add(extension);
} else {
int index = 0;
while (index < versions.size()
&& extension.getId().getVersion().compareTo(versions.get(index).getId().getVersion()) < 0) {
++index;
}
versions.add(index, extension);
}
}
|
java
|
protected void addCachedExtensionVersion(String feature, E extension)
{
// versions
List<E> versions = this.extensionsVersions.get(feature);
if (versions == null) {
versions = new ArrayList<E>();
this.extensionsVersions.put(feature, versions);
versions.add(extension);
} else {
int index = 0;
while (index < versions.size()
&& extension.getId().getVersion().compareTo(versions.get(index).getId().getVersion()) < 0) {
++index;
}
versions.add(index, extension);
}
}
|
[
"protected",
"void",
"addCachedExtensionVersion",
"(",
"String",
"feature",
",",
"E",
"extension",
")",
"{",
"// versions",
"List",
"<",
"E",
">",
"versions",
"=",
"this",
".",
"extensionsVersions",
".",
"get",
"(",
"feature",
")",
";",
"if",
"(",
"versions",
"==",
"null",
")",
"{",
"versions",
"=",
"new",
"ArrayList",
"<",
"E",
">",
"(",
")",
";",
"this",
".",
"extensionsVersions",
".",
"put",
"(",
"feature",
",",
"versions",
")",
";",
"versions",
".",
"add",
"(",
"extension",
")",
";",
"}",
"else",
"{",
"int",
"index",
"=",
"0",
";",
"while",
"(",
"index",
"<",
"versions",
".",
"size",
"(",
")",
"&&",
"extension",
".",
"getId",
"(",
")",
".",
"getVersion",
"(",
")",
".",
"compareTo",
"(",
"versions",
".",
"get",
"(",
"index",
")",
".",
"getId",
"(",
")",
".",
"getVersion",
"(",
")",
")",
"<",
"0",
")",
"{",
"++",
"index",
";",
"}",
"versions",
".",
"add",
"(",
"index",
",",
"extension",
")",
";",
"}",
"}"
] |
Register extension in all caches.
@param feature the feature
@param extension the extension
|
[
"Register",
"extension",
"in",
"all",
"caches",
"."
] |
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/repository/internal/AbstractCachedExtensionRepository.java#L121-L140
|
lessthanoptimal/ejml
|
main/ejml-ddense/src/org/ejml/dense/block/decomposition/bidiagonal/BidiagonalHelper_DDRB.java
|
BidiagonalHelper_DDRB.bidiagOuterBlocks
|
public static boolean bidiagOuterBlocks( final int blockLength ,
final DSubmatrixD1 A ,
final double gammasU[],
final double gammasV[]) {
"""
Performs a standard bidiagonal decomposition just on the outer blocks of the provided matrix
@param blockLength
@param A
@param gammasU
"""
// System.out.println("---------- Orig");
// A.original.print();
int width = Math.min(blockLength,A.col1-A.col0);
int height = Math.min(blockLength,A.row1-A.row0);
int min = Math.min(width,height);
for( int i = 0; i < min; i++ ) {
//--- Apply reflector to the column
// compute the householder vector
if (!computeHouseHolderCol(blockLength, A, gammasU, i))
return false;
// apply to rest of the columns in the column block
rank1UpdateMultR_Col(blockLength,A,i,gammasU[A.col0+i]);
// apply to the top row block
rank1UpdateMultR_TopRow(blockLength,A,i,gammasU[A.col0+i]);
System.out.println("After column stuff");
A.original.print();
//-- Apply reflector to the row
if(!computeHouseHolderRow(blockLength,A,gammasV,i))
return false;
// apply to rest of the rows in the row block
rank1UpdateMultL_Row(blockLength,A,i,i+1,gammasV[A.row0+i]);
System.out.println("After update row");
A.original.print();
// apply to the left column block
// TODO THIS WON'T WORK!!!!!!!!!!!!!
// Needs the whole matrix to have been updated by the left reflector to compute the correct solution
// rank1UpdateMultL_LeftCol(blockLength,A,i,i+1,gammasV[A.row0+i]);
System.out.println("After row stuff");
A.original.print();
}
return true;
}
|
java
|
public static boolean bidiagOuterBlocks( final int blockLength ,
final DSubmatrixD1 A ,
final double gammasU[],
final double gammasV[])
{
// System.out.println("---------- Orig");
// A.original.print();
int width = Math.min(blockLength,A.col1-A.col0);
int height = Math.min(blockLength,A.row1-A.row0);
int min = Math.min(width,height);
for( int i = 0; i < min; i++ ) {
//--- Apply reflector to the column
// compute the householder vector
if (!computeHouseHolderCol(blockLength, A, gammasU, i))
return false;
// apply to rest of the columns in the column block
rank1UpdateMultR_Col(blockLength,A,i,gammasU[A.col0+i]);
// apply to the top row block
rank1UpdateMultR_TopRow(blockLength,A,i,gammasU[A.col0+i]);
System.out.println("After column stuff");
A.original.print();
//-- Apply reflector to the row
if(!computeHouseHolderRow(blockLength,A,gammasV,i))
return false;
// apply to rest of the rows in the row block
rank1UpdateMultL_Row(blockLength,A,i,i+1,gammasV[A.row0+i]);
System.out.println("After update row");
A.original.print();
// apply to the left column block
// TODO THIS WON'T WORK!!!!!!!!!!!!!
// Needs the whole matrix to have been updated by the left reflector to compute the correct solution
// rank1UpdateMultL_LeftCol(blockLength,A,i,i+1,gammasV[A.row0+i]);
System.out.println("After row stuff");
A.original.print();
}
return true;
}
|
[
"public",
"static",
"boolean",
"bidiagOuterBlocks",
"(",
"final",
"int",
"blockLength",
",",
"final",
"DSubmatrixD1",
"A",
",",
"final",
"double",
"gammasU",
"[",
"]",
",",
"final",
"double",
"gammasV",
"[",
"]",
")",
"{",
"// System.out.println(\"---------- Orig\");",
"// A.original.print();",
"int",
"width",
"=",
"Math",
".",
"min",
"(",
"blockLength",
",",
"A",
".",
"col1",
"-",
"A",
".",
"col0",
")",
";",
"int",
"height",
"=",
"Math",
".",
"min",
"(",
"blockLength",
",",
"A",
".",
"row1",
"-",
"A",
".",
"row0",
")",
";",
"int",
"min",
"=",
"Math",
".",
"min",
"(",
"width",
",",
"height",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"min",
";",
"i",
"++",
")",
"{",
"//--- Apply reflector to the column",
"// compute the householder vector",
"if",
"(",
"!",
"computeHouseHolderCol",
"(",
"blockLength",
",",
"A",
",",
"gammasU",
",",
"i",
")",
")",
"return",
"false",
";",
"// apply to rest of the columns in the column block",
"rank1UpdateMultR_Col",
"(",
"blockLength",
",",
"A",
",",
"i",
",",
"gammasU",
"[",
"A",
".",
"col0",
"+",
"i",
"]",
")",
";",
"// apply to the top row block",
"rank1UpdateMultR_TopRow",
"(",
"blockLength",
",",
"A",
",",
"i",
",",
"gammasU",
"[",
"A",
".",
"col0",
"+",
"i",
"]",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"After column stuff\"",
")",
";",
"A",
".",
"original",
".",
"print",
"(",
")",
";",
"//-- Apply reflector to the row",
"if",
"(",
"!",
"computeHouseHolderRow",
"(",
"blockLength",
",",
"A",
",",
"gammasV",
",",
"i",
")",
")",
"return",
"false",
";",
"// apply to rest of the rows in the row block",
"rank1UpdateMultL_Row",
"(",
"blockLength",
",",
"A",
",",
"i",
",",
"i",
"+",
"1",
",",
"gammasV",
"[",
"A",
".",
"row0",
"+",
"i",
"]",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"After update row\"",
")",
";",
"A",
".",
"original",
".",
"print",
"(",
")",
";",
"// apply to the left column block",
"// TODO THIS WON'T WORK!!!!!!!!!!!!!",
"// Needs the whole matrix to have been updated by the left reflector to compute the correct solution",
"// rank1UpdateMultL_LeftCol(blockLength,A,i,i+1,gammasV[A.row0+i]);",
"System",
".",
"out",
".",
"println",
"(",
"\"After row stuff\"",
")",
";",
"A",
".",
"original",
".",
"print",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Performs a standard bidiagonal decomposition just on the outer blocks of the provided matrix
@param blockLength
@param A
@param gammasU
|
[
"Performs",
"a",
"standard",
"bidiagonal",
"decomposition",
"just",
"on",
"the",
"outer",
"blocks",
"of",
"the",
"provided",
"matrix"
] |
train
|
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/bidiagonal/BidiagonalHelper_DDRB.java#L39-L88
|
HubSpot/Singularity
|
SingularityClient/src/main/java/com/hubspot/singularity/client/SingularityClient.java
|
SingularityClient.saveRequestGroup
|
public Optional<SingularityRequestGroup> saveRequestGroup(SingularityRequestGroup requestGroup) {
"""
Update or add a {@link SingularityRequestGroup}
@param requestGroup
The request group to update or add
@return
A {@link SingularityRequestGroup} if the update was successful
"""
final Function<String, String> requestUri = (host) -> String.format(REQUEST_GROUPS_FORMAT, getApiBase(host));
return post(requestUri, "request group", Optional.of(requestGroup), Optional.of(SingularityRequestGroup.class));
}
|
java
|
public Optional<SingularityRequestGroup> saveRequestGroup(SingularityRequestGroup requestGroup) {
final Function<String, String> requestUri = (host) -> String.format(REQUEST_GROUPS_FORMAT, getApiBase(host));
return post(requestUri, "request group", Optional.of(requestGroup), Optional.of(SingularityRequestGroup.class));
}
|
[
"public",
"Optional",
"<",
"SingularityRequestGroup",
">",
"saveRequestGroup",
"(",
"SingularityRequestGroup",
"requestGroup",
")",
"{",
"final",
"Function",
"<",
"String",
",",
"String",
">",
"requestUri",
"=",
"(",
"host",
")",
"-",
">",
"String",
".",
"format",
"(",
"REQUEST_GROUPS_FORMAT",
",",
"getApiBase",
"(",
"host",
")",
")",
";",
"return",
"post",
"(",
"requestUri",
",",
"\"request group\"",
",",
"Optional",
".",
"of",
"(",
"requestGroup",
")",
",",
"Optional",
".",
"of",
"(",
"SingularityRequestGroup",
".",
"class",
")",
")",
";",
"}"
] |
Update or add a {@link SingularityRequestGroup}
@param requestGroup
The request group to update or add
@return
A {@link SingularityRequestGroup} if the update was successful
|
[
"Update",
"or",
"add",
"a",
"{",
"@link",
"SingularityRequestGroup",
"}"
] |
train
|
https://github.com/HubSpot/Singularity/blob/384a8c16a10aa076af5ca45c8dfcedab9e5122c8/SingularityClient/src/main/java/com/hubspot/singularity/client/SingularityClient.java#L1418-L1422
|
Azure/azure-sdk-for-java
|
iotcentral/resource-manager/v2017_07_01_privatepreview/src/main/java/com/microsoft/azure/management/iotcentral/v2017_07_01_privatepreview/implementation/AppsInner.java
|
AppsInner.createOrUpdate
|
public AppInner createOrUpdate(String resourceGroupName, String resourceName, AppInner app) {
"""
Create or update the metadata of an IoT Central application. The usual pattern to modify a property is to retrieve the IoT Central application metadata and security metadata, and then combine them with the modified values in a new body to update the IoT Central application.
@param resourceGroupName The name of the resource group that contains the IoT Central application.
@param resourceName The ARM resource name of the IoT Central application.
@param app The IoT Central application metadata and security metadata.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorDetailsException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the AppInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, resourceName, app).toBlocking().last().body();
}
|
java
|
public AppInner createOrUpdate(String resourceGroupName, String resourceName, AppInner app) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, resourceName, app).toBlocking().last().body();
}
|
[
"public",
"AppInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"AppInner",
"app",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"app",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Create or update the metadata of an IoT Central application. The usual pattern to modify a property is to retrieve the IoT Central application metadata and security metadata, and then combine them with the modified values in a new body to update the IoT Central application.
@param resourceGroupName The name of the resource group that contains the IoT Central application.
@param resourceName The ARM resource name of the IoT Central application.
@param app The IoT Central application metadata and security metadata.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorDetailsException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the AppInner object if successful.
|
[
"Create",
"or",
"update",
"the",
"metadata",
"of",
"an",
"IoT",
"Central",
"application",
".",
"The",
"usual",
"pattern",
"to",
"modify",
"a",
"property",
"is",
"to",
"retrieve",
"the",
"IoT",
"Central",
"application",
"metadata",
"and",
"security",
"metadata",
"and",
"then",
"combine",
"them",
"with",
"the",
"modified",
"values",
"in",
"a",
"new",
"body",
"to",
"update",
"the",
"IoT",
"Central",
"application",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/iotcentral/resource-manager/v2017_07_01_privatepreview/src/main/java/com/microsoft/azure/management/iotcentral/v2017_07_01_privatepreview/implementation/AppsInner.java#L218-L220
|
jeluard/semantic-versioning
|
api/src/main/java/org/osjava/jardiff/Tools.java
|
Tools.isClassAccessChange
|
public static boolean isClassAccessChange(final int oldAccess, final int newAccess) {
"""
Returns whether a class's newAccess is incompatible with oldAccess
following <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html">Java Language Specification, Java SE 7 Edition</a>:
<ul>
<li><a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.4.1">13.4.1 abstract Classes</a><ul>
<li>If a class that was not declared abstract is changed to be declared abstract,
then pre-existing binaries that attempt to create new instances of that class
will throw either an InstantiationError at link time,
or (if a reflective method is used) an InstantiationException at run time.
Such changes <b>break backward compatibility</b>!</li>
<li>Changing a class that is declared abstract to no longer be declared abstract
<b>does not break compatibility</b> with pre-existing binaries.</li>
</ul></li>
<li><a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.4.2">13.4.2 final Classes</a><ul>
<li>If a class that was not declared final is changed to be declared final,
then a VerifyError is thrown if a binary of a pre-existing subclass of this class is loaded,
because final classes can have no subclasses.
Such changes <b>break functional backward compatibility</b>!</li>
<li>Changing a class that is declared final to no longer be declared final
<b>does not break compatibility</b> with pre-existing binaries.</li>
</ul></li>
</ul>
@param oldAccess
@param newAccess
@return
"""
if ( not(oldAccess, Opcodes.ACC_ABSTRACT) && has(newAccess, Opcodes.ACC_ABSTRACT) ) {
return true; // 13.4.1 #1
} else if ( not(oldAccess, Opcodes.ACC_FINAL) && has(newAccess, Opcodes.ACC_FINAL) ) {
return true; // 13.4.2 #1
} else {
final int compatibleChanges = Opcodes.ACC_ABSTRACT | // 13.4.1 #2
Opcodes.ACC_FINAL ; // 13.4.2 #2
// FIXME Opcodes.ACC_VOLATILE ?
final int oldAccess2 = oldAccess & ~compatibleChanges;
final int newAccess2 = newAccess & ~compatibleChanges;
return oldAccess2 != newAccess2;
}
}
|
java
|
public static boolean isClassAccessChange(final int oldAccess, final int newAccess) {
if ( not(oldAccess, Opcodes.ACC_ABSTRACT) && has(newAccess, Opcodes.ACC_ABSTRACT) ) {
return true; // 13.4.1 #1
} else if ( not(oldAccess, Opcodes.ACC_FINAL) && has(newAccess, Opcodes.ACC_FINAL) ) {
return true; // 13.4.2 #1
} else {
final int compatibleChanges = Opcodes.ACC_ABSTRACT | // 13.4.1 #2
Opcodes.ACC_FINAL ; // 13.4.2 #2
// FIXME Opcodes.ACC_VOLATILE ?
final int oldAccess2 = oldAccess & ~compatibleChanges;
final int newAccess2 = newAccess & ~compatibleChanges;
return oldAccess2 != newAccess2;
}
}
|
[
"public",
"static",
"boolean",
"isClassAccessChange",
"(",
"final",
"int",
"oldAccess",
",",
"final",
"int",
"newAccess",
")",
"{",
"if",
"(",
"not",
"(",
"oldAccess",
",",
"Opcodes",
".",
"ACC_ABSTRACT",
")",
"&&",
"has",
"(",
"newAccess",
",",
"Opcodes",
".",
"ACC_ABSTRACT",
")",
")",
"{",
"return",
"true",
";",
"// 13.4.1 #1",
"}",
"else",
"if",
"(",
"not",
"(",
"oldAccess",
",",
"Opcodes",
".",
"ACC_FINAL",
")",
"&&",
"has",
"(",
"newAccess",
",",
"Opcodes",
".",
"ACC_FINAL",
")",
")",
"{",
"return",
"true",
";",
"// 13.4.2 #1",
"}",
"else",
"{",
"final",
"int",
"compatibleChanges",
"=",
"Opcodes",
".",
"ACC_ABSTRACT",
"|",
"// 13.4.1 #2",
"Opcodes",
".",
"ACC_FINAL",
";",
"// 13.4.2 #2",
"// FIXME Opcodes.ACC_VOLATILE ?",
"final",
"int",
"oldAccess2",
"=",
"oldAccess",
"&",
"~",
"compatibleChanges",
";",
"final",
"int",
"newAccess2",
"=",
"newAccess",
"&",
"~",
"compatibleChanges",
";",
"return",
"oldAccess2",
"!=",
"newAccess2",
";",
"}",
"}"
] |
Returns whether a class's newAccess is incompatible with oldAccess
following <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html">Java Language Specification, Java SE 7 Edition</a>:
<ul>
<li><a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.4.1">13.4.1 abstract Classes</a><ul>
<li>If a class that was not declared abstract is changed to be declared abstract,
then pre-existing binaries that attempt to create new instances of that class
will throw either an InstantiationError at link time,
or (if a reflective method is used) an InstantiationException at run time.
Such changes <b>break backward compatibility</b>!</li>
<li>Changing a class that is declared abstract to no longer be declared abstract
<b>does not break compatibility</b> with pre-existing binaries.</li>
</ul></li>
<li><a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.4.2">13.4.2 final Classes</a><ul>
<li>If a class that was not declared final is changed to be declared final,
then a VerifyError is thrown if a binary of a pre-existing subclass of this class is loaded,
because final classes can have no subclasses.
Such changes <b>break functional backward compatibility</b>!</li>
<li>Changing a class that is declared final to no longer be declared final
<b>does not break compatibility</b> with pre-existing binaries.</li>
</ul></li>
</ul>
@param oldAccess
@param newAccess
@return
|
[
"Returns",
"whether",
"a",
"class",
"s",
"newAccess",
"is",
"incompatible",
"with",
"oldAccess",
"following",
"<a",
"href",
"=",
"http",
":",
"//",
"docs",
".",
"oracle",
".",
"com",
"/",
"javase",
"/",
"specs",
"/",
"jls",
"/",
"se7",
"/",
"html",
"/",
"jls",
"-",
"13",
".",
"html",
">",
"Java",
"Language",
"Specification",
"Java",
"SE",
"7",
"Edition<",
"/",
"a",
">",
":",
"<ul",
">",
"<li",
">",
"<a",
"href",
"=",
"http",
":",
"//",
"docs",
".",
"oracle",
".",
"com",
"/",
"javase",
"/",
"specs",
"/",
"jls",
"/",
"se7",
"/",
"html",
"/",
"jls",
"-",
"13",
".",
"html#jls",
"-",
"13",
".",
"4",
".",
"1",
">",
"13",
".",
"4",
".",
"1",
"abstract",
"Classes<",
"/",
"a",
">",
"<ul",
">",
"<li",
">",
"If",
"a",
"class",
"that",
"was",
"not",
"declared",
"abstract",
"is",
"changed",
"to",
"be",
"declared",
"abstract",
"then",
"pre",
"-",
"existing",
"binaries",
"that",
"attempt",
"to",
"create",
"new",
"instances",
"of",
"that",
"class",
"will",
"throw",
"either",
"an",
"InstantiationError",
"at",
"link",
"time",
"or",
"(",
"if",
"a",
"reflective",
"method",
"is",
"used",
")",
"an",
"InstantiationException",
"at",
"run",
"time",
".",
"Such",
"changes",
"<b",
">",
"break",
"backward",
"compatibility<",
"/",
"b",
">",
"!<",
"/",
"li",
">",
"<li",
">",
"Changing",
"a",
"class",
"that",
"is",
"declared",
"abstract",
"to",
"no",
"longer",
"be",
"declared",
"abstract",
"<b",
">",
"does",
"not",
"break",
"compatibility<",
"/",
"b",
">",
"with",
"pre",
"-",
"existing",
"binaries",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<a",
"href",
"=",
"http",
":",
"//",
"docs",
".",
"oracle",
".",
"com",
"/",
"javase",
"/",
"specs",
"/",
"jls",
"/",
"se7",
"/",
"html",
"/",
"jls",
"-",
"13",
".",
"html#jls",
"-",
"13",
".",
"4",
".",
"2",
">",
"13",
".",
"4",
".",
"2",
"final",
"Classes<",
"/",
"a",
">",
"<ul",
">",
"<li",
">",
"If",
"a",
"class",
"that",
"was",
"not",
"declared",
"final",
"is",
"changed",
"to",
"be",
"declared",
"final",
"then",
"a",
"VerifyError",
"is",
"thrown",
"if",
"a",
"binary",
"of",
"a",
"pre",
"-",
"existing",
"subclass",
"of",
"this",
"class",
"is",
"loaded",
"because",
"final",
"classes",
"can",
"have",
"no",
"subclasses",
".",
"Such",
"changes",
"<b",
">",
"break",
"functional",
"backward",
"compatibility<",
"/",
"b",
">",
"!<",
"/",
"li",
">",
"<li",
">",
"Changing",
"a",
"class",
"that",
"is",
"declared",
"final",
"to",
"no",
"longer",
"be",
"declared",
"final",
"<b",
">",
"does",
"not",
"break",
"compatibility<",
"/",
"b",
">",
"with",
"pre",
"-",
"existing",
"binaries",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">"
] |
train
|
https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/Tools.java#L115-L128
|
liferay/com-liferay-commerce
|
commerce-account-service/src/main/java/com/liferay/commerce/account/service/persistence/impl/CommerceAccountPersistenceImpl.java
|
CommerceAccountPersistenceImpl.findByU_T
|
@Override
public List<CommerceAccount> findByU_T(long userId, int type, int start,
int end) {
"""
Returns a range of all the commerce accounts where userId = ? and type = ?.
<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 CommerceAccountModelImpl}. 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 userId the user ID
@param type the type
@param start the lower bound of the range of commerce accounts
@param end the upper bound of the range of commerce accounts (not inclusive)
@return the range of matching commerce accounts
"""
return findByU_T(userId, type, start, end, null);
}
|
java
|
@Override
public List<CommerceAccount> findByU_T(long userId, int type, int start,
int end) {
return findByU_T(userId, type, start, end, null);
}
|
[
"@",
"Override",
"public",
"List",
"<",
"CommerceAccount",
">",
"findByU_T",
"(",
"long",
"userId",
",",
"int",
"type",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findByU_T",
"(",
"userId",
",",
"type",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] |
Returns a range of all the commerce accounts where userId = ? and type = ?.
<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 CommerceAccountModelImpl}. 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 userId the user ID
@param type the type
@param start the lower bound of the range of commerce accounts
@param end the upper bound of the range of commerce accounts (not inclusive)
@return the range of matching commerce accounts
|
[
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"accounts",
"where",
"userId",
"=",
"?",
";",
"and",
"type",
"=",
"?",
";",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-account-service/src/main/java/com/liferay/commerce/account/service/persistence/impl/CommerceAccountPersistenceImpl.java#L1018-L1022
|
xwiki/xwiki-rendering
|
xwiki-rendering-macros/xwiki-rendering-macro-content/src/main/java/org/xwiki/rendering/internal/macro/content/ContentMacro.java
|
ContentMacro.getSyntaxParser
|
protected Parser getSyntaxParser(Syntax syntax) throws MacroExecutionException {
"""
Get the parser for the passed Syntax.
@param syntax the Syntax for which to find the Parser
@return the matching Parser that can be used to parse content in the passed Syntax
@throws MacroExecutionException if there's no Parser in the system for the passed Syntax
"""
if (this.componentManager.hasComponent(Parser.class, syntax.toIdString())) {
try {
return this.componentManager.getInstance(Parser.class, syntax.toIdString());
} catch (ComponentLookupException e) {
throw new MacroExecutionException(
String.format("Failed to lookup Parser for syntax [%s]", syntax.toIdString()), e);
}
} else {
throw new MacroExecutionException(String.format("Cannot find Parser for syntax [%s]", syntax.toIdString()));
}
}
|
java
|
protected Parser getSyntaxParser(Syntax syntax) throws MacroExecutionException
{
if (this.componentManager.hasComponent(Parser.class, syntax.toIdString())) {
try {
return this.componentManager.getInstance(Parser.class, syntax.toIdString());
} catch (ComponentLookupException e) {
throw new MacroExecutionException(
String.format("Failed to lookup Parser for syntax [%s]", syntax.toIdString()), e);
}
} else {
throw new MacroExecutionException(String.format("Cannot find Parser for syntax [%s]", syntax.toIdString()));
}
}
|
[
"protected",
"Parser",
"getSyntaxParser",
"(",
"Syntax",
"syntax",
")",
"throws",
"MacroExecutionException",
"{",
"if",
"(",
"this",
".",
"componentManager",
".",
"hasComponent",
"(",
"Parser",
".",
"class",
",",
"syntax",
".",
"toIdString",
"(",
")",
")",
")",
"{",
"try",
"{",
"return",
"this",
".",
"componentManager",
".",
"getInstance",
"(",
"Parser",
".",
"class",
",",
"syntax",
".",
"toIdString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ComponentLookupException",
"e",
")",
"{",
"throw",
"new",
"MacroExecutionException",
"(",
"String",
".",
"format",
"(",
"\"Failed to lookup Parser for syntax [%s]\"",
",",
"syntax",
".",
"toIdString",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"MacroExecutionException",
"(",
"String",
".",
"format",
"(",
"\"Cannot find Parser for syntax [%s]\"",
",",
"syntax",
".",
"toIdString",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Get the parser for the passed Syntax.
@param syntax the Syntax for which to find the Parser
@return the matching Parser that can be used to parse content in the passed Syntax
@throws MacroExecutionException if there's no Parser in the system for the passed Syntax
|
[
"Get",
"the",
"parser",
"for",
"the",
"passed",
"Syntax",
"."
] |
train
|
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-content/src/main/java/org/xwiki/rendering/internal/macro/content/ContentMacro.java#L113-L125
|
mfornos/humanize
|
humanize-slim/src/main/java/humanize/Humanize.java
|
Humanize.formatDate
|
public static String formatDate(final Date value, final String pattern) {
"""
<p>
Formats a date according to the given pattern.
</p>
@param value
Date to be formatted
@param pattern
The pattern.
@return a formatted date/time string
@see #dateFormat(String)
"""
return new SimpleDateFormat(pattern, currentLocale()).format(value);
}
|
java
|
public static String formatDate(final Date value, final String pattern)
{
return new SimpleDateFormat(pattern, currentLocale()).format(value);
}
|
[
"public",
"static",
"String",
"formatDate",
"(",
"final",
"Date",
"value",
",",
"final",
"String",
"pattern",
")",
"{",
"return",
"new",
"SimpleDateFormat",
"(",
"pattern",
",",
"currentLocale",
"(",
")",
")",
".",
"format",
"(",
"value",
")",
";",
"}"
] |
<p>
Formats a date according to the given pattern.
</p>
@param value
Date to be formatted
@param pattern
The pattern.
@return a formatted date/time string
@see #dateFormat(String)
|
[
"<p",
">",
"Formats",
"a",
"date",
"according",
"to",
"the",
"given",
"pattern",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/mfornos/humanize/blob/59fc103045de9d217c9e77dbcb7621f992f46c63/humanize-slim/src/main/java/humanize/Humanize.java#L986-L989
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-domain/src/main/java/net/minidev/ovh/api/ApiOvhDomain.java
|
ApiOvhDomain.zone_zoneName_task_id_relaunch_POST
|
public void zone_zoneName_task_id_relaunch_POST(String zoneName, Long id) throws IOException {
"""
Relaunch the task
REST: POST /domain/zone/{zoneName}/task/{id}/relaunch
@param zoneName [required] The internal name of your zone
@param id [required] Id of the object
"""
String qPath = "/domain/zone/{zoneName}/task/{id}/relaunch";
StringBuilder sb = path(qPath, zoneName, id);
exec(qPath, "POST", sb.toString(), null);
}
|
java
|
public void zone_zoneName_task_id_relaunch_POST(String zoneName, Long id) throws IOException {
String qPath = "/domain/zone/{zoneName}/task/{id}/relaunch";
StringBuilder sb = path(qPath, zoneName, id);
exec(qPath, "POST", sb.toString(), null);
}
|
[
"public",
"void",
"zone_zoneName_task_id_relaunch_POST",
"(",
"String",
"zoneName",
",",
"Long",
"id",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/domain/zone/{zoneName}/task/{id}/relaunch\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"zoneName",
",",
"id",
")",
";",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] |
Relaunch the task
REST: POST /domain/zone/{zoneName}/task/{id}/relaunch
@param zoneName [required] The internal name of your zone
@param id [required] Id of the object
|
[
"Relaunch",
"the",
"task"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-domain/src/main/java/net/minidev/ovh/api/ApiOvhDomain.java#L763-L767
|
mangstadt/biweekly
|
src/main/java/biweekly/util/Google2445Utils.java
|
Google2445Utils.createRecurrenceIterable
|
public static RecurrenceIterable createRecurrenceIterable(Recurrence recurrence, ICalDate start, TimeZone timezone) {
"""
Creates a recurrence iterator based on the given recurrence rule.
@param recurrence the recurrence rule
@param start the start date
@param timezone the timezone to iterate in. This is needed in order to
account for when the iterator passes over a daylight savings boundary.
@return the recurrence iterator
"""
DateValue startValue = convert(start, timezone);
return RecurrenceIteratorFactory.createRecurrenceIterable(recurrence, startValue, timezone);
}
|
java
|
public static RecurrenceIterable createRecurrenceIterable(Recurrence recurrence, ICalDate start, TimeZone timezone) {
DateValue startValue = convert(start, timezone);
return RecurrenceIteratorFactory.createRecurrenceIterable(recurrence, startValue, timezone);
}
|
[
"public",
"static",
"RecurrenceIterable",
"createRecurrenceIterable",
"(",
"Recurrence",
"recurrence",
",",
"ICalDate",
"start",
",",
"TimeZone",
"timezone",
")",
"{",
"DateValue",
"startValue",
"=",
"convert",
"(",
"start",
",",
"timezone",
")",
";",
"return",
"RecurrenceIteratorFactory",
".",
"createRecurrenceIterable",
"(",
"recurrence",
",",
"startValue",
",",
"timezone",
")",
";",
"}"
] |
Creates a recurrence iterator based on the given recurrence rule.
@param recurrence the recurrence rule
@param start the start date
@param timezone the timezone to iterate in. This is needed in order to
account for when the iterator passes over a daylight savings boundary.
@return the recurrence iterator
|
[
"Creates",
"a",
"recurrence",
"iterator",
"based",
"on",
"the",
"given",
"recurrence",
"rule",
"."
] |
train
|
https://github.com/mangstadt/biweekly/blob/2e21350f85c13dfff52fdef98fdbebe2976fcf61/src/main/java/biweekly/util/Google2445Utils.java#L209-L212
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/pdf/PdfDocument.java
|
PdfDocument.localDestination
|
boolean localDestination(String name, PdfDestination destination) {
"""
The local destination to where a local goto with the same
name will jump to.
@param name the name of this local destination
@param destination the <CODE>PdfDestination</CODE> with the jump coordinates
@return <CODE>true</CODE> if the local destination was added,
<CODE>false</CODE> if a local destination with the same name
already existed
"""
Object obj[] = (Object[])localDestinations.get(name);
if (obj == null)
obj = new Object[3];
if (obj[2] != null)
return false;
obj[2] = destination;
localDestinations.put(name, obj);
destination.addPage(writer.getCurrentPage());
return true;
}
|
java
|
boolean localDestination(String name, PdfDestination destination) {
Object obj[] = (Object[])localDestinations.get(name);
if (obj == null)
obj = new Object[3];
if (obj[2] != null)
return false;
obj[2] = destination;
localDestinations.put(name, obj);
destination.addPage(writer.getCurrentPage());
return true;
}
|
[
"boolean",
"localDestination",
"(",
"String",
"name",
",",
"PdfDestination",
"destination",
")",
"{",
"Object",
"obj",
"[",
"]",
"=",
"(",
"Object",
"[",
"]",
")",
"localDestinations",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"obj",
"==",
"null",
")",
"obj",
"=",
"new",
"Object",
"[",
"3",
"]",
";",
"if",
"(",
"obj",
"[",
"2",
"]",
"!=",
"null",
")",
"return",
"false",
";",
"obj",
"[",
"2",
"]",
"=",
"destination",
";",
"localDestinations",
".",
"put",
"(",
"name",
",",
"obj",
")",
";",
"destination",
".",
"addPage",
"(",
"writer",
".",
"getCurrentPage",
"(",
")",
")",
";",
"return",
"true",
";",
"}"
] |
The local destination to where a local goto with the same
name will jump to.
@param name the name of this local destination
@param destination the <CODE>PdfDestination</CODE> with the jump coordinates
@return <CODE>true</CODE> if the local destination was added,
<CODE>false</CODE> if a local destination with the same name
already existed
|
[
"The",
"local",
"destination",
"to",
"where",
"a",
"local",
"goto",
"with",
"the",
"same",
"name",
"will",
"jump",
"to",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfDocument.java#L2089-L2099
|
ben-manes/caffeine
|
jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/EventDispatcher.java
|
EventDispatcher.publishRemoved
|
public void publishRemoved(Cache<K, V> cache, K key, V value) {
"""
Publishes a remove event for the entry to all of the interested listeners.
@param cache the cache where the entry was removed
@param key the entry's key
@param value the entry's value
"""
publish(cache, EventType.REMOVED, key, /* oldValue */ null, value, /* quiet */ false);
}
|
java
|
public void publishRemoved(Cache<K, V> cache, K key, V value) {
publish(cache, EventType.REMOVED, key, /* oldValue */ null, value, /* quiet */ false);
}
|
[
"public",
"void",
"publishRemoved",
"(",
"Cache",
"<",
"K",
",",
"V",
">",
"cache",
",",
"K",
"key",
",",
"V",
"value",
")",
"{",
"publish",
"(",
"cache",
",",
"EventType",
".",
"REMOVED",
",",
"key",
",",
"/* oldValue */",
"null",
",",
"value",
",",
"/* quiet */",
"false",
")",
";",
"}"
] |
Publishes a remove event for the entry to all of the interested listeners.
@param cache the cache where the entry was removed
@param key the entry's key
@param value the entry's value
|
[
"Publishes",
"a",
"remove",
"event",
"for",
"the",
"entry",
"to",
"all",
"of",
"the",
"interested",
"listeners",
"."
] |
train
|
https://github.com/ben-manes/caffeine/blob/4cf6d6e6a18ea2e8088f166261e5949343b0f2eb/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/EventDispatcher.java#L136-L138
|
googleapis/google-cloud-java
|
google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/CopyJobConfiguration.java
|
CopyJobConfiguration.newBuilder
|
public static Builder newBuilder(TableId destinationTable, TableId sourceTable) {
"""
Creates a builder for a BigQuery Copy Job configuration given destination and source table.
"""
return newBuilder(destinationTable, ImmutableList.of(checkNotNull(sourceTable)));
}
|
java
|
public static Builder newBuilder(TableId destinationTable, TableId sourceTable) {
return newBuilder(destinationTable, ImmutableList.of(checkNotNull(sourceTable)));
}
|
[
"public",
"static",
"Builder",
"newBuilder",
"(",
"TableId",
"destinationTable",
",",
"TableId",
"sourceTable",
")",
"{",
"return",
"newBuilder",
"(",
"destinationTable",
",",
"ImmutableList",
".",
"of",
"(",
"checkNotNull",
"(",
"sourceTable",
")",
")",
")",
";",
"}"
] |
Creates a builder for a BigQuery Copy Job configuration given destination and source table.
|
[
"Creates",
"a",
"builder",
"for",
"a",
"BigQuery",
"Copy",
"Job",
"configuration",
"given",
"destination",
"and",
"source",
"table",
"."
] |
train
|
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/CopyJobConfiguration.java#L255-L257
|
Waikato/moa
|
moa/src/main/java/com/yahoo/labs/samoa/instances/WekaToSamoaInstanceConverter.java
|
WekaToSamoaInstanceConverter.samoaAttribute
|
protected Attribute samoaAttribute(int index, weka.core.Attribute attribute) {
"""
Get Samoa attribute from a weka attribute.
@param index the index
@param attribute the attribute
@return the attribute
"""
Attribute samoaAttribute;
if (attribute.isNominal()) {
Enumeration enu = attribute.enumerateValues();
List<String> attributeValues = new ArrayList<String>();
while (enu.hasMoreElements()) {
attributeValues.add((String) enu.nextElement());
}
samoaAttribute = new Attribute(attribute.name(), attributeValues);
} else {
samoaAttribute = new Attribute(attribute.name());
}
return samoaAttribute;
}
|
java
|
protected Attribute samoaAttribute(int index, weka.core.Attribute attribute) {
Attribute samoaAttribute;
if (attribute.isNominal()) {
Enumeration enu = attribute.enumerateValues();
List<String> attributeValues = new ArrayList<String>();
while (enu.hasMoreElements()) {
attributeValues.add((String) enu.nextElement());
}
samoaAttribute = new Attribute(attribute.name(), attributeValues);
} else {
samoaAttribute = new Attribute(attribute.name());
}
return samoaAttribute;
}
|
[
"protected",
"Attribute",
"samoaAttribute",
"(",
"int",
"index",
",",
"weka",
".",
"core",
".",
"Attribute",
"attribute",
")",
"{",
"Attribute",
"samoaAttribute",
";",
"if",
"(",
"attribute",
".",
"isNominal",
"(",
")",
")",
"{",
"Enumeration",
"enu",
"=",
"attribute",
".",
"enumerateValues",
"(",
")",
";",
"List",
"<",
"String",
">",
"attributeValues",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"while",
"(",
"enu",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"attributeValues",
".",
"add",
"(",
"(",
"String",
")",
"enu",
".",
"nextElement",
"(",
")",
")",
";",
"}",
"samoaAttribute",
"=",
"new",
"Attribute",
"(",
"attribute",
".",
"name",
"(",
")",
",",
"attributeValues",
")",
";",
"}",
"else",
"{",
"samoaAttribute",
"=",
"new",
"Attribute",
"(",
"attribute",
".",
"name",
"(",
")",
")",
";",
"}",
"return",
"samoaAttribute",
";",
"}"
] |
Get Samoa attribute from a weka attribute.
@param index the index
@param attribute the attribute
@return the attribute
|
[
"Get",
"Samoa",
"attribute",
"from",
"a",
"weka",
"attribute",
"."
] |
train
|
https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/com/yahoo/labs/samoa/instances/WekaToSamoaInstanceConverter.java#L111-L124
|
apache/incubator-gobblin
|
gobblin-config-management/gobblin-config-core/src/main/java/org/apache/gobblin/config/store/zip/ZipFileConfigStore.java
|
ZipFileConfigStore.getChildren
|
@Override
public Collection<ConfigKeyPath> getChildren(ConfigKeyPath configKey, String version)
throws VersionDoesNotExistException {
"""
Retrieves all the children of the given {@link ConfigKeyPath} using {@link Files#walk} to list files
"""
Preconditions.checkNotNull(configKey, "configKey cannot be null!");
Preconditions.checkArgument(version.equals(getCurrentVersion()));
List<ConfigKeyPath> children = new ArrayList<>();
Path datasetDir = getDatasetDirForKey(configKey);
try {
if (!Files.exists(this.fs.getPath(datasetDir.toString()))) {
return children;
}
Stream<Path> files = Files.walk(datasetDir, 1);
for (Iterator<Path> it = files.iterator(); it.hasNext();) {
Path path = it.next();
if (Files.isDirectory(path) && !path.equals(datasetDir)) {
children.add(configKey.createChild(StringUtils.removeEnd(path.getName(path.getNameCount() - 1).toString(),
SingleLinkedListConfigKeyPath.PATH_DELIMETER)));
}
}
return children;
} catch (IOException e) {
throw new RuntimeException(String.format("Error while getting children for configKey: \"%s\"", configKey), e);
}
}
|
java
|
@Override
public Collection<ConfigKeyPath> getChildren(ConfigKeyPath configKey, String version)
throws VersionDoesNotExistException {
Preconditions.checkNotNull(configKey, "configKey cannot be null!");
Preconditions.checkArgument(version.equals(getCurrentVersion()));
List<ConfigKeyPath> children = new ArrayList<>();
Path datasetDir = getDatasetDirForKey(configKey);
try {
if (!Files.exists(this.fs.getPath(datasetDir.toString()))) {
return children;
}
Stream<Path> files = Files.walk(datasetDir, 1);
for (Iterator<Path> it = files.iterator(); it.hasNext();) {
Path path = it.next();
if (Files.isDirectory(path) && !path.equals(datasetDir)) {
children.add(configKey.createChild(StringUtils.removeEnd(path.getName(path.getNameCount() - 1).toString(),
SingleLinkedListConfigKeyPath.PATH_DELIMETER)));
}
}
return children;
} catch (IOException e) {
throw new RuntimeException(String.format("Error while getting children for configKey: \"%s\"", configKey), e);
}
}
|
[
"@",
"Override",
"public",
"Collection",
"<",
"ConfigKeyPath",
">",
"getChildren",
"(",
"ConfigKeyPath",
"configKey",
",",
"String",
"version",
")",
"throws",
"VersionDoesNotExistException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"configKey",
",",
"\"configKey cannot be null!\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"version",
".",
"equals",
"(",
"getCurrentVersion",
"(",
")",
")",
")",
";",
"List",
"<",
"ConfigKeyPath",
">",
"children",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Path",
"datasetDir",
"=",
"getDatasetDirForKey",
"(",
"configKey",
")",
";",
"try",
"{",
"if",
"(",
"!",
"Files",
".",
"exists",
"(",
"this",
".",
"fs",
".",
"getPath",
"(",
"datasetDir",
".",
"toString",
"(",
")",
")",
")",
")",
"{",
"return",
"children",
";",
"}",
"Stream",
"<",
"Path",
">",
"files",
"=",
"Files",
".",
"walk",
"(",
"datasetDir",
",",
"1",
")",
";",
"for",
"(",
"Iterator",
"<",
"Path",
">",
"it",
"=",
"files",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Path",
"path",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"Files",
".",
"isDirectory",
"(",
"path",
")",
"&&",
"!",
"path",
".",
"equals",
"(",
"datasetDir",
")",
")",
"{",
"children",
".",
"add",
"(",
"configKey",
".",
"createChild",
"(",
"StringUtils",
".",
"removeEnd",
"(",
"path",
".",
"getName",
"(",
"path",
".",
"getNameCount",
"(",
")",
"-",
"1",
")",
".",
"toString",
"(",
")",
",",
"SingleLinkedListConfigKeyPath",
".",
"PATH_DELIMETER",
")",
")",
")",
";",
"}",
"}",
"return",
"children",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"String",
".",
"format",
"(",
"\"Error while getting children for configKey: \\\"%s\\\"\"",
",",
"configKey",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Retrieves all the children of the given {@link ConfigKeyPath} using {@link Files#walk} to list files
|
[
"Retrieves",
"all",
"the",
"children",
"of",
"the",
"given",
"{"
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-config-management/gobblin-config-core/src/main/java/org/apache/gobblin/config/store/zip/ZipFileConfigStore.java#L98-L128
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/lang/Primitives.java
|
Primitives.findDouble
|
public static final double findDouble(CharSequence cs, int beginIndex, int endIndex) {
"""
Parses next double in decimal form
@param cs
@param beginIndex
@param endIndex
@return
"""
int begin = CharSequences.indexOf(cs, Primitives::isFloatDigit, beginIndex);
int end = CharSequences.indexOf(cs, (c)->!Primitives.isFloatDigit(c), begin);
return parseDouble(cs, begin, endIndex(end, endIndex));
}
|
java
|
public static final double findDouble(CharSequence cs, int beginIndex, int endIndex)
{
int begin = CharSequences.indexOf(cs, Primitives::isFloatDigit, beginIndex);
int end = CharSequences.indexOf(cs, (c)->!Primitives.isFloatDigit(c), begin);
return parseDouble(cs, begin, endIndex(end, endIndex));
}
|
[
"public",
"static",
"final",
"double",
"findDouble",
"(",
"CharSequence",
"cs",
",",
"int",
"beginIndex",
",",
"int",
"endIndex",
")",
"{",
"int",
"begin",
"=",
"CharSequences",
".",
"indexOf",
"(",
"cs",
",",
"Primitives",
"::",
"isFloatDigit",
",",
"beginIndex",
")",
";",
"int",
"end",
"=",
"CharSequences",
".",
"indexOf",
"(",
"cs",
",",
"(",
"c",
")",
"-",
">",
"!",
"Primitives",
".",
"isFloatDigit",
"(",
"c",
")",
",",
"begin",
")",
";",
"return",
"parseDouble",
"(",
"cs",
",",
"begin",
",",
"endIndex",
"(",
"end",
",",
"endIndex",
")",
")",
";",
"}"
] |
Parses next double in decimal form
@param cs
@param beginIndex
@param endIndex
@return
|
[
"Parses",
"next",
"double",
"in",
"decimal",
"form"
] |
train
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/lang/Primitives.java#L1681-L1686
|
kiegroup/drools
|
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
|
OpenBitSet.xorCount
|
public static long xorCount(OpenBitSet a, OpenBitSet b) {
"""
Returns the popcount or cardinality of the exclusive-or of the two sets.
Neither set is modified.
"""
long tot = BitUtil.pop_xor( a.bits, b.bits, 0, Math.min( a.wlen, b.wlen ) );
if (a.wlen < b.wlen) {
tot += BitUtil.pop_array( b.bits, a.wlen, b.wlen - a.wlen );
} else if (a.wlen > b.wlen) {
tot += BitUtil.pop_array( a.bits, b.wlen, a.wlen - b.wlen );
}
return tot;
}
|
java
|
public static long xorCount(OpenBitSet a, OpenBitSet b) {
long tot = BitUtil.pop_xor( a.bits, b.bits, 0, Math.min( a.wlen, b.wlen ) );
if (a.wlen < b.wlen) {
tot += BitUtil.pop_array( b.bits, a.wlen, b.wlen - a.wlen );
} else if (a.wlen > b.wlen) {
tot += BitUtil.pop_array( a.bits, b.wlen, a.wlen - b.wlen );
}
return tot;
}
|
[
"public",
"static",
"long",
"xorCount",
"(",
"OpenBitSet",
"a",
",",
"OpenBitSet",
"b",
")",
"{",
"long",
"tot",
"=",
"BitUtil",
".",
"pop_xor",
"(",
"a",
".",
"bits",
",",
"b",
".",
"bits",
",",
"0",
",",
"Math",
".",
"min",
"(",
"a",
".",
"wlen",
",",
"b",
".",
"wlen",
")",
")",
";",
"if",
"(",
"a",
".",
"wlen",
"<",
"b",
".",
"wlen",
")",
"{",
"tot",
"+=",
"BitUtil",
".",
"pop_array",
"(",
"b",
".",
"bits",
",",
"a",
".",
"wlen",
",",
"b",
".",
"wlen",
"-",
"a",
".",
"wlen",
")",
";",
"}",
"else",
"if",
"(",
"a",
".",
"wlen",
">",
"b",
".",
"wlen",
")",
"{",
"tot",
"+=",
"BitUtil",
".",
"pop_array",
"(",
"a",
".",
"bits",
",",
"b",
".",
"wlen",
",",
"a",
".",
"wlen",
"-",
"b",
".",
"wlen",
")",
";",
"}",
"return",
"tot",
";",
"}"
] |
Returns the popcount or cardinality of the exclusive-or of the two sets.
Neither set is modified.
|
[
"Returns",
"the",
"popcount",
"or",
"cardinality",
"of",
"the",
"exclusive",
"-",
"or",
"of",
"the",
"two",
"sets",
".",
"Neither",
"set",
"is",
"modified",
"."
] |
train
|
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L599-L607
|
Whiley/WhileyCompiler
|
src/main/java/wyil/transform/VerificationConditionGenerator.java
|
VerificationConditionGenerator.translateBreak
|
private Context translateBreak(WyilFile.Stmt.Break stmt, Context context) {
"""
Translate a break statement. This takes the current context and pushes it
into the enclosing loop scope. It will then be extracted later and used.
@param stmt
@param wyalFile
"""
LoopScope enclosingLoop = context.getEnclosingLoopScope();
enclosingLoop.addBreakContext(context);
return null;
}
|
java
|
private Context translateBreak(WyilFile.Stmt.Break stmt, Context context) {
LoopScope enclosingLoop = context.getEnclosingLoopScope();
enclosingLoop.addBreakContext(context);
return null;
}
|
[
"private",
"Context",
"translateBreak",
"(",
"WyilFile",
".",
"Stmt",
".",
"Break",
"stmt",
",",
"Context",
"context",
")",
"{",
"LoopScope",
"enclosingLoop",
"=",
"context",
".",
"getEnclosingLoopScope",
"(",
")",
";",
"enclosingLoop",
".",
"addBreakContext",
"(",
"context",
")",
";",
"return",
"null",
";",
"}"
] |
Translate a break statement. This takes the current context and pushes it
into the enclosing loop scope. It will then be extracted later and used.
@param stmt
@param wyalFile
|
[
"Translate",
"a",
"break",
"statement",
".",
"This",
"takes",
"the",
"current",
"context",
"and",
"pushes",
"it",
"into",
"the",
"enclosing",
"loop",
"scope",
".",
"It",
"will",
"then",
"be",
"extracted",
"later",
"and",
"used",
"."
] |
train
|
https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/transform/VerificationConditionGenerator.java#L744-L748
|
grails/grails-core
|
grails-web-databinding/src/main/groovy/grails/web/databinding/DataBindingUtils.java
|
DataBindingUtils.bindToCollection
|
public static <T> void bindToCollection(final Class<T> targetType, final Collection<T> collectionToPopulate, final CollectionDataBindingSource collectionBindingSource) throws InstantiationException, IllegalAccessException {
"""
For each DataBindingSource provided by collectionBindingSource a new instance of targetType is created,
data binding is imposed on that instance with the DataBindingSource and the instance is added to the end of
collectionToPopulate
@param targetType The type of objects to create, must be a concrete class
@param collectionToPopulate A collection to populate with new instances of targetType
@param collectionBindingSource A CollectionDataBindingSource
@since 2.3
"""
final GrailsApplication application = Holders.findApplication();
PersistentEntity entity = null;
if (application != null) {
try {
entity = application.getMappingContext().getPersistentEntity(targetType.getClass().getName());
} catch (GrailsConfigurationException e) {
//no-op
}
}
final List<DataBindingSource> dataBindingSources = collectionBindingSource.getDataBindingSources();
for(final DataBindingSource dataBindingSource : dataBindingSources) {
final T newObject = targetType.newInstance();
bindObjectToDomainInstance(entity, newObject, dataBindingSource, getBindingIncludeList(newObject), Collections.emptyList(), null);
collectionToPopulate.add(newObject);
}
}
|
java
|
public static <T> void bindToCollection(final Class<T> targetType, final Collection<T> collectionToPopulate, final CollectionDataBindingSource collectionBindingSource) throws InstantiationException, IllegalAccessException {
final GrailsApplication application = Holders.findApplication();
PersistentEntity entity = null;
if (application != null) {
try {
entity = application.getMappingContext().getPersistentEntity(targetType.getClass().getName());
} catch (GrailsConfigurationException e) {
//no-op
}
}
final List<DataBindingSource> dataBindingSources = collectionBindingSource.getDataBindingSources();
for(final DataBindingSource dataBindingSource : dataBindingSources) {
final T newObject = targetType.newInstance();
bindObjectToDomainInstance(entity, newObject, dataBindingSource, getBindingIncludeList(newObject), Collections.emptyList(), null);
collectionToPopulate.add(newObject);
}
}
|
[
"public",
"static",
"<",
"T",
">",
"void",
"bindToCollection",
"(",
"final",
"Class",
"<",
"T",
">",
"targetType",
",",
"final",
"Collection",
"<",
"T",
">",
"collectionToPopulate",
",",
"final",
"CollectionDataBindingSource",
"collectionBindingSource",
")",
"throws",
"InstantiationException",
",",
"IllegalAccessException",
"{",
"final",
"GrailsApplication",
"application",
"=",
"Holders",
".",
"findApplication",
"(",
")",
";",
"PersistentEntity",
"entity",
"=",
"null",
";",
"if",
"(",
"application",
"!=",
"null",
")",
"{",
"try",
"{",
"entity",
"=",
"application",
".",
"getMappingContext",
"(",
")",
".",
"getPersistentEntity",
"(",
"targetType",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"GrailsConfigurationException",
"e",
")",
"{",
"//no-op",
"}",
"}",
"final",
"List",
"<",
"DataBindingSource",
">",
"dataBindingSources",
"=",
"collectionBindingSource",
".",
"getDataBindingSources",
"(",
")",
";",
"for",
"(",
"final",
"DataBindingSource",
"dataBindingSource",
":",
"dataBindingSources",
")",
"{",
"final",
"T",
"newObject",
"=",
"targetType",
".",
"newInstance",
"(",
")",
";",
"bindObjectToDomainInstance",
"(",
"entity",
",",
"newObject",
",",
"dataBindingSource",
",",
"getBindingIncludeList",
"(",
"newObject",
")",
",",
"Collections",
".",
"emptyList",
"(",
")",
",",
"null",
")",
";",
"collectionToPopulate",
".",
"add",
"(",
"newObject",
")",
";",
"}",
"}"
] |
For each DataBindingSource provided by collectionBindingSource a new instance of targetType is created,
data binding is imposed on that instance with the DataBindingSource and the instance is added to the end of
collectionToPopulate
@param targetType The type of objects to create, must be a concrete class
@param collectionToPopulate A collection to populate with new instances of targetType
@param collectionBindingSource A CollectionDataBindingSource
@since 2.3
|
[
"For",
"each",
"DataBindingSource",
"provided",
"by",
"collectionBindingSource",
"a",
"new",
"instance",
"of",
"targetType",
"is",
"created",
"data",
"binding",
"is",
"imposed",
"on",
"that",
"instance",
"with",
"the",
"DataBindingSource",
"and",
"the",
"instance",
"is",
"added",
"to",
"the",
"end",
"of",
"collectionToPopulate"
] |
train
|
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-databinding/src/main/groovy/grails/web/databinding/DataBindingUtils.java#L164-L180
|
spring-projects/spring-android
|
spring-android-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
|
GenericConversionService.getConverter
|
protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
"""
Hook method to lookup the converter for a given sourceType/targetType pair.
First queries this ConversionService's converter cache.
On a cache miss, then performs an exhaustive search for a matching converter.
If no converter matches, returns the default converter.
Subclasses may override.
@param sourceType the source type to convert from
@param targetType the target type to convert to
@return the generic converter that will perform the conversion, or {@code null} if
no suitable converter was found
@see #getDefaultConverter(TypeDescriptor, TypeDescriptor)
"""
ConverterCacheKey key = new ConverterCacheKey(sourceType, targetType);
GenericConverter converter = this.converterCache.get(key);
if (converter != null) {
return (converter != NO_MATCH ? converter : null);
}
converter = this.converters.find(sourceType, targetType);
if (converter == null) {
converter = getDefaultConverter(sourceType, targetType);
}
if (converter != null) {
this.converterCache.put(key, converter);
return converter;
}
this.converterCache.put(key, NO_MATCH);
return null;
}
|
java
|
protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
ConverterCacheKey key = new ConverterCacheKey(sourceType, targetType);
GenericConverter converter = this.converterCache.get(key);
if (converter != null) {
return (converter != NO_MATCH ? converter : null);
}
converter = this.converters.find(sourceType, targetType);
if (converter == null) {
converter = getDefaultConverter(sourceType, targetType);
}
if (converter != null) {
this.converterCache.put(key, converter);
return converter;
}
this.converterCache.put(key, NO_MATCH);
return null;
}
|
[
"protected",
"GenericConverter",
"getConverter",
"(",
"TypeDescriptor",
"sourceType",
",",
"TypeDescriptor",
"targetType",
")",
"{",
"ConverterCacheKey",
"key",
"=",
"new",
"ConverterCacheKey",
"(",
"sourceType",
",",
"targetType",
")",
";",
"GenericConverter",
"converter",
"=",
"this",
".",
"converterCache",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"converter",
"!=",
"null",
")",
"{",
"return",
"(",
"converter",
"!=",
"NO_MATCH",
"?",
"converter",
":",
"null",
")",
";",
"}",
"converter",
"=",
"this",
".",
"converters",
".",
"find",
"(",
"sourceType",
",",
"targetType",
")",
";",
"if",
"(",
"converter",
"==",
"null",
")",
"{",
"converter",
"=",
"getDefaultConverter",
"(",
"sourceType",
",",
"targetType",
")",
";",
"}",
"if",
"(",
"converter",
"!=",
"null",
")",
"{",
"this",
".",
"converterCache",
".",
"put",
"(",
"key",
",",
"converter",
")",
";",
"return",
"converter",
";",
"}",
"this",
".",
"converterCache",
".",
"put",
"(",
"key",
",",
"NO_MATCH",
")",
";",
"return",
"null",
";",
"}"
] |
Hook method to lookup the converter for a given sourceType/targetType pair.
First queries this ConversionService's converter cache.
On a cache miss, then performs an exhaustive search for a matching converter.
If no converter matches, returns the default converter.
Subclasses may override.
@param sourceType the source type to convert from
@param targetType the target type to convert to
@return the generic converter that will perform the conversion, or {@code null} if
no suitable converter was found
@see #getDefaultConverter(TypeDescriptor, TypeDescriptor)
|
[
"Hook",
"method",
"to",
"lookup",
"the",
"converter",
"for",
"a",
"given",
"sourceType",
"/",
"targetType",
"pair",
".",
"First",
"queries",
"this",
"ConversionService",
"s",
"converter",
"cache",
".",
"On",
"a",
"cache",
"miss",
"then",
"performs",
"an",
"exhaustive",
"search",
"for",
"a",
"matching",
"converter",
".",
"If",
"no",
"converter",
"matches",
"returns",
"the",
"default",
"converter",
".",
"Subclasses",
"may",
"override",
"."
] |
train
|
https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java#L222-L241
|
msgpack/msgpack-java
|
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
|
MessageUnpacker.unpackLong
|
public long unpackLong()
throws IOException {
"""
Reads a long.
This method throws {@link MessageIntegerOverflowException} if the value doesn't fit in the range of long. This may happen when {@link #getNextFormat()} returns UINT64.
@return the read value
@throws MessageIntegerOverflowException when value doesn't fit in the range of long
@throws MessageTypeException when value is not MessagePack Integer type
@throws IOException when underlying input throws IOException
"""
byte b = readByte();
if (Code.isFixInt(b)) {
return (long) b;
}
switch (b) {
case Code.UINT8: // unsigned int 8
byte u8 = readByte();
return (long) (u8 & 0xff);
case Code.UINT16: // unsigned int 16
short u16 = readShort();
return (long) (u16 & 0xffff);
case Code.UINT32: // unsigned int 32
int u32 = readInt();
if (u32 < 0) {
return (long) (u32 & 0x7fffffff) + 0x80000000L;
}
else {
return (long) u32;
}
case Code.UINT64: // unsigned int 64
long u64 = readLong();
if (u64 < 0L) {
throw overflowU64(u64);
}
return u64;
case Code.INT8: // signed int 8
byte i8 = readByte();
return (long) i8;
case Code.INT16: // signed int 16
short i16 = readShort();
return (long) i16;
case Code.INT32: // signed int 32
int i32 = readInt();
return (long) i32;
case Code.INT64: // signed int 64
long i64 = readLong();
return i64;
}
throw unexpected("Integer", b);
}
|
java
|
public long unpackLong()
throws IOException
{
byte b = readByte();
if (Code.isFixInt(b)) {
return (long) b;
}
switch (b) {
case Code.UINT8: // unsigned int 8
byte u8 = readByte();
return (long) (u8 & 0xff);
case Code.UINT16: // unsigned int 16
short u16 = readShort();
return (long) (u16 & 0xffff);
case Code.UINT32: // unsigned int 32
int u32 = readInt();
if (u32 < 0) {
return (long) (u32 & 0x7fffffff) + 0x80000000L;
}
else {
return (long) u32;
}
case Code.UINT64: // unsigned int 64
long u64 = readLong();
if (u64 < 0L) {
throw overflowU64(u64);
}
return u64;
case Code.INT8: // signed int 8
byte i8 = readByte();
return (long) i8;
case Code.INT16: // signed int 16
short i16 = readShort();
return (long) i16;
case Code.INT32: // signed int 32
int i32 = readInt();
return (long) i32;
case Code.INT64: // signed int 64
long i64 = readLong();
return i64;
}
throw unexpected("Integer", b);
}
|
[
"public",
"long",
"unpackLong",
"(",
")",
"throws",
"IOException",
"{",
"byte",
"b",
"=",
"readByte",
"(",
")",
";",
"if",
"(",
"Code",
".",
"isFixInt",
"(",
"b",
")",
")",
"{",
"return",
"(",
"long",
")",
"b",
";",
"}",
"switch",
"(",
"b",
")",
"{",
"case",
"Code",
".",
"UINT8",
":",
"// unsigned int 8",
"byte",
"u8",
"=",
"readByte",
"(",
")",
";",
"return",
"(",
"long",
")",
"(",
"u8",
"&",
"0xff",
")",
";",
"case",
"Code",
".",
"UINT16",
":",
"// unsigned int 16",
"short",
"u16",
"=",
"readShort",
"(",
")",
";",
"return",
"(",
"long",
")",
"(",
"u16",
"&",
"0xffff",
")",
";",
"case",
"Code",
".",
"UINT32",
":",
"// unsigned int 32",
"int",
"u32",
"=",
"readInt",
"(",
")",
";",
"if",
"(",
"u32",
"<",
"0",
")",
"{",
"return",
"(",
"long",
")",
"(",
"u32",
"&",
"0x7fffffff",
")",
"+",
"0x80000000",
"L",
";",
"}",
"else",
"{",
"return",
"(",
"long",
")",
"u32",
";",
"}",
"case",
"Code",
".",
"UINT64",
":",
"// unsigned int 64",
"long",
"u64",
"=",
"readLong",
"(",
")",
";",
"if",
"(",
"u64",
"<",
"0L",
")",
"{",
"throw",
"overflowU64",
"(",
"u64",
")",
";",
"}",
"return",
"u64",
";",
"case",
"Code",
".",
"INT8",
":",
"// signed int 8",
"byte",
"i8",
"=",
"readByte",
"(",
")",
";",
"return",
"(",
"long",
")",
"i8",
";",
"case",
"Code",
".",
"INT16",
":",
"// signed int 16",
"short",
"i16",
"=",
"readShort",
"(",
")",
";",
"return",
"(",
"long",
")",
"i16",
";",
"case",
"Code",
".",
"INT32",
":",
"// signed int 32",
"int",
"i32",
"=",
"readInt",
"(",
")",
";",
"return",
"(",
"long",
")",
"i32",
";",
"case",
"Code",
".",
"INT64",
":",
"// signed int 64",
"long",
"i64",
"=",
"readLong",
"(",
")",
";",
"return",
"i64",
";",
"}",
"throw",
"unexpected",
"(",
"\"Integer\"",
",",
"b",
")",
";",
"}"
] |
Reads a long.
This method throws {@link MessageIntegerOverflowException} if the value doesn't fit in the range of long. This may happen when {@link #getNextFormat()} returns UINT64.
@return the read value
@throws MessageIntegerOverflowException when value doesn't fit in the range of long
@throws MessageTypeException when value is not MessagePack Integer type
@throws IOException when underlying input throws IOException
|
[
"Reads",
"a",
"long",
"."
] |
train
|
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L972-L1014
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/TextModerationsImpl.java
|
TextModerationsImpl.screenText
|
public Screen screenText(String textContentType, byte[] textContent, ScreenTextOptionalParameter screenTextOptionalParameter) {
"""
Detect profanity and match against custom and shared blacklists.
Detects profanity in more than 100 languages and match against custom and shared blacklists.
@param textContentType The content type. Possible values include: 'text/plain', 'text/html', 'text/xml', 'text/markdown'
@param textContent Content to screen.
@param screenTextOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws APIErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the Screen object if successful.
"""
return screenTextWithServiceResponseAsync(textContentType, textContent, screenTextOptionalParameter).toBlocking().single().body();
}
|
java
|
public Screen screenText(String textContentType, byte[] textContent, ScreenTextOptionalParameter screenTextOptionalParameter) {
return screenTextWithServiceResponseAsync(textContentType, textContent, screenTextOptionalParameter).toBlocking().single().body();
}
|
[
"public",
"Screen",
"screenText",
"(",
"String",
"textContentType",
",",
"byte",
"[",
"]",
"textContent",
",",
"ScreenTextOptionalParameter",
"screenTextOptionalParameter",
")",
"{",
"return",
"screenTextWithServiceResponseAsync",
"(",
"textContentType",
",",
"textContent",
",",
"screenTextOptionalParameter",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Detect profanity and match against custom and shared blacklists.
Detects profanity in more than 100 languages and match against custom and shared blacklists.
@param textContentType The content type. Possible values include: 'text/plain', 'text/html', 'text/xml', 'text/markdown'
@param textContent Content to screen.
@param screenTextOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws APIErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the Screen object if successful.
|
[
"Detect",
"profanity",
"and",
"match",
"against",
"custom",
"and",
"shared",
"blacklists",
".",
"Detects",
"profanity",
"in",
"more",
"than",
"100",
"languages",
"and",
"match",
"against",
"custom",
"and",
"shared",
"blacklists",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/TextModerationsImpl.java#L84-L86
|
FlyingHe/UtilsMaven
|
src/main/java/com/github/flyinghe/tools/ImgCompressUtils.java
|
ImgCompressUtils.imgCompressByWH
|
public static void imgCompressByWH(String srcFile, String desFile, int width, int height, Float quality,
boolean isForceWh) {
"""
根据指定宽高和压缩质量进行压缩,当isForceWh为false时,如果指定宽或者高大于源图片则按照源图片大小宽高压缩,
当isForceWh为true时,不论怎样均按照指定宽高压缩
@param srcFile 指定原图片地址
@param desFile 指定压缩后图片存放地址,包括图片名称
@param width 指定压缩宽
@param height 指定压缩高
@param quality 指定压缩质量,范围[0.0,1.0],如果指定为null则按照默认值
@param isForceWh 指定是否强制使用指定宽高进行压缩,true代表强制,false反之
"""
try {
Image srcImg = ImageIO.read(new File(srcFile));
if (!isForceWh && (srcImg.getHeight(null) < height || srcImg.getWidth(null) < width)) {
width = srcImg.getWidth(null);
height = srcImg.getHeight(null);
}
//指定目标图片
BufferedImage desImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
//根据源图片绘制目标图片
desImg.getGraphics().drawImage(srcImg, 0, 0, width, height, null);
ImgCompressUtils.encodeImg(desFile, desImg, quality);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
|
java
|
public static void imgCompressByWH(String srcFile, String desFile, int width, int height, Float quality,
boolean isForceWh) {
try {
Image srcImg = ImageIO.read(new File(srcFile));
if (!isForceWh && (srcImg.getHeight(null) < height || srcImg.getWidth(null) < width)) {
width = srcImg.getWidth(null);
height = srcImg.getHeight(null);
}
//指定目标图片
BufferedImage desImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
//根据源图片绘制目标图片
desImg.getGraphics().drawImage(srcImg, 0, 0, width, height, null);
ImgCompressUtils.encodeImg(desFile, desImg, quality);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"static",
"void",
"imgCompressByWH",
"(",
"String",
"srcFile",
",",
"String",
"desFile",
",",
"int",
"width",
",",
"int",
"height",
",",
"Float",
"quality",
",",
"boolean",
"isForceWh",
")",
"{",
"try",
"{",
"Image",
"srcImg",
"=",
"ImageIO",
".",
"read",
"(",
"new",
"File",
"(",
"srcFile",
")",
")",
";",
"if",
"(",
"!",
"isForceWh",
"&&",
"(",
"srcImg",
".",
"getHeight",
"(",
"null",
")",
"<",
"height",
"||",
"srcImg",
".",
"getWidth",
"(",
"null",
")",
"<",
"width",
")",
")",
"{",
"width",
"=",
"srcImg",
".",
"getWidth",
"(",
"null",
")",
";",
"height",
"=",
"srcImg",
".",
"getHeight",
"(",
"null",
")",
";",
"}",
"//指定目标图片",
"BufferedImage",
"desImg",
"=",
"new",
"BufferedImage",
"(",
"width",
",",
"height",
",",
"BufferedImage",
".",
"TYPE_INT_RGB",
")",
";",
"//根据源图片绘制目标图片",
"desImg",
".",
"getGraphics",
"(",
")",
".",
"drawImage",
"(",
"srcImg",
",",
"0",
",",
"0",
",",
"width",
",",
"height",
",",
"null",
")",
";",
"ImgCompressUtils",
".",
"encodeImg",
"(",
"desFile",
",",
"desImg",
",",
"quality",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
根据指定宽高和压缩质量进行压缩,当isForceWh为false时,如果指定宽或者高大于源图片则按照源图片大小宽高压缩,
当isForceWh为true时,不论怎样均按照指定宽高压缩
@param srcFile 指定原图片地址
@param desFile 指定压缩后图片存放地址,包括图片名称
@param width 指定压缩宽
@param height 指定压缩高
@param quality 指定压缩质量,范围[0.0,1.0],如果指定为null则按照默认值
@param isForceWh 指定是否强制使用指定宽高进行压缩,true代表强制,false反之
|
[
"根据指定宽高和压缩质量进行压缩,当isForceWh为false时",
"如果指定宽或者高大于源图片则按照源图片大小宽高压缩",
"当isForceWh为true时",
"不论怎样均按照指定宽高压缩"
] |
train
|
https://github.com/FlyingHe/UtilsMaven/blob/d9605b7bfe0c28a05289252e12d163e114080b4a/src/main/java/com/github/flyinghe/tools/ImgCompressUtils.java#L52-L68
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java
|
Base64Slow.readBase64
|
private static final int readBase64(InputStream in, boolean throwExceptions) throws IOException {
"""
Reads the next (decoded) Base64 character from the input stream. Non Base64 characters are
skipped.
@param in Stream from which bytes are read.
@param throwExceptions Throw an exception if an unexpected character is encountered.
@return the next Base64 character from the stream or -1 if there are no more Base64 characters
on the stream.
@throws IOException if an IO Error occurs.
@throws Base64DecodingException if unexpected data is encountered when throwExceptions is
specified.
@since ostermillerutils 1.00.00
"""
int read;
int numPadding = 0;
do {
read = in.read();
if (read == END_OF_INPUT) {
return END_OF_INPUT;
}
read = reverseBase64Chars[(byte) read];
if (throwExceptions && (read == NON_BASE_64 || (numPadding > 0 && read > NON_BASE_64))) {
throw new Base64DecodingException(
MessageFormat.format(
"Unexpected char",
(Object[]) new String[]{
"'" + (char) read + "' (0x" + Integer.toHexString(read) + ")"
}
),
(char) read
);
}
if (read == NON_BASE_64_PADDING) {
numPadding++;
}
} while (read <= NON_BASE_64);
return read;
}
|
java
|
private static final int readBase64(InputStream in, boolean throwExceptions) throws IOException {
int read;
int numPadding = 0;
do {
read = in.read();
if (read == END_OF_INPUT) {
return END_OF_INPUT;
}
read = reverseBase64Chars[(byte) read];
if (throwExceptions && (read == NON_BASE_64 || (numPadding > 0 && read > NON_BASE_64))) {
throw new Base64DecodingException(
MessageFormat.format(
"Unexpected char",
(Object[]) new String[]{
"'" + (char) read + "' (0x" + Integer.toHexString(read) + ")"
}
),
(char) read
);
}
if (read == NON_BASE_64_PADDING) {
numPadding++;
}
} while (read <= NON_BASE_64);
return read;
}
|
[
"private",
"static",
"final",
"int",
"readBase64",
"(",
"InputStream",
"in",
",",
"boolean",
"throwExceptions",
")",
"throws",
"IOException",
"{",
"int",
"read",
";",
"int",
"numPadding",
"=",
"0",
";",
"do",
"{",
"read",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"read",
"==",
"END_OF_INPUT",
")",
"{",
"return",
"END_OF_INPUT",
";",
"}",
"read",
"=",
"reverseBase64Chars",
"[",
"(",
"byte",
")",
"read",
"]",
";",
"if",
"(",
"throwExceptions",
"&&",
"(",
"read",
"==",
"NON_BASE_64",
"||",
"(",
"numPadding",
">",
"0",
"&&",
"read",
">",
"NON_BASE_64",
")",
")",
")",
"{",
"throw",
"new",
"Base64DecodingException",
"(",
"MessageFormat",
".",
"format",
"(",
"\"Unexpected char\"",
",",
"(",
"Object",
"[",
"]",
")",
"new",
"String",
"[",
"]",
"{",
"\"'\"",
"+",
"(",
"char",
")",
"read",
"+",
"\"' (0x\"",
"+",
"Integer",
".",
"toHexString",
"(",
"read",
")",
"+",
"\")\"",
"}",
")",
",",
"(",
"char",
")",
"read",
")",
";",
"}",
"if",
"(",
"read",
"==",
"NON_BASE_64_PADDING",
")",
"{",
"numPadding",
"++",
";",
"}",
"}",
"while",
"(",
"read",
"<=",
"NON_BASE_64",
")",
";",
"return",
"read",
";",
"}"
] |
Reads the next (decoded) Base64 character from the input stream. Non Base64 characters are
skipped.
@param in Stream from which bytes are read.
@param throwExceptions Throw an exception if an unexpected character is encountered.
@return the next Base64 character from the stream or -1 if there are no more Base64 characters
on the stream.
@throws IOException if an IO Error occurs.
@throws Base64DecodingException if unexpected data is encountered when throwExceptions is
specified.
@since ostermillerutils 1.00.00
|
[
"Reads",
"the",
"next",
"(",
"decoded",
")",
"Base64",
"character",
"from",
"the",
"input",
"stream",
".",
"Non",
"Base64",
"characters",
"are",
"skipped",
"."
] |
train
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java#L677-L702
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.ejbcontainer/src/com/ibm/ws/ejbcontainer/osgi/internal/naming/EJBJavaColonNamingHelper.java
|
EJBJavaColonNamingHelper.addGlobalBinding
|
public synchronized void addGlobalBinding(String name, EJBBinding bindingObject) {
"""
Add a java:global binding object to the global mapping.
@param name lookup name
@param bindingObject object to use to instantiate EJB at lookup time.
@return
"""
Lock writeLock = javaColonLock.writeLock();
writeLock.lock();
try {
javaColonGlobalBindings.bind(name, bindingObject);
} finally {
writeLock.unlock();
}
}
|
java
|
public synchronized void addGlobalBinding(String name, EJBBinding bindingObject) {
Lock writeLock = javaColonLock.writeLock();
writeLock.lock();
try {
javaColonGlobalBindings.bind(name, bindingObject);
} finally {
writeLock.unlock();
}
}
|
[
"public",
"synchronized",
"void",
"addGlobalBinding",
"(",
"String",
"name",
",",
"EJBBinding",
"bindingObject",
")",
"{",
"Lock",
"writeLock",
"=",
"javaColonLock",
".",
"writeLock",
"(",
")",
";",
"writeLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"javaColonGlobalBindings",
".",
"bind",
"(",
"name",
",",
"bindingObject",
")",
";",
"}",
"finally",
"{",
"writeLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Add a java:global binding object to the global mapping.
@param name lookup name
@param bindingObject object to use to instantiate EJB at lookup time.
@return
|
[
"Add",
"a",
"java",
":",
"global",
"binding",
"object",
"to",
"the",
"global",
"mapping",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer/src/com/ibm/ws/ejbcontainer/osgi/internal/naming/EJBJavaColonNamingHelper.java#L347-L356
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java
|
HttpChannelConfig.parseLimitNumberResponses
|
private void parseLimitNumberResponses(Map<Object, Object> props) {
"""
Check the input configuration for a maximum limit on the number of
temporary responses that will be read and skipped past.
@param props
"""
Object value = props.get(HttpConfigConstants.PROPNAME_LIMIT_NUMBER_RESPONSES);
if (null != value) {
try {
int size = convertInteger(value);
if (HttpConfigConstants.UNLIMITED == size) {
this.limitNumResponses = HttpConfigConstants.MAX_LIMIT_NUMRESPONSES;
} else {
this.limitNumResponses = rangeLimit(size, 1, HttpConfigConstants.MAX_LIMIT_NUMRESPONSES);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Num responses limit is " + getLimitOnNumberOfResponses());
}
} catch (NumberFormatException nfe) {
FFDCFilter.processException(nfe, getClass().getName() + ".parseLimitNumberResponses", "1");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Invalid max number of responses; " + value);
}
}
}
}
|
java
|
private void parseLimitNumberResponses(Map<Object, Object> props) {
Object value = props.get(HttpConfigConstants.PROPNAME_LIMIT_NUMBER_RESPONSES);
if (null != value) {
try {
int size = convertInteger(value);
if (HttpConfigConstants.UNLIMITED == size) {
this.limitNumResponses = HttpConfigConstants.MAX_LIMIT_NUMRESPONSES;
} else {
this.limitNumResponses = rangeLimit(size, 1, HttpConfigConstants.MAX_LIMIT_NUMRESPONSES);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Num responses limit is " + getLimitOnNumberOfResponses());
}
} catch (NumberFormatException nfe) {
FFDCFilter.processException(nfe, getClass().getName() + ".parseLimitNumberResponses", "1");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Invalid max number of responses; " + value);
}
}
}
}
|
[
"private",
"void",
"parseLimitNumberResponses",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"props",
")",
"{",
"Object",
"value",
"=",
"props",
".",
"get",
"(",
"HttpConfigConstants",
".",
"PROPNAME_LIMIT_NUMBER_RESPONSES",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"try",
"{",
"int",
"size",
"=",
"convertInteger",
"(",
"value",
")",
";",
"if",
"(",
"HttpConfigConstants",
".",
"UNLIMITED",
"==",
"size",
")",
"{",
"this",
".",
"limitNumResponses",
"=",
"HttpConfigConstants",
".",
"MAX_LIMIT_NUMRESPONSES",
";",
"}",
"else",
"{",
"this",
".",
"limitNumResponses",
"=",
"rangeLimit",
"(",
"size",
",",
"1",
",",
"HttpConfigConstants",
".",
"MAX_LIMIT_NUMRESPONSES",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Config: Num responses limit is \"",
"+",
"getLimitOnNumberOfResponses",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"nfe",
",",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".parseLimitNumberResponses\"",
",",
"\"1\"",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Config: Invalid max number of responses; \"",
"+",
"value",
")",
";",
"}",
"}",
"}",
"}"
] |
Check the input configuration for a maximum limit on the number of
temporary responses that will be read and skipped past.
@param props
|
[
"Check",
"the",
"input",
"configuration",
"for",
"a",
"maximum",
"limit",
"on",
"the",
"number",
"of",
"temporary",
"responses",
"that",
"will",
"be",
"read",
"and",
"skipped",
"past",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java#L858-L878
|
jenkinsci/artifactory-plugin
|
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java
|
DockerUtils.getBlobSum
|
private static JsonNode getBlobSum(boolean isSchemeVersion1, JsonNode fsLayer) {
"""
Return blob sum depend on scheme version.
@param isSchemeVersion1
@param fsLayer
@return
"""
JsonNode blobSum;
if (isSchemeVersion1) {
blobSum = fsLayer.get("blobSum");
} else {
blobSum = fsLayer.get("digest");
}
if (blobSum == null) {
throw new IllegalStateException("Could not find 'blobSub' or 'digest' in manifest");
}
return blobSum;
}
|
java
|
private static JsonNode getBlobSum(boolean isSchemeVersion1, JsonNode fsLayer) {
JsonNode blobSum;
if (isSchemeVersion1) {
blobSum = fsLayer.get("blobSum");
} else {
blobSum = fsLayer.get("digest");
}
if (blobSum == null) {
throw new IllegalStateException("Could not find 'blobSub' or 'digest' in manifest");
}
return blobSum;
}
|
[
"private",
"static",
"JsonNode",
"getBlobSum",
"(",
"boolean",
"isSchemeVersion1",
",",
"JsonNode",
"fsLayer",
")",
"{",
"JsonNode",
"blobSum",
";",
"if",
"(",
"isSchemeVersion1",
")",
"{",
"blobSum",
"=",
"fsLayer",
".",
"get",
"(",
"\"blobSum\"",
")",
";",
"}",
"else",
"{",
"blobSum",
"=",
"fsLayer",
".",
"get",
"(",
"\"digest\"",
")",
";",
"}",
"if",
"(",
"blobSum",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Could not find 'blobSub' or 'digest' in manifest\"",
")",
";",
"}",
"return",
"blobSum",
";",
"}"
] |
Return blob sum depend on scheme version.
@param isSchemeVersion1
@param fsLayer
@return
|
[
"Return",
"blob",
"sum",
"depend",
"on",
"scheme",
"version",
"."
] |
train
|
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java#L194-L207
|
BioPAX/Paxtools
|
pattern/src/main/java/org/biopax/paxtools/pattern/constraint/IDConstraint.java
|
IDConstraint.satisfies
|
@Override
public boolean satisfies(Match match, int... ind) {
"""
Checks if the element has one of the desired IDs.
@param match current pattern match
@param ind mapped indices
@return true if the ID is in the list
"""
return ids.contains(match.get(ind[0]).getUri());
}
|
java
|
@Override
public boolean satisfies(Match match, int... ind)
{
return ids.contains(match.get(ind[0]).getUri());
}
|
[
"@",
"Override",
"public",
"boolean",
"satisfies",
"(",
"Match",
"match",
",",
"int",
"...",
"ind",
")",
"{",
"return",
"ids",
".",
"contains",
"(",
"match",
".",
"get",
"(",
"ind",
"[",
"0",
"]",
")",
".",
"getUri",
"(",
")",
")",
";",
"}"
] |
Checks if the element has one of the desired IDs.
@param match current pattern match
@param ind mapped indices
@return true if the ID is in the list
|
[
"Checks",
"if",
"the",
"element",
"has",
"one",
"of",
"the",
"desired",
"IDs",
"."
] |
train
|
https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/pattern/src/main/java/org/biopax/paxtools/pattern/constraint/IDConstraint.java#L45-L49
|
xqbase/util
|
util/src/main/java/com/xqbase/util/Bytes.java
|
Bytes.toShort
|
public static int toShort(byte[] b, int off, boolean littleEndian) {
"""
Retrieve a <b>short</b> from a byte array in a given byte order
"""
if (littleEndian) {
return ((b[off] & 0xFF) | ((b[off + 1] & 0xFF) << 8));
}
return (((b[off] & 0xFF) << 8) | (b[off + 1] & 0xFF));
}
|
java
|
public static int toShort(byte[] b, int off, boolean littleEndian) {
if (littleEndian) {
return ((b[off] & 0xFF) | ((b[off + 1] & 0xFF) << 8));
}
return (((b[off] & 0xFF) << 8) | (b[off + 1] & 0xFF));
}
|
[
"public",
"static",
"int",
"toShort",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"off",
",",
"boolean",
"littleEndian",
")",
"{",
"if",
"(",
"littleEndian",
")",
"{",
"return",
"(",
"(",
"b",
"[",
"off",
"]",
"&",
"0xFF",
")",
"|",
"(",
"(",
"b",
"[",
"off",
"+",
"1",
"]",
"&",
"0xFF",
")",
"<<",
"8",
")",
")",
";",
"}",
"return",
"(",
"(",
"(",
"b",
"[",
"off",
"]",
"&",
"0xFF",
")",
"<<",
"8",
")",
"|",
"(",
"b",
"[",
"off",
"+",
"1",
"]",
"&",
"0xFF",
")",
")",
";",
"}"
] |
Retrieve a <b>short</b> from a byte array in a given byte order
|
[
"Retrieve",
"a",
"<b",
">",
"short<",
"/",
"b",
">",
"from",
"a",
"byte",
"array",
"in",
"a",
"given",
"byte",
"order"
] |
train
|
https://github.com/xqbase/util/blob/e7b9167b6c701b9eec988a9d1e68446cef5ef420/util/src/main/java/com/xqbase/util/Bytes.java#L194-L199
|
Coveros/selenified
|
src/main/java/com/coveros/selenified/application/WaitFor.java
|
WaitFor.urlEquals
|
public void urlEquals(double seconds, String expectedURL) {
"""
Asserts that the provided URL equals the actual URL the application is
currently on. This information will be logged and recorded, with a
screenshot for traceability and added debugging support.
@param seconds the number of seconds to wait
@param expectedURL - the expectedURL to wait for
"""
double end = System.currentTimeMillis() + (seconds * 1000);
try {
WebDriverWait wait = new WebDriverWait(app.getDriver(), (long) seconds, DEFAULT_POLLING_INTERVAL);
wait.until(ExpectedConditions.urlToBe(expectedURL));
double timeTook = Math.min((seconds * 1000) - (end - System.currentTimeMillis()), seconds * 1000) / 1000;
checkUrlEquals(expectedURL, seconds, timeTook);
} catch (TimeoutException e) {
checkUrlEquals(expectedURL, seconds, seconds);
}
}
|
java
|
public void urlEquals(double seconds, String expectedURL) {
double end = System.currentTimeMillis() + (seconds * 1000);
try {
WebDriverWait wait = new WebDriverWait(app.getDriver(), (long) seconds, DEFAULT_POLLING_INTERVAL);
wait.until(ExpectedConditions.urlToBe(expectedURL));
double timeTook = Math.min((seconds * 1000) - (end - System.currentTimeMillis()), seconds * 1000) / 1000;
checkUrlEquals(expectedURL, seconds, timeTook);
} catch (TimeoutException e) {
checkUrlEquals(expectedURL, seconds, seconds);
}
}
|
[
"public",
"void",
"urlEquals",
"(",
"double",
"seconds",
",",
"String",
"expectedURL",
")",
"{",
"double",
"end",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"(",
"seconds",
"*",
"1000",
")",
";",
"try",
"{",
"WebDriverWait",
"wait",
"=",
"new",
"WebDriverWait",
"(",
"app",
".",
"getDriver",
"(",
")",
",",
"(",
"long",
")",
"seconds",
",",
"DEFAULT_POLLING_INTERVAL",
")",
";",
"wait",
".",
"until",
"(",
"ExpectedConditions",
".",
"urlToBe",
"(",
"expectedURL",
")",
")",
";",
"double",
"timeTook",
"=",
"Math",
".",
"min",
"(",
"(",
"seconds",
"*",
"1000",
")",
"-",
"(",
"end",
"-",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
",",
"seconds",
"*",
"1000",
")",
"/",
"1000",
";",
"checkUrlEquals",
"(",
"expectedURL",
",",
"seconds",
",",
"timeTook",
")",
";",
"}",
"catch",
"(",
"TimeoutException",
"e",
")",
"{",
"checkUrlEquals",
"(",
"expectedURL",
",",
"seconds",
",",
"seconds",
")",
";",
"}",
"}"
] |
Asserts that the provided URL equals the actual URL the application is
currently on. This information will be logged and recorded, with a
screenshot for traceability and added debugging support.
@param seconds the number of seconds to wait
@param expectedURL - the expectedURL to wait for
|
[
"Asserts",
"that",
"the",
"provided",
"URL",
"equals",
"the",
"actual",
"URL",
"the",
"application",
"is",
"currently",
"on",
".",
"This",
"information",
"will",
"be",
"logged",
"and",
"recorded",
"with",
"a",
"screenshot",
"for",
"traceability",
"and",
"added",
"debugging",
"support",
"."
] |
train
|
https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/application/WaitFor.java#L348-L358
|
Ordinastie/MalisisCore
|
src/main/java/net/malisis/core/util/raytrace/RaytraceWorld.java
|
RaytraceWorld.getMin
|
public double getMin(double x, double y, double z) {
"""
Gets the minimum value of <code>x</code>, <code>y</code>, <code>z</code>.
@param x the x
@param y the y
@param z the z
@return <code>Double.NaN</code> if <code>x</code>, <code>y</code> and <code>z</code> are all three <code>Double.NaN</code>
"""
double ret = Double.NaN;
if (!Double.isNaN(x))
ret = x;
if (!Double.isNaN(y))
{
if (!Double.isNaN(ret))
ret = Math.min(ret, y);
else
ret = y;
}
if (!Double.isNaN(z))
{
if (!Double.isNaN(ret))
ret = Math.min(ret, z);
else
ret = z;
}
return ret;
}
|
java
|
public double getMin(double x, double y, double z)
{
double ret = Double.NaN;
if (!Double.isNaN(x))
ret = x;
if (!Double.isNaN(y))
{
if (!Double.isNaN(ret))
ret = Math.min(ret, y);
else
ret = y;
}
if (!Double.isNaN(z))
{
if (!Double.isNaN(ret))
ret = Math.min(ret, z);
else
ret = z;
}
return ret;
}
|
[
"public",
"double",
"getMin",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
")",
"{",
"double",
"ret",
"=",
"Double",
".",
"NaN",
";",
"if",
"(",
"!",
"Double",
".",
"isNaN",
"(",
"x",
")",
")",
"ret",
"=",
"x",
";",
"if",
"(",
"!",
"Double",
".",
"isNaN",
"(",
"y",
")",
")",
"{",
"if",
"(",
"!",
"Double",
".",
"isNaN",
"(",
"ret",
")",
")",
"ret",
"=",
"Math",
".",
"min",
"(",
"ret",
",",
"y",
")",
";",
"else",
"ret",
"=",
"y",
";",
"}",
"if",
"(",
"!",
"Double",
".",
"isNaN",
"(",
"z",
")",
")",
"{",
"if",
"(",
"!",
"Double",
".",
"isNaN",
"(",
"ret",
")",
")",
"ret",
"=",
"Math",
".",
"min",
"(",
"ret",
",",
"z",
")",
";",
"else",
"ret",
"=",
"z",
";",
"}",
"return",
"ret",
";",
"}"
] |
Gets the minimum value of <code>x</code>, <code>y</code>, <code>z</code>.
@param x the x
@param y the y
@param z the z
@return <code>Double.NaN</code> if <code>x</code>, <code>y</code> and <code>z</code> are all three <code>Double.NaN</code>
|
[
"Gets",
"the",
"minimum",
"value",
"of",
"<code",
">",
"x<",
"/",
"code",
">",
"<code",
">",
"y<",
"/",
"code",
">",
"<code",
">",
"z<",
"/",
"code",
">",
"."
] |
train
|
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/raytrace/RaytraceWorld.java#L251-L271
|
elki-project/elki
|
elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/DoubleDynamicHistogram.java
|
DoubleDynamicHistogram.downsample
|
protected double downsample(double[] data, int start, int end, int size) {
"""
Perform downsampling on a number of bins.
@param data Data array (needs cast!)
@param start Interval start
@param end Interval end (exclusive)
@param size Intended size - extra bins are assumed to be empty, should be a
power of two
@return New bin value
"""
double sum = 0;
for (int i = start; i < end; i++) {
sum += data[i];
}
return sum;
}
|
java
|
protected double downsample(double[] data, int start, int end, int size) {
double sum = 0;
for (int i = start; i < end; i++) {
sum += data[i];
}
return sum;
}
|
[
"protected",
"double",
"downsample",
"(",
"double",
"[",
"]",
"data",
",",
"int",
"start",
",",
"int",
"end",
",",
"int",
"size",
")",
"{",
"double",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"start",
";",
"i",
"<",
"end",
";",
"i",
"++",
")",
"{",
"sum",
"+=",
"data",
"[",
"i",
"]",
";",
"}",
"return",
"sum",
";",
"}"
] |
Perform downsampling on a number of bins.
@param data Data array (needs cast!)
@param start Interval start
@param end Interval end (exclusive)
@param size Intended size - extra bins are assumed to be empty, should be a
power of two
@return New bin value
|
[
"Perform",
"downsampling",
"on",
"a",
"number",
"of",
"bins",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/DoubleDynamicHistogram.java#L242-L248
|
jenetics/jpx
|
jpx/src/main/java/io/jenetics/jpx/IO.java
|
IO.readString
|
static String readString(final DataInput in) throws IOException {
"""
Reads a string value from the given data input.
@param in the data input
@return the read string value
@throws NullPointerException if one of the given arguments is {@code null}
@throws IOException if an I/O error occurs
"""
final byte[] bytes = new byte[readInt(in)];
in.readFully(bytes);
return new String(bytes, "UTF-8");
}
|
java
|
static String readString(final DataInput in) throws IOException {
final byte[] bytes = new byte[readInt(in)];
in.readFully(bytes);
return new String(bytes, "UTF-8");
}
|
[
"static",
"String",
"readString",
"(",
"final",
"DataInput",
"in",
")",
"throws",
"IOException",
"{",
"final",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"readInt",
"(",
"in",
")",
"]",
";",
"in",
".",
"readFully",
"(",
"bytes",
")",
";",
"return",
"new",
"String",
"(",
"bytes",
",",
"\"UTF-8\"",
")",
";",
"}"
] |
Reads a string value from the given data input.
@param in the data input
@return the read string value
@throws NullPointerException if one of the given arguments is {@code null}
@throws IOException if an I/O error occurs
|
[
"Reads",
"a",
"string",
"value",
"from",
"the",
"given",
"data",
"input",
"."
] |
train
|
https://github.com/jenetics/jpx/blob/58fefc10580602d07f1480d6a5886d13a553ff8f/jpx/src/main/java/io/jenetics/jpx/IO.java#L129-L133
|
FDMediagroep/hamcrest-jsoup
|
src/main/java/nl/fd/hamcrest/jsoup/ElementWithAttribute.java
|
ElementWithAttribute.hasAttribute
|
@Factory
public static Matcher<Element> hasAttribute(final String attributeName,
final String expectedValue) {
"""
Creates a {@link org.hamcrest.Matcher} for a JSoup {@link org.jsoup.nodes.Element} with the given {@code expectedValue} for the given {@code
attributeName}. See {@link #hasAttribute(String, org.hamcrest.Matcher)} for use with Matchers.
@param attributeName The attribute name whose value to check
@param expectedValue The attribute value that is expected
@return a {@link org.hamcrest.Matcher} for a JSoup {@link org.jsoup.nodes.Element} with the given {@code expectedValue} for the given {@code
attributeName}
"""
return new ElementWithAttribute(attributeName, Matchers.is(expectedValue));
}
|
java
|
@Factory
public static Matcher<Element> hasAttribute(final String attributeName,
final String expectedValue) {
return new ElementWithAttribute(attributeName, Matchers.is(expectedValue));
}
|
[
"@",
"Factory",
"public",
"static",
"Matcher",
"<",
"Element",
">",
"hasAttribute",
"(",
"final",
"String",
"attributeName",
",",
"final",
"String",
"expectedValue",
")",
"{",
"return",
"new",
"ElementWithAttribute",
"(",
"attributeName",
",",
"Matchers",
".",
"is",
"(",
"expectedValue",
")",
")",
";",
"}"
] |
Creates a {@link org.hamcrest.Matcher} for a JSoup {@link org.jsoup.nodes.Element} with the given {@code expectedValue} for the given {@code
attributeName}. See {@link #hasAttribute(String, org.hamcrest.Matcher)} for use with Matchers.
@param attributeName The attribute name whose value to check
@param expectedValue The attribute value that is expected
@return a {@link org.hamcrest.Matcher} for a JSoup {@link org.jsoup.nodes.Element} with the given {@code expectedValue} for the given {@code
attributeName}
|
[
"Creates",
"a",
"{",
"@link",
"org",
".",
"hamcrest",
".",
"Matcher",
"}",
"for",
"a",
"JSoup",
"{",
"@link",
"org",
".",
"jsoup",
".",
"nodes",
".",
"Element",
"}",
"with",
"the",
"given",
"{",
"@code",
"expectedValue",
"}",
"for",
"the",
"given",
"{",
"@code",
"attributeName",
"}",
".",
"See",
"{",
"@link",
"#hasAttribute",
"(",
"String",
"org",
".",
"hamcrest",
".",
"Matcher",
")",
"}",
"for",
"use",
"with",
"Matchers",
"."
] |
train
|
https://github.com/FDMediagroep/hamcrest-jsoup/blob/b7152dac6f834e40117fb7cfdd3149a268d95f7b/src/main/java/nl/fd/hamcrest/jsoup/ElementWithAttribute.java#L55-L59
|
finmath/finmath-lib
|
src/main/java/net/finmath/marketdata/products/SwapAnnuity.java
|
SwapAnnuity.getSwapAnnuity
|
public static double getSwapAnnuity(Schedule schedule, ForwardCurve forwardCurve) {
"""
Function to calculate an (idealized) single curve swap annuity for a given schedule and forward curve.
The discount curve used to calculate the annuity is calculated from the forward curve using classical
single curve interpretations of forwards and a default period length. The may be a crude approximation.
Note: This method will consider evaluationTime being 0, see {@link net.finmath.marketdata.products.SwapAnnuity#getSwapAnnuity(double, Schedule, DiscountCurve, AnalyticModel)}.
@param schedule The schedule discretization, i.e., the period start and end dates. End dates are considered payment dates and start of the next period.
@param forwardCurve The forward curve.
@return The swap annuity.
"""
DiscountCurve discountCurve = new DiscountCurveFromForwardCurve(forwardCurve.getName());
double evaluationTime = 0.0; // Consider only payment time > 0
return getSwapAnnuity(evaluationTime, schedule, discountCurve, new AnalyticModelFromCurvesAndVols( new Curve[] {forwardCurve, discountCurve} ));
}
|
java
|
public static double getSwapAnnuity(Schedule schedule, ForwardCurve forwardCurve) {
DiscountCurve discountCurve = new DiscountCurveFromForwardCurve(forwardCurve.getName());
double evaluationTime = 0.0; // Consider only payment time > 0
return getSwapAnnuity(evaluationTime, schedule, discountCurve, new AnalyticModelFromCurvesAndVols( new Curve[] {forwardCurve, discountCurve} ));
}
|
[
"public",
"static",
"double",
"getSwapAnnuity",
"(",
"Schedule",
"schedule",
",",
"ForwardCurve",
"forwardCurve",
")",
"{",
"DiscountCurve",
"discountCurve",
"=",
"new",
"DiscountCurveFromForwardCurve",
"(",
"forwardCurve",
".",
"getName",
"(",
")",
")",
";",
"double",
"evaluationTime",
"=",
"0.0",
";",
"// Consider only payment time > 0",
"return",
"getSwapAnnuity",
"(",
"evaluationTime",
",",
"schedule",
",",
"discountCurve",
",",
"new",
"AnalyticModelFromCurvesAndVols",
"(",
"new",
"Curve",
"[",
"]",
"{",
"forwardCurve",
",",
"discountCurve",
"}",
")",
")",
";",
"}"
] |
Function to calculate an (idealized) single curve swap annuity for a given schedule and forward curve.
The discount curve used to calculate the annuity is calculated from the forward curve using classical
single curve interpretations of forwards and a default period length. The may be a crude approximation.
Note: This method will consider evaluationTime being 0, see {@link net.finmath.marketdata.products.SwapAnnuity#getSwapAnnuity(double, Schedule, DiscountCurve, AnalyticModel)}.
@param schedule The schedule discretization, i.e., the period start and end dates. End dates are considered payment dates and start of the next period.
@param forwardCurve The forward curve.
@return The swap annuity.
|
[
"Function",
"to",
"calculate",
"an",
"(",
"idealized",
")",
"single",
"curve",
"swap",
"annuity",
"for",
"a",
"given",
"schedule",
"and",
"forward",
"curve",
".",
"The",
"discount",
"curve",
"used",
"to",
"calculate",
"the",
"annuity",
"is",
"calculated",
"from",
"the",
"forward",
"curve",
"using",
"classical",
"single",
"curve",
"interpretations",
"of",
"forwards",
"and",
"a",
"default",
"period",
"length",
".",
"The",
"may",
"be",
"a",
"crude",
"approximation",
"."
] |
train
|
https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java/net/finmath/marketdata/products/SwapAnnuity.java#L99-L103
|
Azure/azure-sdk-for-java
|
batch/data-plane/src/main/java/com/microsoft/azure/batch/FileOperations.java
|
FileOperations.listFilesFromTask
|
public PagedList<NodeFile> listFilesFromTask(String jobId, String taskId, Boolean recursive, DetailLevel detailLevel) throws BatchErrorException, IOException {
"""
Lists the files in the specified task's directory on its compute node.
@param jobId The ID of the job.
@param taskId The ID of the task.
@param recursive If true, performs a recursive list of all files of the task. If false or null, returns only the files in the root task directory.
@param detailLevel A {@link DetailLevel} used for filtering the list and for controlling which properties are retrieved from the service.
@return A list of {@link NodeFile} objects.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
"""
return listFilesFromTask(jobId, taskId, recursive, detailLevel, null);
}
|
java
|
public PagedList<NodeFile> listFilesFromTask(String jobId, String taskId, Boolean recursive, DetailLevel detailLevel) throws BatchErrorException, IOException {
return listFilesFromTask(jobId, taskId, recursive, detailLevel, null);
}
|
[
"public",
"PagedList",
"<",
"NodeFile",
">",
"listFilesFromTask",
"(",
"String",
"jobId",
",",
"String",
"taskId",
",",
"Boolean",
"recursive",
",",
"DetailLevel",
"detailLevel",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"return",
"listFilesFromTask",
"(",
"jobId",
",",
"taskId",
",",
"recursive",
",",
"detailLevel",
",",
"null",
")",
";",
"}"
] |
Lists the files in the specified task's directory on its compute node.
@param jobId The ID of the job.
@param taskId The ID of the task.
@param recursive If true, performs a recursive list of all files of the task. If false or null, returns only the files in the root task directory.
@param detailLevel A {@link DetailLevel} used for filtering the list and for controlling which properties are retrieved from the service.
@return A list of {@link NodeFile} objects.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
|
[
"Lists",
"the",
"files",
"in",
"the",
"specified",
"task",
"s",
"directory",
"on",
"its",
"compute",
"node",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/FileOperations.java#L88-L90
|
timols/java-gitlab-api
|
src/main/java/org/gitlab/api/GitlabAPI.java
|
GitlabAPI.deleteBuildVariable
|
public void deleteBuildVariable(Integer projectId, GitlabBuildVariable variable)
throws IOException {
"""
Deletes an existing variable.
@param projectId The ID of the project containing the variable.
@param variable The variable to delete.
@throws IOException on gitlab api call error
"""
deleteBuildVariable(projectId, variable.getKey());
}
|
java
|
public void deleteBuildVariable(Integer projectId, GitlabBuildVariable variable)
throws IOException {
deleteBuildVariable(projectId, variable.getKey());
}
|
[
"public",
"void",
"deleteBuildVariable",
"(",
"Integer",
"projectId",
",",
"GitlabBuildVariable",
"variable",
")",
"throws",
"IOException",
"{",
"deleteBuildVariable",
"(",
"projectId",
",",
"variable",
".",
"getKey",
"(",
")",
")",
";",
"}"
] |
Deletes an existing variable.
@param projectId The ID of the project containing the variable.
@param variable The variable to delete.
@throws IOException on gitlab api call error
|
[
"Deletes",
"an",
"existing",
"variable",
"."
] |
train
|
https://github.com/timols/java-gitlab-api/blob/f03eedf952cfbb40306be3bf9234dcf78fab029e/src/main/java/org/gitlab/api/GitlabAPI.java#L3722-L3725
|
d-tarasov/android-intents
|
library/src/com/dmitriy/tarasov/android/intents/IntentUtils.java
|
IntentUtils.sendSms
|
public static Intent sendSms(Context context, String to, String message) {
"""
Send SMS message using built-in app
@param context Application context
@param to Receiver phone number
@param message Text to send
"""
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
String defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(context);
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + to));
intent.putExtra("sms_body", message);
if (defaultSmsPackageName != null) {
intent.setPackage(defaultSmsPackageName);
}
return intent;
} else {
Uri smsUri = Uri.parse("tel:" + to);
Intent intent = new Intent(Intent.ACTION_VIEW, smsUri);
intent.putExtra("address", to);
intent.putExtra("sms_body", message);
intent.setType("vnd.android-dir/mms-sms");
return intent;
}
}
|
java
|
public static Intent sendSms(Context context, String to, String message) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
String defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(context);
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + to));
intent.putExtra("sms_body", message);
if (defaultSmsPackageName != null) {
intent.setPackage(defaultSmsPackageName);
}
return intent;
} else {
Uri smsUri = Uri.parse("tel:" + to);
Intent intent = new Intent(Intent.ACTION_VIEW, smsUri);
intent.putExtra("address", to);
intent.putExtra("sms_body", message);
intent.setType("vnd.android-dir/mms-sms");
return intent;
}
}
|
[
"public",
"static",
"Intent",
"sendSms",
"(",
"Context",
"context",
",",
"String",
"to",
",",
"String",
"message",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"KITKAT",
")",
"{",
"String",
"defaultSmsPackageName",
"=",
"Telephony",
".",
"Sms",
".",
"getDefaultSmsPackage",
"(",
"context",
")",
";",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"Intent",
".",
"ACTION_SENDTO",
",",
"Uri",
".",
"parse",
"(",
"\"smsto:\"",
"+",
"to",
")",
")",
";",
"intent",
".",
"putExtra",
"(",
"\"sms_body\"",
",",
"message",
")",
";",
"if",
"(",
"defaultSmsPackageName",
"!=",
"null",
")",
"{",
"intent",
".",
"setPackage",
"(",
"defaultSmsPackageName",
")",
";",
"}",
"return",
"intent",
";",
"}",
"else",
"{",
"Uri",
"smsUri",
"=",
"Uri",
".",
"parse",
"(",
"\"tel:\"",
"+",
"to",
")",
";",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"Intent",
".",
"ACTION_VIEW",
",",
"smsUri",
")",
";",
"intent",
".",
"putExtra",
"(",
"\"address\"",
",",
"to",
")",
";",
"intent",
".",
"putExtra",
"(",
"\"sms_body\"",
",",
"message",
")",
";",
"intent",
".",
"setType",
"(",
"\"vnd.android-dir/mms-sms\"",
")",
";",
"return",
"intent",
";",
"}",
"}"
] |
Send SMS message using built-in app
@param context Application context
@param to Receiver phone number
@param message Text to send
|
[
"Send",
"SMS",
"message",
"using",
"built",
"-",
"in",
"app"
] |
train
|
https://github.com/d-tarasov/android-intents/blob/ac3c6e2fd88057708988a96eda6240c29efe1b9a/library/src/com/dmitriy/tarasov/android/intents/IntentUtils.java#L118-L135
|
shrinkwrap/shrinkwrap
|
impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/io/IOUtil.java
|
IOUtil.closeOnComplete
|
public static <S extends Closeable> void closeOnComplete(S stream, StreamTask<S> task) {
"""
Helper method to run a specified task and automatically handle the closing of the stream.
@param stream
@param task
"""
closeOnComplete(stream, task, DEFAULT_ERROR_HANDLER);
}
|
java
|
public static <S extends Closeable> void closeOnComplete(S stream, StreamTask<S> task) {
closeOnComplete(stream, task, DEFAULT_ERROR_HANDLER);
}
|
[
"public",
"static",
"<",
"S",
"extends",
"Closeable",
">",
"void",
"closeOnComplete",
"(",
"S",
"stream",
",",
"StreamTask",
"<",
"S",
">",
"task",
")",
"{",
"closeOnComplete",
"(",
"stream",
",",
"task",
",",
"DEFAULT_ERROR_HANDLER",
")",
";",
"}"
] |
Helper method to run a specified task and automatically handle the closing of the stream.
@param stream
@param task
|
[
"Helper",
"method",
"to",
"run",
"a",
"specified",
"task",
"and",
"automatically",
"handle",
"the",
"closing",
"of",
"the",
"stream",
"."
] |
train
|
https://github.com/shrinkwrap/shrinkwrap/blob/3f8a1a6d344651428c709a63ebb52d35343c5387/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/io/IOUtil.java#L229-L231
|
mgm-tp/jfunk
|
jfunk-core/src/main/java/com/mgmtp/jfunk/core/config/JFunkBaseModule.java
|
JFunkBaseModule.providePerfLoadVersion
|
@Provides
@Singleton
@JFunkVersion
protected String providePerfLoadVersion() {
"""
Provides the version of perfLoad as specified in the Maven pom.
@return the version string
"""
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream is = loader.getResourceAsStream("com/mgmtp/jfunk/common/version.txt");
try {
return IOUtils.toString(is, "UTF-8");
} catch (IOException ex) {
throw new IllegalStateException("Could not read jFunk version.", ex);
} finally {
IOUtils.closeQuietly(is);
}
}
|
java
|
@Provides
@Singleton
@JFunkVersion
protected String providePerfLoadVersion() {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream is = loader.getResourceAsStream("com/mgmtp/jfunk/common/version.txt");
try {
return IOUtils.toString(is, "UTF-8");
} catch (IOException ex) {
throw new IllegalStateException("Could not read jFunk version.", ex);
} finally {
IOUtils.closeQuietly(is);
}
}
|
[
"@",
"Provides",
"@",
"Singleton",
"@",
"JFunkVersion",
"protected",
"String",
"providePerfLoadVersion",
"(",
")",
"{",
"ClassLoader",
"loader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"InputStream",
"is",
"=",
"loader",
".",
"getResourceAsStream",
"(",
"\"com/mgmtp/jfunk/common/version.txt\"",
")",
";",
"try",
"{",
"return",
"IOUtils",
".",
"toString",
"(",
"is",
",",
"\"UTF-8\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Could not read jFunk version.\"",
",",
"ex",
")",
";",
"}",
"finally",
"{",
"IOUtils",
".",
"closeQuietly",
"(",
"is",
")",
";",
"}",
"}"
] |
Provides the version of perfLoad as specified in the Maven pom.
@return the version string
|
[
"Provides",
"the",
"version",
"of",
"perfLoad",
"as",
"specified",
"in",
"the",
"Maven",
"pom",
"."
] |
train
|
https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-core/src/main/java/com/mgmtp/jfunk/core/config/JFunkBaseModule.java#L151-L164
|
cogroo/cogroo4
|
cogroo-ann/src/main/java/org/cogroo/config/LanguageConfigurationUtil.java
|
LanguageConfigurationUtil.get
|
public static LanguageConfiguration get(InputStream configuration) {
"""
Creates a {@link LanguageConfiguration} from a {@link InputStream}, which
remains opened.
@param configuration
the input stream
@return a {@link LanguageConfiguration}
"""
try {
return unmarshal(configuration);
} catch (JAXBException e) {
throw new InitializationException("Invalid configuration file.", e);
}
}
|
java
|
public static LanguageConfiguration get(InputStream configuration) {
try {
return unmarshal(configuration);
} catch (JAXBException e) {
throw new InitializationException("Invalid configuration file.", e);
}
}
|
[
"public",
"static",
"LanguageConfiguration",
"get",
"(",
"InputStream",
"configuration",
")",
"{",
"try",
"{",
"return",
"unmarshal",
"(",
"configuration",
")",
";",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"throw",
"new",
"InitializationException",
"(",
"\"Invalid configuration file.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Creates a {@link LanguageConfiguration} from a {@link InputStream}, which
remains opened.
@param configuration
the input stream
@return a {@link LanguageConfiguration}
|
[
"Creates",
"a",
"{",
"@link",
"LanguageConfiguration",
"}",
"from",
"a",
"{",
"@link",
"InputStream",
"}",
"which",
"remains",
"opened",
"."
] |
train
|
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-ann/src/main/java/org/cogroo/config/LanguageConfigurationUtil.java#L69-L75
|
alkacon/opencms-core
|
src/org/opencms/cmis/CmsCmisRelationHelper.java
|
CmsCmisRelationHelper.collectAcl
|
protected Acl collectAcl(CmsObject cms, CmsResource resource, boolean onlyBasic) {
"""
Compiles the ACL for a relation.<p>
@param cms the CMS context
@param resource the resource for which to collect the ACLs
@param onlyBasic flag to only include basic ACEs
@return the ACL for the resource
"""
AccessControlListImpl cmisAcl = new AccessControlListImpl();
List<Ace> cmisAces = new ArrayList<Ace>();
cmisAcl.setAces(cmisAces);
cmisAcl.setExact(Boolean.FALSE);
return cmisAcl;
}
|
java
|
protected Acl collectAcl(CmsObject cms, CmsResource resource, boolean onlyBasic) {
AccessControlListImpl cmisAcl = new AccessControlListImpl();
List<Ace> cmisAces = new ArrayList<Ace>();
cmisAcl.setAces(cmisAces);
cmisAcl.setExact(Boolean.FALSE);
return cmisAcl;
}
|
[
"protected",
"Acl",
"collectAcl",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
",",
"boolean",
"onlyBasic",
")",
"{",
"AccessControlListImpl",
"cmisAcl",
"=",
"new",
"AccessControlListImpl",
"(",
")",
";",
"List",
"<",
"Ace",
">",
"cmisAces",
"=",
"new",
"ArrayList",
"<",
"Ace",
">",
"(",
")",
";",
"cmisAcl",
".",
"setAces",
"(",
"cmisAces",
")",
";",
"cmisAcl",
".",
"setExact",
"(",
"Boolean",
".",
"FALSE",
")",
";",
"return",
"cmisAcl",
";",
"}"
] |
Compiles the ACL for a relation.<p>
@param cms the CMS context
@param resource the resource for which to collect the ACLs
@param onlyBasic flag to only include basic ACEs
@return the ACL for the resource
|
[
"Compiles",
"the",
"ACL",
"for",
"a",
"relation",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/cmis/CmsCmisRelationHelper.java#L366-L373
|
arangodb/spring-data
|
src/main/java/com/arangodb/springframework/repository/query/derived/DerivedQueryCreator.java
|
DerivedQueryCreator.ignorePropertyCase
|
private String ignorePropertyCase(final Part part, final String property) {
"""
Wrapps property expression in order to lower case. Only properties of type String or Iterable<String> are lowered
@param part
@param property
@return
"""
if (!shouldIgnoreCase(part)) {
return property;
}
if (!part.getProperty().getLeafProperty().isCollection()) {
return "LOWER(" + property + ")";
}
return format("(FOR i IN TO_ARRAY(%s) RETURN LOWER(i))", property);
}
|
java
|
private String ignorePropertyCase(final Part part, final String property) {
if (!shouldIgnoreCase(part)) {
return property;
}
if (!part.getProperty().getLeafProperty().isCollection()) {
return "LOWER(" + property + ")";
}
return format("(FOR i IN TO_ARRAY(%s) RETURN LOWER(i))", property);
}
|
[
"private",
"String",
"ignorePropertyCase",
"(",
"final",
"Part",
"part",
",",
"final",
"String",
"property",
")",
"{",
"if",
"(",
"!",
"shouldIgnoreCase",
"(",
"part",
")",
")",
"{",
"return",
"property",
";",
"}",
"if",
"(",
"!",
"part",
".",
"getProperty",
"(",
")",
".",
"getLeafProperty",
"(",
")",
".",
"isCollection",
"(",
")",
")",
"{",
"return",
"\"LOWER(\"",
"+",
"property",
"+",
"\")\"",
";",
"}",
"return",
"format",
"(",
"\"(FOR i IN TO_ARRAY(%s) RETURN LOWER(i))\"",
",",
"property",
")",
";",
"}"
] |
Wrapps property expression in order to lower case. Only properties of type String or Iterable<String> are lowered
@param part
@param property
@return
|
[
"Wrapps",
"property",
"expression",
"in",
"order",
"to",
"lower",
"case",
".",
"Only",
"properties",
"of",
"type",
"String",
"or",
"Iterable<String",
">",
"are",
"lowered"
] |
train
|
https://github.com/arangodb/spring-data/blob/ff8ae53986b353964b9b90bd8199996d5aabf0c1/src/main/java/com/arangodb/springframework/repository/query/derived/DerivedQueryCreator.java#L205-L213
|
Impetus/Kundera
|
src/kundera-couchdb/src/main/java/com/impetus/client/couchdb/CouchDBUtils.java
|
CouchDBUtils.createView
|
static void createView(Map<String, MapReduce> views, String columnName, List<String> columns) {
"""
Creates the view.
@param views
the views
@param columnName
the column name
@param columns
the columns
"""
Iterator<String> iterator = columns.iterator();
MapReduce mapr = new MapReduce();
StringBuilder mapBuilder = new StringBuilder();
StringBuilder ifBuilder = new StringBuilder("function(doc){if(");
StringBuilder emitFunction = new StringBuilder("{emit(");
if (columns != null && columns.size() > 1)
{
emitFunction.append("[");
}
while (iterator.hasNext())
{
String nextToken = iterator.next();
ifBuilder.append("doc." + nextToken);
ifBuilder.append(" && ");
emitFunction.append("doc." + nextToken);
emitFunction.append(",");
}
ifBuilder.delete(ifBuilder.toString().lastIndexOf(" && "), ifBuilder.toString().lastIndexOf(" && ") + 3);
emitFunction.deleteCharAt(emitFunction.toString().lastIndexOf(","));
ifBuilder.append(")");
if (columns != null && columns.size() > 1)
{
emitFunction.append("]");
}
emitFunction.append(", doc)}}");
mapBuilder.append(ifBuilder.toString()).append(emitFunction.toString());
mapr.setMap(mapBuilder.toString());
views.put(columnName, mapr);
}
|
java
|
static void createView(Map<String, MapReduce> views, String columnName, List<String> columns)
{
Iterator<String> iterator = columns.iterator();
MapReduce mapr = new MapReduce();
StringBuilder mapBuilder = new StringBuilder();
StringBuilder ifBuilder = new StringBuilder("function(doc){if(");
StringBuilder emitFunction = new StringBuilder("{emit(");
if (columns != null && columns.size() > 1)
{
emitFunction.append("[");
}
while (iterator.hasNext())
{
String nextToken = iterator.next();
ifBuilder.append("doc." + nextToken);
ifBuilder.append(" && ");
emitFunction.append("doc." + nextToken);
emitFunction.append(",");
}
ifBuilder.delete(ifBuilder.toString().lastIndexOf(" && "), ifBuilder.toString().lastIndexOf(" && ") + 3);
emitFunction.deleteCharAt(emitFunction.toString().lastIndexOf(","));
ifBuilder.append(")");
if (columns != null && columns.size() > 1)
{
emitFunction.append("]");
}
emitFunction.append(", doc)}}");
mapBuilder.append(ifBuilder.toString()).append(emitFunction.toString());
mapr.setMap(mapBuilder.toString());
views.put(columnName, mapr);
}
|
[
"static",
"void",
"createView",
"(",
"Map",
"<",
"String",
",",
"MapReduce",
">",
"views",
",",
"String",
"columnName",
",",
"List",
"<",
"String",
">",
"columns",
")",
"{",
"Iterator",
"<",
"String",
">",
"iterator",
"=",
"columns",
".",
"iterator",
"(",
")",
";",
"MapReduce",
"mapr",
"=",
"new",
"MapReduce",
"(",
")",
";",
"StringBuilder",
"mapBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"StringBuilder",
"ifBuilder",
"=",
"new",
"StringBuilder",
"(",
"\"function(doc){if(\"",
")",
";",
"StringBuilder",
"emitFunction",
"=",
"new",
"StringBuilder",
"(",
"\"{emit(\"",
")",
";",
"if",
"(",
"columns",
"!=",
"null",
"&&",
"columns",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"emitFunction",
".",
"append",
"(",
"\"[\"",
")",
";",
"}",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"nextToken",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"ifBuilder",
".",
"append",
"(",
"\"doc.\"",
"+",
"nextToken",
")",
";",
"ifBuilder",
".",
"append",
"(",
"\" && \"",
")",
";",
"emitFunction",
".",
"append",
"(",
"\"doc.\"",
"+",
"nextToken",
")",
";",
"emitFunction",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"ifBuilder",
".",
"delete",
"(",
"ifBuilder",
".",
"toString",
"(",
")",
".",
"lastIndexOf",
"(",
"\" && \"",
")",
",",
"ifBuilder",
".",
"toString",
"(",
")",
".",
"lastIndexOf",
"(",
"\" && \"",
")",
"+",
"3",
")",
";",
"emitFunction",
".",
"deleteCharAt",
"(",
"emitFunction",
".",
"toString",
"(",
")",
".",
"lastIndexOf",
"(",
"\",\"",
")",
")",
";",
"ifBuilder",
".",
"append",
"(",
"\")\"",
")",
";",
"if",
"(",
"columns",
"!=",
"null",
"&&",
"columns",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"emitFunction",
".",
"append",
"(",
"\"]\"",
")",
";",
"}",
"emitFunction",
".",
"append",
"(",
"\", doc)}}\"",
")",
";",
"mapBuilder",
".",
"append",
"(",
"ifBuilder",
".",
"toString",
"(",
")",
")",
".",
"append",
"(",
"emitFunction",
".",
"toString",
"(",
")",
")",
";",
"mapr",
".",
"setMap",
"(",
"mapBuilder",
".",
"toString",
"(",
")",
")",
";",
"views",
".",
"put",
"(",
"columnName",
",",
"mapr",
")",
";",
"}"
] |
Creates the view.
@param views
the views
@param columnName
the column name
@param columns
the columns
|
[
"Creates",
"the",
"view",
"."
] |
train
|
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-couchdb/src/main/java/com/impetus/client/couchdb/CouchDBUtils.java#L112-L146
|
OpenTSDB/opentsdb
|
src/tsd/HttpQuery.java
|
HttpQuery.makePage
|
public static StringBuilder makePage(final String title,
final String subtitle,
final String body) {
"""
Easy way to generate a small, simple HTML page.
<p>
Equivalent to {@code makePage(null, title, subtitle, body)}.
@param title What should be in the {@code title} tag of the page.
@param subtitle Small sentence to use next to the TSD logo.
@param body The body of the page (excluding the {@code body} tag).
@return A full HTML page.
"""
return makePage(null, title, subtitle, body);
}
|
java
|
public static StringBuilder makePage(final String title,
final String subtitle,
final String body) {
return makePage(null, title, subtitle, body);
}
|
[
"public",
"static",
"StringBuilder",
"makePage",
"(",
"final",
"String",
"title",
",",
"final",
"String",
"subtitle",
",",
"final",
"String",
"body",
")",
"{",
"return",
"makePage",
"(",
"null",
",",
"title",
",",
"subtitle",
",",
"body",
")",
";",
"}"
] |
Easy way to generate a small, simple HTML page.
<p>
Equivalent to {@code makePage(null, title, subtitle, body)}.
@param title What should be in the {@code title} tag of the page.
@param subtitle Small sentence to use next to the TSD logo.
@param body The body of the page (excluding the {@code body} tag).
@return A full HTML page.
|
[
"Easy",
"way",
"to",
"generate",
"a",
"small",
"simple",
"HTML",
"page",
".",
"<p",
">",
"Equivalent",
"to",
"{"
] |
train
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpQuery.java#L914-L918
|
sagiegurari/fax4j
|
src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java
|
VBSFaxClientSpi.formatObject
|
protected Object formatObject(Object object) {
"""
This function formats the provided object to enable embedding
in VBS code.
@param object
The object to format
@return The formatted object
"""
Object formattedObject=object;
if(object==null)
{
formattedObject="";
}
else if(object instanceof String)
{
//get string
String string=(String)object;
//remove characters
string=string.replaceAll("\n","");
string=string.replaceAll("\r","");
string=string.replaceAll("\t","");
string=string.replaceAll("\f","");
string=string.replaceAll("\b","");
string=string.replaceAll("'","");
string=string.replaceAll("\"","");
//get reference
formattedObject=string;
}
else if(object instanceof File)
{
//get file
File file=(File)object;
String filePath=null;
try
{
filePath=file.getCanonicalPath();
}
catch(IOException exception)
{
throw new FaxException("Unable to get file path.",exception);
}
filePath=filePath.replaceAll("\\\\","\\\\\\\\");
//get reference
formattedObject=filePath;
}
return formattedObject;
}
|
java
|
protected Object formatObject(Object object)
{
Object formattedObject=object;
if(object==null)
{
formattedObject="";
}
else if(object instanceof String)
{
//get string
String string=(String)object;
//remove characters
string=string.replaceAll("\n","");
string=string.replaceAll("\r","");
string=string.replaceAll("\t","");
string=string.replaceAll("\f","");
string=string.replaceAll("\b","");
string=string.replaceAll("'","");
string=string.replaceAll("\"","");
//get reference
formattedObject=string;
}
else if(object instanceof File)
{
//get file
File file=(File)object;
String filePath=null;
try
{
filePath=file.getCanonicalPath();
}
catch(IOException exception)
{
throw new FaxException("Unable to get file path.",exception);
}
filePath=filePath.replaceAll("\\\\","\\\\\\\\");
//get reference
formattedObject=filePath;
}
return formattedObject;
}
|
[
"protected",
"Object",
"formatObject",
"(",
"Object",
"object",
")",
"{",
"Object",
"formattedObject",
"=",
"object",
";",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"formattedObject",
"=",
"\"\"",
";",
"}",
"else",
"if",
"(",
"object",
"instanceof",
"String",
")",
"{",
"//get string",
"String",
"string",
"=",
"(",
"String",
")",
"object",
";",
"//remove characters",
"string",
"=",
"string",
".",
"replaceAll",
"(",
"\"\\n\"",
",",
"\"\"",
")",
";",
"string",
"=",
"string",
".",
"replaceAll",
"(",
"\"\\r\"",
",",
"\"\"",
")",
";",
"string",
"=",
"string",
".",
"replaceAll",
"(",
"\"\\t\"",
",",
"\"\"",
")",
";",
"string",
"=",
"string",
".",
"replaceAll",
"(",
"\"\\f\"",
",",
"\"\"",
")",
";",
"string",
"=",
"string",
".",
"replaceAll",
"(",
"\"\\b\"",
",",
"\"\"",
")",
";",
"string",
"=",
"string",
".",
"replaceAll",
"(",
"\"'\"",
",",
"\"\"",
")",
";",
"string",
"=",
"string",
".",
"replaceAll",
"(",
"\"\\\"\"",
",",
"\"\"",
")",
";",
"//get reference",
"formattedObject",
"=",
"string",
";",
"}",
"else",
"if",
"(",
"object",
"instanceof",
"File",
")",
"{",
"//get file",
"File",
"file",
"=",
"(",
"File",
")",
"object",
";",
"String",
"filePath",
"=",
"null",
";",
"try",
"{",
"filePath",
"=",
"file",
".",
"getCanonicalPath",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"exception",
")",
"{",
"throw",
"new",
"FaxException",
"(",
"\"Unable to get file path.\"",
",",
"exception",
")",
";",
"}",
"filePath",
"=",
"filePath",
".",
"replaceAll",
"(",
"\"\\\\\\\\\"",
",",
"\"\\\\\\\\\\\\\\\\\"",
")",
";",
"//get reference",
"formattedObject",
"=",
"filePath",
";",
"}",
"return",
"formattedObject",
";",
"}"
] |
This function formats the provided object to enable embedding
in VBS code.
@param object
The object to format
@return The formatted object
|
[
"This",
"function",
"formats",
"the",
"provided",
"object",
"to",
"enable",
"embedding",
"in",
"VBS",
"code",
"."
] |
train
|
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/vbs/VBSFaxClientSpi.java#L534-L579
|
respoke/respoke-sdk-android
|
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
|
RespokeClient.joinConference
|
public RespokeCall joinConference(RespokeCall.Listener callListener, Context context, String conferenceID) {
"""
Initiate a call to a conference.
@param callListener A listener to receive notifications about the new call
@param context An application context with which to access system resources
@param conferenceID The ID of the conference to call
@return A reference to the new RespokeCall object representing this call
"""
RespokeCall call = null;
if ((null != signalingChannel) && (signalingChannel.connected)) {
call = new RespokeCall(signalingChannel, conferenceID, "conference");
call.setListener(callListener);
call.startCall(context, null, true);
}
return call;
}
|
java
|
public RespokeCall joinConference(RespokeCall.Listener callListener, Context context, String conferenceID) {
RespokeCall call = null;
if ((null != signalingChannel) && (signalingChannel.connected)) {
call = new RespokeCall(signalingChannel, conferenceID, "conference");
call.setListener(callListener);
call.startCall(context, null, true);
}
return call;
}
|
[
"public",
"RespokeCall",
"joinConference",
"(",
"RespokeCall",
".",
"Listener",
"callListener",
",",
"Context",
"context",
",",
"String",
"conferenceID",
")",
"{",
"RespokeCall",
"call",
"=",
"null",
";",
"if",
"(",
"(",
"null",
"!=",
"signalingChannel",
")",
"&&",
"(",
"signalingChannel",
".",
"connected",
")",
")",
"{",
"call",
"=",
"new",
"RespokeCall",
"(",
"signalingChannel",
",",
"conferenceID",
",",
"\"conference\"",
")",
";",
"call",
".",
"setListener",
"(",
"callListener",
")",
";",
"call",
".",
"startCall",
"(",
"context",
",",
"null",
",",
"true",
")",
";",
"}",
"return",
"call",
";",
"}"
] |
Initiate a call to a conference.
@param callListener A listener to receive notifications about the new call
@param context An application context with which to access system resources
@param conferenceID The ID of the conference to call
@return A reference to the new RespokeCall object representing this call
|
[
"Initiate",
"a",
"call",
"to",
"a",
"conference",
"."
] |
train
|
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L489-L500
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.