repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
Wadpam/guja | guja-contact/src/main/java/com/wadpam/guja/dao/GeneratedDContactDaoImpl.java | GeneratedDContactDaoImpl.queryByWebPage | public Iterable<DContact> queryByWebPage(Object parent, java.lang.String webPage) {
"""
query-by method for field webPage
@param webPage the specified attribute
@return an Iterable of DContacts for the specified webPage
"""
return queryByField(parent, DContactMapper.Field.WEBPAGE.getFieldName(), webPage);
} | java | public Iterable<DContact> queryByWebPage(Object parent, java.lang.String webPage) {
return queryByField(parent, DContactMapper.Field.WEBPAGE.getFieldName(), webPage);
} | [
"public",
"Iterable",
"<",
"DContact",
">",
"queryByWebPage",
"(",
"Object",
"parent",
",",
"java",
".",
"lang",
".",
"String",
"webPage",
")",
"{",
"return",
"queryByField",
"(",
"parent",
",",
"DContactMapper",
".",
"Field",
".",
"WEBPAGE",
".",
"getFieldName",
"(",
")",
",",
"webPage",
")",
";",
"}"
] | query-by method for field webPage
@param webPage the specified attribute
@return an Iterable of DContacts for the specified webPage | [
"query",
"-",
"by",
"method",
"for",
"field",
"webPage"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-contact/src/main/java/com/wadpam/guja/dao/GeneratedDContactDaoImpl.java#L313-L315 |
shamanland/xdroid | lib-core/src/main/java/xdroid/core/ThreadUtils.java | ThreadUtils.newHandler | public static Handler newHandler(Handler original, Handler.Callback callback) {
"""
Creates new {@link Handler} with the same {@link Looper} as the original handler.
@param original original handler, can not be null
@param callback message handling callback, may be null
@return new instance
"""
return new Handler(original.getLooper(), callback);
} | java | public static Handler newHandler(Handler original, Handler.Callback callback) {
return new Handler(original.getLooper(), callback);
} | [
"public",
"static",
"Handler",
"newHandler",
"(",
"Handler",
"original",
",",
"Handler",
".",
"Callback",
"callback",
")",
"{",
"return",
"new",
"Handler",
"(",
"original",
".",
"getLooper",
"(",
")",
",",
"callback",
")",
";",
"}"
] | Creates new {@link Handler} with the same {@link Looper} as the original handler.
@param original original handler, can not be null
@param callback message handling callback, may be null
@return new instance | [
"Creates",
"new",
"{",
"@link",
"Handler",
"}",
"with",
"the",
"same",
"{",
"@link",
"Looper",
"}",
"as",
"the",
"original",
"handler",
"."
] | train | https://github.com/shamanland/xdroid/blob/5330811114afaf6a7b8f9a10f3bbe19d37995d89/lib-core/src/main/java/xdroid/core/ThreadUtils.java#L67-L69 |
Wadpam/guja | guja-contact/src/main/java/com/wadpam/guja/dao/GeneratedDContactDaoImpl.java | GeneratedDContactDaoImpl.queryByOtherPhone | public Iterable<DContact> queryByOtherPhone(Object parent, java.lang.String otherPhone) {
"""
query-by method for field otherPhone
@param otherPhone the specified attribute
@return an Iterable of DContacts for the specified otherPhone
"""
return queryByField(parent, DContactMapper.Field.OTHERPHONE.getFieldName(), otherPhone);
} | java | public Iterable<DContact> queryByOtherPhone(Object parent, java.lang.String otherPhone) {
return queryByField(parent, DContactMapper.Field.OTHERPHONE.getFieldName(), otherPhone);
} | [
"public",
"Iterable",
"<",
"DContact",
">",
"queryByOtherPhone",
"(",
"Object",
"parent",
",",
"java",
".",
"lang",
".",
"String",
"otherPhone",
")",
"{",
"return",
"queryByField",
"(",
"parent",
",",
"DContactMapper",
".",
"Field",
".",
"OTHERPHONE",
".",
"getFieldName",
"(",
")",
",",
"otherPhone",
")",
";",
"}"
] | query-by method for field otherPhone
@param otherPhone the specified attribute
@return an Iterable of DContacts for the specified otherPhone | [
"query",
"-",
"by",
"method",
"for",
"field",
"otherPhone"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-contact/src/main/java/com/wadpam/guja/dao/GeneratedDContactDaoImpl.java#L241-L243 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/DialogUtils.java | DialogUtils.isDialog | private boolean isDialog(Activity activity, View decorView) {
"""
Checks that the specified DecorView and the Activity DecorView are not equal.
@param activity the activity which DecorView is to be compared
@param decorView the DecorView to compare
@return true if not equal
"""
if(decorView == null || !decorView.isShown() || activity == null){
return false;
}
Context viewContext = null;
if(decorView != null){
viewContext = decorView.getContext();
}
if (viewContext instanceof ContextThemeWrapper) {
ContextThemeWrapper ctw = (ContextThemeWrapper) viewContext;
viewContext = ctw.getBaseContext();
}
Context activityContext = activity;
Context activityBaseContext = activity.getBaseContext();
return (activityContext.equals(viewContext) || activityBaseContext.equals(viewContext)) && (decorView != activity.getWindow().getDecorView());
} | java | private boolean isDialog(Activity activity, View decorView){
if(decorView == null || !decorView.isShown() || activity == null){
return false;
}
Context viewContext = null;
if(decorView != null){
viewContext = decorView.getContext();
}
if (viewContext instanceof ContextThemeWrapper) {
ContextThemeWrapper ctw = (ContextThemeWrapper) viewContext;
viewContext = ctw.getBaseContext();
}
Context activityContext = activity;
Context activityBaseContext = activity.getBaseContext();
return (activityContext.equals(viewContext) || activityBaseContext.equals(viewContext)) && (decorView != activity.getWindow().getDecorView());
} | [
"private",
"boolean",
"isDialog",
"(",
"Activity",
"activity",
",",
"View",
"decorView",
")",
"{",
"if",
"(",
"decorView",
"==",
"null",
"||",
"!",
"decorView",
".",
"isShown",
"(",
")",
"||",
"activity",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"Context",
"viewContext",
"=",
"null",
";",
"if",
"(",
"decorView",
"!=",
"null",
")",
"{",
"viewContext",
"=",
"decorView",
".",
"getContext",
"(",
")",
";",
"}",
"if",
"(",
"viewContext",
"instanceof",
"ContextThemeWrapper",
")",
"{",
"ContextThemeWrapper",
"ctw",
"=",
"(",
"ContextThemeWrapper",
")",
"viewContext",
";",
"viewContext",
"=",
"ctw",
".",
"getBaseContext",
"(",
")",
";",
"}",
"Context",
"activityContext",
"=",
"activity",
";",
"Context",
"activityBaseContext",
"=",
"activity",
".",
"getBaseContext",
"(",
")",
";",
"return",
"(",
"activityContext",
".",
"equals",
"(",
"viewContext",
")",
"||",
"activityBaseContext",
".",
"equals",
"(",
"viewContext",
")",
")",
"&&",
"(",
"decorView",
"!=",
"activity",
".",
"getWindow",
"(",
")",
".",
"getDecorView",
"(",
")",
")",
";",
"}"
] | Checks that the specified DecorView and the Activity DecorView are not equal.
@param activity the activity which DecorView is to be compared
@param decorView the DecorView to compare
@return true if not equal | [
"Checks",
"that",
"the",
"specified",
"DecorView",
"and",
"the",
"Activity",
"DecorView",
"are",
"not",
"equal",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/DialogUtils.java#L129-L145 |
wildfly/wildfly-core | server/src/main/java/org/jboss/as/server/mgmt/domain/HostControllerConnection.java | HostControllerConnection.asyncReconnect | synchronized void asyncReconnect(final URI reconnectUri, String authKey, final ReconnectCallback callback) {
"""
This continuously tries to reconnect in a separate thread and will only stop if the connection was established
successfully or the server gets shutdown. If there is currently a reconnect task active the connection paramaters
and callback will get updated.
@param reconnectUri the updated connection uri
@param authKey the updated authentication key
@param callback the current callback
"""
if (getState() != State.OPEN) {
return;
}
// Update the configuration with the new credentials
final ProtocolConnectionConfiguration config = ProtocolConnectionConfiguration.copy(configuration);
config.setCallbackHandler(createClientCallbackHandler(userName, authKey));
config.setUri(reconnectUri);
this.configuration = config;
final ReconnectRunner reconnectTask = this.reconnectRunner;
if (reconnectTask == null) {
final ReconnectRunner task = new ReconnectRunner();
task.callback = callback;
task.future = executorService.submit(task);
} else {
reconnectTask.callback = callback;
}
} | java | synchronized void asyncReconnect(final URI reconnectUri, String authKey, final ReconnectCallback callback) {
if (getState() != State.OPEN) {
return;
}
// Update the configuration with the new credentials
final ProtocolConnectionConfiguration config = ProtocolConnectionConfiguration.copy(configuration);
config.setCallbackHandler(createClientCallbackHandler(userName, authKey));
config.setUri(reconnectUri);
this.configuration = config;
final ReconnectRunner reconnectTask = this.reconnectRunner;
if (reconnectTask == null) {
final ReconnectRunner task = new ReconnectRunner();
task.callback = callback;
task.future = executorService.submit(task);
} else {
reconnectTask.callback = callback;
}
} | [
"synchronized",
"void",
"asyncReconnect",
"(",
"final",
"URI",
"reconnectUri",
",",
"String",
"authKey",
",",
"final",
"ReconnectCallback",
"callback",
")",
"{",
"if",
"(",
"getState",
"(",
")",
"!=",
"State",
".",
"OPEN",
")",
"{",
"return",
";",
"}",
"// Update the configuration with the new credentials",
"final",
"ProtocolConnectionConfiguration",
"config",
"=",
"ProtocolConnectionConfiguration",
".",
"copy",
"(",
"configuration",
")",
";",
"config",
".",
"setCallbackHandler",
"(",
"createClientCallbackHandler",
"(",
"userName",
",",
"authKey",
")",
")",
";",
"config",
".",
"setUri",
"(",
"reconnectUri",
")",
";",
"this",
".",
"configuration",
"=",
"config",
";",
"final",
"ReconnectRunner",
"reconnectTask",
"=",
"this",
".",
"reconnectRunner",
";",
"if",
"(",
"reconnectTask",
"==",
"null",
")",
"{",
"final",
"ReconnectRunner",
"task",
"=",
"new",
"ReconnectRunner",
"(",
")",
";",
"task",
".",
"callback",
"=",
"callback",
";",
"task",
".",
"future",
"=",
"executorService",
".",
"submit",
"(",
"task",
")",
";",
"}",
"else",
"{",
"reconnectTask",
".",
"callback",
"=",
"callback",
";",
"}",
"}"
] | This continuously tries to reconnect in a separate thread and will only stop if the connection was established
successfully or the server gets shutdown. If there is currently a reconnect task active the connection paramaters
and callback will get updated.
@param reconnectUri the updated connection uri
@param authKey the updated authentication key
@param callback the current callback | [
"This",
"continuously",
"tries",
"to",
"reconnect",
"in",
"a",
"separate",
"thread",
"and",
"will",
"only",
"stop",
"if",
"the",
"connection",
"was",
"established",
"successfully",
"or",
"the",
"server",
"gets",
"shutdown",
".",
"If",
"there",
"is",
"currently",
"a",
"reconnect",
"task",
"active",
"the",
"connection",
"paramaters",
"and",
"callback",
"will",
"get",
"updated",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/server/src/main/java/org/jboss/as/server/mgmt/domain/HostControllerConnection.java#L152-L170 |
line/centraldogma | server/src/main/java/com/linecorp/centraldogma/server/internal/metadata/MetadataService.java | MetadataService.findPermissions | public CompletableFuture<Collection<Permission>> findPermissions(String projectName, String repoName,
User user) {
"""
Finds {@link Permission}s which belong to the specified {@link User} or {@link UserWithToken}
from the specified {@code repoName} in the specified {@code projectName}.
"""
requireNonNull(user, "user");
if (user.isAdmin()) {
return CompletableFuture.completedFuture(PerRolePermissions.ALL_PERMISSION);
}
if (user instanceof UserWithToken) {
return findPermissions(projectName, repoName, ((UserWithToken) user).token().appId());
} else {
return findPermissions0(projectName, repoName, user);
}
} | java | public CompletableFuture<Collection<Permission>> findPermissions(String projectName, String repoName,
User user) {
requireNonNull(user, "user");
if (user.isAdmin()) {
return CompletableFuture.completedFuture(PerRolePermissions.ALL_PERMISSION);
}
if (user instanceof UserWithToken) {
return findPermissions(projectName, repoName, ((UserWithToken) user).token().appId());
} else {
return findPermissions0(projectName, repoName, user);
}
} | [
"public",
"CompletableFuture",
"<",
"Collection",
"<",
"Permission",
">",
">",
"findPermissions",
"(",
"String",
"projectName",
",",
"String",
"repoName",
",",
"User",
"user",
")",
"{",
"requireNonNull",
"(",
"user",
",",
"\"user\"",
")",
";",
"if",
"(",
"user",
".",
"isAdmin",
"(",
")",
")",
"{",
"return",
"CompletableFuture",
".",
"completedFuture",
"(",
"PerRolePermissions",
".",
"ALL_PERMISSION",
")",
";",
"}",
"if",
"(",
"user",
"instanceof",
"UserWithToken",
")",
"{",
"return",
"findPermissions",
"(",
"projectName",
",",
"repoName",
",",
"(",
"(",
"UserWithToken",
")",
"user",
")",
".",
"token",
"(",
")",
".",
"appId",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"findPermissions0",
"(",
"projectName",
",",
"repoName",
",",
"user",
")",
";",
"}",
"}"
] | Finds {@link Permission}s which belong to the specified {@link User} or {@link UserWithToken}
from the specified {@code repoName} in the specified {@code projectName}. | [
"Finds",
"{"
] | train | https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/metadata/MetadataService.java#L585-L596 |
square/jna-gmp | jnagmp/src/main/java/com/squareup/jnagmp/Gmp.java | Gmp.modInverse | public static BigInteger modInverse(BigInteger val, BigInteger modulus) {
"""
Calculate val^-1 % modulus.
@param val must be positive
@param modulus the modulus
@return val^-1 % modulus
@throws ArithmeticException if modulus is non-positive or val is not invertible
"""
if (modulus.signum() <= 0) {
throw new ArithmeticException("modulus must be positive");
}
return INSTANCE.get().modInverseImpl(val, modulus);
} | java | public static BigInteger modInverse(BigInteger val, BigInteger modulus) {
if (modulus.signum() <= 0) {
throw new ArithmeticException("modulus must be positive");
}
return INSTANCE.get().modInverseImpl(val, modulus);
} | [
"public",
"static",
"BigInteger",
"modInverse",
"(",
"BigInteger",
"val",
",",
"BigInteger",
"modulus",
")",
"{",
"if",
"(",
"modulus",
".",
"signum",
"(",
")",
"<=",
"0",
")",
"{",
"throw",
"new",
"ArithmeticException",
"(",
"\"modulus must be positive\"",
")",
";",
"}",
"return",
"INSTANCE",
".",
"get",
"(",
")",
".",
"modInverseImpl",
"(",
"val",
",",
"modulus",
")",
";",
"}"
] | Calculate val^-1 % modulus.
@param val must be positive
@param modulus the modulus
@return val^-1 % modulus
@throws ArithmeticException if modulus is non-positive or val is not invertible | [
"Calculate",
"val^",
"-",
"1",
"%",
"modulus",
"."
] | train | https://github.com/square/jna-gmp/blob/192d26d97d6773bc3c68ccfa97450f4257d54838/jnagmp/src/main/java/com/squareup/jnagmp/Gmp.java#L150-L155 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/internal/BasicAuthAuthenticator.java | BasicAuthAuthenticator.decodeBasicAuth | @Sensitive
protected String decodeBasicAuth(String data, String encoding) {
"""
2. This method intentionally returns empty string in case of error. With that, a caller doesn't need to check null object prior to introspect it.
"""
String output = "";
byte decodedByte[] = null;
decodedByte = Base64Coder.base64DecodeString(data);
if (decodedByte != null && decodedByte.length > 0) {
boolean decoded = false;
if (encoding != null) {
try {
output = new String(decodedByte, encoding);
decoded = true;
} catch (Exception e) {
// fall back not to use encoding..
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "An exception is caught using the encoder: " + encoding + ". The exception is: " + e.getMessage());
}
}
}
if (!decoded) {
output = new String(decodedByte);
}
}
return output;
} | java | @Sensitive
protected String decodeBasicAuth(String data, String encoding) {
String output = "";
byte decodedByte[] = null;
decodedByte = Base64Coder.base64DecodeString(data);
if (decodedByte != null && decodedByte.length > 0) {
boolean decoded = false;
if (encoding != null) {
try {
output = new String(decodedByte, encoding);
decoded = true;
} catch (Exception e) {
// fall back not to use encoding..
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "An exception is caught using the encoder: " + encoding + ". The exception is: " + e.getMessage());
}
}
}
if (!decoded) {
output = new String(decodedByte);
}
}
return output;
} | [
"@",
"Sensitive",
"protected",
"String",
"decodeBasicAuth",
"(",
"String",
"data",
",",
"String",
"encoding",
")",
"{",
"String",
"output",
"=",
"\"\"",
";",
"byte",
"decodedByte",
"[",
"]",
"=",
"null",
";",
"decodedByte",
"=",
"Base64Coder",
".",
"base64DecodeString",
"(",
"data",
")",
";",
"if",
"(",
"decodedByte",
"!=",
"null",
"&&",
"decodedByte",
".",
"length",
">",
"0",
")",
"{",
"boolean",
"decoded",
"=",
"false",
";",
"if",
"(",
"encoding",
"!=",
"null",
")",
"{",
"try",
"{",
"output",
"=",
"new",
"String",
"(",
"decodedByte",
",",
"encoding",
")",
";",
"decoded",
"=",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// fall back not to use encoding..",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"An exception is caught using the encoder: \"",
"+",
"encoding",
"+",
"\". The exception is: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"decoded",
")",
"{",
"output",
"=",
"new",
"String",
"(",
"decodedByte",
")",
";",
"}",
"}",
"return",
"output",
";",
"}"
] | 2. This method intentionally returns empty string in case of error. With that, a caller doesn't need to check null object prior to introspect it. | [
"2",
".",
"This",
"method",
"intentionally",
"returns",
"empty",
"string",
"in",
"case",
"of",
"error",
".",
"With",
"that",
"a",
"caller",
"doesn",
"t",
"need",
"to",
"check",
"null",
"object",
"prior",
"to",
"introspect",
"it",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/internal/BasicAuthAuthenticator.java#L180-L203 |
googleapis/google-http-java-client | google-http-client/src/main/java/com/google/api/client/util/SslUtils.java | SslUtils.trustAllSSLContext | @Beta
public static SSLContext trustAllSSLContext() throws GeneralSecurityException {
"""
{@link Beta} <br>
Returns an SSL context in which all X.509 certificates are trusted.
<p>Be careful! Disabling SSL certificate validation is dangerous and should only be done in
testing environments.
"""
TrustManager[] trustAllCerts =
new TrustManager[] {
new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {}
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
};
SSLContext context = getTlsSslContext();
context.init(null, trustAllCerts, null);
return context;
} | java | @Beta
public static SSLContext trustAllSSLContext() throws GeneralSecurityException {
TrustManager[] trustAllCerts =
new TrustManager[] {
new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {}
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
};
SSLContext context = getTlsSslContext();
context.init(null, trustAllCerts, null);
return context;
} | [
"@",
"Beta",
"public",
"static",
"SSLContext",
"trustAllSSLContext",
"(",
")",
"throws",
"GeneralSecurityException",
"{",
"TrustManager",
"[",
"]",
"trustAllCerts",
"=",
"new",
"TrustManager",
"[",
"]",
"{",
"new",
"X509TrustManager",
"(",
")",
"{",
"public",
"void",
"checkClientTrusted",
"(",
"X509Certificate",
"[",
"]",
"chain",
",",
"String",
"authType",
")",
"throws",
"CertificateException",
"{",
"}",
"public",
"void",
"checkServerTrusted",
"(",
"X509Certificate",
"[",
"]",
"chain",
",",
"String",
"authType",
")",
"throws",
"CertificateException",
"{",
"}",
"public",
"X509Certificate",
"[",
"]",
"getAcceptedIssuers",
"(",
")",
"{",
"return",
"null",
";",
"}",
"}",
"}",
";",
"SSLContext",
"context",
"=",
"getTlsSslContext",
"(",
")",
";",
"context",
".",
"init",
"(",
"null",
",",
"trustAllCerts",
",",
"null",
")",
";",
"return",
"context",
";",
"}"
] | {@link Beta} <br>
Returns an SSL context in which all X.509 certificates are trusted.
<p>Be careful! Disabling SSL certificate validation is dangerous and should only be done in
testing environments. | [
"{",
"@link",
"Beta",
"}",
"<br",
">",
"Returns",
"an",
"SSL",
"context",
"in",
"which",
"all",
"X",
".",
"509",
"certificates",
"are",
"trusted",
"."
] | train | https://github.com/googleapis/google-http-java-client/blob/0988ae4e0f26a80f579b6adb2b276dd8254928de/google-http-client/src/main/java/com/google/api/client/util/SslUtils.java#L119-L139 |
alkacon/opencms-core | src/org/opencms/util/CmsStringUtil.java | CmsStringUtil.comparePaths | public static boolean comparePaths(String path1, String path2) {
"""
Compares two paths, ignoring leading and trailing slashes.<p>
<b>Directly exposed for JSP EL</b>, not through {@link org.opencms.jsp.util.CmsJspElFunctions}.<p>
@param path1 the first path
@param path2 the second path
@return true if the paths are equal (ignoring leading and trailing slashes)
"""
return addLeadingAndTrailingSlash(path1).equals(addLeadingAndTrailingSlash(path2));
} | java | public static boolean comparePaths(String path1, String path2) {
return addLeadingAndTrailingSlash(path1).equals(addLeadingAndTrailingSlash(path2));
} | [
"public",
"static",
"boolean",
"comparePaths",
"(",
"String",
"path1",
",",
"String",
"path2",
")",
"{",
"return",
"addLeadingAndTrailingSlash",
"(",
"path1",
")",
".",
"equals",
"(",
"addLeadingAndTrailingSlash",
"(",
"path2",
")",
")",
";",
"}"
] | Compares two paths, ignoring leading and trailing slashes.<p>
<b>Directly exposed for JSP EL</b>, not through {@link org.opencms.jsp.util.CmsJspElFunctions}.<p>
@param path1 the first path
@param path2 the second path
@return true if the paths are equal (ignoring leading and trailing slashes) | [
"Compares",
"two",
"paths",
"ignoring",
"leading",
"and",
"trailing",
"slashes",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsStringUtil.java#L326-L329 |
Alluxio/alluxio | core/server/master/src/main/java/alluxio/master/block/meta/MasterWorkerInfo.java | MasterWorkerInfo.updateToRemovedBlock | public void updateToRemovedBlock(boolean add, long blockId) {
"""
Adds or removes a block from the to-be-removed blocks set of the worker.
@param add true if to add, to remove otherwise
@param blockId the id of the block to be added or removed
"""
if (add) {
if (mBlocks.contains(blockId)) {
mToRemoveBlocks.add(blockId);
}
} else {
mToRemoveBlocks.remove(blockId);
}
} | java | public void updateToRemovedBlock(boolean add, long blockId) {
if (add) {
if (mBlocks.contains(blockId)) {
mToRemoveBlocks.add(blockId);
}
} else {
mToRemoveBlocks.remove(blockId);
}
} | [
"public",
"void",
"updateToRemovedBlock",
"(",
"boolean",
"add",
",",
"long",
"blockId",
")",
"{",
"if",
"(",
"add",
")",
"{",
"if",
"(",
"mBlocks",
".",
"contains",
"(",
"blockId",
")",
")",
"{",
"mToRemoveBlocks",
".",
"add",
"(",
"blockId",
")",
";",
"}",
"}",
"else",
"{",
"mToRemoveBlocks",
".",
"remove",
"(",
"blockId",
")",
";",
"}",
"}"
] | Adds or removes a block from the to-be-removed blocks set of the worker.
@param add true if to add, to remove otherwise
@param blockId the id of the block to be added or removed | [
"Adds",
"or",
"removes",
"a",
"block",
"from",
"the",
"to",
"-",
"be",
"-",
"removed",
"blocks",
"set",
"of",
"the",
"worker",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/block/meta/MasterWorkerInfo.java#L397-L405 |
actorapp/actor-platform | actor-sdk/sdk-core/core/core-shared/src/main/java/im/actor/core/Messenger.java | Messenger.deleteMessages | @ObjectiveCName("deleteMessagesWithPeer:withRids:")
public void deleteMessages(Peer peer, long[] rids) {
"""
Delete messages
@param peer destination peer
@param rids rids of messages
"""
modules.getMessagesModule().deleteMessages(peer, rids);
} | java | @ObjectiveCName("deleteMessagesWithPeer:withRids:")
public void deleteMessages(Peer peer, long[] rids) {
modules.getMessagesModule().deleteMessages(peer, rids);
} | [
"@",
"ObjectiveCName",
"(",
"\"deleteMessagesWithPeer:withRids:\"",
")",
"public",
"void",
"deleteMessages",
"(",
"Peer",
"peer",
",",
"long",
"[",
"]",
"rids",
")",
"{",
"modules",
".",
"getMessagesModule",
"(",
")",
".",
"deleteMessages",
"(",
"peer",
",",
"rids",
")",
";",
"}"
] | Delete messages
@param peer destination peer
@param rids rids of messages | [
"Delete",
"messages"
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/core/core-shared/src/main/java/im/actor/core/Messenger.java#L980-L983 |
biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/jmolScript/JmolSymmetryScriptGeneratorH.java | JmolSymmetryScriptGeneratorH.drawAxes | @Override
public String drawAxes() {
"""
Returns a Jmol script that draws symmetry or inertia axes for a structure.
Use showAxes() and hideAxes() to toggle visibility.
@return Jmol script
"""
StringBuilder s = new StringBuilder();
// Point3d centroid = helixAxisAligner.getCentroid();
// System.out.println("Centroid: " + helixAxisAligner.getCentroid());
// Point3d centroid = helixAxisAligner.getGeometricCenter();
Point3d centroid = helixAxisAligner.calcCenterOfRotation();
// System.out.println("Geometric center: " + centroid);
AxisAngle4d axisAngle = helixAxisAligner.getHelixLayers().getByLowestAngle().getAxisAngle();
Vector3d axis = new Vector3d(axisAngle.x, axisAngle.y, axisAngle.z);
s.append("draw axesHelical");
s.append(name);
s.append(0);
s.append(" ");
s.append("line");
Point3d v1 = new Point3d(axis);
v1.scale(AXIS_SCALE_FACTOR*(helixAxisAligner.getDimension().y + SIDE_CHAIN_EXTENSION));
Point3d v2 = new Point3d(v1);
v2.negate();
v1.add(centroid);
v2.add(centroid);
s.append(getJmolPoint(v1));
s.append(getJmolPoint(v2));
s.append("width 1.0 ");
s.append(" color red");
s.append(" off;");
return s.toString();
} | java | @Override
public String drawAxes() {
StringBuilder s = new StringBuilder();
// Point3d centroid = helixAxisAligner.getCentroid();
// System.out.println("Centroid: " + helixAxisAligner.getCentroid());
// Point3d centroid = helixAxisAligner.getGeometricCenter();
Point3d centroid = helixAxisAligner.calcCenterOfRotation();
// System.out.println("Geometric center: " + centroid);
AxisAngle4d axisAngle = helixAxisAligner.getHelixLayers().getByLowestAngle().getAxisAngle();
Vector3d axis = new Vector3d(axisAngle.x, axisAngle.y, axisAngle.z);
s.append("draw axesHelical");
s.append(name);
s.append(0);
s.append(" ");
s.append("line");
Point3d v1 = new Point3d(axis);
v1.scale(AXIS_SCALE_FACTOR*(helixAxisAligner.getDimension().y + SIDE_CHAIN_EXTENSION));
Point3d v2 = new Point3d(v1);
v2.negate();
v1.add(centroid);
v2.add(centroid);
s.append(getJmolPoint(v1));
s.append(getJmolPoint(v2));
s.append("width 1.0 ");
s.append(" color red");
s.append(" off;");
return s.toString();
} | [
"@",
"Override",
"public",
"String",
"drawAxes",
"(",
")",
"{",
"StringBuilder",
"s",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"//\t\tPoint3d centroid = helixAxisAligner.getCentroid();",
"//\t\tSystem.out.println(\"Centroid: \" + helixAxisAligner.getCentroid());",
"//\t\tPoint3d centroid = helixAxisAligner.getGeometricCenter();",
"Point3d",
"centroid",
"=",
"helixAxisAligner",
".",
"calcCenterOfRotation",
"(",
")",
";",
"//\t\tSystem.out.println(\"Geometric center: \" + centroid);",
"AxisAngle4d",
"axisAngle",
"=",
"helixAxisAligner",
".",
"getHelixLayers",
"(",
")",
".",
"getByLowestAngle",
"(",
")",
".",
"getAxisAngle",
"(",
")",
";",
"Vector3d",
"axis",
"=",
"new",
"Vector3d",
"(",
"axisAngle",
".",
"x",
",",
"axisAngle",
".",
"y",
",",
"axisAngle",
".",
"z",
")",
";",
"s",
".",
"append",
"(",
"\"draw axesHelical\"",
")",
";",
"s",
".",
"append",
"(",
"name",
")",
";",
"s",
".",
"append",
"(",
"0",
")",
";",
"s",
".",
"append",
"(",
"\" \"",
")",
";",
"s",
".",
"append",
"(",
"\"line\"",
")",
";",
"Point3d",
"v1",
"=",
"new",
"Point3d",
"(",
"axis",
")",
";",
"v1",
".",
"scale",
"(",
"AXIS_SCALE_FACTOR",
"*",
"(",
"helixAxisAligner",
".",
"getDimension",
"(",
")",
".",
"y",
"+",
"SIDE_CHAIN_EXTENSION",
")",
")",
";",
"Point3d",
"v2",
"=",
"new",
"Point3d",
"(",
"v1",
")",
";",
"v2",
".",
"negate",
"(",
")",
";",
"v1",
".",
"add",
"(",
"centroid",
")",
";",
"v2",
".",
"add",
"(",
"centroid",
")",
";",
"s",
".",
"append",
"(",
"getJmolPoint",
"(",
"v1",
")",
")",
";",
"s",
".",
"append",
"(",
"getJmolPoint",
"(",
"v2",
")",
")",
";",
"s",
".",
"append",
"(",
"\"width 1.0 \"",
")",
";",
"s",
".",
"append",
"(",
"\" color red\"",
")",
";",
"s",
".",
"append",
"(",
"\" off;\"",
")",
";",
"return",
"s",
".",
"toString",
"(",
")",
";",
"}"
] | Returns a Jmol script that draws symmetry or inertia axes for a structure.
Use showAxes() and hideAxes() to toggle visibility.
@return Jmol script | [
"Returns",
"a",
"Jmol",
"script",
"that",
"draws",
"symmetry",
"or",
"inertia",
"axes",
"for",
"a",
"structure",
".",
"Use",
"showAxes",
"()",
"and",
"hideAxes",
"()",
"to",
"toggle",
"visibility",
"."
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/jmolScript/JmolSymmetryScriptGeneratorH.java#L313-L341 |
joniles/mpxj | src/main/java/net/sf/mpxj/phoenix/PhoenixReader.java | PhoenixReader.getCurrentStorepoint | private Storepoint getCurrentStorepoint(Project phoenixProject) {
"""
Retrieve the most recent storepoint.
@param phoenixProject project data
@return Storepoint instance
"""
List<Storepoint> storepoints = phoenixProject.getStorepoints().getStorepoint();
Collections.sort(storepoints, new Comparator<Storepoint>()
{
@Override public int compare(Storepoint o1, Storepoint o2)
{
return DateHelper.compare(o2.getCreationTime(), o1.getCreationTime());
}
});
return storepoints.get(0);
} | java | private Storepoint getCurrentStorepoint(Project phoenixProject)
{
List<Storepoint> storepoints = phoenixProject.getStorepoints().getStorepoint();
Collections.sort(storepoints, new Comparator<Storepoint>()
{
@Override public int compare(Storepoint o1, Storepoint o2)
{
return DateHelper.compare(o2.getCreationTime(), o1.getCreationTime());
}
});
return storepoints.get(0);
} | [
"private",
"Storepoint",
"getCurrentStorepoint",
"(",
"Project",
"phoenixProject",
")",
"{",
"List",
"<",
"Storepoint",
">",
"storepoints",
"=",
"phoenixProject",
".",
"getStorepoints",
"(",
")",
".",
"getStorepoint",
"(",
")",
";",
"Collections",
".",
"sort",
"(",
"storepoints",
",",
"new",
"Comparator",
"<",
"Storepoint",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"Storepoint",
"o1",
",",
"Storepoint",
"o2",
")",
"{",
"return",
"DateHelper",
".",
"compare",
"(",
"o2",
".",
"getCreationTime",
"(",
")",
",",
"o1",
".",
"getCreationTime",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"storepoints",
".",
"get",
"(",
"0",
")",
";",
"}"
] | Retrieve the most recent storepoint.
@param phoenixProject project data
@return Storepoint instance | [
"Retrieve",
"the",
"most",
"recent",
"storepoint",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/phoenix/PhoenixReader.java#L713-L724 |
janus-project/guava.janusproject.io | guava/src/com/google/common/primitives/UnsignedInteger.java | UnsignedInteger.dividedBy | @CheckReturnValue
public UnsignedInteger dividedBy(UnsignedInteger val) {
"""
Returns the result of dividing this by {@code val}.
@throws ArithmeticException if {@code val} is zero
@since 14.0
"""
return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value));
} | java | @CheckReturnValue
public UnsignedInteger dividedBy(UnsignedInteger val) {
return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value));
} | [
"@",
"CheckReturnValue",
"public",
"UnsignedInteger",
"dividedBy",
"(",
"UnsignedInteger",
"val",
")",
"{",
"return",
"fromIntBits",
"(",
"UnsignedInts",
".",
"divide",
"(",
"value",
",",
"checkNotNull",
"(",
"val",
")",
".",
"value",
")",
")",
";",
"}"
] | Returns the result of dividing this by {@code val}.
@throws ArithmeticException if {@code val} is zero
@since 14.0 | [
"Returns",
"the",
"result",
"of",
"dividing",
"this",
"by",
"{",
"@code",
"val",
"}",
"."
] | train | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/primitives/UnsignedInteger.java#L159-L162 |
nextreports/nextreports-engine | src/ro/nextreports/engine/queryexec/util/QueryResultPrinter.java | QueryResultPrinter.overwrite | static void overwrite(StringBuffer sb, int pos, String s) {
"""
This utility method is used when printing the table of results.
"""
int len = s.length();
for (int i = 0; i < len; i++) {
sb.setCharAt(pos + i, s.charAt(i));
}
} | java | static void overwrite(StringBuffer sb, int pos, String s) {
int len = s.length();
for (int i = 0; i < len; i++) {
sb.setCharAt(pos + i, s.charAt(i));
}
} | [
"static",
"void",
"overwrite",
"(",
"StringBuffer",
"sb",
",",
"int",
"pos",
",",
"String",
"s",
")",
"{",
"int",
"len",
"=",
"s",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"sb",
".",
"setCharAt",
"(",
"pos",
"+",
"i",
",",
"s",
".",
"charAt",
"(",
"i",
")",
")",
";",
"}",
"}"
] | This utility method is used when printing the table of results. | [
"This",
"utility",
"method",
"is",
"used",
"when",
"printing",
"the",
"table",
"of",
"results",
"."
] | train | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/queryexec/util/QueryResultPrinter.java#L154-L159 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/TimeSeriesUtils.java | TimeSeriesUtils.reverseTimeSeriesMask | public static INDArray reverseTimeSeriesMask(INDArray mask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType) {
"""
Reverse a (per time step) time series mask, with shape [minibatch, timeSeriesLength]
@param mask Mask to reverse along time dimension
@return Mask after reversing
"""
if(mask == null){
return null;
}
if(mask.rank() == 3){
//Should normally not be used - but handle the per-output masking case
return reverseTimeSeries(mask, workspaceMgr, arrayType);
} else if(mask.rank() != 2){
throw new IllegalArgumentException("Invalid mask rank: must be rank 2 or 3. Got rank " + mask.rank()
+ " with shape " + Arrays.toString(mask.shape()));
}
// FIXME: int cast
int[] idxs = new int[(int) mask.size(1)];
int j=0;
for( int i=idxs.length-1; i>=0; i--){
idxs[j++] = i;
}
INDArray ret = workspaceMgr.createUninitialized(arrayType, mask.dataType(), new long[]{mask.size(0), idxs.length}, 'f');
return Nd4j.pullRows(mask, ret, 0, idxs);
/*
//Assume input mask is 2d: [minibatch, tsLength]
INDArray out = Nd4j.createUninitialized(mask.shape(), 'f');
CustomOp op = DynamicCustomOp.builder("reverse")
.addIntegerArguments(new int[]{1})
.addInputs(mask)
.addOutputs(out)
.callInplace(false)
.build();
Nd4j.getExecutioner().exec(op);
return out;
*/
} | java | public static INDArray reverseTimeSeriesMask(INDArray mask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType){
if(mask == null){
return null;
}
if(mask.rank() == 3){
//Should normally not be used - but handle the per-output masking case
return reverseTimeSeries(mask, workspaceMgr, arrayType);
} else if(mask.rank() != 2){
throw new IllegalArgumentException("Invalid mask rank: must be rank 2 or 3. Got rank " + mask.rank()
+ " with shape " + Arrays.toString(mask.shape()));
}
// FIXME: int cast
int[] idxs = new int[(int) mask.size(1)];
int j=0;
for( int i=idxs.length-1; i>=0; i--){
idxs[j++] = i;
}
INDArray ret = workspaceMgr.createUninitialized(arrayType, mask.dataType(), new long[]{mask.size(0), idxs.length}, 'f');
return Nd4j.pullRows(mask, ret, 0, idxs);
/*
//Assume input mask is 2d: [minibatch, tsLength]
INDArray out = Nd4j.createUninitialized(mask.shape(), 'f');
CustomOp op = DynamicCustomOp.builder("reverse")
.addIntegerArguments(new int[]{1})
.addInputs(mask)
.addOutputs(out)
.callInplace(false)
.build();
Nd4j.getExecutioner().exec(op);
return out;
*/
} | [
"public",
"static",
"INDArray",
"reverseTimeSeriesMask",
"(",
"INDArray",
"mask",
",",
"LayerWorkspaceMgr",
"workspaceMgr",
",",
"ArrayType",
"arrayType",
")",
"{",
"if",
"(",
"mask",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"mask",
".",
"rank",
"(",
")",
"==",
"3",
")",
"{",
"//Should normally not be used - but handle the per-output masking case",
"return",
"reverseTimeSeries",
"(",
"mask",
",",
"workspaceMgr",
",",
"arrayType",
")",
";",
"}",
"else",
"if",
"(",
"mask",
".",
"rank",
"(",
")",
"!=",
"2",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid mask rank: must be rank 2 or 3. Got rank \"",
"+",
"mask",
".",
"rank",
"(",
")",
"+",
"\" with shape \"",
"+",
"Arrays",
".",
"toString",
"(",
"mask",
".",
"shape",
"(",
")",
")",
")",
";",
"}",
"// FIXME: int cast",
"int",
"[",
"]",
"idxs",
"=",
"new",
"int",
"[",
"(",
"int",
")",
"mask",
".",
"size",
"(",
"1",
")",
"]",
";",
"int",
"j",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"idxs",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"idxs",
"[",
"j",
"++",
"]",
"=",
"i",
";",
"}",
"INDArray",
"ret",
"=",
"workspaceMgr",
".",
"createUninitialized",
"(",
"arrayType",
",",
"mask",
".",
"dataType",
"(",
")",
",",
"new",
"long",
"[",
"]",
"{",
"mask",
".",
"size",
"(",
"0",
")",
",",
"idxs",
".",
"length",
"}",
",",
"'",
"'",
")",
";",
"return",
"Nd4j",
".",
"pullRows",
"(",
"mask",
",",
"ret",
",",
"0",
",",
"idxs",
")",
";",
"/*\n //Assume input mask is 2d: [minibatch, tsLength]\n INDArray out = Nd4j.createUninitialized(mask.shape(), 'f');\n CustomOp op = DynamicCustomOp.builder(\"reverse\")\n .addIntegerArguments(new int[]{1})\n .addInputs(mask)\n .addOutputs(out)\n .callInplace(false)\n .build();\n Nd4j.getExecutioner().exec(op);\n return out;\n */",
"}"
] | Reverse a (per time step) time series mask, with shape [minibatch, timeSeriesLength]
@param mask Mask to reverse along time dimension
@return Mask after reversing | [
"Reverse",
"a",
"(",
"per",
"time",
"step",
")",
"time",
"series",
"mask",
"with",
"shape",
"[",
"minibatch",
"timeSeriesLength",
"]"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/TimeSeriesUtils.java#L310-L345 |
OpenLiberty/open-liberty | dev/com.ibm.ws.cdi.web/src/com/ibm/ws/cdi/web/impl/AbstractTerminalListenerRegistration.java | AbstractTerminalListenerRegistration.registerListener | @Override
public void registerListener(IServletContext isc, AsyncContextImpl ac) {
"""
/*
This method is called just before the AsyncListener onComplete. onError or onTimeout
methods are called. It registers an AsyncListener which will be run after
any application AsyncListenes.
"""
Object obj = isc.getAttribute(AbstractInitialListenerRegistration.WELD_INITIAL_LISTENER_ATTRIBUTE);
if (obj != null) {
ServletRequestListener wl = (ServletRequestListener) obj;
WeldTerminalAsyncListener asyncListener = new WeldTerminalAsyncListener(wl, isc);
ac.addListener(asyncListener, ac.getIExtendedRequest(), ac.getIExtendedResponse());
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "added WeldInitialAsyncListener to the asyncContext");
}
} | java | @Override
public void registerListener(IServletContext isc, AsyncContextImpl ac) {
Object obj = isc.getAttribute(AbstractInitialListenerRegistration.WELD_INITIAL_LISTENER_ATTRIBUTE);
if (obj != null) {
ServletRequestListener wl = (ServletRequestListener) obj;
WeldTerminalAsyncListener asyncListener = new WeldTerminalAsyncListener(wl, isc);
ac.addListener(asyncListener, ac.getIExtendedRequest(), ac.getIExtendedResponse());
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "added WeldInitialAsyncListener to the asyncContext");
}
} | [
"@",
"Override",
"public",
"void",
"registerListener",
"(",
"IServletContext",
"isc",
",",
"AsyncContextImpl",
"ac",
")",
"{",
"Object",
"obj",
"=",
"isc",
".",
"getAttribute",
"(",
"AbstractInitialListenerRegistration",
".",
"WELD_INITIAL_LISTENER_ATTRIBUTE",
")",
";",
"if",
"(",
"obj",
"!=",
"null",
")",
"{",
"ServletRequestListener",
"wl",
"=",
"(",
"ServletRequestListener",
")",
"obj",
";",
"WeldTerminalAsyncListener",
"asyncListener",
"=",
"new",
"WeldTerminalAsyncListener",
"(",
"wl",
",",
"isc",
")",
";",
"ac",
".",
"addListener",
"(",
"asyncListener",
",",
"ac",
".",
"getIExtendedRequest",
"(",
")",
",",
"ac",
".",
"getIExtendedResponse",
"(",
")",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"added WeldInitialAsyncListener to the asyncContext\"",
")",
";",
"}",
"}"
] | /*
This method is called just before the AsyncListener onComplete. onError or onTimeout
methods are called. It registers an AsyncListener which will be run after
any application AsyncListenes. | [
"/",
"*",
"This",
"method",
"is",
"called",
"just",
"before",
"the",
"AsyncListener",
"onComplete",
".",
"onError",
"or",
"onTimeout",
"methods",
"are",
"called",
".",
"It",
"registers",
"an",
"AsyncListener",
"which",
"will",
"be",
"run",
"after",
"any",
"application",
"AsyncListenes",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.cdi.web/src/com/ibm/ws/cdi/web/impl/AbstractTerminalListenerRegistration.java#L80-L90 |
glyptodon/guacamole-client | extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/totp/TOTPGenerator.java | TOTPGenerator.getHMAC | private byte[] getHMAC(byte[] message) {
"""
Calculates the HMAC for the given message using the key and algorithm
provided when this TOTPGenerator was created.
@param message
The message to calculate the HMAC of.
@return
The HMAC of the given message.
"""
try {
return getMacInstance(mode, key).doFinal(message);
}
catch (InvalidKeyException e) {
// As the key is verified during construction of the TOTPGenerator,
// this should never happen
throw new IllegalStateException("Provided key became invalid after "
+ "passing validation.", e);
}
} | java | private byte[] getHMAC(byte[] message) {
try {
return getMacInstance(mode, key).doFinal(message);
}
catch (InvalidKeyException e) {
// As the key is verified during construction of the TOTPGenerator,
// this should never happen
throw new IllegalStateException("Provided key became invalid after "
+ "passing validation.", e);
}
} | [
"private",
"byte",
"[",
"]",
"getHMAC",
"(",
"byte",
"[",
"]",
"message",
")",
"{",
"try",
"{",
"return",
"getMacInstance",
"(",
"mode",
",",
"key",
")",
".",
"doFinal",
"(",
"message",
")",
";",
"}",
"catch",
"(",
"InvalidKeyException",
"e",
")",
"{",
"// As the key is verified during construction of the TOTPGenerator,",
"// this should never happen",
"throw",
"new",
"IllegalStateException",
"(",
"\"Provided key became invalid after \"",
"+",
"\"passing validation.\"",
",",
"e",
")",
";",
"}",
"}"
] | Calculates the HMAC for the given message using the key and algorithm
provided when this TOTPGenerator was created.
@param message
The message to calculate the HMAC of.
@return
The HMAC of the given message. | [
"Calculates",
"the",
"HMAC",
"for",
"the",
"given",
"message",
"using",
"the",
"key",
"and",
"algorithm",
"provided",
"when",
"this",
"TOTPGenerator",
"was",
"created",
"."
] | train | https://github.com/glyptodon/guacamole-client/blob/ea1b10e9d1e3f1fa640dff2ca64d61b44bf1ace9/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/totp/TOTPGenerator.java#L324-L338 |
facebookarchive/hadoop-20 | src/contrib/raid/src/java/org/apache/hadoop/raid/RaidShell.java | RaidShell.verifyFile | private void verifyFile(String[] args, int startIndex) {
"""
Scan file and verify the checksums match the checksum store if have
args[] contains the root where we need to check
"""
Path root = null;
if (args.length <= startIndex) {
throw new IllegalArgumentException("too few arguments");
}
String arg = args[startIndex];
root = new Path(arg);
try {
FileSystem fs = root.getFileSystem(conf);
// Make sure default uri is the same as root
conf.set(FileSystem.FS_DEFAULT_NAME_KEY, fs.getUri().toString());
FileVerifier fv = new FileVerifier(conf);
fv.verifyFile(root, System.out);
} catch (IOException ex) {
System.err.println("verifyFile: " + ex);
}
} | java | private void verifyFile(String[] args, int startIndex) {
Path root = null;
if (args.length <= startIndex) {
throw new IllegalArgumentException("too few arguments");
}
String arg = args[startIndex];
root = new Path(arg);
try {
FileSystem fs = root.getFileSystem(conf);
// Make sure default uri is the same as root
conf.set(FileSystem.FS_DEFAULT_NAME_KEY, fs.getUri().toString());
FileVerifier fv = new FileVerifier(conf);
fv.verifyFile(root, System.out);
} catch (IOException ex) {
System.err.println("verifyFile: " + ex);
}
} | [
"private",
"void",
"verifyFile",
"(",
"String",
"[",
"]",
"args",
",",
"int",
"startIndex",
")",
"{",
"Path",
"root",
"=",
"null",
";",
"if",
"(",
"args",
".",
"length",
"<=",
"startIndex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"too few arguments\"",
")",
";",
"}",
"String",
"arg",
"=",
"args",
"[",
"startIndex",
"]",
";",
"root",
"=",
"new",
"Path",
"(",
"arg",
")",
";",
"try",
"{",
"FileSystem",
"fs",
"=",
"root",
".",
"getFileSystem",
"(",
"conf",
")",
";",
"// Make sure default uri is the same as root ",
"conf",
".",
"set",
"(",
"FileSystem",
".",
"FS_DEFAULT_NAME_KEY",
",",
"fs",
".",
"getUri",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"FileVerifier",
"fv",
"=",
"new",
"FileVerifier",
"(",
"conf",
")",
";",
"fv",
".",
"verifyFile",
"(",
"root",
",",
"System",
".",
"out",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"verifyFile: \"",
"+",
"ex",
")",
";",
"}",
"}"
] | Scan file and verify the checksums match the checksum store if have
args[] contains the root where we need to check | [
"Scan",
"file",
"and",
"verify",
"the",
"checksums",
"match",
"the",
"checksum",
"store",
"if",
"have",
"args",
"[]",
"contains",
"the",
"root",
"where",
"we",
"need",
"to",
"check"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/raid/src/java/org/apache/hadoop/raid/RaidShell.java#L707-L723 |
apache/spark | common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java | UTF8String.indexOf | public int indexOf(UTF8String v, int start) {
"""
Returns the position of the first occurrence of substr in
current string from the specified position (0-based index).
@param v the string to be searched
@param start the start position of the current string for searching
@return the position of the first occurrence of substr, if not found, -1 returned.
"""
if (v.numBytes() == 0) {
return 0;
}
// locate to the start position.
int i = 0; // position in byte
int c = 0; // position in character
while (i < numBytes && c < start) {
i += numBytesForFirstByte(getByte(i));
c += 1;
}
do {
if (i + v.numBytes > numBytes) {
return -1;
}
if (ByteArrayMethods.arrayEquals(base, offset + i, v.base, v.offset, v.numBytes)) {
return c;
}
i += numBytesForFirstByte(getByte(i));
c += 1;
} while (i < numBytes);
return -1;
} | java | public int indexOf(UTF8String v, int start) {
if (v.numBytes() == 0) {
return 0;
}
// locate to the start position.
int i = 0; // position in byte
int c = 0; // position in character
while (i < numBytes && c < start) {
i += numBytesForFirstByte(getByte(i));
c += 1;
}
do {
if (i + v.numBytes > numBytes) {
return -1;
}
if (ByteArrayMethods.arrayEquals(base, offset + i, v.base, v.offset, v.numBytes)) {
return c;
}
i += numBytesForFirstByte(getByte(i));
c += 1;
} while (i < numBytes);
return -1;
} | [
"public",
"int",
"indexOf",
"(",
"UTF8String",
"v",
",",
"int",
"start",
")",
"{",
"if",
"(",
"v",
".",
"numBytes",
"(",
")",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"// locate to the start position.",
"int",
"i",
"=",
"0",
";",
"// position in byte",
"int",
"c",
"=",
"0",
";",
"// position in character",
"while",
"(",
"i",
"<",
"numBytes",
"&&",
"c",
"<",
"start",
")",
"{",
"i",
"+=",
"numBytesForFirstByte",
"(",
"getByte",
"(",
"i",
")",
")",
";",
"c",
"+=",
"1",
";",
"}",
"do",
"{",
"if",
"(",
"i",
"+",
"v",
".",
"numBytes",
">",
"numBytes",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"ByteArrayMethods",
".",
"arrayEquals",
"(",
"base",
",",
"offset",
"+",
"i",
",",
"v",
".",
"base",
",",
"v",
".",
"offset",
",",
"v",
".",
"numBytes",
")",
")",
"{",
"return",
"c",
";",
"}",
"i",
"+=",
"numBytesForFirstByte",
"(",
"getByte",
"(",
"i",
")",
")",
";",
"c",
"+=",
"1",
";",
"}",
"while",
"(",
"i",
"<",
"numBytes",
")",
";",
"return",
"-",
"1",
";",
"}"
] | Returns the position of the first occurrence of substr in
current string from the specified position (0-based index).
@param v the string to be searched
@param start the start position of the current string for searching
@return the position of the first occurrence of substr, if not found, -1 returned. | [
"Returns",
"the",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"substr",
"in",
"current",
"string",
"from",
"the",
"specified",
"position",
"(",
"0",
"-",
"based",
"index",
")",
"."
] | train | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java#L710-L735 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/timing/StopWatch.java | StopWatch.runMeasured | @Nonnull
public static TimeValue runMeasured (@Nonnull final Runnable aRunnable) {
"""
Run the passed runnable and measure the time.
@param aRunnable
The runnable to be executed. May not be <code>null</code>.
@return The elapsed time. Never <code>null</code>.
"""
final StopWatch aSW = createdStarted ();
aRunnable.run ();
final long nNanos = aSW.stopAndGetNanos ();
return new TimeValue (TimeUnit.NANOSECONDS, nNanos);
} | java | @Nonnull
public static TimeValue runMeasured (@Nonnull final Runnable aRunnable)
{
final StopWatch aSW = createdStarted ();
aRunnable.run ();
final long nNanos = aSW.stopAndGetNanos ();
return new TimeValue (TimeUnit.NANOSECONDS, nNanos);
} | [
"@",
"Nonnull",
"public",
"static",
"TimeValue",
"runMeasured",
"(",
"@",
"Nonnull",
"final",
"Runnable",
"aRunnable",
")",
"{",
"final",
"StopWatch",
"aSW",
"=",
"createdStarted",
"(",
")",
";",
"aRunnable",
".",
"run",
"(",
")",
";",
"final",
"long",
"nNanos",
"=",
"aSW",
".",
"stopAndGetNanos",
"(",
")",
";",
"return",
"new",
"TimeValue",
"(",
"TimeUnit",
".",
"NANOSECONDS",
",",
"nNanos",
")",
";",
"}"
] | Run the passed runnable and measure the time.
@param aRunnable
The runnable to be executed. May not be <code>null</code>.
@return The elapsed time. Never <code>null</code>. | [
"Run",
"the",
"passed",
"runnable",
"and",
"measure",
"the",
"time",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/timing/StopWatch.java#L274-L281 |
magro/memcached-session-manager | core/src/main/java/de/javakaffee/web/msm/MemcachedNodesManager.java | MemcachedNodesManager.setNodeAvailable | public void setNodeAvailable(@Nullable final String nodeId, final boolean available) {
"""
Mark the given nodeId as available as specified.
@param nodeId the nodeId to update
@param available specifies if the node was abailable or not
"""
if ( _nodeIdService != null ) {
_nodeIdService.setNodeAvailable(nodeId, available);
}
} | java | public void setNodeAvailable(@Nullable final String nodeId, final boolean available) {
if ( _nodeIdService != null ) {
_nodeIdService.setNodeAvailable(nodeId, available);
}
} | [
"public",
"void",
"setNodeAvailable",
"(",
"@",
"Nullable",
"final",
"String",
"nodeId",
",",
"final",
"boolean",
"available",
")",
"{",
"if",
"(",
"_nodeIdService",
"!=",
"null",
")",
"{",
"_nodeIdService",
".",
"setNodeAvailable",
"(",
"nodeId",
",",
"available",
")",
";",
"}",
"}"
] | Mark the given nodeId as available as specified.
@param nodeId the nodeId to update
@param available specifies if the node was abailable or not | [
"Mark",
"the",
"given",
"nodeId",
"as",
"available",
"as",
"specified",
"."
] | train | https://github.com/magro/memcached-session-manager/blob/716e147c9840ab10298c4d2b9edd0662058331e6/core/src/main/java/de/javakaffee/web/msm/MemcachedNodesManager.java#L412-L416 |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/process/ProcessExecutor.java | ProcessExecutor.createTransitionInstance | public TransitionInstance createTransitionInstance(Transition transition, Long pProcessInstId)
throws DataAccessException {
"""
Creates a new instance of the WorkTransationInstance entity
@param transition
@param pProcessInstId
@return WorkTransitionInstance object
"""
TransactionWrapper transaction=null;
try {
transaction = startTransaction();
return engineImpl.createTransitionInstance(transition, pProcessInstId);
} catch (DataAccessException e) {
if (canRetryTransaction(e)) {
transaction = (TransactionWrapper)initTransactionRetry(transaction);
return ((ProcessExecutor)getTransactionRetrier()).createTransitionInstance(transition, pProcessInstId);
}
else
throw e;
} finally {
stopTransaction(transaction);
}
} | java | public TransitionInstance createTransitionInstance(Transition transition, Long pProcessInstId)
throws DataAccessException {
TransactionWrapper transaction=null;
try {
transaction = startTransaction();
return engineImpl.createTransitionInstance(transition, pProcessInstId);
} catch (DataAccessException e) {
if (canRetryTransaction(e)) {
transaction = (TransactionWrapper)initTransactionRetry(transaction);
return ((ProcessExecutor)getTransactionRetrier()).createTransitionInstance(transition, pProcessInstId);
}
else
throw e;
} finally {
stopTransaction(transaction);
}
} | [
"public",
"TransitionInstance",
"createTransitionInstance",
"(",
"Transition",
"transition",
",",
"Long",
"pProcessInstId",
")",
"throws",
"DataAccessException",
"{",
"TransactionWrapper",
"transaction",
"=",
"null",
";",
"try",
"{",
"transaction",
"=",
"startTransaction",
"(",
")",
";",
"return",
"engineImpl",
".",
"createTransitionInstance",
"(",
"transition",
",",
"pProcessInstId",
")",
";",
"}",
"catch",
"(",
"DataAccessException",
"e",
")",
"{",
"if",
"(",
"canRetryTransaction",
"(",
"e",
")",
")",
"{",
"transaction",
"=",
"(",
"TransactionWrapper",
")",
"initTransactionRetry",
"(",
"transaction",
")",
";",
"return",
"(",
"(",
"ProcessExecutor",
")",
"getTransactionRetrier",
"(",
")",
")",
".",
"createTransitionInstance",
"(",
"transition",
",",
"pProcessInstId",
")",
";",
"}",
"else",
"throw",
"e",
";",
"}",
"finally",
"{",
"stopTransaction",
"(",
"transaction",
")",
";",
"}",
"}"
] | Creates a new instance of the WorkTransationInstance entity
@param transition
@param pProcessInstId
@return WorkTransitionInstance object | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"WorkTransationInstance",
"entity"
] | train | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/process/ProcessExecutor.java#L631-L647 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/protocols/channels/StoredServerChannel.java | StoredServerChannel.setConnectedHandler | synchronized PaymentChannelServer setConnectedHandler(PaymentChannelServer connectedHandler, boolean override) {
"""
Attempts to connect the given handler to this, returning true if it is the new handler, false if there was
already one attached.
"""
if (this.connectedHandler != null && !override)
return this.connectedHandler;
this.connectedHandler = connectedHandler;
return connectedHandler;
} | java | synchronized PaymentChannelServer setConnectedHandler(PaymentChannelServer connectedHandler, boolean override) {
if (this.connectedHandler != null && !override)
return this.connectedHandler;
this.connectedHandler = connectedHandler;
return connectedHandler;
} | [
"synchronized",
"PaymentChannelServer",
"setConnectedHandler",
"(",
"PaymentChannelServer",
"connectedHandler",
",",
"boolean",
"override",
")",
"{",
"if",
"(",
"this",
".",
"connectedHandler",
"!=",
"null",
"&&",
"!",
"override",
")",
"return",
"this",
".",
"connectedHandler",
";",
"this",
".",
"connectedHandler",
"=",
"connectedHandler",
";",
"return",
"connectedHandler",
";",
"}"
] | Attempts to connect the given handler to this, returning true if it is the new handler, false if there was
already one attached. | [
"Attempts",
"to",
"connect",
"the",
"given",
"handler",
"to",
"this",
"returning",
"true",
"if",
"it",
"is",
"the",
"new",
"handler",
"false",
"if",
"there",
"was",
"already",
"one",
"attached",
"."
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/protocols/channels/StoredServerChannel.java#L78-L83 |
couchbase/couchbase-lite-java | src/main/java/com/couchbase/lite/AbstractReplicatorConfiguration.java | AbstractReplicatorConfiguration.setHeaders | @NonNull
public ReplicatorConfiguration setHeaders(Map<String, String> headers) {
"""
Sets the extra HTTP headers to send in all requests to the remote target.
@param headers The HTTP Headers.
@return The self object.
"""
if (readonly) { throw new IllegalStateException("ReplicatorConfiguration is readonly mode."); }
this.headers = new HashMap<>(headers);
return getReplicatorConfiguration();
} | java | @NonNull
public ReplicatorConfiguration setHeaders(Map<String, String> headers) {
if (readonly) { throw new IllegalStateException("ReplicatorConfiguration is readonly mode."); }
this.headers = new HashMap<>(headers);
return getReplicatorConfiguration();
} | [
"@",
"NonNull",
"public",
"ReplicatorConfiguration",
"setHeaders",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
")",
"{",
"if",
"(",
"readonly",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"ReplicatorConfiguration is readonly mode.\"",
")",
";",
"}",
"this",
".",
"headers",
"=",
"new",
"HashMap",
"<>",
"(",
"headers",
")",
";",
"return",
"getReplicatorConfiguration",
"(",
")",
";",
"}"
] | Sets the extra HTTP headers to send in all requests to the remote target.
@param headers The HTTP Headers.
@return The self object. | [
"Sets",
"the",
"extra",
"HTTP",
"headers",
"to",
"send",
"in",
"all",
"requests",
"to",
"the",
"remote",
"target",
"."
] | train | https://github.com/couchbase/couchbase-lite-java/blob/cb72c44186456e6191a9ad0a7feb310011d0b081/src/main/java/com/couchbase/lite/AbstractReplicatorConfiguration.java#L194-L199 |
undertow-io/undertow | servlet/src/main/java/io/undertow/servlet/api/DeploymentInfo.java | DeploymentInfo.addPreCompressedResourceEncoding | public DeploymentInfo addPreCompressedResourceEncoding(String encoding, String extension) {
"""
Adds a pre compressed resource encoding and maps it to a file extension
@param encoding The content encoding
@param extension The file extension
@return this builder
"""
preCompressedResources.put(encoding, extension);
return this;
} | java | public DeploymentInfo addPreCompressedResourceEncoding(String encoding, String extension) {
preCompressedResources.put(encoding, extension);
return this;
} | [
"public",
"DeploymentInfo",
"addPreCompressedResourceEncoding",
"(",
"String",
"encoding",
",",
"String",
"extension",
")",
"{",
"preCompressedResources",
".",
"put",
"(",
"encoding",
",",
"extension",
")",
";",
"return",
"this",
";",
"}"
] | Adds a pre compressed resource encoding and maps it to a file extension
@param encoding The content encoding
@param extension The file extension
@return this builder | [
"Adds",
"a",
"pre",
"compressed",
"resource",
"encoding",
"and",
"maps",
"it",
"to",
"a",
"file",
"extension"
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/servlet/src/main/java/io/undertow/servlet/api/DeploymentInfo.java#L1342-L1345 |
padrig64/ValidationFramework | validationframework-core/src/main/java/com/google/code/validationframework/base/utils/ValueUtils.java | ValueUtils.areEqual | public static boolean areEqual(Object value1, Object value2) {
"""
Compares the two given values by taking null and NaN values into account.
<p>
Two null values will be considered equal. Two NaN values (either Double or Float) will be considered equal.
@param value1 First value.
@param value2 Second value.
@return True if both values are equal or if both are null.
"""
return ((value1 == null) && (value2 == null)) || //
(isNaN(value1) && isNaN(value2)) || //
((value1 != null) && value1.equals(value2));
} | java | public static boolean areEqual(Object value1, Object value2) {
return ((value1 == null) && (value2 == null)) || //
(isNaN(value1) && isNaN(value2)) || //
((value1 != null) && value1.equals(value2));
} | [
"public",
"static",
"boolean",
"areEqual",
"(",
"Object",
"value1",
",",
"Object",
"value2",
")",
"{",
"return",
"(",
"(",
"value1",
"==",
"null",
")",
"&&",
"(",
"value2",
"==",
"null",
")",
")",
"||",
"//",
"(",
"isNaN",
"(",
"value1",
")",
"&&",
"isNaN",
"(",
"value2",
")",
")",
"||",
"//",
"(",
"(",
"value1",
"!=",
"null",
")",
"&&",
"value1",
".",
"equals",
"(",
"value2",
")",
")",
";",
"}"
] | Compares the two given values by taking null and NaN values into account.
<p>
Two null values will be considered equal. Two NaN values (either Double or Float) will be considered equal.
@param value1 First value.
@param value2 Second value.
@return True if both values are equal or if both are null. | [
"Compares",
"the",
"two",
"given",
"values",
"by",
"taking",
"null",
"and",
"NaN",
"values",
"into",
"account",
".",
"<p",
">",
"Two",
"null",
"values",
"will",
"be",
"considered",
"equal",
".",
"Two",
"NaN",
"values",
"(",
"either",
"Double",
"or",
"Float",
")",
"will",
"be",
"considered",
"equal",
"."
] | train | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-core/src/main/java/com/google/code/validationframework/base/utils/ValueUtils.java#L52-L56 |
lucee/Lucee | core/src/main/java/lucee/commons/io/compress/CompressUtil.java | CompressUtil.compressZip | public static void compressZip(Resource[] sources, Resource target, ResourceFilter filter) throws IOException {
"""
compress a source file/directory to a zip file
@param sources
@param target
@param filter
@throws IOException
"""
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream(IOUtil.toBufferedOutputStream(target.getOutputStream()));
compressZip("", sources, zos, filter);
}
finally {
IOUtil.closeEL(zos);
}
} | java | public static void compressZip(Resource[] sources, Resource target, ResourceFilter filter) throws IOException {
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream(IOUtil.toBufferedOutputStream(target.getOutputStream()));
compressZip("", sources, zos, filter);
}
finally {
IOUtil.closeEL(zos);
}
} | [
"public",
"static",
"void",
"compressZip",
"(",
"Resource",
"[",
"]",
"sources",
",",
"Resource",
"target",
",",
"ResourceFilter",
"filter",
")",
"throws",
"IOException",
"{",
"ZipOutputStream",
"zos",
"=",
"null",
";",
"try",
"{",
"zos",
"=",
"new",
"ZipOutputStream",
"(",
"IOUtil",
".",
"toBufferedOutputStream",
"(",
"target",
".",
"getOutputStream",
"(",
")",
")",
")",
";",
"compressZip",
"(",
"\"\"",
",",
"sources",
",",
"zos",
",",
"filter",
")",
";",
"}",
"finally",
"{",
"IOUtil",
".",
"closeEL",
"(",
"zos",
")",
";",
"}",
"}"
] | compress a source file/directory to a zip file
@param sources
@param target
@param filter
@throws IOException | [
"compress",
"a",
"source",
"file",
"/",
"directory",
"to",
"a",
"zip",
"file"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/commons/io/compress/CompressUtil.java#L483-L492 |
albfernandez/itext2 | src/main/java/com/lowagie/text/rtf/RtfWriter2.java | RtfWriter2.importRtfDocumentIntoElement | public void importRtfDocumentIntoElement(Element elem, FileInputStream documentSource) throws IOException, DocumentException {
"""
Adds the complete RTF document to the current RTF element being generated.
It will parse the font and color tables and correct the font and color references
so that the imported RTF document retains its formattings.
@param elem The Element the RTF document is to be imported into.
@param documentSource The Reader to read the RTF document from.
@throws IOException On errors reading the RTF document.
@throws DocumentException On errors adding to this RTF document.
@since 2.1.4
"""
importRtfDocumentIntoElement(elem, documentSource, null);
} | java | public void importRtfDocumentIntoElement(Element elem, FileInputStream documentSource) throws IOException, DocumentException {
importRtfDocumentIntoElement(elem, documentSource, null);
} | [
"public",
"void",
"importRtfDocumentIntoElement",
"(",
"Element",
"elem",
",",
"FileInputStream",
"documentSource",
")",
"throws",
"IOException",
",",
"DocumentException",
"{",
"importRtfDocumentIntoElement",
"(",
"elem",
",",
"documentSource",
",",
"null",
")",
";",
"}"
] | Adds the complete RTF document to the current RTF element being generated.
It will parse the font and color tables and correct the font and color references
so that the imported RTF document retains its formattings.
@param elem The Element the RTF document is to be imported into.
@param documentSource The Reader to read the RTF document from.
@throws IOException On errors reading the RTF document.
@throws DocumentException On errors adding to this RTF document.
@since 2.1.4 | [
"Adds",
"the",
"complete",
"RTF",
"document",
"to",
"the",
"current",
"RTF",
"element",
"being",
"generated",
".",
"It",
"will",
"parse",
"the",
"font",
"and",
"color",
"tables",
"and",
"correct",
"the",
"font",
"and",
"color",
"references",
"so",
"that",
"the",
"imported",
"RTF",
"document",
"retains",
"its",
"formattings",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/rtf/RtfWriter2.java#L360-L362 |
BigBadaboom/androidsvg | androidsvg/src/main/java/com/caverock/androidsvg/SVGAndroidRenderer.java | SVGAndroidRenderer.calculateViewBoxTransform | private Matrix calculateViewBoxTransform(Box viewPort, Box viewBox, PreserveAspectRatio positioning) {
"""
/*
Calculate the transform required to fit the supplied viewBox into the current viewPort.
See spec section 7.8 for an explanation of how this works.
aspectRatioRule determines where the graphic is placed in the viewPort when aspect ration
is kept. xMin means left justified, xMid is centred, xMax is right justified etc.
slice determines whether we see the whole image or not. True fill the whole viewport.
If slice is false, the image will be "letter-boxed".
Note values in the two Box parameters whould be in user units. If you pass values
that are in "objectBoundingBox" space, you will get incorrect results.
"""
Matrix m = new Matrix();
if (positioning == null || positioning.getAlignment() == null)
return m;
float xScale = viewPort.width / viewBox.width;
float yScale = viewPort.height / viewBox.height;
float xOffset = -viewBox.minX;
float yOffset = -viewBox.minY;
// 'none' means scale both dimensions to fit the viewport
if (positioning.equals(PreserveAspectRatio.STRETCH))
{
m.preTranslate(viewPort.minX, viewPort.minY);
m.preScale(xScale, yScale);
m.preTranslate(xOffset, yOffset);
return m;
}
// Otherwise, the aspect ratio of the image is kept.
// What scale are we going to use?
float scale = (positioning.getScale() == PreserveAspectRatio.Scale.slice) ? Math.max(xScale, yScale) : Math.min(xScale, yScale);
// What size will the image end up being?
float imageW = viewPort.width / scale;
float imageH = viewPort.height / scale;
// Determine final X position
switch (positioning.getAlignment())
{
case xMidYMin:
case xMidYMid:
case xMidYMax:
xOffset -= (viewBox.width - imageW) / 2;
break;
case xMaxYMin:
case xMaxYMid:
case xMaxYMax:
xOffset -= (viewBox.width - imageW);
break;
default:
// nothing to do
break;
}
// Determine final Y position
switch (positioning.getAlignment())
{
case xMinYMid:
case xMidYMid:
case xMaxYMid:
yOffset -= (viewBox.height - imageH) / 2;
break;
case xMinYMax:
case xMidYMax:
case xMaxYMax:
yOffset -= (viewBox.height - imageH);
break;
default:
// nothing to do
break;
}
m.preTranslate(viewPort.minX, viewPort.minY);
m.preScale(scale, scale);
m.preTranslate(xOffset, yOffset);
return m;
} | java | private Matrix calculateViewBoxTransform(Box viewPort, Box viewBox, PreserveAspectRatio positioning)
{
Matrix m = new Matrix();
if (positioning == null || positioning.getAlignment() == null)
return m;
float xScale = viewPort.width / viewBox.width;
float yScale = viewPort.height / viewBox.height;
float xOffset = -viewBox.minX;
float yOffset = -viewBox.minY;
// 'none' means scale both dimensions to fit the viewport
if (positioning.equals(PreserveAspectRatio.STRETCH))
{
m.preTranslate(viewPort.minX, viewPort.minY);
m.preScale(xScale, yScale);
m.preTranslate(xOffset, yOffset);
return m;
}
// Otherwise, the aspect ratio of the image is kept.
// What scale are we going to use?
float scale = (positioning.getScale() == PreserveAspectRatio.Scale.slice) ? Math.max(xScale, yScale) : Math.min(xScale, yScale);
// What size will the image end up being?
float imageW = viewPort.width / scale;
float imageH = viewPort.height / scale;
// Determine final X position
switch (positioning.getAlignment())
{
case xMidYMin:
case xMidYMid:
case xMidYMax:
xOffset -= (viewBox.width - imageW) / 2;
break;
case xMaxYMin:
case xMaxYMid:
case xMaxYMax:
xOffset -= (viewBox.width - imageW);
break;
default:
// nothing to do
break;
}
// Determine final Y position
switch (positioning.getAlignment())
{
case xMinYMid:
case xMidYMid:
case xMaxYMid:
yOffset -= (viewBox.height - imageH) / 2;
break;
case xMinYMax:
case xMidYMax:
case xMaxYMax:
yOffset -= (viewBox.height - imageH);
break;
default:
// nothing to do
break;
}
m.preTranslate(viewPort.minX, viewPort.minY);
m.preScale(scale, scale);
m.preTranslate(xOffset, yOffset);
return m;
} | [
"private",
"Matrix",
"calculateViewBoxTransform",
"(",
"Box",
"viewPort",
",",
"Box",
"viewBox",
",",
"PreserveAspectRatio",
"positioning",
")",
"{",
"Matrix",
"m",
"=",
"new",
"Matrix",
"(",
")",
";",
"if",
"(",
"positioning",
"==",
"null",
"||",
"positioning",
".",
"getAlignment",
"(",
")",
"==",
"null",
")",
"return",
"m",
";",
"float",
"xScale",
"=",
"viewPort",
".",
"width",
"/",
"viewBox",
".",
"width",
";",
"float",
"yScale",
"=",
"viewPort",
".",
"height",
"/",
"viewBox",
".",
"height",
";",
"float",
"xOffset",
"=",
"-",
"viewBox",
".",
"minX",
";",
"float",
"yOffset",
"=",
"-",
"viewBox",
".",
"minY",
";",
"// 'none' means scale both dimensions to fit the viewport\r",
"if",
"(",
"positioning",
".",
"equals",
"(",
"PreserveAspectRatio",
".",
"STRETCH",
")",
")",
"{",
"m",
".",
"preTranslate",
"(",
"viewPort",
".",
"minX",
",",
"viewPort",
".",
"minY",
")",
";",
"m",
".",
"preScale",
"(",
"xScale",
",",
"yScale",
")",
";",
"m",
".",
"preTranslate",
"(",
"xOffset",
",",
"yOffset",
")",
";",
"return",
"m",
";",
"}",
"// Otherwise, the aspect ratio of the image is kept.\r",
"// What scale are we going to use?\r",
"float",
"scale",
"=",
"(",
"positioning",
".",
"getScale",
"(",
")",
"==",
"PreserveAspectRatio",
".",
"Scale",
".",
"slice",
")",
"?",
"Math",
".",
"max",
"(",
"xScale",
",",
"yScale",
")",
":",
"Math",
".",
"min",
"(",
"xScale",
",",
"yScale",
")",
";",
"// What size will the image end up being? \r",
"float",
"imageW",
"=",
"viewPort",
".",
"width",
"/",
"scale",
";",
"float",
"imageH",
"=",
"viewPort",
".",
"height",
"/",
"scale",
";",
"// Determine final X position\r",
"switch",
"(",
"positioning",
".",
"getAlignment",
"(",
")",
")",
"{",
"case",
"xMidYMin",
":",
"case",
"xMidYMid",
":",
"case",
"xMidYMax",
":",
"xOffset",
"-=",
"(",
"viewBox",
".",
"width",
"-",
"imageW",
")",
"/",
"2",
";",
"break",
";",
"case",
"xMaxYMin",
":",
"case",
"xMaxYMid",
":",
"case",
"xMaxYMax",
":",
"xOffset",
"-=",
"(",
"viewBox",
".",
"width",
"-",
"imageW",
")",
";",
"break",
";",
"default",
":",
"// nothing to do \r",
"break",
";",
"}",
"// Determine final Y position\r",
"switch",
"(",
"positioning",
".",
"getAlignment",
"(",
")",
")",
"{",
"case",
"xMinYMid",
":",
"case",
"xMidYMid",
":",
"case",
"xMaxYMid",
":",
"yOffset",
"-=",
"(",
"viewBox",
".",
"height",
"-",
"imageH",
")",
"/",
"2",
";",
"break",
";",
"case",
"xMinYMax",
":",
"case",
"xMidYMax",
":",
"case",
"xMaxYMax",
":",
"yOffset",
"-=",
"(",
"viewBox",
".",
"height",
"-",
"imageH",
")",
";",
"break",
";",
"default",
":",
"// nothing to do \r",
"break",
";",
"}",
"m",
".",
"preTranslate",
"(",
"viewPort",
".",
"minX",
",",
"viewPort",
".",
"minY",
")",
";",
"m",
".",
"preScale",
"(",
"scale",
",",
"scale",
")",
";",
"m",
".",
"preTranslate",
"(",
"xOffset",
",",
"yOffset",
")",
";",
"return",
"m",
";",
"}"
] | /*
Calculate the transform required to fit the supplied viewBox into the current viewPort.
See spec section 7.8 for an explanation of how this works.
aspectRatioRule determines where the graphic is placed in the viewPort when aspect ration
is kept. xMin means left justified, xMid is centred, xMax is right justified etc.
slice determines whether we see the whole image or not. True fill the whole viewport.
If slice is false, the image will be "letter-boxed".
Note values in the two Box parameters whould be in user units. If you pass values
that are in "objectBoundingBox" space, you will get incorrect results. | [
"/",
"*",
"Calculate",
"the",
"transform",
"required",
"to",
"fit",
"the",
"supplied",
"viewBox",
"into",
"the",
"current",
"viewPort",
".",
"See",
"spec",
"section",
"7",
".",
"8",
"for",
"an",
"explanation",
"of",
"how",
"this",
"works",
"."
] | train | https://github.com/BigBadaboom/androidsvg/blob/0d1614dd1a4da10ea4afe3b0cea1361a4ac6b45a/androidsvg/src/main/java/com/caverock/androidsvg/SVGAndroidRenderer.java#L2025-L2091 |
iipc/webarchive-commons | src/main/java/org/archive/util/DateUtils.java | DateUtils.formatBytesForDisplay | public static String formatBytesForDisplay(long amount) {
"""
Takes a byte size and formats it for display with 'friendly' units.
<p>
This involves converting it to the largest unit
(of B, KiB, MiB, GiB, TiB) for which the amount will be > 1.
<p>
Additionally, at least 2 significant digits are always displayed.
<p>
Negative numbers will be returned as '0 B'.
@param amount the amount of bytes
@return A string containing the amount, properly formated.
"""
double displayAmount = (double) amount;
int unitPowerOf1024 = 0;
if(amount <= 0){
return "0 B";
}
while(displayAmount>=1024 && unitPowerOf1024 < 4) {
displayAmount = displayAmount / 1024;
unitPowerOf1024++;
}
final String[] units = { " B", " KiB", " MiB", " GiB", " TiB" };
// ensure at least 2 significant digits (#.#) for small displayValues
int fractionDigits = (displayAmount < 10) ? 1 : 0;
return doubleToString(displayAmount, fractionDigits, fractionDigits)
+ units[unitPowerOf1024];
} | java | public static String formatBytesForDisplay(long amount) {
double displayAmount = (double) amount;
int unitPowerOf1024 = 0;
if(amount <= 0){
return "0 B";
}
while(displayAmount>=1024 && unitPowerOf1024 < 4) {
displayAmount = displayAmount / 1024;
unitPowerOf1024++;
}
final String[] units = { " B", " KiB", " MiB", " GiB", " TiB" };
// ensure at least 2 significant digits (#.#) for small displayValues
int fractionDigits = (displayAmount < 10) ? 1 : 0;
return doubleToString(displayAmount, fractionDigits, fractionDigits)
+ units[unitPowerOf1024];
} | [
"public",
"static",
"String",
"formatBytesForDisplay",
"(",
"long",
"amount",
")",
"{",
"double",
"displayAmount",
"=",
"(",
"double",
")",
"amount",
";",
"int",
"unitPowerOf1024",
"=",
"0",
";",
"if",
"(",
"amount",
"<=",
"0",
")",
"{",
"return",
"\"0 B\"",
";",
"}",
"while",
"(",
"displayAmount",
">=",
"1024",
"&&",
"unitPowerOf1024",
"<",
"4",
")",
"{",
"displayAmount",
"=",
"displayAmount",
"/",
"1024",
";",
"unitPowerOf1024",
"++",
";",
"}",
"final",
"String",
"[",
"]",
"units",
"=",
"{",
"\" B\"",
",",
"\" KiB\"",
",",
"\" MiB\"",
",",
"\" GiB\"",
",",
"\" TiB\"",
"}",
";",
"// ensure at least 2 significant digits (#.#) for small displayValues\r",
"int",
"fractionDigits",
"=",
"(",
"displayAmount",
"<",
"10",
")",
"?",
"1",
":",
"0",
";",
"return",
"doubleToString",
"(",
"displayAmount",
",",
"fractionDigits",
",",
"fractionDigits",
")",
"+",
"units",
"[",
"unitPowerOf1024",
"]",
";",
"}"
] | Takes a byte size and formats it for display with 'friendly' units.
<p>
This involves converting it to the largest unit
(of B, KiB, MiB, GiB, TiB) for which the amount will be > 1.
<p>
Additionally, at least 2 significant digits are always displayed.
<p>
Negative numbers will be returned as '0 B'.
@param amount the amount of bytes
@return A string containing the amount, properly formated. | [
"Takes",
"a",
"byte",
"size",
"and",
"formats",
"it",
"for",
"display",
"with",
"friendly",
"units",
".",
"<p",
">",
"This",
"involves",
"converting",
"it",
"to",
"the",
"largest",
"unit",
"(",
"of",
"B",
"KiB",
"MiB",
"GiB",
"TiB",
")",
"for",
"which",
"the",
"amount",
"will",
"be",
">",
"1",
".",
"<p",
">",
"Additionally",
"at",
"least",
"2",
"significant",
"digits",
"are",
"always",
"displayed",
".",
"<p",
">",
"Negative",
"numbers",
"will",
"be",
"returned",
"as",
"0",
"B",
"."
] | train | https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/DateUtils.java#L569-L588 |
jbundle/jbundle | base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HBasePanel.java | HBasePanel.printHtmlHeader | public void printHtmlHeader(PrintWriter out, ResourceBundle reg) {
"""
Form Header.
@param out The html out stream.
@param reg The resources object.
"""
String strTitle = this.getProperty("title"); // Menu page
if ((strTitle == null) || (strTitle.length() == 0))
strTitle = ((BasePanel)this.getScreenField()).getTitle();
String strHTMLStart = reg.getString("htmlHeaderStart");
String strHTMLEnd = reg.getString("htmlHeaderEnd");
// Note: don't free the reg key (DBServlet will)
this.printHtmlHeader(out, strTitle, strHTMLStart, strHTMLEnd);
} | java | public void printHtmlHeader(PrintWriter out, ResourceBundle reg)
{
String strTitle = this.getProperty("title"); // Menu page
if ((strTitle == null) || (strTitle.length() == 0))
strTitle = ((BasePanel)this.getScreenField()).getTitle();
String strHTMLStart = reg.getString("htmlHeaderStart");
String strHTMLEnd = reg.getString("htmlHeaderEnd");
// Note: don't free the reg key (DBServlet will)
this.printHtmlHeader(out, strTitle, strHTMLStart, strHTMLEnd);
} | [
"public",
"void",
"printHtmlHeader",
"(",
"PrintWriter",
"out",
",",
"ResourceBundle",
"reg",
")",
"{",
"String",
"strTitle",
"=",
"this",
".",
"getProperty",
"(",
"\"title\"",
")",
";",
"// Menu page",
"if",
"(",
"(",
"strTitle",
"==",
"null",
")",
"||",
"(",
"strTitle",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"strTitle",
"=",
"(",
"(",
"BasePanel",
")",
"this",
".",
"getScreenField",
"(",
")",
")",
".",
"getTitle",
"(",
")",
";",
"String",
"strHTMLStart",
"=",
"reg",
".",
"getString",
"(",
"\"htmlHeaderStart\"",
")",
";",
"String",
"strHTMLEnd",
"=",
"reg",
".",
"getString",
"(",
"\"htmlHeaderEnd\"",
")",
";",
"// Note: don't free the reg key (DBServlet will)",
"this",
".",
"printHtmlHeader",
"(",
"out",
",",
"strTitle",
",",
"strHTMLStart",
",",
"strHTMLEnd",
")",
";",
"}"
] | Form Header.
@param out The html out stream.
@param reg The resources object. | [
"Form",
"Header",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HBasePanel.java#L449-L458 |
zackpollard/JavaTelegramBot-API | core/src/main/java/pro/zackpollard/telegrambot/api/TelegramBot.java | TelegramBot.editMessageReplyMarkup | public Message editMessageReplyMarkup(Message oldMessage, InlineReplyMarkup inlineReplyMarkup) {
"""
This allows you to edit the InlineReplyMarkup of any message that you have sent previously.
@param oldMessage The Message object that represents the message you want to edit
@param inlineReplyMarkup Any InlineReplyMarkup object you want to edit into the message
@return A new Message object representing the edited message
"""
return this.editMessageReplyMarkup(oldMessage.getChat().getId(), oldMessage.getMessageId(), inlineReplyMarkup);
} | java | public Message editMessageReplyMarkup(Message oldMessage, InlineReplyMarkup inlineReplyMarkup) {
return this.editMessageReplyMarkup(oldMessage.getChat().getId(), oldMessage.getMessageId(), inlineReplyMarkup);
} | [
"public",
"Message",
"editMessageReplyMarkup",
"(",
"Message",
"oldMessage",
",",
"InlineReplyMarkup",
"inlineReplyMarkup",
")",
"{",
"return",
"this",
".",
"editMessageReplyMarkup",
"(",
"oldMessage",
".",
"getChat",
"(",
")",
".",
"getId",
"(",
")",
",",
"oldMessage",
".",
"getMessageId",
"(",
")",
",",
"inlineReplyMarkup",
")",
";",
"}"
] | This allows you to edit the InlineReplyMarkup of any message that you have sent previously.
@param oldMessage The Message object that represents the message you want to edit
@param inlineReplyMarkup Any InlineReplyMarkup object you want to edit into the message
@return A new Message object representing the edited message | [
"This",
"allows",
"you",
"to",
"edit",
"the",
"InlineReplyMarkup",
"of",
"any",
"message",
"that",
"you",
"have",
"sent",
"previously",
"."
] | train | https://github.com/zackpollard/JavaTelegramBot-API/blob/9d100f351824042ca5fc0ea735d1fa376a13e81d/core/src/main/java/pro/zackpollard/telegrambot/api/TelegramBot.java#L844-L847 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/io/IOUtils.java | IOUtils.writeObjectToFile | public static File writeObjectToFile(Object o, String filename)
throws IOException {
"""
Write object to a file with the specified name.
@param o
object to be written to file
@param filename
name of the temp file
@throws IOException
If can't write file.
@return File containing the object
"""
return writeObjectToFile(o, new File(filename));
} | java | public static File writeObjectToFile(Object o, String filename)
throws IOException {
return writeObjectToFile(o, new File(filename));
} | [
"public",
"static",
"File",
"writeObjectToFile",
"(",
"Object",
"o",
",",
"String",
"filename",
")",
"throws",
"IOException",
"{",
"return",
"writeObjectToFile",
"(",
"o",
",",
"new",
"File",
"(",
"filename",
")",
")",
";",
"}"
] | Write object to a file with the specified name.
@param o
object to be written to file
@param filename
name of the temp file
@throws IOException
If can't write file.
@return File containing the object | [
"Write",
"object",
"to",
"a",
"file",
"with",
"the",
"specified",
"name",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/io/IOUtils.java#L44-L47 |
ocelotds/ocelot | ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java | ServiceTools.getTemplateOfMap | String getTemplateOfMap(Type[] actualTypeArguments, IJsonMarshaller jsonMarshaller) {
"""
Get template of map class from generic type
@param actualTypeArguments
@return
"""
StringBuilder res = new StringBuilder("{");
boolean first = true;
for (Type actualTypeArgument : actualTypeArguments) {
if (!first) {
res.append(":");
}
res.append(_getTemplateOfType(actualTypeArgument, jsonMarshaller));
first = false;
}
res.append("}");
return res.toString();
} | java | String getTemplateOfMap(Type[] actualTypeArguments, IJsonMarshaller jsonMarshaller) {
StringBuilder res = new StringBuilder("{");
boolean first = true;
for (Type actualTypeArgument : actualTypeArguments) {
if (!first) {
res.append(":");
}
res.append(_getTemplateOfType(actualTypeArgument, jsonMarshaller));
first = false;
}
res.append("}");
return res.toString();
} | [
"String",
"getTemplateOfMap",
"(",
"Type",
"[",
"]",
"actualTypeArguments",
",",
"IJsonMarshaller",
"jsonMarshaller",
")",
"{",
"StringBuilder",
"res",
"=",
"new",
"StringBuilder",
"(",
"\"{\"",
")",
";",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"Type",
"actualTypeArgument",
":",
"actualTypeArguments",
")",
"{",
"if",
"(",
"!",
"first",
")",
"{",
"res",
".",
"append",
"(",
"\":\"",
")",
";",
"}",
"res",
".",
"append",
"(",
"_getTemplateOfType",
"(",
"actualTypeArgument",
",",
"jsonMarshaller",
")",
")",
";",
"first",
"=",
"false",
";",
"}",
"res",
".",
"append",
"(",
"\"}\"",
")",
";",
"return",
"res",
".",
"toString",
"(",
")",
";",
"}"
] | Get template of map class from generic type
@param actualTypeArguments
@return | [
"Get",
"template",
"of",
"map",
"class",
"from",
"generic",
"type"
] | train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-dashboard/src/main/java/org/ocelotds/dashboard/services/ServiceTools.java#L283-L295 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hash/MurmurHash3Adaptor.java | MurmurHash3Adaptor.asInt | public static int asInt(final String datum, final int n) {
"""
Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input datum.
@param datum the given String.
@param n The upper exclusive bound of the integers produced. Must be > 1.
@return deterministic uniform random integer
"""
if ((datum == null) || datum.isEmpty()) {
throw new SketchesArgumentException("Input is null or empty.");
}
final byte[] data = datum.getBytes(UTF_8);
return asInteger(toLongArray(data), n); //data is byte[]
} | java | public static int asInt(final String datum, final int n) {
if ((datum == null) || datum.isEmpty()) {
throw new SketchesArgumentException("Input is null or empty.");
}
final byte[] data = datum.getBytes(UTF_8);
return asInteger(toLongArray(data), n); //data is byte[]
} | [
"public",
"static",
"int",
"asInt",
"(",
"final",
"String",
"datum",
",",
"final",
"int",
"n",
")",
"{",
"if",
"(",
"(",
"datum",
"==",
"null",
")",
"||",
"datum",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"SketchesArgumentException",
"(",
"\"Input is null or empty.\"",
")",
";",
"}",
"final",
"byte",
"[",
"]",
"data",
"=",
"datum",
".",
"getBytes",
"(",
"UTF_8",
")",
";",
"return",
"asInteger",
"(",
"toLongArray",
"(",
"data",
")",
",",
"n",
")",
";",
"//data is byte[]",
"}"
] | Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input datum.
@param datum the given String.
@param n The upper exclusive bound of the integers produced. Must be > 1.
@return deterministic uniform random integer | [
"Returns",
"a",
"deterministic",
"uniform",
"random",
"integer",
"between",
"zero",
"(",
"inclusive",
")",
"and",
"n",
"(",
"exclusive",
")",
"given",
"the",
"input",
"datum",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hash/MurmurHash3Adaptor.java#L305-L311 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/DerInputBuffer.java | DerInputBuffer.getUnalignedBitString | BitArray getUnalignedBitString() throws IOException {
"""
Returns the bit string which takes up the rest of this buffer.
The bit string need not be byte-aligned.
"""
if (pos >= count)
return null;
/*
* Just copy the data into an aligned, padded octet buffer,
* and consume the rest of the buffer.
*/
int len = available();
int unusedBits = buf[pos] & 0xff;
if (unusedBits > 7 ) {
throw new IOException("Invalid value for unused bits: " + unusedBits);
}
byte[] bits = new byte[len - 1];
// number of valid bits
int length = (bits.length == 0) ? 0 : bits.length * 8 - unusedBits;
System.arraycopy(buf, pos + 1, bits, 0, len - 1);
BitArray bitArray = new BitArray(length, bits);
pos = count;
return bitArray;
} | java | BitArray getUnalignedBitString() throws IOException {
if (pos >= count)
return null;
/*
* Just copy the data into an aligned, padded octet buffer,
* and consume the rest of the buffer.
*/
int len = available();
int unusedBits = buf[pos] & 0xff;
if (unusedBits > 7 ) {
throw new IOException("Invalid value for unused bits: " + unusedBits);
}
byte[] bits = new byte[len - 1];
// number of valid bits
int length = (bits.length == 0) ? 0 : bits.length * 8 - unusedBits;
System.arraycopy(buf, pos + 1, bits, 0, len - 1);
BitArray bitArray = new BitArray(length, bits);
pos = count;
return bitArray;
} | [
"BitArray",
"getUnalignedBitString",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"pos",
">=",
"count",
")",
"return",
"null",
";",
"/*\n * Just copy the data into an aligned, padded octet buffer,\n * and consume the rest of the buffer.\n */",
"int",
"len",
"=",
"available",
"(",
")",
";",
"int",
"unusedBits",
"=",
"buf",
"[",
"pos",
"]",
"&",
"0xff",
";",
"if",
"(",
"unusedBits",
">",
"7",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Invalid value for unused bits: \"",
"+",
"unusedBits",
")",
";",
"}",
"byte",
"[",
"]",
"bits",
"=",
"new",
"byte",
"[",
"len",
"-",
"1",
"]",
";",
"// number of valid bits",
"int",
"length",
"=",
"(",
"bits",
".",
"length",
"==",
"0",
")",
"?",
"0",
":",
"bits",
".",
"length",
"*",
"8",
"-",
"unusedBits",
";",
"System",
".",
"arraycopy",
"(",
"buf",
",",
"pos",
"+",
"1",
",",
"bits",
",",
"0",
",",
"len",
"-",
"1",
")",
";",
"BitArray",
"bitArray",
"=",
"new",
"BitArray",
"(",
"length",
",",
"bits",
")",
";",
"pos",
"=",
"count",
";",
"return",
"bitArray",
";",
"}"
] | Returns the bit string which takes up the rest of this buffer.
The bit string need not be byte-aligned. | [
"Returns",
"the",
"bit",
"string",
"which",
"takes",
"up",
"the",
"rest",
"of",
"this",
"buffer",
".",
"The",
"bit",
"string",
"need",
"not",
"be",
"byte",
"-",
"aligned",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/DerInputBuffer.java#L233-L254 |
kuali/ojb-1.0.4 | src/tools/org/apache/ojb/tools/mapping/reversedb2/propertyEditors/EditableTreeNodeWithProperties.java | EditableTreeNodeWithProperties.addPropertyChangeListener | public void addPropertyChangeListener (String propertyName, java.beans.PropertyChangeListener listener) {
"""
Add a new PropertyChangeListener to this node for a specific property.
This functionality has
been borrowed from the java.beans package, though this class has
nothing to do with a bean
"""
this.propertyChangeDelegate.addPropertyChangeListener(propertyName, listener);
} | java | public void addPropertyChangeListener (String propertyName, java.beans.PropertyChangeListener listener)
{
this.propertyChangeDelegate.addPropertyChangeListener(propertyName, listener);
} | [
"public",
"void",
"addPropertyChangeListener",
"(",
"String",
"propertyName",
",",
"java",
".",
"beans",
".",
"PropertyChangeListener",
"listener",
")",
"{",
"this",
".",
"propertyChangeDelegate",
".",
"addPropertyChangeListener",
"(",
"propertyName",
",",
"listener",
")",
";",
"}"
] | Add a new PropertyChangeListener to this node for a specific property.
This functionality has
been borrowed from the java.beans package, though this class has
nothing to do with a bean | [
"Add",
"a",
"new",
"PropertyChangeListener",
"to",
"this",
"node",
"for",
"a",
"specific",
"property",
".",
"This",
"functionality",
"has",
"been",
"borrowed",
"from",
"the",
"java",
".",
"beans",
"package",
"though",
"this",
"class",
"has",
"nothing",
"to",
"do",
"with",
"a",
"bean"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/tools/org/apache/ojb/tools/mapping/reversedb2/propertyEditors/EditableTreeNodeWithProperties.java#L63-L66 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/widget/attribute/DefaultFeatureForm.java | DefaultFeatureForm.getValue | @Api
public void getValue(String name, ShortAttribute attribute) {
"""
Get a short value from the form, and place it in <code>attribute</code>.
@param name attribute name
@param attribute attribute to put value
@since 1.11.1
"""
attribute.setValue(toShort(formWidget.getValue(name)));
} | java | @Api
public void getValue(String name, ShortAttribute attribute) {
attribute.setValue(toShort(formWidget.getValue(name)));
} | [
"@",
"Api",
"public",
"void",
"getValue",
"(",
"String",
"name",
",",
"ShortAttribute",
"attribute",
")",
"{",
"attribute",
".",
"setValue",
"(",
"toShort",
"(",
"formWidget",
".",
"getValue",
"(",
"name",
")",
")",
")",
";",
"}"
] | Get a short value from the form, and place it in <code>attribute</code>.
@param name attribute name
@param attribute attribute to put value
@since 1.11.1 | [
"Get",
"a",
"short",
"value",
"from",
"the",
"form",
"and",
"place",
"it",
"in",
"<code",
">",
"attribute<",
"/",
"code",
">",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/widget/attribute/DefaultFeatureForm.java#L659-L662 |
Impetus/Kundera | src/kundera-kudu/src/main/java/com/impetus/client/kudu/KuduDBClient.java | KuduDBClient.onPersist | @Override
protected void onPersist(EntityMetadata entityMetadata, Object entity, Object id, List<RelationHolder> rlHolders) {
"""
On persist.
@param entityMetadata
the entity metadata
@param entity
the entity
@param id
the id
@param rlHolders
the rl holders
"""
KuduSession session = kuduClient.newSession();
KuduTable table = null;
try
{
table = kuduClient.openTable(entityMetadata.getTableName());
}
catch (Exception e)
{
logger.error("Cannot open table : " + entityMetadata.getTableName(), e);
throw new KunderaException("Cannot open table : " + entityMetadata.getTableName(), e);
}
Operation operation = isUpdate ? table.newUpdate() : table.newInsert();
PartialRow row = operation.getRow();
populatePartialRow(row, entityMetadata, entity);
try
{
session.apply(operation);
}
catch (Exception e)
{
logger.error("Cannot insert/update row in table : " + entityMetadata.getTableName(), e);
throw new KunderaException("Cannot insert/update row in table : " + entityMetadata.getTableName(), e);
}
finally
{
try
{
session.close();
}
catch (Exception e)
{
logger.error("Cannot close session", e);
throw new KunderaException("Cannot close session", e);
}
}
} | java | @Override
protected void onPersist(EntityMetadata entityMetadata, Object entity, Object id, List<RelationHolder> rlHolders)
{
KuduSession session = kuduClient.newSession();
KuduTable table = null;
try
{
table = kuduClient.openTable(entityMetadata.getTableName());
}
catch (Exception e)
{
logger.error("Cannot open table : " + entityMetadata.getTableName(), e);
throw new KunderaException("Cannot open table : " + entityMetadata.getTableName(), e);
}
Operation operation = isUpdate ? table.newUpdate() : table.newInsert();
PartialRow row = operation.getRow();
populatePartialRow(row, entityMetadata, entity);
try
{
session.apply(operation);
}
catch (Exception e)
{
logger.error("Cannot insert/update row in table : " + entityMetadata.getTableName(), e);
throw new KunderaException("Cannot insert/update row in table : " + entityMetadata.getTableName(), e);
}
finally
{
try
{
session.close();
}
catch (Exception e)
{
logger.error("Cannot close session", e);
throw new KunderaException("Cannot close session", e);
}
}
} | [
"@",
"Override",
"protected",
"void",
"onPersist",
"(",
"EntityMetadata",
"entityMetadata",
",",
"Object",
"entity",
",",
"Object",
"id",
",",
"List",
"<",
"RelationHolder",
">",
"rlHolders",
")",
"{",
"KuduSession",
"session",
"=",
"kuduClient",
".",
"newSession",
"(",
")",
";",
"KuduTable",
"table",
"=",
"null",
";",
"try",
"{",
"table",
"=",
"kuduClient",
".",
"openTable",
"(",
"entityMetadata",
".",
"getTableName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Cannot open table : \"",
"+",
"entityMetadata",
".",
"getTableName",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"KunderaException",
"(",
"\"Cannot open table : \"",
"+",
"entityMetadata",
".",
"getTableName",
"(",
")",
",",
"e",
")",
";",
"}",
"Operation",
"operation",
"=",
"isUpdate",
"?",
"table",
".",
"newUpdate",
"(",
")",
":",
"table",
".",
"newInsert",
"(",
")",
";",
"PartialRow",
"row",
"=",
"operation",
".",
"getRow",
"(",
")",
";",
"populatePartialRow",
"(",
"row",
",",
"entityMetadata",
",",
"entity",
")",
";",
"try",
"{",
"session",
".",
"apply",
"(",
"operation",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Cannot insert/update row in table : \"",
"+",
"entityMetadata",
".",
"getTableName",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"KunderaException",
"(",
"\"Cannot insert/update row in table : \"",
"+",
"entityMetadata",
".",
"getTableName",
"(",
")",
",",
"e",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"session",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Cannot close session\"",
",",
"e",
")",
";",
"throw",
"new",
"KunderaException",
"(",
"\"Cannot close session\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] | On persist.
@param entityMetadata
the entity metadata
@param entity
the entity
@param id
the id
@param rlHolders
the rl holders | [
"On",
"persist",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-kudu/src/main/java/com/impetus/client/kudu/KuduDBClient.java#L611-L650 |
alkacon/opencms-core | src/org/opencms/loader/CmsResourceManager.java | CmsResourceManager.initHtmlConverters | private void initHtmlConverters() {
"""
Initialize the HTML converters.<p>
HTML converters are configured in the OpenCms <code>opencms-vfs.xml</code> configuration file.<p>
For legacy reasons, the default JTidy HTML converter has to be loaded if no explicit HTML converters
are configured in the configuration file.<p>
"""
// check if any HTML converter configuration were found
if (m_configuredHtmlConverters.size() == 0) {
// no converters configured, add default JTidy converter configuration
String classJTidy = CmsHtmlConverterJTidy.class.getName();
m_configuredHtmlConverters.add(
new CmsHtmlConverterOption(CmsHtmlConverter.PARAM_ENABLED, classJTidy, true));
m_configuredHtmlConverters.add(new CmsHtmlConverterOption(CmsHtmlConverter.PARAM_XHTML, classJTidy, true));
m_configuredHtmlConverters.add(new CmsHtmlConverterOption(CmsHtmlConverter.PARAM_WORD, classJTidy, true));
m_configuredHtmlConverters.add(
new CmsHtmlConverterOption(CmsHtmlConverter.PARAM_REPLACE_PARAGRAPHS, classJTidy, true));
}
// initialize lookup map of configured HTML converters
m_htmlConverters = new HashMap<String, String>(m_configuredHtmlConverters.size());
for (Iterator<CmsHtmlConverterOption> i = m_configuredHtmlConverters.iterator(); i.hasNext();) {
CmsHtmlConverterOption converterOption = i.next();
m_htmlConverters.put(converterOption.getName(), converterOption.getClassName());
}
} | java | private void initHtmlConverters() {
// check if any HTML converter configuration were found
if (m_configuredHtmlConverters.size() == 0) {
// no converters configured, add default JTidy converter configuration
String classJTidy = CmsHtmlConverterJTidy.class.getName();
m_configuredHtmlConverters.add(
new CmsHtmlConverterOption(CmsHtmlConverter.PARAM_ENABLED, classJTidy, true));
m_configuredHtmlConverters.add(new CmsHtmlConverterOption(CmsHtmlConverter.PARAM_XHTML, classJTidy, true));
m_configuredHtmlConverters.add(new CmsHtmlConverterOption(CmsHtmlConverter.PARAM_WORD, classJTidy, true));
m_configuredHtmlConverters.add(
new CmsHtmlConverterOption(CmsHtmlConverter.PARAM_REPLACE_PARAGRAPHS, classJTidy, true));
}
// initialize lookup map of configured HTML converters
m_htmlConverters = new HashMap<String, String>(m_configuredHtmlConverters.size());
for (Iterator<CmsHtmlConverterOption> i = m_configuredHtmlConverters.iterator(); i.hasNext();) {
CmsHtmlConverterOption converterOption = i.next();
m_htmlConverters.put(converterOption.getName(), converterOption.getClassName());
}
} | [
"private",
"void",
"initHtmlConverters",
"(",
")",
"{",
"// check if any HTML converter configuration were found",
"if",
"(",
"m_configuredHtmlConverters",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// no converters configured, add default JTidy converter configuration",
"String",
"classJTidy",
"=",
"CmsHtmlConverterJTidy",
".",
"class",
".",
"getName",
"(",
")",
";",
"m_configuredHtmlConverters",
".",
"add",
"(",
"new",
"CmsHtmlConverterOption",
"(",
"CmsHtmlConverter",
".",
"PARAM_ENABLED",
",",
"classJTidy",
",",
"true",
")",
")",
";",
"m_configuredHtmlConverters",
".",
"add",
"(",
"new",
"CmsHtmlConverterOption",
"(",
"CmsHtmlConverter",
".",
"PARAM_XHTML",
",",
"classJTidy",
",",
"true",
")",
")",
";",
"m_configuredHtmlConverters",
".",
"add",
"(",
"new",
"CmsHtmlConverterOption",
"(",
"CmsHtmlConverter",
".",
"PARAM_WORD",
",",
"classJTidy",
",",
"true",
")",
")",
";",
"m_configuredHtmlConverters",
".",
"add",
"(",
"new",
"CmsHtmlConverterOption",
"(",
"CmsHtmlConverter",
".",
"PARAM_REPLACE_PARAGRAPHS",
",",
"classJTidy",
",",
"true",
")",
")",
";",
"}",
"// initialize lookup map of configured HTML converters",
"m_htmlConverters",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
"m_configuredHtmlConverters",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Iterator",
"<",
"CmsHtmlConverterOption",
">",
"i",
"=",
"m_configuredHtmlConverters",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"CmsHtmlConverterOption",
"converterOption",
"=",
"i",
".",
"next",
"(",
")",
";",
"m_htmlConverters",
".",
"put",
"(",
"converterOption",
".",
"getName",
"(",
")",
",",
"converterOption",
".",
"getClassName",
"(",
")",
")",
";",
"}",
"}"
] | Initialize the HTML converters.<p>
HTML converters are configured in the OpenCms <code>opencms-vfs.xml</code> configuration file.<p>
For legacy reasons, the default JTidy HTML converter has to be loaded if no explicit HTML converters
are configured in the configuration file.<p> | [
"Initialize",
"the",
"HTML",
"converters",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/loader/CmsResourceManager.java#L1319-L1339 |
Impetus/Kundera | src/kundera-rdbms/src/main/java/com/impetus/client/rdbms/HibernateUtils.java | HibernateUtils.getProperties | static final Properties getProperties(final KunderaMetadata kunderaMetadata, final String persistenceUnit) {
"""
Gets the properties.
@param persistenceUnit
the persistence unit
@return the properties
"""
PersistenceUnitMetadata persistenceUnitMetadatata = kunderaMetadata.getApplicationMetadata()
.getPersistenceUnitMetadata(persistenceUnit);
Properties props = persistenceUnitMetadatata.getProperties();
return props;
} | java | static final Properties getProperties(final KunderaMetadata kunderaMetadata, final String persistenceUnit)
{
PersistenceUnitMetadata persistenceUnitMetadatata = kunderaMetadata.getApplicationMetadata()
.getPersistenceUnitMetadata(persistenceUnit);
Properties props = persistenceUnitMetadatata.getProperties();
return props;
} | [
"static",
"final",
"Properties",
"getProperties",
"(",
"final",
"KunderaMetadata",
"kunderaMetadata",
",",
"final",
"String",
"persistenceUnit",
")",
"{",
"PersistenceUnitMetadata",
"persistenceUnitMetadatata",
"=",
"kunderaMetadata",
".",
"getApplicationMetadata",
"(",
")",
".",
"getPersistenceUnitMetadata",
"(",
"persistenceUnit",
")",
";",
"Properties",
"props",
"=",
"persistenceUnitMetadatata",
".",
"getProperties",
"(",
")",
";",
"return",
"props",
";",
"}"
] | Gets the properties.
@param persistenceUnit
the persistence unit
@return the properties | [
"Gets",
"the",
"properties",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-rdbms/src/main/java/com/impetus/client/rdbms/HibernateUtils.java#L61-L67 |
kmi/iserve | iserve-semantic-discovery/src/main/java/uk/ac/open/kmi/iserve/discovery/disco/impl/SparqlLogicConceptMatcher.java | SparqlLogicConceptMatcher.listMatchesAtLeastOfType | @Override
public Table<URI, URI, MatchResult> listMatchesAtLeastOfType(Set<URI> origins, MatchType minType) {
"""
Obtains all the matching resources that have a MatchType with the URIs of {@code origin} of the type provided (inclusive) or more.
@param origins URIs to match
@param minType the minimum MatchType we want to obtain
@return a {@link com.google.common.collect.Table} with the result of the matching indexed by origin URI and then destination URI.
"""
Table<URI, URI, MatchResult> matchTable = HashBasedTable.create();
Stopwatch w = new Stopwatch();
for (URI origin : origins) {
w.start();
Map<URI, MatchResult> result = listMatchesAtLeastOfType(origin, minType);
for (Map.Entry<URI, MatchResult> dest : result.entrySet()) {
matchTable.put(origin, dest.getKey(), dest.getValue());
}
log.debug("Computed matched types for {} in {}. {} total matches.", origin, w.stop().toString(), result.size());
w.reset();
}
return matchTable;
// return obtainMatchResults(origins, minType, this.getMatchTypesSupported().getHighest()); // TODO: Use the proper implementation for this
} | java | @Override
public Table<URI, URI, MatchResult> listMatchesAtLeastOfType(Set<URI> origins, MatchType minType) {
Table<URI, URI, MatchResult> matchTable = HashBasedTable.create();
Stopwatch w = new Stopwatch();
for (URI origin : origins) {
w.start();
Map<URI, MatchResult> result = listMatchesAtLeastOfType(origin, minType);
for (Map.Entry<URI, MatchResult> dest : result.entrySet()) {
matchTable.put(origin, dest.getKey(), dest.getValue());
}
log.debug("Computed matched types for {} in {}. {} total matches.", origin, w.stop().toString(), result.size());
w.reset();
}
return matchTable;
// return obtainMatchResults(origins, minType, this.getMatchTypesSupported().getHighest()); // TODO: Use the proper implementation for this
} | [
"@",
"Override",
"public",
"Table",
"<",
"URI",
",",
"URI",
",",
"MatchResult",
">",
"listMatchesAtLeastOfType",
"(",
"Set",
"<",
"URI",
">",
"origins",
",",
"MatchType",
"minType",
")",
"{",
"Table",
"<",
"URI",
",",
"URI",
",",
"MatchResult",
">",
"matchTable",
"=",
"HashBasedTable",
".",
"create",
"(",
")",
";",
"Stopwatch",
"w",
"=",
"new",
"Stopwatch",
"(",
")",
";",
"for",
"(",
"URI",
"origin",
":",
"origins",
")",
"{",
"w",
".",
"start",
"(",
")",
";",
"Map",
"<",
"URI",
",",
"MatchResult",
">",
"result",
"=",
"listMatchesAtLeastOfType",
"(",
"origin",
",",
"minType",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"URI",
",",
"MatchResult",
">",
"dest",
":",
"result",
".",
"entrySet",
"(",
")",
")",
"{",
"matchTable",
".",
"put",
"(",
"origin",
",",
"dest",
".",
"getKey",
"(",
")",
",",
"dest",
".",
"getValue",
"(",
")",
")",
";",
"}",
"log",
".",
"debug",
"(",
"\"Computed matched types for {} in {}. {} total matches.\"",
",",
"origin",
",",
"w",
".",
"stop",
"(",
")",
".",
"toString",
"(",
")",
",",
"result",
".",
"size",
"(",
")",
")",
";",
"w",
".",
"reset",
"(",
")",
";",
"}",
"return",
"matchTable",
";",
"// return obtainMatchResults(origins, minType, this.getMatchTypesSupported().getHighest()); // TODO: Use the proper implementation for this",
"}"
] | Obtains all the matching resources that have a MatchType with the URIs of {@code origin} of the type provided (inclusive) or more.
@param origins URIs to match
@param minType the minimum MatchType we want to obtain
@return a {@link com.google.common.collect.Table} with the result of the matching indexed by origin URI and then destination URI. | [
"Obtains",
"all",
"the",
"matching",
"resources",
"that",
"have",
"a",
"MatchType",
"with",
"the",
"URIs",
"of",
"{",
"@code",
"origin",
"}",
"of",
"the",
"type",
"provided",
"(",
"inclusive",
")",
"or",
"more",
"."
] | train | https://github.com/kmi/iserve/blob/13e7016e64c1d5a539b838c6debf1a5cc4aefcb7/iserve-semantic-discovery/src/main/java/uk/ac/open/kmi/iserve/discovery/disco/impl/SparqlLogicConceptMatcher.java#L277-L293 |
hsiafan/apk-parser | src/main/java/net/dongliu/apk/parser/ApkParsers.java | ApkParsers.getMetaInfo | public static ApkMeta getMetaInfo(String apkFilePath, Locale locale) throws IOException {
"""
Get apk meta info for apk file, with locale
@throws IOException
"""
try (ApkFile apkFile = new ApkFile(apkFilePath)) {
apkFile.setPreferredLocale(locale);
return apkFile.getApkMeta();
}
} | java | public static ApkMeta getMetaInfo(String apkFilePath, Locale locale) throws IOException {
try (ApkFile apkFile = new ApkFile(apkFilePath)) {
apkFile.setPreferredLocale(locale);
return apkFile.getApkMeta();
}
} | [
"public",
"static",
"ApkMeta",
"getMetaInfo",
"(",
"String",
"apkFilePath",
",",
"Locale",
"locale",
")",
"throws",
"IOException",
"{",
"try",
"(",
"ApkFile",
"apkFile",
"=",
"new",
"ApkFile",
"(",
"apkFilePath",
")",
")",
"{",
"apkFile",
".",
"setPreferredLocale",
"(",
"locale",
")",
";",
"return",
"apkFile",
".",
"getApkMeta",
"(",
")",
";",
"}",
"}"
] | Get apk meta info for apk file, with locale
@throws IOException | [
"Get",
"apk",
"meta",
"info",
"for",
"apk",
"file",
"with",
"locale"
] | train | https://github.com/hsiafan/apk-parser/blob/8993ddd52017b37b8f2e784ae0a15417d9ede932/src/main/java/net/dongliu/apk/parser/ApkParsers.java#L68-L73 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emailpro/src/main/java/net/minidev/ovh/api/ApiOvhEmailpro.java | ApiOvhEmailpro.service_domain_GET | public ArrayList<String> service_domain_GET(String service, OvhObjectStateEnum state) throws IOException {
"""
Domains associated to this service
REST: GET /email/pro/{service}/domain
@param state [required] Filter the value of state property (=)
@param service [required] The internal name of your pro organization
API beta
"""
String qPath = "/email/pro/{service}/domain";
StringBuilder sb = path(qPath, service);
query(sb, "state", state);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t2);
} | java | public ArrayList<String> service_domain_GET(String service, OvhObjectStateEnum state) throws IOException {
String qPath = "/email/pro/{service}/domain";
StringBuilder sb = path(qPath, service);
query(sb, "state", state);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t2);
} | [
"public",
"ArrayList",
"<",
"String",
">",
"service_domain_GET",
"(",
"String",
"service",
",",
"OvhObjectStateEnum",
"state",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/pro/{service}/domain\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"service",
")",
";",
"query",
"(",
"sb",
",",
"\"state\"",
",",
"state",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t2",
")",
";",
"}"
] | Domains associated to this service
REST: GET /email/pro/{service}/domain
@param state [required] Filter the value of state property (=)
@param service [required] The internal name of your pro organization
API beta | [
"Domains",
"associated",
"to",
"this",
"service"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emailpro/src/main/java/net/minidev/ovh/api/ApiOvhEmailpro.java#L728-L734 |
agmip/ace-lookup | src/main/java/org/agmip/ace/util/AcePathfinderUtil.java | AcePathfinderUtil.buildPath | private static void buildPath(HashMap m, String p) {
"""
Creates a nested path, if not already present in the map. This does not
support multipath definitions. Please split prior to sending the path to
this function.
@param m The map to create the path inside of.
@param p The full path to create.
"""
boolean isEvent = false;
if(p.contains("@")) {
String[] components = p.split("@");
int cl = components.length;
buildNestedBuckets(m, components[0]);
if(cl == 2) {
if(p.contains("!")) isEvent = true;
HashMap pointer = traverseToPoint(m, components[0]);
String d;
if(isEvent) {
String[] temp = components[1].split("!");
d = temp[0];
} else {
d = components[1];
}
if( ! pointer.containsKey(d) )
pointer.put(d, new ArrayList());
}
}
} | java | private static void buildPath(HashMap m, String p) {
boolean isEvent = false;
if(p.contains("@")) {
String[] components = p.split("@");
int cl = components.length;
buildNestedBuckets(m, components[0]);
if(cl == 2) {
if(p.contains("!")) isEvent = true;
HashMap pointer = traverseToPoint(m, components[0]);
String d;
if(isEvent) {
String[] temp = components[1].split("!");
d = temp[0];
} else {
d = components[1];
}
if( ! pointer.containsKey(d) )
pointer.put(d, new ArrayList());
}
}
} | [
"private",
"static",
"void",
"buildPath",
"(",
"HashMap",
"m",
",",
"String",
"p",
")",
"{",
"boolean",
"isEvent",
"=",
"false",
";",
"if",
"(",
"p",
".",
"contains",
"(",
"\"@\"",
")",
")",
"{",
"String",
"[",
"]",
"components",
"=",
"p",
".",
"split",
"(",
"\"@\"",
")",
";",
"int",
"cl",
"=",
"components",
".",
"length",
";",
"buildNestedBuckets",
"(",
"m",
",",
"components",
"[",
"0",
"]",
")",
";",
"if",
"(",
"cl",
"==",
"2",
")",
"{",
"if",
"(",
"p",
".",
"contains",
"(",
"\"!\"",
")",
")",
"isEvent",
"=",
"true",
";",
"HashMap",
"pointer",
"=",
"traverseToPoint",
"(",
"m",
",",
"components",
"[",
"0",
"]",
")",
";",
"String",
"d",
";",
"if",
"(",
"isEvent",
")",
"{",
"String",
"[",
"]",
"temp",
"=",
"components",
"[",
"1",
"]",
".",
"split",
"(",
"\"!\"",
")",
";",
"d",
"=",
"temp",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"d",
"=",
"components",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"!",
"pointer",
".",
"containsKey",
"(",
"d",
")",
")",
"pointer",
".",
"put",
"(",
"d",
",",
"new",
"ArrayList",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Creates a nested path, if not already present in the map. This does not
support multipath definitions. Please split prior to sending the path to
this function.
@param m The map to create the path inside of.
@param p The full path to create. | [
"Creates",
"a",
"nested",
"path",
"if",
"not",
"already",
"present",
"in",
"the",
"map",
".",
"This",
"does",
"not",
"support",
"multipath",
"definitions",
".",
"Please",
"split",
"prior",
"to",
"sending",
"the",
"path",
"to",
"this",
"function",
"."
] | train | https://github.com/agmip/ace-lookup/blob/d8224a231cb8c01729e63010916a2a85517ce4c1/src/main/java/org/agmip/ace/util/AcePathfinderUtil.java#L233-L253 |
alipay/sofa-rpc | core/common/src/main/java/com/alipay/sofa/rpc/common/cache/ReflectCache.java | ReflectCache.getMethodCache | public static Method getMethodCache(String serviceName, String methodName) {
"""
从缓存里获取方法
@param serviceName 服务名(非接口名)
@param methodName 方法名
@return 方法
"""
ConcurrentHashMap<String, Method> methods = NOT_OVERLOAD_METHOD_CACHE.get(serviceName);
return methods == null ? null : methods.get(methodName);
} | java | public static Method getMethodCache(String serviceName, String methodName) {
ConcurrentHashMap<String, Method> methods = NOT_OVERLOAD_METHOD_CACHE.get(serviceName);
return methods == null ? null : methods.get(methodName);
} | [
"public",
"static",
"Method",
"getMethodCache",
"(",
"String",
"serviceName",
",",
"String",
"methodName",
")",
"{",
"ConcurrentHashMap",
"<",
"String",
",",
"Method",
">",
"methods",
"=",
"NOT_OVERLOAD_METHOD_CACHE",
".",
"get",
"(",
"serviceName",
")",
";",
"return",
"methods",
"==",
"null",
"?",
"null",
":",
"methods",
".",
"get",
"(",
"methodName",
")",
";",
"}"
] | 从缓存里获取方法
@param serviceName 服务名(非接口名)
@param methodName 方法名
@return 方法 | [
"从缓存里获取方法"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core/common/src/main/java/com/alipay/sofa/rpc/common/cache/ReflectCache.java#L190-L193 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/trees/EnglishGrammaticalStructure.java | EnglishGrammaticalStructure.isConjWithNoPrep | private static boolean isConjWithNoPrep(TreeGraphNode node, Collection<TypedDependency> list) {
"""
Given a list of typedDependencies, returns true if the node "node" is the
governor of a conj relation with a dependent which is not a preposition
@param node
A node in this GrammaticalStructure
@param list
A list of typedDependencies
@return true If node is the governor of a conj relation in the list with
the dep not being a preposition
"""
for (TypedDependency td : list) {
if (td.gov() == node && td.reln() == CONJUNCT) {
// we have a conjunct
// check the POS of the dependent
String tdDepPOS = td.dep().parent().value();
if (!(tdDepPOS.equals("IN") || tdDepPOS.equals("TO"))) {
return true;
}
}
}
return false;
} | java | private static boolean isConjWithNoPrep(TreeGraphNode node, Collection<TypedDependency> list) {
for (TypedDependency td : list) {
if (td.gov() == node && td.reln() == CONJUNCT) {
// we have a conjunct
// check the POS of the dependent
String tdDepPOS = td.dep().parent().value();
if (!(tdDepPOS.equals("IN") || tdDepPOS.equals("TO"))) {
return true;
}
}
}
return false;
} | [
"private",
"static",
"boolean",
"isConjWithNoPrep",
"(",
"TreeGraphNode",
"node",
",",
"Collection",
"<",
"TypedDependency",
">",
"list",
")",
"{",
"for",
"(",
"TypedDependency",
"td",
":",
"list",
")",
"{",
"if",
"(",
"td",
".",
"gov",
"(",
")",
"==",
"node",
"&&",
"td",
".",
"reln",
"(",
")",
"==",
"CONJUNCT",
")",
"{",
"// we have a conjunct\r",
"// check the POS of the dependent\r",
"String",
"tdDepPOS",
"=",
"td",
".",
"dep",
"(",
")",
".",
"parent",
"(",
")",
".",
"value",
"(",
")",
";",
"if",
"(",
"!",
"(",
"tdDepPOS",
".",
"equals",
"(",
"\"IN\"",
")",
"||",
"tdDepPOS",
".",
"equals",
"(",
"\"TO\"",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Given a list of typedDependencies, returns true if the node "node" is the
governor of a conj relation with a dependent which is not a preposition
@param node
A node in this GrammaticalStructure
@param list
A list of typedDependencies
@return true If node is the governor of a conj relation in the list with
the dep not being a preposition | [
"Given",
"a",
"list",
"of",
"typedDependencies",
"returns",
"true",
"if",
"the",
"node",
"node",
"is",
"the",
"governor",
"of",
"a",
"conj",
"relation",
"with",
"a",
"dependent",
"which",
"is",
"not",
"a",
"preposition"
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/trees/EnglishGrammaticalStructure.java#L1106-L1118 |
tango-controls/JTango | server/src/main/java/org/tango/server/events/EventManager.java | EventManager.pushAttributeErrorEvent | public void pushAttributeErrorEvent(final String deviceName, final String attributeName, final DevFailed devFailed)
throws DevFailed {
"""
Check if the event must be sent and fire it if must be done
@param attributeName specified event attribute
@param devFailed the attribute failed error to be sent as event
@throws fr.esrf.Tango.DevFailed
@throws DevFailed
"""
xlogger.entry();
for (final EventType eventType : EventType.values()) {
final String fullName = EventUtilities.buildEventName(deviceName, attributeName, eventType);
final EventImpl eventImpl = getEventImpl(fullName);
if (eventImpl != null) {
for (ZMQ.Socket eventSocket : eventEndpoints.values()) {
eventImpl.pushDevFailedEvent(devFailed, eventSocket);
}
}
}
xlogger.exit();
} | java | public void pushAttributeErrorEvent(final String deviceName, final String attributeName, final DevFailed devFailed)
throws DevFailed {
xlogger.entry();
for (final EventType eventType : EventType.values()) {
final String fullName = EventUtilities.buildEventName(deviceName, attributeName, eventType);
final EventImpl eventImpl = getEventImpl(fullName);
if (eventImpl != null) {
for (ZMQ.Socket eventSocket : eventEndpoints.values()) {
eventImpl.pushDevFailedEvent(devFailed, eventSocket);
}
}
}
xlogger.exit();
} | [
"public",
"void",
"pushAttributeErrorEvent",
"(",
"final",
"String",
"deviceName",
",",
"final",
"String",
"attributeName",
",",
"final",
"DevFailed",
"devFailed",
")",
"throws",
"DevFailed",
"{",
"xlogger",
".",
"entry",
"(",
")",
";",
"for",
"(",
"final",
"EventType",
"eventType",
":",
"EventType",
".",
"values",
"(",
")",
")",
"{",
"final",
"String",
"fullName",
"=",
"EventUtilities",
".",
"buildEventName",
"(",
"deviceName",
",",
"attributeName",
",",
"eventType",
")",
";",
"final",
"EventImpl",
"eventImpl",
"=",
"getEventImpl",
"(",
"fullName",
")",
";",
"if",
"(",
"eventImpl",
"!=",
"null",
")",
"{",
"for",
"(",
"ZMQ",
".",
"Socket",
"eventSocket",
":",
"eventEndpoints",
".",
"values",
"(",
")",
")",
"{",
"eventImpl",
".",
"pushDevFailedEvent",
"(",
"devFailed",
",",
"eventSocket",
")",
";",
"}",
"}",
"}",
"xlogger",
".",
"exit",
"(",
")",
";",
"}"
] | Check if the event must be sent and fire it if must be done
@param attributeName specified event attribute
@param devFailed the attribute failed error to be sent as event
@throws fr.esrf.Tango.DevFailed
@throws DevFailed | [
"Check",
"if",
"the",
"event",
"must",
"be",
"sent",
"and",
"fire",
"it",
"if",
"must",
"be",
"done"
] | train | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/events/EventManager.java#L478-L491 |
EasyinnovaSL/Tiff-Library-4J | src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java | BaselineProfile.CheckTransparencyMask | private void CheckTransparencyMask(IfdTags metadata, int n) {
"""
Check transparency mask.
@param metadata the metadata
@param n the ifd number
"""
// Samples per pixel
if (!metadata.containsTagId(TiffTags.getTagId("SamplesPerPixel"))) {
validation.addErrorLoc("Missing Samples Per Pixel", "IFD" + n);
} else {
long spp = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
if (spp != 1) {
validation.addError("Invalid Samples Per Pixel", "IFD" + n, spp);
}
}
// BitsPerSample
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
} else {
long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
if (bps != 1) {
validation.addError("Invalid BitsPerSample", "IFD" + n, bps);
}
}
} | java | private void CheckTransparencyMask(IfdTags metadata, int n) {
// Samples per pixel
if (!metadata.containsTagId(TiffTags.getTagId("SamplesPerPixel"))) {
validation.addErrorLoc("Missing Samples Per Pixel", "IFD" + n);
} else {
long spp = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
if (spp != 1) {
validation.addError("Invalid Samples Per Pixel", "IFD" + n, spp);
}
}
// BitsPerSample
if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
} else {
long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
if (bps != 1) {
validation.addError("Invalid BitsPerSample", "IFD" + n, bps);
}
}
} | [
"private",
"void",
"CheckTransparencyMask",
"(",
"IfdTags",
"metadata",
",",
"int",
"n",
")",
"{",
"// Samples per pixel",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"SamplesPerPixel\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing Samples Per Pixel\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"else",
"{",
"long",
"spp",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"SamplesPerPixel\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"if",
"(",
"spp",
"!=",
"1",
")",
"{",
"validation",
".",
"addError",
"(",
"\"Invalid Samples Per Pixel\"",
",",
"\"IFD\"",
"+",
"n",
",",
"spp",
")",
";",
"}",
"}",
"// BitsPerSample",
"if",
"(",
"!",
"metadata",
".",
"containsTagId",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
")",
"{",
"validation",
".",
"addErrorLoc",
"(",
"\"Missing BitsPerSample\"",
",",
"\"IFD\"",
"+",
"n",
")",
";",
"}",
"else",
"{",
"long",
"bps",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
".",
"getFirstNumericValue",
"(",
")",
";",
"if",
"(",
"bps",
"!=",
"1",
")",
"{",
"validation",
".",
"addError",
"(",
"\"Invalid BitsPerSample\"",
",",
"\"IFD\"",
"+",
"n",
",",
"bps",
")",
";",
"}",
"}",
"}"
] | Check transparency mask.
@param metadata the metadata
@param n the ifd number | [
"Check",
"transparency",
"mask",
"."
] | train | https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L318-L338 |
Stratio/bdt | src/main/java/com/stratio/qa/specs/FileSpec.java | FileSpec.readFileToVariable | @When("^I read file '(.+?)' as '(.+?)' and save it in environment variable '(.+?)' with:$")
public void readFileToVariable(String baseData, String type, String envVar, DataTable modifications) throws Exception {
"""
Read the file passed as parameter, perform the modifications specified and save the result in the environment
variable passed as parameter.
@param baseData file to read
@param type whether the info in the file is a 'json' or a simple 'string'
@param envVar name of the variable where to store the result
@param modifications modifications to perform in the content of the file
"""
// Retrieve data
String retrievedData = commonspec.retrieveData(baseData, type);
// Modify data
commonspec.getLogger().debug("Modifying data {} as {}", retrievedData, type);
String modifiedData = commonspec.modifyData(retrievedData, type, modifications).toString();
// Save in environment variable
ThreadProperty.set(envVar, modifiedData);
} | java | @When("^I read file '(.+?)' as '(.+?)' and save it in environment variable '(.+?)' with:$")
public void readFileToVariable(String baseData, String type, String envVar, DataTable modifications) throws Exception {
// Retrieve data
String retrievedData = commonspec.retrieveData(baseData, type);
// Modify data
commonspec.getLogger().debug("Modifying data {} as {}", retrievedData, type);
String modifiedData = commonspec.modifyData(retrievedData, type, modifications).toString();
// Save in environment variable
ThreadProperty.set(envVar, modifiedData);
} | [
"@",
"When",
"(",
"\"^I read file '(.+?)' as '(.+?)' and save it in environment variable '(.+?)' with:$\"",
")",
"public",
"void",
"readFileToVariable",
"(",
"String",
"baseData",
",",
"String",
"type",
",",
"String",
"envVar",
",",
"DataTable",
"modifications",
")",
"throws",
"Exception",
"{",
"// Retrieve data",
"String",
"retrievedData",
"=",
"commonspec",
".",
"retrieveData",
"(",
"baseData",
",",
"type",
")",
";",
"// Modify data",
"commonspec",
".",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"Modifying data {} as {}\"",
",",
"retrievedData",
",",
"type",
")",
";",
"String",
"modifiedData",
"=",
"commonspec",
".",
"modifyData",
"(",
"retrievedData",
",",
"type",
",",
"modifications",
")",
".",
"toString",
"(",
")",
";",
"// Save in environment variable",
"ThreadProperty",
".",
"set",
"(",
"envVar",
",",
"modifiedData",
")",
";",
"}"
] | Read the file passed as parameter, perform the modifications specified and save the result in the environment
variable passed as parameter.
@param baseData file to read
@param type whether the info in the file is a 'json' or a simple 'string'
@param envVar name of the variable where to store the result
@param modifications modifications to perform in the content of the file | [
"Read",
"the",
"file",
"passed",
"as",
"parameter",
"perform",
"the",
"modifications",
"specified",
"and",
"save",
"the",
"result",
"in",
"the",
"environment",
"variable",
"passed",
"as",
"parameter",
"."
] | train | https://github.com/Stratio/bdt/blob/55324d19e7497764ad3dd7139923e13eb9841d75/src/main/java/com/stratio/qa/specs/FileSpec.java#L171-L182 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/thread/BaseRecordOwner.java | BaseRecordOwner.setProperty | public void setProperty(String strProperty, String strValue) {
"""
Set this property.
@param strProperty The property key.
@param strValue The property value.
Override this to do something.
"""
if (this.getParentRecordOwner() != null)
this.getParentRecordOwner().setProperty(strProperty, strValue);
} | java | public void setProperty(String strProperty, String strValue)
{
if (this.getParentRecordOwner() != null)
this.getParentRecordOwner().setProperty(strProperty, strValue);
} | [
"public",
"void",
"setProperty",
"(",
"String",
"strProperty",
",",
"String",
"strValue",
")",
"{",
"if",
"(",
"this",
".",
"getParentRecordOwner",
"(",
")",
"!=",
"null",
")",
"this",
".",
"getParentRecordOwner",
"(",
")",
".",
"setProperty",
"(",
"strProperty",
",",
"strValue",
")",
";",
"}"
] | Set this property.
@param strProperty The property key.
@param strValue The property value.
Override this to do something. | [
"Set",
"this",
"property",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/thread/BaseRecordOwner.java#L353-L357 |
ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java | WidgetsUtils.replaceOrAppend | public static void replaceOrAppend(Element e, Widget widget) {
"""
Replace a dom element by a widget.
Old element classes will be copied to the new widget.
"""
assert e != null && widget != null;
if ($(e).widget() != null && $(e).widget().isAttached()) {
replaceWidget($(e).widget(), widget, true);
} else {
detachWidget(widget);
replaceOrAppend(e, widget.getElement());
attachWidget(widget, getFirstParentWidget(widget));
}
} | java | public static void replaceOrAppend(Element e, Widget widget) {
assert e != null && widget != null;
if ($(e).widget() != null && $(e).widget().isAttached()) {
replaceWidget($(e).widget(), widget, true);
} else {
detachWidget(widget);
replaceOrAppend(e, widget.getElement());
attachWidget(widget, getFirstParentWidget(widget));
}
} | [
"public",
"static",
"void",
"replaceOrAppend",
"(",
"Element",
"e",
",",
"Widget",
"widget",
")",
"{",
"assert",
"e",
"!=",
"null",
"&&",
"widget",
"!=",
"null",
";",
"if",
"(",
"$",
"(",
"e",
")",
".",
"widget",
"(",
")",
"!=",
"null",
"&&",
"$",
"(",
"e",
")",
".",
"widget",
"(",
")",
".",
"isAttached",
"(",
")",
")",
"{",
"replaceWidget",
"(",
"$",
"(",
"e",
")",
".",
"widget",
"(",
")",
",",
"widget",
",",
"true",
")",
";",
"}",
"else",
"{",
"detachWidget",
"(",
"widget",
")",
";",
"replaceOrAppend",
"(",
"e",
",",
"widget",
".",
"getElement",
"(",
")",
")",
";",
"attachWidget",
"(",
"widget",
",",
"getFirstParentWidget",
"(",
"widget",
")",
")",
";",
"}",
"}"
] | Replace a dom element by a widget.
Old element classes will be copied to the new widget. | [
"Replace",
"a",
"dom",
"element",
"by",
"a",
"widget",
".",
"Old",
"element",
"classes",
"will",
"be",
"copied",
"to",
"the",
"new",
"widget",
"."
] | train | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java#L88-L97 |
zaproxy/zaproxy | src/org/parosproxy/paros/core/scanner/VariantGWTQuery.java | VariantGWTQuery.getEscapedValue | @Override
public String getEscapedValue(String value, boolean toQuote) {
"""
Escape a GWT string according to the client implementation found on
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter
http://www.gwtproject.org/
@param value the value that need to be escaped
@param toQuote
@return
"""
// Escape special characters
StringBuilder buf = new StringBuilder(value.length());
int idx = 0;
int ch;
while (idx < value.length()) {
ch = value.charAt(idx++);
if (ch == 0) {
buf.append("\\0");
} else if (ch == 92) { // backslash
buf.append("\\\\");
} else if (ch == 124) { // vertical bar
// 124 = "|" = AbstractSerializationStream.RPC_SEPARATOR_CHAR
buf.append("\\!");
} else if ((ch >= 0xD800) && (ch < 0xFFFF)) {
buf.append(String.format("\\u%04x", ch));
} else {
buf.append((char) ch);
}
}
return buf.toString();
} | java | @Override
public String getEscapedValue(String value, boolean toQuote) {
// Escape special characters
StringBuilder buf = new StringBuilder(value.length());
int idx = 0;
int ch;
while (idx < value.length()) {
ch = value.charAt(idx++);
if (ch == 0) {
buf.append("\\0");
} else if (ch == 92) { // backslash
buf.append("\\\\");
} else if (ch == 124) { // vertical bar
// 124 = "|" = AbstractSerializationStream.RPC_SEPARATOR_CHAR
buf.append("\\!");
} else if ((ch >= 0xD800) && (ch < 0xFFFF)) {
buf.append(String.format("\\u%04x", ch));
} else {
buf.append((char) ch);
}
}
return buf.toString();
} | [
"@",
"Override",
"public",
"String",
"getEscapedValue",
"(",
"String",
"value",
",",
"boolean",
"toQuote",
")",
"{",
"// Escape special characters\r",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"value",
".",
"length",
"(",
")",
")",
";",
"int",
"idx",
"=",
"0",
";",
"int",
"ch",
";",
"while",
"(",
"idx",
"<",
"value",
".",
"length",
"(",
")",
")",
"{",
"ch",
"=",
"value",
".",
"charAt",
"(",
"idx",
"++",
")",
";",
"if",
"(",
"ch",
"==",
"0",
")",
"{",
"buf",
".",
"append",
"(",
"\"\\\\0\"",
")",
";",
"}",
"else",
"if",
"(",
"ch",
"==",
"92",
")",
"{",
"// backslash\r",
"buf",
".",
"append",
"(",
"\"\\\\\\\\\"",
")",
";",
"}",
"else",
"if",
"(",
"ch",
"==",
"124",
")",
"{",
"// vertical bar\r",
"// 124 = \"|\" = AbstractSerializationStream.RPC_SEPARATOR_CHAR\r",
"buf",
".",
"append",
"(",
"\"\\\\!\"",
")",
";",
"}",
"else",
"if",
"(",
"(",
"ch",
">=",
"0xD800",
")",
"&&",
"(",
"ch",
"<",
"0xFFFF",
")",
")",
"{",
"buf",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"\\\\u%04x\"",
",",
"ch",
")",
")",
";",
"}",
"else",
"{",
"buf",
".",
"append",
"(",
"(",
"char",
")",
"ch",
")",
";",
"}",
"}",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Escape a GWT string according to the client implementation found on
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter
http://www.gwtproject.org/
@param value the value that need to be escaped
@param toQuote
@return | [
"Escape",
"a",
"GWT",
"string",
"according",
"to",
"the",
"client",
"implementation",
"found",
"on",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"impl",
".",
"ClientSerializationStreamWriter",
"http",
":",
"//",
"www",
".",
"gwtproject",
".",
"org",
"/"
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/core/scanner/VariantGWTQuery.java#L129-L157 |
hal/core | gui/src/main/java/org/jboss/as/console/client/widgets/CollapsibleSplitLayoutPanel.java | CollapsibleSplitLayoutPanel.setWidgetToggleDisplayAllowed | public void setWidgetToggleDisplayAllowed(Widget child, boolean allowed) {
"""
Sets whether or not double-clicking on the splitter should toggle the
display of the widget.
@param child the child whose display toggling will be allowed or not.
@param allowed whether or not display toggling is allowed for this widget
"""
assertIsChild(child);
Splitter splitter = getAssociatedSplitter(child);
// The splitter is null for the center element.
if (splitter != null) {
splitter.setToggleDisplayAllowed(allowed);
}
} | java | public void setWidgetToggleDisplayAllowed(Widget child, boolean allowed) {
assertIsChild(child);
Splitter splitter = getAssociatedSplitter(child);
// The splitter is null for the center element.
if (splitter != null) {
splitter.setToggleDisplayAllowed(allowed);
}
} | [
"public",
"void",
"setWidgetToggleDisplayAllowed",
"(",
"Widget",
"child",
",",
"boolean",
"allowed",
")",
"{",
"assertIsChild",
"(",
"child",
")",
";",
"Splitter",
"splitter",
"=",
"getAssociatedSplitter",
"(",
"child",
")",
";",
"// The splitter is null for the center element.",
"if",
"(",
"splitter",
"!=",
"null",
")",
"{",
"splitter",
".",
"setToggleDisplayAllowed",
"(",
"allowed",
")",
";",
"}",
"}"
] | Sets whether or not double-clicking on the splitter should toggle the
display of the widget.
@param child the child whose display toggling will be allowed or not.
@param allowed whether or not display toggling is allowed for this widget | [
"Sets",
"whether",
"or",
"not",
"double",
"-",
"clicking",
"on",
"the",
"splitter",
"should",
"toggle",
"the",
"display",
"of",
"the",
"widget",
"."
] | train | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/widgets/CollapsibleSplitLayoutPanel.java#L456-L463 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_MultiplyZ.java | ST_MultiplyZ.multiplyZ | public static Geometry multiplyZ(Geometry geometry, double z) throws SQLException {
"""
Multiply the z values of the geometry by another double value. NaN values
are not updated.
@param geometry
@param z
@return
@throws java.sql.SQLException
"""
if(geometry == null){
return null;
}
geometry.apply(new MultiplyZCoordinateSequenceFilter(z));
return geometry;
} | java | public static Geometry multiplyZ(Geometry geometry, double z) throws SQLException {
if(geometry == null){
return null;
}
geometry.apply(new MultiplyZCoordinateSequenceFilter(z));
return geometry;
} | [
"public",
"static",
"Geometry",
"multiplyZ",
"(",
"Geometry",
"geometry",
",",
"double",
"z",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"geometry",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"geometry",
".",
"apply",
"(",
"new",
"MultiplyZCoordinateSequenceFilter",
"(",
"z",
")",
")",
";",
"return",
"geometry",
";",
"}"
] | Multiply the z values of the geometry by another double value. NaN values
are not updated.
@param geometry
@param z
@return
@throws java.sql.SQLException | [
"Multiply",
"the",
"z",
"values",
"of",
"the",
"geometry",
"by",
"another",
"double",
"value",
".",
"NaN",
"values",
"are",
"not",
"updated",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_MultiplyZ.java#L56-L62 |
apache/reef | lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/evaluator/context/ContextManager.java | ContextManager.addContext | private void addContext(
final EvaluatorRuntimeProtocol.AddContextProto addContextProto)
throws ContextClientCodeException {
"""
Add a context to the stack.
@param addContextProto
@throws ContextClientCodeException if there is a client code related issue.
"""
synchronized (this.contextStack) {
try {
final ContextRuntime currentTopContext = this.contextStack.peek();
if (!currentTopContext.getIdentifier().equals(addContextProto.getParentContextId())) {
throw new IllegalStateException("Trying to instantiate a child context on context with id `" +
addContextProto.getParentContextId() + "` while the current top context id is `" +
currentTopContext.getIdentifier() + "`");
}
final Configuration contextConfiguration =
this.configurationSerializer.fromString(addContextProto.getContextConfiguration());
final ContextRuntime newTopContext;
if (addContextProto.hasServiceConfiguration()) {
newTopContext = currentTopContext.spawnChildContext(contextConfiguration,
this.configurationSerializer.fromString(addContextProto.getServiceConfiguration()));
} else {
newTopContext = currentTopContext.spawnChildContext(contextConfiguration);
}
this.contextStack.push(newTopContext);
} catch (final IOException | BindException e) {
throw new RuntimeException("Unable to read configuration.", e);
}
}
} | java | private void addContext(
final EvaluatorRuntimeProtocol.AddContextProto addContextProto)
throws ContextClientCodeException {
synchronized (this.contextStack) {
try {
final ContextRuntime currentTopContext = this.contextStack.peek();
if (!currentTopContext.getIdentifier().equals(addContextProto.getParentContextId())) {
throw new IllegalStateException("Trying to instantiate a child context on context with id `" +
addContextProto.getParentContextId() + "` while the current top context id is `" +
currentTopContext.getIdentifier() + "`");
}
final Configuration contextConfiguration =
this.configurationSerializer.fromString(addContextProto.getContextConfiguration());
final ContextRuntime newTopContext;
if (addContextProto.hasServiceConfiguration()) {
newTopContext = currentTopContext.spawnChildContext(contextConfiguration,
this.configurationSerializer.fromString(addContextProto.getServiceConfiguration()));
} else {
newTopContext = currentTopContext.spawnChildContext(contextConfiguration);
}
this.contextStack.push(newTopContext);
} catch (final IOException | BindException e) {
throw new RuntimeException("Unable to read configuration.", e);
}
}
} | [
"private",
"void",
"addContext",
"(",
"final",
"EvaluatorRuntimeProtocol",
".",
"AddContextProto",
"addContextProto",
")",
"throws",
"ContextClientCodeException",
"{",
"synchronized",
"(",
"this",
".",
"contextStack",
")",
"{",
"try",
"{",
"final",
"ContextRuntime",
"currentTopContext",
"=",
"this",
".",
"contextStack",
".",
"peek",
"(",
")",
";",
"if",
"(",
"!",
"currentTopContext",
".",
"getIdentifier",
"(",
")",
".",
"equals",
"(",
"addContextProto",
".",
"getParentContextId",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Trying to instantiate a child context on context with id `\"",
"+",
"addContextProto",
".",
"getParentContextId",
"(",
")",
"+",
"\"` while the current top context id is `\"",
"+",
"currentTopContext",
".",
"getIdentifier",
"(",
")",
"+",
"\"`\"",
")",
";",
"}",
"final",
"Configuration",
"contextConfiguration",
"=",
"this",
".",
"configurationSerializer",
".",
"fromString",
"(",
"addContextProto",
".",
"getContextConfiguration",
"(",
")",
")",
";",
"final",
"ContextRuntime",
"newTopContext",
";",
"if",
"(",
"addContextProto",
".",
"hasServiceConfiguration",
"(",
")",
")",
"{",
"newTopContext",
"=",
"currentTopContext",
".",
"spawnChildContext",
"(",
"contextConfiguration",
",",
"this",
".",
"configurationSerializer",
".",
"fromString",
"(",
"addContextProto",
".",
"getServiceConfiguration",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"newTopContext",
"=",
"currentTopContext",
".",
"spawnChildContext",
"(",
"contextConfiguration",
")",
";",
"}",
"this",
".",
"contextStack",
".",
"push",
"(",
"newTopContext",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"|",
"BindException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to read configuration.\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Add a context to the stack.
@param addContextProto
@throws ContextClientCodeException if there is a client code related issue. | [
"Add",
"a",
"context",
"to",
"the",
"stack",
"."
] | train | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/evaluator/context/ContextManager.java#L238-L271 |
alkacon/opencms-core | src/org/opencms/workplace/CmsDialog.java | CmsDialog.dialogButtonsCloseDetails | public String dialogButtonsCloseDetails(String closeAttribute, String detailsAttribute) {
"""
Builds a button row with a "close" and a "details" button.<p>
@param closeAttribute additional attributes for the "close" button
@param detailsAttribute additional attributes for the "details" button
@return the button row
"""
return dialogButtons(new int[] {BUTTON_CLOSE, BUTTON_DETAILS}, new String[] {closeAttribute, detailsAttribute});
} | java | public String dialogButtonsCloseDetails(String closeAttribute, String detailsAttribute) {
return dialogButtons(new int[] {BUTTON_CLOSE, BUTTON_DETAILS}, new String[] {closeAttribute, detailsAttribute});
} | [
"public",
"String",
"dialogButtonsCloseDetails",
"(",
"String",
"closeAttribute",
",",
"String",
"detailsAttribute",
")",
"{",
"return",
"dialogButtons",
"(",
"new",
"int",
"[",
"]",
"{",
"BUTTON_CLOSE",
",",
"BUTTON_DETAILS",
"}",
",",
"new",
"String",
"[",
"]",
"{",
"closeAttribute",
",",
"detailsAttribute",
"}",
")",
";",
"}"
] | Builds a button row with a "close" and a "details" button.<p>
@param closeAttribute additional attributes for the "close" button
@param detailsAttribute additional attributes for the "details" button
@return the button row | [
"Builds",
"a",
"button",
"row",
"with",
"a",
"close",
"and",
"a",
"details",
"button",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/CmsDialog.java#L676-L679 |
CodeNarc/CodeNarc | src/main/java/org/codenarc/util/AstUtil.java | AstUtil.isMethodCall | public static boolean isMethodCall(Expression expression, String methodName, Range numArguments) {
"""
Tells you if the expression is a method call for a certain method name with a certain
number of arguments.
@param expression
the (potentially) method call
@param methodName
the name of the method expected
@param numArguments
number of expected arguments
@return
as described
"""
if (expression instanceof MethodCallExpression && AstUtil.isMethodNamed((MethodCallExpression) expression, methodName)) {
int arity = AstUtil.getMethodArguments(expression).size();
if (arity >= (Integer)numArguments.getFrom() && arity <= (Integer)numArguments.getTo()) {
return true;
}
}
return false;
} | java | public static boolean isMethodCall(Expression expression, String methodName, Range numArguments) {
if (expression instanceof MethodCallExpression && AstUtil.isMethodNamed((MethodCallExpression) expression, methodName)) {
int arity = AstUtil.getMethodArguments(expression).size();
if (arity >= (Integer)numArguments.getFrom() && arity <= (Integer)numArguments.getTo()) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isMethodCall",
"(",
"Expression",
"expression",
",",
"String",
"methodName",
",",
"Range",
"numArguments",
")",
"{",
"if",
"(",
"expression",
"instanceof",
"MethodCallExpression",
"&&",
"AstUtil",
".",
"isMethodNamed",
"(",
"(",
"MethodCallExpression",
")",
"expression",
",",
"methodName",
")",
")",
"{",
"int",
"arity",
"=",
"AstUtil",
".",
"getMethodArguments",
"(",
"expression",
")",
".",
"size",
"(",
")",
";",
"if",
"(",
"arity",
">=",
"(",
"Integer",
")",
"numArguments",
".",
"getFrom",
"(",
")",
"&&",
"arity",
"<=",
"(",
"Integer",
")",
"numArguments",
".",
"getTo",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Tells you if the expression is a method call for a certain method name with a certain
number of arguments.
@param expression
the (potentially) method call
@param methodName
the name of the method expected
@param numArguments
number of expected arguments
@return
as described | [
"Tells",
"you",
"if",
"the",
"expression",
"is",
"a",
"method",
"call",
"for",
"a",
"certain",
"method",
"name",
"with",
"a",
"certain",
"number",
"of",
"arguments",
"."
] | train | https://github.com/CodeNarc/CodeNarc/blob/9a7cec02cb8cbaf845030f2434309e8968f5d7a7/src/main/java/org/codenarc/util/AstUtil.java#L408-L416 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging.hpel/src/com/ibm/websphere/logging/hpel/reader/RepositoryReaderImpl.java | RepositoryReaderImpl.getLogLists | @Override
public Iterable<ServerInstanceLogRecordList> getLogLists(RepositoryPointer after, Date maxTime) {
"""
returns log records from the binary repository that are after a given location and less than or equal to a given date
Callers would have to invoke {@link RepositoryLogRecord#getRepositoryPointer()} to obtain the RepositoryPointer of the last record read.
@param after RepositoryPointer of the last read log record.
@param maxTime the maximum {@link Date} value that the returned records can have
@return the iterable instance of a list of log records within a process that are within the parameter range and satisfy the condition.
If no records meet the criteria, an Iterable is returned with no entries
"""
return getLogLists(after, maxTime, (LogRecordFilter) null);
} | java | @Override
public Iterable<ServerInstanceLogRecordList> getLogLists(RepositoryPointer after, Date maxTime) {
return getLogLists(after, maxTime, (LogRecordFilter) null);
} | [
"@",
"Override",
"public",
"Iterable",
"<",
"ServerInstanceLogRecordList",
">",
"getLogLists",
"(",
"RepositoryPointer",
"after",
",",
"Date",
"maxTime",
")",
"{",
"return",
"getLogLists",
"(",
"after",
",",
"maxTime",
",",
"(",
"LogRecordFilter",
")",
"null",
")",
";",
"}"
] | returns log records from the binary repository that are after a given location and less than or equal to a given date
Callers would have to invoke {@link RepositoryLogRecord#getRepositoryPointer()} to obtain the RepositoryPointer of the last record read.
@param after RepositoryPointer of the last read log record.
@param maxTime the maximum {@link Date} value that the returned records can have
@return the iterable instance of a list of log records within a process that are within the parameter range and satisfy the condition.
If no records meet the criteria, an Iterable is returned with no entries | [
"returns",
"log",
"records",
"from",
"the",
"binary",
"repository",
"that",
"are",
"after",
"a",
"given",
"location",
"and",
"less",
"than",
"or",
"equal",
"to",
"a",
"given",
"date",
"Callers",
"would",
"have",
"to",
"invoke",
"{",
"@link",
"RepositoryLogRecord#getRepositoryPointer",
"()",
"}",
"to",
"obtain",
"the",
"RepositoryPointer",
"of",
"the",
"last",
"record",
"read",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.hpel/src/com/ibm/websphere/logging/hpel/reader/RepositoryReaderImpl.java#L774-L777 |
haifengl/smile | data/src/main/java/smile/data/parser/DelimitedTextParser.java | DelimitedTextParser.setResponseIndex | public DelimitedTextParser setResponseIndex(Attribute response, int index) {
"""
Sets the attribute and column index (starting at 0) of dependent/response variable.
"""
if (response.getType() != Attribute.Type.NOMINAL && response.getType() != Attribute.Type.NUMERIC) {
throw new IllegalArgumentException("The response variable is not numeric or nominal.");
}
this.response = response;
this.responseIndex = index;
return this;
} | java | public DelimitedTextParser setResponseIndex(Attribute response, int index) {
if (response.getType() != Attribute.Type.NOMINAL && response.getType() != Attribute.Type.NUMERIC) {
throw new IllegalArgumentException("The response variable is not numeric or nominal.");
}
this.response = response;
this.responseIndex = index;
return this;
} | [
"public",
"DelimitedTextParser",
"setResponseIndex",
"(",
"Attribute",
"response",
",",
"int",
"index",
")",
"{",
"if",
"(",
"response",
".",
"getType",
"(",
")",
"!=",
"Attribute",
".",
"Type",
".",
"NOMINAL",
"&&",
"response",
".",
"getType",
"(",
")",
"!=",
"Attribute",
".",
"Type",
".",
"NUMERIC",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The response variable is not numeric or nominal.\"",
")",
";",
"}",
"this",
".",
"response",
"=",
"response",
";",
"this",
".",
"responseIndex",
"=",
"index",
";",
"return",
"this",
";",
"}"
] | Sets the attribute and column index (starting at 0) of dependent/response variable. | [
"Sets",
"the",
"attribute",
"and",
"column",
"index",
"(",
"starting",
"at",
"0",
")",
"of",
"dependent",
"/",
"response",
"variable",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/data/src/main/java/smile/data/parser/DelimitedTextParser.java#L137-L145 |
ardoq/ardoq-java-client | src/main/java/com/ardoq/util/SyncUtil.java | SyncUtil.getTagByName | public Tag getTagByName(String name) {
"""
Gets an existing tag by name
@param name Name of the tag
@return Returns the tag
"""
Tag t = this.tags.get(name);
if (null == t) {
t = new Tag(name, this.workspace.getId(), "");
this.tags.put(name, t);
}
return t;
} | java | public Tag getTagByName(String name) {
Tag t = this.tags.get(name);
if (null == t) {
t = new Tag(name, this.workspace.getId(), "");
this.tags.put(name, t);
}
return t;
} | [
"public",
"Tag",
"getTagByName",
"(",
"String",
"name",
")",
"{",
"Tag",
"t",
"=",
"this",
".",
"tags",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"null",
"==",
"t",
")",
"{",
"t",
"=",
"new",
"Tag",
"(",
"name",
",",
"this",
".",
"workspace",
".",
"getId",
"(",
")",
",",
"\"\"",
")",
";",
"this",
".",
"tags",
".",
"put",
"(",
"name",
",",
"t",
")",
";",
"}",
"return",
"t",
";",
"}"
] | Gets an existing tag by name
@param name Name of the tag
@return Returns the tag | [
"Gets",
"an",
"existing",
"tag",
"by",
"name"
] | train | https://github.com/ardoq/ardoq-java-client/blob/03731c3df864d850ef41b252364a104376dde983/src/main/java/com/ardoq/util/SyncUtil.java#L145-L152 |
mikepenz/ItemAnimators | library/src/main/java/com/mikepenz/itemanimators/BaseItemAnimator.java | BaseItemAnimator.changeAnimation | public void changeAnimation(ViewHolder oldHolder, ViewHolder newHolder, int fromX, int fromY, int toX, int toY) {
"""
the whole change animation if we have to cross animate two views
@param oldHolder
@param newHolder
@param fromX
@param fromY
@param toX
@param toY
"""
final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
final float prevValue = ViewCompat.getAlpha(oldHolder.itemView);
resetAnimation(oldHolder);
int deltaX = (int) (toX - fromX - prevTranslationX);
int deltaY = (int) (toY - fromY - prevTranslationY);
// recover prev translation state after ending animation
ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
ViewCompat.setAlpha(oldHolder.itemView, prevValue);
if (newHolder != null) {
// carry over translation values
resetAnimation(newHolder);
ViewCompat.setTranslationX(newHolder.itemView, -deltaX);
ViewCompat.setTranslationY(newHolder.itemView, -deltaY);
ViewCompat.setAlpha(newHolder.itemView, 0);
}
} | java | public void changeAnimation(ViewHolder oldHolder, ViewHolder newHolder, int fromX, int fromY, int toX, int toY) {
final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
final float prevValue = ViewCompat.getAlpha(oldHolder.itemView);
resetAnimation(oldHolder);
int deltaX = (int) (toX - fromX - prevTranslationX);
int deltaY = (int) (toY - fromY - prevTranslationY);
// recover prev translation state after ending animation
ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
ViewCompat.setAlpha(oldHolder.itemView, prevValue);
if (newHolder != null) {
// carry over translation values
resetAnimation(newHolder);
ViewCompat.setTranslationX(newHolder.itemView, -deltaX);
ViewCompat.setTranslationY(newHolder.itemView, -deltaY);
ViewCompat.setAlpha(newHolder.itemView, 0);
}
} | [
"public",
"void",
"changeAnimation",
"(",
"ViewHolder",
"oldHolder",
",",
"ViewHolder",
"newHolder",
",",
"int",
"fromX",
",",
"int",
"fromY",
",",
"int",
"toX",
",",
"int",
"toY",
")",
"{",
"final",
"float",
"prevTranslationX",
"=",
"ViewCompat",
".",
"getTranslationX",
"(",
"oldHolder",
".",
"itemView",
")",
";",
"final",
"float",
"prevTranslationY",
"=",
"ViewCompat",
".",
"getTranslationY",
"(",
"oldHolder",
".",
"itemView",
")",
";",
"final",
"float",
"prevValue",
"=",
"ViewCompat",
".",
"getAlpha",
"(",
"oldHolder",
".",
"itemView",
")",
";",
"resetAnimation",
"(",
"oldHolder",
")",
";",
"int",
"deltaX",
"=",
"(",
"int",
")",
"(",
"toX",
"-",
"fromX",
"-",
"prevTranslationX",
")",
";",
"int",
"deltaY",
"=",
"(",
"int",
")",
"(",
"toY",
"-",
"fromY",
"-",
"prevTranslationY",
")",
";",
"// recover prev translation state after ending animation",
"ViewCompat",
".",
"setTranslationX",
"(",
"oldHolder",
".",
"itemView",
",",
"prevTranslationX",
")",
";",
"ViewCompat",
".",
"setTranslationY",
"(",
"oldHolder",
".",
"itemView",
",",
"prevTranslationY",
")",
";",
"ViewCompat",
".",
"setAlpha",
"(",
"oldHolder",
".",
"itemView",
",",
"prevValue",
")",
";",
"if",
"(",
"newHolder",
"!=",
"null",
")",
"{",
"// carry over translation values",
"resetAnimation",
"(",
"newHolder",
")",
";",
"ViewCompat",
".",
"setTranslationX",
"(",
"newHolder",
".",
"itemView",
",",
"-",
"deltaX",
")",
";",
"ViewCompat",
".",
"setTranslationY",
"(",
"newHolder",
".",
"itemView",
",",
"-",
"deltaY",
")",
";",
"ViewCompat",
".",
"setAlpha",
"(",
"newHolder",
".",
"itemView",
",",
"0",
")",
";",
"}",
"}"
] | the whole change animation if we have to cross animate two views
@param oldHolder
@param newHolder
@param fromX
@param fromY
@param toX
@param toY | [
"the",
"whole",
"change",
"animation",
"if",
"we",
"have",
"to",
"cross",
"animate",
"two",
"views"
] | train | https://github.com/mikepenz/ItemAnimators/blob/dacfdbd7bfe8a281670e9378a74f54e362678c43/library/src/main/java/com/mikepenz/itemanimators/BaseItemAnimator.java#L461-L480 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/Calc.java | Calc.getDistance | public static final double getDistance(Atom a, Atom b) {
"""
calculate distance between two atoms.
@param a
an Atom object
@param b
an Atom object
@return a double
"""
double x = a.getX() - b.getX();
double y = a.getY() - b.getY();
double z = a.getZ() - b.getZ();
double s = x * x + y * y + z * z;
return Math.sqrt(s);
} | java | public static final double getDistance(Atom a, Atom b) {
double x = a.getX() - b.getX();
double y = a.getY() - b.getY();
double z = a.getZ() - b.getZ();
double s = x * x + y * y + z * z;
return Math.sqrt(s);
} | [
"public",
"static",
"final",
"double",
"getDistance",
"(",
"Atom",
"a",
",",
"Atom",
"b",
")",
"{",
"double",
"x",
"=",
"a",
".",
"getX",
"(",
")",
"-",
"b",
".",
"getX",
"(",
")",
";",
"double",
"y",
"=",
"a",
".",
"getY",
"(",
")",
"-",
"b",
".",
"getY",
"(",
")",
";",
"double",
"z",
"=",
"a",
".",
"getZ",
"(",
")",
"-",
"b",
".",
"getZ",
"(",
")",
";",
"double",
"s",
"=",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
"+",
"z",
"*",
"z",
";",
"return",
"Math",
".",
"sqrt",
"(",
"s",
")",
";",
"}"
] | calculate distance between two atoms.
@param a
an Atom object
@param b
an Atom object
@return a double | [
"calculate",
"distance",
"between",
"two",
"atoms",
"."
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/Calc.java#L68-L76 |
zaproxy/zaproxy | src/org/zaproxy/zap/utils/PausableScheduledThreadPoolExecutor.java | PausableScheduledThreadPoolExecutor.submit | @Override
public <T> Future<T> submit(Runnable task, T result) {
"""
{@inheritDoc}
<p>
Overridden to schedule with default delay, when non zero.
@throws RejectedExecutionException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
@see #setIncrementalDefaultDelay(boolean)
@see #schedule(Runnable, long, TimeUnit)
@see #setDefaultDelay(long, TimeUnit)
"""
return schedule(Executors.callable(task, result), getDefaultDelayForTask(), TimeUnit.MILLISECONDS);
} | java | @Override
public <T> Future<T> submit(Runnable task, T result) {
return schedule(Executors.callable(task, result), getDefaultDelayForTask(), TimeUnit.MILLISECONDS);
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"Future",
"<",
"T",
">",
"submit",
"(",
"Runnable",
"task",
",",
"T",
"result",
")",
"{",
"return",
"schedule",
"(",
"Executors",
".",
"callable",
"(",
"task",
",",
"result",
")",
",",
"getDefaultDelayForTask",
"(",
")",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}"
] | {@inheritDoc}
<p>
Overridden to schedule with default delay, when non zero.
@throws RejectedExecutionException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
@see #setIncrementalDefaultDelay(boolean)
@see #schedule(Runnable, long, TimeUnit)
@see #setDefaultDelay(long, TimeUnit) | [
"{",
"@inheritDoc",
"}",
"<p",
">",
"Overridden",
"to",
"schedule",
"with",
"default",
"delay",
"when",
"non",
"zero",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/utils/PausableScheduledThreadPoolExecutor.java#L252-L255 |
tvesalainen/util | util/src/main/java/org/vesalainen/bean/BeanHelper.java | BeanHelper.defaultFactory | public static final <T> T defaultFactory(Class<T> cls, String hint) {
"""
Default object factory that calls newInstance method. Checked exceptions
are wrapped in IllegalArgumentException.
@param <T>
@param cls Target class
@param hint Hint for factory
@return
"""
try
{
return cls.newInstance();
}
catch (InstantiationException | IllegalAccessException ex)
{
throw new IllegalArgumentException(ex);
}
} | java | public static final <T> T defaultFactory(Class<T> cls, String hint)
{
try
{
return cls.newInstance();
}
catch (InstantiationException | IllegalAccessException ex)
{
throw new IllegalArgumentException(ex);
}
} | [
"public",
"static",
"final",
"<",
"T",
">",
"T",
"defaultFactory",
"(",
"Class",
"<",
"T",
">",
"cls",
",",
"String",
"hint",
")",
"{",
"try",
"{",
"return",
"cls",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"|",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"ex",
")",
";",
"}",
"}"
] | Default object factory that calls newInstance method. Checked exceptions
are wrapped in IllegalArgumentException.
@param <T>
@param cls Target class
@param hint Hint for factory
@return | [
"Default",
"object",
"factory",
"that",
"calls",
"newInstance",
"method",
".",
"Checked",
"exceptions",
"are",
"wrapped",
"in",
"IllegalArgumentException",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/bean/BeanHelper.java#L416-L426 |
ops4j/org.ops4j.pax.web | pax-web-extender-war/src/main/java/org/ops4j/pax/web/extender/war/internal/RegisterWebAppVisitorHS.java | RegisterWebAppVisitorHS.newInstance | public static <T> T newInstance(final Class<T> clazz,
final ClassLoader classLoader, final String className)
throws ClassNotFoundException, IllegalAccessException,
InstantiationException {
"""
Creates an instance of a class from class name.
@param clazz class of the required object
@param classLoader class loader to use to load the class
@param className class name for the object to create
@return created object
@throws NullArgumentException if any of the parameters is null
@throws ClassNotFoundException re-thrown
@throws IllegalAccessException re-thrown
@throws InstantiationException re-thrown
"""
return loadClass(clazz, classLoader, className).newInstance();
} | java | public static <T> T newInstance(final Class<T> clazz,
final ClassLoader classLoader, final String className)
throws ClassNotFoundException, IllegalAccessException,
InstantiationException {
return loadClass(clazz, classLoader, className).newInstance();
} | [
"public",
"static",
"<",
"T",
">",
"T",
"newInstance",
"(",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"ClassLoader",
"classLoader",
",",
"final",
"String",
"className",
")",
"throws",
"ClassNotFoundException",
",",
"IllegalAccessException",
",",
"InstantiationException",
"{",
"return",
"loadClass",
"(",
"clazz",
",",
"classLoader",
",",
"className",
")",
".",
"newInstance",
"(",
")",
";",
"}"
] | Creates an instance of a class from class name.
@param clazz class of the required object
@param classLoader class loader to use to load the class
@param className class name for the object to create
@return created object
@throws NullArgumentException if any of the parameters is null
@throws ClassNotFoundException re-thrown
@throws IllegalAccessException re-thrown
@throws InstantiationException re-thrown | [
"Creates",
"an",
"instance",
"of",
"a",
"class",
"from",
"class",
"name",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.web/blob/9ecf3676c1d316be0d43ea7fcfdc8f0defffc2a2/pax-web-extender-war/src/main/java/org/ops4j/pax/web/extender/war/internal/RegisterWebAppVisitorHS.java#L201-L206 |
tcurdt/jdeb | src/main/java/org/vafer/jdeb/signing/PGPSigner.java | PGPSigner.clearSign | public void clearSign(InputStream input, OutputStream output) throws IOException, PGPException, GeneralSecurityException {
"""
Creates a clear sign signature over the input data. (Not detached)
@param input the content to be signed
@param output the output destination of the signature
"""
PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(new BcPGPContentSignerBuilder(privateKey.getPublicKeyPacket().getAlgorithm(), digest));
signatureGenerator.init(PGPSignature.CANONICAL_TEXT_DOCUMENT, privateKey);
ArmoredOutputStream armoredOutput = new ArmoredOutputStream(output);
armoredOutput.beginClearText(digest);
LineIterator iterator = new LineIterator(new InputStreamReader(input));
while (iterator.hasNext()) {
String line = iterator.nextLine();
// trailing spaces must be removed for signature calculation (see http://tools.ietf.org/html/rfc4880#section-7.1)
byte[] data = trim(line).getBytes("UTF-8");
armoredOutput.write(data);
armoredOutput.write(EOL);
signatureGenerator.update(data);
if (iterator.hasNext()) {
signatureGenerator.update(EOL);
}
}
armoredOutput.endClearText();
PGPSignature signature = signatureGenerator.generate();
signature.encode(new BCPGOutputStream(armoredOutput));
armoredOutput.close();
} | java | public void clearSign(InputStream input, OutputStream output) throws IOException, PGPException, GeneralSecurityException {
PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(new BcPGPContentSignerBuilder(privateKey.getPublicKeyPacket().getAlgorithm(), digest));
signatureGenerator.init(PGPSignature.CANONICAL_TEXT_DOCUMENT, privateKey);
ArmoredOutputStream armoredOutput = new ArmoredOutputStream(output);
armoredOutput.beginClearText(digest);
LineIterator iterator = new LineIterator(new InputStreamReader(input));
while (iterator.hasNext()) {
String line = iterator.nextLine();
// trailing spaces must be removed for signature calculation (see http://tools.ietf.org/html/rfc4880#section-7.1)
byte[] data = trim(line).getBytes("UTF-8");
armoredOutput.write(data);
armoredOutput.write(EOL);
signatureGenerator.update(data);
if (iterator.hasNext()) {
signatureGenerator.update(EOL);
}
}
armoredOutput.endClearText();
PGPSignature signature = signatureGenerator.generate();
signature.encode(new BCPGOutputStream(armoredOutput));
armoredOutput.close();
} | [
"public",
"void",
"clearSign",
"(",
"InputStream",
"input",
",",
"OutputStream",
"output",
")",
"throws",
"IOException",
",",
"PGPException",
",",
"GeneralSecurityException",
"{",
"PGPSignatureGenerator",
"signatureGenerator",
"=",
"new",
"PGPSignatureGenerator",
"(",
"new",
"BcPGPContentSignerBuilder",
"(",
"privateKey",
".",
"getPublicKeyPacket",
"(",
")",
".",
"getAlgorithm",
"(",
")",
",",
"digest",
")",
")",
";",
"signatureGenerator",
".",
"init",
"(",
"PGPSignature",
".",
"CANONICAL_TEXT_DOCUMENT",
",",
"privateKey",
")",
";",
"ArmoredOutputStream",
"armoredOutput",
"=",
"new",
"ArmoredOutputStream",
"(",
"output",
")",
";",
"armoredOutput",
".",
"beginClearText",
"(",
"digest",
")",
";",
"LineIterator",
"iterator",
"=",
"new",
"LineIterator",
"(",
"new",
"InputStreamReader",
"(",
"input",
")",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"line",
"=",
"iterator",
".",
"nextLine",
"(",
")",
";",
"// trailing spaces must be removed for signature calculation (see http://tools.ietf.org/html/rfc4880#section-7.1)",
"byte",
"[",
"]",
"data",
"=",
"trim",
"(",
"line",
")",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
";",
"armoredOutput",
".",
"write",
"(",
"data",
")",
";",
"armoredOutput",
".",
"write",
"(",
"EOL",
")",
";",
"signatureGenerator",
".",
"update",
"(",
"data",
")",
";",
"if",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"signatureGenerator",
".",
"update",
"(",
"EOL",
")",
";",
"}",
"}",
"armoredOutput",
".",
"endClearText",
"(",
")",
";",
"PGPSignature",
"signature",
"=",
"signatureGenerator",
".",
"generate",
"(",
")",
";",
"signature",
".",
"encode",
"(",
"new",
"BCPGOutputStream",
"(",
"armoredOutput",
")",
")",
";",
"armoredOutput",
".",
"close",
"(",
")",
";",
"}"
] | Creates a clear sign signature over the input data. (Not detached)
@param input the content to be signed
@param output the output destination of the signature | [
"Creates",
"a",
"clear",
"sign",
"signature",
"over",
"the",
"input",
"data",
".",
"(",
"Not",
"detached",
")"
] | train | https://github.com/tcurdt/jdeb/blob/b899a7b1b3391356aafc491ab601f258961f67f0/src/main/java/org/vafer/jdeb/signing/PGPSigner.java#L81-L112 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServiceObjectivesInner.java | ServiceObjectivesInner.getAsync | public Observable<ServiceObjectiveInner> getAsync(String resourceGroupName, String serverName, String serviceObjectiveName) {
"""
Gets a database service objective.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param serviceObjectiveName The name of the service objective to retrieve.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServiceObjectiveInner object
"""
return getWithServiceResponseAsync(resourceGroupName, serverName, serviceObjectiveName).map(new Func1<ServiceResponse<ServiceObjectiveInner>, ServiceObjectiveInner>() {
@Override
public ServiceObjectiveInner call(ServiceResponse<ServiceObjectiveInner> response) {
return response.body();
}
});
} | java | public Observable<ServiceObjectiveInner> getAsync(String resourceGroupName, String serverName, String serviceObjectiveName) {
return getWithServiceResponseAsync(resourceGroupName, serverName, serviceObjectiveName).map(new Func1<ServiceResponse<ServiceObjectiveInner>, ServiceObjectiveInner>() {
@Override
public ServiceObjectiveInner call(ServiceResponse<ServiceObjectiveInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ServiceObjectiveInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"serviceObjectiveName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"serviceObjectiveName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ServiceObjectiveInner",
">",
",",
"ServiceObjectiveInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ServiceObjectiveInner",
"call",
"(",
"ServiceResponse",
"<",
"ServiceObjectiveInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets a database service objective.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param serviceObjectiveName The name of the service objective to retrieve.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServiceObjectiveInner object | [
"Gets",
"a",
"database",
"service",
"objective",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServiceObjectivesInner.java#L103-L110 |
VoltDB/voltdb | src/frontend/org/voltdb/compiler/StatementCompiler.java | StatementCompiler.addFunctionDependence | private static void addFunctionDependence(Function function, Procedure procedure, Statement catalogStmt) {
"""
Add a dependence to a function of a statement. The function's
dependence string is altered with this function.
@param function The function to add as dependee.
@param procedure The procedure of the statement.
@param catalogStmt The statement to add as depender.
"""
String funcDeps = function.getStmtdependers();
Set<String> stmtSet = new TreeSet<>();
for (String stmtName : funcDeps.split(",")) {
if (! stmtName.isEmpty()) {
stmtSet.add(stmtName);
}
}
String statementName = procedure.getTypeName() + ":" + catalogStmt.getTypeName();
if (stmtSet.contains(statementName)) {
return;
}
stmtSet.add(statementName);
StringBuilder sb = new StringBuilder();
// We will add this procedure:statement pair. So make sure we have
// an initial comma. Note that an empty set must be represented
// by an empty string. We represent the set {pp:ss, qq:tt},
// where "pp" and "qq" are procedures and "ss" and "tt" are
// statements in their procedures respectively, with
// the string ",pp:ss,qq:tt,". If we search for "pp:ss" we will
// never find "ppp:sss" by accident.
//
// Do to this, when we add something to string we start with a single
// comma, and then add "qq:tt," at the end.
sb.append(",");
for (String stmtName : stmtSet) {
sb.append(stmtName + ",");
}
function.setStmtdependers(sb.toString());
} | java | private static void addFunctionDependence(Function function, Procedure procedure, Statement catalogStmt) {
String funcDeps = function.getStmtdependers();
Set<String> stmtSet = new TreeSet<>();
for (String stmtName : funcDeps.split(",")) {
if (! stmtName.isEmpty()) {
stmtSet.add(stmtName);
}
}
String statementName = procedure.getTypeName() + ":" + catalogStmt.getTypeName();
if (stmtSet.contains(statementName)) {
return;
}
stmtSet.add(statementName);
StringBuilder sb = new StringBuilder();
// We will add this procedure:statement pair. So make sure we have
// an initial comma. Note that an empty set must be represented
// by an empty string. We represent the set {pp:ss, qq:tt},
// where "pp" and "qq" are procedures and "ss" and "tt" are
// statements in their procedures respectively, with
// the string ",pp:ss,qq:tt,". If we search for "pp:ss" we will
// never find "ppp:sss" by accident.
//
// Do to this, when we add something to string we start with a single
// comma, and then add "qq:tt," at the end.
sb.append(",");
for (String stmtName : stmtSet) {
sb.append(stmtName + ",");
}
function.setStmtdependers(sb.toString());
} | [
"private",
"static",
"void",
"addFunctionDependence",
"(",
"Function",
"function",
",",
"Procedure",
"procedure",
",",
"Statement",
"catalogStmt",
")",
"{",
"String",
"funcDeps",
"=",
"function",
".",
"getStmtdependers",
"(",
")",
";",
"Set",
"<",
"String",
">",
"stmtSet",
"=",
"new",
"TreeSet",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"stmtName",
":",
"funcDeps",
".",
"split",
"(",
"\",\"",
")",
")",
"{",
"if",
"(",
"!",
"stmtName",
".",
"isEmpty",
"(",
")",
")",
"{",
"stmtSet",
".",
"add",
"(",
"stmtName",
")",
";",
"}",
"}",
"String",
"statementName",
"=",
"procedure",
".",
"getTypeName",
"(",
")",
"+",
"\":\"",
"+",
"catalogStmt",
".",
"getTypeName",
"(",
")",
";",
"if",
"(",
"stmtSet",
".",
"contains",
"(",
"statementName",
")",
")",
"{",
"return",
";",
"}",
"stmtSet",
".",
"add",
"(",
"statementName",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"// We will add this procedure:statement pair. So make sure we have",
"// an initial comma. Note that an empty set must be represented",
"// by an empty string. We represent the set {pp:ss, qq:tt},",
"// where \"pp\" and \"qq\" are procedures and \"ss\" and \"tt\" are",
"// statements in their procedures respectively, with",
"// the string \",pp:ss,qq:tt,\". If we search for \"pp:ss\" we will",
"// never find \"ppp:sss\" by accident.",
"//",
"// Do to this, when we add something to string we start with a single",
"// comma, and then add \"qq:tt,\" at the end.",
"sb",
".",
"append",
"(",
"\",\"",
")",
";",
"for",
"(",
"String",
"stmtName",
":",
"stmtSet",
")",
"{",
"sb",
".",
"append",
"(",
"stmtName",
"+",
"\",\"",
")",
";",
"}",
"function",
".",
"setStmtdependers",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Add a dependence to a function of a statement. The function's
dependence string is altered with this function.
@param function The function to add as dependee.
@param procedure The procedure of the statement.
@param catalogStmt The statement to add as depender. | [
"Add",
"a",
"dependence",
"to",
"a",
"function",
"of",
"a",
"statement",
".",
"The",
"function",
"s",
"dependence",
"string",
"is",
"altered",
"with",
"this",
"function",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/StatementCompiler.java#L386-L418 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/thrift/ThriftClientFactory.java | ThriftClientFactory.getConnection | Connection getConnection(ConnectionPool pool) {
"""
Gets the connection.
@param pool the pool
@return the connection
"""
ConnectionPool connectionPool = pool;
boolean success = false;
while (!success)
{
try
{
success = true;
Cassandra.Client client = connectionPool.getConnection();
if (logger.isDebugEnabled())
{
logger.debug("Returning connection of {} :{} .", pool.getPoolProperties().getHost(), pool
.getPoolProperties().getPort());
}
return new Connection(client, connectionPool);
}
catch (TException te)
{
success = false;
logger.warn("{} :{} host appears to be down, trying for next ", pool.getPoolProperties().getHost(),
pool.getPoolProperties().getPort());
connectionPool = getNewPool(pool.getPoolProperties().getHost(), pool.getPoolProperties().getPort());
}
}
throw new KunderaException("All hosts are down. please check servers manully.");
} | java | Connection getConnection(ConnectionPool pool)
{
ConnectionPool connectionPool = pool;
boolean success = false;
while (!success)
{
try
{
success = true;
Cassandra.Client client = connectionPool.getConnection();
if (logger.isDebugEnabled())
{
logger.debug("Returning connection of {} :{} .", pool.getPoolProperties().getHost(), pool
.getPoolProperties().getPort());
}
return new Connection(client, connectionPool);
}
catch (TException te)
{
success = false;
logger.warn("{} :{} host appears to be down, trying for next ", pool.getPoolProperties().getHost(),
pool.getPoolProperties().getPort());
connectionPool = getNewPool(pool.getPoolProperties().getHost(), pool.getPoolProperties().getPort());
}
}
throw new KunderaException("All hosts are down. please check servers manully.");
} | [
"Connection",
"getConnection",
"(",
"ConnectionPool",
"pool",
")",
"{",
"ConnectionPool",
"connectionPool",
"=",
"pool",
";",
"boolean",
"success",
"=",
"false",
";",
"while",
"(",
"!",
"success",
")",
"{",
"try",
"{",
"success",
"=",
"true",
";",
"Cassandra",
".",
"Client",
"client",
"=",
"connectionPool",
".",
"getConnection",
"(",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Returning connection of {} :{} .\"",
",",
"pool",
".",
"getPoolProperties",
"(",
")",
".",
"getHost",
"(",
")",
",",
"pool",
".",
"getPoolProperties",
"(",
")",
".",
"getPort",
"(",
")",
")",
";",
"}",
"return",
"new",
"Connection",
"(",
"client",
",",
"connectionPool",
")",
";",
"}",
"catch",
"(",
"TException",
"te",
")",
"{",
"success",
"=",
"false",
";",
"logger",
".",
"warn",
"(",
"\"{} :{} host appears to be down, trying for next \"",
",",
"pool",
".",
"getPoolProperties",
"(",
")",
".",
"getHost",
"(",
")",
",",
"pool",
".",
"getPoolProperties",
"(",
")",
".",
"getPort",
"(",
")",
")",
";",
"connectionPool",
"=",
"getNewPool",
"(",
"pool",
".",
"getPoolProperties",
"(",
")",
".",
"getHost",
"(",
")",
",",
"pool",
".",
"getPoolProperties",
"(",
")",
".",
"getPort",
"(",
")",
")",
";",
"}",
"}",
"throw",
"new",
"KunderaException",
"(",
"\"All hosts are down. please check servers manully.\"",
")",
";",
"}"
] | Gets the connection.
@param pool the pool
@return the connection | [
"Gets",
"the",
"connection",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/thrift/ThriftClientFactory.java#L278-L307 |
m9aertner/PBKDF2 | src/main/java/de/rtner/security/auth/spi/PBKDF2Engine.java | PBKDF2Engine.INT | protected void INT(byte[] dest, int offset, int i) {
"""
Four-octet encoding of the integer i, most significant octet first.
@see <a href="http://tools.ietf.org/html/rfc2898">RFC 2898 5.2 Step 3.</a>
@param dest destination byte buffer
@param offset zero-based offset into dest
@param i the integer to encode
"""
dest[offset + 0] = (byte) (i / (256 * 256 * 256));
dest[offset + 1] = (byte) (i / (256 * 256));
dest[offset + 2] = (byte) (i / (256));
dest[offset + 3] = (byte) (i);
} | java | protected void INT(byte[] dest, int offset, int i)
{
dest[offset + 0] = (byte) (i / (256 * 256 * 256));
dest[offset + 1] = (byte) (i / (256 * 256));
dest[offset + 2] = (byte) (i / (256));
dest[offset + 3] = (byte) (i);
} | [
"protected",
"void",
"INT",
"(",
"byte",
"[",
"]",
"dest",
",",
"int",
"offset",
",",
"int",
"i",
")",
"{",
"dest",
"[",
"offset",
"+",
"0",
"]",
"=",
"(",
"byte",
")",
"(",
"i",
"/",
"(",
"256",
"*",
"256",
"*",
"256",
")",
")",
";",
"dest",
"[",
"offset",
"+",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"i",
"/",
"(",
"256",
"*",
"256",
")",
")",
";",
"dest",
"[",
"offset",
"+",
"2",
"]",
"=",
"(",
"byte",
")",
"(",
"i",
"/",
"(",
"256",
")",
")",
";",
"dest",
"[",
"offset",
"+",
"3",
"]",
"=",
"(",
"byte",
")",
"(",
"i",
")",
";",
"}"
] | Four-octet encoding of the integer i, most significant octet first.
@see <a href="http://tools.ietf.org/html/rfc2898">RFC 2898 5.2 Step 3.</a>
@param dest destination byte buffer
@param offset zero-based offset into dest
@param i the integer to encode | [
"Four",
"-",
"octet",
"encoding",
"of",
"the",
"integer",
"i",
"most",
"significant",
"octet",
"first",
"."
] | train | https://github.com/m9aertner/PBKDF2/blob/b84511bb78848106c0f778136d9f01870c957722/src/main/java/de/rtner/security/auth/spi/PBKDF2Engine.java#L309-L315 |
OpenLiberty/open-liberty | dev/com.ibm.ws.product.utility/src/com/ibm/ws/product/utility/LicenseUtility.java | LicenseUtility.getLicenseFile | public final File getLicenseFile(File installLicenseDir, String prefix) throws FileNotFoundException {
"""
Gets the license information and agreement from wlp/lafiles directory depending on Locale
@param licenseFile location of directory containing the licenses
@param prefix LA/LI prefix
@return licensefile
@throws FileNotFoundException
"""
if (!!!prefix.endsWith("_")) {
prefix = prefix + "_";
}
Locale locale = Locale.getDefault();
String lang = locale.getLanguage();
String country = locale.getCountry();
String[] suffixes = new String[] { lang + '_' + country, lang, "en" };
File[] listOfFiles = installLicenseDir.listFiles();
File licenseFile = null;
outer: for (File file : listOfFiles) {
for (String suffix : suffixes) {
if (file.getName().startsWith(prefix) && file.getName().endsWith(suffix)) {
licenseFile = new File(file.getAbsolutePath());
break outer;
}
}
}
return licenseFile;
} | java | public final File getLicenseFile(File installLicenseDir, String prefix) throws FileNotFoundException {
if (!!!prefix.endsWith("_")) {
prefix = prefix + "_";
}
Locale locale = Locale.getDefault();
String lang = locale.getLanguage();
String country = locale.getCountry();
String[] suffixes = new String[] { lang + '_' + country, lang, "en" };
File[] listOfFiles = installLicenseDir.listFiles();
File licenseFile = null;
outer: for (File file : listOfFiles) {
for (String suffix : suffixes) {
if (file.getName().startsWith(prefix) && file.getName().endsWith(suffix)) {
licenseFile = new File(file.getAbsolutePath());
break outer;
}
}
}
return licenseFile;
} | [
"public",
"final",
"File",
"getLicenseFile",
"(",
"File",
"installLicenseDir",
",",
"String",
"prefix",
")",
"throws",
"FileNotFoundException",
"{",
"if",
"(",
"!",
"!",
"!",
"prefix",
".",
"endsWith",
"(",
"\"_\"",
")",
")",
"{",
"prefix",
"=",
"prefix",
"+",
"\"_\"",
";",
"}",
"Locale",
"locale",
"=",
"Locale",
".",
"getDefault",
"(",
")",
";",
"String",
"lang",
"=",
"locale",
".",
"getLanguage",
"(",
")",
";",
"String",
"country",
"=",
"locale",
".",
"getCountry",
"(",
")",
";",
"String",
"[",
"]",
"suffixes",
"=",
"new",
"String",
"[",
"]",
"{",
"lang",
"+",
"'",
"'",
"+",
"country",
",",
"lang",
",",
"\"en\"",
"}",
";",
"File",
"[",
"]",
"listOfFiles",
"=",
"installLicenseDir",
".",
"listFiles",
"(",
")",
";",
"File",
"licenseFile",
"=",
"null",
";",
"outer",
":",
"for",
"(",
"File",
"file",
":",
"listOfFiles",
")",
"{",
"for",
"(",
"String",
"suffix",
":",
"suffixes",
")",
"{",
"if",
"(",
"file",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"prefix",
")",
"&&",
"file",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"suffix",
")",
")",
"{",
"licenseFile",
"=",
"new",
"File",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"break",
"outer",
";",
"}",
"}",
"}",
"return",
"licenseFile",
";",
"}"
] | Gets the license information and agreement from wlp/lafiles directory depending on Locale
@param licenseFile location of directory containing the licenses
@param prefix LA/LI prefix
@return licensefile
@throws FileNotFoundException | [
"Gets",
"the",
"license",
"information",
"and",
"agreement",
"from",
"wlp",
"/",
"lafiles",
"directory",
"depending",
"on",
"Locale"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.product.utility/src/com/ibm/ws/product/utility/LicenseUtility.java#L57-L81 |
jbundle/jbundle | base/screen/model/src/main/java/org/jbundle/base/screen/model/report/BaseParserScreen.java | BaseParserScreen.printData | public boolean printData(PrintWriter out, int iPrintOptions) {
"""
Display this screen in html input format.
@return true if default params were found for this form.
@param out The http output stream.
@exception DBException File exception.
"""
if (this.getProperty(DBParams.XML) != null)
return this.getScreenFieldView().printData(out, iPrintOptions);
else
return super.printData(out, iPrintOptions);
} | java | public boolean printData(PrintWriter out, int iPrintOptions)
{
if (this.getProperty(DBParams.XML) != null)
return this.getScreenFieldView().printData(out, iPrintOptions);
else
return super.printData(out, iPrintOptions);
} | [
"public",
"boolean",
"printData",
"(",
"PrintWriter",
"out",
",",
"int",
"iPrintOptions",
")",
"{",
"if",
"(",
"this",
".",
"getProperty",
"(",
"DBParams",
".",
"XML",
")",
"!=",
"null",
")",
"return",
"this",
".",
"getScreenFieldView",
"(",
")",
".",
"printData",
"(",
"out",
",",
"iPrintOptions",
")",
";",
"else",
"return",
"super",
".",
"printData",
"(",
"out",
",",
"iPrintOptions",
")",
";",
"}"
] | Display this screen in html input format.
@return true if default params were found for this form.
@param out The http output stream.
@exception DBException File exception. | [
"Display",
"this",
"screen",
"in",
"html",
"input",
"format",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/BaseParserScreen.java#L131-L137 |
apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/CopySource.java | CopySource.serializeCopyableDataset | public static void serializeCopyableDataset(State state, CopyableDatasetMetadata copyableDataset) {
"""
Serialize a {@link CopyableDataset} into a {@link State} at {@link #SERIALIZED_COPYABLE_DATASET}
"""
state.setProp(SERIALIZED_COPYABLE_DATASET, copyableDataset.serialize());
} | java | public static void serializeCopyableDataset(State state, CopyableDatasetMetadata copyableDataset) {
state.setProp(SERIALIZED_COPYABLE_DATASET, copyableDataset.serialize());
} | [
"public",
"static",
"void",
"serializeCopyableDataset",
"(",
"State",
"state",
",",
"CopyableDatasetMetadata",
"copyableDataset",
")",
"{",
"state",
".",
"setProp",
"(",
"SERIALIZED_COPYABLE_DATASET",
",",
"copyableDataset",
".",
"serialize",
"(",
")",
")",
";",
"}"
] | Serialize a {@link CopyableDataset} into a {@link State} at {@link #SERIALIZED_COPYABLE_DATASET} | [
"Serialize",
"a",
"{"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/CopySource.java#L535-L537 |
netty/netty | codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java | ByteToMessageDecoder.fireChannelRead | static void fireChannelRead(ChannelHandlerContext ctx, List<Object> msgs, int numElements) {
"""
Get {@code numElements} out of the {@link List} and forward these through the pipeline.
"""
if (msgs instanceof CodecOutputList) {
fireChannelRead(ctx, (CodecOutputList) msgs, numElements);
} else {
for (int i = 0; i < numElements; i++) {
ctx.fireChannelRead(msgs.get(i));
}
}
} | java | static void fireChannelRead(ChannelHandlerContext ctx, List<Object> msgs, int numElements) {
if (msgs instanceof CodecOutputList) {
fireChannelRead(ctx, (CodecOutputList) msgs, numElements);
} else {
for (int i = 0; i < numElements; i++) {
ctx.fireChannelRead(msgs.get(i));
}
}
} | [
"static",
"void",
"fireChannelRead",
"(",
"ChannelHandlerContext",
"ctx",
",",
"List",
"<",
"Object",
">",
"msgs",
",",
"int",
"numElements",
")",
"{",
"if",
"(",
"msgs",
"instanceof",
"CodecOutputList",
")",
"{",
"fireChannelRead",
"(",
"ctx",
",",
"(",
"CodecOutputList",
")",
"msgs",
",",
"numElements",
")",
";",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numElements",
";",
"i",
"++",
")",
"{",
"ctx",
".",
"fireChannelRead",
"(",
"msgs",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"}",
"}"
] | Get {@code numElements} out of the {@link List} and forward these through the pipeline. | [
"Get",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java#L308-L316 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/utils/AnnotationProcessorUtilis.java | AnnotationProcessorUtilis.infoOnGeneratedClasses | public static void infoOnGeneratedClasses(Class<? extends Annotation> annotation, String packageName, String className) {
"""
KRIPTON_DEBUG info about generated classes.
@param annotation the annotation
@param packageName the package name
@param className the class name
"""
String msg = String.format("class '%s' in package '%s' is generated by '@%s' annotation processor", className, packageName, annotation.getSimpleName());
printMessage(msg);
} | java | public static void infoOnGeneratedClasses(Class<? extends Annotation> annotation, String packageName, String className) {
String msg = String.format("class '%s' in package '%s' is generated by '@%s' annotation processor", className, packageName, annotation.getSimpleName());
printMessage(msg);
} | [
"public",
"static",
"void",
"infoOnGeneratedClasses",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotation",
",",
"String",
"packageName",
",",
"String",
"className",
")",
"{",
"String",
"msg",
"=",
"String",
".",
"format",
"(",
"\"class '%s' in package '%s' is generated by '@%s' annotation processor\"",
",",
"className",
",",
"packageName",
",",
"annotation",
".",
"getSimpleName",
"(",
")",
")",
";",
"printMessage",
"(",
"msg",
")",
";",
"}"
] | KRIPTON_DEBUG info about generated classes.
@param annotation the annotation
@param packageName the package name
@param className the class name | [
"KRIPTON_DEBUG",
"info",
"about",
"generated",
"classes",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/utils/AnnotationProcessorUtilis.java#L49-L53 |
google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ImmutableChecker.java | ImmutableChecker.matchMemberReference | @Override
public Description matchMemberReference(MemberReferenceTree tree, VisitorState state) {
"""
check instantiations of `@ImmutableTypeParameter`s in method references
"""
return checkInvocation(
tree, ((JCMemberReference) tree).referentType, state, ASTHelpers.getSymbol(tree));
} | java | @Override
public Description matchMemberReference(MemberReferenceTree tree, VisitorState state) {
return checkInvocation(
tree, ((JCMemberReference) tree).referentType, state, ASTHelpers.getSymbol(tree));
} | [
"@",
"Override",
"public",
"Description",
"matchMemberReference",
"(",
"MemberReferenceTree",
"tree",
",",
"VisitorState",
"state",
")",
"{",
"return",
"checkInvocation",
"(",
"tree",
",",
"(",
"(",
"JCMemberReference",
")",
"tree",
")",
".",
"referentType",
",",
"state",
",",
"ASTHelpers",
".",
"getSymbol",
"(",
"tree",
")",
")",
";",
"}"
] | check instantiations of `@ImmutableTypeParameter`s in method references | [
"check",
"instantiations",
"of"
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ImmutableChecker.java#L98-L102 |
aws/aws-sdk-java | aws-java-sdk-core/src/main/java/com/amazonaws/util/URLEncodedUtils.java | URLEncodedUtils.format | public static String format(
final Iterable<? extends NameValuePair> parameters,
final Charset charset) {
"""
Returns a String that is suitable for use as an {@code application/x-www-form-urlencoded}
list of parameters in an HTTP PUT or HTTP POST.
@param parameters The parameters to include.
@param charset The encoding to use.
@return An {@code application/x-www-form-urlencoded} string
@since 4.2
"""
return format(parameters, QP_SEP_A, charset);
} | java | public static String format(
final Iterable<? extends NameValuePair> parameters,
final Charset charset) {
return format(parameters, QP_SEP_A, charset);
} | [
"public",
"static",
"String",
"format",
"(",
"final",
"Iterable",
"<",
"?",
"extends",
"NameValuePair",
">",
"parameters",
",",
"final",
"Charset",
"charset",
")",
"{",
"return",
"format",
"(",
"parameters",
",",
"QP_SEP_A",
",",
"charset",
")",
";",
"}"
] | Returns a String that is suitable for use as an {@code application/x-www-form-urlencoded}
list of parameters in an HTTP PUT or HTTP POST.
@param parameters The parameters to include.
@param charset The encoding to use.
@return An {@code application/x-www-form-urlencoded} string
@since 4.2 | [
"Returns",
"a",
"String",
"that",
"is",
"suitable",
"for",
"use",
"as",
"an",
"{",
"@code",
"application",
"/",
"x",
"-",
"www",
"-",
"form",
"-",
"urlencoded",
"}",
"list",
"of",
"parameters",
"in",
"an",
"HTTP",
"PUT",
"or",
"HTTP",
"POST",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-core/src/main/java/com/amazonaws/util/URLEncodedUtils.java#L103-L107 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java | ArrayUtil.haveEqualSets | public static boolean haveEqualSets(int[] arra, int[] arrb, int count) {
"""
Returns true if the first count elements of arra and arrb are identical
sets of integers (not necessarily in the same order).
"""
if (ArrayUtil.haveEqualArrays(arra, arrb, count)) {
return true;
}
if (count > arra.length || count > arrb.length) {
return false;
}
if (count == 1) {
return arra[0] == arrb[0];
}
int[] tempa = (int[]) resizeArray(arra, count);
int[] tempb = (int[]) resizeArray(arrb, count);
sortArray(tempa);
sortArray(tempb);
for (int j = 0; j < count; j++) {
if (tempa[j] != tempb[j]) {
return false;
}
}
return true;
} | java | public static boolean haveEqualSets(int[] arra, int[] arrb, int count) {
if (ArrayUtil.haveEqualArrays(arra, arrb, count)) {
return true;
}
if (count > arra.length || count > arrb.length) {
return false;
}
if (count == 1) {
return arra[0] == arrb[0];
}
int[] tempa = (int[]) resizeArray(arra, count);
int[] tempb = (int[]) resizeArray(arrb, count);
sortArray(tempa);
sortArray(tempb);
for (int j = 0; j < count; j++) {
if (tempa[j] != tempb[j]) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"haveEqualSets",
"(",
"int",
"[",
"]",
"arra",
",",
"int",
"[",
"]",
"arrb",
",",
"int",
"count",
")",
"{",
"if",
"(",
"ArrayUtil",
".",
"haveEqualArrays",
"(",
"arra",
",",
"arrb",
",",
"count",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"count",
">",
"arra",
".",
"length",
"||",
"count",
">",
"arrb",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"count",
"==",
"1",
")",
"{",
"return",
"arra",
"[",
"0",
"]",
"==",
"arrb",
"[",
"0",
"]",
";",
"}",
"int",
"[",
"]",
"tempa",
"=",
"(",
"int",
"[",
"]",
")",
"resizeArray",
"(",
"arra",
",",
"count",
")",
";",
"int",
"[",
"]",
"tempb",
"=",
"(",
"int",
"[",
"]",
")",
"resizeArray",
"(",
"arrb",
",",
"count",
")",
";",
"sortArray",
"(",
"tempa",
")",
";",
"sortArray",
"(",
"tempb",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"count",
";",
"j",
"++",
")",
"{",
"if",
"(",
"tempa",
"[",
"j",
"]",
"!=",
"tempb",
"[",
"j",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Returns true if the first count elements of arra and arrb are identical
sets of integers (not necessarily in the same order). | [
"Returns",
"true",
"if",
"the",
"first",
"count",
"elements",
"of",
"arra",
"and",
"arrb",
"are",
"identical",
"sets",
"of",
"integers",
"(",
"not",
"necessarily",
"in",
"the",
"same",
"order",
")",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L343-L370 |
wcm-io/wcm-io-tooling | commons/crx-packmgr-helper/src/main/java/io/wcm/tooling/commons/packmgr/PackageManagerHelper.java | PackageManagerHelper.executePackageManagerMethodHtml | public String executePackageManagerMethodHtml(CloseableHttpClient httpClient, HttpRequestBase method) {
"""
Execute CRX HTTP Package manager method and get HTML response.
@param httpClient Http client
@param method Get or Post method
@return Response from HTML server
"""
PackageManagerHtmlCall call = new PackageManagerHtmlCall(httpClient, method, log);
String message = executeHttpCallWithRetry(call, 0);
return message;
} | java | public String executePackageManagerMethodHtml(CloseableHttpClient httpClient, HttpRequestBase method) {
PackageManagerHtmlCall call = new PackageManagerHtmlCall(httpClient, method, log);
String message = executeHttpCallWithRetry(call, 0);
return message;
} | [
"public",
"String",
"executePackageManagerMethodHtml",
"(",
"CloseableHttpClient",
"httpClient",
",",
"HttpRequestBase",
"method",
")",
"{",
"PackageManagerHtmlCall",
"call",
"=",
"new",
"PackageManagerHtmlCall",
"(",
"httpClient",
",",
"method",
",",
"log",
")",
";",
"String",
"message",
"=",
"executeHttpCallWithRetry",
"(",
"call",
",",
"0",
")",
";",
"return",
"message",
";",
"}"
] | Execute CRX HTTP Package manager method and get HTML response.
@param httpClient Http client
@param method Get or Post method
@return Response from HTML server | [
"Execute",
"CRX",
"HTTP",
"Package",
"manager",
"method",
"and",
"get",
"HTML",
"response",
"."
] | train | https://github.com/wcm-io/wcm-io-tooling/blob/1abcd01dd3ad4cc248f03b431f929573d84fa9b4/commons/crx-packmgr-helper/src/main/java/io/wcm/tooling/commons/packmgr/PackageManagerHelper.java#L242-L246 |
haifengl/smile | core/src/main/java/smile/clustering/BBDTree.java | BBDTree.clustering | public double clustering(double[][] centroids, double[][] sums, int[] counts, int[] membership) {
"""
Given k cluster centroids, this method assigns data to nearest centroids.
The return value is the distortion to the centroids. The parameter sums
will hold the sum of data for each cluster. The parameter counts hold
the number of data of each cluster. If membership is
not null, it should be an array of size n that will be filled with the
index of the cluster [0 - k) that each data point is assigned to.
"""
int k = centroids.length;
Arrays.fill(counts, 0);
int[] candidates = new int[k];
for (int i = 0; i < k; i++) {
candidates[i] = i;
Arrays.fill(sums[i], 0.0);
}
return filter(root, centroids, candidates, k, sums, counts, membership);
} | java | public double clustering(double[][] centroids, double[][] sums, int[] counts, int[] membership) {
int k = centroids.length;
Arrays.fill(counts, 0);
int[] candidates = new int[k];
for (int i = 0; i < k; i++) {
candidates[i] = i;
Arrays.fill(sums[i], 0.0);
}
return filter(root, centroids, candidates, k, sums, counts, membership);
} | [
"public",
"double",
"clustering",
"(",
"double",
"[",
"]",
"[",
"]",
"centroids",
",",
"double",
"[",
"]",
"[",
"]",
"sums",
",",
"int",
"[",
"]",
"counts",
",",
"int",
"[",
"]",
"membership",
")",
"{",
"int",
"k",
"=",
"centroids",
".",
"length",
";",
"Arrays",
".",
"fill",
"(",
"counts",
",",
"0",
")",
";",
"int",
"[",
"]",
"candidates",
"=",
"new",
"int",
"[",
"k",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"k",
";",
"i",
"++",
")",
"{",
"candidates",
"[",
"i",
"]",
"=",
"i",
";",
"Arrays",
".",
"fill",
"(",
"sums",
"[",
"i",
"]",
",",
"0.0",
")",
";",
"}",
"return",
"filter",
"(",
"root",
",",
"centroids",
",",
"candidates",
",",
"k",
",",
"sums",
",",
"counts",
",",
"membership",
")",
";",
"}"
] | Given k cluster centroids, this method assigns data to nearest centroids.
The return value is the distortion to the centroids. The parameter sums
will hold the sum of data for each cluster. The parameter counts hold
the number of data of each cluster. If membership is
not null, it should be an array of size n that will be filled with the
index of the cluster [0 - k) that each data point is assigned to. | [
"Given",
"k",
"cluster",
"centroids",
"this",
"method",
"assigns",
"data",
"to",
"nearest",
"centroids",
".",
"The",
"return",
"value",
"is",
"the",
"distortion",
"to",
"the",
"centroids",
".",
"The",
"parameter",
"sums",
"will",
"hold",
"the",
"sum",
"of",
"data",
"for",
"each",
"cluster",
".",
"The",
"parameter",
"counts",
"hold",
"the",
"number",
"of",
"data",
"of",
"each",
"cluster",
".",
"If",
"membership",
"is",
"not",
"null",
"it",
"should",
"be",
"an",
"array",
"of",
"size",
"n",
"that",
"will",
"be",
"filled",
"with",
"the",
"index",
"of",
"the",
"cluster",
"[",
"0",
"-",
"k",
")",
"that",
"each",
"data",
"point",
"is",
"assigned",
"to",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/clustering/BBDTree.java#L259-L270 |
ginere/ginere-base | src/main/java/eu/ginere/base/util/i18n/I18NConnector.java | I18NConnector.getLabel | public static String getLabel(Class<?> clazz, String label) {
"""
Returns the value for this label ussing the getThreadLocaleLanguage
@param section
@param idInSection
@return
"""
Language language=getThreadLocalLanguage(null);
if (language==null){
return label;
} else {
return getLabel(language, clazz.getName(), label);
}
} | java | public static String getLabel(Class<?> clazz, String label) {
Language language=getThreadLocalLanguage(null);
if (language==null){
return label;
} else {
return getLabel(language, clazz.getName(), label);
}
} | [
"public",
"static",
"String",
"getLabel",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"label",
")",
"{",
"Language",
"language",
"=",
"getThreadLocalLanguage",
"(",
"null",
")",
";",
"if",
"(",
"language",
"==",
"null",
")",
"{",
"return",
"label",
";",
"}",
"else",
"{",
"return",
"getLabel",
"(",
"language",
",",
"clazz",
".",
"getName",
"(",
")",
",",
"label",
")",
";",
"}",
"}"
] | Returns the value for this label ussing the getThreadLocaleLanguage
@param section
@param idInSection
@return | [
"Returns",
"the",
"value",
"for",
"this",
"label",
"ussing",
"the",
"getThreadLocaleLanguage"
] | train | https://github.com/ginere/ginere-base/blob/b1cc1c5834bd8a31df475c6f3fc0ee51273c5a24/src/main/java/eu/ginere/base/util/i18n/I18NConnector.java#L102-L110 |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java | Console.changePathInURL | public void changePathInURL(String path, boolean changeHistory) {
"""
Changes node path in the URL displayed by browser.
@param path the path to the node.
@param changeHistory if true store URL changes in browser's history.
"""
jcrURL.setPath(path);
if (changeHistory) {
htmlHistory.newItem(jcrURL.toString(), false);
}
} | java | public void changePathInURL(String path, boolean changeHistory) {
jcrURL.setPath(path);
if (changeHistory) {
htmlHistory.newItem(jcrURL.toString(), false);
}
} | [
"public",
"void",
"changePathInURL",
"(",
"String",
"path",
",",
"boolean",
"changeHistory",
")",
"{",
"jcrURL",
".",
"setPath",
"(",
"path",
")",
";",
"if",
"(",
"changeHistory",
")",
"{",
"htmlHistory",
".",
"newItem",
"(",
"jcrURL",
".",
"toString",
"(",
")",
",",
"false",
")",
";",
"}",
"}"
] | Changes node path in the URL displayed by browser.
@param path the path to the node.
@param changeHistory if true store URL changes in browser's history. | [
"Changes",
"node",
"path",
"in",
"the",
"URL",
"displayed",
"by",
"browser",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java#L276-L281 |
tommyettinger/RegExodus | src/main/java/regexodus/ds/CharArrayList.java | CharArrayList.objectUnwrap | private static <K> int objectUnwrap(final Iterator<? extends K> i, final K array[]) {
"""
Unwraps an iterator into an array starting at a given offset for a given number of elements.
<br>This method iterates over the given type-specific iterator and stores the elements returned, up to a maximum of <code>length</code>, in the given array starting at <code>offset</code>. The
number of actually unwrapped elements is returned (it may be less than <code>max</code> if the iterator emits less than <code>max</code> elements).
@param i a type-specific iterator.
@param array an array to contain the output of the iterator.
@return the number of elements unwrapped.
"""
int j = array.length, offset = 0;
while (j-- != 0 && i.hasNext())
array[offset++] = i.next();
return array.length - j - 1;
} | java | private static <K> int objectUnwrap(final Iterator<? extends K> i, final K array[]) {
int j = array.length, offset = 0;
while (j-- != 0 && i.hasNext())
array[offset++] = i.next();
return array.length - j - 1;
} | [
"private",
"static",
"<",
"K",
">",
"int",
"objectUnwrap",
"(",
"final",
"Iterator",
"<",
"?",
"extends",
"K",
">",
"i",
",",
"final",
"K",
"array",
"[",
"]",
")",
"{",
"int",
"j",
"=",
"array",
".",
"length",
",",
"offset",
"=",
"0",
";",
"while",
"(",
"j",
"--",
"!=",
"0",
"&&",
"i",
".",
"hasNext",
"(",
")",
")",
"array",
"[",
"offset",
"++",
"]",
"=",
"i",
".",
"next",
"(",
")",
";",
"return",
"array",
".",
"length",
"-",
"j",
"-",
"1",
";",
"}"
] | Unwraps an iterator into an array starting at a given offset for a given number of elements.
<br>This method iterates over the given type-specific iterator and stores the elements returned, up to a maximum of <code>length</code>, in the given array starting at <code>offset</code>. The
number of actually unwrapped elements is returned (it may be less than <code>max</code> if the iterator emits less than <code>max</code> elements).
@param i a type-specific iterator.
@param array an array to contain the output of the iterator.
@return the number of elements unwrapped. | [
"Unwraps",
"an",
"iterator",
"into",
"an",
"array",
"starting",
"at",
"a",
"given",
"offset",
"for",
"a",
"given",
"number",
"of",
"elements",
".",
"<br",
">",
"This",
"method",
"iterates",
"over",
"the",
"given",
"type",
"-",
"specific",
"iterator",
"and",
"stores",
"the",
"elements",
"returned",
"up",
"to",
"a",
"maximum",
"of",
"<code",
">",
"length<",
"/",
"code",
">",
"in",
"the",
"given",
"array",
"starting",
"at",
"<code",
">",
"offset<",
"/",
"code",
">",
".",
"The",
"number",
"of",
"actually",
"unwrapped",
"elements",
"is",
"returned",
"(",
"it",
"may",
"be",
"less",
"than",
"<code",
">",
"max<",
"/",
"code",
">",
"if",
"the",
"iterator",
"emits",
"less",
"than",
"<code",
">",
"max<",
"/",
"code",
">",
"elements",
")",
"."
] | train | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/ds/CharArrayList.java#L925-L930 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java | ModuleSummaryBuilder.getInstance | public static ModuleSummaryBuilder getInstance(Context context,
ModuleElement mdle, ModuleSummaryWriter moduleWriter) {
"""
Construct a new ModuleSummaryBuilder.
@param context the build context.
@param mdle the module being documented.
@param moduleWriter the doclet specific writer that will output the
result.
@return an instance of a ModuleSummaryBuilder.
"""
return new ModuleSummaryBuilder(context, mdle, moduleWriter);
} | java | public static ModuleSummaryBuilder getInstance(Context context,
ModuleElement mdle, ModuleSummaryWriter moduleWriter) {
return new ModuleSummaryBuilder(context, mdle, moduleWriter);
} | [
"public",
"static",
"ModuleSummaryBuilder",
"getInstance",
"(",
"Context",
"context",
",",
"ModuleElement",
"mdle",
",",
"ModuleSummaryWriter",
"moduleWriter",
")",
"{",
"return",
"new",
"ModuleSummaryBuilder",
"(",
"context",
",",
"mdle",
",",
"moduleWriter",
")",
";",
"}"
] | Construct a new ModuleSummaryBuilder.
@param context the build context.
@param mdle the module being documented.
@param moduleWriter the doclet specific writer that will output the
result.
@return an instance of a ModuleSummaryBuilder. | [
"Construct",
"a",
"new",
"ModuleSummaryBuilder",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java#L99-L102 |
lucee/Lucee | core/src/main/java/lucee/transformer/cfml/script/AbstrCFMLScriptTransformer.java | AbstrCFMLScriptTransformer.defaultStatement | private final boolean defaultStatement(Data data, Switch swit) throws TemplateException {
"""
Liest ein default Statement ein
@return default Statement
@throws TemplateException
"""
if (!data.srcCode.forwardIfCurrent("default", ':')) return false;
// int line=data.srcCode.getLine();
Body body = new BodyBase(data.factory);
swit.setDefaultCase(body);
switchBlock(data, body);
return true;
} | java | private final boolean defaultStatement(Data data, Switch swit) throws TemplateException {
if (!data.srcCode.forwardIfCurrent("default", ':')) return false;
// int line=data.srcCode.getLine();
Body body = new BodyBase(data.factory);
swit.setDefaultCase(body);
switchBlock(data, body);
return true;
} | [
"private",
"final",
"boolean",
"defaultStatement",
"(",
"Data",
"data",
",",
"Switch",
"swit",
")",
"throws",
"TemplateException",
"{",
"if",
"(",
"!",
"data",
".",
"srcCode",
".",
"forwardIfCurrent",
"(",
"\"default\"",
",",
"'",
"'",
")",
")",
"return",
"false",
";",
"// int line=data.srcCode.getLine();",
"Body",
"body",
"=",
"new",
"BodyBase",
"(",
"data",
".",
"factory",
")",
";",
"swit",
".",
"setDefaultCase",
"(",
"body",
")",
";",
"switchBlock",
"(",
"data",
",",
"body",
")",
";",
"return",
"true",
";",
"}"
] | Liest ein default Statement ein
@return default Statement
@throws TemplateException | [
"Liest",
"ein",
"default",
"Statement",
"ein"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/transformer/cfml/script/AbstrCFMLScriptTransformer.java#L517-L526 |
52inc/android-52Kit | library/src/main/java/com/ftinc/kit/util/MediaUtils.java | MediaUtils.getCameraCaptureIntent | public static Intent getCameraCaptureIntent(Context ctx, String authority) {
"""
Generate the appropriate intent to launch the existing camera application
to capture an image
@see #CAPTURE_PHOTO_REQUEST_CODE
@return the intent necessary to launch the camera to capture a photo
"""
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
try {
// Get the app's local file storage
mCurrentCaptureUri = createAccessibleTempFile(ctx, authority);
grantPermissions(ctx, mCurrentCaptureUri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mCurrentCaptureUri);
} catch (IOException e) {
e.printStackTrace();
}
return intent;
} | java | public static Intent getCameraCaptureIntent(Context ctx, String authority){
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
try {
// Get the app's local file storage
mCurrentCaptureUri = createAccessibleTempFile(ctx, authority);
grantPermissions(ctx, mCurrentCaptureUri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mCurrentCaptureUri);
} catch (IOException e) {
e.printStackTrace();
}
return intent;
} | [
"public",
"static",
"Intent",
"getCameraCaptureIntent",
"(",
"Context",
"ctx",
",",
"String",
"authority",
")",
"{",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"MediaStore",
".",
"ACTION_IMAGE_CAPTURE",
")",
";",
"try",
"{",
"// Get the app's local file storage",
"mCurrentCaptureUri",
"=",
"createAccessibleTempFile",
"(",
"ctx",
",",
"authority",
")",
";",
"grantPermissions",
"(",
"ctx",
",",
"mCurrentCaptureUri",
")",
";",
"intent",
".",
"putExtra",
"(",
"MediaStore",
".",
"EXTRA_OUTPUT",
",",
"mCurrentCaptureUri",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"intent",
";",
"}"
] | Generate the appropriate intent to launch the existing camera application
to capture an image
@see #CAPTURE_PHOTO_REQUEST_CODE
@return the intent necessary to launch the camera to capture a photo | [
"Generate",
"the",
"appropriate",
"intent",
"to",
"launch",
"the",
"existing",
"camera",
"application",
"to",
"capture",
"an",
"image"
] | train | https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/MediaUtils.java#L79-L91 |
spring-projects/spring-boot | spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java | TemplateAvailabilityProviders.getProvider | public TemplateAvailabilityProvider getProvider(String view, Environment environment,
ClassLoader classLoader, ResourceLoader resourceLoader) {
"""
Get the provider that can be used to render the given view.
@param view the view to render
@param environment the environment
@param classLoader the class loader
@param resourceLoader the resource loader
@return a {@link TemplateAvailabilityProvider} or null
"""
Assert.notNull(view, "View must not be null");
Assert.notNull(environment, "Environment must not be null");
Assert.notNull(classLoader, "ClassLoader must not be null");
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
Boolean useCache = environment.getProperty("spring.template.provider.cache",
Boolean.class, true);
if (!useCache) {
return findProvider(view, environment, classLoader, resourceLoader);
}
TemplateAvailabilityProvider provider = this.resolved.get(view);
if (provider == null) {
synchronized (this.cache) {
provider = findProvider(view, environment, classLoader, resourceLoader);
provider = (provider != null) ? provider : NONE;
this.resolved.put(view, provider);
this.cache.put(view, provider);
}
}
return (provider != NONE) ? provider : null;
} | java | public TemplateAvailabilityProvider getProvider(String view, Environment environment,
ClassLoader classLoader, ResourceLoader resourceLoader) {
Assert.notNull(view, "View must not be null");
Assert.notNull(environment, "Environment must not be null");
Assert.notNull(classLoader, "ClassLoader must not be null");
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
Boolean useCache = environment.getProperty("spring.template.provider.cache",
Boolean.class, true);
if (!useCache) {
return findProvider(view, environment, classLoader, resourceLoader);
}
TemplateAvailabilityProvider provider = this.resolved.get(view);
if (provider == null) {
synchronized (this.cache) {
provider = findProvider(view, environment, classLoader, resourceLoader);
provider = (provider != null) ? provider : NONE;
this.resolved.put(view, provider);
this.cache.put(view, provider);
}
}
return (provider != NONE) ? provider : null;
} | [
"public",
"TemplateAvailabilityProvider",
"getProvider",
"(",
"String",
"view",
",",
"Environment",
"environment",
",",
"ClassLoader",
"classLoader",
",",
"ResourceLoader",
"resourceLoader",
")",
"{",
"Assert",
".",
"notNull",
"(",
"view",
",",
"\"View must not be null\"",
")",
";",
"Assert",
".",
"notNull",
"(",
"environment",
",",
"\"Environment must not be null\"",
")",
";",
"Assert",
".",
"notNull",
"(",
"classLoader",
",",
"\"ClassLoader must not be null\"",
")",
";",
"Assert",
".",
"notNull",
"(",
"resourceLoader",
",",
"\"ResourceLoader must not be null\"",
")",
";",
"Boolean",
"useCache",
"=",
"environment",
".",
"getProperty",
"(",
"\"spring.template.provider.cache\"",
",",
"Boolean",
".",
"class",
",",
"true",
")",
";",
"if",
"(",
"!",
"useCache",
")",
"{",
"return",
"findProvider",
"(",
"view",
",",
"environment",
",",
"classLoader",
",",
"resourceLoader",
")",
";",
"}",
"TemplateAvailabilityProvider",
"provider",
"=",
"this",
".",
"resolved",
".",
"get",
"(",
"view",
")",
";",
"if",
"(",
"provider",
"==",
"null",
")",
"{",
"synchronized",
"(",
"this",
".",
"cache",
")",
"{",
"provider",
"=",
"findProvider",
"(",
"view",
",",
"environment",
",",
"classLoader",
",",
"resourceLoader",
")",
";",
"provider",
"=",
"(",
"provider",
"!=",
"null",
")",
"?",
"provider",
":",
"NONE",
";",
"this",
".",
"resolved",
".",
"put",
"(",
"view",
",",
"provider",
")",
";",
"this",
".",
"cache",
".",
"put",
"(",
"view",
",",
"provider",
")",
";",
"}",
"}",
"return",
"(",
"provider",
"!=",
"NONE",
")",
"?",
"provider",
":",
"null",
";",
"}"
] | Get the provider that can be used to render the given view.
@param view the view to render
@param environment the environment
@param classLoader the class loader
@param resourceLoader the resource loader
@return a {@link TemplateAvailabilityProvider} or null | [
"Get",
"the",
"provider",
"that",
"can",
"be",
"used",
"to",
"render",
"the",
"given",
"view",
"."
] | train | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java#L131-L152 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/string/FindingReplacing.java | FindingReplacing.betns | public S betns(String left, String right) {
"""
Sets the substrings in given left tag and right tag as the search string
<B>May multiple substring matched.</B>
@see Betner#between(String, String)
@param leftSameWithRight
@return
"""
return betn(left, right).late();
} | java | public S betns(String left, String right) {
return betn(left, right).late();
} | [
"public",
"S",
"betns",
"(",
"String",
"left",
",",
"String",
"right",
")",
"{",
"return",
"betn",
"(",
"left",
",",
"right",
")",
".",
"late",
"(",
")",
";",
"}"
] | Sets the substrings in given left tag and right tag as the search string
<B>May multiple substring matched.</B>
@see Betner#between(String, String)
@param leftSameWithRight
@return | [
"Sets",
"the",
"substrings",
"in",
"given",
"left",
"tag",
"and",
"right",
"tag",
"as",
"the",
"search",
"string",
"<B",
">",
"May",
"multiple",
"substring",
"matched",
".",
"<",
"/",
"B",
">"
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/string/FindingReplacing.java#L202-L204 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/schemamanager/CassandraDataTranslator.java | CassandraDataTranslator.marshalMap | public static Map marshalMap(List<Class<?>> mapGenericClasses, Class keyClass, Class valueClass, Map rawMap) {
"""
In case, key or value class is of type blob. Iterate and populate
corresponding byte[]
@param mapGenericClasses
the map generic classes
@param keyClass
the key class
@param valueClass
the value class
@param rawMap
the raw map
@return the map
"""
Map dataCollection = new HashMap();
if (keyClass.isAssignableFrom(BytesType.class) || valueClass.isAssignableFrom(BytesType.class))
{
Iterator iter = rawMap.keySet().iterator();
while (iter.hasNext())
{
Object key = iter.next();
Object value = rawMap.get(key);
if (keyClass.isAssignableFrom(BytesType.class))
{
byte[] keyAsBytes = new byte[((ByteBuffer) value).remaining()];
((ByteBuffer) key).get(keyAsBytes);
key = PropertyAccessorHelper.getObject(mapGenericClasses.get(0), keyAsBytes);
}
if (valueClass.isAssignableFrom(BytesType.class))
{
byte[] valueAsBytes = new byte[((ByteBuffer) value).remaining()];
((ByteBuffer) value).get(valueAsBytes);
value = PropertyAccessorHelper.getObject(mapGenericClasses.get(1), valueAsBytes);
}
dataCollection.put(key, value);
}
}
return dataCollection;
} | java | public static Map marshalMap(List<Class<?>> mapGenericClasses, Class keyClass, Class valueClass, Map rawMap)
{
Map dataCollection = new HashMap();
if (keyClass.isAssignableFrom(BytesType.class) || valueClass.isAssignableFrom(BytesType.class))
{
Iterator iter = rawMap.keySet().iterator();
while (iter.hasNext())
{
Object key = iter.next();
Object value = rawMap.get(key);
if (keyClass.isAssignableFrom(BytesType.class))
{
byte[] keyAsBytes = new byte[((ByteBuffer) value).remaining()];
((ByteBuffer) key).get(keyAsBytes);
key = PropertyAccessorHelper.getObject(mapGenericClasses.get(0), keyAsBytes);
}
if (valueClass.isAssignableFrom(BytesType.class))
{
byte[] valueAsBytes = new byte[((ByteBuffer) value).remaining()];
((ByteBuffer) value).get(valueAsBytes);
value = PropertyAccessorHelper.getObject(mapGenericClasses.get(1), valueAsBytes);
}
dataCollection.put(key, value);
}
}
return dataCollection;
} | [
"public",
"static",
"Map",
"marshalMap",
"(",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"mapGenericClasses",
",",
"Class",
"keyClass",
",",
"Class",
"valueClass",
",",
"Map",
"rawMap",
")",
"{",
"Map",
"dataCollection",
"=",
"new",
"HashMap",
"(",
")",
";",
"if",
"(",
"keyClass",
".",
"isAssignableFrom",
"(",
"BytesType",
".",
"class",
")",
"||",
"valueClass",
".",
"isAssignableFrom",
"(",
"BytesType",
".",
"class",
")",
")",
"{",
"Iterator",
"iter",
"=",
"rawMap",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"Object",
"key",
"=",
"iter",
".",
"next",
"(",
")",
";",
"Object",
"value",
"=",
"rawMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"keyClass",
".",
"isAssignableFrom",
"(",
"BytesType",
".",
"class",
")",
")",
"{",
"byte",
"[",
"]",
"keyAsBytes",
"=",
"new",
"byte",
"[",
"(",
"(",
"ByteBuffer",
")",
"value",
")",
".",
"remaining",
"(",
")",
"]",
";",
"(",
"(",
"ByteBuffer",
")",
"key",
")",
".",
"get",
"(",
"keyAsBytes",
")",
";",
"key",
"=",
"PropertyAccessorHelper",
".",
"getObject",
"(",
"mapGenericClasses",
".",
"get",
"(",
"0",
")",
",",
"keyAsBytes",
")",
";",
"}",
"if",
"(",
"valueClass",
".",
"isAssignableFrom",
"(",
"BytesType",
".",
"class",
")",
")",
"{",
"byte",
"[",
"]",
"valueAsBytes",
"=",
"new",
"byte",
"[",
"(",
"(",
"ByteBuffer",
")",
"value",
")",
".",
"remaining",
"(",
")",
"]",
";",
"(",
"(",
"ByteBuffer",
")",
"value",
")",
".",
"get",
"(",
"valueAsBytes",
")",
";",
"value",
"=",
"PropertyAccessorHelper",
".",
"getObject",
"(",
"mapGenericClasses",
".",
"get",
"(",
"1",
")",
",",
"valueAsBytes",
")",
";",
"}",
"dataCollection",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"return",
"dataCollection",
";",
"}"
] | In case, key or value class is of type blob. Iterate and populate
corresponding byte[]
@param mapGenericClasses
the map generic classes
@param keyClass
the key class
@param valueClass
the value class
@param rawMap
the raw map
@return the map | [
"In",
"case",
"key",
"or",
"value",
"class",
"is",
"of",
"type",
"blob",
".",
"Iterate",
"and",
"populate",
"corresponding",
"byte",
"[]"
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/schemamanager/CassandraDataTranslator.java#L560-L592 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/index/IndexAVL.java | IndexAVL.firstRow | @Override
public RowIterator firstRow(Session session, PersistentStore store) {
"""
Returns the row for the first node of the index
@return Iterator for first row
"""
int tempDepth = 0;
readLock.lock();
try {
NodeAVL x = getAccessor(store);
NodeAVL l = x;
while (l != null) {
x = l;
l = x.getLeft(store);
tempDepth++;
}
while (session != null && x != null) {
Row row = x.getRow(store);
if (session.database.txManager.canRead(session, row)) {
break;
}
x = next(store, x);
}
return getIterator(session, store, x);
} finally {
depth = tempDepth;
readLock.unlock();
}
} | java | @Override
public RowIterator firstRow(Session session, PersistentStore store) {
int tempDepth = 0;
readLock.lock();
try {
NodeAVL x = getAccessor(store);
NodeAVL l = x;
while (l != null) {
x = l;
l = x.getLeft(store);
tempDepth++;
}
while (session != null && x != null) {
Row row = x.getRow(store);
if (session.database.txManager.canRead(session, row)) {
break;
}
x = next(store, x);
}
return getIterator(session, store, x);
} finally {
depth = tempDepth;
readLock.unlock();
}
} | [
"@",
"Override",
"public",
"RowIterator",
"firstRow",
"(",
"Session",
"session",
",",
"PersistentStore",
"store",
")",
"{",
"int",
"tempDepth",
"=",
"0",
";",
"readLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"NodeAVL",
"x",
"=",
"getAccessor",
"(",
"store",
")",
";",
"NodeAVL",
"l",
"=",
"x",
";",
"while",
"(",
"l",
"!=",
"null",
")",
"{",
"x",
"=",
"l",
";",
"l",
"=",
"x",
".",
"getLeft",
"(",
"store",
")",
";",
"tempDepth",
"++",
";",
"}",
"while",
"(",
"session",
"!=",
"null",
"&&",
"x",
"!=",
"null",
")",
"{",
"Row",
"row",
"=",
"x",
".",
"getRow",
"(",
"store",
")",
";",
"if",
"(",
"session",
".",
"database",
".",
"txManager",
".",
"canRead",
"(",
"session",
",",
"row",
")",
")",
"{",
"break",
";",
"}",
"x",
"=",
"next",
"(",
"store",
",",
"x",
")",
";",
"}",
"return",
"getIterator",
"(",
"session",
",",
"store",
",",
"x",
")",
";",
"}",
"finally",
"{",
"depth",
"=",
"tempDepth",
";",
"readLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Returns the row for the first node of the index
@return Iterator for first row | [
"Returns",
"the",
"row",
"for",
"the",
"first",
"node",
"of",
"the",
"index"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/index/IndexAVL.java#L1049-L1083 |
glyptodon/guacamole-client | guacamole/src/main/java/org/apache/guacamole/tunnel/InputStreamInterceptingFilter.java | InputStreamInterceptingFilter.sendBlob | private void sendBlob(String index, byte[] blob) {
"""
Injects a "blob" instruction into the outbound Guacamole protocol
stream, as if sent by the connected client. "blob" instructions are used
to send chunks of data along a stream.
@param index
The index of the stream that this "blob" instruction relates to.
@param blob
The chunk of data to send within the "blob" instruction.
"""
// Send "blob" containing provided data
sendInstruction(new GuacamoleInstruction("blob", index,
BaseEncoding.base64().encode(blob)));
} | java | private void sendBlob(String index, byte[] blob) {
// Send "blob" containing provided data
sendInstruction(new GuacamoleInstruction("blob", index,
BaseEncoding.base64().encode(blob)));
} | [
"private",
"void",
"sendBlob",
"(",
"String",
"index",
",",
"byte",
"[",
"]",
"blob",
")",
"{",
"// Send \"blob\" containing provided data",
"sendInstruction",
"(",
"new",
"GuacamoleInstruction",
"(",
"\"blob\"",
",",
"index",
",",
"BaseEncoding",
".",
"base64",
"(",
")",
".",
"encode",
"(",
"blob",
")",
")",
")",
";",
"}"
] | Injects a "blob" instruction into the outbound Guacamole protocol
stream, as if sent by the connected client. "blob" instructions are used
to send chunks of data along a stream.
@param index
The index of the stream that this "blob" instruction relates to.
@param blob
The chunk of data to send within the "blob" instruction. | [
"Injects",
"a",
"blob",
"instruction",
"into",
"the",
"outbound",
"Guacamole",
"protocol",
"stream",
"as",
"if",
"sent",
"by",
"the",
"connected",
"client",
".",
"blob",
"instructions",
"are",
"used",
"to",
"send",
"chunks",
"of",
"data",
"along",
"a",
"stream",
"."
] | train | https://github.com/glyptodon/guacamole-client/blob/ea1b10e9d1e3f1fa640dff2ca64d61b44bf1ace9/guacamole/src/main/java/org/apache/guacamole/tunnel/InputStreamInterceptingFilter.java#L74-L80 |
perwendel/spark | src/main/java/spark/utils/urldecoding/TypeUtil.java | TypeUtil.parseInt | public static int parseInt(String s, int offset, int length, int base)
throws NumberFormatException {
"""
Parse an int from a substring.
Negative numbers are not handled.
@param s String
@param offset Offset within string
@param length Length of integer or -1 for remainder of string
@param base base of the integer
@return the parsed integer
@throws NumberFormatException if the string cannot be parsed
"""
int value = 0;
if (length < 0) {
length = s.length() - offset;
}
for (int i = 0; i < length; i++) {
char c = s.charAt(offset + i);
int digit = convertHexDigit((int) c);
if (digit < 0 || digit >= base) {
throw new NumberFormatException(s.substring(offset, offset + length));
}
value = value * base + digit;
}
return value;
} | java | public static int parseInt(String s, int offset, int length, int base)
throws NumberFormatException {
int value = 0;
if (length < 0) {
length = s.length() - offset;
}
for (int i = 0; i < length; i++) {
char c = s.charAt(offset + i);
int digit = convertHexDigit((int) c);
if (digit < 0 || digit >= base) {
throw new NumberFormatException(s.substring(offset, offset + length));
}
value = value * base + digit;
}
return value;
} | [
"public",
"static",
"int",
"parseInt",
"(",
"String",
"s",
",",
"int",
"offset",
",",
"int",
"length",
",",
"int",
"base",
")",
"throws",
"NumberFormatException",
"{",
"int",
"value",
"=",
"0",
";",
"if",
"(",
"length",
"<",
"0",
")",
"{",
"length",
"=",
"s",
".",
"length",
"(",
")",
"-",
"offset",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"s",
".",
"charAt",
"(",
"offset",
"+",
"i",
")",
";",
"int",
"digit",
"=",
"convertHexDigit",
"(",
"(",
"int",
")",
"c",
")",
";",
"if",
"(",
"digit",
"<",
"0",
"||",
"digit",
">=",
"base",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"s",
".",
"substring",
"(",
"offset",
",",
"offset",
"+",
"length",
")",
")",
";",
"}",
"value",
"=",
"value",
"*",
"base",
"+",
"digit",
";",
"}",
"return",
"value",
";",
"}"
] | Parse an int from a substring.
Negative numbers are not handled.
@param s String
@param offset Offset within string
@param length Length of integer or -1 for remainder of string
@param base base of the integer
@return the parsed integer
@throws NumberFormatException if the string cannot be parsed | [
"Parse",
"an",
"int",
"from",
"a",
"substring",
".",
"Negative",
"numbers",
"are",
"not",
"handled",
"."
] | train | https://github.com/perwendel/spark/blob/080fb1f9d6e580f6742e9589044c7420d3157b8b/src/main/java/spark/utils/urldecoding/TypeUtil.java#L161-L179 |
shrinkwrap/shrinkwrap | impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/io/tar/TarEntry.java | TarEntry.getDirectoryEntries | public TarEntry[] getDirectoryEntries() throws InvalidHeaderException {
"""
If this entry represents a file, and the file is a directory, return an array of TarEntries for this entry's
children.
@return An array of TarEntry's for this entry's children.
"""
if (this.file == null || !this.file.isDirectory()) {
return new TarEntry[0];
}
String[] list = this.file.list();
TarEntry[] result = new TarEntry[list.length];
for (int i = 0; i < list.length; ++i) {
result[i] = new TarEntry(new File(this.file, list[i]));
}
return result;
} | java | public TarEntry[] getDirectoryEntries() throws InvalidHeaderException {
if (this.file == null || !this.file.isDirectory()) {
return new TarEntry[0];
}
String[] list = this.file.list();
TarEntry[] result = new TarEntry[list.length];
for (int i = 0; i < list.length; ++i) {
result[i] = new TarEntry(new File(this.file, list[i]));
}
return result;
} | [
"public",
"TarEntry",
"[",
"]",
"getDirectoryEntries",
"(",
")",
"throws",
"InvalidHeaderException",
"{",
"if",
"(",
"this",
".",
"file",
"==",
"null",
"||",
"!",
"this",
".",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"new",
"TarEntry",
"[",
"0",
"]",
";",
"}",
"String",
"[",
"]",
"list",
"=",
"this",
".",
"file",
".",
"list",
"(",
")",
";",
"TarEntry",
"[",
"]",
"result",
"=",
"new",
"TarEntry",
"[",
"list",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"length",
";",
"++",
"i",
")",
"{",
"result",
"[",
"i",
"]",
"=",
"new",
"TarEntry",
"(",
"new",
"File",
"(",
"this",
".",
"file",
",",
"list",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | If this entry represents a file, and the file is a directory, return an array of TarEntries for this entry's
children.
@return An array of TarEntry's for this entry's children. | [
"If",
"this",
"entry",
"represents",
"a",
"file",
"and",
"the",
"file",
"is",
"a",
"directory",
"return",
"an",
"array",
"of",
"TarEntries",
"for",
"this",
"entry",
"s",
"children",
"."
] | train | https://github.com/shrinkwrap/shrinkwrap/blob/3f8a1a6d344651428c709a63ebb52d35343c5387/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/io/tar/TarEntry.java#L594-L608 |
ysc/word | src/main/java/org/apdplat/word/corpus/Evaluation.java | Evaluation.generateDataset | public static int generateDataset(String file, String test, String standard) {
"""
生成测试数据集和标准数据集
@param file 已分词文本,词之间空格分隔
@param test 生成测试数据集文件路径
@param standard 生成标准数据集文件路径
@return 测试数据集字符数
"""
int textCharCount=0;
try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),"utf-8"));
BufferedWriter testWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(test),"utf-8"));
BufferedWriter standardWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(standard),"utf-8"))){
String line;
int duplicateCount=0;
Set<String> set = new HashSet<>();
while( (line = reader.readLine()) != null ){
//不把空格当做标点符号
List<String> list = Punctuation.seg(line, false, ' ');
for(String item : list){
item = item.trim();
//忽略空行和长度为一的行
if("".equals(item)
|| item.length()==1){
continue;
}
//忽略重复的内容
if(set.contains(item)){
duplicateCount++;
continue;
}
set.add(item);
String testItem = item.replaceAll(" ", "");
textCharCount += testItem.length();
testWriter.write(testItem+"\n");
standardWriter.write(item+"\n");
}
}
LOGGER.info("重复行数为:"+duplicateCount);
} catch (IOException ex) {
LOGGER.error("生成测试数据集和标准数据集失败:", ex);
}
return textCharCount;
} | java | public static int generateDataset(String file, String test, String standard){
int textCharCount=0;
try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),"utf-8"));
BufferedWriter testWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(test),"utf-8"));
BufferedWriter standardWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(standard),"utf-8"))){
String line;
int duplicateCount=0;
Set<String> set = new HashSet<>();
while( (line = reader.readLine()) != null ){
//不把空格当做标点符号
List<String> list = Punctuation.seg(line, false, ' ');
for(String item : list){
item = item.trim();
//忽略空行和长度为一的行
if("".equals(item)
|| item.length()==1){
continue;
}
//忽略重复的内容
if(set.contains(item)){
duplicateCount++;
continue;
}
set.add(item);
String testItem = item.replaceAll(" ", "");
textCharCount += testItem.length();
testWriter.write(testItem+"\n");
standardWriter.write(item+"\n");
}
}
LOGGER.info("重复行数为:"+duplicateCount);
} catch (IOException ex) {
LOGGER.error("生成测试数据集和标准数据集失败:", ex);
}
return textCharCount;
} | [
"public",
"static",
"int",
"generateDataset",
"(",
"String",
"file",
",",
"String",
"test",
",",
"String",
"standard",
")",
"{",
"int",
"textCharCount",
"=",
"0",
";",
"try",
"(",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
",",
"\"utf-8\"",
")",
")",
";",
"BufferedWriter",
"testWriter",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"test",
")",
",",
"\"utf-8\"",
")",
")",
";",
"BufferedWriter",
"standardWriter",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"standard",
")",
",",
"\"utf-8\"",
")",
")",
")",
"{",
"String",
"line",
";",
"int",
"duplicateCount",
"=",
"0",
";",
"Set",
"<",
"String",
">",
"set",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"//不把空格当做标点符号",
"List",
"<",
"String",
">",
"list",
"=",
"Punctuation",
".",
"seg",
"(",
"line",
",",
"false",
",",
"'",
"'",
")",
";",
"for",
"(",
"String",
"item",
":",
"list",
")",
"{",
"item",
"=",
"item",
".",
"trim",
"(",
")",
";",
"//忽略空行和长度为一的行",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"item",
")",
"||",
"item",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"continue",
";",
"}",
"//忽略重复的内容",
"if",
"(",
"set",
".",
"contains",
"(",
"item",
")",
")",
"{",
"duplicateCount",
"++",
";",
"continue",
";",
"}",
"set",
".",
"add",
"(",
"item",
")",
";",
"String",
"testItem",
"=",
"item",
".",
"replaceAll",
"(",
"\" \"",
",",
"\"\"",
")",
";",
"textCharCount",
"+=",
"testItem",
".",
"length",
"(",
")",
";",
"testWriter",
".",
"write",
"(",
"testItem",
"+",
"\"\\n\"",
")",
";",
"standardWriter",
".",
"write",
"(",
"item",
"+",
"\"\\n\"",
")",
";",
"}",
"}",
"LOGGER",
".",
"info",
"(",
"\"重复行数为:\"+duplicateCo",
"u",
"nt);",
"",
"",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"生成测试数据集和标准数据集失败:\", ex);",
"",
"",
"",
"",
"}",
"return",
"textCharCount",
";",
"}"
] | 生成测试数据集和标准数据集
@param file 已分词文本,词之间空格分隔
@param test 生成测试数据集文件路径
@param standard 生成标准数据集文件路径
@return 测试数据集字符数 | [
"生成测试数据集和标准数据集"
] | train | https://github.com/ysc/word/blob/5e45607f4e97207f55d1e3bc561abda6b34f7c54/src/main/java/org/apdplat/word/corpus/Evaluation.java#L113-L148 |
Azure/azure-sdk-for-java | resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/DeploymentsInner.java | DeploymentsInner.getByResourceGroup | public DeploymentExtendedInner getByResourceGroup(String resourceGroupName, String deploymentName) {
"""
Gets a deployment.
@param resourceGroupName The name of the resource group. The name is case insensitive.
@param deploymentName The name of the deployment to get.
@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 DeploymentExtendedInner object if successful.
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, deploymentName).toBlocking().single().body();
} | java | public DeploymentExtendedInner getByResourceGroup(String resourceGroupName, String deploymentName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, deploymentName).toBlocking().single().body();
} | [
"public",
"DeploymentExtendedInner",
"getByResourceGroup",
"(",
"String",
"resourceGroupName",
",",
"String",
"deploymentName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"deploymentName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Gets a deployment.
@param resourceGroupName The name of the resource group. The name is case insensitive.
@param deploymentName The name of the deployment to get.
@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 DeploymentExtendedInner object if successful. | [
"Gets",
"a",
"deployment",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/DeploymentsInner.java#L558-L560 |
modelmapper/modelmapper | core/src/main/java/org/modelmapper/internal/TypeInfoRegistry.java | TypeInfoRegistry.typeInfoFor | @SuppressWarnings("unchecked")
static <T> TypeInfoImpl<T> typeInfoFor(Class<T> sourceType, InheritingConfiguration configuration) {
"""
Returns a statically cached TypeInfoImpl instance for the given criteria.
"""
TypeInfoKey pair = new TypeInfoKey(sourceType, configuration);
TypeInfoImpl<T> typeInfo = (TypeInfoImpl<T>) cache.get(pair);
if (typeInfo == null) {
synchronized (cache) {
typeInfo = (TypeInfoImpl<T>) cache.get(pair);
if (typeInfo == null) {
typeInfo = new TypeInfoImpl<T>(null, sourceType, configuration);
cache.put(pair, typeInfo);
}
}
}
return typeInfo;
} | java | @SuppressWarnings("unchecked")
static <T> TypeInfoImpl<T> typeInfoFor(Class<T> sourceType, InheritingConfiguration configuration) {
TypeInfoKey pair = new TypeInfoKey(sourceType, configuration);
TypeInfoImpl<T> typeInfo = (TypeInfoImpl<T>) cache.get(pair);
if (typeInfo == null) {
synchronized (cache) {
typeInfo = (TypeInfoImpl<T>) cache.get(pair);
if (typeInfo == null) {
typeInfo = new TypeInfoImpl<T>(null, sourceType, configuration);
cache.put(pair, typeInfo);
}
}
}
return typeInfo;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"static",
"<",
"T",
">",
"TypeInfoImpl",
"<",
"T",
">",
"typeInfoFor",
"(",
"Class",
"<",
"T",
">",
"sourceType",
",",
"InheritingConfiguration",
"configuration",
")",
"{",
"TypeInfoKey",
"pair",
"=",
"new",
"TypeInfoKey",
"(",
"sourceType",
",",
"configuration",
")",
";",
"TypeInfoImpl",
"<",
"T",
">",
"typeInfo",
"=",
"(",
"TypeInfoImpl",
"<",
"T",
">",
")",
"cache",
".",
"get",
"(",
"pair",
")",
";",
"if",
"(",
"typeInfo",
"==",
"null",
")",
"{",
"synchronized",
"(",
"cache",
")",
"{",
"typeInfo",
"=",
"(",
"TypeInfoImpl",
"<",
"T",
">",
")",
"cache",
".",
"get",
"(",
"pair",
")",
";",
"if",
"(",
"typeInfo",
"==",
"null",
")",
"{",
"typeInfo",
"=",
"new",
"TypeInfoImpl",
"<",
"T",
">",
"(",
"null",
",",
"sourceType",
",",
"configuration",
")",
";",
"cache",
".",
"put",
"(",
"pair",
",",
"typeInfo",
")",
";",
"}",
"}",
"}",
"return",
"typeInfo",
";",
"}"
] | Returns a statically cached TypeInfoImpl instance for the given criteria. | [
"Returns",
"a",
"statically",
"cached",
"TypeInfoImpl",
"instance",
"for",
"the",
"given",
"criteria",
"."
] | train | https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/TypeInfoRegistry.java#L76-L92 |
kaazing/java.client | ws/ws/src/main/java/org/kaazing/gateway/client/util/WrappedByteBuffer.java | WrappedByteBuffer.putUnsignedAt | public WrappedByteBuffer putUnsignedAt(int index, int v) {
"""
Puts an unsigned single byte into the buffer at the specified position.
@param v the unsigned byte as an int
@return the buffer
"""
_checkForWriteAt(index, 1);
byte b = (byte)(v & 0xFF);
return this.putAt(index, b);
} | java | public WrappedByteBuffer putUnsignedAt(int index, int v) {
_checkForWriteAt(index, 1);
byte b = (byte)(v & 0xFF);
return this.putAt(index, b);
} | [
"public",
"WrappedByteBuffer",
"putUnsignedAt",
"(",
"int",
"index",
",",
"int",
"v",
")",
"{",
"_checkForWriteAt",
"(",
"index",
",",
"1",
")",
";",
"byte",
"b",
"=",
"(",
"byte",
")",
"(",
"v",
"&",
"0xFF",
")",
";",
"return",
"this",
".",
"putAt",
"(",
"index",
",",
"b",
")",
";",
"}"
] | Puts an unsigned single byte into the buffer at the specified position.
@param v the unsigned byte as an int
@return the buffer | [
"Puts",
"an",
"unsigned",
"single",
"byte",
"into",
"the",
"buffer",
"at",
"the",
"specified",
"position",
"."
] | train | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/ws/ws/src/main/java/org/kaazing/gateway/client/util/WrappedByteBuffer.java#L413-L417 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.