code stringlengths 130 281k | code_dependency stringlengths 182 306k |
|---|---|
public class class_name {
public SSLEngine get() {
try {
String pass = env.sslKeystorePassword();
char[] password = pass == null || pass.isEmpty() ? null : pass.toCharArray();
KeyStore ks = env.sslKeystore();
if (ks == null) {
String ksFile = env.sslKeystoreFile();
if (ksFile != null && !ksFile.isEmpty()) {
ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(new FileInputStream(ksFile), password);
}
}
KeyStore ts = env.sslTruststore();
if (ts == null) {
String tsFile = env.sslTruststoreFile();
if (tsFile != null && !tsFile.isEmpty()) {
// filepath found, open and init
String tsPassword = env.sslTruststorePassword();
char[] tspass = tsPassword == null || tsPassword.isEmpty() ? null : tsPassword.toCharArray();
ts = KeyStore.getInstance(KeyStore.getDefaultType());
ts.load(new FileInputStream(tsFile), tspass);
}
}
if (ks == null && ts == null) {
throw new IllegalStateException("Either a KeyStore or a TrustStore " +
"need to be provided (or both).");
} else if (ks == null) {
ks = ts;
LOGGER.debug("No KeyStore provided, using provided TrustStore to initialize both factories.");
} else if (ts == null) {
ts = ks;
LOGGER.debug("No TrustStore provided, using provided KeyStore to initialize both factories.");
}
String defaultAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
KeyManagerFactory kmf = KeyManagerFactory.getInstance(defaultAlgorithm);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(defaultAlgorithm);
kmf.init(ks, password);
tmf.init(ts);
if (!sslContextProtocol.startsWith("TLS")) {
throw new IllegalArgumentException(
"SSLContext Protocol does not start with TLS, this is to prevent "
+ "insecure protocols (Like SSL*) to be used. Potential candidates "
+ "are TLS (default), TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 depending on "
+ "the Java version used.");
}
SSLContext ctx = SSLContext.getInstance(sslContextProtocol);
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
SSLEngine engine = ctx.createSSLEngine();
engine.setUseClientMode(true);
return engine;
} catch (Exception ex) {
throw new SSLException("Could not create SSLEngine.", ex);
}
} } | public class class_name {
public SSLEngine get() {
try {
String pass = env.sslKeystorePassword();
char[] password = pass == null || pass.isEmpty() ? null : pass.toCharArray();
KeyStore ks = env.sslKeystore();
if (ks == null) {
String ksFile = env.sslKeystoreFile();
if (ksFile != null && !ksFile.isEmpty()) {
ks = KeyStore.getInstance(KeyStore.getDefaultType()); // depends on control dependency: [if], data = [none]
ks.load(new FileInputStream(ksFile), password); // depends on control dependency: [if], data = [(ksFile]
}
}
KeyStore ts = env.sslTruststore();
if (ts == null) {
String tsFile = env.sslTruststoreFile();
if (tsFile != null && !tsFile.isEmpty()) {
// filepath found, open and init
String tsPassword = env.sslTruststorePassword();
char[] tspass = tsPassword == null || tsPassword.isEmpty() ? null : tsPassword.toCharArray();
ts = KeyStore.getInstance(KeyStore.getDefaultType()); // depends on control dependency: [if], data = [none]
ts.load(new FileInputStream(tsFile), tspass); // depends on control dependency: [if], data = [(tsFile]
}
}
if (ks == null && ts == null) {
throw new IllegalStateException("Either a KeyStore or a TrustStore " +
"need to be provided (or both).");
} else if (ks == null) {
ks = ts; // depends on control dependency: [if], data = [none]
LOGGER.debug("No KeyStore provided, using provided TrustStore to initialize both factories."); // depends on control dependency: [if], data = [none]
} else if (ts == null) {
ts = ks; // depends on control dependency: [if], data = [none]
LOGGER.debug("No TrustStore provided, using provided KeyStore to initialize both factories."); // depends on control dependency: [if], data = [none]
}
String defaultAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
KeyManagerFactory kmf = KeyManagerFactory.getInstance(defaultAlgorithm);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(defaultAlgorithm);
kmf.init(ks, password);
tmf.init(ts);
if (!sslContextProtocol.startsWith("TLS")) {
throw new IllegalArgumentException(
"SSLContext Protocol does not start with TLS, this is to prevent "
+ "insecure protocols (Like SSL*) to be used. Potential candidates "
+ "are TLS (default), TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 depending on "
+ "the Java version used.");
}
SSLContext ctx = SSLContext.getInstance(sslContextProtocol);
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
SSLEngine engine = ctx.createSSLEngine();
engine.setUseClientMode(true);
return engine;
} catch (Exception ex) {
throw new SSLException("Could not create SSLEngine.", ex);
}
} } |
public class class_name {
public void marshall(GetDeviceDefinitionVersionRequest getDeviceDefinitionVersionRequest, ProtocolMarshaller protocolMarshaller) {
if (getDeviceDefinitionVersionRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(getDeviceDefinitionVersionRequest.getDeviceDefinitionId(), DEVICEDEFINITIONID_BINDING);
protocolMarshaller.marshall(getDeviceDefinitionVersionRequest.getDeviceDefinitionVersionId(), DEVICEDEFINITIONVERSIONID_BINDING);
protocolMarshaller.marshall(getDeviceDefinitionVersionRequest.getNextToken(), NEXTTOKEN_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(GetDeviceDefinitionVersionRequest getDeviceDefinitionVersionRequest, ProtocolMarshaller protocolMarshaller) {
if (getDeviceDefinitionVersionRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(getDeviceDefinitionVersionRequest.getDeviceDefinitionId(), DEVICEDEFINITIONID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(getDeviceDefinitionVersionRequest.getDeviceDefinitionVersionId(), DEVICEDEFINITIONVERSIONID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(getDeviceDefinitionVersionRequest.getNextToken(), NEXTTOKEN_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void modifyRequest(ResponseBuilder rb, SearchComponent who,
ShardRequest sreq) {
if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
&& sreq.params.getBool(PARAM_MTAS_FACET, false)) {
if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) {
// do nothing
} else {
// remove prefix for other requests
Set<String> keys = MtasSolrResultUtil
.getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_FACET);
sreq.params.remove(PARAM_MTAS_FACET);
for (String key : keys) {
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_FIELD);
sreq.params
.remove(PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_KEY);
Set<String> subKeys = MtasSolrResultUtil.getIdsFromParameters(
rb.req.getParams(),
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY);
for (String subKey : subKeys) {
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
+ subKey + "." + SUBNAME_MTAS_FACET_QUERY_TYPE);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
+ subKey + "." + SUBNAME_MTAS_FACET_QUERY_VALUE);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
+ subKey + "." + SUBNAME_MTAS_FACET_QUERY_PREFIX);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
+ subKey + "." + SUBNAME_MTAS_FACET_QUERY_IGNORE);
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_QUERY + "." + subKey + "."
+ SUBNAME_MTAS_FACET_QUERY_MAXIMUM_IGNORE_LENGTH);
Set<String> subSubKeys = MtasSolrResultUtil
.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY
+ "." + subKey + "."
+ SUBNAME_MTAS_FACET_QUERY_VARIABLE);
for (String subSubKey : subSubKeys) {
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_QUERY + "." + subKey + "."
+ SUBNAME_MTAS_FACET_QUERY_VARIABLE + "." + subSubKey + "."
+ SUBNAME_MTAS_FACET_QUERY_VARIABLE_NAME);
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_QUERY + "." + subKey + "."
+ SUBNAME_MTAS_FACET_QUERY_VARIABLE + "." + subSubKey + "."
+ SUBNAME_MTAS_FACET_QUERY_VARIABLE_VALUE);
}
}
subKeys = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE);
for (String subKey : subKeys) {
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_FIELD);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_TYPE);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_RANGE + "."
+ SUBNAME_MTAS_FACET_BASE_RANGE_SIZE);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_RANGE + "."
+ SUBNAME_MTAS_FACET_BASE_RANGE_BASE);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_MAXIMUM);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_MINIMUM);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_NUMBER);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_SORT_DIRECTION);
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_SORT_TYPE);
Set<String> subSubKeys = MtasSolrResultUtil
.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE
+ "." + subKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION);
for (String subSubKey : subSubKeys) {
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_BASE + "." + subKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION + "." + subSubKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION_EXPRESSION);
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_BASE + "." + subKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION + "." + subSubKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION_KEY);
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_BASE + "." + subKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION + "." + subSubKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION_TYPE);
}
}
}
}
}
} } | public class class_name {
public void modifyRequest(ResponseBuilder rb, SearchComponent who,
ShardRequest sreq) {
if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
&& sreq.params.getBool(PARAM_MTAS_FACET, false)) {
if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) {
// do nothing
} else {
// remove prefix for other requests
Set<String> keys = MtasSolrResultUtil
.getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_FACET);
sreq.params.remove(PARAM_MTAS_FACET); // depends on control dependency: [if], data = [none]
for (String key : keys) {
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_FIELD); // depends on control dependency: [for], data = [none]
sreq.params
.remove(PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_KEY); // depends on control dependency: [for], data = [none]
Set<String> subKeys = MtasSolrResultUtil.getIdsFromParameters(
rb.req.getParams(),
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY);
for (String subKey : subKeys) {
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
+ subKey + "." + SUBNAME_MTAS_FACET_QUERY_TYPE); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
+ subKey + "." + SUBNAME_MTAS_FACET_QUERY_VALUE); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
+ subKey + "." + SUBNAME_MTAS_FACET_QUERY_PREFIX); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY + "."
+ subKey + "." + SUBNAME_MTAS_FACET_QUERY_IGNORE); // depends on control dependency: [for], data = [none]
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_QUERY + "." + subKey + "."
+ SUBNAME_MTAS_FACET_QUERY_MAXIMUM_IGNORE_LENGTH); // depends on control dependency: [for], data = [none]
Set<String> subSubKeys = MtasSolrResultUtil
.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_QUERY
+ "." + subKey + "."
+ SUBNAME_MTAS_FACET_QUERY_VARIABLE);
for (String subSubKey : subSubKeys) {
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_QUERY + "." + subKey + "."
+ SUBNAME_MTAS_FACET_QUERY_VARIABLE + "." + subSubKey + "."
+ SUBNAME_MTAS_FACET_QUERY_VARIABLE_NAME); // depends on control dependency: [for], data = [none]
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_QUERY + "." + subKey + "."
+ SUBNAME_MTAS_FACET_QUERY_VARIABLE + "." + subSubKey + "."
+ SUBNAME_MTAS_FACET_QUERY_VARIABLE_VALUE); // depends on control dependency: [for], data = [none]
}
}
subKeys = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE); // depends on control dependency: [for], data = [none]
for (String subKey : subKeys) {
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_FIELD); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_TYPE); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_RANGE + "."
+ SUBNAME_MTAS_FACET_BASE_RANGE_SIZE); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_RANGE + "."
+ SUBNAME_MTAS_FACET_BASE_RANGE_BASE); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_MAXIMUM); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_MINIMUM); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_NUMBER); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_SORT_DIRECTION); // depends on control dependency: [for], data = [none]
sreq.params.remove(
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE + "."
+ subKey + "." + SUBNAME_MTAS_FACET_BASE_SORT_TYPE); // depends on control dependency: [for], data = [none]
Set<String> subSubKeys = MtasSolrResultUtil
.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_FACET + "." + key + "." + NAME_MTAS_FACET_BASE
+ "." + subKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION);
for (String subSubKey : subSubKeys) {
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_BASE + "." + subKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION + "." + subSubKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION_EXPRESSION); // depends on control dependency: [for], data = [none]
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_BASE + "." + subKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION + "." + subSubKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION_KEY); // depends on control dependency: [for], data = [none]
sreq.params.remove(PARAM_MTAS_FACET + "." + key + "."
+ NAME_MTAS_FACET_BASE + "." + subKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION + "." + subSubKey + "."
+ SUBNAME_MTAS_FACET_BASE_FUNCTION_TYPE); // depends on control dependency: [for], data = [none]
}
}
}
}
}
} } |
public class class_name {
public static String getMdwVersion() {
if (mdwVersion != null)
return mdwVersion;
mdwVersion = "Unknown";
try {
String cpUtilLoc = ClasspathUtil.locate(ClasspathUtil.class.getName());
int jarBangIdx = cpUtilLoc.indexOf(".jar!");
if (jarBangIdx > 0) {
String jarFilePath = cpUtilLoc.substring(0, jarBangIdx + 4);
if (jarFilePath.startsWith("file:/"))
jarFilePath = jarFilePath.substring(6);
if (!jarFilePath.startsWith("/"))
jarFilePath = "/" + jarFilePath;
JarFile jarFile = new JarFile(new File(jarFilePath));
String subpath = cpUtilLoc.substring(jarBangIdx + 5);
int subjarBang = subpath.indexOf(".jar!");
if (subjarBang > 0) {
// subjars in spring boot client apps
String subjarPath = subpath.substring(1, subjarBang + 4);
ZipEntry subjar = jarFile.getEntry(subjarPath);
File tempjar = Files.createTempFile("mdw", ".jar").toFile();
try (InputStream is = jarFile.getInputStream(subjar);
OutputStream os = new FileOutputStream(tempjar)) {
int bufSize = 16 * 1024;
int read = 0;
byte[] bytes = new byte[bufSize];
while((read = is.read(bytes)) != -1)
os.write(bytes, 0, read);
}
JarFile tempJarFile = new JarFile(tempjar);
Manifest manifest = tempJarFile.getManifest();
mdwVersion = manifest.getMainAttributes().getValue("MDW-Version");
mdwBuildTimestamp = manifest.getMainAttributes().getValue("MDW-Build");
tempJarFile.close();
tempjar.delete();
}
else {
Manifest manifest = jarFile.getManifest();
mdwVersion = manifest.getMainAttributes().getValue("MDW-Version");
mdwBuildTimestamp = manifest.getMainAttributes().getValue("MDW-Build");
}
jarFile.close();
}
else {
// try tomcat deploy structure
String catalinaBase = System.getProperty("catalina.base");
if (catalinaBase != null) {
File webInfLib = new File(catalinaBase + "/webapps/mdw/WEB-INF/lib");
if (webInfLib.exists()) {
for (File file : webInfLib.listFiles()) {
if (file.getName().startsWith("mdw-common")) {
mdwVersion = file.getName().substring(11, file.getName().length() - 4);
String mfPath = "jar:" + file.toURI() + "!/META-INF/MANIFEST.MF";
Manifest manifest = new Manifest(new URL(mfPath).openStream());
Attributes attrs = manifest.getMainAttributes();
mdwBuildTimestamp = attrs.getValue("MDW-Build");
break;
}
}
}
}
}
if (mdwVersion != null && mdwVersion.endsWith(".SNAPSHOT")) {
mdwVersion = mdwVersion.substring(0, mdwVersion.length() - 9) + "-SNAPSHOT";
}
}
catch (Exception ex) {
logger.severeException(ex.getMessage(), ex);
}
return mdwVersion;
} } | public class class_name {
public static String getMdwVersion() {
if (mdwVersion != null)
return mdwVersion;
mdwVersion = "Unknown";
try {
String cpUtilLoc = ClasspathUtil.locate(ClasspathUtil.class.getName());
int jarBangIdx = cpUtilLoc.indexOf(".jar!");
if (jarBangIdx > 0) {
String jarFilePath = cpUtilLoc.substring(0, jarBangIdx + 4);
if (jarFilePath.startsWith("file:/"))
jarFilePath = jarFilePath.substring(6);
if (!jarFilePath.startsWith("/"))
jarFilePath = "/" + jarFilePath;
JarFile jarFile = new JarFile(new File(jarFilePath));
String subpath = cpUtilLoc.substring(jarBangIdx + 5);
int subjarBang = subpath.indexOf(".jar!");
if (subjarBang > 0) {
// subjars in spring boot client apps
String subjarPath = subpath.substring(1, subjarBang + 4);
ZipEntry subjar = jarFile.getEntry(subjarPath);
File tempjar = Files.createTempFile("mdw", ".jar").toFile();
try (InputStream is = jarFile.getInputStream(subjar);
OutputStream os = new FileOutputStream(tempjar)) {
int bufSize = 16 * 1024;
int read = 0;
byte[] bytes = new byte[bufSize];
while((read = is.read(bytes)) != -1)
os.write(bytes, 0, read);
}
JarFile tempJarFile = new JarFile(tempjar);
Manifest manifest = tempJarFile.getManifest();
mdwVersion = manifest.getMainAttributes().getValue("MDW-Version"); // depends on control dependency: [if], data = [none]
mdwBuildTimestamp = manifest.getMainAttributes().getValue("MDW-Build"); // depends on control dependency: [if], data = [none]
tempJarFile.close(); // depends on control dependency: [if], data = [none]
tempjar.delete(); // depends on control dependency: [if], data = [none]
}
else {
Manifest manifest = jarFile.getManifest();
mdwVersion = manifest.getMainAttributes().getValue("MDW-Version"); // depends on control dependency: [if], data = [none]
mdwBuildTimestamp = manifest.getMainAttributes().getValue("MDW-Build"); // depends on control dependency: [if], data = [none]
}
jarFile.close();
}
else {
// try tomcat deploy structure
String catalinaBase = System.getProperty("catalina.base");
if (catalinaBase != null) {
File webInfLib = new File(catalinaBase + "/webapps/mdw/WEB-INF/lib");
if (webInfLib.exists()) {
for (File file : webInfLib.listFiles()) {
if (file.getName().startsWith("mdw-common")) {
mdwVersion = file.getName().substring(11, file.getName().length() - 4);
String mfPath = "jar:" + file.toURI() + "!/META-INF/MANIFEST.MF";
Manifest manifest = new Manifest(new URL(mfPath).openStream());
Attributes attrs = manifest.getMainAttributes();
mdwBuildTimestamp = attrs.getValue("MDW-Build");
break;
}
}
}
}
}
if (mdwVersion != null && mdwVersion.endsWith(".SNAPSHOT")) {
mdwVersion = mdwVersion.substring(0, mdwVersion.length() - 9) + "-SNAPSHOT";
}
}
catch (Exception ex) {
logger.severeException(ex.getMessage(), ex);
}
return mdwVersion;
} } |
public class class_name {
@Override
public String getQualifiedName() {
String prefix = StringUtil.defaultString(entityPrefix, "");
String suffix = StringUtil.defaultString(entitySuffix, "");
if (packageName == null || packageName.isEmpty()) {
return prefix + simpleName + suffix;
}
return packageName + "." + prefix + simpleName + suffix;
} } | public class class_name {
@Override
public String getQualifiedName() {
String prefix = StringUtil.defaultString(entityPrefix, "");
String suffix = StringUtil.defaultString(entitySuffix, "");
if (packageName == null || packageName.isEmpty()) {
return prefix + simpleName + suffix; // depends on control dependency: [if], data = [none]
}
return packageName + "." + prefix + simpleName + suffix;
} } |
public class class_name {
private boolean removeListenersOfCachedRequestToLaunch(final SpiceRequest<?> request) {
synchronized (mapRequestToLaunchToRequestListener) {
for (final CachedSpiceRequest<?> cachedSpiceRequest : mapRequestToLaunchToRequestListener.keySet()) {
if (match(cachedSpiceRequest, request)) {
final Set<RequestListener<?>> setRequestListeners = mapRequestToLaunchToRequestListener.get(cachedSpiceRequest);
setRequestListeners.clear();
return true;
}
}
return false;
}
} } | public class class_name {
private boolean removeListenersOfCachedRequestToLaunch(final SpiceRequest<?> request) {
synchronized (mapRequestToLaunchToRequestListener) {
for (final CachedSpiceRequest<?> cachedSpiceRequest : mapRequestToLaunchToRequestListener.keySet()) {
if (match(cachedSpiceRequest, request)) {
final Set<RequestListener<?>> setRequestListeners = mapRequestToLaunchToRequestListener.get(cachedSpiceRequest); // depends on control dependency: [if], data = [none]
setRequestListeners.clear(); // depends on control dependency: [if], data = [none]
return true; // depends on control dependency: [if], data = [none]
}
}
return false;
}
} } |
public class class_name {
public final V set(int index, K key, V value) {
if (index < 0) {
throw new IndexOutOfBoundsException();
}
int minSize = index + 1;
ensureCapacity(minSize);
int dataIndex = index << 1;
V result = valueAtDataIndex(dataIndex + 1);
setData(dataIndex, key, value);
if (minSize > this.size) {
this.size = minSize;
}
return result;
} } | public class class_name {
public final V set(int index, K key, V value) {
if (index < 0) {
throw new IndexOutOfBoundsException();
}
int minSize = index + 1;
ensureCapacity(minSize);
int dataIndex = index << 1;
V result = valueAtDataIndex(dataIndex + 1);
setData(dataIndex, key, value);
if (minSize > this.size) {
this.size = minSize; // depends on control dependency: [if], data = [none]
}
return result;
} } |
public class class_name {
@Override
public void destroy() {
try {
_destroyNodeWatcher();
} catch (Exception e) {
LOGGER.warn(e.getMessage(), e);
}
try {
_close();
} catch (Exception e) {
LOGGER.warn(e.getMessage(), e);
}
super.destroy();
} } | public class class_name {
@Override
public void destroy() {
try {
_destroyNodeWatcher(); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
LOGGER.warn(e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
try {
_close(); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
LOGGER.warn(e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
super.destroy();
} } |
public class class_name {
public DestinationHandler getNamedDestination()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
{
SibTr.entry(tc, "getNamedDestination");
SibTr.exit(tc, "getNamedDestination", _dest);
}
return _dest;
} } | public class class_name {
public DestinationHandler getNamedDestination()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
{
SibTr.entry(tc, "getNamedDestination"); // depends on control dependency: [if], data = [none]
SibTr.exit(tc, "getNamedDestination", _dest); // depends on control dependency: [if], data = [none]
}
return _dest;
} } |
public class class_name {
private MyEntitiesValidationReport generateEntityValidationReport(
RepositoryCollection source,
MyEntitiesValidationReport report,
Map<String, EntityType> metaDataMap) {
for (String sheet : source.getEntityTypeIds()) {
if (EMX_PACKAGES.equals(sheet)) {
IntermediateParseResults parseResult = parseTagsSheet(source.getRepository(EMX_TAGS));
parsePackagesSheet(source.getRepository(sheet), parseResult);
parseResult.getPackages().keySet().forEach(report::addPackage);
} else if (!EMX_ENTITIES.equals(sheet)
&& !EMX_ATTRIBUTES.equals(sheet)
&& !EMX_TAGS.equals(sheet)
&& !EMX_LANGUAGES.equals(sheet)
&& !EMX_I18NSTRINGS.equals(sheet)) {
// check if sheet is known
report = report.addEntity(sheet, metaDataMap.containsKey(sheet));
// check the fields
Repository<Entity> sourceRepository = source.getRepository(sheet);
EntityType target = metaDataMap.get(sheet);
if (target != null) {
report = getAttributeValidationReport(report, sheet, sourceRepository, target);
}
}
}
return report;
} } | public class class_name {
private MyEntitiesValidationReport generateEntityValidationReport(
RepositoryCollection source,
MyEntitiesValidationReport report,
Map<String, EntityType> metaDataMap) {
for (String sheet : source.getEntityTypeIds()) {
if (EMX_PACKAGES.equals(sheet)) {
IntermediateParseResults parseResult = parseTagsSheet(source.getRepository(EMX_TAGS));
parsePackagesSheet(source.getRepository(sheet), parseResult); // depends on control dependency: [if], data = [none]
parseResult.getPackages().keySet().forEach(report::addPackage); // depends on control dependency: [if], data = [none]
} else if (!EMX_ENTITIES.equals(sheet)
&& !EMX_ATTRIBUTES.equals(sheet)
&& !EMX_TAGS.equals(sheet)
&& !EMX_LANGUAGES.equals(sheet)
&& !EMX_I18NSTRINGS.equals(sheet)) {
// check if sheet is known
report = report.addEntity(sheet, metaDataMap.containsKey(sheet)); // depends on control dependency: [if], data = [none]
// check the fields
Repository<Entity> sourceRepository = source.getRepository(sheet);
EntityType target = metaDataMap.get(sheet);
if (target != null) {
report = getAttributeValidationReport(report, sheet, sourceRepository, target); // depends on control dependency: [if], data = [none]
}
}
}
return report;
} } |
public class class_name {
protected void fireAttributeChangedEvent(String name, AttributeValue oldValue, AttributeValue currentValue) {
if (this.listeners != null && isEventFirable()) {
final AttributeChangeEvent event = new AttributeChangeEvent(
//source
this,
//type
Type.VALUE_UPDATE,
//old name
name,
//old value
oldValue,
//current name
name,
//current value
currentValue);
for (final AttributeChangeListener listener : this.listeners) {
listener.onAttributeChangeEvent(event);
}
}
} } | public class class_name {
protected void fireAttributeChangedEvent(String name, AttributeValue oldValue, AttributeValue currentValue) {
if (this.listeners != null && isEventFirable()) {
final AttributeChangeEvent event = new AttributeChangeEvent(
//source
this,
//type
Type.VALUE_UPDATE,
//old name
name,
//old value
oldValue,
//current name
name,
//current value
currentValue);
for (final AttributeChangeListener listener : this.listeners) {
listener.onAttributeChangeEvent(event); // depends on control dependency: [for], data = [listener]
}
}
} } |
public class class_name {
public static Option[] combine( final Option[] options1,
final Option... options2 )
{
int size1 = 0;
if( options1 != null && options1.length > 0 )
{
size1 += options1.length;
}
int size2 = 0;
if( options2 != null && options2.length > 0 )
{
size2 += options2.length;
}
final Option[] combined = new Option[size1 + size2];
if( size1 > 0 )
{
System.arraycopy( options1, 0, combined, 0, size1 );
}
if( size2 > 0 )
{
System.arraycopy( options2, 0, combined, size1, size2 );
}
return combined;
} } | public class class_name {
public static Option[] combine( final Option[] options1,
final Option... options2 )
{
int size1 = 0;
if( options1 != null && options1.length > 0 )
{
size1 += options1.length; // depends on control dependency: [if], data = [none]
}
int size2 = 0;
if( options2 != null && options2.length > 0 )
{
size2 += options2.length; // depends on control dependency: [if], data = [none]
}
final Option[] combined = new Option[size1 + size2];
if( size1 > 0 )
{
System.arraycopy( options1, 0, combined, 0, size1 ); // depends on control dependency: [if], data = [none]
}
if( size2 > 0 )
{
System.arraycopy( options2, 0, combined, size1, size2 ); // depends on control dependency: [if], data = [none]
}
return combined;
} } |
public class class_name {
@Override
public void onException(final Throwable cause, final SocketAddress remoteAddress, final T message) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.log(Level.FINEST, "Error sending message " + message + " to " + remoteAddress, cause);
}
} } | public class class_name {
@Override
public void onException(final Throwable cause, final SocketAddress remoteAddress, final T message) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.log(Level.FINEST, "Error sending message " + message + " to " + remoteAddress, cause); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void prepareDBInsert(final SQLInsert _insert,
final Object... _values)
throws SQLException
{
Object[] tmp = _values;
try {
final List<Return> returns = executeEvents(EventType.UPDATE_VALUE, ParameterValues.CLASS, this,
ParameterValues.OTHERS, _values);
for (final Return aRet : returns) {
if (aRet.contains(ReturnValues.VALUES)) {
tmp = (Object[]) aRet.get(ReturnValues.VALUES);
}
}
} catch (final EFapsException e) {
throw new SQLException(e);
}
this.attributeType.getDbAttrType().prepareInsert(_insert, this, tmp);
} } | public class class_name {
public void prepareDBInsert(final SQLInsert _insert,
final Object... _values)
throws SQLException
{
Object[] tmp = _values;
try {
final List<Return> returns = executeEvents(EventType.UPDATE_VALUE, ParameterValues.CLASS, this,
ParameterValues.OTHERS, _values);
for (final Return aRet : returns) {
if (aRet.contains(ReturnValues.VALUES)) {
tmp = (Object[]) aRet.get(ReturnValues.VALUES); // depends on control dependency: [if], data = [none]
}
}
} catch (final EFapsException e) {
throw new SQLException(e);
}
this.attributeType.getDbAttrType().prepareInsert(_insert, this, tmp);
} } |
public class class_name {
public static void consume(Class expectedType, EvaluationContext ctx, Collection collection, Object value) {
if (ctx.configuration().jsonProvider().isArray(value)) {
for (Object o : ctx.configuration().jsonProvider().toIterable(value)) {
if (o != null && expectedType.isAssignableFrom(o.getClass())) {
collection.add(o);
} else if (o != null && expectedType == String.class) {
collection.add(o.toString());
}
}
} else {
if (value != null && expectedType.isAssignableFrom(value.getClass())) {
collection.add(value);
}
}
} } | public class class_name {
public static void consume(Class expectedType, EvaluationContext ctx, Collection collection, Object value) {
if (ctx.configuration().jsonProvider().isArray(value)) {
for (Object o : ctx.configuration().jsonProvider().toIterable(value)) {
if (o != null && expectedType.isAssignableFrom(o.getClass())) {
collection.add(o); // depends on control dependency: [if], data = [(o]
} else if (o != null && expectedType == String.class) {
collection.add(o.toString()); // depends on control dependency: [if], data = [none]
}
}
} else {
if (value != null && expectedType.isAssignableFrom(value.getClass())) {
collection.add(value); // depends on control dependency: [if], data = [(value]
}
}
} } |
public class class_name {
public void informConsumersOfRollback() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "informConsumersOfRollback", new Object[]{Boolean.valueOf(strictRedeliveryOrdering)});
if (strictRedeliveryOrdering) {
// Take a copy of the set of consumers, to avoid additional locking
// when we call into the consumers to inform them of a rollback.
ConsumerSessionProxy[] consumersToNotify;
synchronized(associatedConsumersLock) {
consumersToNotify =
new ConsumerSessionProxy[associatedConsumers.size()];
consumersToNotify = (ConsumerSessionProxy[])
associatedConsumers.toArray(consumersToNotify);
}
// Callback each consumer to inform them of the rollback
for (int i = 0; i < consumersToNotify.length; i++) {
try {
consumersToNotify[i].rollbackOccurred();
}
catch (SIException e) {
// FFDC for the error, but do not re-throw.
// Most likely the connection to the ME is unavailable, or the
// consumer has been closed and cleaned up.
// In these cases the consumer will not be able to consume any
// more messages - so redelivery ordering is not an issue.
FFDCFilter.processException(e, CLASS_NAME + ".informConsumersOfRollback",
CommsConstants.TRANSACTION_INFORMCONSUMERSOFROLLBACK_01, this);
if (tc.isDebugEnabled()) SibTr.debug(tc, "Encountered error informing consumer of rollback: " + consumersToNotify[i]);
if (tc.isEventEnabled()) SibTr.exception(tc, e);
}
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "informConsumersOfRollback");
} } | public class class_name {
public void informConsumersOfRollback() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "informConsumersOfRollback", new Object[]{Boolean.valueOf(strictRedeliveryOrdering)});
if (strictRedeliveryOrdering) {
// Take a copy of the set of consumers, to avoid additional locking
// when we call into the consumers to inform them of a rollback.
ConsumerSessionProxy[] consumersToNotify;
synchronized(associatedConsumersLock) { // depends on control dependency: [if], data = [none]
consumersToNotify =
new ConsumerSessionProxy[associatedConsumers.size()];
consumersToNotify = (ConsumerSessionProxy[])
associatedConsumers.toArray(consumersToNotify);
}
// Callback each consumer to inform them of the rollback
for (int i = 0; i < consumersToNotify.length; i++) {
try {
consumersToNotify[i].rollbackOccurred(); // depends on control dependency: [try], data = [none]
}
catch (SIException e) {
// FFDC for the error, but do not re-throw.
// Most likely the connection to the ME is unavailable, or the
// consumer has been closed and cleaned up.
// In these cases the consumer will not be able to consume any
// more messages - so redelivery ordering is not an issue.
FFDCFilter.processException(e, CLASS_NAME + ".informConsumersOfRollback",
CommsConstants.TRANSACTION_INFORMCONSUMERSOFROLLBACK_01, this);
if (tc.isDebugEnabled()) SibTr.debug(tc, "Encountered error informing consumer of rollback: " + consumersToNotify[i]);
if (tc.isEventEnabled()) SibTr.exception(tc, e);
} // depends on control dependency: [catch], data = [none]
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "informConsumersOfRollback");
} } |
public class class_name {
private void replaceProperties(Set<CmsResource> matchedResources) {
for (CmsResource resource : matchedResources) {
try {
CmsProperty prop = getCms().readPropertyObject(resource, m_settings.getProperty().getName(), false);
Matcher matcher = Pattern.compile(m_settings.getSearchpattern()).matcher(prop.getValue());
if (m_settings.getReplacepattern().isEmpty()) {
prop.setValue("", "");
} else {
prop.setValue(matcher.replaceAll(m_settings.getReplacepattern()), CmsProperty.TYPE_INDIVIDUAL);
}
getCms().lockResource(resource);
getCms().writePropertyObjects(resource, Collections.singletonList(prop));
getCms().unlockResource(resource);
} catch (CmsException e) {
LOG.error("Ubable to change property", e);
}
}
} } | public class class_name {
private void replaceProperties(Set<CmsResource> matchedResources) {
for (CmsResource resource : matchedResources) {
try {
CmsProperty prop = getCms().readPropertyObject(resource, m_settings.getProperty().getName(), false);
Matcher matcher = Pattern.compile(m_settings.getSearchpattern()).matcher(prop.getValue());
if (m_settings.getReplacepattern().isEmpty()) {
prop.setValue("", ""); // depends on control dependency: [if], data = [none]
} else {
prop.setValue(matcher.replaceAll(m_settings.getReplacepattern()), CmsProperty.TYPE_INDIVIDUAL); // depends on control dependency: [if], data = [none]
}
getCms().lockResource(resource); // depends on control dependency: [try], data = [none]
getCms().writePropertyObjects(resource, Collections.singletonList(prop)); // depends on control dependency: [try], data = [none]
getCms().unlockResource(resource); // depends on control dependency: [try], data = [none]
} catch (CmsException e) {
LOG.error("Ubable to change property", e);
} // depends on control dependency: [catch], data = [none]
}
} } |
public class class_name {
public static boolean sendStaticContent(
Request.In event, IOSubchannel channel,
Function<String, URL> resolver, MaxAgeCalculator maxAgeCalculator) {
if (sendStaticContent(
event.httpRequest(), channel, resolver, maxAgeCalculator)) {
event.setResult(true);
event.stop();
return true;
}
return false;
} } | public class class_name {
public static boolean sendStaticContent(
Request.In event, IOSubchannel channel,
Function<String, URL> resolver, MaxAgeCalculator maxAgeCalculator) {
if (sendStaticContent(
event.httpRequest(), channel, resolver, maxAgeCalculator)) {
event.setResult(true); // depends on control dependency: [if], data = [none]
event.stop(); // depends on control dependency: [if], data = [none]
return true; // depends on control dependency: [if], data = [none]
}
return false;
} } |
public class class_name {
public static void renameFiles(File[] filePath, String prefix, String suffix, int start) {
String[] fileNames = new String[filePath.length];
for (int i = 0; i < fileNames.length; i++) {
fileNames[i] = prefix + (start++) + suffix;
}
renameFiles(filePath, fileNames);
} } | public class class_name {
public static void renameFiles(File[] filePath, String prefix, String suffix, int start) {
String[] fileNames = new String[filePath.length];
for (int i = 0; i < fileNames.length; i++) {
fileNames[i] = prefix + (start++) + suffix; // depends on control dependency: [for], data = [i]
}
renameFiles(filePath, fileNames);
} } |
public class class_name {
protected static String stringOf(Value val)
{
StringBuilder s = new StringBuilder();
val = val.deref();
if (val instanceof SeqValue)
{
SeqValue sv = (SeqValue) val;
for (Value v : sv.values)
{
v = v.deref();
if (v instanceof CharacterValue)
{
CharacterValue cv = (CharacterValue) v;
s.append(cv.unicode);
} else
{
s.append("?");
}
}
return s.toString();
} else
{
return val.toString();
}
} } | public class class_name {
protected static String stringOf(Value val)
{
StringBuilder s = new StringBuilder();
val = val.deref();
if (val instanceof SeqValue)
{
SeqValue sv = (SeqValue) val;
for (Value v : sv.values)
{
v = v.deref(); // depends on control dependency: [for], data = [v]
if (v instanceof CharacterValue)
{
CharacterValue cv = (CharacterValue) v;
s.append(cv.unicode); // depends on control dependency: [if], data = [none]
} else
{
s.append("?"); // depends on control dependency: [if], data = [none]
}
}
return s.toString(); // depends on control dependency: [if], data = [none]
} else
{
return val.toString(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static String serialize(Object object) {
if (object == null) return "[null]";
try {
return new ScriptConverter().serialize(object);
}
catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
return object.toString();
}
} } | public class class_name {
public static String serialize(Object object) {
if (object == null) return "[null]";
try {
return new ScriptConverter().serialize(object); // depends on control dependency: [try], data = [none]
}
catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
return object.toString();
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
@SuppressWarnings("UnusedReturnValue")
boolean createBond() {
final BluetoothDevice device = mGatt.getDevice();
if (device.getBondState() == BluetoothDevice.BOND_BONDED)
return true;
boolean result;
mRequestCompleted = false;
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_VERBOSE, "Starting pairing...");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_DEBUG, "gatt.getDevice().createBond()");
result = device.createBond();
} else {
result = createBondApi18(device);
}
// We have to wait until device is bounded
try {
synchronized (mLock) {
while (!mRequestCompleted && !mAborted)
mLock.wait();
}
} catch (final InterruptedException e) {
loge("Sleeping interrupted", e);
}
return result;
} } | public class class_name {
@SuppressWarnings("UnusedReturnValue")
boolean createBond() {
final BluetoothDevice device = mGatt.getDevice();
if (device.getBondState() == BluetoothDevice.BOND_BONDED)
return true;
boolean result;
mRequestCompleted = false;
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_VERBOSE, "Starting pairing...");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_DEBUG, "gatt.getDevice().createBond()"); // depends on control dependency: [if], data = [none]
result = device.createBond(); // depends on control dependency: [if], data = [none]
} else {
result = createBondApi18(device); // depends on control dependency: [if], data = [none]
}
// We have to wait until device is bounded
try {
synchronized (mLock) { // depends on control dependency: [try], data = [none]
while (!mRequestCompleted && !mAborted)
mLock.wait();
}
} catch (final InterruptedException e) {
loge("Sleeping interrupted", e);
} // depends on control dependency: [catch], data = [none]
return result;
} } |
public class class_name {
private void checkDestinationHandlerExists(
boolean condition, String destName, String engineName) throws SINotPossibleInCurrentConfigurationException, SITemporaryDestinationNotFoundException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(
tc,
"checkDestinationHandlerExists",
new Object[] { new Boolean(condition), destName, engineName });
if (!condition)
{
if (destName.startsWith(SIMPConstants.TEMPORARY_QUEUE_DESTINATION_PREFIX) ||
destName.startsWith(SIMPConstants.TEMPORARY_PUBSUB_DESTINATION_PREFIX))
{
SIMPTemporaryDestinationNotFoundException e = new SIMPTemporaryDestinationNotFoundException(
nls.getFormattedMessage(
"TEMPORARY_DESTINATION_NAME_ERROR_CWSIP0097",
new Object[] { destName },
null));
SibTr.exception(tc, e);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "checkDestinationHandlerExists", e);
throw e;
}
SIMPNotPossibleInCurrentConfigurationException e = new SIMPNotPossibleInCurrentConfigurationException(
nls_cwsik.getFormattedMessage(
"DELIVERY_ERROR_SIRC_15", // DESTINATION_NOT_FOUND_ERROR_CWSIP0042
new Object[] { destName, engineName },
null));
e.setExceptionReason(SIRCConstants.SIRC0015_DESTINATION_NOT_FOUND_ERROR);
e.setExceptionInserts(new String[] { destName, engineName });
SibTr.exception(tc, e);
// Log a warning message to assist in PD. We use the suppressor to avoid
// multiple messages for the same destination.
SibTr.warning(tc_cwsik,
SibTr.Suppressor.ALL_FOR_A_WHILE_SIMILAR_INSERTS,
"DELIVERY_ERROR_SIRC_15",
new Object[] { destName, engineName });
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "checkDestinationHandlerExists", e);
throw e;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "checkDestinationHandlerExists");
} } | public class class_name {
private void checkDestinationHandlerExists(
boolean condition, String destName, String engineName) throws SINotPossibleInCurrentConfigurationException, SITemporaryDestinationNotFoundException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(
tc,
"checkDestinationHandlerExists",
new Object[] { new Boolean(condition), destName, engineName });
if (!condition)
{
if (destName.startsWith(SIMPConstants.TEMPORARY_QUEUE_DESTINATION_PREFIX) ||
destName.startsWith(SIMPConstants.TEMPORARY_PUBSUB_DESTINATION_PREFIX))
{
SIMPTemporaryDestinationNotFoundException e = new SIMPTemporaryDestinationNotFoundException(
nls.getFormattedMessage(
"TEMPORARY_DESTINATION_NAME_ERROR_CWSIP0097",
new Object[] { destName },
null));
SibTr.exception(tc, e); // depends on control dependency: [if], data = [none]
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "checkDestinationHandlerExists", e);
throw e;
}
SIMPNotPossibleInCurrentConfigurationException e = new SIMPNotPossibleInCurrentConfigurationException(
nls_cwsik.getFormattedMessage(
"DELIVERY_ERROR_SIRC_15", // DESTINATION_NOT_FOUND_ERROR_CWSIP0042
new Object[] { destName, engineName },
null));
e.setExceptionReason(SIRCConstants.SIRC0015_DESTINATION_NOT_FOUND_ERROR); // depends on control dependency: [if], data = [none]
e.setExceptionInserts(new String[] { destName, engineName }); // depends on control dependency: [if], data = [none]
SibTr.exception(tc, e); // depends on control dependency: [if], data = [none]
// Log a warning message to assist in PD. We use the suppressor to avoid
// multiple messages for the same destination.
SibTr.warning(tc_cwsik,
SibTr.Suppressor.ALL_FOR_A_WHILE_SIMILAR_INSERTS,
"DELIVERY_ERROR_SIRC_15",
new Object[] { destName, engineName }); // depends on control dependency: [if], data = [none]
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "checkDestinationHandlerExists", e);
throw e;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "checkDestinationHandlerExists");
} } |
public class class_name {
private boolean checkPermissions(String sentence) {
sentence = sentence.toUpperCase();
// protected user from the case where they accidentally left off the condition in DELETE statements
// (you can still use dummy conditions like 'WHERE 1=1' if you really want to delete everything)
if (sentence.contains("DELETE FROM") && !sentence.contains("WHERE")) {
return false;
}
return true;
} } | public class class_name {
private boolean checkPermissions(String sentence) {
sentence = sentence.toUpperCase();
// protected user from the case where they accidentally left off the condition in DELETE statements
// (you can still use dummy conditions like 'WHERE 1=1' if you really want to delete everything)
if (sentence.contains("DELETE FROM") && !sentence.contains("WHERE")) {
return false; // depends on control dependency: [if], data = [none]
}
return true;
} } |
public class class_name {
@Override public void skip(long byteCount) throws EOFException {
while (byteCount > 0) {
if (head == null) throw new EOFException();
int toSkip = (int) Math.min(byteCount, head.limit - head.pos);
size -= toSkip;
byteCount -= toSkip;
head.pos += toSkip;
if (head.pos == head.limit) {
Segment toRecycle = head;
head = toRecycle.pop();
SegmentPool.recycle(toRecycle);
}
}
} } | public class class_name {
@Override public void skip(long byteCount) throws EOFException {
while (byteCount > 0) {
if (head == null) throw new EOFException();
int toSkip = (int) Math.min(byteCount, head.limit - head.pos);
size -= toSkip;
byteCount -= toSkip;
head.pos += toSkip;
if (head.pos == head.limit) {
Segment toRecycle = head;
head = toRecycle.pop(); // depends on control dependency: [if], data = [none]
SegmentPool.recycle(toRecycle); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
private void addNewChild(String name, Object value) {
IntrospectionLevelMember prospectiveMember = new IntrospectionLevelMember(_level + 1, name, makeDescription(value), makeMember(value), _allKnownMembersInThisTree);
if (makeMember(value) != null) {
// OK, we'd like to introspect the object further - have we seen it?
if (_allKnownMembersInThisTree.contains(prospectiveMember)) {
// Already seen it, so ensure we don't reexamine it
prospectiveMember = new IntrospectionLevelMember(_level + 1, name, makeDescription(value), null, _allKnownMembersInThisTree);
} else {
// Ensure we don't reexamine it if we see it again!
_allKnownMembersInThisTree.add(prospectiveMember);
}
}
_children.add(prospectiveMember);
} } | public class class_name {
private void addNewChild(String name, Object value) {
IntrospectionLevelMember prospectiveMember = new IntrospectionLevelMember(_level + 1, name, makeDescription(value), makeMember(value), _allKnownMembersInThisTree);
if (makeMember(value) != null) {
// OK, we'd like to introspect the object further - have we seen it?
if (_allKnownMembersInThisTree.contains(prospectiveMember)) {
// Already seen it, so ensure we don't reexamine it
prospectiveMember = new IntrospectionLevelMember(_level + 1, name, makeDescription(value), null, _allKnownMembersInThisTree); // depends on control dependency: [if], data = [none]
} else {
// Ensure we don't reexamine it if we see it again!
_allKnownMembersInThisTree.add(prospectiveMember); // depends on control dependency: [if], data = [none]
}
}
_children.add(prospectiveMember);
} } |
public class class_name {
public static List<Integer> randomizeWithinLimit(int limit) {
List<Integer> list = new ArrayList<Integer>(limit);
for (int i = 0; i < limit; i++) {
list.add(i);
}
Collections.shuffle(list, new Random());
return list;
} } | public class class_name {
public static List<Integer> randomizeWithinLimit(int limit) {
List<Integer> list = new ArrayList<Integer>(limit);
for (int i = 0; i < limit; i++) {
list.add(i); // depends on control dependency: [for], data = [i]
}
Collections.shuffle(list, new Random());
return list;
} } |
public class class_name {
public boolean hasDouble(String attributeName) {
String attr = attributes.get(attributeName);
if (attr == null || attr.isEmpty()) {
return false;
}
try {
Double.parseDouble(attr);
return true;
} catch (NumberFormatException ex) {
return false;
}
} } | public class class_name {
public boolean hasDouble(String attributeName) {
String attr = attributes.get(attributeName);
if (attr == null || attr.isEmpty()) {
return false; // depends on control dependency: [if], data = [none]
}
try {
Double.parseDouble(attr); // depends on control dependency: [try], data = [none]
return true; // depends on control dependency: [try], data = [none]
} catch (NumberFormatException ex) {
return false;
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
@Override
public List<Build> standardFilter(Branch branch, StandardBuildFilterData data, Function<String, PropertyType<?>> propertyTypeAccessor) {
// Query root
StringBuilder tables = new StringBuilder("SELECT DISTINCT(B.ID) FROM BUILDS B ");
// Criterias
StringBuilder criteria = new StringBuilder(" WHERE B.BRANCHID = :branch");
// Parameters
MapSqlParameterSource params = new MapSqlParameterSource("branch", branch.id());
Integer sinceBuildId = null;
// sincePromotionLevel
String sincePromotionLevel = data.getSincePromotionLevel();
if (StringUtils.isNotBlank(sincePromotionLevel)) {
// Gets the promotion level ID
int promotionLevelId = structureRepository
.getPromotionLevelByName(branch, sincePromotionLevel)
.map(Entity::id)
.orElse(-1);
// Gets the last build having this promotion level
Integer id = findLastBuildWithPromotionLevel(promotionLevelId);
if (id != null) {
sinceBuildId = id;
}
}
// withPromotionLevel
String withPromotionLevel = data.getWithPromotionLevel();
if (StringUtils.isNotBlank(withPromotionLevel)) {
tables.append(
" LEFT JOIN PROMOTION_RUNS PR ON PR.BUILDID = B.ID" +
" LEFT JOIN PROMOTION_LEVELS PL ON PL.ID = PR.PROMOTIONLEVELID");
criteria.append(" AND PL.NAME = :withPromotionLevel");
params.addValue("withPromotionLevel", withPromotionLevel);
}
// afterDate
LocalDate afterDate = data.getAfterDate();
if (afterDate != null) {
criteria.append(" AND B.CREATION >= :afterDate");
params.addValue("afterDate", dateTimeForDB(afterDate.atTime(0, 0)));
}
// beforeDate
LocalDate beforeDate = data.getBeforeDate();
if (beforeDate != null) {
criteria.append(" AND B.CREATION <= :beforeDate");
params.addValue("beforeDate", dateTimeForDB(beforeDate.atTime(23, 59, 59)));
}
// sinceValidationStamp
String sinceValidationStamp = data.getSinceValidationStamp();
if (StringUtils.isNotBlank(sinceValidationStamp)) {
// Gets the validation stamp ID
int validationStampId = getValidationStampId(branch, sinceValidationStamp);
// Gets the last build having this validation stamp and the validation status
Integer id = findLastBuildWithValidationStamp(validationStampId, data.getSinceValidationStampStatus());
if (id != null) {
if (sinceBuildId == null) {
sinceBuildId = id;
} else {
sinceBuildId = Math.max(sinceBuildId, id);
}
}
}
// withValidationStamp
String withValidationStamp = data.getWithValidationStamp();
if (StringUtils.isNotBlank(withValidationStamp)) {
tables.append(
" LEFT JOIN (" +
" SELECT R.BUILDID, R.VALIDATIONSTAMPID, VRS.VALIDATIONRUNSTATUSID " +
" FROM VALIDATION_RUNS R" +
" INNER JOIN VALIDATION_RUN_STATUSES VRS ON VRS.ID = (SELECT ID FROM VALIDATION_RUN_STATUSES WHERE VALIDATIONRUNID = R.ID ORDER BY ID DESC LIMIT 1)" +
" AND R.ID = (SELECT MAX(ID) FROM VALIDATION_RUNS WHERE BUILDID = R.BUILDID AND VALIDATIONSTAMPID = R.VALIDATIONSTAMPID)" +
" ) S ON S.BUILDID = B.ID"
);
// Gets the validation stamp ID
int validationStampId = getValidationStampId(branch, withValidationStamp);
criteria.append(" AND (S.VALIDATIONSTAMPID = :validationStampId");
params.addValue("validationStampId", validationStampId);
// withValidationStampStatus
String withValidationStampStatus = data.getWithValidationStampStatus();
if (StringUtils.isNotBlank(withValidationStampStatus)) {
criteria.append(" AND S.VALIDATIONRUNSTATUSID = :withValidationStampStatus");
params.addValue("withValidationStampStatus", withValidationStampStatus);
}
criteria.append(")");
}
// withProperty
String withProperty = data.getWithProperty();
if (StringUtils.isNotBlank(withProperty)) {
tables.append(" LEFT JOIN PROPERTIES PP ON PP.BUILD = B.ID");
criteria.append(" AND PP.TYPE = :withProperty");
params.addValue("withProperty", withProperty);
// withPropertyValue
String withPropertyValue = data.getWithPropertyValue();
if (StringUtils.isNotBlank(withPropertyValue)) {
// Gets the property type
PropertyType<?> propertyType = propertyTypeAccessor.apply(withProperty);
// Gets the search arguments
PropertySearchArguments searchArguments = propertyType.getSearchArguments(withPropertyValue);
// If defined use them
if (searchArguments != null && searchArguments.isDefined()) {
PropertyJdbcRepository.prepareQueryForPropertyValue(
searchArguments,
tables,
criteria,
params
);
} else {
// No match
return Collections.emptyList();
}
}
}
// sinceProperty
String sinceProperty = data.getSinceProperty();
if (StringUtils.isNotBlank(sinceProperty)) {
String sincePropertyValue = data.getSincePropertyValue();
Integer id = findLastBuildWithPropertyValue(branch, sinceProperty, sincePropertyValue, propertyTypeAccessor);
if (id != null) {
if (sinceBuildId == null) {
sinceBuildId = id;
} else {
sinceBuildId = Math.max(sinceBuildId, id);
}
}
}
// linkedFrom
String linkedFrom = data.getLinkedFrom();
if (isNotBlank(linkedFrom)) {
tables.append(
" LEFT JOIN BUILD_LINKS BLFROM ON BLFROM.TARGETBUILDID = B.ID" +
" LEFT JOIN BUILDS BDFROM ON BDFROM.ID = BLFROM.BUILDID" +
" LEFT JOIN BRANCHES BRFROM ON BRFROM.ID = BDFROM.BRANCHID" +
" LEFT JOIN PROJECTS PJFROM ON PJFROM.ID = BRFROM.PROJECTID"
);
String project = StringUtils.substringBefore(linkedFrom, ":");
criteria.append(" AND PJFROM.NAME = :fromProject");
params.addValue("fromProject", project);
String buildPattern = StringUtils.substringAfter(linkedFrom, ":");
if (StringUtils.isNotBlank(buildPattern)) {
if (StringUtils.contains(buildPattern, "*")) {
criteria.append(" AND BDFROM.NAME LIKE :buildFrom");
params.addValue("buildFrom", StringUtils.replace(buildPattern, "*", "%"));
} else {
criteria.append(" AND BDFROM.NAME = :buildFrom");
params.addValue("buildFrom", buildPattern);
}
}
// linkedFromPromotion
String linkedFromPromotion = data.getLinkedFromPromotion();
if (StringUtils.isNotBlank(linkedFromPromotion)) {
tables.append(
" LEFT JOIN PROMOTION_RUNS PRFROM ON PRFROM.BUILDID = BDFROM.ID" +
" LEFT JOIN PROMOTION_LEVELS PLFROM ON PLFROM.ID = PRFROM.PROMOTIONLEVELID"
);
criteria.append(" AND PLFROM.NAME = :linkedFromPromotion");
params.addValue("linkedFromPromotion", linkedFromPromotion);
}
}
// linkedTo
String linkedTo = data.getLinkedTo();
if (isNotBlank(linkedTo)) {
tables.append(
" LEFT JOIN BUILD_LINKS BLTO ON BLTO.BUILDID = B.ID" +
" LEFT JOIN BUILDS BDTO ON BDTO.ID = BLTO.TARGETBUILDID" +
" LEFT JOIN BRANCHES BRTO ON BRTO.ID = BDTO.BRANCHID" +
" LEFT JOIN PROJECTS PJTO ON PJTO.ID = BRTO.PROJECTID"
);
String project = StringUtils.substringBefore(linkedTo, ":");
criteria.append(" AND PJTO.NAME = :toProject");
params.addValue("toProject", project);
String buildPattern = StringUtils.substringAfter(linkedTo, ":");
if (StringUtils.isNotBlank(buildPattern)) {
if (StringUtils.contains(buildPattern, "*")) {
criteria.append(" AND BDTO.NAME LIKE :buildTo");
params.addValue("buildTo", StringUtils.replace(buildPattern, "*", "%"));
} else {
criteria.append(" AND BDTO.NAME = :buildTo");
params.addValue("buildTo", buildPattern);
}
}
// linkedToPromotion
String linkedToPromotion = data.getLinkedToPromotion();
if (StringUtils.isNotBlank(linkedToPromotion)) {
tables.append(
" LEFT JOIN PROMOTION_RUNS PRTO ON PRTO.BUILDID = BDTO.ID" +
" LEFT JOIN PROMOTION_LEVELS PLTO ON PLTO.ID = PRTO.PROMOTIONLEVELID"
);
criteria.append(" AND PLTO.NAME = :linkedToPromotion");
params.addValue("linkedToPromotion", linkedToPromotion);
}
}
// Since build?
if (sinceBuildId != null) {
criteria.append(" AND B.ID >= :sinceBuildId");
params.addValue("sinceBuildId", sinceBuildId);
}
// Final SQL
String sql = format(
"%s %s ORDER BY B.ID DESC LIMIT :count",
tables,
criteria);
params.addValue("count", data.getCount());
// Running the query
return loadBuilds(sql, params);
} } | public class class_name {
@Override
public List<Build> standardFilter(Branch branch, StandardBuildFilterData data, Function<String, PropertyType<?>> propertyTypeAccessor) {
// Query root
StringBuilder tables = new StringBuilder("SELECT DISTINCT(B.ID) FROM BUILDS B ");
// Criterias
StringBuilder criteria = new StringBuilder(" WHERE B.BRANCHID = :branch");
// Parameters
MapSqlParameterSource params = new MapSqlParameterSource("branch", branch.id());
Integer sinceBuildId = null;
// sincePromotionLevel
String sincePromotionLevel = data.getSincePromotionLevel();
if (StringUtils.isNotBlank(sincePromotionLevel)) {
// Gets the promotion level ID
int promotionLevelId = structureRepository
.getPromotionLevelByName(branch, sincePromotionLevel)
.map(Entity::id)
.orElse(-1);
// Gets the last build having this promotion level
Integer id = findLastBuildWithPromotionLevel(promotionLevelId);
if (id != null) {
sinceBuildId = id; // depends on control dependency: [if], data = [none]
}
}
// withPromotionLevel
String withPromotionLevel = data.getWithPromotionLevel();
if (StringUtils.isNotBlank(withPromotionLevel)) {
tables.append(
" LEFT JOIN PROMOTION_RUNS PR ON PR.BUILDID = B.ID" +
" LEFT JOIN PROMOTION_LEVELS PL ON PL.ID = PR.PROMOTIONLEVELID");
criteria.append(" AND PL.NAME = :withPromotionLevel");
params.addValue("withPromotionLevel", withPromotionLevel);
}
// afterDate
LocalDate afterDate = data.getAfterDate();
if (afterDate != null) {
criteria.append(" AND B.CREATION >= :afterDate");
params.addValue("afterDate", dateTimeForDB(afterDate.atTime(0, 0)));
}
// beforeDate
LocalDate beforeDate = data.getBeforeDate();
if (beforeDate != null) {
criteria.append(" AND B.CREATION <= :beforeDate");
params.addValue("beforeDate", dateTimeForDB(beforeDate.atTime(23, 59, 59)));
}
// sinceValidationStamp
String sinceValidationStamp = data.getSinceValidationStamp();
if (StringUtils.isNotBlank(sinceValidationStamp)) {
// Gets the validation stamp ID
int validationStampId = getValidationStampId(branch, sinceValidationStamp);
// Gets the last build having this validation stamp and the validation status
Integer id = findLastBuildWithValidationStamp(validationStampId, data.getSinceValidationStampStatus());
if (id != null) {
if (sinceBuildId == null) {
sinceBuildId = id;
} else {
sinceBuildId = Math.max(sinceBuildId, id);
}
}
}
// withValidationStamp
String withValidationStamp = data.getWithValidationStamp();
if (StringUtils.isNotBlank(withValidationStamp)) {
tables.append(
" LEFT JOIN (" +
" SELECT R.BUILDID, R.VALIDATIONSTAMPID, VRS.VALIDATIONRUNSTATUSID " +
" FROM VALIDATION_RUNS R" +
" INNER JOIN VALIDATION_RUN_STATUSES VRS ON VRS.ID = (SELECT ID FROM VALIDATION_RUN_STATUSES WHERE VALIDATIONRUNID = R.ID ORDER BY ID DESC LIMIT 1)" +
" AND R.ID = (SELECT MAX(ID) FROM VALIDATION_RUNS WHERE BUILDID = R.BUILDID AND VALIDATIONSTAMPID = R.VALIDATIONSTAMPID)" +
" ) S ON S.BUILDID = B.ID"
);
// Gets the validation stamp ID
int validationStampId = getValidationStampId(branch, withValidationStamp);
criteria.append(" AND (S.VALIDATIONSTAMPID = :validationStampId");
params.addValue("validationStampId", validationStampId);
// withValidationStampStatus
String withValidationStampStatus = data.getWithValidationStampStatus();
if (StringUtils.isNotBlank(withValidationStampStatus)) {
criteria.append(" AND S.VALIDATIONRUNSTATUSID = :withValidationStampStatus");
params.addValue("withValidationStampStatus", withValidationStampStatus);
}
criteria.append(")");
}
// withProperty
String withProperty = data.getWithProperty();
if (StringUtils.isNotBlank(withProperty)) {
tables.append(" LEFT JOIN PROPERTIES PP ON PP.BUILD = B.ID");
criteria.append(" AND PP.TYPE = :withProperty");
params.addValue("withProperty", withProperty);
// withPropertyValue
String withPropertyValue = data.getWithPropertyValue();
if (StringUtils.isNotBlank(withPropertyValue)) {
// Gets the property type
PropertyType<?> propertyType = propertyTypeAccessor.apply(withProperty);
// Gets the search arguments
PropertySearchArguments searchArguments = propertyType.getSearchArguments(withPropertyValue);
// If defined use them
if (searchArguments != null && searchArguments.isDefined()) {
PropertyJdbcRepository.prepareQueryForPropertyValue(
searchArguments,
tables,
criteria,
params
);
} else {
// No match
return Collections.emptyList();
}
}
}
// sinceProperty
String sinceProperty = data.getSinceProperty();
if (StringUtils.isNotBlank(sinceProperty)) {
String sincePropertyValue = data.getSincePropertyValue();
Integer id = findLastBuildWithPropertyValue(branch, sinceProperty, sincePropertyValue, propertyTypeAccessor);
if (id != null) {
if (sinceBuildId == null) {
sinceBuildId = id;
} else {
sinceBuildId = Math.max(sinceBuildId, id);
}
}
}
// linkedFrom
String linkedFrom = data.getLinkedFrom();
if (isNotBlank(linkedFrom)) {
tables.append(
" LEFT JOIN BUILD_LINKS BLFROM ON BLFROM.TARGETBUILDID = B.ID" +
" LEFT JOIN BUILDS BDFROM ON BDFROM.ID = BLFROM.BUILDID" +
" LEFT JOIN BRANCHES BRFROM ON BRFROM.ID = BDFROM.BRANCHID" +
" LEFT JOIN PROJECTS PJFROM ON PJFROM.ID = BRFROM.PROJECTID"
);
String project = StringUtils.substringBefore(linkedFrom, ":");
criteria.append(" AND PJFROM.NAME = :fromProject");
params.addValue("fromProject", project);
String buildPattern = StringUtils.substringAfter(linkedFrom, ":");
if (StringUtils.isNotBlank(buildPattern)) {
if (StringUtils.contains(buildPattern, "*")) {
criteria.append(" AND BDFROM.NAME LIKE :buildFrom");
params.addValue("buildFrom", StringUtils.replace(buildPattern, "*", "%"));
} else {
criteria.append(" AND BDFROM.NAME = :buildFrom");
params.addValue("buildFrom", buildPattern);
}
}
// linkedFromPromotion
String linkedFromPromotion = data.getLinkedFromPromotion();
if (StringUtils.isNotBlank(linkedFromPromotion)) {
tables.append(
" LEFT JOIN PROMOTION_RUNS PRFROM ON PRFROM.BUILDID = BDFROM.ID" +
" LEFT JOIN PROMOTION_LEVELS PLFROM ON PLFROM.ID = PRFROM.PROMOTIONLEVELID"
);
criteria.append(" AND PLFROM.NAME = :linkedFromPromotion");
params.addValue("linkedFromPromotion", linkedFromPromotion);
}
}
// linkedTo
String linkedTo = data.getLinkedTo();
if (isNotBlank(linkedTo)) {
tables.append(
" LEFT JOIN BUILD_LINKS BLTO ON BLTO.BUILDID = B.ID" +
" LEFT JOIN BUILDS BDTO ON BDTO.ID = BLTO.TARGETBUILDID" +
" LEFT JOIN BRANCHES BRTO ON BRTO.ID = BDTO.BRANCHID" +
" LEFT JOIN PROJECTS PJTO ON PJTO.ID = BRTO.PROJECTID"
);
String project = StringUtils.substringBefore(linkedTo, ":");
criteria.append(" AND PJTO.NAME = :toProject");
params.addValue("toProject", project);
String buildPattern = StringUtils.substringAfter(linkedTo, ":");
if (StringUtils.isNotBlank(buildPattern)) {
if (StringUtils.contains(buildPattern, "*")) {
criteria.append(" AND BDTO.NAME LIKE :buildTo");
params.addValue("buildTo", StringUtils.replace(buildPattern, "*", "%"));
} else {
criteria.append(" AND BDTO.NAME = :buildTo");
params.addValue("buildTo", buildPattern);
}
}
// linkedToPromotion
String linkedToPromotion = data.getLinkedToPromotion();
if (StringUtils.isNotBlank(linkedToPromotion)) {
tables.append(
" LEFT JOIN PROMOTION_RUNS PRTO ON PRTO.BUILDID = BDTO.ID" +
" LEFT JOIN PROMOTION_LEVELS PLTO ON PLTO.ID = PRTO.PROMOTIONLEVELID"
);
criteria.append(" AND PLTO.NAME = :linkedToPromotion");
params.addValue("linkedToPromotion", linkedToPromotion);
}
}
// Since build?
if (sinceBuildId != null) {
criteria.append(" AND B.ID >= :sinceBuildId");
params.addValue("sinceBuildId", sinceBuildId);
}
// Final SQL
String sql = format(
"%s %s ORDER BY B.ID DESC LIMIT :count",
tables,
criteria);
params.addValue("count", data.getCount());
// Running the query
return loadBuilds(sql, params);
} } |
public class class_name {
private static int calculateBitRate(int mpegVer, int layer, int code) {
int[] arr = null;
if (mpegVer == AudioFrame.MPEG_V1) {
switch (layer) {
case AudioFrame.LAYER_1:
arr = BIT_RATE_MPEG1_L1;
break;
case AudioFrame.LAYER_2:
arr = BIT_RATE_MPEG1_L2;
break;
case AudioFrame.LAYER_3:
arr = BIT_RATE_MPEG1_L3;
break;
}
} else {
if (layer == AudioFrame.LAYER_1) {
arr = BIT_RATE_MPEG2_L1;
} else {
arr = BIT_RATE_MPEG2_L2;
}
}
return arr[code];
} } | public class class_name {
private static int calculateBitRate(int mpegVer, int layer, int code) {
int[] arr = null;
if (mpegVer == AudioFrame.MPEG_V1) {
switch (layer) {
case AudioFrame.LAYER_1:
arr = BIT_RATE_MPEG1_L1;
break;
case AudioFrame.LAYER_2:
arr = BIT_RATE_MPEG1_L2;
break;
case AudioFrame.LAYER_3:
arr = BIT_RATE_MPEG1_L3;
break;
}
} else {
if (layer == AudioFrame.LAYER_1) {
arr = BIT_RATE_MPEG2_L1; // depends on control dependency: [if], data = [none]
} else {
arr = BIT_RATE_MPEG2_L2; // depends on control dependency: [if], data = [none]
}
}
return arr[code];
} } |
public class class_name {
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
if (servletContext == null)
if (applicationContext instanceof WebApplicationContext) {
servletContext = ((WebApplicationContext) applicationContext).getServletContext();
if (servletContext == null) {
System.err.print("this class only fit for Spring Web Application");
return;
}
}
// start up jdon
AppContextWrapper acw = new ServletContextWrapper(servletContext);
ContainerFinder containerFinder = new ContainerFinderImp();
containerWrapper = containerFinder.findContainer(acw);
} } | public class class_name {
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
if (servletContext == null)
if (applicationContext instanceof WebApplicationContext) {
servletContext = ((WebApplicationContext) applicationContext).getServletContext();
if (servletContext == null) {
System.err.print("this class only fit for Spring Web Application");
// depends on control dependency: [if], data = [none]
return;
// depends on control dependency: [if], data = [none]
}
}
// start up jdon
AppContextWrapper acw = new ServletContextWrapper(servletContext);
ContainerFinder containerFinder = new ContainerFinderImp();
containerWrapper = containerFinder.findContainer(acw);
} } |
public class class_name {
private static ZipInputStream newCloseShieldZipInputStream(final InputStream is, Charset charset) {
InputStream in = new BufferedInputStream(new CloseShieldInputStream(is));
if (charset == null) {
return new ZipInputStream(in);
}
return ZipFileUtil.createZipInputStream(in, charset);
} } | public class class_name {
private static ZipInputStream newCloseShieldZipInputStream(final InputStream is, Charset charset) {
InputStream in = new BufferedInputStream(new CloseShieldInputStream(is));
if (charset == null) {
return new ZipInputStream(in); // depends on control dependency: [if], data = [none]
}
return ZipFileUtil.createZipInputStream(in, charset);
} } |
public class class_name {
public static void setDefaultExecutorService(
ExecutorService defaultExecutorService) {
// If the timer executor service is set to the default
// executor service, adjust it to the new value as well.
if (timerExecutorService == Components.defaultExecutorService) {
timerExecutorService = defaultExecutorService;
}
Components.defaultExecutorService = defaultExecutorService;
} } | public class class_name {
public static void setDefaultExecutorService(
ExecutorService defaultExecutorService) {
// If the timer executor service is set to the default
// executor service, adjust it to the new value as well.
if (timerExecutorService == Components.defaultExecutorService) {
timerExecutorService = defaultExecutorService; // depends on control dependency: [if], data = [none]
}
Components.defaultExecutorService = defaultExecutorService;
} } |
public class class_name {
public F2<P1, P2, R> orElse(final Func2<? super P1, ? super P2, ? extends R> fallback) {
final F2<P1, P2, R> me = this;
return new F2<P1, P2, R>() {
@Override
public R apply(P1 p1, P2 p2) {
try {
return me.apply(p1, p2);
} catch (RuntimeException e) {
return fallback.apply(p1, p2);
}
}
};
} } | public class class_name {
public F2<P1, P2, R> orElse(final Func2<? super P1, ? super P2, ? extends R> fallback) {
final F2<P1, P2, R> me = this;
return new F2<P1, P2, R>() {
@Override
public R apply(P1 p1, P2 p2) {
try {
return me.apply(p1, p2); // depends on control dependency: [try], data = [none]
} catch (RuntimeException e) {
return fallback.apply(p1, p2);
} // depends on control dependency: [catch], data = [none]
}
};
} } |
public class class_name {
public Deferred<Boolean> flushCollisions(final TSDB tsdb) {
if (!store_failures) {
collisions.clear();
return Deferred.fromResult(true);
}
final byte[] row_key = new byte[TREE_ID_WIDTH + 1];
System.arraycopy(idToBytes(tree_id), 0, row_key, 0, TREE_ID_WIDTH);
row_key[TREE_ID_WIDTH] = COLLISION_ROW_SUFFIX;
final byte[][] qualifiers = new byte[collisions.size()][];
final byte[][] values = new byte[collisions.size()][];
int index = 0;
for (Map.Entry<String, String> entry : collisions.entrySet()) {
qualifiers[index] = new byte[COLLISION_PREFIX.length +
(entry.getKey().length() / 2)];
System.arraycopy(COLLISION_PREFIX, 0, qualifiers[index], 0,
COLLISION_PREFIX.length);
final byte[] tsuid = UniqueId.stringToUid(entry.getKey());
System.arraycopy(tsuid, 0, qualifiers[index],
COLLISION_PREFIX.length, tsuid.length);
values[index] = entry.getValue().getBytes(CHARSET);
index++;
}
final PutRequest put = new PutRequest(tsdb.treeTable(), row_key,
TREE_FAMILY, qualifiers, values);
collisions.clear();
/**
* Super simple callback used to convert the Deferred<Object> to a
* Deferred<Boolean> so that it can be grouped with other storage
* calls
*/
final class PutCB implements Callback<Deferred<Boolean>, Object> {
@Override
public Deferred<Boolean> call(Object result) throws Exception {
return Deferred.fromResult(true);
}
}
return tsdb.getClient().put(put).addCallbackDeferring(new PutCB());
} } | public class class_name {
public Deferred<Boolean> flushCollisions(final TSDB tsdb) {
if (!store_failures) {
collisions.clear(); // depends on control dependency: [if], data = [none]
return Deferred.fromResult(true); // depends on control dependency: [if], data = [none]
}
final byte[] row_key = new byte[TREE_ID_WIDTH + 1];
System.arraycopy(idToBytes(tree_id), 0, row_key, 0, TREE_ID_WIDTH);
row_key[TREE_ID_WIDTH] = COLLISION_ROW_SUFFIX;
final byte[][] qualifiers = new byte[collisions.size()][];
final byte[][] values = new byte[collisions.size()][];
int index = 0;
for (Map.Entry<String, String> entry : collisions.entrySet()) {
qualifiers[index] = new byte[COLLISION_PREFIX.length +
(entry.getKey().length() / 2)]; // depends on control dependency: [for], data = [none]
System.arraycopy(COLLISION_PREFIX, 0, qualifiers[index], 0,
COLLISION_PREFIX.length); // depends on control dependency: [for], data = [none]
final byte[] tsuid = UniqueId.stringToUid(entry.getKey());
System.arraycopy(tsuid, 0, qualifiers[index],
COLLISION_PREFIX.length, tsuid.length); // depends on control dependency: [for], data = [none]
values[index] = entry.getValue().getBytes(CHARSET); // depends on control dependency: [for], data = [entry]
index++; // depends on control dependency: [for], data = [none]
}
final PutRequest put = new PutRequest(tsdb.treeTable(), row_key,
TREE_FAMILY, qualifiers, values);
collisions.clear();
/**
* Super simple callback used to convert the Deferred<Object> to a
* Deferred<Boolean> so that it can be grouped with other storage
* calls
*/
final class PutCB implements Callback<Deferred<Boolean>, Object> {
@Override
public Deferred<Boolean> call(Object result) throws Exception {
return Deferred.fromResult(true);
}
}
return tsdb.getClient().put(put).addCallbackDeferring(new PutCB());
} } |
public class class_name {
public Observable<ServiceResponse<Page<RecommendationInner>>> listRecommendedRulesForWebAppWithServiceResponseAsync(final String resourceGroupName, final String siteName, final Boolean featured, final String filter) {
return listRecommendedRulesForWebAppSinglePageAsync(resourceGroupName, siteName, featured, filter)
.concatMap(new Func1<ServiceResponse<Page<RecommendationInner>>, Observable<ServiceResponse<Page<RecommendationInner>>>>() {
@Override
public Observable<ServiceResponse<Page<RecommendationInner>>> call(ServiceResponse<Page<RecommendationInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listRecommendedRulesForWebAppNextWithServiceResponseAsync(nextPageLink));
}
});
} } | public class class_name {
public Observable<ServiceResponse<Page<RecommendationInner>>> listRecommendedRulesForWebAppWithServiceResponseAsync(final String resourceGroupName, final String siteName, final Boolean featured, final String filter) {
return listRecommendedRulesForWebAppSinglePageAsync(resourceGroupName, siteName, featured, filter)
.concatMap(new Func1<ServiceResponse<Page<RecommendationInner>>, Observable<ServiceResponse<Page<RecommendationInner>>>>() {
@Override
public Observable<ServiceResponse<Page<RecommendationInner>>> call(ServiceResponse<Page<RecommendationInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page); // depends on control dependency: [if], data = [none]
}
return Observable.just(page).concatWith(listRecommendedRulesForWebAppNextWithServiceResponseAsync(nextPageLink));
}
});
} } |
public class class_name {
public ZonedDateTime getTime() {
if (null == time) {
ZonedDateTime now = ZonedDateTime.now();
time = new ObjectPropertyBase<ZonedDateTime>(now) {
@Override protected void invalidated() {
zoneId = get().getZone();
fireTileEvent(RECALC_EVENT);
if (!isRunning() && isAnimated()) {
long animationDuration = getAnimationDuration();
timeline.stop();
final KeyValue KEY_VALUE = new KeyValue(currentTime, now.toEpochSecond());
final KeyFrame KEY_FRAME = new KeyFrame(javafx.util.Duration.millis(animationDuration), KEY_VALUE);
timeline.getKeyFrames().setAll(KEY_FRAME);
timeline.setOnFinished(e -> fireTileEvent(FINISHED_EVENT));
timeline.play();
} else {
currentTime.set(now.toEpochSecond());
fireTileEvent(FINISHED_EVENT);
}
}
@Override public Object getBean() { return Tile.this; }
@Override public String getName() { return "time"; }
};
}
return time.get();
} } | public class class_name {
public ZonedDateTime getTime() {
if (null == time) {
ZonedDateTime now = ZonedDateTime.now();
time = new ObjectPropertyBase<ZonedDateTime>(now) {
@Override protected void invalidated() {
zoneId = get().getZone();
fireTileEvent(RECALC_EVENT);
if (!isRunning() && isAnimated()) {
long animationDuration = getAnimationDuration();
timeline.stop(); // depends on control dependency: [if], data = [none]
final KeyValue KEY_VALUE = new KeyValue(currentTime, now.toEpochSecond());
final KeyFrame KEY_FRAME = new KeyFrame(javafx.util.Duration.millis(animationDuration), KEY_VALUE);
timeline.getKeyFrames().setAll(KEY_FRAME); // depends on control dependency: [if], data = [none]
timeline.setOnFinished(e -> fireTileEvent(FINISHED_EVENT)); // depends on control dependency: [if], data = [none]
timeline.play(); // depends on control dependency: [if], data = [none]
} else {
currentTime.set(now.toEpochSecond()); // depends on control dependency: [if], data = [none]
fireTileEvent(FINISHED_EVENT); // depends on control dependency: [if], data = [none]
}
}
@Override public Object getBean() { return Tile.this; }
@Override public String getName() { return "time"; }
}; // depends on control dependency: [if], data = [none]
}
return time.get();
} } |
public class class_name {
private void processTaskQueue() {
mQueueProcessed = true;
try {
Task task;
while((task = mTaskQueue.poll()) != null) {
switch (task.code) {
case Task.CODE_FIRE_EVENT: {
Object event = task.event;
final Class<? extends Object> clazz = event.getClass();
fire(clazz, event, StateHandler.STATE_ANY);
fire(clazz, event, mCurrentState);
break;
}
case Task.CODE_TRANSITION: {
int state = task.state;
if (mCurrentState != state) {
fire(OnExit.class, null, StateHandler.STATE_ANY);
fire(OnExit.class, null, mCurrentState);
mCurrentState = state;
if (mTraceTag != null) {
log("new state", null);
}
fire(OnEntry.class, null, StateHandler.STATE_ANY);
fire(OnEntry.class, null, mCurrentState);
}
break;
}
default: throw new IllegalStateException("wrong code: " + task.code);
}
task.recycle();
}
} finally {
mQueueProcessed = false;
}
} } | public class class_name {
private void processTaskQueue() {
mQueueProcessed = true;
try {
Task task;
while((task = mTaskQueue.poll()) != null) {
switch (task.code) {
case Task.CODE_FIRE_EVENT: {
Object event = task.event;
final Class<? extends Object> clazz = event.getClass();
fire(clazz, event, StateHandler.STATE_ANY);
fire(clazz, event, mCurrentState);
break;
}
case Task.CODE_TRANSITION: {
int state = task.state;
if (mCurrentState != state) {
fire(OnExit.class, null, StateHandler.STATE_ANY); // depends on control dependency: [if], data = [none]
fire(OnExit.class, null, mCurrentState); // depends on control dependency: [if], data = [none]
mCurrentState = state; // depends on control dependency: [if], data = [none]
if (mTraceTag != null) {
log("new state", null); // depends on control dependency: [if], data = [null)]
}
fire(OnEntry.class, null, StateHandler.STATE_ANY); // depends on control dependency: [if], data = [none]
fire(OnEntry.class, null, mCurrentState); // depends on control dependency: [if], data = [none]
}
break;
}
default: throw new IllegalStateException("wrong code: " + task.code);
}
task.recycle();
}
} finally {
mQueueProcessed = false;
}
} } |
public class class_name {
@Nullable
public static String[] nullableArrayOfStrings(@Nullable List<Object> list) {
if (list == null || list.isEmpty()) {
return null;
} else {
final String[] strings = new String[list.size()];
//noinspection ForLoopReplaceableByForEach -> on Android it's faster
for (int i = 0; i < list.size(); i++) {
final Object arg = list.get(i);
strings[i] = arg != null ? arg.toString() : "null";
}
return strings;
}
} } | public class class_name {
@Nullable
public static String[] nullableArrayOfStrings(@Nullable List<Object> list) {
if (list == null || list.isEmpty()) {
return null; // depends on control dependency: [if], data = [none]
} else {
final String[] strings = new String[list.size()];
//noinspection ForLoopReplaceableByForEach -> on Android it's faster
for (int i = 0; i < list.size(); i++) {
final Object arg = list.get(i);
strings[i] = arg != null ? arg.toString() : "null"; // depends on control dependency: [for], data = [i]
}
return strings; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private CellFormatResult getCellValue(final POICell poiCell, final Locale locale) {
final short formatIndex = poiCell.getFormatIndex();
final String formatPattern = poiCell.getFormatPattern();
if(formatterResolver.canResolve(formatIndex)) {
final CellFormatter cellFormatter = formatterResolver.getFormatter(formatIndex);
return cellFormatter.format(poiCell, locale);
} else if(formatterResolver.canResolve(formatPattern)) {
final CellFormatter cellFormatter = formatterResolver.getFormatter(formatPattern);
return cellFormatter.format(poiCell, locale);
} else {
// キャッシュに存在しない場合
final CellFormatter cellFormatter = formatterResolver.createFormatter(formatPattern) ;
if(isCache()) {
formatterResolver.registerFormatter(formatPattern, cellFormatter);
}
return cellFormatter.format(poiCell, locale);
}
} } | public class class_name {
private CellFormatResult getCellValue(final POICell poiCell, final Locale locale) {
final short formatIndex = poiCell.getFormatIndex();
final String formatPattern = poiCell.getFormatPattern();
if(formatterResolver.canResolve(formatIndex)) {
final CellFormatter cellFormatter = formatterResolver.getFormatter(formatIndex);
return cellFormatter.format(poiCell, locale);
// depends on control dependency: [if], data = [none]
} else if(formatterResolver.canResolve(formatPattern)) {
final CellFormatter cellFormatter = formatterResolver.getFormatter(formatPattern);
return cellFormatter.format(poiCell, locale);
// depends on control dependency: [if], data = [none]
} else {
// キャッシュに存在しない場合
final CellFormatter cellFormatter = formatterResolver.createFormatter(formatPattern) ;
if(isCache()) {
formatterResolver.registerFormatter(formatPattern, cellFormatter);
// depends on control dependency: [if], data = [none]
}
return cellFormatter.format(poiCell, locale);
// depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void drawImage(Object parent, String name, String href, Bbox bounds, PictureStyle style) {
if (isAttached()) {
Element image = helper.createOrUpdateElement(parent, name, "image", style);
applyAbsolutePosition(image, bounds.getOrigin());
applyElementSize(image, (int) bounds.getWidth(), (int) bounds.getHeight(), true);
Dom.setElementAttribute(image, "src", Dom.makeUrlAbsolute(href));
}
} } | public class class_name {
public void drawImage(Object parent, String name, String href, Bbox bounds, PictureStyle style) {
if (isAttached()) {
Element image = helper.createOrUpdateElement(parent, name, "image", style);
applyAbsolutePosition(image, bounds.getOrigin()); // depends on control dependency: [if], data = [none]
applyElementSize(image, (int) bounds.getWidth(), (int) bounds.getHeight(), true); // depends on control dependency: [if], data = [none]
Dom.setElementAttribute(image, "src", Dom.makeUrlAbsolute(href)); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
protected void get(URL fullUrl) {
alert.close();
alert.setAutoAccept(false);
try {
// we can't use webClient.getPage(url) here because selenium has a different idea
// of the current window and we like to load into to selenium current one
final WebRequest request = new WebRequest(fullUrl, getBrowserVersion().getHtmlAcceptHeader());
request.setCharset(StandardCharsets.UTF_8);
getWebClient().getPage(getCurrentWindow().getTopWindow(), request);
// A "get" works over the entire page
currentWindow = getCurrentWindow().getTopWindow();
} catch (UnknownHostException e) {
getCurrentWindow().getTopWindow().setEnclosedPage(new UnexpectedPage(
new StringWebResponse("Unknown host", fullUrl),
getCurrentWindow().getTopWindow()
));
} catch (ConnectException e) {
// This might be expected
} catch (SocketTimeoutException e) {
throw new TimeoutException(e);
} catch (NoSuchSessionException e) {
throw e;
} catch (SSLHandshakeException e) {
return;
} catch (Exception e) {
throw new WebDriverException(e);
}
gotPage = true;
pickWindow();
resetKeyboardAndMouseState();
} } | public class class_name {
protected void get(URL fullUrl) {
alert.close();
alert.setAutoAccept(false);
try {
// we can't use webClient.getPage(url) here because selenium has a different idea
// of the current window and we like to load into to selenium current one
final WebRequest request = new WebRequest(fullUrl, getBrowserVersion().getHtmlAcceptHeader());
request.setCharset(StandardCharsets.UTF_8); // depends on control dependency: [try], data = [none]
getWebClient().getPage(getCurrentWindow().getTopWindow(), request); // depends on control dependency: [try], data = [none]
// A "get" works over the entire page
currentWindow = getCurrentWindow().getTopWindow(); // depends on control dependency: [try], data = [none]
} catch (UnknownHostException e) {
getCurrentWindow().getTopWindow().setEnclosedPage(new UnexpectedPage(
new StringWebResponse("Unknown host", fullUrl),
getCurrentWindow().getTopWindow()
));
} catch (ConnectException e) { // depends on control dependency: [catch], data = [none]
// This might be expected
} catch (SocketTimeoutException e) { // depends on control dependency: [catch], data = [none]
throw new TimeoutException(e);
} catch (NoSuchSessionException e) { // depends on control dependency: [catch], data = [none]
throw e;
} catch (SSLHandshakeException e) { // depends on control dependency: [catch], data = [none]
return;
} catch (Exception e) { // depends on control dependency: [catch], data = [none]
throw new WebDriverException(e);
} // depends on control dependency: [catch], data = [none]
gotPage = true;
pickWindow();
resetKeyboardAndMouseState();
} } |
public class class_name {
public void importResource() {
m_resourceIdWasNull = false;
try {
if (m_throwable != null) {
getReport().println(m_throwable);
getReport().addError(m_throwable);
CmsMessageContainer message = Messages.get().container(
Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
if (LOG.isDebugEnabled()) {
LOG.debug(message.key(), m_throwable);
}
m_throwable = null;
m_importACEs = false;
m_resource = null;
return;
}
// apply name translation and import path
String translatedName = getRequestContext().addSiteRoot(
CmsStringUtil.joinPaths(m_parameters.getDestinationPath(), m_destination));
boolean resourceImmutable = checkImmutable(translatedName);
translatedName = getRequestContext().removeSiteRoot(translatedName);
// if the resource is not immutable and not on the exclude list, import it
if (!resourceImmutable) {
// print out the information to the report
getReport().print(Messages.get().container(Messages.RPT_IMPORTING_0), I_CmsReport.FORMAT_NOTE);
getReport().print(
org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_ARGUMENT_1,
translatedName));
getReport().print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));
boolean exists = getCms().existsResource(translatedName, CmsResourceFilter.ALL);
byte[] content = null;
// get the file content
if (m_source != null) {
content = m_helper.getFileBytes(m_source);
}
int size = 0;
if (content != null) {
size = content.length;
}
setDefaultsForEmptyResourceFields();
// create a new CmsResource
CmsResource resource = createResourceObjectFromFields(translatedName, size);
if (m_resourceBuilder.getType().isFolder()
|| m_resourceIdWasNull
|| hasContentInVfsOrImport(resource)) {
// import this resource in the VFS
m_resource = getCms().importResource(
translatedName,
resource,
content,
new ArrayList<CmsProperty>(m_properties.values()));
}
if (m_resource != null) {
m_indexToStructureId.put(Integer.valueOf(m_fileCounter), m_resource.getStructureId());
}
// only set permissions if the resource did not exists or if the keep permissions flag is not set
m_importACEs = (m_resource != null) && (!exists || !m_parameters.isKeepPermissions());
if (m_resource != null) {
getReport().println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
I_CmsReport.FORMAT_OK);
if (OpenCms.getResourceManager().getResourceType(
m_resource.getTypeId()) instanceof I_CmsLinkParseable) {
// store for later use
m_parseables.add(m_resource);
}
if (LOG.isInfoEnabled()) {
LOG.info(
Messages.get().getBundle().key(
Messages.LOG_IMPORTING_4,
new Object[] {
String.valueOf(m_fileCounter),
String.valueOf(m_totalFiles),
translatedName,
m_destination}));
}
} else {
// resource import failed, since no CmsResource was created
getReport().print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
getReport().println(
org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_ARGUMENT_1,
translatedName));
if (LOG.isInfoEnabled()) {
LOG.info(
Messages.get().getBundle().key(
Messages.LOG_SKIPPING_3,
String.valueOf(m_fileCounter),
String.valueOf(m_totalFiles),
translatedName));
}
}
} else {
m_resource = null;
// skip the file import, just print out the information to the report
getReport().print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
getReport().println(
org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_ARGUMENT_1,
translatedName));
if (LOG.isInfoEnabled()) {
LOG.info(
Messages.get().getBundle().key(
Messages.LOG_SKIPPING_3,
String.valueOf(m_fileCounter),
String.valueOf(m_totalFiles),
translatedName));
}
// do not import ACEs
m_importACEs = false;
}
} catch (Exception e) {
m_resource = null;
m_importACEs = false;
getReport().println(e);
getReport().addError(e);
CmsMessageContainer message = Messages.get().container(
Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
if (LOG.isDebugEnabled()) {
LOG.debug(message.key(), e);
}
return;
}
} } | public class class_name {
public void importResource() {
m_resourceIdWasNull = false;
try {
if (m_throwable != null) {
getReport().println(m_throwable); // depends on control dependency: [if], data = [(m_throwable]
getReport().addError(m_throwable); // depends on control dependency: [if], data = [(m_throwable]
CmsMessageContainer message = Messages.get().container(
Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
if (LOG.isDebugEnabled()) {
LOG.debug(message.key(), m_throwable); // depends on control dependency: [if], data = [none]
}
m_throwable = null; // depends on control dependency: [if], data = [none]
m_importACEs = false; // depends on control dependency: [if], data = [none]
m_resource = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
// apply name translation and import path
String translatedName = getRequestContext().addSiteRoot(
CmsStringUtil.joinPaths(m_parameters.getDestinationPath(), m_destination));
boolean resourceImmutable = checkImmutable(translatedName);
translatedName = getRequestContext().removeSiteRoot(translatedName); // depends on control dependency: [try], data = [none]
// if the resource is not immutable and not on the exclude list, import it
if (!resourceImmutable) {
// print out the information to the report
getReport().print(Messages.get().container(Messages.RPT_IMPORTING_0), I_CmsReport.FORMAT_NOTE); // depends on control dependency: [if], data = [none]
getReport().print(
org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_ARGUMENT_1,
translatedName)); // depends on control dependency: [if], data = [none]
getReport().print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0)); // depends on control dependency: [if], data = [none]
boolean exists = getCms().existsResource(translatedName, CmsResourceFilter.ALL);
byte[] content = null;
// get the file content
if (m_source != null) {
content = m_helper.getFileBytes(m_source); // depends on control dependency: [if], data = [(m_source]
}
int size = 0;
if (content != null) {
size = content.length; // depends on control dependency: [if], data = [none]
}
setDefaultsForEmptyResourceFields(); // depends on control dependency: [if], data = [none]
// create a new CmsResource
CmsResource resource = createResourceObjectFromFields(translatedName, size);
if (m_resourceBuilder.getType().isFolder()
|| m_resourceIdWasNull
|| hasContentInVfsOrImport(resource)) {
// import this resource in the VFS
m_resource = getCms().importResource(
translatedName,
resource,
content,
new ArrayList<CmsProperty>(m_properties.values())); // depends on control dependency: [if], data = [none]
}
if (m_resource != null) {
m_indexToStructureId.put(Integer.valueOf(m_fileCounter), m_resource.getStructureId()); // depends on control dependency: [if], data = [none]
}
// only set permissions if the resource did not exists or if the keep permissions flag is not set
m_importACEs = (m_resource != null) && (!exists || !m_parameters.isKeepPermissions()); // depends on control dependency: [if], data = [none]
if (m_resource != null) {
getReport().println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
I_CmsReport.FORMAT_OK); // depends on control dependency: [if], data = [none]
if (OpenCms.getResourceManager().getResourceType(
m_resource.getTypeId()) instanceof I_CmsLinkParseable) {
// store for later use
m_parseables.add(m_resource); // depends on control dependency: [if], data = [none]
}
if (LOG.isInfoEnabled()) {
LOG.info(
Messages.get().getBundle().key(
Messages.LOG_IMPORTING_4,
new Object[] {
String.valueOf(m_fileCounter),
String.valueOf(m_totalFiles),
translatedName,
m_destination})); // depends on control dependency: [if], data = [none]
}
} else {
// resource import failed, since no CmsResource was created
getReport().print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE); // depends on control dependency: [if], data = [none]
getReport().println(
org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_ARGUMENT_1,
translatedName)); // depends on control dependency: [if], data = [none]
if (LOG.isInfoEnabled()) {
LOG.info(
Messages.get().getBundle().key(
Messages.LOG_SKIPPING_3,
String.valueOf(m_fileCounter),
String.valueOf(m_totalFiles),
translatedName)); // depends on control dependency: [if], data = [none]
}
}
} else {
m_resource = null; // depends on control dependency: [if], data = [none]
// skip the file import, just print out the information to the report
getReport().print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE); // depends on control dependency: [if], data = [none]
getReport().println(
org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_ARGUMENT_1,
translatedName)); // depends on control dependency: [if], data = [none]
if (LOG.isInfoEnabled()) {
LOG.info(
Messages.get().getBundle().key(
Messages.LOG_SKIPPING_3,
String.valueOf(m_fileCounter),
String.valueOf(m_totalFiles),
translatedName)); // depends on control dependency: [if], data = [none]
}
// do not import ACEs
m_importACEs = false; // depends on control dependency: [if], data = [none]
}
} catch (Exception e) {
m_resource = null;
m_importACEs = false;
getReport().println(e);
getReport().addError(e);
CmsMessageContainer message = Messages.get().container(
Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
if (LOG.isDebugEnabled()) {
LOG.debug(message.key(), e); // depends on control dependency: [if], data = [none]
}
return;
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public static void logBeforeExit(ExitLogger logger) {
try {
if (logged.compareAndSet(false, true)) {
logger.logExit();
}
} catch (Throwable ignored){
// ignored
}
} } | public class class_name {
public static void logBeforeExit(ExitLogger logger) {
try {
if (logged.compareAndSet(false, true)) {
logger.logExit(); // depends on control dependency: [if], data = [none]
}
} catch (Throwable ignored){
// ignored
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void forceLeave(String node) {
final URI uri = createURI("/force-leave/" + node);
final HTTP.Response httpResponse = HTTP.getResponse(uri.toString());
if (httpResponse.code() != 200) {
die("Unable to force leave", uri, httpResponse.code(), httpResponse.body());
}
} } | public class class_name {
public void forceLeave(String node) {
final URI uri = createURI("/force-leave/" + node);
final HTTP.Response httpResponse = HTTP.getResponse(uri.toString());
if (httpResponse.code() != 200) {
die("Unable to force leave", uri, httpResponse.code(), httpResponse.body()); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public final DRL5Expressions.expression_return expression() throws RecognitionException {
DRL5Expressions.expression_return retval = new DRL5Expressions.expression_return();
retval.start = input.LT(1);
BaseDescr left =null;
ParserRuleReturnScope right =null;
try {
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:164:5: (left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )? )
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:164:7: left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )?
{
pushFollow(FOLLOW_conditionalExpression_in_expression768);
left=conditionalExpression();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) { if( buildDescr ) { retval.result = left; } }
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:165:9: ( ( assignmentOperator )=>op= assignmentOperator right= expression )?
int alt16=2;
switch ( input.LA(1) ) {
case EQUALS_ASSIGN:
{
int LA16_1 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case PLUS_ASSIGN:
{
int LA16_2 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case MINUS_ASSIGN:
{
int LA16_3 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case MULT_ASSIGN:
{
int LA16_4 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case DIV_ASSIGN:
{
int LA16_5 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case AND_ASSIGN:
{
int LA16_6 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case OR_ASSIGN:
{
int LA16_7 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case XOR_ASSIGN:
{
int LA16_8 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case MOD_ASSIGN:
{
int LA16_9 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case LESS:
{
int LA16_10 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case GREATER:
{
int LA16_11 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
}
switch (alt16) {
case 1 :
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:165:10: ( assignmentOperator )=>op= assignmentOperator right= expression
{
pushFollow(FOLLOW_assignmentOperator_in_expression789);
assignmentOperator();
state._fsp--;
if (state.failed) return retval;
pushFollow(FOLLOW_expression_in_expression793);
right=expression();
state._fsp--;
if (state.failed) return retval;
}
break;
}
}
retval.stop = input.LT(-1);
}
catch (RecognitionException re) {
throw re;
}
finally {
// do for sure before leaving
}
return retval;
} } | public class class_name {
public final DRL5Expressions.expression_return expression() throws RecognitionException {
DRL5Expressions.expression_return retval = new DRL5Expressions.expression_return();
retval.start = input.LT(1);
BaseDescr left =null;
ParserRuleReturnScope right =null;
try {
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:164:5: (left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )? )
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:164:7: left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )?
{
pushFollow(FOLLOW_conditionalExpression_in_expression768);
left=conditionalExpression();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) { if( buildDescr ) { retval.result = left; } } // depends on control dependency: [if], data = [none]
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:165:9: ( ( assignmentOperator )=>op= assignmentOperator right= expression )?
int alt16=2;
switch ( input.LA(1) ) {
case EQUALS_ASSIGN:
{
int LA16_1 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1; // depends on control dependency: [if], data = [none]
}
}
break;
case PLUS_ASSIGN:
{
int LA16_2 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1; // depends on control dependency: [if], data = [none]
}
}
break;
case MINUS_ASSIGN:
{
int LA16_3 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case MULT_ASSIGN:
{
int LA16_4 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case DIV_ASSIGN:
{
int LA16_5 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case AND_ASSIGN:
{
int LA16_6 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case OR_ASSIGN:
{
int LA16_7 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case XOR_ASSIGN:
{
int LA16_8 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case MOD_ASSIGN:
{
int LA16_9 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case LESS:
{
int LA16_10 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
case GREATER:
{
int LA16_11 = input.LA(2);
if ( (synpred6_DRL5Expressions()) ) {
alt16=1;
}
}
break;
}
switch (alt16) {
case 1 :
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:165:10: ( assignmentOperator )=>op= assignmentOperator right= expression
{
pushFollow(FOLLOW_assignmentOperator_in_expression789);
assignmentOperator();
state._fsp--;
if (state.failed) return retval;
pushFollow(FOLLOW_expression_in_expression793);
right=expression();
state._fsp--;
if (state.failed) return retval;
}
break;
}
}
retval.stop = input.LT(-1);
}
catch (RecognitionException re) {
throw re;
}
finally {
// do for sure before leaving
}
return retval;
} } |
public class class_name {
public Attribute removeAttributeByFullName(CharSequence name) {
for (Iterator<Attribute> it = event.attributes.iterator(); it.hasNext(); ) {
Attribute attr = it.next();
if (attr.text.equals(name)) {
it.remove();
return attr;
}
}
return null;
} } | public class class_name {
public Attribute removeAttributeByFullName(CharSequence name) {
for (Iterator<Attribute> it = event.attributes.iterator(); it.hasNext(); ) {
Attribute attr = it.next();
if (attr.text.equals(name)) {
it.remove();
// depends on control dependency: [if], data = [none]
return attr;
// depends on control dependency: [if], data = [none]
}
}
return null;
} } |
public class class_name {
private Set<ConnectionKey> getStaleConnectionKeys() {
Map<ConnectionKey, StatefulRedisConnection<K, V>> map = new ConcurrentHashMap<>();
connectionProvider.forEach(map::put);
Set<ConnectionKey> stale = new HashSet<>();
for (ConnectionKey connectionKey : map.keySet()) {
if (connectionKey.host != null && findNodeByHostAndPort(knownNodes, connectionKey.host, connectionKey.port) != null) {
continue;
}
stale.add(connectionKey);
}
return stale;
} } | public class class_name {
private Set<ConnectionKey> getStaleConnectionKeys() {
Map<ConnectionKey, StatefulRedisConnection<K, V>> map = new ConcurrentHashMap<>();
connectionProvider.forEach(map::put);
Set<ConnectionKey> stale = new HashSet<>();
for (ConnectionKey connectionKey : map.keySet()) {
if (connectionKey.host != null && findNodeByHostAndPort(knownNodes, connectionKey.host, connectionKey.port) != null) {
continue;
}
stale.add(connectionKey); // depends on control dependency: [for], data = [connectionKey]
}
return stale;
} } |
public class class_name {
@Override
public EEnum getIfcCoolingTowerTypeEnum() {
if (ifcCoolingTowerTypeEnumEEnum == null) {
ifcCoolingTowerTypeEnumEEnum = (EEnum) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(948);
}
return ifcCoolingTowerTypeEnumEEnum;
} } | public class class_name {
@Override
public EEnum getIfcCoolingTowerTypeEnum() {
if (ifcCoolingTowerTypeEnumEEnum == null) {
ifcCoolingTowerTypeEnumEEnum = (EEnum) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(948);
// depends on control dependency: [if], data = [none]
}
return ifcCoolingTowerTypeEnumEEnum;
} } |
public class class_name {
public static String getResourceFolderPath(ResourceType type) {
String cachePath = getSystemConfiguration().getCacheDirectory()
.getAbsolutePath();
File cacheDir = new File(cachePath);
if (!cacheDir.exists()) {
throw new IllegalStateException(
"The system configuration's cache directory - "
+ cacheDir.getAbsolutePath() + " - does not exist.");
}
if (!cacheDir.canRead()) {
throw new IllegalStateException(
"The system configuration's cache directory - "
+ cacheDir.getAbsolutePath()
+ " - is not readable.");
}
if (!cacheDir.canWrite()) {
throw new IllegalStateException(
"The system configuration's cache directory - "
+ cacheDir.getAbsolutePath()
+ " - is not writable.");
}
StringBuilder resourceFolderPath = new StringBuilder();
resourceFolderPath.append(cachePath);
if (!cachePath.endsWith("/")) {
resourceFolderPath.append(File.separator);
}
resourceFolderPath.append(type.getResourceFolderName());
return resourceFolderPath.toString();
} } | public class class_name {
public static String getResourceFolderPath(ResourceType type) {
String cachePath = getSystemConfiguration().getCacheDirectory()
.getAbsolutePath();
File cacheDir = new File(cachePath);
if (!cacheDir.exists()) {
throw new IllegalStateException(
"The system configuration's cache directory - "
+ cacheDir.getAbsolutePath() + " - does not exist.");
}
if (!cacheDir.canRead()) {
throw new IllegalStateException(
"The system configuration's cache directory - "
+ cacheDir.getAbsolutePath()
+ " - is not readable.");
}
if (!cacheDir.canWrite()) {
throw new IllegalStateException(
"The system configuration's cache directory - "
+ cacheDir.getAbsolutePath()
+ " - is not writable.");
}
StringBuilder resourceFolderPath = new StringBuilder();
resourceFolderPath.append(cachePath);
if (!cachePath.endsWith("/")) {
resourceFolderPath.append(File.separator); // depends on control dependency: [if], data = [none]
}
resourceFolderPath.append(type.getResourceFolderName());
return resourceFolderPath.toString();
} } |
public class class_name {
public static double maxAbsolute(FlatDataCollection flatDataCollection) {
double maxAbs=0.0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double v = it.next();
if(v != null) {
maxAbs= Math.max(maxAbs, Math.abs(v));
}
}
return maxAbs;
} } | public class class_name {
public static double maxAbsolute(FlatDataCollection flatDataCollection) {
double maxAbs=0.0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double v = it.next();
if(v != null) {
maxAbs= Math.max(maxAbs, Math.abs(v)); // depends on control dependency: [if], data = [(v]
}
}
return maxAbs;
} } |
public class class_name {
public LdapEntry getEntityByIdentifier(String dn, String extId, String uniqueName, List<String> inEntityTypes,
List<String> propNames, boolean getMbrshipAttr, boolean getMbrAttr) throws WIMException {
String[] attrIds = iLdapConfigMgr.getAttributeNames(inEntityTypes, propNames, getMbrshipAttr, getMbrAttr);
Attributes attrs = null;
if (dn == null && !iLdapConfigMgr.needTranslateRDN()) {
dn = iLdapConfigMgr.switchToLdapNode(uniqueName);
}
// Changed the order of the if-else ladder. Please check against tWAS code for the original order
if (dn != null) {
attrs = checkAttributesCache(dn, attrIds);
} else if (extId != null) {
if (iLdapConfigMgr.isAnyExtIdDN()) {
dn = LdapHelper.getValidDN(extId);
if (dn != null) {
attrs = checkAttributesCache(dn, attrIds);
} else if (uniqueName != null) {
attrs = getAttributesByUniqueName(uniqueName, attrIds, inEntityTypes);
dn = LdapHelper.getDNFromAttributes(attrs);
} else {
String msg = Tr.formatMessage(tc, WIMMessageKey.ENTITY_NOT_FOUND, WIMMessageHelper.generateMsgParms(null));
throw new EntityNotFoundException(WIMMessageKey.ENTITY_NOT_FOUND, msg);
}
} else {
attrs = getAttributesByUniqueName(extId, attrIds, inEntityTypes);
dn = LdapHelper.getDNFromAttributes(attrs);
}
} else if (uniqueName != null) {
attrs = getAttributesByUniqueName(uniqueName, attrIds, inEntityTypes);
dn = LdapHelper.getDNFromAttributes(attrs);
} else {
String msg = Tr.formatMessage(tc, WIMMessageKey.ENTITY_NOT_FOUND, WIMMessageHelper.generateMsgParms(null));
throw new EntityNotFoundException(WIMMessageKey.ENTITY_NOT_FOUND, msg);
}
String entityType = iLdapConfigMgr.getEntityType(attrs, uniqueName, dn, extId, inEntityTypes);
uniqueName = getUniqueName(dn, entityType, attrs);
if (extId == null) {
extId = iLdapConfigMgr.getExtIdFromAttributes(dn, entityType, attrs);
}
LdapEntry ldapEntry = new LdapEntry(dn, extId, uniqueName, entityType, attrs);
return ldapEntry;
} } | public class class_name {
public LdapEntry getEntityByIdentifier(String dn, String extId, String uniqueName, List<String> inEntityTypes,
List<String> propNames, boolean getMbrshipAttr, boolean getMbrAttr) throws WIMException {
String[] attrIds = iLdapConfigMgr.getAttributeNames(inEntityTypes, propNames, getMbrshipAttr, getMbrAttr);
Attributes attrs = null;
if (dn == null && !iLdapConfigMgr.needTranslateRDN()) {
dn = iLdapConfigMgr.switchToLdapNode(uniqueName);
}
// Changed the order of the if-else ladder. Please check against tWAS code for the original order
if (dn != null) {
attrs = checkAttributesCache(dn, attrIds);
} else if (extId != null) {
if (iLdapConfigMgr.isAnyExtIdDN()) {
dn = LdapHelper.getValidDN(extId); // depends on control dependency: [if], data = [none]
if (dn != null) {
attrs = checkAttributesCache(dn, attrIds); // depends on control dependency: [if], data = [(dn]
} else if (uniqueName != null) {
attrs = getAttributesByUniqueName(uniqueName, attrIds, inEntityTypes); // depends on control dependency: [if], data = [(uniqueName]
dn = LdapHelper.getDNFromAttributes(attrs); // depends on control dependency: [if], data = [none]
} else {
String msg = Tr.formatMessage(tc, WIMMessageKey.ENTITY_NOT_FOUND, WIMMessageHelper.generateMsgParms(null));
throw new EntityNotFoundException(WIMMessageKey.ENTITY_NOT_FOUND, msg);
}
} else {
attrs = getAttributesByUniqueName(extId, attrIds, inEntityTypes); // depends on control dependency: [if], data = [none]
dn = LdapHelper.getDNFromAttributes(attrs); // depends on control dependency: [if], data = [none]
}
} else if (uniqueName != null) {
attrs = getAttributesByUniqueName(uniqueName, attrIds, inEntityTypes);
dn = LdapHelper.getDNFromAttributes(attrs);
} else {
String msg = Tr.formatMessage(tc, WIMMessageKey.ENTITY_NOT_FOUND, WIMMessageHelper.generateMsgParms(null));
throw new EntityNotFoundException(WIMMessageKey.ENTITY_NOT_FOUND, msg);
}
String entityType = iLdapConfigMgr.getEntityType(attrs, uniqueName, dn, extId, inEntityTypes);
uniqueName = getUniqueName(dn, entityType, attrs);
if (extId == null) {
extId = iLdapConfigMgr.getExtIdFromAttributes(dn, entityType, attrs);
}
LdapEntry ldapEntry = new LdapEntry(dn, extId, uniqueName, entityType, attrs);
return ldapEntry;
} } |
public class class_name {
private ThymeleafTemplater getOrCreateTemplater()
{
ThymeleafTemplater templater = this.templater.get();
// Lazy-create a ThymeleafTemplater
if (templater == null)
{
final TemplateEngine engine = getOrCreateEngine();
templater = new ThymeleafTemplater(engine, configuration, metrics, userProvider);
templater.set("coreRestPrefix", coreRestPrefix);
templater.set("coreRestEndpoint", coreRestEndpoint.toString());
templater.set("coreServices", services);
templater.set("currentUser", new ThymeleafCurrentUserUtils(userProvider));
this.templater = new WeakReference<>(templater);
}
return templater;
} } | public class class_name {
private ThymeleafTemplater getOrCreateTemplater()
{
ThymeleafTemplater templater = this.templater.get();
// Lazy-create a ThymeleafTemplater
if (templater == null)
{
final TemplateEngine engine = getOrCreateEngine();
templater = new ThymeleafTemplater(engine, configuration, metrics, userProvider); // depends on control dependency: [if], data = [none]
templater.set("coreRestPrefix", coreRestPrefix); // depends on control dependency: [if], data = [none]
templater.set("coreRestEndpoint", coreRestEndpoint.toString()); // depends on control dependency: [if], data = [none]
templater.set("coreServices", services); // depends on control dependency: [if], data = [none]
templater.set("currentUser", new ThymeleafCurrentUserUtils(userProvider)); // depends on control dependency: [if], data = [none]
this.templater = new WeakReference<>(templater); // depends on control dependency: [if], data = [(templater]
}
return templater;
} } |
public class class_name {
public final void destroy() {
if (doneUpdater.compareAndSet(this, 0, 1)) try {
preDestroy();
final Object instance = getInstance();
if (instance != null) {
final InterceptorContext interceptorContext = prepareInterceptorContext();
interceptorContext.setTarget(instance);
interceptorContext.putPrivateData(InvocationType.class, InvocationType.PRE_DESTROY);
preDestroy.processInvocation(interceptorContext);
}
} catch (Exception e) {
ROOT_LOGGER.componentDestroyFailure(e, this);
} finally {
component.finishDestroy();
}
} } | public class class_name {
public final void destroy() {
if (doneUpdater.compareAndSet(this, 0, 1)) try {
preDestroy(); // depends on control dependency: [try], data = [none]
final Object instance = getInstance();
if (instance != null) {
final InterceptorContext interceptorContext = prepareInterceptorContext();
interceptorContext.setTarget(instance); // depends on control dependency: [if], data = [(instance]
interceptorContext.putPrivateData(InvocationType.class, InvocationType.PRE_DESTROY); // depends on control dependency: [if], data = [none]
preDestroy.processInvocation(interceptorContext); // depends on control dependency: [if], data = [none]
}
} catch (Exception e) {
ROOT_LOGGER.componentDestroyFailure(e, this);
} finally { // depends on control dependency: [catch], data = [none]
component.finishDestroy();
}
} } |
public class class_name {
@Operation(name = JpaConstants.OPERATION_GET_RESOURCE_COUNTS, idempotent = true, returnParameters = {
@OperationParam(name = "AllergyIntolerance", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Appointment", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "AppointmentResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "AuditEvent", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Basic", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Binary", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "BodySite", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Bundle", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "CarePlan", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "CarePlan2", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Claim", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ClaimResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ClinicalImpression", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Communication", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "CommunicationRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Composition", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ConceptMap", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Condition", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Conformance", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Contract", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Contraindication", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Coverage", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DataElement", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Device", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DeviceComponent", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DeviceMetric", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DeviceUseRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DeviceUseStatement", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DiagnosticOrder", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DiagnosticReport", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DocumentManifest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DocumentReference", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "EligibilityRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "EligibilityResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Encounter", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "EnrollmentRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "EnrollmentResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "EpisodeOfCare", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ExplanationOfBenefit", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "FamilyMemberHistory", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Flag", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Goal", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Group", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "HealthcareService", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ImagingObjectSelection", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ImagingStudy", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Immunization", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ImmunizationRecommendation", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ListResource", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Location", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Media", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Medication", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "MedicationAdministration", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "MedicationDispense", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "MedicationPrescription", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "MedicationStatement", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "MessageHeader", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "NamingSystem", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "NutritionOrder", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Observation", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "OperationDefinition", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "OperationOutcome", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Order", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "OrderResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Organization", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Parameters", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Patient", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "PaymentNotice", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "PaymentReconciliation", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Person", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Practitioner", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Procedure", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ProcedureRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ProcessRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ProcessResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Provenance", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Questionnaire", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "QuestionnaireAnswers", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ReferralRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "RelatedPerson", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "RiskAssessment", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Schedule", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "SearchParameter", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Slot", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Specimen", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "StructureDefinition", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Subscription", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Substance", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Supply", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ValueSet", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "VisionPrescription", type = IntegerDt.class, min = 0, max = 1)
})
@Description(shortDefinition = "Provides the number of resources currently stored on the server, broken down by resource type")
//@formatter:on
public Parameters getResourceCounts() {
Parameters retVal = new Parameters();
Map<String, Long> counts = mySystemDao.getResourceCountsFromCache();
counts = defaultIfNull(counts, Collections.emptyMap());
counts = new TreeMap<>(counts);
for (Entry<String, Long> nextEntry : counts.entrySet()) {
retVal.addParameter().setName(new StringDt(nextEntry.getKey())).setValue(new IntegerDt(nextEntry.getValue().intValue()));
}
return retVal;
} } | public class class_name {
@Operation(name = JpaConstants.OPERATION_GET_RESOURCE_COUNTS, idempotent = true, returnParameters = {
@OperationParam(name = "AllergyIntolerance", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Appointment", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "AppointmentResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "AuditEvent", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Basic", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Binary", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "BodySite", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Bundle", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "CarePlan", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "CarePlan2", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Claim", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ClaimResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ClinicalImpression", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Communication", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "CommunicationRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Composition", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ConceptMap", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Condition", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Conformance", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Contract", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Contraindication", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Coverage", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DataElement", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Device", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DeviceComponent", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DeviceMetric", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DeviceUseRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DeviceUseStatement", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DiagnosticOrder", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DiagnosticReport", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DocumentManifest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "DocumentReference", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "EligibilityRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "EligibilityResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Encounter", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "EnrollmentRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "EnrollmentResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "EpisodeOfCare", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ExplanationOfBenefit", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "FamilyMemberHistory", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Flag", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Goal", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Group", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "HealthcareService", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ImagingObjectSelection", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ImagingStudy", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Immunization", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ImmunizationRecommendation", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ListResource", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Location", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Media", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Medication", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "MedicationAdministration", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "MedicationDispense", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "MedicationPrescription", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "MedicationStatement", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "MessageHeader", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "NamingSystem", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "NutritionOrder", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Observation", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "OperationDefinition", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "OperationOutcome", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Order", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "OrderResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Organization", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Parameters", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Patient", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "PaymentNotice", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "PaymentReconciliation", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Person", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Practitioner", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Procedure", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ProcedureRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ProcessRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ProcessResponse", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Provenance", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Questionnaire", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "QuestionnaireAnswers", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ReferralRequest", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "RelatedPerson", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "RiskAssessment", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Schedule", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "SearchParameter", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Slot", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Specimen", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "StructureDefinition", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Subscription", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Substance", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "Supply", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "ValueSet", type = IntegerDt.class, min = 0, max = 1),
@OperationParam(name = "VisionPrescription", type = IntegerDt.class, min = 0, max = 1)
})
@Description(shortDefinition = "Provides the number of resources currently stored on the server, broken down by resource type")
//@formatter:on
public Parameters getResourceCounts() {
Parameters retVal = new Parameters();
Map<String, Long> counts = mySystemDao.getResourceCountsFromCache();
counts = defaultIfNull(counts, Collections.emptyMap());
counts = new TreeMap<>(counts);
for (Entry<String, Long> nextEntry : counts.entrySet()) {
retVal.addParameter().setName(new StringDt(nextEntry.getKey())).setValue(new IntegerDt(nextEntry.getValue().intValue())); // depends on control dependency: [for], data = [nextEntry]
}
return retVal;
} } |
public class class_name {
public EpollSocketChannelConfig setTcpQuickAck(boolean quickAck) {
try {
((EpollSocketChannel) channel).socket.setTcpQuickAck(quickAck);
return this;
} catch (IOException e) {
throw new ChannelException(e);
}
} } | public class class_name {
public EpollSocketChannelConfig setTcpQuickAck(boolean quickAck) {
try {
((EpollSocketChannel) channel).socket.setTcpQuickAck(quickAck); // depends on control dependency: [try], data = [none]
return this; // depends on control dependency: [try], data = [none]
} catch (IOException e) {
throw new ChannelException(e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void onClose()
{
RuntimeException ce = null;
for (final Agent agent : agents)
{
try
{
agent.onClose();
}
catch (final Exception ex)
{
if (ce == null)
{
ce = new RuntimeException(getClass().getName() + ": underlying agent error on close");
}
ce.addSuppressed(ex);
}
}
if (ce != null)
{
throw ce;
}
} } | public class class_name {
public void onClose()
{
RuntimeException ce = null;
for (final Agent agent : agents)
{
try
{
agent.onClose(); // depends on control dependency: [try], data = [none]
}
catch (final Exception ex)
{
if (ce == null)
{
ce = new RuntimeException(getClass().getName() + ": underlying agent error on close"); // depends on control dependency: [if], data = [none]
}
ce.addSuppressed(ex);
} // depends on control dependency: [catch], data = [none]
}
if (ce != null)
{
throw ce;
}
} } |
public class class_name {
public ICondition getEffectiveCondition()
{
if( effCondition_ == null)
{
effCondition_ = getValueDef().getEffectiveCondition( getVarDef().getEffectiveCondition());
}
return effCondition_;
} } | public class class_name {
public ICondition getEffectiveCondition()
{
if( effCondition_ == null)
{
effCondition_ = getValueDef().getEffectiveCondition( getVarDef().getEffectiveCondition()); // depends on control dependency: [if], data = [none]
}
return effCondition_;
} } |
public class class_name {
@Override
public InputStream getResourceAsStream(final String name)
{
InputStream is = null;
if (parent != null)
{
is = parent.getResourceAsStream(name);
}
return (is == null) ? delegate.getResourceAsStream(name) : is;
} } | public class class_name {
@Override
public InputStream getResourceAsStream(final String name)
{
InputStream is = null;
if (parent != null)
{
is = parent.getResourceAsStream(name); // depends on control dependency: [if], data = [none]
}
return (is == null) ? delegate.getResourceAsStream(name) : is;
} } |
public class class_name {
public static synchronized JingleSession getInstanceFor(XMPPConnection con) {
if (con == null) {
throw new IllegalArgumentException("XMPPConnection cannot be null");
}
JingleSession result = null;
synchronized (sessions) {
if (sessions.containsKey(con)) {
result = sessions.get(con);
}
}
return result;
} } | public class class_name {
public static synchronized JingleSession getInstanceFor(XMPPConnection con) {
if (con == null) {
throw new IllegalArgumentException("XMPPConnection cannot be null");
}
JingleSession result = null;
synchronized (sessions) {
if (sessions.containsKey(con)) {
result = sessions.get(con); // depends on control dependency: [if], data = [none]
}
}
return result;
} } |
public class class_name {
public void parseConllFileNoParallel(String inputFile, String outputFile, boolean rootFirst, int beamWidth, boolean labeled, boolean lowerCased, int numOfThreads, boolean partial, String scorePath) throws IOException, ExecutionException, InterruptedException
{
CoNLLReader reader = new CoNLLReader(inputFile);
boolean addScore = false;
if (scorePath.trim().length() > 0)
addScore = true;
ArrayList<Float> scoreList = new ArrayList<Float>();
long start = System.currentTimeMillis();
int allArcs = 0;
int size = 0;
BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile + ".tmp"));
int dataCount = 0;
while (true)
{
ArrayList<Instance> data = reader.readData(15000, true, labeled, rootFirst, lowerCased, maps);
size += data.size();
if (data.size() == 0)
break;
for (Instance instance : data)
{
dataCount++;
if (dataCount % 100 == 0)
System.err.print(dataCount + " ... ");
Configuration bestParse;
if (partial)
bestParse = parsePartial(instance, instance.getSentence(), rootFirst, beamWidth, numOfThreads);
else bestParse = parse(instance.getSentence(), rootFirst, beamWidth, numOfThreads);
int[] words = instance.getSentence().getWords();
allArcs += words.length - 1;
if (addScore)
scoreList.add(bestParse.score / bestParse.sentence.size());
writeParsedSentence(writer, rootFirst, bestParse, words);
}
}
// System.err.print("\n");
long end = System.currentTimeMillis();
float each = (1.0f * (end - start)) / size;
float eacharc = (1.0f * (end - start)) / allArcs;
writer.flush();
writer.close();
// DecimalFormat format = new DecimalFormat("##.00");
//
// System.err.print(format.format(eacharc) + " ms for each arc!\n");
// System.err.print(format.format(each) + " ms for each sentence!\n\n");
BufferedReader gReader = new BufferedReader(new FileReader(inputFile));
BufferedReader pReader = new BufferedReader(new FileReader(outputFile + ".tmp"));
BufferedWriter pwriter = new BufferedWriter(new FileWriter(outputFile));
String line;
while ((line = pReader.readLine()) != null)
{
String gLine = gReader.readLine();
if (line.trim().length() > 0)
{
while (gLine.trim().length() == 0)
gLine = gReader.readLine();
String[] ps = line.split("\t");
String[] gs = gLine.split("\t");
gs[6] = ps[0];
gs[7] = ps[1];
StringBuilder output = new StringBuilder();
for (int i = 0; i < gs.length; i++)
{
output.append(gs[i]).append("\t");
}
pwriter.write(output.toString().trim() + "\n");
}
else
{
pwriter.write("\n");
}
}
pwriter.flush();
pwriter.close();
if (addScore)
{
BufferedWriter scoreWriter = new BufferedWriter(new FileWriter(scorePath));
for (int i = 0; i < scoreList.size(); i++)
scoreWriter.write(scoreList.get(i) + "\n");
scoreWriter.flush();
scoreWriter.close();
}
IOUtil.deleteFile(outputFile + ".tmp");
} } | public class class_name {
public void parseConllFileNoParallel(String inputFile, String outputFile, boolean rootFirst, int beamWidth, boolean labeled, boolean lowerCased, int numOfThreads, boolean partial, String scorePath) throws IOException, ExecutionException, InterruptedException
{
CoNLLReader reader = new CoNLLReader(inputFile);
boolean addScore = false;
if (scorePath.trim().length() > 0)
addScore = true;
ArrayList<Float> scoreList = new ArrayList<Float>();
long start = System.currentTimeMillis();
int allArcs = 0;
int size = 0;
BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile + ".tmp"));
int dataCount = 0;
while (true)
{
ArrayList<Instance> data = reader.readData(15000, true, labeled, rootFirst, lowerCased, maps);
size += data.size();
if (data.size() == 0)
break;
for (Instance instance : data)
{
dataCount++; // depends on control dependency: [for], data = [none]
if (dataCount % 100 == 0)
System.err.print(dataCount + " ... ");
Configuration bestParse;
if (partial)
bestParse = parsePartial(instance, instance.getSentence(), rootFirst, beamWidth, numOfThreads);
else bestParse = parse(instance.getSentence(), rootFirst, beamWidth, numOfThreads);
int[] words = instance.getSentence().getWords();
allArcs += words.length - 1; // depends on control dependency: [for], data = [none]
if (addScore)
scoreList.add(bestParse.score / bestParse.sentence.size());
writeParsedSentence(writer, rootFirst, bestParse, words); // depends on control dependency: [for], data = [none]
}
}
// System.err.print("\n");
long end = System.currentTimeMillis();
float each = (1.0f * (end - start)) / size;
float eacharc = (1.0f * (end - start)) / allArcs;
writer.flush();
writer.close();
// DecimalFormat format = new DecimalFormat("##.00");
//
// System.err.print(format.format(eacharc) + " ms for each arc!\n");
// System.err.print(format.format(each) + " ms for each sentence!\n\n");
BufferedReader gReader = new BufferedReader(new FileReader(inputFile));
BufferedReader pReader = new BufferedReader(new FileReader(outputFile + ".tmp"));
BufferedWriter pwriter = new BufferedWriter(new FileWriter(outputFile));
String line;
while ((line = pReader.readLine()) != null)
{
String gLine = gReader.readLine();
if (line.trim().length() > 0)
{
while (gLine.trim().length() == 0)
gLine = gReader.readLine();
String[] ps = line.split("\t");
String[] gs = gLine.split("\t");
gs[6] = ps[0]; // depends on control dependency: [if], data = [none]
gs[7] = ps[1]; // depends on control dependency: [if], data = [none]
StringBuilder output = new StringBuilder();
for (int i = 0; i < gs.length; i++)
{
output.append(gs[i]).append("\t"); // depends on control dependency: [for], data = [i]
}
pwriter.write(output.toString().trim() + "\n"); // depends on control dependency: [if], data = [none]
}
else
{
pwriter.write("\n"); // depends on control dependency: [if], data = [none]
}
}
pwriter.flush();
pwriter.close();
if (addScore)
{
BufferedWriter scoreWriter = new BufferedWriter(new FileWriter(scorePath));
for (int i = 0; i < scoreList.size(); i++)
scoreWriter.write(scoreList.get(i) + "\n");
scoreWriter.flush();
scoreWriter.close();
}
IOUtil.deleteFile(outputFile + ".tmp");
} } |
public class class_name {
public Cluster withApplications(Application... applications) {
if (this.applications == null) {
setApplications(new com.amazonaws.internal.SdkInternalList<Application>(applications.length));
}
for (Application ele : applications) {
this.applications.add(ele);
}
return this;
} } | public class class_name {
public Cluster withApplications(Application... applications) {
if (this.applications == null) {
setApplications(new com.amazonaws.internal.SdkInternalList<Application>(applications.length)); // depends on control dependency: [if], data = [none]
}
for (Application ele : applications) {
this.applications.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
protected void configureNavi (FlexTable controls, int row, int col,
int start, int limit, int total)
{
HorizontalPanel panel = new HorizontalPanel();
panel.add(new Label("Page:")); // TODO: i18n
// determine which pages we want to show
int page = 1+start/_resultsPerPage;
int pages;
if (total < 0) {
pages = page + 1;
} else {
pages = total/_resultsPerPage + (total%_resultsPerPage == 0 ? 0 : 1);
}
List<Integer> shown = new ArrayList<Integer>();
shown.add(1);
for (int ii = Math.max(2, Math.min(page-2, pages-5));
ii <= Math.min(pages-1, Math.max(page+2, 6)); ii++) {
shown.add(ii);
}
if (pages != 1) {
shown.add(pages);
}
// now display those as "Page: _1_ ... _3_ _4_ 5 _6_ _7_ ... _10_"
int ppage = 0;
for (Integer cpage : shown) {
if (cpage - ppage > 1) {
panel.add(createPageLabel("...", null));
}
if (cpage == page) {
panel.add(createPageLabel(""+page, "Current"));
} else {
panel.add(createPageLinkLabel(cpage));
}
ppage = cpage;
}
if (total < 0) {
panel.add(createPageLabel("...", null));
}
controls.setWidget(row, col, panel);
controls.getFlexCellFormatter().setHorizontalAlignment(row, col, HasAlignment.ALIGN_CENTER);
} } | public class class_name {
protected void configureNavi (FlexTable controls, int row, int col,
int start, int limit, int total)
{
HorizontalPanel panel = new HorizontalPanel();
panel.add(new Label("Page:")); // TODO: i18n
// determine which pages we want to show
int page = 1+start/_resultsPerPage;
int pages;
if (total < 0) {
pages = page + 1; // depends on control dependency: [if], data = [none]
} else {
pages = total/_resultsPerPage + (total%_resultsPerPage == 0 ? 0 : 1); // depends on control dependency: [if], data = [(total]
}
List<Integer> shown = new ArrayList<Integer>();
shown.add(1);
for (int ii = Math.max(2, Math.min(page-2, pages-5));
ii <= Math.min(pages-1, Math.max(page+2, 6)); ii++) {
shown.add(ii); // depends on control dependency: [for], data = [ii]
}
if (pages != 1) {
shown.add(pages); // depends on control dependency: [if], data = [(pages]
}
// now display those as "Page: _1_ ... _3_ _4_ 5 _6_ _7_ ... _10_"
int ppage = 0;
for (Integer cpage : shown) {
if (cpage - ppage > 1) {
panel.add(createPageLabel("...", null)); // depends on control dependency: [if], data = [none]
}
if (cpage == page) {
panel.add(createPageLabel(""+page, "Current")); // depends on control dependency: [if], data = [none]
} else {
panel.add(createPageLinkLabel(cpage)); // depends on control dependency: [if], data = [(cpage]
}
ppage = cpage; // depends on control dependency: [for], data = [cpage]
}
if (total < 0) {
panel.add(createPageLabel("...", null)); // depends on control dependency: [if], data = [none]
}
controls.setWidget(row, col, panel);
controls.getFlexCellFormatter().setHorizontalAlignment(row, col, HasAlignment.ALIGN_CENTER);
} } |
public class class_name {
@Override
protected boolean doHandleRequest(final Request request) {
FileItemWrap value = getRequestValue(request);
FileItemWrap current = getValue();
boolean changed = value != null || current != null;
if (changed) {
// Reset validation fields
resetValidationState();
// if User Model exists it will be returned, othewise Shared Model is returned
final FileWidgetModel sharedModel = getComponentModel();
// if fileType is supplied then validate it
if (hasFileTypes()) {
boolean validFileType = FileUtil.validateFileType(value, getFileTypes());
// If invalid only then update
if (sharedModel.validFileType != validFileType) {
// if User Model exists it will be returned, othewise it will be created
final FileWidgetModel userModel = getOrCreateComponentModel();
userModel.validFileType = validFileType;
}
}
// if fileSize is supplied then validate it
if (hasMaxFileSize()) {
boolean validFileSize = FileUtil.validateFileSize(value, getMaxFileSize());
// If invalid only then update
if (sharedModel.validFileSize != validFileSize) {
// if User Model exists it will be returned, othewise it will be created
final FileWidgetModel userModel = getOrCreateComponentModel();
userModel.validFileSize = validFileSize;
}
}
// if file is valid, the update data
if (isFileSizeValid() && isFileTypeValid()) {
setData(value);
} else if (current == null) {
// otherwise no change
changed = false;
} else {
changed = true;
setData(null);
}
}
return changed;
} } | public class class_name {
@Override
protected boolean doHandleRequest(final Request request) {
FileItemWrap value = getRequestValue(request);
FileItemWrap current = getValue();
boolean changed = value != null || current != null;
if (changed) {
// Reset validation fields
resetValidationState(); // depends on control dependency: [if], data = [none]
// if User Model exists it will be returned, othewise Shared Model is returned
final FileWidgetModel sharedModel = getComponentModel();
// if fileType is supplied then validate it
if (hasFileTypes()) {
boolean validFileType = FileUtil.validateFileType(value, getFileTypes());
// If invalid only then update
if (sharedModel.validFileType != validFileType) {
// if User Model exists it will be returned, othewise it will be created
final FileWidgetModel userModel = getOrCreateComponentModel();
userModel.validFileType = validFileType; // depends on control dependency: [if], data = [none]
}
}
// if fileSize is supplied then validate it
if (hasMaxFileSize()) {
boolean validFileSize = FileUtil.validateFileSize(value, getMaxFileSize());
// If invalid only then update
if (sharedModel.validFileSize != validFileSize) {
// if User Model exists it will be returned, othewise it will be created
final FileWidgetModel userModel = getOrCreateComponentModel();
userModel.validFileSize = validFileSize; // depends on control dependency: [if], data = [none]
}
}
// if file is valid, the update data
if (isFileSizeValid() && isFileTypeValid()) {
setData(value); // depends on control dependency: [if], data = [none]
} else if (current == null) {
// otherwise no change
changed = false; // depends on control dependency: [if], data = [none]
} else {
changed = true; // depends on control dependency: [if], data = [none]
setData(null); // depends on control dependency: [if], data = [null)]
}
}
return changed;
} } |
public class class_name {
public static String getRelativePath(File file, File folder) {
String filePath = file.getAbsolutePath();
String folderPath = folder.getAbsolutePath();
if (filePath.startsWith(folderPath)) {
return filePath.substring(folderPath.length() + 1);
} else {
return null;
}
} } | public class class_name {
public static String getRelativePath(File file, File folder) {
String filePath = file.getAbsolutePath();
String folderPath = folder.getAbsolutePath();
if (filePath.startsWith(folderPath)) {
return filePath.substring(folderPath.length() + 1); // depends on control dependency: [if], data = [none]
} else {
return null; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public int getSize() {
int dataSize = size;
for (int i = 0; i < getChildCount(); i++) {
dataSize += ((ObjectGraphNode) getChildAt(i)).getSize();
}
return dataSize;
} } | public class class_name {
public int getSize() {
int dataSize = size;
for (int i = 0; i < getChildCount(); i++) {
dataSize += ((ObjectGraphNode) getChildAt(i)).getSize(); // depends on control dependency: [for], data = [i]
}
return dataSize;
} } |
public class class_name {
public static void quickSort(double[] array, int[] idx, int from, int to) {
if (from < to) {
double temp = array[to];
int tempIdx = idx[to];
int i = from - 1;
for (int j = from; j < to; j++) {
if (array[j] <= temp) {
i++;
double tempValue = array[j];
array[j] = array[i];
array[i] = tempValue;
int tempIndex = idx[j];
idx[j] = idx[i];
idx[i] = tempIndex;
}
}
array[to] = array[i + 1];
array[i + 1] = temp;
idx[to] = idx[i + 1];
idx[i + 1] = tempIdx;
quickSort(array, idx, from, i);
quickSort(array, idx, i + 1, to);
}
} } | public class class_name {
public static void quickSort(double[] array, int[] idx, int from, int to) {
if (from < to) {
double temp = array[to];
int tempIdx = idx[to];
int i = from - 1;
for (int j = from; j < to; j++) {
if (array[j] <= temp) {
i++; // depends on control dependency: [if], data = [none]
double tempValue = array[j];
array[j] = array[i]; // depends on control dependency: [if], data = [none]
array[i] = tempValue; // depends on control dependency: [if], data = [none]
int tempIndex = idx[j];
idx[j] = idx[i]; // depends on control dependency: [if], data = [none]
idx[i] = tempIndex; // depends on control dependency: [if], data = [none]
}
}
array[to] = array[i + 1]; // depends on control dependency: [if], data = [none]
array[i + 1] = temp; // depends on control dependency: [if], data = [none]
idx[to] = idx[i + 1]; // depends on control dependency: [if], data = [none]
idx[i + 1] = tempIdx; // depends on control dependency: [if], data = [none]
quickSort(array, idx, from, i); // depends on control dependency: [if], data = [none]
quickSort(array, idx, i + 1, to); // depends on control dependency: [if], data = [to)]
}
} } |
public class class_name {
@Override
public List<Object> getContextValues(final String label) {
final List<Object> values = new ArrayList<>();
for (final Pair<String, Object> pair : contextValues) {
if (StringUtils.equals(label, pair.getKey())) {
values.add(pair.getValue());
}
}
return values;
} } | public class class_name {
@Override
public List<Object> getContextValues(final String label) {
final List<Object> values = new ArrayList<>();
for (final Pair<String, Object> pair : contextValues) {
if (StringUtils.equals(label, pair.getKey())) {
values.add(pair.getValue()); // depends on control dependency: [if], data = [none]
}
}
return values;
} } |
public class class_name {
protected void notifyTransformListeners(Decision decision, DmnDecision dmnDecision) {
for (DmnTransformListener transformListener : transformListeners) {
transformListener.transformDecision(decision, dmnDecision);
}
} } | public class class_name {
protected void notifyTransformListeners(Decision decision, DmnDecision dmnDecision) {
for (DmnTransformListener transformListener : transformListeners) {
transformListener.transformDecision(decision, dmnDecision); // depends on control dependency: [for], data = [transformListener]
}
} } |
public class class_name {
public static Deque<SentryException> extractExceptionQueue(Throwable throwable) {
Deque<SentryException> exceptions = new ArrayDeque<>();
Set<Throwable> circularityDetector = new HashSet<>();
StackTraceElement[] childExceptionStackTrace = new StackTraceElement[0];
//Stack the exceptions to send them in the reverse order
while (throwable != null && circularityDetector.add(throwable)) {
exceptions.add(new SentryException(throwable, childExceptionStackTrace));
childExceptionStackTrace = throwable.getStackTrace();
throwable = throwable.getCause();
}
return exceptions;
} } | public class class_name {
public static Deque<SentryException> extractExceptionQueue(Throwable throwable) {
Deque<SentryException> exceptions = new ArrayDeque<>();
Set<Throwable> circularityDetector = new HashSet<>();
StackTraceElement[] childExceptionStackTrace = new StackTraceElement[0];
//Stack the exceptions to send them in the reverse order
while (throwable != null && circularityDetector.add(throwable)) {
exceptions.add(new SentryException(throwable, childExceptionStackTrace)); // depends on control dependency: [while], data = [(throwable]
childExceptionStackTrace = throwable.getStackTrace(); // depends on control dependency: [while], data = [none]
throwable = throwable.getCause(); // depends on control dependency: [while], data = [none]
}
return exceptions;
} } |
public class class_name {
public static int[] permuteDataFormatForSameDiff(String dataFormat, boolean weights) {
val dl4jFormat = "NCHW";
dataFormat = dataFormat.toUpperCase();
//TF: filter_height, filter_width, in_channels, out_channels
/**
* N: filter_height
* H: filter_width
* W: in_channels
* C: out_channels
*/
/**
*
*
*/
//DL4J: filter_height,out_channels,filter_width,in_channels
// Weights should be: out channels, in channels, height,width
int[] ret = new int[4];
if (weights) {
ret[0] = dataFormat.indexOf('W');
ret[1] = dataFormat.indexOf('C');
ret[2] = dataFormat.indexOf('N');
ret[3] = dataFormat.indexOf('H');
return ret;
}
//NHWC
//DL4J: NCHW
for (int i = 0; i < dataFormat.length(); i++) {
if (dl4jFormat.indexOf(dataFormat.charAt(i)) < 0) {
throw new ND4JIllegalStateException("Illegal convolution data format string passed in " + dataFormat + " must be some variant of NCHW");
}
}
for (int i = 0; i < dl4jFormat.length(); i++) {
ret[i] = dl4jFormat.indexOf(dataFormat.charAt(i));
}
return ret;
} } | public class class_name {
public static int[] permuteDataFormatForSameDiff(String dataFormat, boolean weights) {
val dl4jFormat = "NCHW";
dataFormat = dataFormat.toUpperCase();
//TF: filter_height, filter_width, in_channels, out_channels
/**
* N: filter_height
* H: filter_width
* W: in_channels
* C: out_channels
*/
/**
*
*
*/
//DL4J: filter_height,out_channels,filter_width,in_channels
// Weights should be: out channels, in channels, height,width
int[] ret = new int[4];
if (weights) {
ret[0] = dataFormat.indexOf('W'); // depends on control dependency: [if], data = [none]
ret[1] = dataFormat.indexOf('C'); // depends on control dependency: [if], data = [none]
ret[2] = dataFormat.indexOf('N'); // depends on control dependency: [if], data = [none]
ret[3] = dataFormat.indexOf('H'); // depends on control dependency: [if], data = [none]
return ret; // depends on control dependency: [if], data = [none]
}
//NHWC
//DL4J: NCHW
for (int i = 0; i < dataFormat.length(); i++) {
if (dl4jFormat.indexOf(dataFormat.charAt(i)) < 0) {
throw new ND4JIllegalStateException("Illegal convolution data format string passed in " + dataFormat + " must be some variant of NCHW");
}
}
for (int i = 0; i < dl4jFormat.length(); i++) {
ret[i] = dl4jFormat.indexOf(dataFormat.charAt(i));
}
return ret;
} } |
public class class_name {
HeaderField getHeaderField(int index) {
HeaderEntry entry = head;
while(index-- >= 0) {
entry = entry.before;
}
return entry;
} } | public class class_name {
HeaderField getHeaderField(int index) {
HeaderEntry entry = head;
while(index-- >= 0) {
entry = entry.before; // depends on control dependency: [while], data = [none]
}
return entry;
} } |
public class class_name {
public Message editMessageReplyMarkup(String chatId, Long messageId, InlineReplyMarkup inlineReplyMarkup) {
if(inlineReplyMarkup != null && chatId != null && messageId != null) {
JSONObject jsonResponse = this.editMessageReplyMarkup(chatId, messageId, null, inlineReplyMarkup);
if(jsonResponse != null) {
return MessageImpl.createMessage(jsonResponse.getJSONObject("result"), this);
}
}
return null;
} } | public class class_name {
public Message editMessageReplyMarkup(String chatId, Long messageId, InlineReplyMarkup inlineReplyMarkup) {
if(inlineReplyMarkup != null && chatId != null && messageId != null) {
JSONObject jsonResponse = this.editMessageReplyMarkup(chatId, messageId, null, inlineReplyMarkup);
if(jsonResponse != null) {
return MessageImpl.createMessage(jsonResponse.getJSONObject("result"), this); // depends on control dependency: [if], data = [(jsonResponse]
}
}
return null;
} } |
public class class_name {
private void userInfoInit() {
boolean first = true;
userId = null;
userLocale = null;
userName = null;
userOrganization = null;
userDivision = null;
if (null != authentications) {
for (Authentication auth : authentications) {
userId = combine(userId, auth.getUserId());
userName = combine(userName, auth.getUserName());
if (first) {
userLocale = auth.getUserLocale();
first = false;
} else {
if (null != auth.getUserLocale() &&
(null == userLocale || !userLocale.equals(auth.getUserLocale()))) {
userLocale = null;
}
}
userOrganization = combine(userOrganization, auth.getUserOrganization());
userDivision = combine(userDivision, auth.getUserDivision());
}
}
// now calculate the "id" for this context, this should be independent of the data order, so sort
Map<String, List<String>> idParts = new HashMap<String, List<String>>();
if (null != authentications) {
for (Authentication auth : authentications) {
List<String> auths = new ArrayList<String>();
for (BaseAuthorization ba : auth.getAuthorizations()) {
auths.add(ba.getId());
}
Collections.sort(auths);
idParts.put(auth.getSecurityServiceId(), auths);
}
}
StringBuilder sb = new StringBuilder();
List<String> sortedKeys = new ArrayList<String>(idParts.keySet());
Collections.sort(sortedKeys);
for (String key : sortedKeys) {
if (sb.length() > 0) {
sb.append('|');
}
List<String> auths = idParts.get(key);
first = true;
for (String ak : auths) {
if (first) {
first = false;
} else {
sb.append('|');
}
sb.append(ak);
}
sb.append('@');
sb.append(key);
}
id = sb.toString();
} } | public class class_name {
private void userInfoInit() {
boolean first = true;
userId = null;
userLocale = null;
userName = null;
userOrganization = null;
userDivision = null;
if (null != authentications) {
for (Authentication auth : authentications) {
userId = combine(userId, auth.getUserId()); // depends on control dependency: [for], data = [auth]
userName = combine(userName, auth.getUserName()); // depends on control dependency: [for], data = [auth]
if (first) {
userLocale = auth.getUserLocale(); // depends on control dependency: [if], data = [none]
first = false; // depends on control dependency: [if], data = [none]
} else {
if (null != auth.getUserLocale() &&
(null == userLocale || !userLocale.equals(auth.getUserLocale()))) {
userLocale = null; // depends on control dependency: [if], data = [none]
}
}
userOrganization = combine(userOrganization, auth.getUserOrganization()); // depends on control dependency: [for], data = [auth]
userDivision = combine(userDivision, auth.getUserDivision()); // depends on control dependency: [for], data = [auth]
}
}
// now calculate the "id" for this context, this should be independent of the data order, so sort
Map<String, List<String>> idParts = new HashMap<String, List<String>>();
if (null != authentications) {
for (Authentication auth : authentications) {
List<String> auths = new ArrayList<String>();
for (BaseAuthorization ba : auth.getAuthorizations()) {
auths.add(ba.getId()); // depends on control dependency: [for], data = [ba]
}
Collections.sort(auths); // depends on control dependency: [for], data = [auth]
idParts.put(auth.getSecurityServiceId(), auths); // depends on control dependency: [for], data = [auth]
}
}
StringBuilder sb = new StringBuilder();
List<String> sortedKeys = new ArrayList<String>(idParts.keySet());
Collections.sort(sortedKeys);
for (String key : sortedKeys) {
if (sb.length() > 0) {
sb.append('|'); // depends on control dependency: [if], data = [none]
}
List<String> auths = idParts.get(key);
first = true; // depends on control dependency: [for], data = [none]
for (String ak : auths) {
if (first) {
first = false; // depends on control dependency: [if], data = [none]
} else {
sb.append('|'); // depends on control dependency: [if], data = [none]
}
sb.append(ak); // depends on control dependency: [for], data = [ak]
}
sb.append('@'); // depends on control dependency: [for], data = [none]
sb.append(key); // depends on control dependency: [for], data = [key]
}
id = sb.toString();
} } |
public class class_name {
public JobGetOptions withOcpDate(DateTime ocpDate) {
if (ocpDate == null) {
this.ocpDate = null;
} else {
this.ocpDate = new DateTimeRfc1123(ocpDate);
}
return this;
} } | public class class_name {
public JobGetOptions withOcpDate(DateTime ocpDate) {
if (ocpDate == null) {
this.ocpDate = null; // depends on control dependency: [if], data = [none]
} else {
this.ocpDate = new DateTimeRfc1123(ocpDate); // depends on control dependency: [if], data = [(ocpDate]
}
return this;
} } |
public class class_name {
public void incrementHighRateCounter(String name) {
if (monitorActive) {
String escapedName = keyHandler.handle(name);
for (MonitorPlugin p : getPlugins()) {
p.incrementHighRateCounter(escapedName, 1);
}
}
} } | public class class_name {
public void incrementHighRateCounter(String name) {
if (monitorActive) {
String escapedName = keyHandler.handle(name);
for (MonitorPlugin p : getPlugins()) {
p.incrementHighRateCounter(escapedName, 1);
// depends on control dependency: [for], data = [p]
}
}
} } |
public class class_name {
private String getDynamicAttributeValue(
CmsFile file,
I_CmsXmlContentValue value,
String attributeName,
CmsEntity editedLocalEntity) {
if ((null != editedLocalEntity) && (editedLocalEntity.getAttribute(attributeName) != null)) {
getSessionCache().setDynamicValue(
attributeName,
editedLocalEntity.getAttribute(attributeName).getSimpleValue());
}
String currentValue = getSessionCache().getDynamicValue(attributeName);
if (null != currentValue) {
return currentValue;
}
if (null != file) {
if (value.getTypeName().equals(CmsXmlDynamicCategoryValue.TYPE_NAME)) {
List<CmsCategory> categories = new ArrayList<CmsCategory>(0);
try {
categories = CmsCategoryService.getInstance().readResourceCategories(getCmsObject(), file);
} catch (CmsException e) {
LOG.error(Messages.get().getBundle().key(Messages.ERROR_FAILED_READING_CATEGORIES_1), e);
}
I_CmsWidget widget = null;
widget = CmsWidgetUtil.collectWidgetInfo(value).getWidget();
if ((null != widget) && (widget instanceof CmsCategoryWidget)) {
String mainCategoryPath = ((CmsCategoryWidget)widget).getStartingCategory(
getCmsObject(),
getCmsObject().getSitePath(file));
StringBuffer pathes = new StringBuffer();
for (CmsCategory category : categories) {
if (category.getPath().startsWith(mainCategoryPath)) {
String path = category.getBasePath() + category.getPath();
path = getCmsObject().getRequestContext().removeSiteRoot(path);
pathes.append(path).append(',');
}
}
String dynamicConfigString = pathes.length() > 0 ? pathes.substring(0, pathes.length() - 1) : "";
getSessionCache().setDynamicValue(attributeName, dynamicConfigString);
return dynamicConfigString;
}
}
}
return "";
} } | public class class_name {
private String getDynamicAttributeValue(
CmsFile file,
I_CmsXmlContentValue value,
String attributeName,
CmsEntity editedLocalEntity) {
if ((null != editedLocalEntity) && (editedLocalEntity.getAttribute(attributeName) != null)) {
getSessionCache().setDynamicValue(
attributeName,
editedLocalEntity.getAttribute(attributeName).getSimpleValue()); // depends on control dependency: [if], data = [none]
}
String currentValue = getSessionCache().getDynamicValue(attributeName);
if (null != currentValue) {
return currentValue; // depends on control dependency: [if], data = [none]
}
if (null != file) {
if (value.getTypeName().equals(CmsXmlDynamicCategoryValue.TYPE_NAME)) {
List<CmsCategory> categories = new ArrayList<CmsCategory>(0);
try {
categories = CmsCategoryService.getInstance().readResourceCategories(getCmsObject(), file); // depends on control dependency: [try], data = [none]
} catch (CmsException e) {
LOG.error(Messages.get().getBundle().key(Messages.ERROR_FAILED_READING_CATEGORIES_1), e);
} // depends on control dependency: [catch], data = [none]
I_CmsWidget widget = null;
widget = CmsWidgetUtil.collectWidgetInfo(value).getWidget(); // depends on control dependency: [if], data = [none]
if ((null != widget) && (widget instanceof CmsCategoryWidget)) {
String mainCategoryPath = ((CmsCategoryWidget)widget).getStartingCategory(
getCmsObject(),
getCmsObject().getSitePath(file));
StringBuffer pathes = new StringBuffer();
for (CmsCategory category : categories) {
if (category.getPath().startsWith(mainCategoryPath)) {
String path = category.getBasePath() + category.getPath();
path = getCmsObject().getRequestContext().removeSiteRoot(path); // depends on control dependency: [if], data = [none]
pathes.append(path).append(','); // depends on control dependency: [if], data = [none]
}
}
String dynamicConfigString = pathes.length() > 0 ? pathes.substring(0, pathes.length() - 1) : "";
getSessionCache().setDynamicValue(attributeName, dynamicConfigString);
return dynamicConfigString; // depends on control dependency: [if], data = [none]
}
}
}
return "";
} } |
public class class_name {
@Override
public synchronized P readPage(int pageID) {
countRead();
P page = map.get(pageID);
if(page != null) {
if(LOG.isDebuggingFine()) {
LOG.debugFine("Read from cache: " + pageID);
}
}
else {
if(LOG.isDebuggingFine()) {
LOG.debugFine("Read from backing: " + pageID);
}
page = file.readPage(pageID);
map.put(pageID, page);
}
return page;
} } | public class class_name {
@Override
public synchronized P readPage(int pageID) {
countRead();
P page = map.get(pageID);
if(page != null) {
if(LOG.isDebuggingFine()) {
LOG.debugFine("Read from cache: " + pageID); // depends on control dependency: [if], data = [none]
}
}
else {
if(LOG.isDebuggingFine()) {
LOG.debugFine("Read from backing: " + pageID); // depends on control dependency: [if], data = [none]
}
page = file.readPage(pageID); // depends on control dependency: [if], data = [(page]
map.put(pageID, page); // depends on control dependency: [if], data = [(page]
}
return page;
} } |
public class class_name {
protected String getValue (String name, Object defaultValue)
{
String value = getParameter(name);
if (StringUtil.isBlank(value)) {
if (defaultValue == null) {
value = "";
} else {
value = String.valueOf(defaultValue);
}
}
return HTMLUtil.entify(value);
} } | public class class_name {
protected String getValue (String name, Object defaultValue)
{
String value = getParameter(name);
if (StringUtil.isBlank(value)) {
if (defaultValue == null) {
value = ""; // depends on control dependency: [if], data = [none]
} else {
value = String.valueOf(defaultValue); // depends on control dependency: [if], data = [(defaultValue]
}
}
return HTMLUtil.entify(value);
} } |
public class class_name {
public MethodDoc overriddenMethod() {
// Real overriding only. Static members are simply hidden.
// Likewise for constructors, but the MethodSymbol.overrides
// method takes this into account.
if ((sym.flags() & Flags.STATIC) != 0) {
return null;
}
// Derived from com.sun.tools.javac.comp.Check.checkOverride .
ClassSymbol origin = (ClassSymbol)sym.owner;
for (Type t = env.types.supertype(origin.type);
t.hasTag(CLASS);
t = env.types.supertype(t)) {
ClassSymbol c = (ClassSymbol)t.tsym;
for (Symbol sym2 : membersOf(c).getSymbolsByName(sym.name)) {
if (sym.overrides(sym2, origin, env.types, true)) {
return env.getMethodDoc((MethodSymbol)sym2);
}
}
}
return null;
} } | public class class_name {
public MethodDoc overriddenMethod() {
// Real overriding only. Static members are simply hidden.
// Likewise for constructors, but the MethodSymbol.overrides
// method takes this into account.
if ((sym.flags() & Flags.STATIC) != 0) {
return null; // depends on control dependency: [if], data = [none]
}
// Derived from com.sun.tools.javac.comp.Check.checkOverride .
ClassSymbol origin = (ClassSymbol)sym.owner;
for (Type t = env.types.supertype(origin.type);
t.hasTag(CLASS);
t = env.types.supertype(t)) {
ClassSymbol c = (ClassSymbol)t.tsym;
for (Symbol sym2 : membersOf(c).getSymbolsByName(sym.name)) {
if (sym.overrides(sym2, origin, env.types, true)) {
return env.getMethodDoc((MethodSymbol)sym2); // depends on control dependency: [if], data = [none]
}
}
}
return null;
} } |
public class class_name {
private static int scanTypeVariableSignature(String string, int start) {
// need a minimum 3 chars "Tx;"
if (start >= string.length() - 2) {
throw new IllegalArgumentException();
}
// must start in "T"
char c = string.charAt(start);
if (c != C_TYPE_VARIABLE) {
throw new IllegalArgumentException();
}
int id = scanIdentifier(string, start + 1);
c = string.charAt(id + 1);
if (c == C_SEMICOLON) {
return id + 1;
} else {
throw new IllegalArgumentException();
}
} } | public class class_name {
private static int scanTypeVariableSignature(String string, int start) {
// need a minimum 3 chars "Tx;"
if (start >= string.length() - 2) {
throw new IllegalArgumentException();
}
// must start in "T"
char c = string.charAt(start);
if (c != C_TYPE_VARIABLE) {
throw new IllegalArgumentException();
}
int id = scanIdentifier(string, start + 1);
c = string.charAt(id + 1);
if (c == C_SEMICOLON) {
return id + 1; // depends on control dependency: [if], data = [none]
} else {
throw new IllegalArgumentException();
}
} } |
public class class_name {
public final void dummy() throws RecognitionException {
try {
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:157:5: ( expression ( AT | SEMICOLON | EOF | ID | RIGHT_PAREN ) )
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:157:7: expression ( AT | SEMICOLON | EOF | ID | RIGHT_PAREN )
{
pushFollow(FOLLOW_expression_in_dummy711);
expression();
state._fsp--;
if (state.failed) return;
if ( input.LA(1)==EOF||input.LA(1)==AT||input.LA(1)==ID||input.LA(1)==RIGHT_PAREN||input.LA(1)==SEMICOLON ) {
input.consume();
state.errorRecovery=false;
state.failed=false;
}
else {
if (state.backtracking>0) {state.failed=true; return;}
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
}
}
catch (RecognitionException re) {
throw re;
}
finally {
// do for sure before leaving
}
} } | public class class_name {
public final void dummy() throws RecognitionException {
try {
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:157:5: ( expression ( AT | SEMICOLON | EOF | ID | RIGHT_PAREN ) )
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:157:7: expression ( AT | SEMICOLON | EOF | ID | RIGHT_PAREN )
{
pushFollow(FOLLOW_expression_in_dummy711);
expression();
state._fsp--;
if (state.failed) return;
if ( input.LA(1)==EOF||input.LA(1)==AT||input.LA(1)==ID||input.LA(1)==RIGHT_PAREN||input.LA(1)==SEMICOLON ) {
input.consume();
state.errorRecovery=false;
state.failed=false;
}
else {
if (state.backtracking>0) {state.failed=true; return;} // depends on control dependency: [if], data = [none] // depends on control dependency: [if], data = [none]
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
}
}
catch (RecognitionException re) {
throw re;
}
finally {
// do for sure before leaving
}
} } |
public class class_name {
void zApplyMinimumToggleTimeMenuButtonWidthInPixels() {
if (parent == null) {
return;
}
Dimension menuButtonPreferredSize = parent.getComponentToggleTimeMenuButton().getPreferredSize();
int width = menuButtonPreferredSize.width;
int height = menuButtonPreferredSize.height;
int minimumWidth = minimumToggleTimeMenuButtonWidthInPixels;
width = (width < minimumWidth) ? minimumWidth : width;
Dimension newSize = new Dimension(width, height);
parent.getComponentToggleTimeMenuButton().setPreferredSize(newSize);
} } | public class class_name {
void zApplyMinimumToggleTimeMenuButtonWidthInPixels() {
if (parent == null) {
return; // depends on control dependency: [if], data = [none]
}
Dimension menuButtonPreferredSize = parent.getComponentToggleTimeMenuButton().getPreferredSize();
int width = menuButtonPreferredSize.width;
int height = menuButtonPreferredSize.height;
int minimumWidth = minimumToggleTimeMenuButtonWidthInPixels;
width = (width < minimumWidth) ? minimumWidth : width;
Dimension newSize = new Dimension(width, height);
parent.getComponentToggleTimeMenuButton().setPreferredSize(newSize);
} } |
public class class_name {
public Matrix transpose() {
Matrix A = new Matrix(N, M);
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
A.data[j][i] = data[i][j];
}
}
return A;
} } | public class class_name {
public Matrix transpose() {
Matrix A = new Matrix(N, M);
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
A.data[j][i] = data[i][j]; // depends on control dependency: [for], data = [j]
}
}
return A;
} } |
public class class_name {
protected <T> T getFieldValue(Object object, Field field, Class<T> clazz) throws VisitorException {
boolean reprotect = false;
if(object == null) {
return null;
}
try {
if(!field.isAccessible()) {
field.setAccessible(true);
reprotect = true;
}
Object value = field.get(object);
if(value != null) {
logger.trace("field '{}' has value '{}'", field.getName(), value);
return clazz.cast(value);
}
} catch (IllegalArgumentException e) {
logger.error("trying to access field '{}' on invalid object of class '{}'", field.getName(), object.getClass().getSimpleName());
throw new VisitorException("Trying to access field on invalid object", e);
} catch (IllegalAccessException e) {
logger.error("illegal access to class '{}'", object.getClass().getSimpleName());
throw new VisitorException("Illegal access to class", e);
} finally {
if(reprotect) {
field.setAccessible(false);
}
}
return null;
} } | public class class_name {
protected <T> T getFieldValue(Object object, Field field, Class<T> clazz) throws VisitorException {
boolean reprotect = false;
if(object == null) {
return null;
}
try {
if(!field.isAccessible()) {
field.setAccessible(true); // depends on control dependency: [if], data = [none]
reprotect = true; // depends on control dependency: [if], data = [none]
}
Object value = field.get(object);
if(value != null) {
logger.trace("field '{}' has value '{}'", field.getName(), value); // depends on control dependency: [if], data = [none]
return clazz.cast(value); // depends on control dependency: [if], data = [(value]
}
} catch (IllegalArgumentException e) {
logger.error("trying to access field '{}' on invalid object of class '{}'", field.getName(), object.getClass().getSimpleName());
throw new VisitorException("Trying to access field on invalid object", e);
} catch (IllegalAccessException e) {
logger.error("illegal access to class '{}'", object.getClass().getSimpleName());
throw new VisitorException("Illegal access to class", e);
} finally {
if(reprotect) {
field.setAccessible(false);
}
}
return null;
} } |
public class class_name {
private void initView(){
LinearLayout mProgressContainer = (LinearLayout) mLayout.findViewById(R.id.progress_container);
int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, mLayout.getResources().getDisplayMetrics());
mLayout.setPadding(padding, padding, padding, padding);
// Based on configuration from Builder, construct the Layout
switch (mProgressStyle){
case HORIZONTAL:
mProgress = new ProgressBar(mCtx, null, android.R.attr.progressBarStyleHorizontal);
break;
case SMALL:
mIsIndeterminate = true;
mProgressText.setVisibility(View.GONE);
mProgressMax.setVisibility(View.GONE);
mProgress = new ProgressBar(mCtx, null, android.R.attr.progressBarStyleSmall);
break;
case NORMAL:
mIsIndeterminate = true;
mProgressText.setVisibility(View.GONE);
mProgressMax.setVisibility(View.GONE);
mProgress = new ProgressBar(mCtx);
break;
case LARGE:
mIsIndeterminate = true;
mProgressText.setVisibility(View.GONE);
mProgressMax.setVisibility(View.GONE);
mProgress = new ProgressBar(mCtx, null, android.R.attr.progressBarStyleLarge);
break;
}
// The ProgressBar parameters
LinearLayout.LayoutParams progressParams;
// Generate the message parameters
int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, mCtx.getResources().getDisplayMetrics());
LinearLayout.LayoutParams messageParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
messageParams.weight = 1f;
messageParams.gravity = Gravity.CENTER_VERTICAL;
messageParams.setMargins(margin, 0, margin, 0);
// Now based on the provided message content, change up hte LayoutParameters of the progresses
if(mProgressStyle == HORIZONTAL){
progressParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}else{
if(mMessage != null){
progressParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}else{
progressParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
}
Log.d("ProgressStyle", "Setting ProgressBar LayoutParams(" + progressParams.width + "," + progressParams.height + ")");
// Add the stylized progress bar to the layout
mProgress.setLayoutParams(progressParams);
mProgressContainer.addView(mProgress);
// If the message isn't null, and it's not the progress style
if(mMessage != null && mProgressStyle != HORIZONTAL){
// Create and add the text view
TextView message = new TextView(mCtx);
message.setId(R.id.progress_mesage);
FontLoader.applyTypeface(message, Types.ROBOTO_REGULAR);
message.setText(mMessage);
// Add this to the layout
mProgressContainer.addView(message, messageParams);
}
// Now based on other attributes style the progressBar
if(mProgressStyle == HORIZONTAL) {
if (mIsIndeterminate) {
Log.d(ProgressStyle.class.getName(), "Setting Indeterminate for Horizontal ProgressStyle");
// Update the ProgressBar
mProgress.setIndeterminate(true);
// Hide the auxillary text
mProgressText.setVisibility(View.GONE);
mProgressMax.setVisibility(View.GONE);
} else {
Log.d(ProgressStyle.class.getName(), "Setting Progress for Horizontal ProgressStyle");
// Only if the progress style is horizontal, should
// we attempt to set the progress and max
mProgress.setIndeterminate(false);
setProgress(mInitProgress);
setMax(mInitMax);
}
}
} } | public class class_name {
private void initView(){
LinearLayout mProgressContainer = (LinearLayout) mLayout.findViewById(R.id.progress_container);
int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, mLayout.getResources().getDisplayMetrics());
mLayout.setPadding(padding, padding, padding, padding);
// Based on configuration from Builder, construct the Layout
switch (mProgressStyle){
case HORIZONTAL:
mProgress = new ProgressBar(mCtx, null, android.R.attr.progressBarStyleHorizontal);
break;
case SMALL:
mIsIndeterminate = true;
mProgressText.setVisibility(View.GONE);
mProgressMax.setVisibility(View.GONE);
mProgress = new ProgressBar(mCtx, null, android.R.attr.progressBarStyleSmall);
break;
case NORMAL:
mIsIndeterminate = true;
mProgressText.setVisibility(View.GONE);
mProgressMax.setVisibility(View.GONE);
mProgress = new ProgressBar(mCtx);
break;
case LARGE:
mIsIndeterminate = true;
mProgressText.setVisibility(View.GONE);
mProgressMax.setVisibility(View.GONE);
mProgress = new ProgressBar(mCtx, null, android.R.attr.progressBarStyleLarge);
break;
}
// The ProgressBar parameters
LinearLayout.LayoutParams progressParams;
// Generate the message parameters
int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, mCtx.getResources().getDisplayMetrics());
LinearLayout.LayoutParams messageParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
messageParams.weight = 1f;
messageParams.gravity = Gravity.CENTER_VERTICAL;
messageParams.setMargins(margin, 0, margin, 0);
// Now based on the provided message content, change up hte LayoutParameters of the progresses
if(mProgressStyle == HORIZONTAL){
progressParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); // depends on control dependency: [if], data = [none]
}else{
if(mMessage != null){
progressParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); // depends on control dependency: [if], data = [none]
}else{
progressParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); // depends on control dependency: [if], data = [none]
}
}
Log.d("ProgressStyle", "Setting ProgressBar LayoutParams(" + progressParams.width + "," + progressParams.height + ")");
// Add the stylized progress bar to the layout
mProgress.setLayoutParams(progressParams);
mProgressContainer.addView(mProgress);
// If the message isn't null, and it's not the progress style
if(mMessage != null && mProgressStyle != HORIZONTAL){
// Create and add the text view
TextView message = new TextView(mCtx);
message.setId(R.id.progress_mesage);
FontLoader.applyTypeface(message, Types.ROBOTO_REGULAR);
message.setText(mMessage);
// Add this to the layout
mProgressContainer.addView(message, messageParams);
}
// Now based on other attributes style the progressBar
if(mProgressStyle == HORIZONTAL) {
if (mIsIndeterminate) {
Log.d(ProgressStyle.class.getName(), "Setting Indeterminate for Horizontal ProgressStyle");
// Update the ProgressBar
mProgress.setIndeterminate(true);
// Hide the auxillary text
mProgressText.setVisibility(View.GONE);
mProgressMax.setVisibility(View.GONE);
} else {
Log.d(ProgressStyle.class.getName(), "Setting Progress for Horizontal ProgressStyle");
// Only if the progress style is horizontal, should
// we attempt to set the progress and max
mProgress.setIndeterminate(false);
setProgress(mInitProgress);
setMax(mInitMax);
}
}
} } |
public class class_name {
public void marshall(UpdateResolverEndpointRequest updateResolverEndpointRequest, ProtocolMarshaller protocolMarshaller) {
if (updateResolverEndpointRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(updateResolverEndpointRequest.getResolverEndpointId(), RESOLVERENDPOINTID_BINDING);
protocolMarshaller.marshall(updateResolverEndpointRequest.getName(), NAME_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(UpdateResolverEndpointRequest updateResolverEndpointRequest, ProtocolMarshaller protocolMarshaller) {
if (updateResolverEndpointRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(updateResolverEndpointRequest.getResolverEndpointId(), RESOLVERENDPOINTID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(updateResolverEndpointRequest.getName(), NAME_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public String getArguments(MethodInvocation invocation) {
try {
Object[] args = invocation.getArguments();
if (args == null)
return null;
if (args.length != 1)
return null;// 参数是一个主键
if (args[0] == null)
return null;
return args[0].toString();
} catch (Exception ex) {
Debug.logError("[JdonFramework] method:"
+ invocation.getMethod().getName() + " " + ex, module);
return null;
}
} } | public class class_name {
public String getArguments(MethodInvocation invocation) {
try {
Object[] args = invocation.getArguments();
if (args == null)
return null;
if (args.length != 1)
return null;// 参数是一个主键
if (args[0] == null)
return null;
return args[0].toString();
// depends on control dependency: [try], data = [none]
} catch (Exception ex) {
Debug.logError("[JdonFramework] method:"
+ invocation.getMethod().getName() + " " + ex, module);
return null;
}
// depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public ParameterDescription.InDefinedShape get(int index) {
int offset = declaringMethod.isStatic() ? 0 : 1;
for (ParameterDescription.Token token : tokens.subList(0, index)) {
offset += token.getType().getStackSize().getSize();
}
return new ParameterDescription.Latent(declaringMethod, tokens.get(index), index, offset);
} } | public class class_name {
public ParameterDescription.InDefinedShape get(int index) {
int offset = declaringMethod.isStatic() ? 0 : 1;
for (ParameterDescription.Token token : tokens.subList(0, index)) {
offset += token.getType().getStackSize().getSize(); // depends on control dependency: [for], data = [token]
}
return new ParameterDescription.Latent(declaringMethod, tokens.get(index), index, offset);
} } |
public class class_name {
public void marshall(SqlInjectionMatchSetUpdate sqlInjectionMatchSetUpdate, ProtocolMarshaller protocolMarshaller) {
if (sqlInjectionMatchSetUpdate == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(sqlInjectionMatchSetUpdate.getAction(), ACTION_BINDING);
protocolMarshaller.marshall(sqlInjectionMatchSetUpdate.getSqlInjectionMatchTuple(), SQLINJECTIONMATCHTUPLE_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(SqlInjectionMatchSetUpdate sqlInjectionMatchSetUpdate, ProtocolMarshaller protocolMarshaller) {
if (sqlInjectionMatchSetUpdate == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(sqlInjectionMatchSetUpdate.getAction(), ACTION_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(sqlInjectionMatchSetUpdate.getSqlInjectionMatchTuple(), SQLINJECTIONMATCHTUPLE_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void marshall(GetOfferingStatusRequest getOfferingStatusRequest, ProtocolMarshaller protocolMarshaller) {
if (getOfferingStatusRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(getOfferingStatusRequest.getNextToken(), NEXTTOKEN_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(GetOfferingStatusRequest getOfferingStatusRequest, ProtocolMarshaller protocolMarshaller) {
if (getOfferingStatusRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(getOfferingStatusRequest.getNextToken(), NEXTTOKEN_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private static boolean inEncoding(char ch, byte[] data) {
final boolean isInEncoding;
// If the string written out as data is not in the encoding,
// the output is not specified according to the documentation
// on the String.getBytes(encoding) method,
// but we do our best here.
if (data==null || data.length == 0) {
isInEncoding = false;
}
else {
if (data[0] == 0)
isInEncoding = false;
else if (data[0] == '?' && ch != '?')
isInEncoding = false;
/*
* else if (isJapanese) {
* // isJapanese is really
* // ( "EUC-JP".equals(javaName)
* // || "EUC_JP".equals(javaName)
* // || "SJIS".equals(javaName) )
*
* // Work around some bugs in JRE for Japanese
* if(data[0] == 0x21)
* isInEncoding = false;
* else if (ch == 0xA5)
* isInEncoding = false;
* else
* isInEncoding = true;
* }
*/
else {
// We don't know for sure, but it looks like it is in the encoding
isInEncoding = true;
}
}
return isInEncoding;
} } | public class class_name {
private static boolean inEncoding(char ch, byte[] data) {
final boolean isInEncoding;
// If the string written out as data is not in the encoding,
// the output is not specified according to the documentation
// on the String.getBytes(encoding) method,
// but we do our best here.
if (data==null || data.length == 0) {
isInEncoding = false; // depends on control dependency: [if], data = [none]
}
else {
if (data[0] == 0)
isInEncoding = false;
else if (data[0] == '?' && ch != '?')
isInEncoding = false;
/*
* else if (isJapanese) {
* // isJapanese is really
* // ( "EUC-JP".equals(javaName)
* // || "EUC_JP".equals(javaName)
* // || "SJIS".equals(javaName) )
*
* // Work around some bugs in JRE for Japanese
* if(data[0] == 0x21)
* isInEncoding = false;
* else if (ch == 0xA5)
* isInEncoding = false;
* else
* isInEncoding = true;
* }
*/
else {
// We don't know for sure, but it looks like it is in the encoding
isInEncoding = true; // depends on control dependency: [if], data = [none]
}
}
return isInEncoding;
} } |
public class class_name {
public void setFullUrl(String fullUrl) {
if (fullUrl == null) {
return;
}
Uri parsedUri = Uri.parse(fullUrl);
if (!WonderPushUriHelper.isAPIUri(parsedUri)) {
mWebView.loadUrl(fullUrl);
} else {
setResource(WonderPushUriHelper.getResource(parsedUri), WonderPushUriHelper.getParams(parsedUri));
}
} } | public class class_name {
public void setFullUrl(String fullUrl) {
if (fullUrl == null) {
return; // depends on control dependency: [if], data = [none]
}
Uri parsedUri = Uri.parse(fullUrl);
if (!WonderPushUriHelper.isAPIUri(parsedUri)) {
mWebView.loadUrl(fullUrl); // depends on control dependency: [if], data = [none]
} else {
setResource(WonderPushUriHelper.getResource(parsedUri), WonderPushUriHelper.getParams(parsedUri)); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public synchronized void unregisterJmxIfRequired() {
referenceCount--;
if (isRegistered == true && referenceCount <= 0) {
JmxUtils.unregisterMbean(this.jmxObjectName);
isRegistered = false;
}
} } | public class class_name {
public synchronized void unregisterJmxIfRequired() {
referenceCount--;
if (isRegistered == true && referenceCount <= 0) {
JmxUtils.unregisterMbean(this.jmxObjectName); // depends on control dependency: [if], data = [none]
isRegistered = false; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void marshall(SplitShardRequest splitShardRequest, ProtocolMarshaller protocolMarshaller) {
if (splitShardRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(splitShardRequest.getStreamName(), STREAMNAME_BINDING);
protocolMarshaller.marshall(splitShardRequest.getShardToSplit(), SHARDTOSPLIT_BINDING);
protocolMarshaller.marshall(splitShardRequest.getNewStartingHashKey(), NEWSTARTINGHASHKEY_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(SplitShardRequest splitShardRequest, ProtocolMarshaller protocolMarshaller) {
if (splitShardRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(splitShardRequest.getStreamName(), STREAMNAME_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(splitShardRequest.getShardToSplit(), SHARDTOSPLIT_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(splitShardRequest.getNewStartingHashKey(), NEWSTARTINGHASHKEY_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void setExtraParams(java.util.Collection<ExtraParam> extraParams) {
if (extraParams == null) {
this.extraParams = null;
return;
}
this.extraParams = new com.amazonaws.internal.SdkInternalList<ExtraParam>(extraParams);
} } | public class class_name {
public void setExtraParams(java.util.Collection<ExtraParam> extraParams) {
if (extraParams == null) {
this.extraParams = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.extraParams = new com.amazonaws.internal.SdkInternalList<ExtraParam>(extraParams);
} } |
public class class_name {
public static <T extends V, V> Value<V> fromNullable(T value) {
if (value == null) {
return empty();
}
return new Value<V>(value);
} } | public class class_name {
public static <T extends V, V> Value<V> fromNullable(T value) {
if (value == null) {
return empty(); // depends on control dependency: [if], data = [none]
}
return new Value<V>(value);
} } |
public class class_name {
void log(LogRecord record, boolean wasForced) {
// Do the fast boolean check (which normally succeeds) before calling isLoggable().
if (!wasForced || logger.isLoggable(record.getLevel())) {
// Unforced log statements or forced log statements at or above the logger's level can be
// passed to the normal log(LogRecord) method.
logger.log(record);
} else {
// If logging has been forced for a log record which would otherwise be discarded, we cannot
// call our logger's log(LogRecord) method, so we must simulate its behavior in one of two
// ways.
// 1: Simulate the effect of calling the log(LogRecord) method directly (this is safe if the
// logger provided by the log manager was a normal Logger instance).
// 2: Obtain a "child" logger from the log manager which is set to log everything, and call
// its log(LogRecord) method instead (which should have the same overridden behavior and
// will still publish log records to our logger's handlers).
//
// In all cases we still call the filter (if one exists) even though we ignore the result.
// Use a local variable to avoid race conditions where the filter can be unset at any time.
Filter filter = logger.getFilter();
if (filter != null) {
filter.isLoggable(record);
}
if (logger.getClass() == Logger.class || cannotUseForcingLogger) {
// If the Logger instance is not a subclass, its log(LogRecord) method cannot have been
// overridden. That means it's safe to just publish the log record directly to handlers
// to avoid the loggability check, which would otherwise discard the forced log record.
publish(logger, record);
} else {
// Hopefully rare situation in which the logger is subclassed _and_ the log record would
// normally be discarded based on its level.
forceLoggingViaChildLogger(record);
}
}
} } | public class class_name {
void log(LogRecord record, boolean wasForced) {
// Do the fast boolean check (which normally succeeds) before calling isLoggable().
if (!wasForced || logger.isLoggable(record.getLevel())) {
// Unforced log statements or forced log statements at or above the logger's level can be
// passed to the normal log(LogRecord) method.
logger.log(record); // depends on control dependency: [if], data = [none]
} else {
// If logging has been forced for a log record which would otherwise be discarded, we cannot
// call our logger's log(LogRecord) method, so we must simulate its behavior in one of two
// ways.
// 1: Simulate the effect of calling the log(LogRecord) method directly (this is safe if the
// logger provided by the log manager was a normal Logger instance).
// 2: Obtain a "child" logger from the log manager which is set to log everything, and call
// its log(LogRecord) method instead (which should have the same overridden behavior and
// will still publish log records to our logger's handlers).
//
// In all cases we still call the filter (if one exists) even though we ignore the result.
// Use a local variable to avoid race conditions where the filter can be unset at any time.
Filter filter = logger.getFilter();
if (filter != null) {
filter.isLoggable(record); // depends on control dependency: [if], data = [none]
}
if (logger.getClass() == Logger.class || cannotUseForcingLogger) {
// If the Logger instance is not a subclass, its log(LogRecord) method cannot have been
// overridden. That means it's safe to just publish the log record directly to handlers
// to avoid the loggability check, which would otherwise discard the forced log record.
publish(logger, record); // depends on control dependency: [if], data = [none]
} else {
// Hopefully rare situation in which the logger is subclassed _and_ the log record would
// normally be discarded based on its level.
forceLoggingViaChildLogger(record); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public final void ruleJvmUpperBound() throws RecognitionException {
int stackSize = keepStackSize();
try {
// InternalXbase.g:1754:2: ( ( ( rule__JvmUpperBound__Group__0 ) ) )
// InternalXbase.g:1755:2: ( ( rule__JvmUpperBound__Group__0 ) )
{
// InternalXbase.g:1755:2: ( ( rule__JvmUpperBound__Group__0 ) )
// InternalXbase.g:1756:3: ( rule__JvmUpperBound__Group__0 )
{
if ( state.backtracking==0 ) {
before(grammarAccess.getJvmUpperBoundAccess().getGroup());
}
// InternalXbase.g:1757:3: ( rule__JvmUpperBound__Group__0 )
// InternalXbase.g:1757:4: rule__JvmUpperBound__Group__0
{
pushFollow(FOLLOW_2);
rule__JvmUpperBound__Group__0();
state._fsp--;
if (state.failed) return ;
}
if ( state.backtracking==0 ) {
after(grammarAccess.getJvmUpperBoundAccess().getGroup());
}
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
restoreStackSize(stackSize);
}
return ;
} } | public class class_name {
public final void ruleJvmUpperBound() throws RecognitionException {
int stackSize = keepStackSize();
try {
// InternalXbase.g:1754:2: ( ( ( rule__JvmUpperBound__Group__0 ) ) )
// InternalXbase.g:1755:2: ( ( rule__JvmUpperBound__Group__0 ) )
{
// InternalXbase.g:1755:2: ( ( rule__JvmUpperBound__Group__0 ) )
// InternalXbase.g:1756:3: ( rule__JvmUpperBound__Group__0 )
{
if ( state.backtracking==0 ) {
before(grammarAccess.getJvmUpperBoundAccess().getGroup()); // depends on control dependency: [if], data = [none]
}
// InternalXbase.g:1757:3: ( rule__JvmUpperBound__Group__0 )
// InternalXbase.g:1757:4: rule__JvmUpperBound__Group__0
{
pushFollow(FOLLOW_2);
rule__JvmUpperBound__Group__0();
state._fsp--;
if (state.failed) return ;
}
if ( state.backtracking==0 ) {
after(grammarAccess.getJvmUpperBoundAccess().getGroup()); // depends on control dependency: [if], data = [none]
}
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
restoreStackSize(stackSize);
}
return ;
} } |
public class class_name {
public int compare(S solution1, S solution2) {
double violationDegreeSolution1 ;
double violationDegreeSolution2;
if (overallConstraintViolation.getAttribute(solution1) == null) {
return 0 ;
}
violationDegreeSolution1 = overallConstraintViolation.getAttribute(solution1);
violationDegreeSolution2 = overallConstraintViolation.getAttribute(solution2);
if ((violationDegreeSolution1 < 0) && (violationDegreeSolution2 < 0)) {
if (violationDegreeSolution1 > violationDegreeSolution2) {
return -1;
} else if (violationDegreeSolution2 > violationDegreeSolution1) {
return 1;
} else {
return 0;
}
} else if ((violationDegreeSolution1 == 0) && (violationDegreeSolution2 < 0)) {
return -1;
} else if ((violationDegreeSolution1 < 0) && (violationDegreeSolution2 == 0)) {
return 1;
} else {
return 0;
}
} } | public class class_name {
public int compare(S solution1, S solution2) {
double violationDegreeSolution1 ;
double violationDegreeSolution2;
if (overallConstraintViolation.getAttribute(solution1) == null) {
return 0 ; // depends on control dependency: [if], data = [none]
}
violationDegreeSolution1 = overallConstraintViolation.getAttribute(solution1);
violationDegreeSolution2 = overallConstraintViolation.getAttribute(solution2);
if ((violationDegreeSolution1 < 0) && (violationDegreeSolution2 < 0)) {
if (violationDegreeSolution1 > violationDegreeSolution2) {
return -1; // depends on control dependency: [if], data = [none]
} else if (violationDegreeSolution2 > violationDegreeSolution1) {
return 1; // depends on control dependency: [if], data = [none]
} else {
return 0; // depends on control dependency: [if], data = [none]
}
} else if ((violationDegreeSolution1 == 0) && (violationDegreeSolution2 < 0)) {
return -1; // depends on control dependency: [if], data = [none]
} else if ((violationDegreeSolution1 < 0) && (violationDegreeSolution2 == 0)) {
return 1; // depends on control dependency: [if], data = [none]
} else {
return 0; // depends on control dependency: [if], data = [none]
}
} } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.