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
|
---|---|---|---|---|---|---|---|---|---|---|
Azure/azure-sdk-for-java | batchai/resource-manager/v2018_05_01/src/main/java/com/microsoft/azure/management/batchai/v2018_05_01/implementation/ClustersInner.java | ClustersInner.listRemoteLoginInformationAsync | public Observable<Page<RemoteLoginInformationInner>> listRemoteLoginInformationAsync(final String resourceGroupName, final String workspaceName, final String clusterName) {
"""
Get the IP address, port of all the compute nodes in the Cluster.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param workspaceName The name of the workspace. Workspace names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param clusterName The name of the cluster within the specified resource group. Cluster names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<RemoteLoginInformationInner> object
"""
return listRemoteLoginInformationWithServiceResponseAsync(resourceGroupName, workspaceName, clusterName)
.map(new Func1<ServiceResponse<Page<RemoteLoginInformationInner>>, Page<RemoteLoginInformationInner>>() {
@Override
public Page<RemoteLoginInformationInner> call(ServiceResponse<Page<RemoteLoginInformationInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<RemoteLoginInformationInner>> listRemoteLoginInformationAsync(final String resourceGroupName, final String workspaceName, final String clusterName) {
return listRemoteLoginInformationWithServiceResponseAsync(resourceGroupName, workspaceName, clusterName)
.map(new Func1<ServiceResponse<Page<RemoteLoginInformationInner>>, Page<RemoteLoginInformationInner>>() {
@Override
public Page<RemoteLoginInformationInner> call(ServiceResponse<Page<RemoteLoginInformationInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"RemoteLoginInformationInner",
">",
">",
"listRemoteLoginInformationAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"workspaceName",
",",
"final",
"String",
"clusterName",
")",
"{",
"return",
"listRemoteLoginInformationWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"workspaceName",
",",
"clusterName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"RemoteLoginInformationInner",
">",
">",
",",
"Page",
"<",
"RemoteLoginInformationInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"RemoteLoginInformationInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"RemoteLoginInformationInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get the IP address, port of all the compute nodes in the Cluster.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param workspaceName The name of the workspace. Workspace names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param clusterName The name of the cluster within the specified resource group. Cluster names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<RemoteLoginInformationInner> object | [
"Get",
"the",
"IP",
"address",
"port",
"of",
"all",
"the",
"compute",
"nodes",
"in",
"the",
"Cluster",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batchai/resource-manager/v2018_05_01/src/main/java/com/microsoft/azure/management/batchai/v2018_05_01/implementation/ClustersInner.java#L1185-L1193 |
depsypher/pngtastic | src/main/java/com/googlecode/pngtastic/core/processing/Base64.java | Base64.decodeFileToFile | public static void decodeFileToFile(String infile, String outfile) throws IOException {
"""
Reads <tt>infile</tt> and decodes it to <tt>outfile</tt>.
@param infile Input file
@param outfile Output file
@throws java.io.IOException if there is an error
@since 2.2
"""
byte[] decoded = Base64.decodeFromFile(infile);
java.io.OutputStream out = null;
try{
out = new java.io.BufferedOutputStream(new FileOutputStream(outfile));
out.write(decoded);
} catch (IOException e) {
throw e; // Catch and release to execute finally{}
} finally {
try {
if (out != null) {
out.close();
}
} catch (Exception ex) {
}
}
} | java | public static void decodeFileToFile(String infile, String outfile) throws IOException {
byte[] decoded = Base64.decodeFromFile(infile);
java.io.OutputStream out = null;
try{
out = new java.io.BufferedOutputStream(new FileOutputStream(outfile));
out.write(decoded);
} catch (IOException e) {
throw e; // Catch and release to execute finally{}
} finally {
try {
if (out != null) {
out.close();
}
} catch (Exception ex) {
}
}
} | [
"public",
"static",
"void",
"decodeFileToFile",
"(",
"String",
"infile",
",",
"String",
"outfile",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"decoded",
"=",
"Base64",
".",
"decodeFromFile",
"(",
"infile",
")",
";",
"java",
".",
"io",
".",
"OutputStream",
"out",
"=",
"null",
";",
"try",
"{",
"out",
"=",
"new",
"java",
".",
"io",
".",
"BufferedOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"outfile",
")",
")",
";",
"out",
".",
"write",
"(",
"decoded",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"e",
";",
"// Catch and release to execute finally{}",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"out",
"!=",
"null",
")",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"}",
"}"
] | Reads <tt>infile</tt> and decodes it to <tt>outfile</tt>.
@param infile Input file
@param outfile Output file
@throws java.io.IOException if there is an error
@since 2.2 | [
"Reads",
"<tt",
">",
"infile<",
"/",
"tt",
">",
"and",
"decodes",
"it",
"to",
"<tt",
">",
"outfile<",
"/",
"tt",
">",
"."
] | train | https://github.com/depsypher/pngtastic/blob/13fd2a63dd8b2febd7041273889a1bba4f2a6a07/src/main/java/com/googlecode/pngtastic/core/processing/Base64.java#L1470-L1486 |
orbisgis/h2gis | h2gis-utilities/src/main/java/org/h2gis/utilities/JDBCUtilities.java | JDBCUtilities.getRowCount | public static int getRowCount(Connection connection, String tableReference) throws SQLException {
"""
Fetch the row count of a table.
@param connection Active connection.
@param tableReference Table reference
@return Row count
@throws SQLException If the table does not exists, or sql request fail.
"""
Statement st = connection.createStatement();
int rowCount = 0;
try {
ResultSet rs = st.executeQuery(String.format("select count(*) rowcount from %s", TableLocation.parse(tableReference)));
try {
if(rs.next()) {
rowCount = rs.getInt(1);
}
} finally {
rs.close();
}
}finally {
st.close();
}
return rowCount;
} | java | public static int getRowCount(Connection connection, String tableReference) throws SQLException {
Statement st = connection.createStatement();
int rowCount = 0;
try {
ResultSet rs = st.executeQuery(String.format("select count(*) rowcount from %s", TableLocation.parse(tableReference)));
try {
if(rs.next()) {
rowCount = rs.getInt(1);
}
} finally {
rs.close();
}
}finally {
st.close();
}
return rowCount;
} | [
"public",
"static",
"int",
"getRowCount",
"(",
"Connection",
"connection",
",",
"String",
"tableReference",
")",
"throws",
"SQLException",
"{",
"Statement",
"st",
"=",
"connection",
".",
"createStatement",
"(",
")",
";",
"int",
"rowCount",
"=",
"0",
";",
"try",
"{",
"ResultSet",
"rs",
"=",
"st",
".",
"executeQuery",
"(",
"String",
".",
"format",
"(",
"\"select count(*) rowcount from %s\"",
",",
"TableLocation",
".",
"parse",
"(",
"tableReference",
")",
")",
")",
";",
"try",
"{",
"if",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"rowCount",
"=",
"rs",
".",
"getInt",
"(",
"1",
")",
";",
"}",
"}",
"finally",
"{",
"rs",
".",
"close",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"st",
".",
"close",
"(",
")",
";",
"}",
"return",
"rowCount",
";",
"}"
] | Fetch the row count of a table.
@param connection Active connection.
@param tableReference Table reference
@return Row count
@throws SQLException If the table does not exists, or sql request fail. | [
"Fetch",
"the",
"row",
"count",
"of",
"a",
"table",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/JDBCUtilities.java#L177-L193 |
VoltDB/voltdb | src/frontend/org/voltcore/logging/VoltLogger.java | VoltLogger.configure | public static void configure(String xmlConfig, File voltroot) {
"""
Static method to change the Log4j config globally. This fails
if you're not using Log4j for now.
@param xmlConfig The text of a Log4j config file.
@param voltroot The VoltDB root path
"""
try {
Class<?> loggerClz = Class.forName("org.voltcore.logging.VoltLog4jLogger");
assert(loggerClz != null);
Method configureMethod = loggerClz.getMethod("configure", String.class, File.class);
configureMethod.invoke(null, xmlConfig, voltroot);
} catch (Exception e) {}
} | java | public static void configure(String xmlConfig, File voltroot) {
try {
Class<?> loggerClz = Class.forName("org.voltcore.logging.VoltLog4jLogger");
assert(loggerClz != null);
Method configureMethod = loggerClz.getMethod("configure", String.class, File.class);
configureMethod.invoke(null, xmlConfig, voltroot);
} catch (Exception e) {}
} | [
"public",
"static",
"void",
"configure",
"(",
"String",
"xmlConfig",
",",
"File",
"voltroot",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"loggerClz",
"=",
"Class",
".",
"forName",
"(",
"\"org.voltcore.logging.VoltLog4jLogger\"",
")",
";",
"assert",
"(",
"loggerClz",
"!=",
"null",
")",
";",
"Method",
"configureMethod",
"=",
"loggerClz",
".",
"getMethod",
"(",
"\"configure\"",
",",
"String",
".",
"class",
",",
"File",
".",
"class",
")",
";",
"configureMethod",
".",
"invoke",
"(",
"null",
",",
"xmlConfig",
",",
"voltroot",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}"
] | Static method to change the Log4j config globally. This fails
if you're not using Log4j for now.
@param xmlConfig The text of a Log4j config file.
@param voltroot The VoltDB root path | [
"Static",
"method",
"to",
"change",
"the",
"Log4j",
"config",
"globally",
".",
"This",
"fails",
"if",
"you",
"re",
"not",
"using",
"Log4j",
"for",
"now",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/logging/VoltLogger.java#L360-L367 |
paymill/paymill-java | src/main/java/com/paymill/services/SubscriptionService.java | SubscriptionService.changeAmountTemporary | public Subscription changeAmountTemporary( String subscriptionId, Integer amount ) {
"""
Changes the amount of a subscription.<br>
<br>
The new amount is valid one-time only after which the original subscription amount will be charged again. If you
want to permanently change the amount use {@link SubscriptionService#changeAmount(String, Integer)}.
@param subscriptionId the Id of the subscription.
@param amount the new amount.
@return the updated subscription.
"""
return this.changeAmountTemporary( new Subscription( subscriptionId ), amount );
} | java | public Subscription changeAmountTemporary( String subscriptionId, Integer amount ) {
return this.changeAmountTemporary( new Subscription( subscriptionId ), amount );
} | [
"public",
"Subscription",
"changeAmountTemporary",
"(",
"String",
"subscriptionId",
",",
"Integer",
"amount",
")",
"{",
"return",
"this",
".",
"changeAmountTemporary",
"(",
"new",
"Subscription",
"(",
"subscriptionId",
")",
",",
"amount",
")",
";",
"}"
] | Changes the amount of a subscription.<br>
<br>
The new amount is valid one-time only after which the original subscription amount will be charged again. If you
want to permanently change the amount use {@link SubscriptionService#changeAmount(String, Integer)}.
@param subscriptionId the Id of the subscription.
@param amount the new amount.
@return the updated subscription. | [
"Changes",
"the",
"amount",
"of",
"a",
"subscription",
".",
"<br",
">",
"<br",
">",
"The",
"new",
"amount",
"is",
"valid",
"one",
"-",
"time",
"only",
"after",
"which",
"the",
"original",
"subscription",
"amount",
"will",
"be",
"charged",
"again",
".",
"If",
"you",
"want",
"to",
"permanently",
"change",
"the",
"amount",
"use",
"{",
"@link",
"SubscriptionService#changeAmount",
"(",
"String",
"Integer",
")",
"}",
"."
] | train | https://github.com/paymill/paymill-java/blob/17281a0d4376c76f1711af9f09bfc138c90ba65a/src/main/java/com/paymill/services/SubscriptionService.java#L367-L369 |
tvesalainen/util | util/src/main/java/org/vesalainen/navi/Area.java | Area.getPolar | public static Area getPolar(double latFrom, double latTo, double lonFrom, double midLon, double lonTo) {
"""
Returns rectangular area. Area is limited by lat/lon coordinates.
Parameter midLon determines which side of earth area lies.
@param latFrom
@param latTo
@param lonFrom
@param midLon
@param lonTo
@return
"""
Location[] locs = new Location[5];
locs[0] = new Location(latFrom, lonFrom);
locs[1] = new Location(latFrom, lonTo);
locs[2] = new Location(latTo, lonFrom);
locs[3] = new Location(latTo, lonTo);
locs[4] = new Location(latFrom, midLon);
return new ConvexArea(locs);
} | java | public static Area getPolar(double latFrom, double latTo, double lonFrom, double midLon, double lonTo)
{
Location[] locs = new Location[5];
locs[0] = new Location(latFrom, lonFrom);
locs[1] = new Location(latFrom, lonTo);
locs[2] = new Location(latTo, lonFrom);
locs[3] = new Location(latTo, lonTo);
locs[4] = new Location(latFrom, midLon);
return new ConvexArea(locs);
} | [
"public",
"static",
"Area",
"getPolar",
"(",
"double",
"latFrom",
",",
"double",
"latTo",
",",
"double",
"lonFrom",
",",
"double",
"midLon",
",",
"double",
"lonTo",
")",
"{",
"Location",
"[",
"]",
"locs",
"=",
"new",
"Location",
"[",
"5",
"]",
";",
"locs",
"[",
"0",
"]",
"=",
"new",
"Location",
"(",
"latFrom",
",",
"lonFrom",
")",
";",
"locs",
"[",
"1",
"]",
"=",
"new",
"Location",
"(",
"latFrom",
",",
"lonTo",
")",
";",
"locs",
"[",
"2",
"]",
"=",
"new",
"Location",
"(",
"latTo",
",",
"lonFrom",
")",
";",
"locs",
"[",
"3",
"]",
"=",
"new",
"Location",
"(",
"latTo",
",",
"lonTo",
")",
";",
"locs",
"[",
"4",
"]",
"=",
"new",
"Location",
"(",
"latFrom",
",",
"midLon",
")",
";",
"return",
"new",
"ConvexArea",
"(",
"locs",
")",
";",
"}"
] | Returns rectangular area. Area is limited by lat/lon coordinates.
Parameter midLon determines which side of earth area lies.
@param latFrom
@param latTo
@param lonFrom
@param midLon
@param lonTo
@return | [
"Returns",
"rectangular",
"area",
".",
"Area",
"is",
"limited",
"by",
"lat",
"/",
"lon",
"coordinates",
".",
"Parameter",
"midLon",
"determines",
"which",
"side",
"of",
"earth",
"area",
"lies",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/Area.java#L122-L131 |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java | IPAddressSegment.isBitwiseOrCompatibleWithRange | public boolean isBitwiseOrCompatibleWithRange(int maskValue, Integer segmentPrefixLength) throws PrefixLenException {
"""
Similar to masking, checks that the range resulting from the bitwise or is contiguous.
@param maskValue
@param segmentPrefixLength
@return
@throws PrefixLenException
"""
return super.isBitwiseOrCompatibleWithRange(maskValue, segmentPrefixLength, getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets());
} | java | public boolean isBitwiseOrCompatibleWithRange(int maskValue, Integer segmentPrefixLength) throws PrefixLenException {
return super.isBitwiseOrCompatibleWithRange(maskValue, segmentPrefixLength, getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets());
} | [
"public",
"boolean",
"isBitwiseOrCompatibleWithRange",
"(",
"int",
"maskValue",
",",
"Integer",
"segmentPrefixLength",
")",
"throws",
"PrefixLenException",
"{",
"return",
"super",
".",
"isBitwiseOrCompatibleWithRange",
"(",
"maskValue",
",",
"segmentPrefixLength",
",",
"getNetwork",
"(",
")",
".",
"getPrefixConfiguration",
"(",
")",
".",
"allPrefixedAddressesAreSubnets",
"(",
")",
")",
";",
"}"
] | Similar to masking, checks that the range resulting from the bitwise or is contiguous.
@param maskValue
@param segmentPrefixLength
@return
@throws PrefixLenException | [
"Similar",
"to",
"masking",
"checks",
"that",
"the",
"range",
"resulting",
"from",
"the",
"bitwise",
"or",
"is",
"contiguous",
"."
] | train | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java#L335-L337 |
OpenLiberty/open-liberty | dev/com.ibm.websphere.security/src/com/ibm/wsspi/security/registry/RegistryHelper.java | RegistryHelper.isRealmInboundTrusted | public static boolean isRealmInboundTrusted(String inboundRealm, String localRealm) {
"""
Determine if the inbound realm is one of the trusted realms of the
specified local realm. If the local realm is null the realm of the
current active user registry will be used.
@param inboundRealm
@param localRealm
@return true - inbound realm is trusted, false - inbound reamn is not trusted
"""
WSSecurityService ss = wsSecurityServiceRef.getService();
if (ss == null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "No WSSecurityService, returning true");
}
return true;
} else {
return ss.isRealmInboundTrusted(inboundRealm, localRealm);
}
} | java | public static boolean isRealmInboundTrusted(String inboundRealm, String localRealm) {
WSSecurityService ss = wsSecurityServiceRef.getService();
if (ss == null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "No WSSecurityService, returning true");
}
return true;
} else {
return ss.isRealmInboundTrusted(inboundRealm, localRealm);
}
} | [
"public",
"static",
"boolean",
"isRealmInboundTrusted",
"(",
"String",
"inboundRealm",
",",
"String",
"localRealm",
")",
"{",
"WSSecurityService",
"ss",
"=",
"wsSecurityServiceRef",
".",
"getService",
"(",
")",
";",
"if",
"(",
"ss",
"==",
"null",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"No WSSecurityService, returning true\"",
")",
";",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"ss",
".",
"isRealmInboundTrusted",
"(",
"inboundRealm",
",",
"localRealm",
")",
";",
"}",
"}"
] | Determine if the inbound realm is one of the trusted realms of the
specified local realm. If the local realm is null the realm of the
current active user registry will be used.
@param inboundRealm
@param localRealm
@return true - inbound realm is trusted, false - inbound reamn is not trusted | [
"Determine",
"if",
"the",
"inbound",
"realm",
"is",
"one",
"of",
"the",
"trusted",
"realms",
"of",
"the",
"specified",
"local",
"realm",
".",
"If",
"the",
"local",
"realm",
"is",
"null",
"the",
"realm",
"of",
"the",
"current",
"active",
"user",
"registry",
"will",
"be",
"used",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.websphere.security/src/com/ibm/wsspi/security/registry/RegistryHelper.java#L128-L138 |
casbin/jcasbin | src/main/java/org/casbin/jcasbin/main/Enforcer.java | Enforcer.addPermissionForUser | public boolean addPermissionForUser(String user, List<String> permission) {
"""
addPermissionForUser adds a permission for a user or role.
Returns false if the user or role already has the permission (aka not affected).
@param user the user.
@param permission the permission, usually be (obj, act). It is actually the rule without the subject.
@return succeeds or not.
"""
return addPermissionForUser(user, permission.toArray(new String[0]));
} | java | public boolean addPermissionForUser(String user, List<String> permission) {
return addPermissionForUser(user, permission.toArray(new String[0]));
} | [
"public",
"boolean",
"addPermissionForUser",
"(",
"String",
"user",
",",
"List",
"<",
"String",
">",
"permission",
")",
"{",
"return",
"addPermissionForUser",
"(",
"user",
",",
"permission",
".",
"toArray",
"(",
"new",
"String",
"[",
"0",
"]",
")",
")",
";",
"}"
] | addPermissionForUser adds a permission for a user or role.
Returns false if the user or role already has the permission (aka not affected).
@param user the user.
@param permission the permission, usually be (obj, act). It is actually the rule without the subject.
@return succeeds or not. | [
"addPermissionForUser",
"adds",
"a",
"permission",
"for",
"a",
"user",
"or",
"role",
".",
"Returns",
"false",
"if",
"the",
"user",
"or",
"role",
"already",
"has",
"the",
"permission",
"(",
"aka",
"not",
"affected",
")",
"."
] | train | https://github.com/casbin/jcasbin/blob/b46d7a756b6c39cdb17e0600607e5fcdc66edd11/src/main/java/org/casbin/jcasbin/main/Enforcer.java#L268-L270 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/bcc/BccClient.java | BccClient.aes128WithFirst16Char | private String aes128WithFirst16Char(String content, String privateKey) throws GeneralSecurityException {
"""
The encryption implement for AES-128 algorithm for BCE password encryption.
Only the first 16 bytes of privateKey will be used to encrypt the content.
See more detail on
<a href = "https://bce.baidu.com/doc/BCC/API.html#.7A.E6.31.D8.94.C1.A1.C2.1A.8D.92.ED.7F.60.7D.AF">
BCE API doc</a>
@param content The content String to encrypt.
@param privateKey The security key to encrypt.
Only the first 16 bytes of privateKey will be used to encrypt the content.
@return The encrypted string of the original content with AES-128 algorithm.
@throws GeneralSecurityException
"""
byte[] crypted = null;
SecretKeySpec skey = new SecretKeySpec(privateKey.substring(0, 16).getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skey);
crypted = cipher.doFinal(content.getBytes());
return new String(Hex.encodeHex(crypted));
} | java | private String aes128WithFirst16Char(String content, String privateKey) throws GeneralSecurityException {
byte[] crypted = null;
SecretKeySpec skey = new SecretKeySpec(privateKey.substring(0, 16).getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skey);
crypted = cipher.doFinal(content.getBytes());
return new String(Hex.encodeHex(crypted));
} | [
"private",
"String",
"aes128WithFirst16Char",
"(",
"String",
"content",
",",
"String",
"privateKey",
")",
"throws",
"GeneralSecurityException",
"{",
"byte",
"[",
"]",
"crypted",
"=",
"null",
";",
"SecretKeySpec",
"skey",
"=",
"new",
"SecretKeySpec",
"(",
"privateKey",
".",
"substring",
"(",
"0",
",",
"16",
")",
".",
"getBytes",
"(",
")",
",",
"\"AES\"",
")",
";",
"Cipher",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"\"AES/ECB/PKCS5Padding\"",
")",
";",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"ENCRYPT_MODE",
",",
"skey",
")",
";",
"crypted",
"=",
"cipher",
".",
"doFinal",
"(",
"content",
".",
"getBytes",
"(",
")",
")",
";",
"return",
"new",
"String",
"(",
"Hex",
".",
"encodeHex",
"(",
"crypted",
")",
")",
";",
"}"
] | The encryption implement for AES-128 algorithm for BCE password encryption.
Only the first 16 bytes of privateKey will be used to encrypt the content.
See more detail on
<a href = "https://bce.baidu.com/doc/BCC/API.html#.7A.E6.31.D8.94.C1.A1.C2.1A.8D.92.ED.7F.60.7D.AF">
BCE API doc</a>
@param content The content String to encrypt.
@param privateKey The security key to encrypt.
Only the first 16 bytes of privateKey will be used to encrypt the content.
@return The encrypted string of the original content with AES-128 algorithm.
@throws GeneralSecurityException | [
"The",
"encryption",
"implement",
"for",
"AES",
"-",
"128",
"algorithm",
"for",
"BCE",
"password",
"encryption",
".",
"Only",
"the",
"first",
"16",
"bytes",
"of",
"privateKey",
"will",
"be",
"used",
"to",
"encrypt",
"the",
"content",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/bcc/BccClient.java#L229-L236 |
czyzby/gdx-lml | autumn/src/main/java/com/github/czyzby/autumn/context/ContextInitializer.java | ContextInitializer.invokeProcessorActionsAfterInitiation | private void invokeProcessorActionsAfterInitiation(final Context context, final ContextDestroyer destroyer) {
"""
Calls {@link AnnotationProcessor#doAfterScanning(ContextInitializer, Context, ContextDestroyer)} with "this"
argument on each processor.
@param context might be required by some processors to finish up.
@param destroyer used to register destruction callbacks.
"""
for (final AnnotationProcessor<?> processor : processors) {
processor.doAfterScanning(this, context, destroyer);
}
} | java | private void invokeProcessorActionsAfterInitiation(final Context context, final ContextDestroyer destroyer) {
for (final AnnotationProcessor<?> processor : processors) {
processor.doAfterScanning(this, context, destroyer);
}
} | [
"private",
"void",
"invokeProcessorActionsAfterInitiation",
"(",
"final",
"Context",
"context",
",",
"final",
"ContextDestroyer",
"destroyer",
")",
"{",
"for",
"(",
"final",
"AnnotationProcessor",
"<",
"?",
">",
"processor",
":",
"processors",
")",
"{",
"processor",
".",
"doAfterScanning",
"(",
"this",
",",
"context",
",",
"destroyer",
")",
";",
"}",
"}"
] | Calls {@link AnnotationProcessor#doAfterScanning(ContextInitializer, Context, ContextDestroyer)} with "this"
argument on each processor.
@param context might be required by some processors to finish up.
@param destroyer used to register destruction callbacks. | [
"Calls",
"{"
] | train | https://github.com/czyzby/gdx-lml/blob/7623b322e6afe49ad4dd636c80c230150a1cfa4e/autumn/src/main/java/com/github/czyzby/autumn/context/ContextInitializer.java#L349-L353 |
Syncleus/aparapi | src/main/java/com/aparapi/internal/kernel/KernelProfile.java | KernelProfile.onStart | void onStart(Device device) {
"""
Starts a profiling information gathering sequence for the current thread invoking this method
regarding the specified execution device.
@param device
"""
KernelDeviceProfile currentDeviceProfile = deviceProfiles.get(device);
if (currentDeviceProfile == null) {
currentDeviceProfile = new KernelDeviceProfile(this, kernelClass, device);
KernelDeviceProfile existingProfile = deviceProfiles.putIfAbsent(device, currentDeviceProfile);
if (existingProfile != null) {
currentDeviceProfile = existingProfile;
}
}
currentDeviceProfile.onEvent(ProfilingEvent.START);
currentDevice.set(device);
} | java | void onStart(Device device) {
KernelDeviceProfile currentDeviceProfile = deviceProfiles.get(device);
if (currentDeviceProfile == null) {
currentDeviceProfile = new KernelDeviceProfile(this, kernelClass, device);
KernelDeviceProfile existingProfile = deviceProfiles.putIfAbsent(device, currentDeviceProfile);
if (existingProfile != null) {
currentDeviceProfile = existingProfile;
}
}
currentDeviceProfile.onEvent(ProfilingEvent.START);
currentDevice.set(device);
} | [
"void",
"onStart",
"(",
"Device",
"device",
")",
"{",
"KernelDeviceProfile",
"currentDeviceProfile",
"=",
"deviceProfiles",
".",
"get",
"(",
"device",
")",
";",
"if",
"(",
"currentDeviceProfile",
"==",
"null",
")",
"{",
"currentDeviceProfile",
"=",
"new",
"KernelDeviceProfile",
"(",
"this",
",",
"kernelClass",
",",
"device",
")",
";",
"KernelDeviceProfile",
"existingProfile",
"=",
"deviceProfiles",
".",
"putIfAbsent",
"(",
"device",
",",
"currentDeviceProfile",
")",
";",
"if",
"(",
"existingProfile",
"!=",
"null",
")",
"{",
"currentDeviceProfile",
"=",
"existingProfile",
";",
"}",
"}",
"currentDeviceProfile",
".",
"onEvent",
"(",
"ProfilingEvent",
".",
"START",
")",
";",
"currentDevice",
".",
"set",
"(",
"device",
")",
";",
"}"
] | Starts a profiling information gathering sequence for the current thread invoking this method
regarding the specified execution device.
@param device | [
"Starts",
"a",
"profiling",
"information",
"gathering",
"sequence",
"for",
"the",
"current",
"thread",
"invoking",
"this",
"method",
"regarding",
"the",
"specified",
"execution",
"device",
"."
] | train | https://github.com/Syncleus/aparapi/blob/6d5892c8e69854b3968c541023de37cf4762bd24/src/main/java/com/aparapi/internal/kernel/KernelProfile.java#L76-L88 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.createRandomAccessFile | public static RandomAccessFile createRandomAccessFile(Path path, FileMode mode) {
"""
创建{@link RandomAccessFile}
@param path 文件Path
@param mode 模式,见{@link FileMode}
@return {@link RandomAccessFile}
@since 4.5.2
"""
return createRandomAccessFile(path.toFile(), mode);
} | java | public static RandomAccessFile createRandomAccessFile(Path path, FileMode mode) {
return createRandomAccessFile(path.toFile(), mode);
} | [
"public",
"static",
"RandomAccessFile",
"createRandomAccessFile",
"(",
"Path",
"path",
",",
"FileMode",
"mode",
")",
"{",
"return",
"createRandomAccessFile",
"(",
"path",
".",
"toFile",
"(",
")",
",",
"mode",
")",
";",
"}"
] | 创建{@link RandomAccessFile}
@param path 文件Path
@param mode 模式,见{@link FileMode}
@return {@link RandomAccessFile}
@since 4.5.2 | [
"创建",
"{",
"@link",
"RandomAccessFile",
"}"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L3445-L3447 |
RestComm/sip-servlets | sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java | FacebookRestClient.feed_publishStoryToUser | public boolean feed_publishStoryToUser(CharSequence title, CharSequence body)
throws FacebookException, IOException {
"""
Publish a story to the logged-in user's newsfeed.
@param title the title of the feed story
@param body the body of the feed story
@return whether the story was successfully published; false in case of permission error
@see <a href="http://wiki.developers.facebook.com/index.php/Feed.publishStoryToUser">
Developers Wiki: Feed.publishStoryToUser</a>
"""
return feed_publishStoryToUser(title, body, null, null);
} | java | public boolean feed_publishStoryToUser(CharSequence title, CharSequence body)
throws FacebookException, IOException {
return feed_publishStoryToUser(title, body, null, null);
} | [
"public",
"boolean",
"feed_publishStoryToUser",
"(",
"CharSequence",
"title",
",",
"CharSequence",
"body",
")",
"throws",
"FacebookException",
",",
"IOException",
"{",
"return",
"feed_publishStoryToUser",
"(",
"title",
",",
"body",
",",
"null",
",",
"null",
")",
";",
"}"
] | Publish a story to the logged-in user's newsfeed.
@param title the title of the feed story
@param body the body of the feed story
@return whether the story was successfully published; false in case of permission error
@see <a href="http://wiki.developers.facebook.com/index.php/Feed.publishStoryToUser">
Developers Wiki: Feed.publishStoryToUser</a> | [
"Publish",
"a",
"story",
"to",
"the",
"logged",
"-",
"in",
"user",
"s",
"newsfeed",
"."
] | train | https://github.com/RestComm/sip-servlets/blob/fd7011d2803ab1d205b140768a760c8c69e0c997/sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java#L321-L324 |
intendia-oss/rxjava-gwt | src/main/modified/io/reactivex/super/io/reactivex/Maybe.java | Maybe.flatMapCompletable | @CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Completable flatMapCompletable(final Function<? super T, ? extends CompletableSource> mapper) {
"""
Returns a {@link Completable} that completes based on applying a specified function to the item emitted by the
source {@link Maybe}, where that function returns a {@link Completable}.
<p>
<img width="640" height="267" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.flatMapCompletable.png" alt="">
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code flatMapCompletable} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param mapper
a function that, when applied to the item emitted by the source Maybe, returns a
Completable
@return the Completable returned from {@code mapper} when applied to the item emitted by the source Maybe
@see <a href="http://reactivex.io/documentation/operators/flatmap.html">ReactiveX operators documentation: FlatMap</a>
"""
ObjectHelper.requireNonNull(mapper, "mapper is null");
return RxJavaPlugins.onAssembly(new MaybeFlatMapCompletable<T>(this, mapper));
} | java | @CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Completable flatMapCompletable(final Function<? super T, ? extends CompletableSource> mapper) {
ObjectHelper.requireNonNull(mapper, "mapper is null");
return RxJavaPlugins.onAssembly(new MaybeFlatMapCompletable<T>(this, mapper));
} | [
"@",
"CheckReturnValue",
"@",
"SchedulerSupport",
"(",
"SchedulerSupport",
".",
"NONE",
")",
"public",
"final",
"Completable",
"flatMapCompletable",
"(",
"final",
"Function",
"<",
"?",
"super",
"T",
",",
"?",
"extends",
"CompletableSource",
">",
"mapper",
")",
"{",
"ObjectHelper",
".",
"requireNonNull",
"(",
"mapper",
",",
"\"mapper is null\"",
")",
";",
"return",
"RxJavaPlugins",
".",
"onAssembly",
"(",
"new",
"MaybeFlatMapCompletable",
"<",
"T",
">",
"(",
"this",
",",
"mapper",
")",
")",
";",
"}"
] | Returns a {@link Completable} that completes based on applying a specified function to the item emitted by the
source {@link Maybe}, where that function returns a {@link Completable}.
<p>
<img width="640" height="267" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.flatMapCompletable.png" alt="">
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code flatMapCompletable} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param mapper
a function that, when applied to the item emitted by the source Maybe, returns a
Completable
@return the Completable returned from {@code mapper} when applied to the item emitted by the source Maybe
@see <a href="http://reactivex.io/documentation/operators/flatmap.html">ReactiveX operators documentation: FlatMap</a> | [
"Returns",
"a",
"{",
"@link",
"Completable",
"}",
"that",
"completes",
"based",
"on",
"applying",
"a",
"specified",
"function",
"to",
"the",
"item",
"emitted",
"by",
"the",
"source",
"{",
"@link",
"Maybe",
"}",
"where",
"that",
"function",
"returns",
"a",
"{",
"@link",
"Completable",
"}",
".",
"<p",
">",
"<img",
"width",
"=",
"640",
"height",
"=",
"267",
"src",
"=",
"https",
":",
"//",
"raw",
".",
"github",
".",
"com",
"/",
"wiki",
"/",
"ReactiveX",
"/",
"RxJava",
"/",
"images",
"/",
"rx",
"-",
"operators",
"/",
"Maybe",
".",
"flatMapCompletable",
".",
"png",
"alt",
"=",
">",
"<dl",
">",
"<dt",
">",
"<b",
">",
"Scheduler",
":",
"<",
"/",
"b",
">",
"<",
"/",
"dt",
">",
"<dd",
">",
"{",
"@code",
"flatMapCompletable",
"}",
"does",
"not",
"operate",
"by",
"default",
"on",
"a",
"particular",
"{",
"@link",
"Scheduler",
"}",
".",
"<",
"/",
"dd",
">",
"<",
"/",
"dl",
">"
] | train | https://github.com/intendia-oss/rxjava-gwt/blob/8d5635b12ce40da99e76b59dc6bfe6fc2fffc1fa/src/main/modified/io/reactivex/super/io/reactivex/Maybe.java#L3141-L3146 |
Clivern/Racter | src/main/java/com/clivern/racter/senders/templates/GenericTemplate.java | GenericTemplate.setElement | public Integer setElement(String title, String image_url, String subtitle) {
"""
Set Element
@param title the element title
@param image_url the element image url
@param subtitle the element subtitle
@return Integer the element index
"""
HashMap<String, Object> element = new HashMap<String, Object>();
element.put("title", title);
element.put("image_url", image_url);
element.put("subtitle", subtitle);
this.elements.add(element);
return this.elements.size() - 1;
} | java | public Integer setElement(String title, String image_url, String subtitle)
{
HashMap<String, Object> element = new HashMap<String, Object>();
element.put("title", title);
element.put("image_url", image_url);
element.put("subtitle", subtitle);
this.elements.add(element);
return this.elements.size() - 1;
} | [
"public",
"Integer",
"setElement",
"(",
"String",
"title",
",",
"String",
"image_url",
",",
"String",
"subtitle",
")",
"{",
"HashMap",
"<",
"String",
",",
"Object",
">",
"element",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"element",
".",
"put",
"(",
"\"title\"",
",",
"title",
")",
";",
"element",
".",
"put",
"(",
"\"image_url\"",
",",
"image_url",
")",
";",
"element",
".",
"put",
"(",
"\"subtitle\"",
",",
"subtitle",
")",
";",
"this",
".",
"elements",
".",
"add",
"(",
"element",
")",
";",
"return",
"this",
".",
"elements",
".",
"size",
"(",
")",
"-",
"1",
";",
"}"
] | Set Element
@param title the element title
@param image_url the element image url
@param subtitle the element subtitle
@return Integer the element index | [
"Set",
"Element"
] | train | https://github.com/Clivern/Racter/blob/bbde02f0c2a8a80653ad6b1607376d8408acd71c/src/main/java/com/clivern/racter/senders/templates/GenericTemplate.java#L62-L72 |
hltcoe/annotated-nyt | src/main/java/com/nytlabs/corpus/NYTCorpusDocumentParser.java | NYTCorpusDocumentParser.loadValidating | private Document loadValidating(InputStream is) {
"""
Parse the specified file into a DOM Document.
@param file
The file to parse.
@return The parsed DOM Document or null if an error occurs.
"""
try {
return getDOMObject(is, true);
} catch (SAXException e) {
e.printStackTrace();
System.out.println("Error parsing digital document from nitf inputstream.");
} catch (IOException e) {
e.printStackTrace();
System.out.println("Error parsing digital document from nitf inputstream.");
} catch (ParserConfigurationException e) {
e.printStackTrace();
System.out.println("Error parsing digital document from nitf inputstream.");
}
return null;
} | java | private Document loadValidating(InputStream is) {
try {
return getDOMObject(is, true);
} catch (SAXException e) {
e.printStackTrace();
System.out.println("Error parsing digital document from nitf inputstream.");
} catch (IOException e) {
e.printStackTrace();
System.out.println("Error parsing digital document from nitf inputstream.");
} catch (ParserConfigurationException e) {
e.printStackTrace();
System.out.println("Error parsing digital document from nitf inputstream.");
}
return null;
} | [
"private",
"Document",
"loadValidating",
"(",
"InputStream",
"is",
")",
"{",
"try",
"{",
"return",
"getDOMObject",
"(",
"is",
",",
"true",
")",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Error parsing digital document from nitf inputstream.\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Error parsing digital document from nitf inputstream.\"",
")",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Error parsing digital document from nitf inputstream.\"",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Parse the specified file into a DOM Document.
@param file
The file to parse.
@return The parsed DOM Document or null if an error occurs. | [
"Parse",
"the",
"specified",
"file",
"into",
"a",
"DOM",
"Document",
"."
] | train | https://github.com/hltcoe/annotated-nyt/blob/0a4daa97705591cefea9de61614770ae2665a48e/src/main/java/com/nytlabs/corpus/NYTCorpusDocumentParser.java#L362-L376 |
alkacon/opencms-core | src/org/opencms/workplace/threads/CmsXmlContentRepairSettings.java | CmsXmlContentRepairSettings.setVfsFolder | public void setVfsFolder(String vfsFolder) throws CmsIllegalArgumentException {
"""
Sets the VFS folder under which XML contents will be processed recursively.<p>
@param vfsFolder the VFS folder under which XML contents will be processed recursively
@throws CmsIllegalArgumentException if the given VFS path is not valid
"""
if (CmsStringUtil.isEmptyOrWhitespaceOnly(vfsFolder)) {
throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_VALUE_EMPTY_0));
}
// test if it is a valid path
if (!m_cms.existsResource(vfsFolder, CmsResourceFilter.ALL.addRequireFolder())) {
throw new CmsIllegalArgumentException(
Messages.get().container(Messages.ERR_XMLCONTENT_VFSFOLDER_1, vfsFolder));
}
m_vfsFolder = vfsFolder;
} | java | public void setVfsFolder(String vfsFolder) throws CmsIllegalArgumentException {
if (CmsStringUtil.isEmptyOrWhitespaceOnly(vfsFolder)) {
throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_VALUE_EMPTY_0));
}
// test if it is a valid path
if (!m_cms.existsResource(vfsFolder, CmsResourceFilter.ALL.addRequireFolder())) {
throw new CmsIllegalArgumentException(
Messages.get().container(Messages.ERR_XMLCONTENT_VFSFOLDER_1, vfsFolder));
}
m_vfsFolder = vfsFolder;
} | [
"public",
"void",
"setVfsFolder",
"(",
"String",
"vfsFolder",
")",
"throws",
"CmsIllegalArgumentException",
"{",
"if",
"(",
"CmsStringUtil",
".",
"isEmptyOrWhitespaceOnly",
"(",
"vfsFolder",
")",
")",
"{",
"throw",
"new",
"CmsIllegalArgumentException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_VALUE_EMPTY_0",
")",
")",
";",
"}",
"// test if it is a valid path",
"if",
"(",
"!",
"m_cms",
".",
"existsResource",
"(",
"vfsFolder",
",",
"CmsResourceFilter",
".",
"ALL",
".",
"addRequireFolder",
"(",
")",
")",
")",
"{",
"throw",
"new",
"CmsIllegalArgumentException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_XMLCONTENT_VFSFOLDER_1",
",",
"vfsFolder",
")",
")",
";",
"}",
"m_vfsFolder",
"=",
"vfsFolder",
";",
"}"
] | Sets the VFS folder under which XML contents will be processed recursively.<p>
@param vfsFolder the VFS folder under which XML contents will be processed recursively
@throws CmsIllegalArgumentException if the given VFS path is not valid | [
"Sets",
"the",
"VFS",
"folder",
"under",
"which",
"XML",
"contents",
"will",
"be",
"processed",
"recursively",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/threads/CmsXmlContentRepairSettings.java#L149-L160 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/itemfilters/AbstractNamePatternFilter.java | AbstractNamePatternFilter.parsePatternQPathEntry | private QPathEntry parsePatternQPathEntry(String namePattern, SessionImpl session) throws RepositoryException {
"""
Parse QPathEntry from string namePattern. NamePattern may contain wildcard symbols in
namespace and local name. And may not contain index, which means look all samename siblings.
So ordinary QPathEntry parser is not acceptable.
@param namePattern string pattern
@param session session used to fetch namespace URI
@return PatternQPathEntry
@throws RepositoryException if namePattern is malformed or there is some namespace problem.
"""
int colonIndex = namePattern.indexOf(':');
int bracketIndex = namePattern.lastIndexOf('[');
String namespaceURI;
String localName;
int index = getDefaultIndex();
if (bracketIndex != -1)
{
int rbracketIndex = namePattern.lastIndexOf(']');
if (rbracketIndex < bracketIndex)
{
throw new RepositoryException("Malformed pattern expression " + namePattern);
}
index = Integer.parseInt(namePattern.substring(bracketIndex + 1, rbracketIndex));
}
if (colonIndex == -1)
{
namespaceURI = "";
localName = (bracketIndex == -1) ? namePattern : namePattern.substring(0, bracketIndex);
}
else
{
String prefix = namePattern.substring(0, colonIndex);
localName =
(bracketIndex == -1) ? namePattern.substring(colonIndex + 1) : namePattern.substring(0, bracketIndex);
if (prefix.indexOf("*") != -1)
{
namespaceURI = "*";
}
else
{
namespaceURI = session.getNamespaceURI(prefix);
}
}
return new PatternQPathEntry(namespaceURI, localName, index);
} | java | private QPathEntry parsePatternQPathEntry(String namePattern, SessionImpl session) throws RepositoryException
{
int colonIndex = namePattern.indexOf(':');
int bracketIndex = namePattern.lastIndexOf('[');
String namespaceURI;
String localName;
int index = getDefaultIndex();
if (bracketIndex != -1)
{
int rbracketIndex = namePattern.lastIndexOf(']');
if (rbracketIndex < bracketIndex)
{
throw new RepositoryException("Malformed pattern expression " + namePattern);
}
index = Integer.parseInt(namePattern.substring(bracketIndex + 1, rbracketIndex));
}
if (colonIndex == -1)
{
namespaceURI = "";
localName = (bracketIndex == -1) ? namePattern : namePattern.substring(0, bracketIndex);
}
else
{
String prefix = namePattern.substring(0, colonIndex);
localName =
(bracketIndex == -1) ? namePattern.substring(colonIndex + 1) : namePattern.substring(0, bracketIndex);
if (prefix.indexOf("*") != -1)
{
namespaceURI = "*";
}
else
{
namespaceURI = session.getNamespaceURI(prefix);
}
}
return new PatternQPathEntry(namespaceURI, localName, index);
} | [
"private",
"QPathEntry",
"parsePatternQPathEntry",
"(",
"String",
"namePattern",
",",
"SessionImpl",
"session",
")",
"throws",
"RepositoryException",
"{",
"int",
"colonIndex",
"=",
"namePattern",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"int",
"bracketIndex",
"=",
"namePattern",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"String",
"namespaceURI",
";",
"String",
"localName",
";",
"int",
"index",
"=",
"getDefaultIndex",
"(",
")",
";",
"if",
"(",
"bracketIndex",
"!=",
"-",
"1",
")",
"{",
"int",
"rbracketIndex",
"=",
"namePattern",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"rbracketIndex",
"<",
"bracketIndex",
")",
"{",
"throw",
"new",
"RepositoryException",
"(",
"\"Malformed pattern expression \"",
"+",
"namePattern",
")",
";",
"}",
"index",
"=",
"Integer",
".",
"parseInt",
"(",
"namePattern",
".",
"substring",
"(",
"bracketIndex",
"+",
"1",
",",
"rbracketIndex",
")",
")",
";",
"}",
"if",
"(",
"colonIndex",
"==",
"-",
"1",
")",
"{",
"namespaceURI",
"=",
"\"\"",
";",
"localName",
"=",
"(",
"bracketIndex",
"==",
"-",
"1",
")",
"?",
"namePattern",
":",
"namePattern",
".",
"substring",
"(",
"0",
",",
"bracketIndex",
")",
";",
"}",
"else",
"{",
"String",
"prefix",
"=",
"namePattern",
".",
"substring",
"(",
"0",
",",
"colonIndex",
")",
";",
"localName",
"=",
"(",
"bracketIndex",
"==",
"-",
"1",
")",
"?",
"namePattern",
".",
"substring",
"(",
"colonIndex",
"+",
"1",
")",
":",
"namePattern",
".",
"substring",
"(",
"0",
",",
"bracketIndex",
")",
";",
"if",
"(",
"prefix",
".",
"indexOf",
"(",
"\"*\"",
")",
"!=",
"-",
"1",
")",
"{",
"namespaceURI",
"=",
"\"*\"",
";",
"}",
"else",
"{",
"namespaceURI",
"=",
"session",
".",
"getNamespaceURI",
"(",
"prefix",
")",
";",
"}",
"}",
"return",
"new",
"PatternQPathEntry",
"(",
"namespaceURI",
",",
"localName",
",",
"index",
")",
";",
"}"
] | Parse QPathEntry from string namePattern. NamePattern may contain wildcard symbols in
namespace and local name. And may not contain index, which means look all samename siblings.
So ordinary QPathEntry parser is not acceptable.
@param namePattern string pattern
@param session session used to fetch namespace URI
@return PatternQPathEntry
@throws RepositoryException if namePattern is malformed or there is some namespace problem. | [
"Parse",
"QPathEntry",
"from",
"string",
"namePattern",
".",
"NamePattern",
"may",
"contain",
"wildcard",
"symbols",
"in",
"namespace",
"and",
"local",
"name",
".",
"And",
"may",
"not",
"contain",
"index",
"which",
"means",
"look",
"all",
"samename",
"siblings",
".",
"So",
"ordinary",
"QPathEntry",
"parser",
"is",
"not",
"acceptable",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/itemfilters/AbstractNamePatternFilter.java#L293-L333 |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/files/FileUtils.java | FileUtils.loadStringToFileMap | public static Map<String, File> loadStringToFileMap(final File f) throws IOException {
"""
Reads an {@link Map} from a {@link File}, where each line is a key, a tab character
("\t"), and a value. Blank lines and lines beginning with "#" are ignored.
"""
return loadStringToFileMap(Files.asCharSource(f, Charsets.UTF_8));
} | java | public static Map<String, File> loadStringToFileMap(final File f) throws IOException {
return loadStringToFileMap(Files.asCharSource(f, Charsets.UTF_8));
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"File",
">",
"loadStringToFileMap",
"(",
"final",
"File",
"f",
")",
"throws",
"IOException",
"{",
"return",
"loadStringToFileMap",
"(",
"Files",
".",
"asCharSource",
"(",
"f",
",",
"Charsets",
".",
"UTF_8",
")",
")",
";",
"}"
] | Reads an {@link Map} from a {@link File}, where each line is a key, a tab character
("\t"), and a value. Blank lines and lines beginning with "#" are ignored. | [
"Reads",
"an",
"{"
] | train | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/files/FileUtils.java#L275-L277 |
geomajas/geomajas-project-client-gwt | common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java | HtmlBuilder.openTag | private static String openTag(String tag, String clazz, String style, boolean contentIsHtml, String... content) {
"""
Build a String containing a HTML opening tag with given CSS class and/or
style and concatenates the given content.
@param tag String name of HTML tag
@param clazz CSS class of the tag
@param style style for tag (plain CSS)
@param contentIsHtml if false content is prepared with {@link HtmlBuilder#htmlEncode(String)}.
@param content content string
@return HTML tag element as string
"""
StringBuilder result = new StringBuilder("<").append(tag);
if (clazz != null && !"".equals(clazz)) {
result.append(" ").append(Html.Attribute.CLASS).append("='").append(clazz).append("'");
}
if (style != null && !"".equals(style)) {
result.append(" ").append(Html.Attribute.STYLE).append("='").append(style).append("'");
}
result.append(">");
if (content != null && content.length > 0) {
for (String c : content) {
if (contentIsHtml) {
result.append(c);
} else {
result.append(htmlEncode(c));
}
}
}
return result.toString();
} | java | private static String openTag(String tag, String clazz, String style, boolean contentIsHtml, String... content) {
StringBuilder result = new StringBuilder("<").append(tag);
if (clazz != null && !"".equals(clazz)) {
result.append(" ").append(Html.Attribute.CLASS).append("='").append(clazz).append("'");
}
if (style != null && !"".equals(style)) {
result.append(" ").append(Html.Attribute.STYLE).append("='").append(style).append("'");
}
result.append(">");
if (content != null && content.length > 0) {
for (String c : content) {
if (contentIsHtml) {
result.append(c);
} else {
result.append(htmlEncode(c));
}
}
}
return result.toString();
} | [
"private",
"static",
"String",
"openTag",
"(",
"String",
"tag",
",",
"String",
"clazz",
",",
"String",
"style",
",",
"boolean",
"contentIsHtml",
",",
"String",
"...",
"content",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"\"<\"",
")",
".",
"append",
"(",
"tag",
")",
";",
"if",
"(",
"clazz",
"!=",
"null",
"&&",
"!",
"\"\"",
".",
"equals",
"(",
"clazz",
")",
")",
"{",
"result",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"Html",
".",
"Attribute",
".",
"CLASS",
")",
".",
"append",
"(",
"\"='\"",
")",
".",
"append",
"(",
"clazz",
")",
".",
"append",
"(",
"\"'\"",
")",
";",
"}",
"if",
"(",
"style",
"!=",
"null",
"&&",
"!",
"\"\"",
".",
"equals",
"(",
"style",
")",
")",
"{",
"result",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"Html",
".",
"Attribute",
".",
"STYLE",
")",
".",
"append",
"(",
"\"='\"",
")",
".",
"append",
"(",
"style",
")",
".",
"append",
"(",
"\"'\"",
")",
";",
"}",
"result",
".",
"append",
"(",
"\">\"",
")",
";",
"if",
"(",
"content",
"!=",
"null",
"&&",
"content",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"String",
"c",
":",
"content",
")",
"{",
"if",
"(",
"contentIsHtml",
")",
"{",
"result",
".",
"append",
"(",
"c",
")",
";",
"}",
"else",
"{",
"result",
".",
"append",
"(",
"htmlEncode",
"(",
"c",
")",
")",
";",
"}",
"}",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Build a String containing a HTML opening tag with given CSS class and/or
style and concatenates the given content.
@param tag String name of HTML tag
@param clazz CSS class of the tag
@param style style for tag (plain CSS)
@param contentIsHtml if false content is prepared with {@link HtmlBuilder#htmlEncode(String)}.
@param content content string
@return HTML tag element as string | [
"Build",
"a",
"String",
"containing",
"a",
"HTML",
"opening",
"tag",
"with",
"given",
"CSS",
"class",
"and",
"/",
"or",
"style",
"and",
"concatenates",
"the",
"given",
"content",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java#L419-L439 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/transformer/TransformerIdentityImpl.java | TransformerIdentityImpl.processingInstruction | public void processingInstruction(String target, String data)
throws SAXException {
"""
Receive notification of a processing instruction.
<p>By default, do nothing. Application writers may override this
method in a subclass to take specific actions for each
processing instruction, such as setting status variables or
invoking other methods.</p>
@param target The processing instruction target.
@param data The processing instruction data, or null if
none is supplied.
@throws org.xml.sax.SAXException Any SAX exception, possibly
wrapping another exception.
@see org.xml.sax.ContentHandler#processingInstruction
@throws SAXException
"""
flushStartDoc();
m_resultContentHandler.processingInstruction(target, data);
} | java | public void processingInstruction(String target, String data)
throws SAXException
{
flushStartDoc();
m_resultContentHandler.processingInstruction(target, data);
} | [
"public",
"void",
"processingInstruction",
"(",
"String",
"target",
",",
"String",
"data",
")",
"throws",
"SAXException",
"{",
"flushStartDoc",
"(",
")",
";",
"m_resultContentHandler",
".",
"processingInstruction",
"(",
"target",
",",
"data",
")",
";",
"}"
] | Receive notification of a processing instruction.
<p>By default, do nothing. Application writers may override this
method in a subclass to take specific actions for each
processing instruction, such as setting status variables or
invoking other methods.</p>
@param target The processing instruction target.
@param data The processing instruction data, or null if
none is supplied.
@throws org.xml.sax.SAXException Any SAX exception, possibly
wrapping another exception.
@see org.xml.sax.ContentHandler#processingInstruction
@throws SAXException | [
"Receive",
"notification",
"of",
"a",
"processing",
"instruction",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/transformer/TransformerIdentityImpl.java#L1170-L1175 |
pravega/pravega | controller/src/main/java/io/pravega/controller/util/ZKUtils.java | ZKUtils.createPathIfNotExists | public static void createPathIfNotExists(final CuratorFramework client, final String basePath,
final byte[] initData) {
"""
Creates the znode if is doesn't already exist in zookeeper.
@param client The curator client to access zookeeper.
@param basePath The znode path string.
@param initData Initialize the znode using the supplied data if not already created.
@throws RuntimeException If checking or creating path on zookeeper fails.
"""
Preconditions.checkNotNull(client, "client");
Preconditions.checkNotNull(basePath, "basePath");
Preconditions.checkNotNull(initData, "initData");
try {
if (client.checkExists().forPath(basePath) == null) {
client.create().creatingParentsIfNeeded().forPath(basePath, initData);
}
} catch (KeeperException.NodeExistsException e) {
log.debug("Path exists {}, ignoring exception", basePath);
} catch (Exception e) {
throw new RuntimeException("Exception while creating znode: " + basePath, e);
}
} | java | public static void createPathIfNotExists(final CuratorFramework client, final String basePath,
final byte[] initData) {
Preconditions.checkNotNull(client, "client");
Preconditions.checkNotNull(basePath, "basePath");
Preconditions.checkNotNull(initData, "initData");
try {
if (client.checkExists().forPath(basePath) == null) {
client.create().creatingParentsIfNeeded().forPath(basePath, initData);
}
} catch (KeeperException.NodeExistsException e) {
log.debug("Path exists {}, ignoring exception", basePath);
} catch (Exception e) {
throw new RuntimeException("Exception while creating znode: " + basePath, e);
}
} | [
"public",
"static",
"void",
"createPathIfNotExists",
"(",
"final",
"CuratorFramework",
"client",
",",
"final",
"String",
"basePath",
",",
"final",
"byte",
"[",
"]",
"initData",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"client",
",",
"\"client\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"basePath",
",",
"\"basePath\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"initData",
",",
"\"initData\"",
")",
";",
"try",
"{",
"if",
"(",
"client",
".",
"checkExists",
"(",
")",
".",
"forPath",
"(",
"basePath",
")",
"==",
"null",
")",
"{",
"client",
".",
"create",
"(",
")",
".",
"creatingParentsIfNeeded",
"(",
")",
".",
"forPath",
"(",
"basePath",
",",
"initData",
")",
";",
"}",
"}",
"catch",
"(",
"KeeperException",
".",
"NodeExistsException",
"e",
")",
"{",
"log",
".",
"debug",
"(",
"\"Path exists {}, ignoring exception\"",
",",
"basePath",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Exception while creating znode: \"",
"+",
"basePath",
",",
"e",
")",
";",
"}",
"}"
] | Creates the znode if is doesn't already exist in zookeeper.
@param client The curator client to access zookeeper.
@param basePath The znode path string.
@param initData Initialize the znode using the supplied data if not already created.
@throws RuntimeException If checking or creating path on zookeeper fails. | [
"Creates",
"the",
"znode",
"if",
"is",
"doesn",
"t",
"already",
"exist",
"in",
"zookeeper",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/controller/src/main/java/io/pravega/controller/util/ZKUtils.java#L33-L48 |
GoogleCloudPlatform/bigdata-interop | util/src/main/java/com/google/cloud/hadoop/util/CredentialFactory.java | CredentialFactory.getCredentialFromFileCredentialStoreForInstalledApp | public Credential getCredentialFromFileCredentialStoreForInstalledApp(
String clientId,
String clientSecret,
String filePath,
List<String> scopes,
HttpTransport transport)
throws IOException, GeneralSecurityException {
"""
Initialized OAuth2 credential for the "installed application" flow; where the credential
typically represents an actual end user (instead of a service account), and is stored as a
refresh token in a local FileCredentialStore.
@param clientId OAuth2 client ID identifying the 'installed app'
@param clientSecret OAuth2 client secret
@param filePath full path to a ".json" file for storing the credential
@param scopes list of well-formed scopes desired in the credential
@param transport The HttpTransport used for authorization
@return credential with desired scopes, possibly obtained from loading {@code filePath}.
@throws IOException on IO error
"""
logger.atFine().log(
"getCredentialFromFileCredentialStoreForInstalledApp(%s, %s, %s, %s)",
clientId, clientSecret, filePath, scopes);
checkArgument(!isNullOrEmpty(clientId), "clientId must not be null or empty");
checkArgument(!isNullOrEmpty(clientSecret), "clientSecret must not be null or empty");
checkArgument(!isNullOrEmpty(filePath), "filePath must not be null or empty");
checkNotNull(scopes, "scopes must not be null");
// Initialize client secrets.
GoogleClientSecrets.Details details =
new GoogleClientSecrets.Details().setClientId(clientId).setClientSecret(clientSecret);
GoogleClientSecrets clientSecrets = new GoogleClientSecrets().setInstalled(details);
// Set up file credential store.
FileCredentialStore credentialStore = new FileCredentialStore(new File(filePath), JSON_FACTORY);
// Set up authorization code flow.
GoogleAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow.Builder(transport, JSON_FACTORY, clientSecrets, scopes)
.setCredentialStore(credentialStore)
.setRequestInitializer(new CredentialHttpRetryInitializer())
.setTokenServerUrl(new GenericUrl(TOKEN_SERVER_URL))
.build();
// Authorize access.
return new AuthorizationCodeInstalledApp(flow, new GooglePromptReceiver()).authorize("user");
} | java | public Credential getCredentialFromFileCredentialStoreForInstalledApp(
String clientId,
String clientSecret,
String filePath,
List<String> scopes,
HttpTransport transport)
throws IOException, GeneralSecurityException {
logger.atFine().log(
"getCredentialFromFileCredentialStoreForInstalledApp(%s, %s, %s, %s)",
clientId, clientSecret, filePath, scopes);
checkArgument(!isNullOrEmpty(clientId), "clientId must not be null or empty");
checkArgument(!isNullOrEmpty(clientSecret), "clientSecret must not be null or empty");
checkArgument(!isNullOrEmpty(filePath), "filePath must not be null or empty");
checkNotNull(scopes, "scopes must not be null");
// Initialize client secrets.
GoogleClientSecrets.Details details =
new GoogleClientSecrets.Details().setClientId(clientId).setClientSecret(clientSecret);
GoogleClientSecrets clientSecrets = new GoogleClientSecrets().setInstalled(details);
// Set up file credential store.
FileCredentialStore credentialStore = new FileCredentialStore(new File(filePath), JSON_FACTORY);
// Set up authorization code flow.
GoogleAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow.Builder(transport, JSON_FACTORY, clientSecrets, scopes)
.setCredentialStore(credentialStore)
.setRequestInitializer(new CredentialHttpRetryInitializer())
.setTokenServerUrl(new GenericUrl(TOKEN_SERVER_URL))
.build();
// Authorize access.
return new AuthorizationCodeInstalledApp(flow, new GooglePromptReceiver()).authorize("user");
} | [
"public",
"Credential",
"getCredentialFromFileCredentialStoreForInstalledApp",
"(",
"String",
"clientId",
",",
"String",
"clientSecret",
",",
"String",
"filePath",
",",
"List",
"<",
"String",
">",
"scopes",
",",
"HttpTransport",
"transport",
")",
"throws",
"IOException",
",",
"GeneralSecurityException",
"{",
"logger",
".",
"atFine",
"(",
")",
".",
"log",
"(",
"\"getCredentialFromFileCredentialStoreForInstalledApp(%s, %s, %s, %s)\"",
",",
"clientId",
",",
"clientSecret",
",",
"filePath",
",",
"scopes",
")",
";",
"checkArgument",
"(",
"!",
"isNullOrEmpty",
"(",
"clientId",
")",
",",
"\"clientId must not be null or empty\"",
")",
";",
"checkArgument",
"(",
"!",
"isNullOrEmpty",
"(",
"clientSecret",
")",
",",
"\"clientSecret must not be null or empty\"",
")",
";",
"checkArgument",
"(",
"!",
"isNullOrEmpty",
"(",
"filePath",
")",
",",
"\"filePath must not be null or empty\"",
")",
";",
"checkNotNull",
"(",
"scopes",
",",
"\"scopes must not be null\"",
")",
";",
"// Initialize client secrets.",
"GoogleClientSecrets",
".",
"Details",
"details",
"=",
"new",
"GoogleClientSecrets",
".",
"Details",
"(",
")",
".",
"setClientId",
"(",
"clientId",
")",
".",
"setClientSecret",
"(",
"clientSecret",
")",
";",
"GoogleClientSecrets",
"clientSecrets",
"=",
"new",
"GoogleClientSecrets",
"(",
")",
".",
"setInstalled",
"(",
"details",
")",
";",
"// Set up file credential store.",
"FileCredentialStore",
"credentialStore",
"=",
"new",
"FileCredentialStore",
"(",
"new",
"File",
"(",
"filePath",
")",
",",
"JSON_FACTORY",
")",
";",
"// Set up authorization code flow.",
"GoogleAuthorizationCodeFlow",
"flow",
"=",
"new",
"GoogleAuthorizationCodeFlow",
".",
"Builder",
"(",
"transport",
",",
"JSON_FACTORY",
",",
"clientSecrets",
",",
"scopes",
")",
".",
"setCredentialStore",
"(",
"credentialStore",
")",
".",
"setRequestInitializer",
"(",
"new",
"CredentialHttpRetryInitializer",
"(",
")",
")",
".",
"setTokenServerUrl",
"(",
"new",
"GenericUrl",
"(",
"TOKEN_SERVER_URL",
")",
")",
".",
"build",
"(",
")",
";",
"// Authorize access.",
"return",
"new",
"AuthorizationCodeInstalledApp",
"(",
"flow",
",",
"new",
"GooglePromptReceiver",
"(",
")",
")",
".",
"authorize",
"(",
"\"user\"",
")",
";",
"}"
] | Initialized OAuth2 credential for the "installed application" flow; where the credential
typically represents an actual end user (instead of a service account), and is stored as a
refresh token in a local FileCredentialStore.
@param clientId OAuth2 client ID identifying the 'installed app'
@param clientSecret OAuth2 client secret
@param filePath full path to a ".json" file for storing the credential
@param scopes list of well-formed scopes desired in the credential
@param transport The HttpTransport used for authorization
@return credential with desired scopes, possibly obtained from loading {@code filePath}.
@throws IOException on IO error | [
"Initialized",
"OAuth2",
"credential",
"for",
"the",
"installed",
"application",
"flow",
";",
"where",
"the",
"credential",
"typically",
"represents",
"an",
"actual",
"end",
"user",
"(",
"instead",
"of",
"a",
"service",
"account",
")",
"and",
"is",
"stored",
"as",
"a",
"refresh",
"token",
"in",
"a",
"local",
"FileCredentialStore",
"."
] | train | https://github.com/GoogleCloudPlatform/bigdata-interop/blob/918d91c80a63e36046edb28972a5c65d3326a858/util/src/main/java/com/google/cloud/hadoop/util/CredentialFactory.java#L325-L358 |
drewnoakes/metadata-extractor | Source/com/drew/metadata/eps/EpsReader.java | EpsReader.extractPhotoshopData | private static void extractPhotoshopData(@NotNull final Metadata metadata, @NotNull SequentialReader reader) throws IOException {
"""
Decodes a commented hex section, and uses {@link PhotoshopReader} to decode the resulting data.
"""
byte[] buffer = decodeHexCommentBlock(reader);
if (buffer != null)
new PhotoshopReader().extract(new SequentialByteArrayReader(buffer), buffer.length, metadata);
} | java | private static void extractPhotoshopData(@NotNull final Metadata metadata, @NotNull SequentialReader reader) throws IOException
{
byte[] buffer = decodeHexCommentBlock(reader);
if (buffer != null)
new PhotoshopReader().extract(new SequentialByteArrayReader(buffer), buffer.length, metadata);
} | [
"private",
"static",
"void",
"extractPhotoshopData",
"(",
"@",
"NotNull",
"final",
"Metadata",
"metadata",
",",
"@",
"NotNull",
"SequentialReader",
"reader",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"decodeHexCommentBlock",
"(",
"reader",
")",
";",
"if",
"(",
"buffer",
"!=",
"null",
")",
"new",
"PhotoshopReader",
"(",
")",
".",
"extract",
"(",
"new",
"SequentialByteArrayReader",
"(",
"buffer",
")",
",",
"buffer",
".",
"length",
",",
"metadata",
")",
";",
"}"
] | Decodes a commented hex section, and uses {@link PhotoshopReader} to decode the resulting data. | [
"Decodes",
"a",
"commented",
"hex",
"section",
"and",
"uses",
"{"
] | train | https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/eps/EpsReader.java#L232-L238 |
JodaOrg/joda-time | src/main/java/org/joda/time/DateTimeUtils.java | DateTimeUtils.setDefaultTimeZoneNames | public static final void setDefaultTimeZoneNames(Map<String, DateTimeZone> names) {
"""
Sets the default map of time zone names.
<p>
The map is copied before storage.
@param names the map of abbreviations to zones, not null
@since 2.2
"""
cZoneNames.set(Collections.unmodifiableMap(new HashMap<String, DateTimeZone>(names)));
} | java | public static final void setDefaultTimeZoneNames(Map<String, DateTimeZone> names) {
cZoneNames.set(Collections.unmodifiableMap(new HashMap<String, DateTimeZone>(names)));
} | [
"public",
"static",
"final",
"void",
"setDefaultTimeZoneNames",
"(",
"Map",
"<",
"String",
",",
"DateTimeZone",
">",
"names",
")",
"{",
"cZoneNames",
".",
"set",
"(",
"Collections",
".",
"unmodifiableMap",
"(",
"new",
"HashMap",
"<",
"String",
",",
"DateTimeZone",
">",
"(",
"names",
")",
")",
")",
";",
"}"
] | Sets the default map of time zone names.
<p>
The map is copied before storage.
@param names the map of abbreviations to zones, not null
@since 2.2 | [
"Sets",
"the",
"default",
"map",
"of",
"time",
"zone",
"names",
".",
"<p",
">",
"The",
"map",
"is",
"copied",
"before",
"storage",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/DateTimeUtils.java#L431-L433 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/brief/FactoryBriefDefinition.java | FactoryBriefDefinition.randomGaussian | private static void randomGaussian( Random rand , double sigma , int radius , Point2D_I32 pt ) {
"""
Randomly selects a point which is inside a square region using a Gaussian distribution.
"""
int x,y;
while( true ) {
x = (int)(rand.nextGaussian()*sigma);
y = (int)(rand.nextGaussian()*sigma);
if( Math.sqrt(x*x + y*y) < radius )
break;
}
pt.set(x,y);
} | java | private static void randomGaussian( Random rand , double sigma , int radius , Point2D_I32 pt ) {
int x,y;
while( true ) {
x = (int)(rand.nextGaussian()*sigma);
y = (int)(rand.nextGaussian()*sigma);
if( Math.sqrt(x*x + y*y) < radius )
break;
}
pt.set(x,y);
} | [
"private",
"static",
"void",
"randomGaussian",
"(",
"Random",
"rand",
",",
"double",
"sigma",
",",
"int",
"radius",
",",
"Point2D_I32",
"pt",
")",
"{",
"int",
"x",
",",
"y",
";",
"while",
"(",
"true",
")",
"{",
"x",
"=",
"(",
"int",
")",
"(",
"rand",
".",
"nextGaussian",
"(",
")",
"*",
"sigma",
")",
";",
"y",
"=",
"(",
"int",
")",
"(",
"rand",
".",
"nextGaussian",
"(",
")",
"*",
"sigma",
")",
";",
"if",
"(",
"Math",
".",
"sqrt",
"(",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
")",
"<",
"radius",
")",
"break",
";",
"}",
"pt",
".",
"set",
"(",
"x",
",",
"y",
")",
";",
"}"
] | Randomly selects a point which is inside a square region using a Gaussian distribution. | [
"Randomly",
"selects",
"a",
"point",
"which",
"is",
"inside",
"a",
"square",
"region",
"using",
"a",
"Gaussian",
"distribution",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/brief/FactoryBriefDefinition.java#L73-L85 |
Syncleus/aparapi | src/main/java/com/aparapi/Kernel.java | Kernel.atomicAdd | @OpenCLMapping(atomic32 = true)
protected int atomicAdd(int[] _arr, int _index, int _delta) {
"""
Atomically adds <code>_delta</code> value to <code>_index</code> element of array <code>_arr</code> (Java) or delegates to <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atomic_add.html">atomic_add(volatile int*, int)</a></code> (OpenCL).
@param _arr array for which an element value needs to be atomically incremented by <code>_delta</code>
@param _index index of the <code>_arr</code> array that needs to be atomically incremented by <code>_delta</code>
@param _delta value by which <code>_index</code> element of <code>_arr</code> array needs to be atomically incremented
@return previous value of <code>_index</code> element of <code>_arr</code> array
@see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atomic_add.html">atomic_add(volatile int*, int)</a></code>
"""
if (!Config.disableUnsafe) {
return UnsafeWrapper.atomicAdd(_arr, _index, _delta);
} else {
synchronized (_arr) {
final int previous = _arr[_index];
_arr[_index] += _delta;
return previous;
}
}
} | java | @OpenCLMapping(atomic32 = true)
protected int atomicAdd(int[] _arr, int _index, int _delta) {
if (!Config.disableUnsafe) {
return UnsafeWrapper.atomicAdd(_arr, _index, _delta);
} else {
synchronized (_arr) {
final int previous = _arr[_index];
_arr[_index] += _delta;
return previous;
}
}
} | [
"@",
"OpenCLMapping",
"(",
"atomic32",
"=",
"true",
")",
"protected",
"int",
"atomicAdd",
"(",
"int",
"[",
"]",
"_arr",
",",
"int",
"_index",
",",
"int",
"_delta",
")",
"{",
"if",
"(",
"!",
"Config",
".",
"disableUnsafe",
")",
"{",
"return",
"UnsafeWrapper",
".",
"atomicAdd",
"(",
"_arr",
",",
"_index",
",",
"_delta",
")",
";",
"}",
"else",
"{",
"synchronized",
"(",
"_arr",
")",
"{",
"final",
"int",
"previous",
"=",
"_arr",
"[",
"_index",
"]",
";",
"_arr",
"[",
"_index",
"]",
"+=",
"_delta",
";",
"return",
"previous",
";",
"}",
"}",
"}"
] | Atomically adds <code>_delta</code> value to <code>_index</code> element of array <code>_arr</code> (Java) or delegates to <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atomic_add.html">atomic_add(volatile int*, int)</a></code> (OpenCL).
@param _arr array for which an element value needs to be atomically incremented by <code>_delta</code>
@param _index index of the <code>_arr</code> array that needs to be atomically incremented by <code>_delta</code>
@param _delta value by which <code>_index</code> element of <code>_arr</code> array needs to be atomically incremented
@return previous value of <code>_index</code> element of <code>_arr</code> array
@see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atomic_add.html">atomic_add(volatile int*, int)</a></code> | [
"Atomically",
"adds",
"<code",
">",
"_delta<",
"/",
"code",
">",
"value",
"to",
"<code",
">",
"_index<",
"/",
"code",
">",
"element",
"of",
"array",
"<code",
">",
"_arr<",
"/",
"code",
">",
"(",
"Java",
")",
"or",
"delegates",
"to",
"<code",
">",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"khronos",
".",
"org",
"/",
"registry",
"/",
"cl",
"/",
"sdk",
"/",
"1",
".",
"1",
"/",
"docs",
"/",
"man",
"/",
"xhtml",
"/",
"atomic_add",
".",
"html",
">",
"atomic_add",
"(",
"volatile",
"int",
"*",
"int",
")",
"<",
"/",
"a",
">",
"<",
"/",
"code",
">",
"(",
"OpenCL",
")",
"."
] | train | https://github.com/Syncleus/aparapi/blob/6d5892c8e69854b3968c541023de37cf4762bd24/src/main/java/com/aparapi/Kernel.java#L2336-L2347 |
twitter/hraven | hraven-etl/src/main/java/com/twitter/hraven/etl/JobFilePartitioner.java | JobFilePartitioner.processHDFSSource | private void processHDFSSource(FileSystem hdfs, FileStatus f,
Path outputPath, Configuration conf, boolean skipExisting, boolean retain)
throws IOException {
"""
@param hdfs
FileSystem handle
@param f
file to process
@param outputPath
@param conf
configuration to use for copying.
@param skipExisting
skip if the file already exist in the target. File will be
overwritten if already there and this argument is false.
@retain whether this file should be retained
@throws IOException
"""
long fileModTime = f.getModificationTime();
Path targetDir = getTargetDirectory(hdfs, outputPath, fileModTime);
boolean targetExists = false;
Path target = new Path(targetDir, f.getPath().getName());
targetExists = hdfs.exists(target);
if (moveFiles || !retain) {
if (targetExists) {
hdfs.delete(f.getPath(), false);
} else {
hdfs.rename(f.getPath(), targetDir);
}
} else {
if (targetExists && skipExisting) {
// Do nothing, target is already there and we're instructed to skip
// existing records.
} else {
copy(hdfs, f, conf, targetDir);
}
}
} | java | private void processHDFSSource(FileSystem hdfs, FileStatus f,
Path outputPath, Configuration conf, boolean skipExisting, boolean retain)
throws IOException {
long fileModTime = f.getModificationTime();
Path targetDir = getTargetDirectory(hdfs, outputPath, fileModTime);
boolean targetExists = false;
Path target = new Path(targetDir, f.getPath().getName());
targetExists = hdfs.exists(target);
if (moveFiles || !retain) {
if (targetExists) {
hdfs.delete(f.getPath(), false);
} else {
hdfs.rename(f.getPath(), targetDir);
}
} else {
if (targetExists && skipExisting) {
// Do nothing, target is already there and we're instructed to skip
// existing records.
} else {
copy(hdfs, f, conf, targetDir);
}
}
} | [
"private",
"void",
"processHDFSSource",
"(",
"FileSystem",
"hdfs",
",",
"FileStatus",
"f",
",",
"Path",
"outputPath",
",",
"Configuration",
"conf",
",",
"boolean",
"skipExisting",
",",
"boolean",
"retain",
")",
"throws",
"IOException",
"{",
"long",
"fileModTime",
"=",
"f",
".",
"getModificationTime",
"(",
")",
";",
"Path",
"targetDir",
"=",
"getTargetDirectory",
"(",
"hdfs",
",",
"outputPath",
",",
"fileModTime",
")",
";",
"boolean",
"targetExists",
"=",
"false",
";",
"Path",
"target",
"=",
"new",
"Path",
"(",
"targetDir",
",",
"f",
".",
"getPath",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"targetExists",
"=",
"hdfs",
".",
"exists",
"(",
"target",
")",
";",
"if",
"(",
"moveFiles",
"||",
"!",
"retain",
")",
"{",
"if",
"(",
"targetExists",
")",
"{",
"hdfs",
".",
"delete",
"(",
"f",
".",
"getPath",
"(",
")",
",",
"false",
")",
";",
"}",
"else",
"{",
"hdfs",
".",
"rename",
"(",
"f",
".",
"getPath",
"(",
")",
",",
"targetDir",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"targetExists",
"&&",
"skipExisting",
")",
"{",
"// Do nothing, target is already there and we're instructed to skip",
"// existing records.",
"}",
"else",
"{",
"copy",
"(",
"hdfs",
",",
"f",
",",
"conf",
",",
"targetDir",
")",
";",
"}",
"}",
"}"
] | @param hdfs
FileSystem handle
@param f
file to process
@param outputPath
@param conf
configuration to use for copying.
@param skipExisting
skip if the file already exist in the target. File will be
overwritten if already there and this argument is false.
@retain whether this file should be retained
@throws IOException | [
"@param",
"hdfs",
"FileSystem",
"handle",
"@param",
"f",
"file",
"to",
"process",
"@param",
"outputPath",
"@param",
"conf",
"configuration",
"to",
"use",
"for",
"copying",
".",
"@param",
"skipExisting",
"skip",
"if",
"the",
"file",
"already",
"exist",
"in",
"the",
"target",
".",
"File",
"will",
"be",
"overwritten",
"if",
"already",
"there",
"and",
"this",
"argument",
"is",
"false",
".",
"@retain",
"whether",
"this",
"file",
"should",
"be",
"retained"
] | train | https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-etl/src/main/java/com/twitter/hraven/etl/JobFilePartitioner.java#L479-L504 |
aws/aws-sdk-java | aws-java-sdk-xray/src/main/java/com/amazonaws/services/xray/model/SamplingRule.java | SamplingRule.withAttributes | public SamplingRule withAttributes(java.util.Map<String, String> attributes) {
"""
<p>
Matches attributes derived from the request.
</p>
@param attributes
Matches attributes derived from the request.
@return Returns a reference to this object so that method calls can be chained together.
"""
setAttributes(attributes);
return this;
} | java | public SamplingRule withAttributes(java.util.Map<String, String> attributes) {
setAttributes(attributes);
return this;
} | [
"public",
"SamplingRule",
"withAttributes",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"attributes",
")",
"{",
"setAttributes",
"(",
"attributes",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Matches attributes derived from the request.
</p>
@param attributes
Matches attributes derived from the request.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Matches",
"attributes",
"derived",
"from",
"the",
"request",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-xray/src/main/java/com/amazonaws/services/xray/model/SamplingRule.java#L633-L636 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/system/systemuser_binding.java | systemuser_binding.get | public static systemuser_binding get(nitro_service service, String username) throws Exception {
"""
Use this API to fetch systemuser_binding resource of given name .
"""
systemuser_binding obj = new systemuser_binding();
obj.set_username(username);
systemuser_binding response = (systemuser_binding) obj.get_resource(service);
return response;
} | java | public static systemuser_binding get(nitro_service service, String username) throws Exception{
systemuser_binding obj = new systemuser_binding();
obj.set_username(username);
systemuser_binding response = (systemuser_binding) obj.get_resource(service);
return response;
} | [
"public",
"static",
"systemuser_binding",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"username",
")",
"throws",
"Exception",
"{",
"systemuser_binding",
"obj",
"=",
"new",
"systemuser_binding",
"(",
")",
";",
"obj",
".",
"set_username",
"(",
"username",
")",
";",
"systemuser_binding",
"response",
"=",
"(",
"systemuser_binding",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch systemuser_binding resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"systemuser_binding",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/system/systemuser_binding.java#L114-L119 |
Impetus/Kundera | src/jpa-engine/fallback-impl/src/main/java/com/impetus/kundera/index/LuceneIndexer.java | LuceneIndexer.updateDocument | public void updateDocument(String id, Document document, String EmbeddedEntityFieldName) {
"""
Indexes document in file system using lucene.
@param metadata
the metadata
@param document
the document
"""
if (log.isDebugEnabled())
{
log.debug("Updateing indexed document: {} for in file system using Lucene", document);
}
IndexWriter w = getIndexWriter();
try
{
Term term = null;
if (EmbeddedEntityFieldName == null)
{
term = new Term(IndexingConstants.ENTITY_ID_FIELD, id);
}
else
{
term = new Term(EmbeddedEntityFieldName, id);
}
w.updateDocument(term, document);
}
catch (LuceneIndexingException lie)
{
log.error("Error while updating LuceneIndexer, Caused by :.", lie);
throw new LuceneIndexingException(lie);
}
catch (IOException ioe)
{
log.error("Error while reading Lucene indexes, Caused by :.", ioe);
}
} | java | public void updateDocument(String id, Document document, String EmbeddedEntityFieldName)
{
if (log.isDebugEnabled())
{
log.debug("Updateing indexed document: {} for in file system using Lucene", document);
}
IndexWriter w = getIndexWriter();
try
{
Term term = null;
if (EmbeddedEntityFieldName == null)
{
term = new Term(IndexingConstants.ENTITY_ID_FIELD, id);
}
else
{
term = new Term(EmbeddedEntityFieldName, id);
}
w.updateDocument(term, document);
}
catch (LuceneIndexingException lie)
{
log.error("Error while updating LuceneIndexer, Caused by :.", lie);
throw new LuceneIndexingException(lie);
}
catch (IOException ioe)
{
log.error("Error while reading Lucene indexes, Caused by :.", ioe);
}
} | [
"public",
"void",
"updateDocument",
"(",
"String",
"id",
",",
"Document",
"document",
",",
"String",
"EmbeddedEntityFieldName",
")",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Updateing indexed document: {} for in file system using Lucene\"",
",",
"document",
")",
";",
"}",
"IndexWriter",
"w",
"=",
"getIndexWriter",
"(",
")",
";",
"try",
"{",
"Term",
"term",
"=",
"null",
";",
"if",
"(",
"EmbeddedEntityFieldName",
"==",
"null",
")",
"{",
"term",
"=",
"new",
"Term",
"(",
"IndexingConstants",
".",
"ENTITY_ID_FIELD",
",",
"id",
")",
";",
"}",
"else",
"{",
"term",
"=",
"new",
"Term",
"(",
"EmbeddedEntityFieldName",
",",
"id",
")",
";",
"}",
"w",
".",
"updateDocument",
"(",
"term",
",",
"document",
")",
";",
"}",
"catch",
"(",
"LuceneIndexingException",
"lie",
")",
"{",
"log",
".",
"error",
"(",
"\"Error while updating LuceneIndexer, Caused by :.\"",
",",
"lie",
")",
";",
"throw",
"new",
"LuceneIndexingException",
"(",
"lie",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"log",
".",
"error",
"(",
"\"Error while reading Lucene indexes, Caused by :.\"",
",",
"ioe",
")",
";",
"}",
"}"
] | Indexes document in file system using lucene.
@param metadata
the metadata
@param document
the document | [
"Indexes",
"document",
"in",
"file",
"system",
"using",
"lucene",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/fallback-impl/src/main/java/com/impetus/kundera/index/LuceneIndexer.java#L498-L530 |
SeleniumHQ/selenium | java/server/src/org/openqa/selenium/remote/server/xdrpc/CrossDomainRpcLoader.java | CrossDomainRpcLoader.loadRpc | public CrossDomainRpc loadRpc(HttpServletRequest request) throws IOException {
"""
Parses the request for a CrossDomainRpc.
@param request The request to parse.
@return The parsed RPC.
@throws IOException If an error occurs reading from the request.
@throws IllegalArgumentException If an occurs while parsing the request
data.
"""
Charset encoding;
try {
String enc = request.getCharacterEncoding();
encoding = Charset.forName(enc);
} catch (IllegalArgumentException | NullPointerException e) {
encoding = UTF_8;
}
// We tend to look at the input stream, rather than the reader.
try (InputStream in = request.getInputStream();
Reader reader = new InputStreamReader(in, encoding);
JsonInput jsonInput = json.newInput(reader)) {
Map<String, Object> read = jsonInput.read(MAP_TYPE);
return new CrossDomainRpc(
getField(read, Field.METHOD),
getField(read, Field.PATH),
getField(read, Field.DATA));
} catch (JsonException e) {
throw new IllegalArgumentException(
"Failed to parse JSON request: " + e.getMessage(), e);
}
} | java | public CrossDomainRpc loadRpc(HttpServletRequest request) throws IOException {
Charset encoding;
try {
String enc = request.getCharacterEncoding();
encoding = Charset.forName(enc);
} catch (IllegalArgumentException | NullPointerException e) {
encoding = UTF_8;
}
// We tend to look at the input stream, rather than the reader.
try (InputStream in = request.getInputStream();
Reader reader = new InputStreamReader(in, encoding);
JsonInput jsonInput = json.newInput(reader)) {
Map<String, Object> read = jsonInput.read(MAP_TYPE);
return new CrossDomainRpc(
getField(read, Field.METHOD),
getField(read, Field.PATH),
getField(read, Field.DATA));
} catch (JsonException e) {
throw new IllegalArgumentException(
"Failed to parse JSON request: " + e.getMessage(), e);
}
} | [
"public",
"CrossDomainRpc",
"loadRpc",
"(",
"HttpServletRequest",
"request",
")",
"throws",
"IOException",
"{",
"Charset",
"encoding",
";",
"try",
"{",
"String",
"enc",
"=",
"request",
".",
"getCharacterEncoding",
"(",
")",
";",
"encoding",
"=",
"Charset",
".",
"forName",
"(",
"enc",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"|",
"NullPointerException",
"e",
")",
"{",
"encoding",
"=",
"UTF_8",
";",
"}",
"// We tend to look at the input stream, rather than the reader.",
"try",
"(",
"InputStream",
"in",
"=",
"request",
".",
"getInputStream",
"(",
")",
";",
"Reader",
"reader",
"=",
"new",
"InputStreamReader",
"(",
"in",
",",
"encoding",
")",
";",
"JsonInput",
"jsonInput",
"=",
"json",
".",
"newInput",
"(",
"reader",
")",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"read",
"=",
"jsonInput",
".",
"read",
"(",
"MAP_TYPE",
")",
";",
"return",
"new",
"CrossDomainRpc",
"(",
"getField",
"(",
"read",
",",
"Field",
".",
"METHOD",
")",
",",
"getField",
"(",
"read",
",",
"Field",
".",
"PATH",
")",
",",
"getField",
"(",
"read",
",",
"Field",
".",
"DATA",
")",
")",
";",
"}",
"catch",
"(",
"JsonException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Failed to parse JSON request: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Parses the request for a CrossDomainRpc.
@param request The request to parse.
@return The parsed RPC.
@throws IOException If an error occurs reading from the request.
@throws IllegalArgumentException If an occurs while parsing the request
data. | [
"Parses",
"the",
"request",
"for",
"a",
"CrossDomainRpc",
"."
] | train | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/server/src/org/openqa/selenium/remote/server/xdrpc/CrossDomainRpcLoader.java#L52-L75 |
atomix/atomix | protocols/raft/src/main/java/io/atomix/protocols/raft/session/RaftSession.java | RaftSession.registerResult | public void registerResult(long sequence, OperationResult result) {
"""
Registers a session result.
<p>
Results are stored in memory on all servers in order to provide linearizable semantics. When a command
is applied to the state machine, the command's return value is stored with the sequence number. Once the
client acknowledges receipt of the command output the result will be cleared from memory.
@param sequence The result sequence number.
@param result The result.
"""
setRequestSequence(sequence);
results.put(sequence, result);
} | java | public void registerResult(long sequence, OperationResult result) {
setRequestSequence(sequence);
results.put(sequence, result);
} | [
"public",
"void",
"registerResult",
"(",
"long",
"sequence",
",",
"OperationResult",
"result",
")",
"{",
"setRequestSequence",
"(",
"sequence",
")",
";",
"results",
".",
"put",
"(",
"sequence",
",",
"result",
")",
";",
"}"
] | Registers a session result.
<p>
Results are stored in memory on all servers in order to provide linearizable semantics. When a command
is applied to the state machine, the command's return value is stored with the sequence number. Once the
client acknowledges receipt of the command output the result will be cleared from memory.
@param sequence The result sequence number.
@param result The result. | [
"Registers",
"a",
"session",
"result",
".",
"<p",
">",
"Results",
"are",
"stored",
"in",
"memory",
"on",
"all",
"servers",
"in",
"order",
"to",
"provide",
"linearizable",
"semantics",
".",
"When",
"a",
"command",
"is",
"applied",
"to",
"the",
"state",
"machine",
"the",
"command",
"s",
"return",
"value",
"is",
"stored",
"with",
"the",
"sequence",
"number",
".",
"Once",
"the",
"client",
"acknowledges",
"receipt",
"of",
"the",
"command",
"output",
"the",
"result",
"will",
"be",
"cleared",
"from",
"memory",
"."
] | train | https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/session/RaftSession.java#L383-L386 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/database/CursorUtils.java | CursorUtils.getBoolean | public static boolean getBoolean(Cursor cursor, String columnName) {
"""
Read the boolean data for the column.
@see android.database.Cursor#getColumnIndex(String).
@param cursor the cursor.
@param columnName the column name.
@return the boolean value.
"""
return cursor != null && cursor.getInt(cursor.getColumnIndex(columnName)) == TRUE;
} | java | public static boolean getBoolean(Cursor cursor, String columnName) {
return cursor != null && cursor.getInt(cursor.getColumnIndex(columnName)) == TRUE;
} | [
"public",
"static",
"boolean",
"getBoolean",
"(",
"Cursor",
"cursor",
",",
"String",
"columnName",
")",
"{",
"return",
"cursor",
"!=",
"null",
"&&",
"cursor",
".",
"getInt",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"columnName",
")",
")",
"==",
"TRUE",
";",
"}"
] | Read the boolean data for the column.
@see android.database.Cursor#getColumnIndex(String).
@param cursor the cursor.
@param columnName the column name.
@return the boolean value. | [
"Read",
"the",
"boolean",
"data",
"for",
"the",
"column",
"."
] | train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/database/CursorUtils.java#L52-L54 |
sirthias/parboiled | parboiled-core/src/main/java/org/parboiled/trees/TreeUtils.java | TreeUtils.addChild | public static <T extends MutableTreeNode<T>> void addChild(T parent, T child) {
"""
Adds a new child node to a given MutableTreeNode parent.
@param parent the parent node
@param child the child node to add
"""
checkArgNotNull(parent, "parent");
parent.addChild(parent.getChildren().size(), child);
} | java | public static <T extends MutableTreeNode<T>> void addChild(T parent, T child) {
checkArgNotNull(parent, "parent");
parent.addChild(parent.getChildren().size(), child);
} | [
"public",
"static",
"<",
"T",
"extends",
"MutableTreeNode",
"<",
"T",
">",
">",
"void",
"addChild",
"(",
"T",
"parent",
",",
"T",
"child",
")",
"{",
"checkArgNotNull",
"(",
"parent",
",",
"\"parent\"",
")",
";",
"parent",
".",
"addChild",
"(",
"parent",
".",
"getChildren",
"(",
")",
".",
"size",
"(",
")",
",",
"child",
")",
";",
"}"
] | Adds a new child node to a given MutableTreeNode parent.
@param parent the parent node
@param child the child node to add | [
"Adds",
"a",
"new",
"child",
"node",
"to",
"a",
"given",
"MutableTreeNode",
"parent",
"."
] | train | https://github.com/sirthias/parboiled/blob/84f3ed43e3e171b4c6ab5e6ca6297d264a9d686a/parboiled-core/src/main/java/org/parboiled/trees/TreeUtils.java#L46-L49 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/VerboseFormatter.java | VerboseFormatter.appendFunction | private static void appendFunction(StringBuilder message, LogRecord event) {
"""
Append function location.
@param message The message builder.
@param event The log record.
"""
final String clazz = event.getSourceClassName();
if (clazz != null)
{
message.append(IN).append(clazz);
}
final String function = event.getSourceMethodName();
if (function != null)
{
message.append(AT).append(function).append(Constant.DOUBLE_DOT);
}
} | java | private static void appendFunction(StringBuilder message, LogRecord event)
{
final String clazz = event.getSourceClassName();
if (clazz != null)
{
message.append(IN).append(clazz);
}
final String function = event.getSourceMethodName();
if (function != null)
{
message.append(AT).append(function).append(Constant.DOUBLE_DOT);
}
} | [
"private",
"static",
"void",
"appendFunction",
"(",
"StringBuilder",
"message",
",",
"LogRecord",
"event",
")",
"{",
"final",
"String",
"clazz",
"=",
"event",
".",
"getSourceClassName",
"(",
")",
";",
"if",
"(",
"clazz",
"!=",
"null",
")",
"{",
"message",
".",
"append",
"(",
"IN",
")",
".",
"append",
"(",
"clazz",
")",
";",
"}",
"final",
"String",
"function",
"=",
"event",
".",
"getSourceMethodName",
"(",
")",
";",
"if",
"(",
"function",
"!=",
"null",
")",
"{",
"message",
".",
"append",
"(",
"AT",
")",
".",
"append",
"(",
"function",
")",
".",
"append",
"(",
"Constant",
".",
"DOUBLE_DOT",
")",
";",
"}",
"}"
] | Append function location.
@param message The message builder.
@param event The log record. | [
"Append",
"function",
"location",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/VerboseFormatter.java#L74-L87 |
shekhargulati/strman-java | src/main/java/strman/Strman.java | Strman.ensureLeft | public static String ensureLeft(final String value, final String prefix) {
"""
Ensures that the value begins with prefix. If it doesn't exist, it's prepended. It is case sensitive.
@param value input
@param prefix prefix
@return string with prefix if it was not present.
"""
return ensureLeft(value, prefix, true);
} | java | public static String ensureLeft(final String value, final String prefix) {
return ensureLeft(value, prefix, true);
} | [
"public",
"static",
"String",
"ensureLeft",
"(",
"final",
"String",
"value",
",",
"final",
"String",
"prefix",
")",
"{",
"return",
"ensureLeft",
"(",
"value",
",",
"prefix",
",",
"true",
")",
";",
"}"
] | Ensures that the value begins with prefix. If it doesn't exist, it's prepended. It is case sensitive.
@param value input
@param prefix prefix
@return string with prefix if it was not present. | [
"Ensures",
"that",
"the",
"value",
"begins",
"with",
"prefix",
".",
"If",
"it",
"doesn",
"t",
"exist",
"it",
"s",
"prepended",
".",
"It",
"is",
"case",
"sensitive",
"."
] | train | https://github.com/shekhargulati/strman-java/blob/d0c2a10a6273fd6082f084e95156653ca55ce1be/src/main/java/strman/Strman.java#L300-L302 |
appium/java-client | src/main/java/io/appium/java_client/events/EventFiringWebDriverFactory.java | EventFiringWebDriverFactory.getEventFiringWebDriver | public static <T extends WebDriver> T getEventFiringWebDriver(T driver, Listener ... listeners) {
"""
This method makes an event firing instance of {@link org.openqa.selenium.WebDriver}.
@param driver an original instance of {@link org.openqa.selenium.WebDriver} that is
supposed to be listenable
@param listeners is a set of {@link io.appium.java_client.events.api.Listener} that
is supposed to be used for the event firing
@param <T> T
@return an instance of {@link org.openqa.selenium.WebDriver} that fires events
"""
return getEventFiringObject(driver, driver, listeners);
} | java | public static <T extends WebDriver> T getEventFiringWebDriver(T driver, Listener ... listeners) {
return getEventFiringObject(driver, driver, listeners);
} | [
"public",
"static",
"<",
"T",
"extends",
"WebDriver",
">",
"T",
"getEventFiringWebDriver",
"(",
"T",
"driver",
",",
"Listener",
"...",
"listeners",
")",
"{",
"return",
"getEventFiringObject",
"(",
"driver",
",",
"driver",
",",
"listeners",
")",
";",
"}"
] | This method makes an event firing instance of {@link org.openqa.selenium.WebDriver}.
@param driver an original instance of {@link org.openqa.selenium.WebDriver} that is
supposed to be listenable
@param listeners is a set of {@link io.appium.java_client.events.api.Listener} that
is supposed to be used for the event firing
@param <T> T
@return an instance of {@link org.openqa.selenium.WebDriver} that fires events | [
"This",
"method",
"makes",
"an",
"event",
"firing",
"instance",
"of",
"{",
"@link",
"org",
".",
"openqa",
".",
"selenium",
".",
"WebDriver",
"}",
"."
] | train | https://github.com/appium/java-client/blob/5a17759b05d6fda8ef425b3ab6e766c73ed2e8df/src/main/java/io/appium/java_client/events/EventFiringWebDriverFactory.java#L50-L52 |
nguillaumin/slick2d-maven | slick2d-examples/src/main/java/org/newdawn/slick/examples/scroller/Scroller.java | Scroller.tryMove | private boolean tryMove(float x, float y) {
"""
Try to move in the direction specified. If it's blocked, try sliding. If that
doesn't work just don't bother
@param x The amount on the X axis to move
@param y The amount on the Y axis to move
@return True if we managed to move
"""
float newx = playerX + x;
float newy = playerY + y;
// first we try the real move, if that doesn't work
// we try moving on just one of the axis (X and then Y)
// this allows us to slide against edges
if (blocked(newx,newy)) {
if (blocked(newx, playerY)) {
if (blocked(playerX, newy)) {
// can't move at all!
return false;
} else {
playerY = newy;
return true;
}
} else {
playerX = newx;
return true;
}
} else {
playerX = newx;
playerY = newy;
return true;
}
} | java | private boolean tryMove(float x, float y) {
float newx = playerX + x;
float newy = playerY + y;
// first we try the real move, if that doesn't work
// we try moving on just one of the axis (X and then Y)
// this allows us to slide against edges
if (blocked(newx,newy)) {
if (blocked(newx, playerY)) {
if (blocked(playerX, newy)) {
// can't move at all!
return false;
} else {
playerY = newy;
return true;
}
} else {
playerX = newx;
return true;
}
} else {
playerX = newx;
playerY = newy;
return true;
}
} | [
"private",
"boolean",
"tryMove",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"float",
"newx",
"=",
"playerX",
"+",
"x",
";",
"float",
"newy",
"=",
"playerY",
"+",
"y",
";",
"// first we try the real move, if that doesn't work\r",
"// we try moving on just one of the axis (X and then Y) \r",
"// this allows us to slide against edges\r",
"if",
"(",
"blocked",
"(",
"newx",
",",
"newy",
")",
")",
"{",
"if",
"(",
"blocked",
"(",
"newx",
",",
"playerY",
")",
")",
"{",
"if",
"(",
"blocked",
"(",
"playerX",
",",
"newy",
")",
")",
"{",
"// can't move at all!\r",
"return",
"false",
";",
"}",
"else",
"{",
"playerY",
"=",
"newy",
";",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"playerX",
"=",
"newx",
";",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"playerX",
"=",
"newx",
";",
"playerY",
"=",
"newy",
";",
"return",
"true",
";",
"}",
"}"
] | Try to move in the direction specified. If it's blocked, try sliding. If that
doesn't work just don't bother
@param x The amount on the X axis to move
@param y The amount on the Y axis to move
@return True if we managed to move | [
"Try",
"to",
"move",
"in",
"the",
"direction",
"specified",
".",
"If",
"it",
"s",
"blocked",
"try",
"sliding",
".",
"If",
"that",
"doesn",
"t",
"work",
"just",
"don",
"t",
"bother"
] | train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-examples/src/main/java/org/newdawn/slick/examples/scroller/Scroller.java#L160-L185 |
EsotericSoftware/kryo | src/com/esotericsoftware/kryo/util/Generics.java | Generics.pushTypeVariables | public int pushTypeVariables (GenericsHierarchy hierarchy, GenericType[] args) {
"""
Stores the types of the type parameters for the specified class hierarchy. Must be balanced by
{@link #popTypeVariables(int)} if >0 is returned.
@param args May contain null for type arguments that aren't known.
@return The number of entries that were pushed.
"""
int startSize = this.argumentsSize;
// Ensure arguments capacity.
int sizeNeeded = startSize + hierarchy.total;
if (sizeNeeded > arguments.length) {
Type[] newArray = new Type[Math.max(sizeNeeded, arguments.length << 1)];
System.arraycopy(arguments, 0, newArray, 0, startSize);
arguments = newArray;
}
// Resolve and store the type arguments.
int[] counts = hierarchy.counts;
TypeVariable[] params = hierarchy.parameters;
for (int i = 0, p = 0, n = args.length; i < n; i++) {
GenericType arg = args[i];
Class resolved = arg.resolve(this);
if (resolved == null) continue;
int count = counts[i];
if (arg == null)
p += count;
else {
for (int nn = p + count; p < nn; p++) {
arguments[argumentsSize] = params[p];
arguments[argumentsSize + 1] = resolved;
argumentsSize += 2;
}
}
}
return argumentsSize - startSize;
} | java | public int pushTypeVariables (GenericsHierarchy hierarchy, GenericType[] args) {
int startSize = this.argumentsSize;
// Ensure arguments capacity.
int sizeNeeded = startSize + hierarchy.total;
if (sizeNeeded > arguments.length) {
Type[] newArray = new Type[Math.max(sizeNeeded, arguments.length << 1)];
System.arraycopy(arguments, 0, newArray, 0, startSize);
arguments = newArray;
}
// Resolve and store the type arguments.
int[] counts = hierarchy.counts;
TypeVariable[] params = hierarchy.parameters;
for (int i = 0, p = 0, n = args.length; i < n; i++) {
GenericType arg = args[i];
Class resolved = arg.resolve(this);
if (resolved == null) continue;
int count = counts[i];
if (arg == null)
p += count;
else {
for (int nn = p + count; p < nn; p++) {
arguments[argumentsSize] = params[p];
arguments[argumentsSize + 1] = resolved;
argumentsSize += 2;
}
}
}
return argumentsSize - startSize;
} | [
"public",
"int",
"pushTypeVariables",
"(",
"GenericsHierarchy",
"hierarchy",
",",
"GenericType",
"[",
"]",
"args",
")",
"{",
"int",
"startSize",
"=",
"this",
".",
"argumentsSize",
";",
"// Ensure arguments capacity.",
"int",
"sizeNeeded",
"=",
"startSize",
"+",
"hierarchy",
".",
"total",
";",
"if",
"(",
"sizeNeeded",
">",
"arguments",
".",
"length",
")",
"{",
"Type",
"[",
"]",
"newArray",
"=",
"new",
"Type",
"[",
"Math",
".",
"max",
"(",
"sizeNeeded",
",",
"arguments",
".",
"length",
"<<",
"1",
")",
"]",
";",
"System",
".",
"arraycopy",
"(",
"arguments",
",",
"0",
",",
"newArray",
",",
"0",
",",
"startSize",
")",
";",
"arguments",
"=",
"newArray",
";",
"}",
"// Resolve and store the type arguments.",
"int",
"[",
"]",
"counts",
"=",
"hierarchy",
".",
"counts",
";",
"TypeVariable",
"[",
"]",
"params",
"=",
"hierarchy",
".",
"parameters",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"p",
"=",
"0",
",",
"n",
"=",
"args",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"GenericType",
"arg",
"=",
"args",
"[",
"i",
"]",
";",
"Class",
"resolved",
"=",
"arg",
".",
"resolve",
"(",
"this",
")",
";",
"if",
"(",
"resolved",
"==",
"null",
")",
"continue",
";",
"int",
"count",
"=",
"counts",
"[",
"i",
"]",
";",
"if",
"(",
"arg",
"==",
"null",
")",
"p",
"+=",
"count",
";",
"else",
"{",
"for",
"(",
"int",
"nn",
"=",
"p",
"+",
"count",
";",
"p",
"<",
"nn",
";",
"p",
"++",
")",
"{",
"arguments",
"[",
"argumentsSize",
"]",
"=",
"params",
"[",
"p",
"]",
";",
"arguments",
"[",
"argumentsSize",
"+",
"1",
"]",
"=",
"resolved",
";",
"argumentsSize",
"+=",
"2",
";",
"}",
"}",
"}",
"return",
"argumentsSize",
"-",
"startSize",
";",
"}"
] | Stores the types of the type parameters for the specified class hierarchy. Must be balanced by
{@link #popTypeVariables(int)} if >0 is returned.
@param args May contain null for type arguments that aren't known.
@return The number of entries that were pushed. | [
"Stores",
"the",
"types",
"of",
"the",
"type",
"parameters",
"for",
"the",
"specified",
"class",
"hierarchy",
".",
"Must",
"be",
"balanced",
"by",
"{"
] | train | https://github.com/EsotericSoftware/kryo/blob/a8be1ab26f347f299a3c3f7171d6447dd5390845/src/com/esotericsoftware/kryo/util/Generics.java#L119-L150 |
jglobus/JGlobus | io/src/main/java/org/globus/io/gass/server/JobOutputStream.java | JobOutputStream.write | public void write(byte[] b, int off, int len)
throws IOException {
"""
Converts the byte array to a string and forwards
it to the job output listener.
<BR>Called by the GassServer.
"""
String s = new String(b, off, len);
listener.outputChanged(s);
} | java | public void write(byte[] b, int off, int len)
throws IOException {
String s = new String(b, off, len);
listener.outputChanged(s);
} | [
"public",
"void",
"write",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"off",
",",
"int",
"len",
")",
"throws",
"IOException",
"{",
"String",
"s",
"=",
"new",
"String",
"(",
"b",
",",
"off",
",",
"len",
")",
";",
"listener",
".",
"outputChanged",
"(",
"s",
")",
";",
"}"
] | Converts the byte array to a string and forwards
it to the job output listener.
<BR>Called by the GassServer. | [
"Converts",
"the",
"byte",
"array",
"to",
"a",
"string",
"and",
"forwards",
"it",
"to",
"the",
"job",
"output",
"listener",
".",
"<BR",
">",
"Called",
"by",
"the",
"GassServer",
"."
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/io/src/main/java/org/globus/io/gass/server/JobOutputStream.java#L57-L61 |
Impetus/Kundera | src/jpa-engine/core/src/main/java/com/impetus/kundera/persistence/IdGenerator.java | IdGenerator.onSequenceGenerator | private Object onSequenceGenerator(EntityMetadata m, Client<?> client, IdDiscriptor keyValue, Object e) {
"""
Generate Id when given sequence generation strategy.
@param m
@param client
@param keyValue
@param e
"""
Object seqgenerator = getAutoGenClazz(client);
if (seqgenerator instanceof SequenceGenerator)
{
Object generatedId = ((SequenceGenerator) seqgenerator).generate(
keyValue.getSequenceDiscriptor(), client, m.getIdAttribute().getJavaType().getSimpleName());
try
{
generatedId = PropertyAccessorHelper.fromSourceToTargetClass(m.getIdAttribute().getJavaType(),
generatedId.getClass(), generatedId);
PropertyAccessorHelper.setId(e, m, generatedId);
return generatedId;
}
catch (IllegalArgumentException iae)
{
log.error("Unknown integral data type for ids : " + m.getIdAttribute().getJavaType());
throw new KunderaException("Unknown integral data type for ids : " + m.getIdAttribute().getJavaType(),
iae);
}
}
throw new IllegalArgumentException(GenerationType.class.getSimpleName() + "." + GenerationType.SEQUENCE
+ " Strategy not supported by this client :" + client.getClass().getName());
} | java | private Object onSequenceGenerator(EntityMetadata m, Client<?> client, IdDiscriptor keyValue, Object e)
{
Object seqgenerator = getAutoGenClazz(client);
if (seqgenerator instanceof SequenceGenerator)
{
Object generatedId = ((SequenceGenerator) seqgenerator).generate(
keyValue.getSequenceDiscriptor(), client, m.getIdAttribute().getJavaType().getSimpleName());
try
{
generatedId = PropertyAccessorHelper.fromSourceToTargetClass(m.getIdAttribute().getJavaType(),
generatedId.getClass(), generatedId);
PropertyAccessorHelper.setId(e, m, generatedId);
return generatedId;
}
catch (IllegalArgumentException iae)
{
log.error("Unknown integral data type for ids : " + m.getIdAttribute().getJavaType());
throw new KunderaException("Unknown integral data type for ids : " + m.getIdAttribute().getJavaType(),
iae);
}
}
throw new IllegalArgumentException(GenerationType.class.getSimpleName() + "." + GenerationType.SEQUENCE
+ " Strategy not supported by this client :" + client.getClass().getName());
} | [
"private",
"Object",
"onSequenceGenerator",
"(",
"EntityMetadata",
"m",
",",
"Client",
"<",
"?",
">",
"client",
",",
"IdDiscriptor",
"keyValue",
",",
"Object",
"e",
")",
"{",
"Object",
"seqgenerator",
"=",
"getAutoGenClazz",
"(",
"client",
")",
";",
"if",
"(",
"seqgenerator",
"instanceof",
"SequenceGenerator",
")",
"{",
"Object",
"generatedId",
"=",
"(",
"(",
"SequenceGenerator",
")",
"seqgenerator",
")",
".",
"generate",
"(",
"keyValue",
".",
"getSequenceDiscriptor",
"(",
")",
",",
"client",
",",
"m",
".",
"getIdAttribute",
"(",
")",
".",
"getJavaType",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"try",
"{",
"generatedId",
"=",
"PropertyAccessorHelper",
".",
"fromSourceToTargetClass",
"(",
"m",
".",
"getIdAttribute",
"(",
")",
".",
"getJavaType",
"(",
")",
",",
"generatedId",
".",
"getClass",
"(",
")",
",",
"generatedId",
")",
";",
"PropertyAccessorHelper",
".",
"setId",
"(",
"e",
",",
"m",
",",
"generatedId",
")",
";",
"return",
"generatedId",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"log",
".",
"error",
"(",
"\"Unknown integral data type for ids : \"",
"+",
"m",
".",
"getIdAttribute",
"(",
")",
".",
"getJavaType",
"(",
")",
")",
";",
"throw",
"new",
"KunderaException",
"(",
"\"Unknown integral data type for ids : \"",
"+",
"m",
".",
"getIdAttribute",
"(",
")",
".",
"getJavaType",
"(",
")",
",",
"iae",
")",
";",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"GenerationType",
".",
"class",
".",
"getSimpleName",
"(",
")",
"+",
"\".\"",
"+",
"GenerationType",
".",
"SEQUENCE",
"+",
"\" Strategy not supported by this client :\"",
"+",
"client",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Generate Id when given sequence generation strategy.
@param m
@param client
@param keyValue
@param e | [
"Generate",
"Id",
"when",
"given",
"sequence",
"generation",
"strategy",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/persistence/IdGenerator.java#L170-L193 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/RandomUtil.java | RandomUtil.randomDouble | public static double randomDouble(int scale, RoundingMode roundingMode) {
"""
获得指定范围内的随机数
@param scale 保留小数位数
@param roundingMode 保留小数的模式 {@link RoundingMode}
@return 随机数
@since 4.0.8
"""
return NumberUtil.round(randomDouble(), scale, roundingMode).doubleValue();
} | java | public static double randomDouble(int scale, RoundingMode roundingMode) {
return NumberUtil.round(randomDouble(), scale, roundingMode).doubleValue();
} | [
"public",
"static",
"double",
"randomDouble",
"(",
"int",
"scale",
",",
"RoundingMode",
"roundingMode",
")",
"{",
"return",
"NumberUtil",
".",
"round",
"(",
"randomDouble",
"(",
")",
",",
"scale",
",",
"roundingMode",
")",
".",
"doubleValue",
"(",
")",
";",
"}"
] | 获得指定范围内的随机数
@param scale 保留小数位数
@param roundingMode 保留小数的模式 {@link RoundingMode}
@return 随机数
@since 4.0.8 | [
"获得指定范围内的随机数"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/RandomUtil.java#L182-L184 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java | UtilLepetitEPnP.constraintMatrix3x3a | public static void constraintMatrix3x3a( DMatrixRMaj L_3x6 , DMatrixRMaj L_3x3 ) {
"""
Extracts the linear constraint matrix for case 1 from the full 6x10 constraint matrix.
"""
int index = 0;
for( int i = 0; i < 3; i++ ) {
L_3x3.data[index++] = L_3x6.get(i,0);
L_3x3.data[index++] = L_3x6.get(i,1);
L_3x3.data[index++] = L_3x6.get(i,2);
}
} | java | public static void constraintMatrix3x3a( DMatrixRMaj L_3x6 , DMatrixRMaj L_3x3 ) {
int index = 0;
for( int i = 0; i < 3; i++ ) {
L_3x3.data[index++] = L_3x6.get(i,0);
L_3x3.data[index++] = L_3x6.get(i,1);
L_3x3.data[index++] = L_3x6.get(i,2);
}
} | [
"public",
"static",
"void",
"constraintMatrix3x3a",
"(",
"DMatrixRMaj",
"L_3x6",
",",
"DMatrixRMaj",
"L_3x3",
")",
"{",
"int",
"index",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"L_3x3",
".",
"data",
"[",
"index",
"++",
"]",
"=",
"L_3x6",
".",
"get",
"(",
"i",
",",
"0",
")",
";",
"L_3x3",
".",
"data",
"[",
"index",
"++",
"]",
"=",
"L_3x6",
".",
"get",
"(",
"i",
",",
"1",
")",
";",
"L_3x3",
".",
"data",
"[",
"index",
"++",
"]",
"=",
"L_3x6",
".",
"get",
"(",
"i",
",",
"2",
")",
";",
"}",
"}"
] | Extracts the linear constraint matrix for case 1 from the full 6x10 constraint matrix. | [
"Extracts",
"the",
"linear",
"constraint",
"matrix",
"for",
"case",
"1",
"from",
"the",
"full",
"6x10",
"constraint",
"matrix",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java#L181-L189 |
UrielCh/ovh-java-sdk | ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java | ApiOvhCloud.project_serviceName_ip_failover_id_attach_POST | public OvhFailoverIp project_serviceName_ip_failover_id_attach_POST(String serviceName, String id, String instanceId) throws IOException {
"""
Attach failover ip to an instance
REST: POST /cloud/project/{serviceName}/ip/failover/{id}/attach
@param id [required] Ip id
@param instanceId [required] Attach failover ip to instance
@param serviceName [required] Project id
"""
String qPath = "/cloud/project/{serviceName}/ip/failover/{id}/attach";
StringBuilder sb = path(qPath, serviceName, id);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "instanceId", instanceId);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhFailoverIp.class);
} | java | public OvhFailoverIp project_serviceName_ip_failover_id_attach_POST(String serviceName, String id, String instanceId) throws IOException {
String qPath = "/cloud/project/{serviceName}/ip/failover/{id}/attach";
StringBuilder sb = path(qPath, serviceName, id);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "instanceId", instanceId);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhFailoverIp.class);
} | [
"public",
"OvhFailoverIp",
"project_serviceName_ip_failover_id_attach_POST",
"(",
"String",
"serviceName",
",",
"String",
"id",
",",
"String",
"instanceId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/project/{serviceName}/ip/failover/{id}/attach\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"id",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"instanceId\"",
",",
"instanceId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhFailoverIp",
".",
"class",
")",
";",
"}"
] | Attach failover ip to an instance
REST: POST /cloud/project/{serviceName}/ip/failover/{id}/attach
@param id [required] Ip id
@param instanceId [required] Attach failover ip to instance
@param serviceName [required] Project id | [
"Attach",
"failover",
"ip",
"to",
"an",
"instance"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L1293-L1300 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.jms.common/src/com/ibm/ws/sib/ra/impl/SibRaConnection.java | SibRaConnection.createProducerSession | @Override
public ProducerSession createProducerSession(
final SIDestinationAddress destAddr,
final DestinationType destType,
final OrderingContext orderingContext, final String alternateUser)
throws SIConnectionDroppedException,
SIConnectionUnavailableException, SIConnectionLostException,
SILimitExceededException, SINotAuthorizedException,
SITemporaryDestinationNotFoundException, SIResourceException,
SIErrorException, SINotPossibleInCurrentConfigurationException,
SIIncorrectCallException {
"""
Creates a producer session. Checks that the connection is valid and then
delegates. Wraps the <code>ProducerSession</code> returned from the
delegate in a <code>SibRaProducerSession</code>.
@param destAddr
the address of the destination
@param destType
the destination type
@param orderingContext
indicates that the order of messages from multiple
ProducerSessions should be preserved
@param alternateUser
the name of the user under whose authority operations of the
ProducerSession should be performed (may be null)
@return the producer session
@throws SIIncorrectCallException
if the delegation fails
@throws SINotPossibleInCurrentConfigurationException
if the delegation fails
@throws SIErrorException
if the delegation fails
@throws SIResourceException
if the delegation fails
@throws SITemporaryDestinationNotFoundException
if the delegation fails
@throws SINotAuthorizedException
if the delegation fails
@throws SILimitExceededException
if the delegation fails
@throws SIConnectionLostException
if the delegation fails
@throws SIConnectionUnavailableException
if the connection is not valid
@throws SIConnectionDroppedException
if the delegation fails
"""
checkValid();
final ProducerSession session = _delegateConnection
.createProducerSession(destAddr, destType, orderingContext,
alternateUser);
return new SibRaProducerSession(this, session);
} | java | @Override
public ProducerSession createProducerSession(
final SIDestinationAddress destAddr,
final DestinationType destType,
final OrderingContext orderingContext, final String alternateUser)
throws SIConnectionDroppedException,
SIConnectionUnavailableException, SIConnectionLostException,
SILimitExceededException, SINotAuthorizedException,
SITemporaryDestinationNotFoundException, SIResourceException,
SIErrorException, SINotPossibleInCurrentConfigurationException,
SIIncorrectCallException {
checkValid();
final ProducerSession session = _delegateConnection
.createProducerSession(destAddr, destType, orderingContext,
alternateUser);
return new SibRaProducerSession(this, session);
} | [
"@",
"Override",
"public",
"ProducerSession",
"createProducerSession",
"(",
"final",
"SIDestinationAddress",
"destAddr",
",",
"final",
"DestinationType",
"destType",
",",
"final",
"OrderingContext",
"orderingContext",
",",
"final",
"String",
"alternateUser",
")",
"throws",
"SIConnectionDroppedException",
",",
"SIConnectionUnavailableException",
",",
"SIConnectionLostException",
",",
"SILimitExceededException",
",",
"SINotAuthorizedException",
",",
"SITemporaryDestinationNotFoundException",
",",
"SIResourceException",
",",
"SIErrorException",
",",
"SINotPossibleInCurrentConfigurationException",
",",
"SIIncorrectCallException",
"{",
"checkValid",
"(",
")",
";",
"final",
"ProducerSession",
"session",
"=",
"_delegateConnection",
".",
"createProducerSession",
"(",
"destAddr",
",",
"destType",
",",
"orderingContext",
",",
"alternateUser",
")",
";",
"return",
"new",
"SibRaProducerSession",
"(",
"this",
",",
"session",
")",
";",
"}"
] | Creates a producer session. Checks that the connection is valid and then
delegates. Wraps the <code>ProducerSession</code> returned from the
delegate in a <code>SibRaProducerSession</code>.
@param destAddr
the address of the destination
@param destType
the destination type
@param orderingContext
indicates that the order of messages from multiple
ProducerSessions should be preserved
@param alternateUser
the name of the user under whose authority operations of the
ProducerSession should be performed (may be null)
@return the producer session
@throws SIIncorrectCallException
if the delegation fails
@throws SINotPossibleInCurrentConfigurationException
if the delegation fails
@throws SIErrorException
if the delegation fails
@throws SIResourceException
if the delegation fails
@throws SITemporaryDestinationNotFoundException
if the delegation fails
@throws SINotAuthorizedException
if the delegation fails
@throws SILimitExceededException
if the delegation fails
@throws SIConnectionLostException
if the delegation fails
@throws SIConnectionUnavailableException
if the connection is not valid
@throws SIConnectionDroppedException
if the delegation fails | [
"Creates",
"a",
"producer",
"session",
".",
"Checks",
"that",
"the",
"connection",
"is",
"valid",
"and",
"then",
"delegates",
".",
"Wraps",
"the",
"<code",
">",
"ProducerSession<",
"/",
"code",
">",
"returned",
"from",
"the",
"delegate",
"in",
"a",
"<code",
">",
"SibRaProducerSession<",
"/",
"code",
">",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.jms.common/src/com/ibm/ws/sib/ra/impl/SibRaConnection.java#L514-L534 |
jbundle/jbundle | thin/base/screen/util/src/main/java/org/jbundle/thin/base/screen/util/JFSTextScroller.java | JFSTextScroller.init | public void init(Object text) {
"""
Creates new JThreeStateCheckBox.
@param text The checkbox description.
"""
this.setOpaque(false);
this.setPreferredSize(PREFERRED_SIZE);
int rows = 1;
int cols = 30;
m_control = new JTextArea(rows, cols);
m_control.setBorder(null); // No border inside a scroller.
JScrollPane scrollpane = new JScrollPane(m_control, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
this.setLayout(new BorderLayout());
this.add(scrollpane);
this.setControlValue(text);
m_control.addKeyListener(this);
} | java | public void init(Object text)
{
this.setOpaque(false);
this.setPreferredSize(PREFERRED_SIZE);
int rows = 1;
int cols = 30;
m_control = new JTextArea(rows, cols);
m_control.setBorder(null); // No border inside a scroller.
JScrollPane scrollpane = new JScrollPane(m_control, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
this.setLayout(new BorderLayout());
this.add(scrollpane);
this.setControlValue(text);
m_control.addKeyListener(this);
} | [
"public",
"void",
"init",
"(",
"Object",
"text",
")",
"{",
"this",
".",
"setOpaque",
"(",
"false",
")",
";",
"this",
".",
"setPreferredSize",
"(",
"PREFERRED_SIZE",
")",
";",
"int",
"rows",
"=",
"1",
";",
"int",
"cols",
"=",
"30",
";",
"m_control",
"=",
"new",
"JTextArea",
"(",
"rows",
",",
"cols",
")",
";",
"m_control",
".",
"setBorder",
"(",
"null",
")",
";",
"// No border inside a scroller.",
"JScrollPane",
"scrollpane",
"=",
"new",
"JScrollPane",
"(",
"m_control",
",",
"ScrollPaneConstants",
".",
"VERTICAL_SCROLLBAR_AS_NEEDED",
",",
"ScrollPaneConstants",
".",
"HORIZONTAL_SCROLLBAR_AS_NEEDED",
")",
";",
"this",
".",
"setLayout",
"(",
"new",
"BorderLayout",
"(",
")",
")",
";",
"this",
".",
"add",
"(",
"scrollpane",
")",
";",
"this",
".",
"setControlValue",
"(",
"text",
")",
";",
"m_control",
".",
"addKeyListener",
"(",
"this",
")",
";",
"}"
] | Creates new JThreeStateCheckBox.
@param text The checkbox description. | [
"Creates",
"new",
"JThreeStateCheckBox",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/util/src/main/java/org/jbundle/thin/base/screen/util/JFSTextScroller.java#L71-L84 |
ixa-ehu/ixa-pipe-pos | src/main/java/eus/ixa/ixa/pipe/pos/dict/MultiWordMatcher.java | MultiWordMatcher.getMultiWordDict | private final InputStream getMultiWordDict(final String lang, final String resourcesDirectory) {
"""
Get the dictionary for the {@code MultiWordMatcher}.
@param lang
the language
@param resourcesDirectory
the directory where the dictionary can be found.
If {@code null}, load from package resources.
@return the inputstream of the dictionary
"""
return resourcesDirectory == null
? getMultiWordDictFromResources(lang)
: getMultiWordDictFromDirectory(lang, resourcesDirectory);
} | java | private final InputStream getMultiWordDict(final String lang, final String resourcesDirectory) {
return resourcesDirectory == null
? getMultiWordDictFromResources(lang)
: getMultiWordDictFromDirectory(lang, resourcesDirectory);
} | [
"private",
"final",
"InputStream",
"getMultiWordDict",
"(",
"final",
"String",
"lang",
",",
"final",
"String",
"resourcesDirectory",
")",
"{",
"return",
"resourcesDirectory",
"==",
"null",
"?",
"getMultiWordDictFromResources",
"(",
"lang",
")",
":",
"getMultiWordDictFromDirectory",
"(",
"lang",
",",
"resourcesDirectory",
")",
";",
"}"
] | Get the dictionary for the {@code MultiWordMatcher}.
@param lang
the language
@param resourcesDirectory
the directory where the dictionary can be found.
If {@code null}, load from package resources.
@return the inputstream of the dictionary | [
"Get",
"the",
"dictionary",
"for",
"the",
"{",
"@code",
"MultiWordMatcher",
"}",
"."
] | train | https://github.com/ixa-ehu/ixa-pipe-pos/blob/083c986103f95ae8063b8ddc89a2caa8047d29b9/src/main/java/eus/ixa/ixa/pipe/pos/dict/MultiWordMatcher.java#L115-L119 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.listPrebuiltEntities | public List<AvailablePrebuiltEntityModel> listPrebuiltEntities(UUID appId, String versionId) {
"""
Gets all the available prebuilt entity extractors for the application.
@param appId The application ID.
@param versionId The version ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<AvailablePrebuiltEntityModel> object if successful.
"""
return listPrebuiltEntitiesWithServiceResponseAsync(appId, versionId).toBlocking().single().body();
} | java | public List<AvailablePrebuiltEntityModel> listPrebuiltEntities(UUID appId, String versionId) {
return listPrebuiltEntitiesWithServiceResponseAsync(appId, versionId).toBlocking().single().body();
} | [
"public",
"List",
"<",
"AvailablePrebuiltEntityModel",
">",
"listPrebuiltEntities",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
")",
"{",
"return",
"listPrebuiltEntitiesWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Gets all the available prebuilt entity extractors for the application.
@param appId The application ID.
@param versionId The version ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<AvailablePrebuiltEntityModel> object if successful. | [
"Gets",
"all",
"the",
"available",
"prebuilt",
"entity",
"extractors",
"for",
"the",
"application",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L2359-L2361 |
groupon/odo | proxylib/src/main/java/com/groupon/odo/proxylib/OverrideService.java | OverrideService.disableAllOverrides | public void disableAllOverrides(int pathID, String clientUUID) {
"""
Disable all overrides for a specified path
@param pathID ID of path containing overrides
@param clientUUID UUID of client
"""
PreparedStatement statement = null;
try (Connection sqlConnection = sqlService.getConnection()) {
statement = sqlConnection.prepareStatement(
"DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE +
" WHERE " + Constants.ENABLED_OVERRIDES_PATH_ID + " = ? " +
" AND " + Constants.GENERIC_CLIENT_UUID + " = ? "
);
statement.setInt(1, pathID);
statement.setString(2, clientUUID);
statement.execute();
statement.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (Exception e) {
}
}
} | java | public void disableAllOverrides(int pathID, String clientUUID) {
PreparedStatement statement = null;
try (Connection sqlConnection = sqlService.getConnection()) {
statement = sqlConnection.prepareStatement(
"DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE +
" WHERE " + Constants.ENABLED_OVERRIDES_PATH_ID + " = ? " +
" AND " + Constants.GENERIC_CLIENT_UUID + " = ? "
);
statement.setInt(1, pathID);
statement.setString(2, clientUUID);
statement.execute();
statement.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (Exception e) {
}
}
} | [
"public",
"void",
"disableAllOverrides",
"(",
"int",
"pathID",
",",
"String",
"clientUUID",
")",
"{",
"PreparedStatement",
"statement",
"=",
"null",
";",
"try",
"(",
"Connection",
"sqlConnection",
"=",
"sqlService",
".",
"getConnection",
"(",
")",
")",
"{",
"statement",
"=",
"sqlConnection",
".",
"prepareStatement",
"(",
"\"DELETE FROM \"",
"+",
"Constants",
".",
"DB_TABLE_ENABLED_OVERRIDE",
"+",
"\" WHERE \"",
"+",
"Constants",
".",
"ENABLED_OVERRIDES_PATH_ID",
"+",
"\" = ? \"",
"+",
"\" AND \"",
"+",
"Constants",
".",
"GENERIC_CLIENT_UUID",
"+",
"\" = ? \"",
")",
";",
"statement",
".",
"setInt",
"(",
"1",
",",
"pathID",
")",
";",
"statement",
".",
"setString",
"(",
"2",
",",
"clientUUID",
")",
";",
"statement",
".",
"execute",
"(",
")",
";",
"statement",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"statement",
"!=",
"null",
")",
"{",
"statement",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"}"
] | Disable all overrides for a specified path
@param pathID ID of path containing overrides
@param clientUUID UUID of client | [
"Disable",
"all",
"overrides",
"for",
"a",
"specified",
"path"
] | train | https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/OverrideService.java#L528-L550 |
brettwooldridge/HikariCP | src/main/java/com/zaxxer/hikari/util/UtilityElf.java | UtilityElf.createThreadPoolExecutor | public static ThreadPoolExecutor createThreadPoolExecutor(final int queueSize, final String threadName, ThreadFactory threadFactory, final RejectedExecutionHandler policy) {
"""
Create a ThreadPoolExecutor.
@param queueSize the queue size
@param threadName the thread name
@param threadFactory an optional ThreadFactory
@param policy the RejectedExecutionHandler policy
@return a ThreadPoolExecutor
"""
if (threadFactory == null) {
threadFactory = new DefaultThreadFactory(threadName, true);
}
LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(queueSize);
ThreadPoolExecutor executor = new ThreadPoolExecutor(1 /*core*/, 1 /*max*/, 5 /*keepalive*/, SECONDS, queue, threadFactory, policy);
executor.allowCoreThreadTimeOut(true);
return executor;
} | java | public static ThreadPoolExecutor createThreadPoolExecutor(final int queueSize, final String threadName, ThreadFactory threadFactory, final RejectedExecutionHandler policy)
{
if (threadFactory == null) {
threadFactory = new DefaultThreadFactory(threadName, true);
}
LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(queueSize);
ThreadPoolExecutor executor = new ThreadPoolExecutor(1 /*core*/, 1 /*max*/, 5 /*keepalive*/, SECONDS, queue, threadFactory, policy);
executor.allowCoreThreadTimeOut(true);
return executor;
} | [
"public",
"static",
"ThreadPoolExecutor",
"createThreadPoolExecutor",
"(",
"final",
"int",
"queueSize",
",",
"final",
"String",
"threadName",
",",
"ThreadFactory",
"threadFactory",
",",
"final",
"RejectedExecutionHandler",
"policy",
")",
"{",
"if",
"(",
"threadFactory",
"==",
"null",
")",
"{",
"threadFactory",
"=",
"new",
"DefaultThreadFactory",
"(",
"threadName",
",",
"true",
")",
";",
"}",
"LinkedBlockingQueue",
"<",
"Runnable",
">",
"queue",
"=",
"new",
"LinkedBlockingQueue",
"<>",
"(",
"queueSize",
")",
";",
"ThreadPoolExecutor",
"executor",
"=",
"new",
"ThreadPoolExecutor",
"(",
"1",
"/*core*/",
",",
"1",
"/*max*/",
",",
"5",
"/*keepalive*/",
",",
"SECONDS",
",",
"queue",
",",
"threadFactory",
",",
"policy",
")",
";",
"executor",
".",
"allowCoreThreadTimeOut",
"(",
"true",
")",
";",
"return",
"executor",
";",
"}"
] | Create a ThreadPoolExecutor.
@param queueSize the queue size
@param threadName the thread name
@param threadFactory an optional ThreadFactory
@param policy the RejectedExecutionHandler policy
@return a ThreadPoolExecutor | [
"Create",
"a",
"ThreadPoolExecutor",
"."
] | train | https://github.com/brettwooldridge/HikariCP/blob/c509ec1a3f1e19769ee69323972f339cf098ff4b/src/main/java/com/zaxxer/hikari/util/UtilityElf.java#L125-L135 |
line/centraldogma | server/src/main/java/com/linecorp/centraldogma/server/internal/metadata/MetadataService.java | MetadataService.ensureProjectMember | private static void ensureProjectMember(ProjectMetadata project, User user) {
"""
Ensures that the specified {@code user} is a member of the specified {@code project}.
"""
requireNonNull(project, "project");
requireNonNull(user, "user");
checkArgument(project.members().values().stream().anyMatch(member -> member.login().equals(user.id())),
user.id() + " is not a member of the project " + project.name());
} | java | private static void ensureProjectMember(ProjectMetadata project, User user) {
requireNonNull(project, "project");
requireNonNull(user, "user");
checkArgument(project.members().values().stream().anyMatch(member -> member.login().equals(user.id())),
user.id() + " is not a member of the project " + project.name());
} | [
"private",
"static",
"void",
"ensureProjectMember",
"(",
"ProjectMetadata",
"project",
",",
"User",
"user",
")",
"{",
"requireNonNull",
"(",
"project",
",",
"\"project\"",
")",
";",
"requireNonNull",
"(",
"user",
",",
"\"user\"",
")",
";",
"checkArgument",
"(",
"project",
".",
"members",
"(",
")",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"member",
"->",
"member",
".",
"login",
"(",
")",
".",
"equals",
"(",
"user",
".",
"id",
"(",
")",
")",
")",
",",
"user",
".",
"id",
"(",
")",
"+",
"\" is not a member of the project \"",
"+",
"project",
".",
"name",
"(",
")",
")",
";",
"}"
] | Ensures that the specified {@code user} is a member of the specified {@code project}. | [
"Ensures",
"that",
"the",
"specified",
"{"
] | train | https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/metadata/MetadataService.java#L860-L866 |
inkstand-io/scribble | scribble-jcr/src/main/java/io/inkstand/scribble/jcr/rules/util/XMLContentHandler.java | XMLContentHandler.startElementMixin | private void startElementMixin(final Attributes attributes) {
"""
Invoked on mixin element.
@param attributes
the DOM attributes of the mixin element
@throws SAXException
if the mixin type can not be added
"""
LOG.debug("Found mixin declaration");
try {
this.addMixin(this.nodeStack.peek(), attributes);
} catch (final RepositoryException e) {
throw new AssertionError("Could not add mixin type", e);
}
} | java | private void startElementMixin(final Attributes attributes) {
LOG.debug("Found mixin declaration");
try {
this.addMixin(this.nodeStack.peek(), attributes);
} catch (final RepositoryException e) {
throw new AssertionError("Could not add mixin type", e);
}
} | [
"private",
"void",
"startElementMixin",
"(",
"final",
"Attributes",
"attributes",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Found mixin declaration\"",
")",
";",
"try",
"{",
"this",
".",
"addMixin",
"(",
"this",
".",
"nodeStack",
".",
"peek",
"(",
")",
",",
"attributes",
")",
";",
"}",
"catch",
"(",
"final",
"RepositoryException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"\"Could not add mixin type\"",
",",
"e",
")",
";",
"}",
"}"
] | Invoked on mixin element.
@param attributes
the DOM attributes of the mixin element
@throws SAXException
if the mixin type can not be added | [
"Invoked",
"on",
"mixin",
"element",
"."
] | train | https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/rules/util/XMLContentHandler.java#L373-L381 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java | AppServiceEnvironmentsInner.beginCreateOrUpdate | public AppServiceEnvironmentResourceInner beginCreateOrUpdate(String resourceGroupName, String name, AppServiceEnvironmentResourceInner hostingEnvironmentEnvelope) {
"""
Create or update an App Service Environment.
Create or update an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@param hostingEnvironmentEnvelope Configuration details of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the AppServiceEnvironmentResourceInner object if successful.
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, name, hostingEnvironmentEnvelope).toBlocking().single().body();
} | java | public AppServiceEnvironmentResourceInner beginCreateOrUpdate(String resourceGroupName, String name, AppServiceEnvironmentResourceInner hostingEnvironmentEnvelope) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, name, hostingEnvironmentEnvelope).toBlocking().single().body();
} | [
"public",
"AppServiceEnvironmentResourceInner",
"beginCreateOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"name",
",",
"AppServiceEnvironmentResourceInner",
"hostingEnvironmentEnvelope",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
",",
"hostingEnvironmentEnvelope",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Create or update an App Service Environment.
Create or update an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@param hostingEnvironmentEnvelope Configuration details of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the AppServiceEnvironmentResourceInner object if successful. | [
"Create",
"or",
"update",
"an",
"App",
"Service",
"Environment",
".",
"Create",
"or",
"update",
"an",
"App",
"Service",
"Environment",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L767-L769 |
aws/aws-sdk-java | aws-java-sdk-glue/src/main/java/com/amazonaws/services/glue/model/Action.java | Action.withArguments | public Action withArguments(java.util.Map<String, String> arguments) {
"""
<p>
The job arguments used when this trigger fires. For this job run, they replace the default arguments set in the
job definition itself.
</p>
<p>
You can specify arguments here that your own job-execution script consumes, as well as arguments that AWS Glue
itself consumes.
</p>
<p>
For information about how to specify and consume your own Job arguments, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-python-calling.html">Calling AWS Glue APIs
in Python</a> topic in the developer guide.
</p>
<p>
For information about the key-value pairs that AWS Glue consumes to set up your job, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html">Special Parameters
Used by AWS Glue</a> topic in the developer guide.
</p>
@param arguments
The job arguments used when this trigger fires. For this job run, they replace the default arguments set
in the job definition itself.</p>
<p>
You can specify arguments here that your own job-execution script consumes, as well as arguments that AWS
Glue itself consumes.
</p>
<p>
For information about how to specify and consume your own Job arguments, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-python-calling.html">Calling AWS Glue
APIs in Python</a> topic in the developer guide.
</p>
<p>
For information about the key-value pairs that AWS Glue consumes to set up your job, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html">Special
Parameters Used by AWS Glue</a> topic in the developer guide.
@return Returns a reference to this object so that method calls can be chained together.
"""
setArguments(arguments);
return this;
} | java | public Action withArguments(java.util.Map<String, String> arguments) {
setArguments(arguments);
return this;
} | [
"public",
"Action",
"withArguments",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"arguments",
")",
"{",
"setArguments",
"(",
"arguments",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The job arguments used when this trigger fires. For this job run, they replace the default arguments set in the
job definition itself.
</p>
<p>
You can specify arguments here that your own job-execution script consumes, as well as arguments that AWS Glue
itself consumes.
</p>
<p>
For information about how to specify and consume your own Job arguments, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-python-calling.html">Calling AWS Glue APIs
in Python</a> topic in the developer guide.
</p>
<p>
For information about the key-value pairs that AWS Glue consumes to set up your job, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html">Special Parameters
Used by AWS Glue</a> topic in the developer guide.
</p>
@param arguments
The job arguments used when this trigger fires. For this job run, they replace the default arguments set
in the job definition itself.</p>
<p>
You can specify arguments here that your own job-execution script consumes, as well as arguments that AWS
Glue itself consumes.
</p>
<p>
For information about how to specify and consume your own Job arguments, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-python-calling.html">Calling AWS Glue
APIs in Python</a> topic in the developer guide.
</p>
<p>
For information about the key-value pairs that AWS Glue consumes to set up your job, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html">Special
Parameters Used by AWS Glue</a> topic in the developer guide.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"job",
"arguments",
"used",
"when",
"this",
"trigger",
"fires",
".",
"For",
"this",
"job",
"run",
"they",
"replace",
"the",
"default",
"arguments",
"set",
"in",
"the",
"job",
"definition",
"itself",
".",
"<",
"/",
"p",
">",
"<p",
">",
"You",
"can",
"specify",
"arguments",
"here",
"that",
"your",
"own",
"job",
"-",
"execution",
"script",
"consumes",
"as",
"well",
"as",
"arguments",
"that",
"AWS",
"Glue",
"itself",
"consumes",
".",
"<",
"/",
"p",
">",
"<p",
">",
"For",
"information",
"about",
"how",
"to",
"specify",
"and",
"consume",
"your",
"own",
"Job",
"arguments",
"see",
"the",
"<a",
"href",
"=",
"http",
":",
"//",
"docs",
".",
"aws",
".",
"amazon",
".",
"com",
"/",
"glue",
"/",
"latest",
"/",
"dg",
"/",
"aws",
"-",
"glue",
"-",
"programming",
"-",
"python",
"-",
"calling",
".",
"html",
">",
"Calling",
"AWS",
"Glue",
"APIs",
"in",
"Python<",
"/",
"a",
">",
"topic",
"in",
"the",
"developer",
"guide",
".",
"<",
"/",
"p",
">",
"<p",
">",
"For",
"information",
"about",
"the",
"key",
"-",
"value",
"pairs",
"that",
"AWS",
"Glue",
"consumes",
"to",
"set",
"up",
"your",
"job",
"see",
"the",
"<a",
"href",
"=",
"http",
":",
"//",
"docs",
".",
"aws",
".",
"amazon",
".",
"com",
"/",
"glue",
"/",
"latest",
"/",
"dg",
"/",
"aws",
"-",
"glue",
"-",
"programming",
"-",
"etl",
"-",
"glue",
"-",
"arguments",
".",
"html",
">",
"Special",
"Parameters",
"Used",
"by",
"AWS",
"Glue<",
"/",
"a",
">",
"topic",
"in",
"the",
"developer",
"guide",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-glue/src/main/java/com/amazonaws/services/glue/model/Action.java#L240-L243 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/filter/DependentFileFilter.java | DependentFileFilter.doRecordChange | public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption) {
"""
Called when a change is the record status is about to happen/has happened.
@param field If this file change is due to a field, this is the field.
@param iChangeType The type of change that occurred.
@param bDisplayOption If true, display any changes.
@return an error code.
Before an add, set the key back to the original value.
""" // Read a valid record
int iErrorCode = super.doRecordChange(field, iChangeType, bDisplayOption); // Initialize the record
if (iErrorCode != DBConstants.NORMAL_RETURN)
return iErrorCode;
boolean bSetIfModified = true;
switch (iChangeType)
{
case DBConstants.UPDATE_TYPE: // This should not be necessary (but I do it anyway).
if (!this.getOwner().isRefreshedRecord())
break; // No first add
bSetIfModified = false;
case DBConstants.ADD_TYPE:
boolean bNonNulls = this.setMainKey(bDisplayOption, null, bSetIfModified); // Set up the key (keys are marked as changed if they change!)
if ((bNonNulls == false) && ((this.getOwner().getMasterSlave() & RecordOwner.SLAVE) == 0)) // Don't return for a server!
{
if (this.getOwner().getTask() != null)
return this.getOwner().getTask().setLastError("Main key cannot be null");
return DBConstants.ERROR_RETURN; // Key can't be null!
}
break;
}
return iErrorCode; // Initialize the record
} | java | public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption)
{ // Read a valid record
int iErrorCode = super.doRecordChange(field, iChangeType, bDisplayOption); // Initialize the record
if (iErrorCode != DBConstants.NORMAL_RETURN)
return iErrorCode;
boolean bSetIfModified = true;
switch (iChangeType)
{
case DBConstants.UPDATE_TYPE: // This should not be necessary (but I do it anyway).
if (!this.getOwner().isRefreshedRecord())
break; // No first add
bSetIfModified = false;
case DBConstants.ADD_TYPE:
boolean bNonNulls = this.setMainKey(bDisplayOption, null, bSetIfModified); // Set up the key (keys are marked as changed if they change!)
if ((bNonNulls == false) && ((this.getOwner().getMasterSlave() & RecordOwner.SLAVE) == 0)) // Don't return for a server!
{
if (this.getOwner().getTask() != null)
return this.getOwner().getTask().setLastError("Main key cannot be null");
return DBConstants.ERROR_RETURN; // Key can't be null!
}
break;
}
return iErrorCode; // Initialize the record
} | [
"public",
"int",
"doRecordChange",
"(",
"FieldInfo",
"field",
",",
"int",
"iChangeType",
",",
"boolean",
"bDisplayOption",
")",
"{",
"// Read a valid record",
"int",
"iErrorCode",
"=",
"super",
".",
"doRecordChange",
"(",
"field",
",",
"iChangeType",
",",
"bDisplayOption",
")",
";",
"// Initialize the record",
"if",
"(",
"iErrorCode",
"!=",
"DBConstants",
".",
"NORMAL_RETURN",
")",
"return",
"iErrorCode",
";",
"boolean",
"bSetIfModified",
"=",
"true",
";",
"switch",
"(",
"iChangeType",
")",
"{",
"case",
"DBConstants",
".",
"UPDATE_TYPE",
":",
"// This should not be necessary (but I do it anyway).",
"if",
"(",
"!",
"this",
".",
"getOwner",
"(",
")",
".",
"isRefreshedRecord",
"(",
")",
")",
"break",
";",
"// No first add",
"bSetIfModified",
"=",
"false",
";",
"case",
"DBConstants",
".",
"ADD_TYPE",
":",
"boolean",
"bNonNulls",
"=",
"this",
".",
"setMainKey",
"(",
"bDisplayOption",
",",
"null",
",",
"bSetIfModified",
")",
";",
"// Set up the key (keys are marked as changed if they change!)",
"if",
"(",
"(",
"bNonNulls",
"==",
"false",
")",
"&&",
"(",
"(",
"this",
".",
"getOwner",
"(",
")",
".",
"getMasterSlave",
"(",
")",
"&",
"RecordOwner",
".",
"SLAVE",
")",
"==",
"0",
")",
")",
"// Don't return for a server!",
"{",
"if",
"(",
"this",
".",
"getOwner",
"(",
")",
".",
"getTask",
"(",
")",
"!=",
"null",
")",
"return",
"this",
".",
"getOwner",
"(",
")",
".",
"getTask",
"(",
")",
".",
"setLastError",
"(",
"\"Main key cannot be null\"",
")",
";",
"return",
"DBConstants",
".",
"ERROR_RETURN",
";",
"// Key can't be null!",
"}",
"break",
";",
"}",
"return",
"iErrorCode",
";",
"// Initialize the record",
"}"
] | Called when a change is the record status is about to happen/has happened.
@param field If this file change is due to a field, this is the field.
@param iChangeType The type of change that occurred.
@param bDisplayOption If true, display any changes.
@return an error code.
Before an add, set the key back to the original value. | [
"Called",
"when",
"a",
"change",
"is",
"the",
"record",
"status",
"is",
"about",
"to",
"happen",
"/",
"has",
"happened",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/filter/DependentFileFilter.java#L142-L165 |
h2oai/h2o-2 | src/main/java/water/Value.java | Value.setReplica | boolean setReplica( H2ONode h2o ) {
"""
Atomically insert h2o into the replica list; reports false if the Value
flagged against future replication with a -1. Also bumps the active
Get count, which remains until the Get completes (we receive an ACKACK).
"""
assert _key.home(); // Only the HOME node for a key tracks replicas
assert h2o != H2O.SELF; // Do not track self as a replica
while( true ) { // Repeat, in case racing GETs are bumping the counter
int old = _rwlock.get();
if( old == -1 ) return false; // Write-locked; no new replications. Read fails to read *this* value
assert old >= 0; // Not negative
if( RW_CAS(old,old+1,"rlock+") ) break;
}
// Narrow non-race here. Here is a time window where the rwlock count went
// up, but the replica list does not account for the new replica. However,
// the rwlock cannot go down until an ACKACK is received, and the ACK
// (hence ACKACK) doesn't go out until after this function returns.
_replicas.add(h2o._unique_idx);
// Both rwlock taken, and replica count is up now.
return true;
} | java | boolean setReplica( H2ONode h2o ) {
assert _key.home(); // Only the HOME node for a key tracks replicas
assert h2o != H2O.SELF; // Do not track self as a replica
while( true ) { // Repeat, in case racing GETs are bumping the counter
int old = _rwlock.get();
if( old == -1 ) return false; // Write-locked; no new replications. Read fails to read *this* value
assert old >= 0; // Not negative
if( RW_CAS(old,old+1,"rlock+") ) break;
}
// Narrow non-race here. Here is a time window where the rwlock count went
// up, but the replica list does not account for the new replica. However,
// the rwlock cannot go down until an ACKACK is received, and the ACK
// (hence ACKACK) doesn't go out until after this function returns.
_replicas.add(h2o._unique_idx);
// Both rwlock taken, and replica count is up now.
return true;
} | [
"boolean",
"setReplica",
"(",
"H2ONode",
"h2o",
")",
"{",
"assert",
"_key",
".",
"home",
"(",
")",
";",
"// Only the HOME node for a key tracks replicas",
"assert",
"h2o",
"!=",
"H2O",
".",
"SELF",
";",
"// Do not track self as a replica",
"while",
"(",
"true",
")",
"{",
"// Repeat, in case racing GETs are bumping the counter",
"int",
"old",
"=",
"_rwlock",
".",
"get",
"(",
")",
";",
"if",
"(",
"old",
"==",
"-",
"1",
")",
"return",
"false",
";",
"// Write-locked; no new replications. Read fails to read *this* value",
"assert",
"old",
">=",
"0",
";",
"// Not negative",
"if",
"(",
"RW_CAS",
"(",
"old",
",",
"old",
"+",
"1",
",",
"\"rlock+\"",
")",
")",
"break",
";",
"}",
"// Narrow non-race here. Here is a time window where the rwlock count went",
"// up, but the replica list does not account for the new replica. However,",
"// the rwlock cannot go down until an ACKACK is received, and the ACK",
"// (hence ACKACK) doesn't go out until after this function returns.",
"_replicas",
".",
"add",
"(",
"h2o",
".",
"_unique_idx",
")",
";",
"// Both rwlock taken, and replica count is up now.",
"return",
"true",
";",
"}"
] | Atomically insert h2o into the replica list; reports false if the Value
flagged against future replication with a -1. Also bumps the active
Get count, which remains until the Get completes (we receive an ACKACK). | [
"Atomically",
"insert",
"h2o",
"into",
"the",
"replica",
"list",
";",
"reports",
"false",
"if",
"the",
"Value",
"flagged",
"against",
"future",
"replication",
"with",
"a",
"-",
"1",
".",
"Also",
"bumps",
"the",
"active",
"Get",
"count",
"which",
"remains",
"until",
"the",
"Get",
"completes",
"(",
"we",
"receive",
"an",
"ACKACK",
")",
"."
] | train | https://github.com/h2oai/h2o-2/blob/be350f3f2c2fb6f135cc07c41f83fd0e4f521ac1/src/main/java/water/Value.java#L483-L499 |
facebook/fresco | imagepipeline/src/main/java/com/facebook/imagepipeline/platform/DefaultDecoder.java | DefaultDecoder.decodeJPEGFromEncodedImageWithColorSpace | @Override
public CloseableReference<Bitmap> decodeJPEGFromEncodedImageWithColorSpace(
EncodedImage encodedImage,
Bitmap.Config bitmapConfig,
@Nullable Rect regionToDecode,
int length,
@Nullable final ColorSpace colorSpace) {
"""
Creates a bitmap from encoded JPEG bytes. Supports a partial JPEG image.
@param encodedImage the encoded image with reference to the encoded bytes
@param bitmapConfig the {@link android.graphics.Bitmap.Config} used to create the decoded
Bitmap
@param regionToDecode optional image region to decode or null to decode the whole image
@param length the number of encoded bytes in the buffer
@param colorSpace the target color space of the decoded bitmap, must be one of the named color
space in {@link android.graphics.ColorSpace.Named}. If null, then SRGB color space is
assumed if the SDK version >= 26.
@return the bitmap
@exception java.lang.OutOfMemoryError if the Bitmap cannot be allocated
"""
boolean isJpegComplete = encodedImage.isCompleteAt(length);
final BitmapFactory.Options options = getDecodeOptionsForStream(encodedImage, bitmapConfig);
InputStream jpegDataStream = encodedImage.getInputStream();
// At this point the InputStream from the encoded image should not be null since in the
// pipeline,this comes from a call stack where this was checked before. Also this method needs
// the InputStream to decode the image so this can't be null.
Preconditions.checkNotNull(jpegDataStream);
if (encodedImage.getSize() > length) {
jpegDataStream = new LimitedInputStream(jpegDataStream, length);
}
if (!isJpegComplete) {
jpegDataStream = new TailAppendingInputStream(jpegDataStream, EOI_TAIL);
}
boolean retryOnFail = options.inPreferredConfig != Bitmap.Config.ARGB_8888;
try {
return decodeFromStream(jpegDataStream, options, regionToDecode, colorSpace);
} catch (RuntimeException re) {
if (retryOnFail) {
return decodeJPEGFromEncodedImageWithColorSpace(
encodedImage, Bitmap.Config.ARGB_8888, regionToDecode, length, colorSpace);
}
throw re;
}
} | java | @Override
public CloseableReference<Bitmap> decodeJPEGFromEncodedImageWithColorSpace(
EncodedImage encodedImage,
Bitmap.Config bitmapConfig,
@Nullable Rect regionToDecode,
int length,
@Nullable final ColorSpace colorSpace) {
boolean isJpegComplete = encodedImage.isCompleteAt(length);
final BitmapFactory.Options options = getDecodeOptionsForStream(encodedImage, bitmapConfig);
InputStream jpegDataStream = encodedImage.getInputStream();
// At this point the InputStream from the encoded image should not be null since in the
// pipeline,this comes from a call stack where this was checked before. Also this method needs
// the InputStream to decode the image so this can't be null.
Preconditions.checkNotNull(jpegDataStream);
if (encodedImage.getSize() > length) {
jpegDataStream = new LimitedInputStream(jpegDataStream, length);
}
if (!isJpegComplete) {
jpegDataStream = new TailAppendingInputStream(jpegDataStream, EOI_TAIL);
}
boolean retryOnFail = options.inPreferredConfig != Bitmap.Config.ARGB_8888;
try {
return decodeFromStream(jpegDataStream, options, regionToDecode, colorSpace);
} catch (RuntimeException re) {
if (retryOnFail) {
return decodeJPEGFromEncodedImageWithColorSpace(
encodedImage, Bitmap.Config.ARGB_8888, regionToDecode, length, colorSpace);
}
throw re;
}
} | [
"@",
"Override",
"public",
"CloseableReference",
"<",
"Bitmap",
">",
"decodeJPEGFromEncodedImageWithColorSpace",
"(",
"EncodedImage",
"encodedImage",
",",
"Bitmap",
".",
"Config",
"bitmapConfig",
",",
"@",
"Nullable",
"Rect",
"regionToDecode",
",",
"int",
"length",
",",
"@",
"Nullable",
"final",
"ColorSpace",
"colorSpace",
")",
"{",
"boolean",
"isJpegComplete",
"=",
"encodedImage",
".",
"isCompleteAt",
"(",
"length",
")",
";",
"final",
"BitmapFactory",
".",
"Options",
"options",
"=",
"getDecodeOptionsForStream",
"(",
"encodedImage",
",",
"bitmapConfig",
")",
";",
"InputStream",
"jpegDataStream",
"=",
"encodedImage",
".",
"getInputStream",
"(",
")",
";",
"// At this point the InputStream from the encoded image should not be null since in the",
"// pipeline,this comes from a call stack where this was checked before. Also this method needs",
"// the InputStream to decode the image so this can't be null.",
"Preconditions",
".",
"checkNotNull",
"(",
"jpegDataStream",
")",
";",
"if",
"(",
"encodedImage",
".",
"getSize",
"(",
")",
">",
"length",
")",
"{",
"jpegDataStream",
"=",
"new",
"LimitedInputStream",
"(",
"jpegDataStream",
",",
"length",
")",
";",
"}",
"if",
"(",
"!",
"isJpegComplete",
")",
"{",
"jpegDataStream",
"=",
"new",
"TailAppendingInputStream",
"(",
"jpegDataStream",
",",
"EOI_TAIL",
")",
";",
"}",
"boolean",
"retryOnFail",
"=",
"options",
".",
"inPreferredConfig",
"!=",
"Bitmap",
".",
"Config",
".",
"ARGB_8888",
";",
"try",
"{",
"return",
"decodeFromStream",
"(",
"jpegDataStream",
",",
"options",
",",
"regionToDecode",
",",
"colorSpace",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"re",
")",
"{",
"if",
"(",
"retryOnFail",
")",
"{",
"return",
"decodeJPEGFromEncodedImageWithColorSpace",
"(",
"encodedImage",
",",
"Bitmap",
".",
"Config",
".",
"ARGB_8888",
",",
"regionToDecode",
",",
"length",
",",
"colorSpace",
")",
";",
"}",
"throw",
"re",
";",
"}",
"}"
] | Creates a bitmap from encoded JPEG bytes. Supports a partial JPEG image.
@param encodedImage the encoded image with reference to the encoded bytes
@param bitmapConfig the {@link android.graphics.Bitmap.Config} used to create the decoded
Bitmap
@param regionToDecode optional image region to decode or null to decode the whole image
@param length the number of encoded bytes in the buffer
@param colorSpace the target color space of the decoded bitmap, must be one of the named color
space in {@link android.graphics.ColorSpace.Named}. If null, then SRGB color space is
assumed if the SDK version >= 26.
@return the bitmap
@exception java.lang.OutOfMemoryError if the Bitmap cannot be allocated | [
"Creates",
"a",
"bitmap",
"from",
"encoded",
"JPEG",
"bytes",
".",
"Supports",
"a",
"partial",
"JPEG",
"image",
"."
] | train | https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/platform/DefaultDecoder.java#L133-L163 |
bladecoder/blade-ink | src/main/java/com/bladecoder/ink/runtime/Story.java | Story.removeVariableObserver | public void removeVariableObserver(VariableObserver observer, String specificVariableName) throws Exception {
"""
Removes the variable observer, to stop getting variable change notifications.
If you pass a specific variable name, it will stop observing that particular
one. If you pass null (or leave it blank, since it's optional), then the
observer will be removed from all variables that it's subscribed to.
@param observer
The observer to stop observing.
@param specificVariableName
(Optional) Specific variable name to stop observing.
@throws Exception
"""
ifAsyncWeCant("remove a variable observer");
if (variableObservers == null)
return;
// Remove observer for this specific variable
if (specificVariableName != null) {
if (variableObservers.containsKey(specificVariableName)) {
variableObservers.get(specificVariableName).remove(observer);
}
} else {
// Remove observer for all variables
for (List<VariableObserver> obs : variableObservers.values()) {
obs.remove(observer);
}
}
} | java | public void removeVariableObserver(VariableObserver observer, String specificVariableName) throws Exception {
ifAsyncWeCant("remove a variable observer");
if (variableObservers == null)
return;
// Remove observer for this specific variable
if (specificVariableName != null) {
if (variableObservers.containsKey(specificVariableName)) {
variableObservers.get(specificVariableName).remove(observer);
}
} else {
// Remove observer for all variables
for (List<VariableObserver> obs : variableObservers.values()) {
obs.remove(observer);
}
}
} | [
"public",
"void",
"removeVariableObserver",
"(",
"VariableObserver",
"observer",
",",
"String",
"specificVariableName",
")",
"throws",
"Exception",
"{",
"ifAsyncWeCant",
"(",
"\"remove a variable observer\"",
")",
";",
"if",
"(",
"variableObservers",
"==",
"null",
")",
"return",
";",
"// Remove observer for this specific variable",
"if",
"(",
"specificVariableName",
"!=",
"null",
")",
"{",
"if",
"(",
"variableObservers",
".",
"containsKey",
"(",
"specificVariableName",
")",
")",
"{",
"variableObservers",
".",
"get",
"(",
"specificVariableName",
")",
".",
"remove",
"(",
"observer",
")",
";",
"}",
"}",
"else",
"{",
"// Remove observer for all variables",
"for",
"(",
"List",
"<",
"VariableObserver",
">",
"obs",
":",
"variableObservers",
".",
"values",
"(",
")",
")",
"{",
"obs",
".",
"remove",
"(",
"observer",
")",
";",
"}",
"}",
"}"
] | Removes the variable observer, to stop getting variable change notifications.
If you pass a specific variable name, it will stop observing that particular
one. If you pass null (or leave it blank, since it's optional), then the
observer will be removed from all variables that it's subscribed to.
@param observer
The observer to stop observing.
@param specificVariableName
(Optional) Specific variable name to stop observing.
@throws Exception | [
"Removes",
"the",
"variable",
"observer",
"to",
"stop",
"getting",
"variable",
"change",
"notifications",
".",
"If",
"you",
"pass",
"a",
"specific",
"variable",
"name",
"it",
"will",
"stop",
"observing",
"that",
"particular",
"one",
".",
"If",
"you",
"pass",
"null",
"(",
"or",
"leave",
"it",
"blank",
"since",
"it",
"s",
"optional",
")",
"then",
"the",
"observer",
"will",
"be",
"removed",
"from",
"all",
"variables",
"that",
"it",
"s",
"subscribed",
"to",
"."
] | train | https://github.com/bladecoder/blade-ink/blob/930922099f7073f50f956479adaa3cbd47c70225/src/main/java/com/bladecoder/ink/runtime/Story.java#L1090-L1107 |
BlueBrain/bluima | modules/bluima_pdf/src/main/java/edu/psu/seersuite/extractors/tableextractor/extraction/BoxTableExtractor.java | BoxTableExtractor.getTableStructure | public void getTableStructure (int cc, TableCandidate tc, ArrayList<TextPiece> wordsOfAPage) {
"""
Implements the table structure decomposition step
@param cc
the number of the table columns
@param tc
the object of the table candidate
@param wordsOfAPage
the list of all the words in a document page
"""
float minGapBtwColumns = 1000.0f;
float[] leftX_tableColumns = tc.getLeftX_tableColumns();
float[] rightX_tableColumns = tc.getRightX_tableColumns();
int YNum = tc.getRows().size();
for (int zz=1; zz<cc; zz++) {
float thisColumnGap = leftX_tableColumns[zz]-rightX_tableColumns[zz-1];
if (thisColumnGap<minGapBtwColumns)
minGapBtwColumns = thisColumnGap;
}
double columnGapThreshold = 0.0;
//if (withoutKwd==true) columnGapThreshold = parameters.ave_X_Gap_inLine*1.6;
if (minGapBtwColumns>columnGapThreshold) {
getEachCellContent(YNum, cc, tc);
getRealHeadingBasedOnCells(YNum, cc, tc);
getColumnHeading(tc);
getRowHeadingBasedOnCells(tc);
tc.setMetadataStructureLevel(YNum, cc, wordsOfAPage, m_docInfo);
//tc.setMetaStructureLevelx(YNum, cc, wordsOfAPage, m_docInfo);
if ( (tc.getFootnoteBeginRow()>1) & (tc.getMaxColumnNumber()>1) ) {}
else tc.setValid(false);
}
else {
m_docInfo.setErrorMsg("Although we detected some tabular structures in page " + (tc.getPageId_thisTable()+1) + ", we do not treat them as tables because the space gaps between columns are not large enough.");
}
} | java | public void getTableStructure (int cc, TableCandidate tc, ArrayList<TextPiece> wordsOfAPage) {
float minGapBtwColumns = 1000.0f;
float[] leftX_tableColumns = tc.getLeftX_tableColumns();
float[] rightX_tableColumns = tc.getRightX_tableColumns();
int YNum = tc.getRows().size();
for (int zz=1; zz<cc; zz++) {
float thisColumnGap = leftX_tableColumns[zz]-rightX_tableColumns[zz-1];
if (thisColumnGap<minGapBtwColumns)
minGapBtwColumns = thisColumnGap;
}
double columnGapThreshold = 0.0;
//if (withoutKwd==true) columnGapThreshold = parameters.ave_X_Gap_inLine*1.6;
if (minGapBtwColumns>columnGapThreshold) {
getEachCellContent(YNum, cc, tc);
getRealHeadingBasedOnCells(YNum, cc, tc);
getColumnHeading(tc);
getRowHeadingBasedOnCells(tc);
tc.setMetadataStructureLevel(YNum, cc, wordsOfAPage, m_docInfo);
//tc.setMetaStructureLevelx(YNum, cc, wordsOfAPage, m_docInfo);
if ( (tc.getFootnoteBeginRow()>1) & (tc.getMaxColumnNumber()>1) ) {}
else tc.setValid(false);
}
else {
m_docInfo.setErrorMsg("Although we detected some tabular structures in page " + (tc.getPageId_thisTable()+1) + ", we do not treat them as tables because the space gaps between columns are not large enough.");
}
} | [
"public",
"void",
"getTableStructure",
"(",
"int",
"cc",
",",
"TableCandidate",
"tc",
",",
"ArrayList",
"<",
"TextPiece",
">",
"wordsOfAPage",
")",
"{",
"float",
"minGapBtwColumns",
"=",
"1000.0f",
";",
"float",
"[",
"]",
"leftX_tableColumns",
"=",
"tc",
".",
"getLeftX_tableColumns",
"(",
")",
";",
"float",
"[",
"]",
"rightX_tableColumns",
"=",
"tc",
".",
"getRightX_tableColumns",
"(",
")",
";",
"int",
"YNum",
"=",
"tc",
".",
"getRows",
"(",
")",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"zz",
"=",
"1",
";",
"zz",
"<",
"cc",
";",
"zz",
"++",
")",
"{",
"float",
"thisColumnGap",
"=",
"leftX_tableColumns",
"[",
"zz",
"]",
"-",
"rightX_tableColumns",
"[",
"zz",
"-",
"1",
"]",
";",
"if",
"(",
"thisColumnGap",
"<",
"minGapBtwColumns",
")",
"minGapBtwColumns",
"=",
"thisColumnGap",
";",
"}",
"double",
"columnGapThreshold",
"=",
"0.0",
";",
"//if (withoutKwd==true) columnGapThreshold = parameters.ave_X_Gap_inLine*1.6;\t\r",
"if",
"(",
"minGapBtwColumns",
">",
"columnGapThreshold",
")",
"{",
"getEachCellContent",
"(",
"YNum",
",",
"cc",
",",
"tc",
")",
";",
"getRealHeadingBasedOnCells",
"(",
"YNum",
",",
"cc",
",",
"tc",
")",
";",
"getColumnHeading",
"(",
"tc",
")",
";",
"getRowHeadingBasedOnCells",
"(",
"tc",
")",
";",
"tc",
".",
"setMetadataStructureLevel",
"(",
"YNum",
",",
"cc",
",",
"wordsOfAPage",
",",
"m_docInfo",
")",
";",
"//tc.setMetaStructureLevelx(YNum, cc, wordsOfAPage, m_docInfo);\r",
"if",
"(",
"(",
"tc",
".",
"getFootnoteBeginRow",
"(",
")",
">",
"1",
")",
"&",
"(",
"tc",
".",
"getMaxColumnNumber",
"(",
")",
">",
"1",
")",
")",
"{",
"}",
"else",
"tc",
".",
"setValid",
"(",
"false",
")",
";",
"}",
"else",
"{",
"m_docInfo",
".",
"setErrorMsg",
"(",
"\"Although we detected some tabular structures in page \"",
"+",
"(",
"tc",
".",
"getPageId_thisTable",
"(",
")",
"+",
"1",
")",
"+",
"\", we do not treat them as tables because the space gaps between columns are not large enough.\"",
")",
";",
"}",
"}"
] | Implements the table structure decomposition step
@param cc
the number of the table columns
@param tc
the object of the table candidate
@param wordsOfAPage
the list of all the words in a document page | [
"Implements",
"the",
"table",
"structure",
"decomposition",
"step"
] | train | https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_pdf/src/main/java/edu/psu/seersuite/extractors/tableextractor/extraction/BoxTableExtractor.java#L1662-L1689 |
duracloud/duracloud | irodsstorageprovider/src/main/java/org/duracloud/irodsstorage/IrodsStorageProvider.java | IrodsStorageProvider.getSpaces | @Override
public Iterator<String> getSpaces() {
"""
Return a list of irods spaces. IRODS spaces are directories under
the baseDirectory of this provider.
@return
"""
ConnectOperation co =
new ConnectOperation(host, port, username, password, zone);
log.trace("Listing spaces");
try {
return listDirectories(baseDirectory, co.getConnection());
} catch (IOException e) {
log.error("Could not connect to iRODS", e);
throw new StorageException(e);
}
} | java | @Override
public Iterator<String> getSpaces() {
ConnectOperation co =
new ConnectOperation(host, port, username, password, zone);
log.trace("Listing spaces");
try {
return listDirectories(baseDirectory, co.getConnection());
} catch (IOException e) {
log.error("Could not connect to iRODS", e);
throw new StorageException(e);
}
} | [
"@",
"Override",
"public",
"Iterator",
"<",
"String",
">",
"getSpaces",
"(",
")",
"{",
"ConnectOperation",
"co",
"=",
"new",
"ConnectOperation",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"zone",
")",
";",
"log",
".",
"trace",
"(",
"\"Listing spaces\"",
")",
";",
"try",
"{",
"return",
"listDirectories",
"(",
"baseDirectory",
",",
"co",
".",
"getConnection",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Could not connect to iRODS\"",
",",
"e",
")",
";",
"throw",
"new",
"StorageException",
"(",
"e",
")",
";",
"}",
"}"
] | Return a list of irods spaces. IRODS spaces are directories under
the baseDirectory of this provider.
@return | [
"Return",
"a",
"list",
"of",
"irods",
"spaces",
".",
"IRODS",
"spaces",
"are",
"directories",
"under",
"the",
"baseDirectory",
"of",
"this",
"provider",
"."
] | train | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/irodsstorageprovider/src/main/java/org/duracloud/irodsstorage/IrodsStorageProvider.java#L104-L116 |
apache/incubator-atlas | webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java | EntityREST.addClassifications | @POST
@Path("/guid/ {
"""
Adds classifications to an existing entity represented by a guid.
@param guid globally unique identifier for the entity
"""guid}/classifications")
@Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON})
@Produces(Servlets.JSON_MEDIA_TYPE)
public void addClassifications(@PathParam("guid") final String guid, List<AtlasClassification> classifications) throws AtlasBaseException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addClassifications(" + guid + ")");
}
if (StringUtils.isEmpty(guid)) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
}
entitiesStore.addClassifications(guid, classifications);
} finally {
AtlasPerfTracer.log(perf);
}
} | java | @POST
@Path("/guid/{guid}/classifications")
@Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON})
@Produces(Servlets.JSON_MEDIA_TYPE)
public void addClassifications(@PathParam("guid") final String guid, List<AtlasClassification> classifications) throws AtlasBaseException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addClassifications(" + guid + ")");
}
if (StringUtils.isEmpty(guid)) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
}
entitiesStore.addClassifications(guid, classifications);
} finally {
AtlasPerfTracer.log(perf);
}
} | [
"@",
"POST",
"@",
"Path",
"(",
"\"/guid/{guid}/classifications\"",
")",
"@",
"Consumes",
"(",
"{",
"Servlets",
".",
"JSON_MEDIA_TYPE",
",",
"MediaType",
".",
"APPLICATION_JSON",
"}",
")",
"@",
"Produces",
"(",
"Servlets",
".",
"JSON_MEDIA_TYPE",
")",
"public",
"void",
"addClassifications",
"(",
"@",
"PathParam",
"(",
"\"guid\"",
")",
"final",
"String",
"guid",
",",
"List",
"<",
"AtlasClassification",
">",
"classifications",
")",
"throws",
"AtlasBaseException",
"{",
"AtlasPerfTracer",
"perf",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"AtlasPerfTracer",
".",
"isPerfTraceEnabled",
"(",
"PERF_LOG",
")",
")",
"{",
"perf",
"=",
"AtlasPerfTracer",
".",
"getPerfTracer",
"(",
"PERF_LOG",
",",
"\"EntityREST.addClassifications(\"",
"+",
"guid",
"+",
"\")\"",
")",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"guid",
")",
")",
"{",
"throw",
"new",
"AtlasBaseException",
"(",
"AtlasErrorCode",
".",
"INSTANCE_GUID_NOT_FOUND",
",",
"guid",
")",
";",
"}",
"entitiesStore",
".",
"addClassifications",
"(",
"guid",
",",
"classifications",
")",
";",
"}",
"finally",
"{",
"AtlasPerfTracer",
".",
"log",
"(",
"perf",
")",
";",
"}",
"}"
] | Adds classifications to an existing entity represented by a guid.
@param guid globally unique identifier for the entity | [
"Adds",
"classifications",
"to",
"an",
"existing",
"entity",
"represented",
"by",
"a",
"guid",
"."
] | train | https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java#L328-L348 |
OpenLiberty/open-liberty | dev/com.ibm.websphere.javaee.jsf.2.2/src/javax/faces/webapp/UIComponentClassicTagBase.java | UIComponentClassicTagBase.addFacetNameToParentTag | private void addFacetNameToParentTag(UIComponentClassicTagBase parentTag, String facetName) {
"""
Notify the enclosing JSP tag of the id of this facet's id. The parent tag will later delete any existing view
facets that were not seen during this rendering phase; see doEndTag for details.
"""
if (parentTag._facetsAdded == null)
{
parentTag._facetsAdded = new ArrayList<String>();
}
parentTag._facetsAdded.add(facetName);
} | java | private void addFacetNameToParentTag(UIComponentClassicTagBase parentTag, String facetName)
{
if (parentTag._facetsAdded == null)
{
parentTag._facetsAdded = new ArrayList<String>();
}
parentTag._facetsAdded.add(facetName);
} | [
"private",
"void",
"addFacetNameToParentTag",
"(",
"UIComponentClassicTagBase",
"parentTag",
",",
"String",
"facetName",
")",
"{",
"if",
"(",
"parentTag",
".",
"_facetsAdded",
"==",
"null",
")",
"{",
"parentTag",
".",
"_facetsAdded",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"}",
"parentTag",
".",
"_facetsAdded",
".",
"add",
"(",
"facetName",
")",
";",
"}"
] | Notify the enclosing JSP tag of the id of this facet's id. The parent tag will later delete any existing view
facets that were not seen during this rendering phase; see doEndTag for details. | [
"Notify",
"the",
"enclosing",
"JSP",
"tag",
"of",
"the",
"id",
"of",
"this",
"facet",
"s",
"id",
".",
"The",
"parent",
"tag",
"will",
"later",
"delete",
"any",
"existing",
"view",
"facets",
"that",
"were",
"not",
"seen",
"during",
"this",
"rendering",
"phase",
";",
"see",
"doEndTag",
"for",
"details",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.websphere.javaee.jsf.2.2/src/javax/faces/webapp/UIComponentClassicTagBase.java#L1392-L1399 |
jtablesaw/tablesaw | core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java | DataFrameJoiner.leftOuter | public Table leftOuter(Table table2, boolean allowDuplicateColumnNames, String... col2Names) {
"""
Joins the joiner to the table2, using the given columns for the second table and returns the resulting table
@param table2 The table to join with
@param allowDuplicateColumnNames if {@code false} the join will fail if any columns other than the join column have the same name
if {@code true} the join will succeed and duplicate columns are renamed
@param col2Names The columns to join on. If a name refers to a double column, the join is performed after
rounding to integers.
@return The resulting table
"""
return joinInternal(table, table2, true, allowDuplicateColumnNames, col2Names);
} | java | public Table leftOuter(Table table2, boolean allowDuplicateColumnNames, String... col2Names) {
return joinInternal(table, table2, true, allowDuplicateColumnNames, col2Names);
} | [
"public",
"Table",
"leftOuter",
"(",
"Table",
"table2",
",",
"boolean",
"allowDuplicateColumnNames",
",",
"String",
"...",
"col2Names",
")",
"{",
"return",
"joinInternal",
"(",
"table",
",",
"table2",
",",
"true",
",",
"allowDuplicateColumnNames",
",",
"col2Names",
")",
";",
"}"
] | Joins the joiner to the table2, using the given columns for the second table and returns the resulting table
@param table2 The table to join with
@param allowDuplicateColumnNames if {@code false} the join will fail if any columns other than the join column have the same name
if {@code true} the join will succeed and duplicate columns are renamed
@param col2Names The columns to join on. If a name refers to a double column, the join is performed after
rounding to integers.
@return The resulting table | [
"Joins",
"the",
"joiner",
"to",
"the",
"table2",
"using",
"the",
"given",
"columns",
"for",
"the",
"second",
"table",
"and",
"returns",
"the",
"resulting",
"table"
] | train | https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java#L540-L542 |
alkacon/opencms-core | src-gwt/org/opencms/ade/galleries/client/ui/A_CmsListTab.java | A_CmsListTab.createSelectResourceButton | protected CmsPushButton createSelectResourceButton(
String resourcePath,
CmsUUID structureId,
String title,
String resourceType) {
"""
Creates a button widget to select the specified resource.<p>
@param resourcePath the item resource path
@param structureId the structure id
@param title the resource title
@param resourceType the item resource type
@return the initialized select resource button
"""
CmsPushButton result = new CmsPushButton();
result.setImageClass(I_CmsButton.CHECK_SMALL);
result.setButtonStyle(ButtonStyle.FONT_ICON, null);
result.setTitle(Messages.get().key(Messages.GUI_PREVIEW_BUTTON_SELECT_0));
result.addClickHandler(new SelectHandler(resourcePath, structureId, title, resourceType));
return result;
} | java | protected CmsPushButton createSelectResourceButton(
String resourcePath,
CmsUUID structureId,
String title,
String resourceType) {
CmsPushButton result = new CmsPushButton();
result.setImageClass(I_CmsButton.CHECK_SMALL);
result.setButtonStyle(ButtonStyle.FONT_ICON, null);
result.setTitle(Messages.get().key(Messages.GUI_PREVIEW_BUTTON_SELECT_0));
result.addClickHandler(new SelectHandler(resourcePath, structureId, title, resourceType));
return result;
} | [
"protected",
"CmsPushButton",
"createSelectResourceButton",
"(",
"String",
"resourcePath",
",",
"CmsUUID",
"structureId",
",",
"String",
"title",
",",
"String",
"resourceType",
")",
"{",
"CmsPushButton",
"result",
"=",
"new",
"CmsPushButton",
"(",
")",
";",
"result",
".",
"setImageClass",
"(",
"I_CmsButton",
".",
"CHECK_SMALL",
")",
";",
"result",
".",
"setButtonStyle",
"(",
"ButtonStyle",
".",
"FONT_ICON",
",",
"null",
")",
";",
"result",
".",
"setTitle",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"GUI_PREVIEW_BUTTON_SELECT_0",
")",
")",
";",
"result",
".",
"addClickHandler",
"(",
"new",
"SelectHandler",
"(",
"resourcePath",
",",
"structureId",
",",
"title",
",",
"resourceType",
")",
")",
";",
"return",
"result",
";",
"}"
] | Creates a button widget to select the specified resource.<p>
@param resourcePath the item resource path
@param structureId the structure id
@param title the resource title
@param resourceType the item resource type
@return the initialized select resource button | [
"Creates",
"a",
"button",
"widget",
"to",
"select",
"the",
"specified",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/galleries/client/ui/A_CmsListTab.java#L550-L562 |
atomix/catalyst | serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java | SerializerRegistry.registerDefault | public SerializerRegistry registerDefault(Class<?> baseType, Class<? extends TypeSerializer> serializer) {
"""
Registers the given class as a default serializer for the given base type.
@param baseType The base type for which to register the serializer.
@param serializer The serializer class.
@return The serializer registry.
"""
return registerDefault(baseType, new DefaultTypeSerializerFactory(serializer));
} | java | public SerializerRegistry registerDefault(Class<?> baseType, Class<? extends TypeSerializer> serializer) {
return registerDefault(baseType, new DefaultTypeSerializerFactory(serializer));
} | [
"public",
"SerializerRegistry",
"registerDefault",
"(",
"Class",
"<",
"?",
">",
"baseType",
",",
"Class",
"<",
"?",
"extends",
"TypeSerializer",
">",
"serializer",
")",
"{",
"return",
"registerDefault",
"(",
"baseType",
",",
"new",
"DefaultTypeSerializerFactory",
"(",
"serializer",
")",
")",
";",
"}"
] | Registers the given class as a default serializer for the given base type.
@param baseType The base type for which to register the serializer.
@param serializer The serializer class.
@return The serializer registry. | [
"Registers",
"the",
"given",
"class",
"as",
"a",
"default",
"serializer",
"for",
"the",
"given",
"base",
"type",
"."
] | train | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java#L257-L259 |
boncey/Flickr4Java | src/main/java/com/flickr4java/flickr/stats/StatsInterface.java | StatsInterface.getCollectionStats | public Stats getCollectionStats(String collectionId, Date date) throws FlickrException {
"""
Get the number of views, comments and favorites on a collection for a given date.
@param date
(Required) Stats will be returned for this date. A day according to Flickr Stats starts at midnight GMT for all users, and timestamps will
automatically be rounded down to the start of the day.
@param collectionId
(Required) The id (from the URL!) of the collection to get stats for.
@see "http://www.flickr.com/services/api/flickr.stats.getCollectionStats.htm"
"""
return getStats(METHOD_GET_COLLECTION_STATS, "collection_id", collectionId, date);
} | java | public Stats getCollectionStats(String collectionId, Date date) throws FlickrException {
return getStats(METHOD_GET_COLLECTION_STATS, "collection_id", collectionId, date);
} | [
"public",
"Stats",
"getCollectionStats",
"(",
"String",
"collectionId",
",",
"Date",
"date",
")",
"throws",
"FlickrException",
"{",
"return",
"getStats",
"(",
"METHOD_GET_COLLECTION_STATS",
",",
"\"collection_id\"",
",",
"collectionId",
",",
"date",
")",
";",
"}"
] | Get the number of views, comments and favorites on a collection for a given date.
@param date
(Required) Stats will be returned for this date. A day according to Flickr Stats starts at midnight GMT for all users, and timestamps will
automatically be rounded down to the start of the day.
@param collectionId
(Required) The id (from the URL!) of the collection to get stats for.
@see "http://www.flickr.com/services/api/flickr.stats.getCollectionStats.htm" | [
"Get",
"the",
"number",
"of",
"views",
"comments",
"and",
"favorites",
"on",
"a",
"collection",
"for",
"a",
"given",
"date",
"."
] | train | https://github.com/boncey/Flickr4Java/blob/f66987ba0e360e5fb7730efbbb8c51f3d978fc25/src/main/java/com/flickr4java/flickr/stats/StatsInterface.java#L129-L131 |
azkaban/azkaban | az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopSparkJob.java | HadoopSparkJob.addAdditionalNamenodesFromConf | private void addAdditionalNamenodesFromConf(final Props props) {
"""
Add additional namenodes specified in the Spark Configuration
({@link #SPARK_CONF_ADDITIONAL_NAMENODES}) to the Props provided.
@param props Props to add additional namenodes to.
@see HadoopJobUtils#addAdditionalNamenodesToProps(Props, String)
"""
final String sparkConfDir = getSparkLibConf()[1];
final File sparkConfFile = new File(sparkConfDir, "spark-defaults.conf");
try {
final InputStreamReader inReader =
new InputStreamReader(new FileInputStream(sparkConfFile), StandardCharsets.UTF_8);
// Use Properties to avoid needing Spark on our classpath
final Properties sparkProps = new Properties();
sparkProps.load(inReader);
inReader.close();
final String additionalNamenodes =
sparkProps.getProperty(SPARK_CONF_ADDITIONAL_NAMENODES);
if (additionalNamenodes != null && additionalNamenodes.length() > 0) {
getLog().info("Found property " + SPARK_CONF_ADDITIONAL_NAMENODES +
" = " + additionalNamenodes + "; setting additional namenodes");
HadoopJobUtils.addAdditionalNamenodesToProps(props, additionalNamenodes);
}
} catch (final IOException e) {
getLog().warn("Unable to load Spark configuration; not adding any additional " +
"namenode delegation tokens.", e);
}
} | java | private void addAdditionalNamenodesFromConf(final Props props) {
final String sparkConfDir = getSparkLibConf()[1];
final File sparkConfFile = new File(sparkConfDir, "spark-defaults.conf");
try {
final InputStreamReader inReader =
new InputStreamReader(new FileInputStream(sparkConfFile), StandardCharsets.UTF_8);
// Use Properties to avoid needing Spark on our classpath
final Properties sparkProps = new Properties();
sparkProps.load(inReader);
inReader.close();
final String additionalNamenodes =
sparkProps.getProperty(SPARK_CONF_ADDITIONAL_NAMENODES);
if (additionalNamenodes != null && additionalNamenodes.length() > 0) {
getLog().info("Found property " + SPARK_CONF_ADDITIONAL_NAMENODES +
" = " + additionalNamenodes + "; setting additional namenodes");
HadoopJobUtils.addAdditionalNamenodesToProps(props, additionalNamenodes);
}
} catch (final IOException e) {
getLog().warn("Unable to load Spark configuration; not adding any additional " +
"namenode delegation tokens.", e);
}
} | [
"private",
"void",
"addAdditionalNamenodesFromConf",
"(",
"final",
"Props",
"props",
")",
"{",
"final",
"String",
"sparkConfDir",
"=",
"getSparkLibConf",
"(",
")",
"[",
"1",
"]",
";",
"final",
"File",
"sparkConfFile",
"=",
"new",
"File",
"(",
"sparkConfDir",
",",
"\"spark-defaults.conf\"",
")",
";",
"try",
"{",
"final",
"InputStreamReader",
"inReader",
"=",
"new",
"InputStreamReader",
"(",
"new",
"FileInputStream",
"(",
"sparkConfFile",
")",
",",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"// Use Properties to avoid needing Spark on our classpath",
"final",
"Properties",
"sparkProps",
"=",
"new",
"Properties",
"(",
")",
";",
"sparkProps",
".",
"load",
"(",
"inReader",
")",
";",
"inReader",
".",
"close",
"(",
")",
";",
"final",
"String",
"additionalNamenodes",
"=",
"sparkProps",
".",
"getProperty",
"(",
"SPARK_CONF_ADDITIONAL_NAMENODES",
")",
";",
"if",
"(",
"additionalNamenodes",
"!=",
"null",
"&&",
"additionalNamenodes",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Found property \"",
"+",
"SPARK_CONF_ADDITIONAL_NAMENODES",
"+",
"\" = \"",
"+",
"additionalNamenodes",
"+",
"\"; setting additional namenodes\"",
")",
";",
"HadoopJobUtils",
".",
"addAdditionalNamenodesToProps",
"(",
"props",
",",
"additionalNamenodes",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"getLog",
"(",
")",
".",
"warn",
"(",
"\"Unable to load Spark configuration; not adding any additional \"",
"+",
"\"namenode delegation tokens.\"",
",",
"e",
")",
";",
"}",
"}"
] | Add additional namenodes specified in the Spark Configuration
({@link #SPARK_CONF_ADDITIONAL_NAMENODES}) to the Props provided.
@param props Props to add additional namenodes to.
@see HadoopJobUtils#addAdditionalNamenodesToProps(Props, String) | [
"Add",
"additional",
"namenodes",
"specified",
"in",
"the",
"Spark",
"Configuration",
"(",
"{",
"@link",
"#SPARK_CONF_ADDITIONAL_NAMENODES",
"}",
")",
"to",
"the",
"Props",
"provided",
"."
] | train | https://github.com/azkaban/azkaban/blob/d258ea7d6e66807c6eff79c5325d6d3443618dff/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopSparkJob.java#L273-L294 |
trustathsh/ifmapj | src/main/java/de/hshannover/f4/trust/ifmapj/channel/CommunicationHandlerFactory.java | CommunicationHandlerFactory.newHandler | public static CommunicationHandler newHandler(String url, String user,
String pass, SSLSocketFactory sslSocketFactory, HostnameVerifier verifier, int initialConnectionTimeout)
throws InitializationException {
"""
Create a {@link CommunicationHandler} instance.
The {@link CommunicationHandler} implementation returned by this method
depends on the system property ifmapj.communication.handler. If it is
set to <b>java</b> an instance of {@link JavaCommunicationHandler} is
returned, if set to <b>apache</b> instead, {@link ApacheCoreCommunicationHandler}
is used. If it is not set, either one is returned, preferring
{@link ApacheCoreCommunicationHandler}.
@param url The url to connect to.
@param user for basic auth, if user != null -> pass != null
@param pass for basic auth, if pass != null -> user != null
@param sslSocketFactory the {@link SSLSocketFactory} to be used
@param verifier
@param initialConnectionTimeout the initial connection timeout in milliseconds
@return the new {@link CommunicationHandler}
@throws InitializationException
"""
String handler = System.getProperty(HANDLER_PROPERTY);
if (handler != null) {
return newHandlerPreference(handler, url, user, pass, sslSocketFactory, verifier, initialConnectionTimeout);
} else {
return newHandlerAuto(url, user, pass, sslSocketFactory, verifier, initialConnectionTimeout);
}
} | java | public static CommunicationHandler newHandler(String url, String user,
String pass, SSLSocketFactory sslSocketFactory, HostnameVerifier verifier, int initialConnectionTimeout)
throws InitializationException {
String handler = System.getProperty(HANDLER_PROPERTY);
if (handler != null) {
return newHandlerPreference(handler, url, user, pass, sslSocketFactory, verifier, initialConnectionTimeout);
} else {
return newHandlerAuto(url, user, pass, sslSocketFactory, verifier, initialConnectionTimeout);
}
} | [
"public",
"static",
"CommunicationHandler",
"newHandler",
"(",
"String",
"url",
",",
"String",
"user",
",",
"String",
"pass",
",",
"SSLSocketFactory",
"sslSocketFactory",
",",
"HostnameVerifier",
"verifier",
",",
"int",
"initialConnectionTimeout",
")",
"throws",
"InitializationException",
"{",
"String",
"handler",
"=",
"System",
".",
"getProperty",
"(",
"HANDLER_PROPERTY",
")",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"{",
"return",
"newHandlerPreference",
"(",
"handler",
",",
"url",
",",
"user",
",",
"pass",
",",
"sslSocketFactory",
",",
"verifier",
",",
"initialConnectionTimeout",
")",
";",
"}",
"else",
"{",
"return",
"newHandlerAuto",
"(",
"url",
",",
"user",
",",
"pass",
",",
"sslSocketFactory",
",",
"verifier",
",",
"initialConnectionTimeout",
")",
";",
"}",
"}"
] | Create a {@link CommunicationHandler} instance.
The {@link CommunicationHandler} implementation returned by this method
depends on the system property ifmapj.communication.handler. If it is
set to <b>java</b> an instance of {@link JavaCommunicationHandler} is
returned, if set to <b>apache</b> instead, {@link ApacheCoreCommunicationHandler}
is used. If it is not set, either one is returned, preferring
{@link ApacheCoreCommunicationHandler}.
@param url The url to connect to.
@param user for basic auth, if user != null -> pass != null
@param pass for basic auth, if pass != null -> user != null
@param sslSocketFactory the {@link SSLSocketFactory} to be used
@param verifier
@param initialConnectionTimeout the initial connection timeout in milliseconds
@return the new {@link CommunicationHandler}
@throws InitializationException | [
"Create",
"a",
"{",
"@link",
"CommunicationHandler",
"}",
"instance",
"."
] | train | https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj/channel/CommunicationHandlerFactory.java#L69-L80 |
dspinellis/UMLGraph | src/main/java/org/umlgraph/doclet/UmlGraphDoc.java | UmlGraphDoc.runGraphviz | private static void runGraphviz(String dotExecutable, String outputFolder, String packageName, String name, RootDoc root) {
"""
Runs Graphviz dot building both a diagram (in png format) and a client side map for it.
"""
if (dotExecutable == null) {
dotExecutable = "dot";
}
File dotFile = new File(outputFolder, packageName.replace(".", "/") + "/" + name + ".dot");
File svgFile = new File(outputFolder, packageName.replace(".", "/") + "/" + name + ".svg");
try {
Process p = Runtime.getRuntime().exec(new String [] {
dotExecutable,
"-Tsvg",
"-o",
svgFile.getAbsolutePath(),
dotFile.getAbsolutePath()
});
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line;
while((line = reader.readLine()) != null)
root.printWarning(line);
int result = p.waitFor();
if (result != 0)
root.printWarning("Errors running Graphviz on " + dotFile);
} catch (Exception e) {
e.printStackTrace();
System.err.println("Ensure that dot is in your path and that its path does not contain spaces");
}
} | java | private static void runGraphviz(String dotExecutable, String outputFolder, String packageName, String name, RootDoc root) {
if (dotExecutable == null) {
dotExecutable = "dot";
}
File dotFile = new File(outputFolder, packageName.replace(".", "/") + "/" + name + ".dot");
File svgFile = new File(outputFolder, packageName.replace(".", "/") + "/" + name + ".svg");
try {
Process p = Runtime.getRuntime().exec(new String [] {
dotExecutable,
"-Tsvg",
"-o",
svgFile.getAbsolutePath(),
dotFile.getAbsolutePath()
});
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line;
while((line = reader.readLine()) != null)
root.printWarning(line);
int result = p.waitFor();
if (result != 0)
root.printWarning("Errors running Graphviz on " + dotFile);
} catch (Exception e) {
e.printStackTrace();
System.err.println("Ensure that dot is in your path and that its path does not contain spaces");
}
} | [
"private",
"static",
"void",
"runGraphviz",
"(",
"String",
"dotExecutable",
",",
"String",
"outputFolder",
",",
"String",
"packageName",
",",
"String",
"name",
",",
"RootDoc",
"root",
")",
"{",
"if",
"(",
"dotExecutable",
"==",
"null",
")",
"{",
"dotExecutable",
"=",
"\"dot\"",
";",
"}",
"File",
"dotFile",
"=",
"new",
"File",
"(",
"outputFolder",
",",
"packageName",
".",
"replace",
"(",
"\".\"",
",",
"\"/\"",
")",
"+",
"\"/\"",
"+",
"name",
"+",
"\".dot\"",
")",
";",
"File",
"svgFile",
"=",
"new",
"File",
"(",
"outputFolder",
",",
"packageName",
".",
"replace",
"(",
"\".\"",
",",
"\"/\"",
")",
"+",
"\"/\"",
"+",
"name",
"+",
"\".svg\"",
")",
";",
"try",
"{",
"Process",
"p",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec",
"(",
"new",
"String",
"[",
"]",
"{",
"dotExecutable",
",",
"\"-Tsvg\"",
",",
"\"-o\"",
",",
"svgFile",
".",
"getAbsolutePath",
"(",
")",
",",
"dotFile",
".",
"getAbsolutePath",
"(",
")",
"}",
")",
";",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"p",
".",
"getErrorStream",
"(",
")",
")",
")",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"root",
".",
"printWarning",
"(",
"line",
")",
";",
"int",
"result",
"=",
"p",
".",
"waitFor",
"(",
")",
";",
"if",
"(",
"result",
"!=",
"0",
")",
"root",
".",
"printWarning",
"(",
"\"Errors running Graphviz on \"",
"+",
"dotFile",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"\"Ensure that dot is in your path and that its path does not contain spaces\"",
")",
";",
"}",
"}"
] | Runs Graphviz dot building both a diagram (in png format) and a client side map for it. | [
"Runs",
"Graphviz",
"dot",
"building",
"both",
"a",
"diagram",
"(",
"in",
"png",
"format",
")",
"and",
"a",
"client",
"side",
"map",
"for",
"it",
"."
] | train | https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L136-L162 |
apache/reef | lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/evaluator/AllocatedEvaluatorImpl.java | AllocatedEvaluatorImpl.makeEvaluatorConfiguration | private Configuration makeEvaluatorConfiguration(final Configuration contextConfiguration,
final Optional<Configuration> serviceConfiguration,
final Optional<Configuration> taskConfiguration) {
"""
Make configuration for evaluator.
@param contextConfiguration
@param serviceConfiguration
@param taskConfiguration
@return Configuration
"""
final String contextConfigurationString = this.configurationSerializer.toString(contextConfiguration);
final Optional<String> taskConfigurationString;
if (taskConfiguration.isPresent()) {
taskConfigurationString = Optional.of(this.configurationSerializer.toString(taskConfiguration.get()));
} else {
taskConfigurationString = Optional.empty();
}
final Optional<Configuration> mergedServiceConfiguration = makeRootServiceConfiguration(serviceConfiguration);
if (mergedServiceConfiguration.isPresent()) {
final String serviceConfigurationString = this.configurationSerializer.toString(mergedServiceConfiguration.get());
return makeEvaluatorConfiguration(contextConfigurationString, Optional.<String>empty(),
Optional.of(serviceConfigurationString), taskConfigurationString);
} else {
return makeEvaluatorConfiguration(
contextConfigurationString, Optional.<String>empty(), Optional.<String>empty(), taskConfigurationString);
}
} | java | private Configuration makeEvaluatorConfiguration(final Configuration contextConfiguration,
final Optional<Configuration> serviceConfiguration,
final Optional<Configuration> taskConfiguration) {
final String contextConfigurationString = this.configurationSerializer.toString(contextConfiguration);
final Optional<String> taskConfigurationString;
if (taskConfiguration.isPresent()) {
taskConfigurationString = Optional.of(this.configurationSerializer.toString(taskConfiguration.get()));
} else {
taskConfigurationString = Optional.empty();
}
final Optional<Configuration> mergedServiceConfiguration = makeRootServiceConfiguration(serviceConfiguration);
if (mergedServiceConfiguration.isPresent()) {
final String serviceConfigurationString = this.configurationSerializer.toString(mergedServiceConfiguration.get());
return makeEvaluatorConfiguration(contextConfigurationString, Optional.<String>empty(),
Optional.of(serviceConfigurationString), taskConfigurationString);
} else {
return makeEvaluatorConfiguration(
contextConfigurationString, Optional.<String>empty(), Optional.<String>empty(), taskConfigurationString);
}
} | [
"private",
"Configuration",
"makeEvaluatorConfiguration",
"(",
"final",
"Configuration",
"contextConfiguration",
",",
"final",
"Optional",
"<",
"Configuration",
">",
"serviceConfiguration",
",",
"final",
"Optional",
"<",
"Configuration",
">",
"taskConfiguration",
")",
"{",
"final",
"String",
"contextConfigurationString",
"=",
"this",
".",
"configurationSerializer",
".",
"toString",
"(",
"contextConfiguration",
")",
";",
"final",
"Optional",
"<",
"String",
">",
"taskConfigurationString",
";",
"if",
"(",
"taskConfiguration",
".",
"isPresent",
"(",
")",
")",
"{",
"taskConfigurationString",
"=",
"Optional",
".",
"of",
"(",
"this",
".",
"configurationSerializer",
".",
"toString",
"(",
"taskConfiguration",
".",
"get",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"taskConfigurationString",
"=",
"Optional",
".",
"empty",
"(",
")",
";",
"}",
"final",
"Optional",
"<",
"Configuration",
">",
"mergedServiceConfiguration",
"=",
"makeRootServiceConfiguration",
"(",
"serviceConfiguration",
")",
";",
"if",
"(",
"mergedServiceConfiguration",
".",
"isPresent",
"(",
")",
")",
"{",
"final",
"String",
"serviceConfigurationString",
"=",
"this",
".",
"configurationSerializer",
".",
"toString",
"(",
"mergedServiceConfiguration",
".",
"get",
"(",
")",
")",
";",
"return",
"makeEvaluatorConfiguration",
"(",
"contextConfigurationString",
",",
"Optional",
".",
"<",
"String",
">",
"empty",
"(",
")",
",",
"Optional",
".",
"of",
"(",
"serviceConfigurationString",
")",
",",
"taskConfigurationString",
")",
";",
"}",
"else",
"{",
"return",
"makeEvaluatorConfiguration",
"(",
"contextConfigurationString",
",",
"Optional",
".",
"<",
"String",
">",
"empty",
"(",
")",
",",
"Optional",
".",
"<",
"String",
">",
"empty",
"(",
")",
",",
"taskConfigurationString",
")",
";",
"}",
"}"
] | Make configuration for evaluator.
@param contextConfiguration
@param serviceConfiguration
@param taskConfiguration
@return Configuration | [
"Make",
"configuration",
"for",
"evaluator",
"."
] | train | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/evaluator/AllocatedEvaluatorImpl.java#L279-L301 |
ow2-chameleon/fuchsia | bases/knx/calimero/src/main/java/tuwien/auto/calimero/process/ProcessCommunicatorImpl.java | ProcessCommunicatorImpl.extractGroupASDU | private static void extractGroupASDU(byte[] apdu, DPTXlator t) {
"""
Extracts the service data unit of an application layer protocol data unit into a
DPT translator.
<p>
The whole service data unit is taken as data for translation. If the length of the
supplied <code>apdu</code> is 2, a compact group APDU format layout is assumed.<br>
On return of this method, the supplied translator contains the DPT items from the
ASDU.
@param apdu application layer protocol data unit, 2 <= apdu.length
@param t the DPT translator to fill with the ASDU
"""
if (apdu.length < 2)
throw new KNXIllegalArgumentException("minimum APDU length is 2 bytes");
t.setData(apdu, apdu.length == 2 ? 1 : 2);
} | java | private static void extractGroupASDU(byte[] apdu, DPTXlator t)
{
if (apdu.length < 2)
throw new KNXIllegalArgumentException("minimum APDU length is 2 bytes");
t.setData(apdu, apdu.length == 2 ? 1 : 2);
} | [
"private",
"static",
"void",
"extractGroupASDU",
"(",
"byte",
"[",
"]",
"apdu",
",",
"DPTXlator",
"t",
")",
"{",
"if",
"(",
"apdu",
".",
"length",
"<",
"2",
")",
"throw",
"new",
"KNXIllegalArgumentException",
"(",
"\"minimum APDU length is 2 bytes\"",
")",
";",
"t",
".",
"setData",
"(",
"apdu",
",",
"apdu",
".",
"length",
"==",
"2",
"?",
"1",
":",
"2",
")",
";",
"}"
] | Extracts the service data unit of an application layer protocol data unit into a
DPT translator.
<p>
The whole service data unit is taken as data for translation. If the length of the
supplied <code>apdu</code> is 2, a compact group APDU format layout is assumed.<br>
On return of this method, the supplied translator contains the DPT items from the
ASDU.
@param apdu application layer protocol data unit, 2 <= apdu.length
@param t the DPT translator to fill with the ASDU | [
"Extracts",
"the",
"service",
"data",
"unit",
"of",
"an",
"application",
"layer",
"protocol",
"data",
"unit",
"into",
"a",
"DPT",
"translator",
".",
"<p",
">",
"The",
"whole",
"service",
"data",
"unit",
"is",
"taken",
"as",
"data",
"for",
"translation",
".",
"If",
"the",
"length",
"of",
"the",
"supplied",
"<code",
">",
"apdu<",
"/",
"code",
">",
"is",
"2",
"a",
"compact",
"group",
"APDU",
"format",
"layout",
"is",
"assumed",
".",
"<br",
">",
"On",
"return",
"of",
"this",
"method",
"the",
"supplied",
"translator",
"contains",
"the",
"DPT",
"items",
"from",
"the",
"ASDU",
"."
] | train | https://github.com/ow2-chameleon/fuchsia/blob/4e9318eadbdeb945e529789f573b45386e619bed/bases/knx/calimero/src/main/java/tuwien/auto/calimero/process/ProcessCommunicatorImpl.java#L550-L555 |
gresrun/jesque | src/main/java/net/greghaines/jesque/utils/PoolUtils.java | PoolUtils.doWorkInPool | public static <V> V doWorkInPool(final Pool<Jedis> pool, final PoolWork<Jedis, V> work) throws Exception {
"""
Perform the given work with a Jedis connection from the given pool.
@param pool the resource pool
@param work the work to perform
@param <V> the result type
@return the result of the given work
@throws Exception if something went wrong
"""
if (pool == null) {
throw new IllegalArgumentException("pool must not be null");
}
if (work == null) {
throw new IllegalArgumentException("work must not be null");
}
final V result;
final Jedis poolResource = pool.getResource();
try {
result = work.doWork(poolResource);
} finally {
poolResource.close();
}
return result;
} | java | public static <V> V doWorkInPool(final Pool<Jedis> pool, final PoolWork<Jedis, V> work) throws Exception {
if (pool == null) {
throw new IllegalArgumentException("pool must not be null");
}
if (work == null) {
throw new IllegalArgumentException("work must not be null");
}
final V result;
final Jedis poolResource = pool.getResource();
try {
result = work.doWork(poolResource);
} finally {
poolResource.close();
}
return result;
} | [
"public",
"static",
"<",
"V",
">",
"V",
"doWorkInPool",
"(",
"final",
"Pool",
"<",
"Jedis",
">",
"pool",
",",
"final",
"PoolWork",
"<",
"Jedis",
",",
"V",
">",
"work",
")",
"throws",
"Exception",
"{",
"if",
"(",
"pool",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"pool must not be null\"",
")",
";",
"}",
"if",
"(",
"work",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"work must not be null\"",
")",
";",
"}",
"final",
"V",
"result",
";",
"final",
"Jedis",
"poolResource",
"=",
"pool",
".",
"getResource",
"(",
")",
";",
"try",
"{",
"result",
"=",
"work",
".",
"doWork",
"(",
"poolResource",
")",
";",
"}",
"finally",
"{",
"poolResource",
".",
"close",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Perform the given work with a Jedis connection from the given pool.
@param pool the resource pool
@param work the work to perform
@param <V> the result type
@return the result of the given work
@throws Exception if something went wrong | [
"Perform",
"the",
"given",
"work",
"with",
"a",
"Jedis",
"connection",
"from",
"the",
"given",
"pool",
"."
] | train | https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/PoolUtils.java#L42-L57 |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.getDistinctEventLogEventSources | public String[] getDistinctEventLogEventSources()
throws DataAccessException, EventException {
"""
Method that returns distinct event log sources
@return String[]
"""
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
return edao.getDistinctEventLogEventSources();
} catch (SQLException e) {
throw new EventException("Failed to notify events", e);
} finally {
edao.stopTransaction(transaction);
}
} | java | public String[] getDistinctEventLogEventSources()
throws DataAccessException, EventException {
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
return edao.getDistinctEventLogEventSources();
} catch (SQLException e) {
throw new EventException("Failed to notify events", e);
} finally {
edao.stopTransaction(transaction);
}
} | [
"public",
"String",
"[",
"]",
"getDistinctEventLogEventSources",
"(",
")",
"throws",
"DataAccessException",
",",
"EventException",
"{",
"TransactionWrapper",
"transaction",
"=",
"null",
";",
"EngineDataAccessDB",
"edao",
"=",
"new",
"EngineDataAccessDB",
"(",
")",
";",
"try",
"{",
"transaction",
"=",
"edao",
".",
"startTransaction",
"(",
")",
";",
"return",
"edao",
".",
"getDistinctEventLogEventSources",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"EventException",
"(",
"\"Failed to notify events\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"edao",
".",
"stopTransaction",
"(",
"transaction",
")",
";",
"}",
"}"
] | Method that returns distinct event log sources
@return String[] | [
"Method",
"that",
"returns",
"distinct",
"event",
"log",
"sources"
] | train | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L121-L133 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/ComputeNodeOperations.java | ComputeNodeOperations.enableComputeNodeScheduling | public void enableComputeNodeScheduling(String poolId, String nodeId) throws BatchErrorException, IOException {
"""
Enables task scheduling on the specified compute node.
@param poolId The ID of the pool.
@param nodeId The ID of the compute node.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
"""
enableComputeNodeScheduling(poolId, nodeId, null);
} | java | public void enableComputeNodeScheduling(String poolId, String nodeId) throws BatchErrorException, IOException {
enableComputeNodeScheduling(poolId, nodeId, null);
} | [
"public",
"void",
"enableComputeNodeScheduling",
"(",
"String",
"poolId",
",",
"String",
"nodeId",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"enableComputeNodeScheduling",
"(",
"poolId",
",",
"nodeId",
",",
"null",
")",
";",
"}"
] | Enables task scheduling on the specified compute node.
@param poolId The ID of the pool.
@param nodeId The ID of the compute node.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. | [
"Enables",
"task",
"scheduling",
"on",
"the",
"specified",
"compute",
"node",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/ComputeNodeOperations.java#L411-L413 |
vincentk/joptimizer | src/main/java/com/joptimizer/algebra/MatrixLogSumRescaler.java | MatrixLogSumRescaler.getMatrixScalingFactorsSymm | @Override
public DoubleMatrix1D getMatrixScalingFactorsSymm(DoubleMatrix2D A) {
"""
Symmetry preserving scale factors
@see Gajulapalli, Lasdon "Scaling Sparse Matrices for Optimization Algorithms", algorithm 3
"""
int n = A.rows();
final double log10_b = Math.log10(base);
final int[] x = new int[n];
final double[] cHolder = new double[1];
final double[] tHolder = new double[1];
final int[] currentColumnIndexHolder = new int[] { -1 };
IntIntDoubleFunction myFunct = new IntIntDoubleFunction() {
@Override
public double apply(int i, int j, double pij) {
int currentColumnIndex = currentColumnIndexHolder[0];
// we take into account only the lower left subdiagonal part of Q (that is symmetric)
if(i == currentColumnIndex){
//diagonal element
//log.debug("i:" + i + ", j:" + currentColumnIndex + ": " + pij);
tHolder[0] = tHolder[0] - 0.5 * (Math.log10(Math.abs(pij))/log10_b + 0.5);//log(b, x) = log(k, x) / log(k, b)
cHolder[0] = cHolder[0] + 1;
}else if (i > currentColumnIndex) {
//sub-diagonal elements
//log.debug("i:" + i + ", j:" + currentColumnIndex + ": " + pij);
tHolder[0] = tHolder[0] - 2 * (Math.log10(Math.abs(pij))/log10_b + 0.5) -2*x[i];//log(b, x) = log(k, x) / log(k, b)
cHolder[0] = cHolder[0] + 2;//- 2*x[i]
}
return pij;
}
};
//view A column by column
for (int currentColumnIndex = n - 1; currentColumnIndex >= 0; currentColumnIndex--) {
//log.debug("currentColumnIndex:" + currentColumnIndex);
cHolder[0] = 0;//reset
tHolder[0] = 0;//reset
currentColumnIndexHolder[0] = currentColumnIndex;
DoubleMatrix2D P = A.viewPart(0, currentColumnIndex, n, 1);
P.forEachNonZero(myFunct);
if(cHolder[0] > 0){
x[currentColumnIndex] = (int)Math.round(tHolder[0] / cHolder[0]);
}
}
//log.debug("x: " + ArrayUtils.toString(x));
DoubleMatrix1D u = new DenseDoubleMatrix1D(n);
for (int k = 0; k < n; k++) {
u.setQuick(k, Math.pow(base, x[k]));
}
return u;
} | java | @Override
public DoubleMatrix1D getMatrixScalingFactorsSymm(DoubleMatrix2D A) {
int n = A.rows();
final double log10_b = Math.log10(base);
final int[] x = new int[n];
final double[] cHolder = new double[1];
final double[] tHolder = new double[1];
final int[] currentColumnIndexHolder = new int[] { -1 };
IntIntDoubleFunction myFunct = new IntIntDoubleFunction() {
@Override
public double apply(int i, int j, double pij) {
int currentColumnIndex = currentColumnIndexHolder[0];
// we take into account only the lower left subdiagonal part of Q (that is symmetric)
if(i == currentColumnIndex){
//diagonal element
//log.debug("i:" + i + ", j:" + currentColumnIndex + ": " + pij);
tHolder[0] = tHolder[0] - 0.5 * (Math.log10(Math.abs(pij))/log10_b + 0.5);//log(b, x) = log(k, x) / log(k, b)
cHolder[0] = cHolder[0] + 1;
}else if (i > currentColumnIndex) {
//sub-diagonal elements
//log.debug("i:" + i + ", j:" + currentColumnIndex + ": " + pij);
tHolder[0] = tHolder[0] - 2 * (Math.log10(Math.abs(pij))/log10_b + 0.5) -2*x[i];//log(b, x) = log(k, x) / log(k, b)
cHolder[0] = cHolder[0] + 2;//- 2*x[i]
}
return pij;
}
};
//view A column by column
for (int currentColumnIndex = n - 1; currentColumnIndex >= 0; currentColumnIndex--) {
//log.debug("currentColumnIndex:" + currentColumnIndex);
cHolder[0] = 0;//reset
tHolder[0] = 0;//reset
currentColumnIndexHolder[0] = currentColumnIndex;
DoubleMatrix2D P = A.viewPart(0, currentColumnIndex, n, 1);
P.forEachNonZero(myFunct);
if(cHolder[0] > 0){
x[currentColumnIndex] = (int)Math.round(tHolder[0] / cHolder[0]);
}
}
//log.debug("x: " + ArrayUtils.toString(x));
DoubleMatrix1D u = new DenseDoubleMatrix1D(n);
for (int k = 0; k < n; k++) {
u.setQuick(k, Math.pow(base, x[k]));
}
return u;
} | [
"@",
"Override",
"public",
"DoubleMatrix1D",
"getMatrixScalingFactorsSymm",
"(",
"DoubleMatrix2D",
"A",
")",
"{",
"int",
"n",
"=",
"A",
".",
"rows",
"(",
")",
";",
"final",
"double",
"log10_b",
"=",
"Math",
".",
"log10",
"(",
"base",
")",
";",
"final",
"int",
"[",
"]",
"x",
"=",
"new",
"int",
"[",
"n",
"]",
";",
"final",
"double",
"[",
"]",
"cHolder",
"=",
"new",
"double",
"[",
"1",
"]",
";",
"final",
"double",
"[",
"]",
"tHolder",
"=",
"new",
"double",
"[",
"1",
"]",
";",
"final",
"int",
"[",
"]",
"currentColumnIndexHolder",
"=",
"new",
"int",
"[",
"]",
"{",
"-",
"1",
"}",
";",
"IntIntDoubleFunction",
"myFunct",
"=",
"new",
"IntIntDoubleFunction",
"(",
")",
"{",
"@",
"Override",
"public",
"double",
"apply",
"(",
"int",
"i",
",",
"int",
"j",
",",
"double",
"pij",
")",
"{",
"int",
"currentColumnIndex",
"=",
"currentColumnIndexHolder",
"[",
"0",
"]",
";",
"// we take into account only the lower left subdiagonal part of Q (that is symmetric)\r",
"if",
"(",
"i",
"==",
"currentColumnIndex",
")",
"{",
"//diagonal element\r",
"//log.debug(\"i:\" + i + \", j:\" + currentColumnIndex + \": \" + pij);\r",
"tHolder",
"[",
"0",
"]",
"=",
"tHolder",
"[",
"0",
"]",
"-",
"0.5",
"*",
"(",
"Math",
".",
"log10",
"(",
"Math",
".",
"abs",
"(",
"pij",
")",
")",
"/",
"log10_b",
"+",
"0.5",
")",
";",
"//log(b, x) = log(k, x) / log(k, b)\r",
"cHolder",
"[",
"0",
"]",
"=",
"cHolder",
"[",
"0",
"]",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"i",
">",
"currentColumnIndex",
")",
"{",
"//sub-diagonal elements\r",
"//log.debug(\"i:\" + i + \", j:\" + currentColumnIndex + \": \" + pij);\r",
"tHolder",
"[",
"0",
"]",
"=",
"tHolder",
"[",
"0",
"]",
"-",
"2",
"*",
"(",
"Math",
".",
"log10",
"(",
"Math",
".",
"abs",
"(",
"pij",
")",
")",
"/",
"log10_b",
"+",
"0.5",
")",
"-",
"2",
"*",
"x",
"[",
"i",
"]",
";",
"//log(b, x) = log(k, x) / log(k, b)\r",
"cHolder",
"[",
"0",
"]",
"=",
"cHolder",
"[",
"0",
"]",
"+",
"2",
";",
"//- 2*x[i]\r",
"}",
"return",
"pij",
";",
"}",
"}",
";",
"//view A column by column\r",
"for",
"(",
"int",
"currentColumnIndex",
"=",
"n",
"-",
"1",
";",
"currentColumnIndex",
">=",
"0",
";",
"currentColumnIndex",
"--",
")",
"{",
"//log.debug(\"currentColumnIndex:\" + currentColumnIndex);\r",
"cHolder",
"[",
"0",
"]",
"=",
"0",
";",
"//reset\r",
"tHolder",
"[",
"0",
"]",
"=",
"0",
";",
"//reset\r",
"currentColumnIndexHolder",
"[",
"0",
"]",
"=",
"currentColumnIndex",
";",
"DoubleMatrix2D",
"P",
"=",
"A",
".",
"viewPart",
"(",
"0",
",",
"currentColumnIndex",
",",
"n",
",",
"1",
")",
";",
"P",
".",
"forEachNonZero",
"(",
"myFunct",
")",
";",
"if",
"(",
"cHolder",
"[",
"0",
"]",
">",
"0",
")",
"{",
"x",
"[",
"currentColumnIndex",
"]",
"=",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"tHolder",
"[",
"0",
"]",
"/",
"cHolder",
"[",
"0",
"]",
")",
";",
"}",
"}",
"//log.debug(\"x: \" + ArrayUtils.toString(x));\r",
"DoubleMatrix1D",
"u",
"=",
"new",
"DenseDoubleMatrix1D",
"(",
"n",
")",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"n",
";",
"k",
"++",
")",
"{",
"u",
".",
"setQuick",
"(",
"k",
",",
"Math",
".",
"pow",
"(",
"base",
",",
"x",
"[",
"k",
"]",
")",
")",
";",
"}",
"return",
"u",
";",
"}"
] | Symmetry preserving scale factors
@see Gajulapalli, Lasdon "Scaling Sparse Matrices for Optimization Algorithms", algorithm 3 | [
"Symmetry",
"preserving",
"scale",
"factors"
] | train | https://github.com/vincentk/joptimizer/blob/65064c1bb0b26c7261358021e4c93d06dd43564f/src/main/java/com/joptimizer/algebra/MatrixLogSumRescaler.java#L181-L230 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/MessageDigest.java | MessageDigest.getInstance | public static MessageDigest getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
"""
Returns a MessageDigest object that implements the specified digest
algorithm.
<p> A new MessageDigest object encapsulating the
MessageDigestSpi implementation from the specified provider
is returned. The specified provider must be registered
in the security provider list.
<p> Note that the list of registered providers may be retrieved via
the {@link Security#getProviders() Security.getProviders()} method.
@param algorithm the name of the algorithm requested.
See the MessageDigest section in the <a href=
"{@docRoot}openjdk-redirect.html?v=8&path=/technotes/guides/security/StandardNames.html#MessageDigest">
Java Cryptography Architecture Standard Algorithm Name Documentation</a>
for information about standard algorithm names.
@param provider the name of the provider.
@return a MessageDigest object that implements the specified algorithm.
@exception NoSuchAlgorithmException if a MessageDigestSpi
implementation for the specified algorithm is not
available from the specified provider.
@exception NoSuchProviderException if the specified provider is not
registered in the security provider list.
@exception IllegalArgumentException if the provider name is null
or empty.
@see Provider
"""
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
if (objs[0] instanceof MessageDigest) {
MessageDigest md = (MessageDigest)objs[0];
md.provider = (Provider)objs[1];
return md;
} else {
MessageDigest delegate =
new Delegate((MessageDigestSpi)objs[0], algorithm);
delegate.provider = (Provider)objs[1];
return delegate;
}
} | java | public static MessageDigest getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
if (objs[0] instanceof MessageDigest) {
MessageDigest md = (MessageDigest)objs[0];
md.provider = (Provider)objs[1];
return md;
} else {
MessageDigest delegate =
new Delegate((MessageDigestSpi)objs[0], algorithm);
delegate.provider = (Provider)objs[1];
return delegate;
}
} | [
"public",
"static",
"MessageDigest",
"getInstance",
"(",
"String",
"algorithm",
",",
"String",
"provider",
")",
"throws",
"NoSuchAlgorithmException",
",",
"NoSuchProviderException",
"{",
"if",
"(",
"provider",
"==",
"null",
"||",
"provider",
".",
"length",
"(",
")",
"==",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"missing provider\"",
")",
";",
"Object",
"[",
"]",
"objs",
"=",
"Security",
".",
"getImpl",
"(",
"algorithm",
",",
"\"MessageDigest\"",
",",
"provider",
")",
";",
"if",
"(",
"objs",
"[",
"0",
"]",
"instanceof",
"MessageDigest",
")",
"{",
"MessageDigest",
"md",
"=",
"(",
"MessageDigest",
")",
"objs",
"[",
"0",
"]",
";",
"md",
".",
"provider",
"=",
"(",
"Provider",
")",
"objs",
"[",
"1",
"]",
";",
"return",
"md",
";",
"}",
"else",
"{",
"MessageDigest",
"delegate",
"=",
"new",
"Delegate",
"(",
"(",
"MessageDigestSpi",
")",
"objs",
"[",
"0",
"]",
",",
"algorithm",
")",
";",
"delegate",
".",
"provider",
"=",
"(",
"Provider",
")",
"objs",
"[",
"1",
"]",
";",
"return",
"delegate",
";",
"}",
"}"
] | Returns a MessageDigest object that implements the specified digest
algorithm.
<p> A new MessageDigest object encapsulating the
MessageDigestSpi implementation from the specified provider
is returned. The specified provider must be registered
in the security provider list.
<p> Note that the list of registered providers may be retrieved via
the {@link Security#getProviders() Security.getProviders()} method.
@param algorithm the name of the algorithm requested.
See the MessageDigest section in the <a href=
"{@docRoot}openjdk-redirect.html?v=8&path=/technotes/guides/security/StandardNames.html#MessageDigest">
Java Cryptography Architecture Standard Algorithm Name Documentation</a>
for information about standard algorithm names.
@param provider the name of the provider.
@return a MessageDigest object that implements the specified algorithm.
@exception NoSuchAlgorithmException if a MessageDigestSpi
implementation for the specified algorithm is not
available from the specified provider.
@exception NoSuchProviderException if the specified provider is not
registered in the security provider list.
@exception IllegalArgumentException if the provider name is null
or empty.
@see Provider | [
"Returns",
"a",
"MessageDigest",
"object",
"that",
"implements",
"the",
"specified",
"digest",
"algorithm",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/MessageDigest.java#L257-L273 |
nextreports/nextreports-engine | src/ro/nextreports/engine/querybuilder/sql/dialect/DialectFactory.java | DialectFactory.buildDialect | public static Dialect buildDialect(String dialectName) throws DialectException {
"""
Returns a dialect instance given the name of the class to use.
@param dialectName The name of the dialect class.
@return The dialect instance.
@throws DialectException
"""
try {
return (Dialect) loadDialect(dialectName).newInstance();
} catch (ClassNotFoundException e) {
throw new DialectException("Dialect class not found: " + dialectName);
} catch (Exception e) {
throw new DialectException("Could not instantiate dialect class", e);
}
} | java | public static Dialect buildDialect(String dialectName) throws DialectException {
try {
return (Dialect) loadDialect(dialectName).newInstance();
} catch (ClassNotFoundException e) {
throw new DialectException("Dialect class not found: " + dialectName);
} catch (Exception e) {
throw new DialectException("Could not instantiate dialect class", e);
}
} | [
"public",
"static",
"Dialect",
"buildDialect",
"(",
"String",
"dialectName",
")",
"throws",
"DialectException",
"{",
"try",
"{",
"return",
"(",
"Dialect",
")",
"loadDialect",
"(",
"dialectName",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"DialectException",
"(",
"\"Dialect class not found: \"",
"+",
"dialectName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"DialectException",
"(",
"\"Could not instantiate dialect class\"",
",",
"e",
")",
";",
"}",
"}"
] | Returns a dialect instance given the name of the class to use.
@param dialectName The name of the dialect class.
@return The dialect instance.
@throws DialectException | [
"Returns",
"a",
"dialect",
"instance",
"given",
"the",
"name",
"of",
"the",
"class",
"to",
"use",
"."
] | train | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/querybuilder/sql/dialect/DialectFactory.java#L115-L123 |
facebookarchive/hadoop-20 | src/contrib/corona/src/java/org/apache/hadoop/mapred/CoronaReleaseManager.java | CoronaReleaseManager.getLastTimeStamp | private long getLastTimeStamp() {
"""
getLastStamp will go throught all the files and directories in the release
directory, and find the largest timestamp. This is used to check if there
is any new release. RELEASE_COPY_PATTERN and CORONA_RELEASE_FILE_CHECK can
be used to limit the files checked
"""
long result = -1;
if (coronaReleaseFileCheck != null && !coronaReleaseFileCheck.isEmpty()) {
result = getLastTimeStamp(new Path(releasePath, coronaReleaseFileCheck));
if (result > 0) {
return result;
}
}
return getLastTimeStamp(releasePath);
} | java | private long getLastTimeStamp() {
long result = -1;
if (coronaReleaseFileCheck != null && !coronaReleaseFileCheck.isEmpty()) {
result = getLastTimeStamp(new Path(releasePath, coronaReleaseFileCheck));
if (result > 0) {
return result;
}
}
return getLastTimeStamp(releasePath);
} | [
"private",
"long",
"getLastTimeStamp",
"(",
")",
"{",
"long",
"result",
"=",
"-",
"1",
";",
"if",
"(",
"coronaReleaseFileCheck",
"!=",
"null",
"&&",
"!",
"coronaReleaseFileCheck",
".",
"isEmpty",
"(",
")",
")",
"{",
"result",
"=",
"getLastTimeStamp",
"(",
"new",
"Path",
"(",
"releasePath",
",",
"coronaReleaseFileCheck",
")",
")",
";",
"if",
"(",
"result",
">",
"0",
")",
"{",
"return",
"result",
";",
"}",
"}",
"return",
"getLastTimeStamp",
"(",
"releasePath",
")",
";",
"}"
] | getLastStamp will go throught all the files and directories in the release
directory, and find the largest timestamp. This is used to check if there
is any new release. RELEASE_COPY_PATTERN and CORONA_RELEASE_FILE_CHECK can
be used to limit the files checked | [
"getLastStamp",
"will",
"go",
"throught",
"all",
"the",
"files",
"and",
"directories",
"in",
"the",
"release",
"directory",
"and",
"find",
"the",
"largest",
"timestamp",
".",
"This",
"is",
"used",
"to",
"check",
"if",
"there",
"is",
"any",
"new",
"release",
".",
"RELEASE_COPY_PATTERN",
"and",
"CORONA_RELEASE_FILE_CHECK",
"can",
"be",
"used",
"to",
"limit",
"the",
"files",
"checked"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/corona/src/java/org/apache/hadoop/mapred/CoronaReleaseManager.java#L352-L361 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/Validator.java | Validator.validateMatchRegex | public static <T extends CharSequence> T validateMatchRegex(String regex, T value, String errorMsg) throws ValidateException {
"""
通过正则表达式验证<br>
不符合正则抛出{@link ValidateException} 异常
@param <T> 字符串类型
@param regex 正则
@param value 值
@param errorMsg 验证错误的信息
@return 验证后的值
@throws ValidateException 验证异常
"""
if (false == isMactchRegex(regex, value)) {
throw new ValidateException(errorMsg);
}
return value;
} | java | public static <T extends CharSequence> T validateMatchRegex(String regex, T value, String errorMsg) throws ValidateException {
if (false == isMactchRegex(regex, value)) {
throw new ValidateException(errorMsg);
}
return value;
} | [
"public",
"static",
"<",
"T",
"extends",
"CharSequence",
">",
"T",
"validateMatchRegex",
"(",
"String",
"regex",
",",
"T",
"value",
",",
"String",
"errorMsg",
")",
"throws",
"ValidateException",
"{",
"if",
"(",
"false",
"==",
"isMactchRegex",
"(",
"regex",
",",
"value",
")",
")",
"{",
"throw",
"new",
"ValidateException",
"(",
"errorMsg",
")",
";",
"}",
"return",
"value",
";",
"}"
] | 通过正则表达式验证<br>
不符合正则抛出{@link ValidateException} 异常
@param <T> 字符串类型
@param regex 正则
@param value 值
@param errorMsg 验证错误的信息
@return 验证后的值
@throws ValidateException 验证异常 | [
"通过正则表达式验证<br",
">",
"不符合正则抛出",
"{",
"@link",
"ValidateException",
"}",
"异常"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Validator.java#L321-L326 |
livetribe/livetribe-slp | core/src/main/java/org/livetribe/slp/Attributes.java | Attributes.from | public static Attributes from(Map<String, String> stringMap) {
"""
Creates an <code>Attributes</code> object converting the given string map.
The keys and values are not escaped.
@param stringMap The string map containing the attributes convert
@return a new Attributes instance obtained converting the given string map
@throws ServiceLocationException If the conversion fails
"""
if (stringMap == null || stringMap.size() == 0) return NONE;
Attributes result = new Attributes();
for (Map.Entry<String, String> entry : stringMap.entrySet())
{
result.attributes.put(Tag.from(entry.getKey(), false), Value.from(entry.getValue()));
}
return result;
} | java | public static Attributes from(Map<String, String> stringMap)
{
if (stringMap == null || stringMap.size() == 0) return NONE;
Attributes result = new Attributes();
for (Map.Entry<String, String> entry : stringMap.entrySet())
{
result.attributes.put(Tag.from(entry.getKey(), false), Value.from(entry.getValue()));
}
return result;
} | [
"public",
"static",
"Attributes",
"from",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"stringMap",
")",
"{",
"if",
"(",
"stringMap",
"==",
"null",
"||",
"stringMap",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
"NONE",
";",
"Attributes",
"result",
"=",
"new",
"Attributes",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"stringMap",
".",
"entrySet",
"(",
")",
")",
"{",
"result",
".",
"attributes",
".",
"put",
"(",
"Tag",
".",
"from",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"false",
")",
",",
"Value",
".",
"from",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Creates an <code>Attributes</code> object converting the given string map.
The keys and values are not escaped.
@param stringMap The string map containing the attributes convert
@return a new Attributes instance obtained converting the given string map
@throws ServiceLocationException If the conversion fails | [
"Creates",
"an",
"<code",
">",
"Attributes<",
"/",
"code",
">",
"object",
"converting",
"the",
"given",
"string",
"map",
".",
"The",
"keys",
"and",
"values",
"are",
"not",
"escaped",
"."
] | train | https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/Attributes.java#L95-L107 |
apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/scheduler/JobScheduler.java | JobScheduler.scheduleJob | public void scheduleJob(Properties jobProps, JobListener jobListener)
throws JobException {
"""
Schedule a job.
<p>
This method calls the Quartz scheduler to scheduler the job.
</p>
@param jobProps Job configuration properties
@param jobListener {@link JobListener} used for callback,
can be <em>null</em> if no callback is needed.
@throws JobException when there is anything wrong
with scheduling the job
"""
try {
scheduleJob(jobProps, jobListener, Maps.<String, Object>newHashMap(), GobblinJob.class);
} catch (JobException | RuntimeException exc) {
LOG.error("Could not schedule job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "Unknown job"), exc);
}
} | java | public void scheduleJob(Properties jobProps, JobListener jobListener)
throws JobException {
try {
scheduleJob(jobProps, jobListener, Maps.<String, Object>newHashMap(), GobblinJob.class);
} catch (JobException | RuntimeException exc) {
LOG.error("Could not schedule job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "Unknown job"), exc);
}
} | [
"public",
"void",
"scheduleJob",
"(",
"Properties",
"jobProps",
",",
"JobListener",
"jobListener",
")",
"throws",
"JobException",
"{",
"try",
"{",
"scheduleJob",
"(",
"jobProps",
",",
"jobListener",
",",
"Maps",
".",
"<",
"String",
",",
"Object",
">",
"newHashMap",
"(",
")",
",",
"GobblinJob",
".",
"class",
")",
";",
"}",
"catch",
"(",
"JobException",
"|",
"RuntimeException",
"exc",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Could not schedule job \"",
"+",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"JOB_NAME_KEY",
",",
"\"Unknown job\"",
")",
",",
"exc",
")",
";",
"}",
"}"
] | Schedule a job.
<p>
This method calls the Quartz scheduler to scheduler the job.
</p>
@param jobProps Job configuration properties
@param jobListener {@link JobListener} used for callback,
can be <em>null</em> if no callback is needed.
@throws JobException when there is anything wrong
with scheduling the job | [
"Schedule",
"a",
"job",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/scheduler/JobScheduler.java#L236-L243 |
apereo/cas | core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/crypto/GlibcCryptPasswordEncoder.java | GlibcCryptPasswordEncoder.matches | @Override
public boolean matches(final CharSequence rawPassword, final String encodedPassword) {
"""
Special note on DES UnixCrypt:
In DES UnixCrypt, so first two characters of the encoded password are the salt.
<p>
When you change your password, the {@code /bin/passwd} program selects a salt based on the time of day.
The salt is converted into a two-character string and is stored in the {@code /etc/passwd} file along with the
encrypted {@code "password."[10]} In this manner, when you type your password at login time, the same salt is used again.
UNIX stores the salt as the first two characters of the encrypted password.
@param rawPassword the raw password as it was provided
@param encodedPassword the encoded password.
@return true/false
"""
if (StringUtils.isBlank(encodedPassword)) {
LOGGER.warn("The encoded password provided for matching is null. Returning false");
return false;
}
var providedSalt = StringUtils.EMPTY;
val lastDollarIndex = encodedPassword.lastIndexOf('$');
if (lastDollarIndex == -1) {
providedSalt = encodedPassword.substring(0, 2);
LOGGER.debug("Assuming DES UnixCrypt as no delimiter could be found in the encoded password provided");
} else {
providedSalt = encodedPassword.substring(0, lastDollarIndex);
LOGGER.debug("Encoded password uses algorithm [{}]", providedSalt.charAt(1));
}
var encodedRawPassword = Crypt.crypt(rawPassword.toString(), providedSalt);
var matched = StringUtils.equals(encodedRawPassword, encodedPassword);
LOGGER.debug("Provided password does {}match the encoded password", BooleanUtils.toString(matched, StringUtils.EMPTY, "not "));
return matched;
} | java | @Override
public boolean matches(final CharSequence rawPassword, final String encodedPassword) {
if (StringUtils.isBlank(encodedPassword)) {
LOGGER.warn("The encoded password provided for matching is null. Returning false");
return false;
}
var providedSalt = StringUtils.EMPTY;
val lastDollarIndex = encodedPassword.lastIndexOf('$');
if (lastDollarIndex == -1) {
providedSalt = encodedPassword.substring(0, 2);
LOGGER.debug("Assuming DES UnixCrypt as no delimiter could be found in the encoded password provided");
} else {
providedSalt = encodedPassword.substring(0, lastDollarIndex);
LOGGER.debug("Encoded password uses algorithm [{}]", providedSalt.charAt(1));
}
var encodedRawPassword = Crypt.crypt(rawPassword.toString(), providedSalt);
var matched = StringUtils.equals(encodedRawPassword, encodedPassword);
LOGGER.debug("Provided password does {}match the encoded password", BooleanUtils.toString(matched, StringUtils.EMPTY, "not "));
return matched;
} | [
"@",
"Override",
"public",
"boolean",
"matches",
"(",
"final",
"CharSequence",
"rawPassword",
",",
"final",
"String",
"encodedPassword",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"encodedPassword",
")",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"The encoded password provided for matching is null. Returning false\"",
")",
";",
"return",
"false",
";",
"}",
"var",
"providedSalt",
"=",
"StringUtils",
".",
"EMPTY",
";",
"val",
"lastDollarIndex",
"=",
"encodedPassword",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"lastDollarIndex",
"==",
"-",
"1",
")",
"{",
"providedSalt",
"=",
"encodedPassword",
".",
"substring",
"(",
"0",
",",
"2",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Assuming DES UnixCrypt as no delimiter could be found in the encoded password provided\"",
")",
";",
"}",
"else",
"{",
"providedSalt",
"=",
"encodedPassword",
".",
"substring",
"(",
"0",
",",
"lastDollarIndex",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Encoded password uses algorithm [{}]\"",
",",
"providedSalt",
".",
"charAt",
"(",
"1",
")",
")",
";",
"}",
"var",
"encodedRawPassword",
"=",
"Crypt",
".",
"crypt",
"(",
"rawPassword",
".",
"toString",
"(",
")",
",",
"providedSalt",
")",
";",
"var",
"matched",
"=",
"StringUtils",
".",
"equals",
"(",
"encodedRawPassword",
",",
"encodedPassword",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Provided password does {}match the encoded password\"",
",",
"BooleanUtils",
".",
"toString",
"(",
"matched",
",",
"StringUtils",
".",
"EMPTY",
",",
"\"not \"",
")",
")",
";",
"return",
"matched",
";",
"}"
] | Special note on DES UnixCrypt:
In DES UnixCrypt, so first two characters of the encoded password are the salt.
<p>
When you change your password, the {@code /bin/passwd} program selects a salt based on the time of day.
The salt is converted into a two-character string and is stored in the {@code /etc/passwd} file along with the
encrypted {@code "password."[10]} In this manner, when you type your password at login time, the same salt is used again.
UNIX stores the salt as the first two characters of the encrypted password.
@param rawPassword the raw password as it was provided
@param encodedPassword the encoded password.
@return true/false | [
"Special",
"note",
"on",
"DES",
"UnixCrypt",
":",
"In",
"DES",
"UnixCrypt",
"so",
"first",
"two",
"characters",
"of",
"the",
"encoded",
"password",
"are",
"the",
"salt",
".",
"<p",
">",
"When",
"you",
"change",
"your",
"password",
"the",
"{",
"@code",
"/",
"bin",
"/",
"passwd",
"}",
"program",
"selects",
"a",
"salt",
"based",
"on",
"the",
"time",
"of",
"day",
".",
"The",
"salt",
"is",
"converted",
"into",
"a",
"two",
"-",
"character",
"string",
"and",
"is",
"stored",
"in",
"the",
"{",
"@code",
"/",
"etc",
"/",
"passwd",
"}",
"file",
"along",
"with",
"the",
"encrypted",
"{",
"@code",
"password",
".",
"[",
"10",
"]",
"}",
"In",
"this",
"manner",
"when",
"you",
"type",
"your",
"password",
"at",
"login",
"time",
"the",
"same",
"salt",
"is",
"used",
"again",
".",
"UNIX",
"stores",
"the",
"salt",
"as",
"the",
"first",
"two",
"characters",
"of",
"the",
"encrypted",
"password",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/crypto/GlibcCryptPasswordEncoder.java#L56-L75 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/misc/ImageMiscOps.java | ImageMiscOps.fillBand | public static void fillBand(InterleavedF64 input, int band , double value) {
"""
Fills one band in the image with the specified value
@param input An image.
@param band Which band is to be filled with the specified value
@param value The value that the image is being filled with.
"""
final int numBands = input.numBands;
for (int y = 0; y < input.height; y++) {
int index = input.getStartIndex() + y * input.getStride() + band;
int end = index + input.width*numBands - band;
for (; index < end; index += numBands ) {
input.data[index] = value;
}
}
} | java | public static void fillBand(InterleavedF64 input, int band , double value) {
final int numBands = input.numBands;
for (int y = 0; y < input.height; y++) {
int index = input.getStartIndex() + y * input.getStride() + band;
int end = index + input.width*numBands - band;
for (; index < end; index += numBands ) {
input.data[index] = value;
}
}
} | [
"public",
"static",
"void",
"fillBand",
"(",
"InterleavedF64",
"input",
",",
"int",
"band",
",",
"double",
"value",
")",
"{",
"final",
"int",
"numBands",
"=",
"input",
".",
"numBands",
";",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"input",
".",
"height",
";",
"y",
"++",
")",
"{",
"int",
"index",
"=",
"input",
".",
"getStartIndex",
"(",
")",
"+",
"y",
"*",
"input",
".",
"getStride",
"(",
")",
"+",
"band",
";",
"int",
"end",
"=",
"index",
"+",
"input",
".",
"width",
"*",
"numBands",
"-",
"band",
";",
"for",
"(",
";",
"index",
"<",
"end",
";",
"index",
"+=",
"numBands",
")",
"{",
"input",
".",
"data",
"[",
"index",
"]",
"=",
"value",
";",
"}",
"}",
"}"
] | Fills one band in the image with the specified value
@param input An image.
@param band Which band is to be filled with the specified value
@param value The value that the image is being filled with. | [
"Fills",
"one",
"band",
"in",
"the",
"image",
"with",
"the",
"specified",
"value"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/ImageMiscOps.java#L2847-L2857 |
overturetool/overture | core/parser/src/main/java/org/overture/parser/syntax/SyntaxReader.java | SyntaxReader.throwMessage | protected void throwMessage(int number, String message, int depth)
throws ParserException, LexException {
"""
Raise a {@link ParserException} with a given token depth.
@param number The error number.
@param message The error message.
@param depth The depth of the exception (tokens read).
@throws ParserException
"""
throw new ParserException(number, message, lastToken().location, depth);
} | java | protected void throwMessage(int number, String message, int depth)
throws ParserException, LexException
{
throw new ParserException(number, message, lastToken().location, depth);
} | [
"protected",
"void",
"throwMessage",
"(",
"int",
"number",
",",
"String",
"message",
",",
"int",
"depth",
")",
"throws",
"ParserException",
",",
"LexException",
"{",
"throw",
"new",
"ParserException",
"(",
"number",
",",
"message",
",",
"lastToken",
"(",
")",
".",
"location",
",",
"depth",
")",
";",
"}"
] | Raise a {@link ParserException} with a given token depth.
@param number The error number.
@param message The error message.
@param depth The depth of the exception (tokens read).
@throws ParserException | [
"Raise",
"a",
"{",
"@link",
"ParserException",
"}",
"with",
"a",
"given",
"token",
"depth",
".",
"@param",
"number",
"The",
"error",
"number",
".",
"@param",
"message",
"The",
"error",
"message",
".",
"@param",
"depth",
"The",
"depth",
"of",
"the",
"exception",
"(",
"tokens",
"read",
")",
"."
] | train | https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/parser/src/main/java/org/overture/parser/syntax/SyntaxReader.java#L522-L526 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WFigureRenderer.java | WFigureRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
"""
Paints the given WFigure.
@param component the WFigure to paint.
@param renderContext the RenderContext to paint to.
"""
WFigure figure = (WFigure) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean renderChildren = isRenderContent(figure);
xml.appendTagOpen("ui:figure");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
if (FigureMode.LAZY.equals(figure.getMode())) {
xml.appendOptionalAttribute("hidden", !renderChildren, "true");
} else {
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
}
FigureMode mode = figure.getMode();
if (mode != null) {
switch (mode) {
case LAZY:
xml.appendAttribute("mode", "lazy");
break;
case EAGER:
xml.appendAttribute("mode", "eager");
break;
default:
throw new SystemException("Unknown figure mode: " + figure.getMode());
}
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(figure, renderContext);
if (renderChildren) {
// Label
figure.getDecoratedLabel().paint(renderContext);
// Content
xml.appendTagOpen("ui:content");
xml.appendAttribute("id", component.getId() + "-content");
xml.appendClose();
figure.getContent().paint(renderContext);
xml.appendEndTag("ui:content");
}
xml.appendEndTag("ui:figure");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WFigure figure = (WFigure) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean renderChildren = isRenderContent(figure);
xml.appendTagOpen("ui:figure");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
if (FigureMode.LAZY.equals(figure.getMode())) {
xml.appendOptionalAttribute("hidden", !renderChildren, "true");
} else {
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
}
FigureMode mode = figure.getMode();
if (mode != null) {
switch (mode) {
case LAZY:
xml.appendAttribute("mode", "lazy");
break;
case EAGER:
xml.appendAttribute("mode", "eager");
break;
default:
throw new SystemException("Unknown figure mode: " + figure.getMode());
}
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(figure, renderContext);
if (renderChildren) {
// Label
figure.getDecoratedLabel().paint(renderContext);
// Content
xml.appendTagOpen("ui:content");
xml.appendAttribute("id", component.getId() + "-content");
xml.appendClose();
figure.getContent().paint(renderContext);
xml.appendEndTag("ui:content");
}
xml.appendEndTag("ui:figure");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WFigure",
"figure",
"=",
"(",
"WFigure",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"boolean",
"renderChildren",
"=",
"isRenderContent",
"(",
"figure",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:figure\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"if",
"(",
"FigureMode",
".",
"LAZY",
".",
"equals",
"(",
"figure",
".",
"getMode",
"(",
")",
")",
")",
"{",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"!",
"renderChildren",
",",
"\"true\"",
")",
";",
"}",
"else",
"{",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"component",
".",
"isHidden",
"(",
")",
",",
"\"true\"",
")",
";",
"}",
"FigureMode",
"mode",
"=",
"figure",
".",
"getMode",
"(",
")",
";",
"if",
"(",
"mode",
"!=",
"null",
")",
"{",
"switch",
"(",
"mode",
")",
"{",
"case",
"LAZY",
":",
"xml",
".",
"appendAttribute",
"(",
"\"mode\"",
",",
"\"lazy\"",
")",
";",
"break",
";",
"case",
"EAGER",
":",
"xml",
".",
"appendAttribute",
"(",
"\"mode\"",
",",
"\"eager\"",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"SystemException",
"(",
"\"Unknown figure mode: \"",
"+",
"figure",
".",
"getMode",
"(",
")",
")",
";",
"}",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Render margin",
"MarginRendererUtil",
".",
"renderMargin",
"(",
"figure",
",",
"renderContext",
")",
";",
"if",
"(",
"renderChildren",
")",
"{",
"// Label",
"figure",
".",
"getDecoratedLabel",
"(",
")",
".",
"paint",
"(",
"renderContext",
")",
";",
"// Content",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:content\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
"+",
"\"-content\"",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"figure",
".",
"getContent",
"(",
")",
".",
"paint",
"(",
"renderContext",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"ui:content\"",
")",
";",
"}",
"xml",
".",
"appendEndTag",
"(",
"\"ui:figure\"",
")",
";",
"}"
] | Paints the given WFigure.
@param component the WFigure to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WFigure",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WFigureRenderer.java#L25-L74 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRLight.java | GVRLight.setInt | public void setInt(String key, int value) {
"""
Bind an {@code int} to the shader uniform {@code key}.
Throws an exception of the key does not exist.
@param key Name of the shader uniform
@param value New data
"""
checkKeyIsUniform(key);
NativeLight.setInt(getNative(), key, value);
} | java | public void setInt(String key, int value)
{
checkKeyIsUniform(key);
NativeLight.setInt(getNative(), key, value);
} | [
"public",
"void",
"setInt",
"(",
"String",
"key",
",",
"int",
"value",
")",
"{",
"checkKeyIsUniform",
"(",
"key",
")",
";",
"NativeLight",
".",
"setInt",
"(",
"getNative",
"(",
")",
",",
"key",
",",
"value",
")",
";",
"}"
] | Bind an {@code int} to the shader uniform {@code key}.
Throws an exception of the key does not exist.
@param key Name of the shader uniform
@param value New data | [
"Bind",
"an",
"{"
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRLight.java#L347-L351 |
actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.sendJsonToPeers | public WebSocketContext sendJsonToPeers(Object data, boolean excludeSelf) {
"""
Send JSON representation of a data object to all connections connected to
the same URL of this context with the connection of this context excluded
@param data the data to be sent
@param excludeSelf whether it should send to the connection of this context
@return this context
"""
return sendToPeers(JSON.toJSONString(data), excludeSelf);
} | java | public WebSocketContext sendJsonToPeers(Object data, boolean excludeSelf) {
return sendToPeers(JSON.toJSONString(data), excludeSelf);
} | [
"public",
"WebSocketContext",
"sendJsonToPeers",
"(",
"Object",
"data",
",",
"boolean",
"excludeSelf",
")",
"{",
"return",
"sendToPeers",
"(",
"JSON",
".",
"toJSONString",
"(",
"data",
")",
",",
"excludeSelf",
")",
";",
"}"
] | Send JSON representation of a data object to all connections connected to
the same URL of this context with the connection of this context excluded
@param data the data to be sent
@param excludeSelf whether it should send to the connection of this context
@return this context | [
"Send",
"JSON",
"representation",
"of",
"a",
"data",
"object",
"to",
"all",
"connections",
"connected",
"to",
"the",
"same",
"URL",
"of",
"this",
"context",
"with",
"the",
"connection",
"of",
"this",
"context",
"excluded"
] | train | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L208-L210 |
openbaton/openbaton-client | cli/src/main/java/org/openbaton/cli/util/Utils.java | Utils.methodsAreEqual | public static boolean methodsAreEqual(Method m1, Method m2) {
"""
Returns true if the two passed methods are equal. Methods are in this case regarded as equal if
they take the same parameter types, return the same return type and share the same name.
@param m1 message one
@param m2 message two
@return true if method m1 and method m2 are considered equal for our case
"""
if (!m1.getName().equals(m2.getName())) return false;
if (!m1.getReturnType().equals(m2.getReturnType())) return false;
if (!Objects.deepEquals(m1.getParameterTypes(), m2.getParameterTypes())) return false;
return true;
} | java | public static boolean methodsAreEqual(Method m1, Method m2) {
if (!m1.getName().equals(m2.getName())) return false;
if (!m1.getReturnType().equals(m2.getReturnType())) return false;
if (!Objects.deepEquals(m1.getParameterTypes(), m2.getParameterTypes())) return false;
return true;
} | [
"public",
"static",
"boolean",
"methodsAreEqual",
"(",
"Method",
"m1",
",",
"Method",
"m2",
")",
"{",
"if",
"(",
"!",
"m1",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"m2",
".",
"getName",
"(",
")",
")",
")",
"return",
"false",
";",
"if",
"(",
"!",
"m1",
".",
"getReturnType",
"(",
")",
".",
"equals",
"(",
"m2",
".",
"getReturnType",
"(",
")",
")",
")",
"return",
"false",
";",
"if",
"(",
"!",
"Objects",
".",
"deepEquals",
"(",
"m1",
".",
"getParameterTypes",
"(",
")",
",",
"m2",
".",
"getParameterTypes",
"(",
")",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | Returns true if the two passed methods are equal. Methods are in this case regarded as equal if
they take the same parameter types, return the same return type and share the same name.
@param m1 message one
@param m2 message two
@return true if method m1 and method m2 are considered equal for our case | [
"Returns",
"true",
"if",
"the",
"two",
"passed",
"methods",
"are",
"equal",
".",
"Methods",
"are",
"in",
"this",
"case",
"regarded",
"as",
"equal",
"if",
"they",
"take",
"the",
"same",
"parameter",
"types",
"return",
"the",
"same",
"return",
"type",
"and",
"share",
"the",
"same",
"name",
"."
] | train | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/cli/src/main/java/org/openbaton/cli/util/Utils.java#L34-L39 |
Hygieia/Hygieia | collectors/misc/score/src/main/java/com/capitalone/dashboard/widget/GithubScmWidgetScore.java | GithubScmWidgetScore.getPercentCoverageForDays | private Double getPercentCoverageForDays(Iterable<Commit> commits, int days) {
"""
Calculate percentage of days with commits out of total days
@param commits
@param days
@return percentage of days with commits
"""
Set<String> dates = new HashSet<>();
for (Commit commit : commits) {
dates.add(Constants.DAY_FORMAT.format(new Date(commit.getScmCommitTimestamp())));
}
return (dates.size() / (double) days) * 100;
} | java | private Double getPercentCoverageForDays(Iterable<Commit> commits, int days) {
Set<String> dates = new HashSet<>();
for (Commit commit : commits) {
dates.add(Constants.DAY_FORMAT.format(new Date(commit.getScmCommitTimestamp())));
}
return (dates.size() / (double) days) * 100;
} | [
"private",
"Double",
"getPercentCoverageForDays",
"(",
"Iterable",
"<",
"Commit",
">",
"commits",
",",
"int",
"days",
")",
"{",
"Set",
"<",
"String",
">",
"dates",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"Commit",
"commit",
":",
"commits",
")",
"{",
"dates",
".",
"add",
"(",
"Constants",
".",
"DAY_FORMAT",
".",
"format",
"(",
"new",
"Date",
"(",
"commit",
".",
"getScmCommitTimestamp",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"(",
"dates",
".",
"size",
"(",
")",
"/",
"(",
"double",
")",
"days",
")",
"*",
"100",
";",
"}"
] | Calculate percentage of days with commits out of total days
@param commits
@param days
@return percentage of days with commits | [
"Calculate",
"percentage",
"of",
"days",
"with",
"commits",
"out",
"of",
"total",
"days"
] | train | https://github.com/Hygieia/Hygieia/blob/d8b67a590da2744acf59bcd99d9b34ef1bb84890/collectors/misc/score/src/main/java/com/capitalone/dashboard/widget/GithubScmWidgetScore.java#L164-L170 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java | ApiOvhDedicatedCloud.serviceName_changeProperties_POST | public OvhTask serviceName_changeProperties_POST(String serviceName, String description, Boolean sslV3, OvhUserAccessPolicyEnum userAccessPolicy, Long userLimitConcurrentSession, OvhUserLogoutPolicyEnum userLogoutPolicy, Long userSessionTimeout) throws IOException {
"""
Update this Private Cloud properties.
REST: POST /dedicatedCloud/{serviceName}/changeProperties
@param sslV3 [required] Enable SSL v3 support. Warning: this option is not recommended as it was recognized as a security breach. If this is enabled, we advise you to enable the filtered User access policy
@param userLimitConcurrentSession [required] The maximum amount of connected users allowed on the Private Cloud management interface
@param description [required] Description of your Private Cloud
@param userLogoutPolicy [required] Logout policy of your Private Cloud
@param userAccessPolicy [required] Access policy of your Private Cloud: opened to every IPs or filtered
@param userSessionTimeout [required] The timeout (in seconds) for the user sessions on the Private Cloud management interface. 0 value disable the timeout
@param serviceName [required] Domain of the service
"""
String qPath = "/dedicatedCloud/{serviceName}/changeProperties";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "sslV3", sslV3);
addBody(o, "userAccessPolicy", userAccessPolicy);
addBody(o, "userLimitConcurrentSession", userLimitConcurrentSession);
addBody(o, "userLogoutPolicy", userLogoutPolicy);
addBody(o, "userSessionTimeout", userSessionTimeout);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | java | public OvhTask serviceName_changeProperties_POST(String serviceName, String description, Boolean sslV3, OvhUserAccessPolicyEnum userAccessPolicy, Long userLimitConcurrentSession, OvhUserLogoutPolicyEnum userLogoutPolicy, Long userSessionTimeout) throws IOException {
String qPath = "/dedicatedCloud/{serviceName}/changeProperties";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "sslV3", sslV3);
addBody(o, "userAccessPolicy", userAccessPolicy);
addBody(o, "userLimitConcurrentSession", userLimitConcurrentSession);
addBody(o, "userLogoutPolicy", userLogoutPolicy);
addBody(o, "userSessionTimeout", userSessionTimeout);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | [
"public",
"OvhTask",
"serviceName_changeProperties_POST",
"(",
"String",
"serviceName",
",",
"String",
"description",
",",
"Boolean",
"sslV3",
",",
"OvhUserAccessPolicyEnum",
"userAccessPolicy",
",",
"Long",
"userLimitConcurrentSession",
",",
"OvhUserLogoutPolicyEnum",
"userLogoutPolicy",
",",
"Long",
"userSessionTimeout",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicatedCloud/{serviceName}/changeProperties\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"description\"",
",",
"description",
")",
";",
"addBody",
"(",
"o",
",",
"\"sslV3\"",
",",
"sslV3",
")",
";",
"addBody",
"(",
"o",
",",
"\"userAccessPolicy\"",
",",
"userAccessPolicy",
")",
";",
"addBody",
"(",
"o",
",",
"\"userLimitConcurrentSession\"",
",",
"userLimitConcurrentSession",
")",
";",
"addBody",
"(",
"o",
",",
"\"userLogoutPolicy\"",
",",
"userLogoutPolicy",
")",
";",
"addBody",
"(",
"o",
",",
"\"userSessionTimeout\"",
",",
"userSessionTimeout",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhTask",
".",
"class",
")",
";",
"}"
] | Update this Private Cloud properties.
REST: POST /dedicatedCloud/{serviceName}/changeProperties
@param sslV3 [required] Enable SSL v3 support. Warning: this option is not recommended as it was recognized as a security breach. If this is enabled, we advise you to enable the filtered User access policy
@param userLimitConcurrentSession [required] The maximum amount of connected users allowed on the Private Cloud management interface
@param description [required] Description of your Private Cloud
@param userLogoutPolicy [required] Logout policy of your Private Cloud
@param userAccessPolicy [required] Access policy of your Private Cloud: opened to every IPs or filtered
@param userSessionTimeout [required] The timeout (in seconds) for the user sessions on the Private Cloud management interface. 0 value disable the timeout
@param serviceName [required] Domain of the service | [
"Update",
"this",
"Private",
"Cloud",
"properties",
"."
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java#L1195-L1207 |
lightblueseas/vintage-time | src/main/java/de/alpharogroup/date/ParseDateExtensions.java | ParseDateExtensions.parseToString | public static String parseToString(final String date, final String currentformat,
final String newFormat) throws ParseException {
"""
The Method parseToString(String, String, String) formats the given Date as string from the
current Format to the new given Format. For Example:<br>
<br>
<code> String expected = "20120810";<br>
String actual = ParseDateUtils.parseToString(
ParseDateUtils.parseToDate("10.08.2012", "dd.MM.yyyy"), "yyyyMMdd");
</code><br>
<br>
The output is:20120810
@param date
The date as String object that shell be parsed to the new format
@param currentformat
The current format from the date
@param newFormat
The new format for the output date as String object
@return The formated String in the new date format
@throws ParseException
occurs when their are problems with parsing the String to Date.
"""
final Date currentDate = parseToDate(date, currentformat);
return parseToString(currentDate, newFormat);
} | java | public static String parseToString(final String date, final String currentformat,
final String newFormat) throws ParseException
{
final Date currentDate = parseToDate(date, currentformat);
return parseToString(currentDate, newFormat);
} | [
"public",
"static",
"String",
"parseToString",
"(",
"final",
"String",
"date",
",",
"final",
"String",
"currentformat",
",",
"final",
"String",
"newFormat",
")",
"throws",
"ParseException",
"{",
"final",
"Date",
"currentDate",
"=",
"parseToDate",
"(",
"date",
",",
"currentformat",
")",
";",
"return",
"parseToString",
"(",
"currentDate",
",",
"newFormat",
")",
";",
"}"
] | The Method parseToString(String, String, String) formats the given Date as string from the
current Format to the new given Format. For Example:<br>
<br>
<code> String expected = "20120810";<br>
String actual = ParseDateUtils.parseToString(
ParseDateUtils.parseToDate("10.08.2012", "dd.MM.yyyy"), "yyyyMMdd");
</code><br>
<br>
The output is:20120810
@param date
The date as String object that shell be parsed to the new format
@param currentformat
The current format from the date
@param newFormat
The new format for the output date as String object
@return The formated String in the new date format
@throws ParseException
occurs when their are problems with parsing the String to Date. | [
"The",
"Method",
"parseToString",
"(",
"String",
"String",
"String",
")",
"formats",
"the",
"given",
"Date",
"as",
"string",
"from",
"the",
"current",
"Format",
"to",
"the",
"new",
"given",
"Format",
".",
"For",
"Example",
":",
"<br",
">",
"<br",
">",
"<code",
">",
"String",
"expected",
"=",
"20120810",
";",
"<br",
">",
"String",
"actual",
"=",
"ParseDateUtils",
".",
"parseToString",
"(",
"ParseDateUtils",
".",
"parseToDate",
"(",
"10",
".",
"08",
".",
"2012",
"dd",
".",
"MM",
".",
"yyyy",
")",
"yyyyMMdd",
")",
";",
"<",
"/",
"code",
">",
"<br",
">",
"<br",
">",
"The",
"output",
"is",
":",
"20120810"
] | train | https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/ParseDateExtensions.java#L210-L215 |
Netflix/spectator | spectator-ext-sandbox/src/main/java/com/netflix/spectator/sandbox/HttpLogEntry.java | HttpLogEntry.logServerRequest | @Deprecated
public static void logServerRequest(Logger logger, HttpLogEntry entry) {
"""
Log a request received by a server.
@deprecated Use {@link #logServerRequest(HttpLogEntry)} instead.
"""
log(logger, SERVER, entry);
} | java | @Deprecated
public static void logServerRequest(Logger logger, HttpLogEntry entry) {
log(logger, SERVER, entry);
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"logServerRequest",
"(",
"Logger",
"logger",
",",
"HttpLogEntry",
"entry",
")",
"{",
"log",
"(",
"logger",
",",
"SERVER",
",",
"entry",
")",
";",
"}"
] | Log a request received by a server.
@deprecated Use {@link #logServerRequest(HttpLogEntry)} instead. | [
"Log",
"a",
"request",
"received",
"by",
"a",
"server",
"."
] | train | https://github.com/Netflix/spectator/blob/259318252770de3bad581b85adff187d8f2c6537/spectator-ext-sandbox/src/main/java/com/netflix/spectator/sandbox/HttpLogEntry.java#L125-L128 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.getAt | @SuppressWarnings("unchecked")
public static List<Double> getAt(double[] array, Collection indices) {
"""
Support the subscript operator with a collection for a double array
@param array a double array
@param indices a collection of indices for the items to retrieve
@return list of the doubles at the given indices
@since 1.0
"""
return primitiveArrayGet(array, indices);
} | java | @SuppressWarnings("unchecked")
public static List<Double> getAt(double[] array, Collection indices) {
return primitiveArrayGet(array, indices);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"List",
"<",
"Double",
">",
"getAt",
"(",
"double",
"[",
"]",
"array",
",",
"Collection",
"indices",
")",
"{",
"return",
"primitiveArrayGet",
"(",
"array",
",",
"indices",
")",
";",
"}"
] | Support the subscript operator with a collection for a double array
@param array a double array
@param indices a collection of indices for the items to retrieve
@return list of the doubles at the given indices
@since 1.0 | [
"Support",
"the",
"subscript",
"operator",
"with",
"a",
"collection",
"for",
"a",
"double",
"array"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L14016-L14019 |
cdk/cdk | base/standard/src/main/java/org/openscience/cdk/math/RandomNumbersTool.java | RandomNumbersTool.nextLong | private static long nextLong(Random rng, long n) {
"""
Access the next long random number between 0 and n.
@param rng random number generator
@param n max value
@return a long random number between 0 and n
@see <a href="http://stackoverflow.com/questions/2546078/java-random-long-number-in-0-x-n-range">Random Long Number in range, Stack Overflow</a>
"""
if (n <= 0) throw new IllegalArgumentException("n must be greater than 0");
long bits, val;
do {
bits = (rng.nextLong() << 1) >>> 1;
val = bits % n;
} while (bits - val + (n - 1) < 0L);
return val;
} | java | private static long nextLong(Random rng, long n) {
if (n <= 0) throw new IllegalArgumentException("n must be greater than 0");
long bits, val;
do {
bits = (rng.nextLong() << 1) >>> 1;
val = bits % n;
} while (bits - val + (n - 1) < 0L);
return val;
} | [
"private",
"static",
"long",
"nextLong",
"(",
"Random",
"rng",
",",
"long",
"n",
")",
"{",
"if",
"(",
"n",
"<=",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"n must be greater than 0\"",
")",
";",
"long",
"bits",
",",
"val",
";",
"do",
"{",
"bits",
"=",
"(",
"rng",
".",
"nextLong",
"(",
")",
"<<",
"1",
")",
">>>",
"1",
";",
"val",
"=",
"bits",
"%",
"n",
";",
"}",
"while",
"(",
"bits",
"-",
"val",
"+",
"(",
"n",
"-",
"1",
")",
"<",
"0L",
")",
";",
"return",
"val",
";",
"}"
] | Access the next long random number between 0 and n.
@param rng random number generator
@param n max value
@return a long random number between 0 and n
@see <a href="http://stackoverflow.com/questions/2546078/java-random-long-number-in-0-x-n-range">Random Long Number in range, Stack Overflow</a> | [
"Access",
"the",
"next",
"long",
"random",
"number",
"between",
"0",
"and",
"n",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/standard/src/main/java/org/openscience/cdk/math/RandomNumbersTool.java#L140-L148 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.copyContent | public static File copyContent(File src, File dest, boolean isOverride) throws IORuntimeException {
"""
复制文件或目录<br>
情况如下:
<pre>
1、src和dest都为目录,则讲src下所有文件目录拷贝到dest下
2、src和dest都为文件,直接复制,名字为dest
3、src为文件,dest为目录,将src拷贝到dest目录下
</pre>
@param src 源文件
@param dest 目标文件或目录,目标不存在会自动创建(目录、文件都创建)
@param isOverride 是否覆盖目标文件
@return 目标目录或文件
@throws IORuntimeException IO异常
"""
return FileCopier.create(src, dest).setCopyContentIfDir(true).setOverride(isOverride).copy();
} | java | public static File copyContent(File src, File dest, boolean isOverride) throws IORuntimeException {
return FileCopier.create(src, dest).setCopyContentIfDir(true).setOverride(isOverride).copy();
} | [
"public",
"static",
"File",
"copyContent",
"(",
"File",
"src",
",",
"File",
"dest",
",",
"boolean",
"isOverride",
")",
"throws",
"IORuntimeException",
"{",
"return",
"FileCopier",
".",
"create",
"(",
"src",
",",
"dest",
")",
".",
"setCopyContentIfDir",
"(",
"true",
")",
".",
"setOverride",
"(",
"isOverride",
")",
".",
"copy",
"(",
")",
";",
"}"
] | 复制文件或目录<br>
情况如下:
<pre>
1、src和dest都为目录,则讲src下所有文件目录拷贝到dest下
2、src和dest都为文件,直接复制,名字为dest
3、src为文件,dest为目录,将src拷贝到dest目录下
</pre>
@param src 源文件
@param dest 目标文件或目录,目标不存在会自动创建(目录、文件都创建)
@param isOverride 是否覆盖目标文件
@return 目标目录或文件
@throws IORuntimeException IO异常 | [
"复制文件或目录<br",
">",
"情况如下:"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L1023-L1025 |
eurekaclinical/eurekaclinical-common | src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java | EurekaClinicalClient.doDelete | protected void doDelete(String path, MultivaluedMap<String, String> headers) throws ClientException {
"""
Deletes the resource specified by the path.
@param headers any HTTP headers. Can be <code>null</code>.
@param path the path to the resource. Cannot be <code>null</code>.
@throws ClientException if a status code other than 204 (No Content), 202
(Accepted), and 200 (OK) is returned.
"""
this.readLock.lock();
try {
ClientResponse response = this.getResourceWrapper()
.rewritten(path, HttpMethod.DELETE)
.delete(ClientResponse.class);
errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT, ClientResponse.Status.ACCEPTED);
response.close();
} catch (ClientHandlerException ex) {
throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage());
} finally {
this.readLock.unlock();
}
} | java | protected void doDelete(String path, MultivaluedMap<String, String> headers) throws ClientException {
this.readLock.lock();
try {
ClientResponse response = this.getResourceWrapper()
.rewritten(path, HttpMethod.DELETE)
.delete(ClientResponse.class);
errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT, ClientResponse.Status.ACCEPTED);
response.close();
} catch (ClientHandlerException ex) {
throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage());
} finally {
this.readLock.unlock();
}
} | [
"protected",
"void",
"doDelete",
"(",
"String",
"path",
",",
"MultivaluedMap",
"<",
"String",
",",
"String",
">",
"headers",
")",
"throws",
"ClientException",
"{",
"this",
".",
"readLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"ClientResponse",
"response",
"=",
"this",
".",
"getResourceWrapper",
"(",
")",
".",
"rewritten",
"(",
"path",
",",
"HttpMethod",
".",
"DELETE",
")",
".",
"delete",
"(",
"ClientResponse",
".",
"class",
")",
";",
"errorIfStatusNotEqualTo",
"(",
"response",
",",
"ClientResponse",
".",
"Status",
".",
"OK",
",",
"ClientResponse",
".",
"Status",
".",
"NO_CONTENT",
",",
"ClientResponse",
".",
"Status",
".",
"ACCEPTED",
")",
";",
"response",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"ClientHandlerException",
"ex",
")",
"{",
"throw",
"new",
"ClientException",
"(",
"ClientResponse",
".",
"Status",
".",
"INTERNAL_SERVER_ERROR",
",",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"finally",
"{",
"this",
".",
"readLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Deletes the resource specified by the path.
@param headers any HTTP headers. Can be <code>null</code>.
@param path the path to the resource. Cannot be <code>null</code>.
@throws ClientException if a status code other than 204 (No Content), 202
(Accepted), and 200 (OK) is returned. | [
"Deletes",
"the",
"resource",
"specified",
"by",
"the",
"path",
"."
] | train | https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L129-L142 |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemRangeRemoved | public void notifyHeaderItemRangeRemoved(int positionStart, int itemCount) {
"""
Notifies that multiple header items are removed.
@param positionStart the position.
@param itemCount the item count.
"""
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeRemoved(positionStart, itemCount);
} | java | public void notifyHeaderItemRangeRemoved(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeRemoved(positionStart, itemCount);
} | [
"public",
"void",
"notifyHeaderItemRangeRemoved",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"headerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for header items [0 - \"",
"+",
"(",
"headerItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeRemoved",
"(",
"positionStart",
",",
"itemCount",
")",
";",
"}"
] | Notifies that multiple header items are removed.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"header",
"items",
"are",
"removed",
"."
] | train | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L197-L202 |
tvesalainen/util | util/src/main/java/org/vesalainen/util/concurrent/SimpleWorkflow.java | SimpleWorkflow.accessContext | public <R> R accessContext(ContextAccess<C,R> access) {
"""
Provides thread save access to the context object. ContextAccess.access
method is called inside a lock to prevent concurrent modification to
the object.
@param <R> Return type
@param access
@return
"""
contextLock.lock();
try
{
return access.access(context);
}
finally
{
contextLock.unlock();
}
} | java | public <R> R accessContext(ContextAccess<C,R> access)
{
contextLock.lock();
try
{
return access.access(context);
}
finally
{
contextLock.unlock();
}
} | [
"public",
"<",
"R",
">",
"R",
"accessContext",
"(",
"ContextAccess",
"<",
"C",
",",
"R",
">",
"access",
")",
"{",
"contextLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"return",
"access",
".",
"access",
"(",
"context",
")",
";",
"}",
"finally",
"{",
"contextLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Provides thread save access to the context object. ContextAccess.access
method is called inside a lock to prevent concurrent modification to
the object.
@param <R> Return type
@param access
@return | [
"Provides",
"thread",
"save",
"access",
"to",
"the",
"context",
"object",
".",
"ContextAccess",
".",
"access",
"method",
"is",
"called",
"inside",
"a",
"lock",
"to",
"prevent",
"concurrent",
"modification",
"to",
"the",
"object",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/SimpleWorkflow.java#L445-L456 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.