code stringlengths 130 281k | code_dependency stringlengths 182 306k |
|---|---|
public class class_name {
private Object[] getEncodingName(byte[] b4, int count) {
if (count < 2) {
return new Object[]{"UTF-8", null, null};
}
// UTF-16, with BOM
int b0 = b4[0] & 0xFF;
int b1 = b4[1] & 0xFF;
if (b0 == 0xFE && b1 == 0xFF) {
// UTF-16, big-endian, with a BOM
return new Object [] {"UTF-16BE", Boolean.TRUE,
Boolean.TRUE};
}
/* SJSAS 6307968
if (b0 == 0xFF && b1 == 0xFE) {
*/
// BEGIN SJSAS 6307968
if (count == 2 && b0 == 0xFF && b1 == 0xFE) {
// END SJSAS 6307968
// UTF-16, little-endian, with a BOM
return new Object [] {"UTF-16LE", Boolean.FALSE,
Boolean.TRUE};
}
// default to UTF-8 if we don't have enough bytes to make a
// good determination of the encoding
if (count < 3) {
return new Object [] {"UTF-8", null, null};
}
// UTF-8 with a BOM
int b2 = b4[2] & 0xFF;
if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) {
return new Object [] {"UTF-8", null, Boolean.TRUE};
}
// default to UTF-8 if we don't have enough bytes to make a
// good determination of the encoding
if (count < 4) {
return new Object [] {"UTF-8", null, null};
}
// other encodings
int b3 = b4[3] & 0xFF;
if (b0 == 0x00 && b1 == 0x00 && b2 == 0x00 && b3 == 0x3C) {
// UCS-4, big endian (1234)
return new Object [] {"ISO-10646-UCS-4", Boolean.TRUE, null};
}
if (b0 == 0x3C && b1 == 0x00 && b2 == 0x00 && b3 == 0x00) {
// UCS-4, little endian (4321)
return new Object [] {"ISO-10646-UCS-4", Boolean.FALSE, null};
}
if (b0 == 0x00 && b1 == 0x00 && b2 == 0x3C && b3 == 0x00) {
// UCS-4, unusual octet order (2143)
// REVISIT: What should this be?
return new Object [] {"ISO-10646-UCS-4", null, null};
}
if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x00) {
// UCS-4, unusual octect order (3412)
// REVISIT: What should this be?
return new Object [] {"ISO-10646-UCS-4", null, null};
}
if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F) {
// UTF-16, big-endian, no BOM
// (or could turn out to be UCS-2...
// REVISIT: What should this be?
return new Object [] {"UTF-16BE", Boolean.TRUE, null};
}
if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00) {
// UTF-16, little-endian, no BOM
// (or could turn out to be UCS-2...
return new Object [] {"UTF-16LE", Boolean.FALSE, null};
}
if (b0 == 0x4C && b1 == 0x6F && b2 == 0xA7 && b3 == 0x94) {
// EBCDIC
// a la xerces1, return CP037 instead of EBCDIC here
return new Object [] {"CP037", null, null};
}
if (b0 == 0x00 && b1 == 0x00 && b2 == 0xFE && b3 == 0xFF) {
// UTF-32, big-endian, with a BOM
return new Object [] {"UTF-32BE", Boolean.TRUE,
Boolean.TRUE};
}
if (b0 == 0xFF && b1 == 0xFE && b2 == 0x00 && b3 == 0x00) {
// UTF-32, little-endian, with a BOM
return new Object [] {"UTF-32LE", Boolean.FALSE,
Boolean.TRUE};
}
// BEGIN SJSAS 6307968
if (b0 == 0xFF && b1 == 0xFE) {
// UTF-16, little-endian, with a BOM
return new Object [] {"UTF-16LE", Boolean.FALSE,
Boolean.TRUE};
}
// END SJSAS 6307968
// default encoding
return new Object [] {"UTF-8", null, null};
} } | public class class_name {
private Object[] getEncodingName(byte[] b4, int count) {
if (count < 2) {
return new Object[]{"UTF-8", null, null}; // depends on control dependency: [if], data = [none]
}
// UTF-16, with BOM
int b0 = b4[0] & 0xFF;
int b1 = b4[1] & 0xFF;
if (b0 == 0xFE && b1 == 0xFF) {
// UTF-16, big-endian, with a BOM
return new Object [] {"UTF-16BE", Boolean.TRUE,
Boolean.TRUE}; // depends on control dependency: [if], data = [none]
}
/* SJSAS 6307968
if (b0 == 0xFF && b1 == 0xFE) {
*/
// BEGIN SJSAS 6307968
if (count == 2 && b0 == 0xFF && b1 == 0xFE) {
// END SJSAS 6307968
// UTF-16, little-endian, with a BOM
return new Object [] {"UTF-16LE", Boolean.FALSE,
Boolean.TRUE}; // depends on control dependency: [if], data = [none]
}
// default to UTF-8 if we don't have enough bytes to make a
// good determination of the encoding
if (count < 3) {
return new Object [] {"UTF-8", null, null}; // depends on control dependency: [if], data = [none]
}
// UTF-8 with a BOM
int b2 = b4[2] & 0xFF;
if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) {
return new Object [] {"UTF-8", null, Boolean.TRUE}; // depends on control dependency: [if], data = [none]
}
// default to UTF-8 if we don't have enough bytes to make a
// good determination of the encoding
if (count < 4) {
return new Object [] {"UTF-8", null, null}; // depends on control dependency: [if], data = [none]
}
// other encodings
int b3 = b4[3] & 0xFF;
if (b0 == 0x00 && b1 == 0x00 && b2 == 0x00 && b3 == 0x3C) {
// UCS-4, big endian (1234)
return new Object [] {"ISO-10646-UCS-4", Boolean.TRUE, null}; // depends on control dependency: [if], data = [none]
}
if (b0 == 0x3C && b1 == 0x00 && b2 == 0x00 && b3 == 0x00) {
// UCS-4, little endian (4321)
return new Object [] {"ISO-10646-UCS-4", Boolean.FALSE, null}; // depends on control dependency: [if], data = [none]
}
if (b0 == 0x00 && b1 == 0x00 && b2 == 0x3C && b3 == 0x00) {
// UCS-4, unusual octet order (2143)
// REVISIT: What should this be?
return new Object [] {"ISO-10646-UCS-4", null, null}; // depends on control dependency: [if], data = [none]
}
if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x00) {
// UCS-4, unusual octect order (3412)
// REVISIT: What should this be?
return new Object [] {"ISO-10646-UCS-4", null, null}; // depends on control dependency: [if], data = [none]
}
if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F) {
// UTF-16, big-endian, no BOM
// (or could turn out to be UCS-2...
// REVISIT: What should this be?
return new Object [] {"UTF-16BE", Boolean.TRUE, null}; // depends on control dependency: [if], data = [none]
}
if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00) {
// UTF-16, little-endian, no BOM
// (or could turn out to be UCS-2...
return new Object [] {"UTF-16LE", Boolean.FALSE, null}; // depends on control dependency: [if], data = [none]
}
if (b0 == 0x4C && b1 == 0x6F && b2 == 0xA7 && b3 == 0x94) {
// EBCDIC
// a la xerces1, return CP037 instead of EBCDIC here
return new Object [] {"CP037", null, null}; // depends on control dependency: [if], data = [none]
}
if (b0 == 0x00 && b1 == 0x00 && b2 == 0xFE && b3 == 0xFF) {
// UTF-32, big-endian, with a BOM
return new Object [] {"UTF-32BE", Boolean.TRUE,
Boolean.TRUE}; // depends on control dependency: [if], data = [none]
}
if (b0 == 0xFF && b1 == 0xFE && b2 == 0x00 && b3 == 0x00) {
// UTF-32, little-endian, with a BOM
return new Object [] {"UTF-32LE", Boolean.FALSE,
Boolean.TRUE}; // depends on control dependency: [if], data = [none]
}
// BEGIN SJSAS 6307968
if (b0 == 0xFF && b1 == 0xFE) {
// UTF-16, little-endian, with a BOM
return new Object [] {"UTF-16LE", Boolean.FALSE,
Boolean.TRUE}; // depends on control dependency: [if], data = [none]
}
// END SJSAS 6307968
// default encoding
return new Object [] {"UTF-8", null, null};
} } |
public class class_name {
private boolean checkPlTin(final String ptin) {
final int checkSum = ptin.charAt(ptin.length() - 1) - '0';
int calculatedCheckSum;
if (StringUtils.length(ptin) == 11) {
// PESEL
final int sum = (ptin.charAt(0) - '0') * 1 //
+ (ptin.charAt(1) - '0') * 3 //
+ (ptin.charAt(2) - '0') * 7 //
+ (ptin.charAt(3) - '0') * 9 //
+ (ptin.charAt(4) - '0') * 1 //
+ (ptin.charAt(5) - '0') * 3 //
+ (ptin.charAt(6) - '0') * 7 //
+ (ptin.charAt(7) - '0') * 9 //
+ (ptin.charAt(8) - '0') * 1 //
+ (ptin.charAt(9) - '0') * 3;
calculatedCheckSum = sum % 10;
if (calculatedCheckSum != 0) {
calculatedCheckSum = 10 - sum % 10;
}
} else {
// NIP
final int sum = (ptin.charAt(0) - '0') * 6 //
+ (ptin.charAt(1) - '0') * 5 //
+ (ptin.charAt(2) - '0') * 7 //
+ (ptin.charAt(3) - '0') * 2 //
+ (ptin.charAt(4) - '0') * 3 //
+ (ptin.charAt(5) - '0') * 4 //
+ (ptin.charAt(6) - '0') * 5 //
+ (ptin.charAt(7) - '0') * 6 //
+ (ptin.charAt(8) - '0') * 7;
calculatedCheckSum = sum % MODULO_11;
}
return checkSum == calculatedCheckSum;
} } | public class class_name {
private boolean checkPlTin(final String ptin) {
final int checkSum = ptin.charAt(ptin.length() - 1) - '0';
int calculatedCheckSum;
if (StringUtils.length(ptin) == 11) {
// PESEL
final int sum = (ptin.charAt(0) - '0') * 1 //
+ (ptin.charAt(1) - '0') * 3 //
+ (ptin.charAt(2) - '0') * 7 //
+ (ptin.charAt(3) - '0') * 9 //
+ (ptin.charAt(4) - '0') * 1 //
+ (ptin.charAt(5) - '0') * 3 //
+ (ptin.charAt(6) - '0') * 7 //
+ (ptin.charAt(7) - '0') * 9 //
+ (ptin.charAt(8) - '0') * 1 //
+ (ptin.charAt(9) - '0') * 3;
calculatedCheckSum = sum % 10;
// depends on control dependency: [if], data = [none]
if (calculatedCheckSum != 0) {
calculatedCheckSum = 10 - sum % 10;
// depends on control dependency: [if], data = [none]
}
} else {
// NIP
final int sum = (ptin.charAt(0) - '0') * 6 //
+ (ptin.charAt(1) - '0') * 5 //
+ (ptin.charAt(2) - '0') * 7 //
+ (ptin.charAt(3) - '0') * 2 //
+ (ptin.charAt(4) - '0') * 3 //
+ (ptin.charAt(5) - '0') * 4 //
+ (ptin.charAt(6) - '0') * 5 //
+ (ptin.charAt(7) - '0') * 6 //
+ (ptin.charAt(8) - '0') * 7;
calculatedCheckSum = sum % MODULO_11;
// depends on control dependency: [if], data = [none]
}
return checkSum == calculatedCheckSum;
} } |
public class class_name {
public final void ruleXConstructorCall() throws RecognitionException {
int stackSize = keepStackSize();
try {
// InternalXbase.g:1271:2: ( ( ( rule__XConstructorCall__Group__0 ) ) )
// InternalXbase.g:1272:2: ( ( rule__XConstructorCall__Group__0 ) )
{
// InternalXbase.g:1272:2: ( ( rule__XConstructorCall__Group__0 ) )
// InternalXbase.g:1273:3: ( rule__XConstructorCall__Group__0 )
{
if ( state.backtracking==0 ) {
before(grammarAccess.getXConstructorCallAccess().getGroup());
}
// InternalXbase.g:1274:3: ( rule__XConstructorCall__Group__0 )
// InternalXbase.g:1274:4: rule__XConstructorCall__Group__0
{
pushFollow(FOLLOW_2);
rule__XConstructorCall__Group__0();
state._fsp--;
if (state.failed) return ;
}
if ( state.backtracking==0 ) {
after(grammarAccess.getXConstructorCallAccess().getGroup());
}
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
restoreStackSize(stackSize);
}
return ;
} } | public class class_name {
public final void ruleXConstructorCall() throws RecognitionException {
int stackSize = keepStackSize();
try {
// InternalXbase.g:1271:2: ( ( ( rule__XConstructorCall__Group__0 ) ) )
// InternalXbase.g:1272:2: ( ( rule__XConstructorCall__Group__0 ) )
{
// InternalXbase.g:1272:2: ( ( rule__XConstructorCall__Group__0 ) )
// InternalXbase.g:1273:3: ( rule__XConstructorCall__Group__0 )
{
if ( state.backtracking==0 ) {
before(grammarAccess.getXConstructorCallAccess().getGroup()); // depends on control dependency: [if], data = [none]
}
// InternalXbase.g:1274:3: ( rule__XConstructorCall__Group__0 )
// InternalXbase.g:1274:4: rule__XConstructorCall__Group__0
{
pushFollow(FOLLOW_2);
rule__XConstructorCall__Group__0();
state._fsp--;
if (state.failed) return ;
}
if ( state.backtracking==0 ) {
after(grammarAccess.getXConstructorCallAccess().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 static String[] parseCallerId(String s)
{
final String[] result = new String[2];
final int lbPosition;
final int rbPosition;
String name;
String number;
if (s == null)
{
return result;
}
lbPosition = s.lastIndexOf('<');
rbPosition = s.lastIndexOf('>');
// no opening and closing brace? use value as CallerId name
if (lbPosition < 0 || rbPosition < 0)
{
name = s.trim();
if (name.length() == 0)
{
name = null;
}
result[0] = name;
return result;
}
number = s.substring(lbPosition + 1, rbPosition).trim();
if (number.length() == 0)
{
number = null;
}
name = s.substring(0, lbPosition).trim();
if (name.startsWith("\"") && name.endsWith("\"") && name.length() > 1)
{
name = name.substring(1, name.length() - 1).trim();
}
if (name.length() == 0)
{
name = null;
}
result[0] = name;
result[1] = number;
return result;
} } | public class class_name {
public static String[] parseCallerId(String s)
{
final String[] result = new String[2];
final int lbPosition;
final int rbPosition;
String name;
String number;
if (s == null)
{
return result; // depends on control dependency: [if], data = [none]
}
lbPosition = s.lastIndexOf('<');
rbPosition = s.lastIndexOf('>');
// no opening and closing brace? use value as CallerId name
if (lbPosition < 0 || rbPosition < 0)
{
name = s.trim(); // depends on control dependency: [if], data = [none]
if (name.length() == 0)
{
name = null; // depends on control dependency: [if], data = [none]
}
result[0] = name; // depends on control dependency: [if], data = [none]
return result; // depends on control dependency: [if], data = [none]
}
number = s.substring(lbPosition + 1, rbPosition).trim();
if (number.length() == 0)
{
number = null; // depends on control dependency: [if], data = [none]
}
name = s.substring(0, lbPosition).trim();
if (name.startsWith("\"") && name.endsWith("\"") && name.length() > 1)
{
name = name.substring(1, name.length() - 1).trim(); // depends on control dependency: [if], data = [1)]
}
if (name.length() == 0)
{
name = null; // depends on control dependency: [if], data = [none]
}
result[0] = name;
result[1] = number;
return result;
} } |
public class class_name {
public void marshall(PasswordData passwordData, ProtocolMarshaller protocolMarshaller) {
if (passwordData == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(passwordData.getCiphertext(), CIPHERTEXT_BINDING);
protocolMarshaller.marshall(passwordData.getKeyPairName(), KEYPAIRNAME_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(PasswordData passwordData, ProtocolMarshaller protocolMarshaller) {
if (passwordData == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(passwordData.getCiphertext(), CIPHERTEXT_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(passwordData.getKeyPairName(), KEYPAIRNAME_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 seekTo(int milli) {
checkState();
if (!mPlayerPlaylist.isEmpty()) {
PlaybackService.seekTo(getContext(), mClientKey, milli);
}
} } | public class class_name {
public void seekTo(int milli) {
checkState();
if (!mPlayerPlaylist.isEmpty()) {
PlaybackService.seekTo(getContext(), mClientKey, milli); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public boolean handleImageUpload(CmsObject cms, List<String> uploadedFiles) {
boolean result = false;
if (uploadedFiles.size() == 1) {
String tempFile = CmsStringUtil.joinPaths(USER_IMAGE_FOLDER, TEMP_FOLDER, uploadedFiles.get(0));
result = handleImageUpload(cms, cms.getRequestContext().getCurrentUser(), tempFile);
}
return result;
} } | public class class_name {
public boolean handleImageUpload(CmsObject cms, List<String> uploadedFiles) {
boolean result = false;
if (uploadedFiles.size() == 1) {
String tempFile = CmsStringUtil.joinPaths(USER_IMAGE_FOLDER, TEMP_FOLDER, uploadedFiles.get(0));
result = handleImageUpload(cms, cms.getRequestContext().getCurrentUser(), tempFile); // depends on control dependency: [if], data = [none]
}
return result;
} } |
public class class_name {
public static String byte2FitMemorySize(final long byteNum) {
if (byteNum < 0) {
return "shouldn't be less than zero!";
} else if (byteNum < MemoryConst.KB) {
return String.format("%.3fB", (double) byteNum);
} else if (byteNum < MemoryConst.MB) {
return String.format("%.3fKB", (double) byteNum / MemoryConst.KB);
} else if (byteNum < MemoryConst.GB) {
return String.format("%.3fMB", (double) byteNum / MemoryConst.MB);
} else {
return String.format("%.3fGB", (double) byteNum / MemoryConst.GB);
}
} } | public class class_name {
public static String byte2FitMemorySize(final long byteNum) {
if (byteNum < 0) {
return "shouldn't be less than zero!"; // depends on control dependency: [if], data = [none]
} else if (byteNum < MemoryConst.KB) {
return String.format("%.3fB", (double) byteNum); // depends on control dependency: [if], data = [none]
} else if (byteNum < MemoryConst.MB) {
return String.format("%.3fKB", (double) byteNum / MemoryConst.KB); // depends on control dependency: [if], data = [none]
} else if (byteNum < MemoryConst.GB) {
return String.format("%.3fMB", (double) byteNum / MemoryConst.MB); // depends on control dependency: [if], data = [none]
} else {
return String.format("%.3fGB", (double) byteNum / MemoryConst.GB); // depends on control dependency: [if], data = [MemoryConst.GB)]
}
} } |
public class class_name {
public static CmsResource getInheritanceGroupContentByName(CmsObject cms, String name) throws CmsException {
String oldSiteRoot = cms.getRequestContext().getSiteRoot();
try {
cms.getRequestContext().setSiteRoot("");
List<CmsResource> resources = cms.readResourcesWithProperty(
"/",
CmsPropertyDefinition.PROPERTY_KEYWORDS,
name);
Iterator<CmsResource> resourceIter = resources.iterator();
while (resourceIter.hasNext()) {
CmsResource currentRes = resourceIter.next();
if (!OpenCms.getResourceManager().getResourceType(currentRes).getTypeName().equals(
"inheritance_group")) {
resourceIter.remove();
}
}
if (resources.isEmpty()) {
throw new CmsVfsResourceNotFoundException(
org.opencms.gwt.Messages.get().container(
org.opencms.gwt.Messages.ERR_INHERITANCE_GROUP_NOT_FOUND_1,
name));
}
return resources.get(0);
} finally {
cms.getRequestContext().setSiteRoot(oldSiteRoot);
}
} } | public class class_name {
public static CmsResource getInheritanceGroupContentByName(CmsObject cms, String name) throws CmsException {
String oldSiteRoot = cms.getRequestContext().getSiteRoot();
try {
cms.getRequestContext().setSiteRoot("");
List<CmsResource> resources = cms.readResourcesWithProperty(
"/",
CmsPropertyDefinition.PROPERTY_KEYWORDS,
name);
Iterator<CmsResource> resourceIter = resources.iterator();
while (resourceIter.hasNext()) {
CmsResource currentRes = resourceIter.next();
if (!OpenCms.getResourceManager().getResourceType(currentRes).getTypeName().equals(
"inheritance_group")) {
resourceIter.remove();
// depends on control dependency: [if], data = [none]
}
}
if (resources.isEmpty()) {
throw new CmsVfsResourceNotFoundException(
org.opencms.gwt.Messages.get().container(
org.opencms.gwt.Messages.ERR_INHERITANCE_GROUP_NOT_FOUND_1,
name));
}
return resources.get(0);
} finally {
cms.getRequestContext().setSiteRoot(oldSiteRoot);
}
} } |
public class class_name {
@VisibleForTesting
void configureHelixQuotaBasedTaskScheduling() {
// set up the cluster quota config
List<String> quotaConfigList = ConfigUtils.getStringList(this.config,
GobblinClusterConfigurationKeys.HELIX_TASK_QUOTA_CONFIG_KEY);
if (quotaConfigList.isEmpty()) {
return;
}
// retrieve the cluster config for updating
ClusterConfig clusterConfig = this.multiManager.getJobClusterHelixManager().getConfigAccessor()
.getClusterConfig(this.clusterName);
clusterConfig.resetTaskQuotaRatioMap();
for (String entry : quotaConfigList) {
List<String> quotaConfig = Splitter.on(":").limit(2).trimResults().omitEmptyStrings().splitToList(entry);
if (quotaConfig.size() < 2) {
throw new IllegalArgumentException(
"Quota configurations must be of the form <key1>:<value1>,<key2>:<value2>,...");
}
clusterConfig.setTaskQuotaRatio(quotaConfig.get(0), Integer.parseInt(quotaConfig.get(1)));
}
this.multiManager.getJobClusterHelixManager().getConfigAccessor()
.setClusterConfig(this.clusterName, clusterConfig); // Set the new ClusterConfig
} } | public class class_name {
@VisibleForTesting
void configureHelixQuotaBasedTaskScheduling() {
// set up the cluster quota config
List<String> quotaConfigList = ConfigUtils.getStringList(this.config,
GobblinClusterConfigurationKeys.HELIX_TASK_QUOTA_CONFIG_KEY);
if (quotaConfigList.isEmpty()) {
return; // depends on control dependency: [if], data = [none]
}
// retrieve the cluster config for updating
ClusterConfig clusterConfig = this.multiManager.getJobClusterHelixManager().getConfigAccessor()
.getClusterConfig(this.clusterName);
clusterConfig.resetTaskQuotaRatioMap();
for (String entry : quotaConfigList) {
List<String> quotaConfig = Splitter.on(":").limit(2).trimResults().omitEmptyStrings().splitToList(entry);
if (quotaConfig.size() < 2) {
throw new IllegalArgumentException(
"Quota configurations must be of the form <key1>:<value1>,<key2>:<value2>,...");
}
clusterConfig.setTaskQuotaRatio(quotaConfig.get(0), Integer.parseInt(quotaConfig.get(1)));
}
this.multiManager.getJobClusterHelixManager().getConfigAccessor()
.setClusterConfig(this.clusterName, clusterConfig); // Set the new ClusterConfig // depends on control dependency: [for], data = [none]
} } |
public class class_name {
public void computeIndicatorValuesHD(List<S> solutionSet, double[] maximumValues,
double[] minimumValues) {
List<S> A, B;
// Initialize the structures
indicatorValues = new ArrayList<List<Double>>();
maxIndicatorValue = -Double.MAX_VALUE;
for (int j = 0; j < solutionSet.size(); j++) {
A = new ArrayList<>(1);
A.add(solutionSet.get(j));
List<Double> aux = new ArrayList<Double>();
for (S solution : solutionSet) {
B = new ArrayList<>(1);
B.add(solution);
int flag = (new DominanceComparator<S>()).compare(A.get(0), B.get(0));
double value;
if (flag == -1) {
value =
-calculateHypervolumeIndicator(A.get(0), B.get(0), problem.getNumberOfObjectives(),
maximumValues, minimumValues);
} else {
value = calculateHypervolumeIndicator(B.get(0), A.get(0), problem.getNumberOfObjectives(),
maximumValues, minimumValues);
}
//Update the max value of the indicator
if (Math.abs(value) > maxIndicatorValue) {
maxIndicatorValue = Math.abs(value);
}
aux.add(value);
}
indicatorValues.add(aux);
}
} } | public class class_name {
public void computeIndicatorValuesHD(List<S> solutionSet, double[] maximumValues,
double[] minimumValues) {
List<S> A, B;
// Initialize the structures
indicatorValues = new ArrayList<List<Double>>();
maxIndicatorValue = -Double.MAX_VALUE;
for (int j = 0; j < solutionSet.size(); j++) {
A = new ArrayList<>(1); // depends on control dependency: [for], data = [none]
A.add(solutionSet.get(j)); // depends on control dependency: [for], data = [j]
List<Double> aux = new ArrayList<Double>();
for (S solution : solutionSet) {
B = new ArrayList<>(1); // depends on control dependency: [for], data = [none]
B.add(solution); // depends on control dependency: [for], data = [solution]
int flag = (new DominanceComparator<S>()).compare(A.get(0), B.get(0));
double value;
if (flag == -1) {
value =
-calculateHypervolumeIndicator(A.get(0), B.get(0), problem.getNumberOfObjectives(),
maximumValues, minimumValues); // depends on control dependency: [if], data = [none]
} else {
value = calculateHypervolumeIndicator(B.get(0), A.get(0), problem.getNumberOfObjectives(),
maximumValues, minimumValues); // depends on control dependency: [if], data = [none]
}
//Update the max value of the indicator
if (Math.abs(value) > maxIndicatorValue) {
maxIndicatorValue = Math.abs(value); // depends on control dependency: [if], data = [none]
}
aux.add(value); // depends on control dependency: [for], data = [none]
}
indicatorValues.add(aux); // depends on control dependency: [for], data = [none]
}
} } |
public class class_name {
public void marshall(ListAssociatedFleetsRequest listAssociatedFleetsRequest, ProtocolMarshaller protocolMarshaller) {
if (listAssociatedFleetsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(listAssociatedFleetsRequest.getStackName(), STACKNAME_BINDING);
protocolMarshaller.marshall(listAssociatedFleetsRequest.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(ListAssociatedFleetsRequest listAssociatedFleetsRequest, ProtocolMarshaller protocolMarshaller) {
if (listAssociatedFleetsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(listAssociatedFleetsRequest.getStackName(), STACKNAME_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(listAssociatedFleetsRequest.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 HttpTrailersImpl duplicate() {
if (null == this.myFactory) {
if (tc.isDebugEnabled()) {
Tr.debug(tc, "Null factory, unable to duplicate: " + this);
}
return null;
}
if (tc.isDebugEnabled()) {
Tr.debug(tc, "Duplicating the trailer headers: " + this);
}
computeRemainingTrailers();
HttpTrailersImpl msg = this.myFactory.getTrailers();
super.duplicate(msg);
return msg;
} } | public class class_name {
public HttpTrailersImpl duplicate() {
if (null == this.myFactory) {
if (tc.isDebugEnabled()) {
Tr.debug(tc, "Null factory, unable to duplicate: " + this); // depends on control dependency: [if], data = [none]
}
return null; // depends on control dependency: [if], data = [none]
}
if (tc.isDebugEnabled()) {
Tr.debug(tc, "Duplicating the trailer headers: " + this); // depends on control dependency: [if], data = [none]
}
computeRemainingTrailers();
HttpTrailersImpl msg = this.myFactory.getTrailers();
super.duplicate(msg);
return msg;
} } |
public class class_name {
public final static void putContext(String key, Object value) {
Map<String, Object> ctx = CTX_HOLDER.get();
if (ctx == null) {
// FIXME 需要注意释放,或者用软引用之类的替代,timewait或回收队列均可考虑
ctx = new HashMap<String, Object>();
CTX_HOLDER.set(ctx);
}
ctx.put(key, value);
} } | public class class_name {
public final static void putContext(String key, Object value) {
Map<String, Object> ctx = CTX_HOLDER.get();
if (ctx == null) {
// FIXME 需要注意释放,或者用软引用之类的替代,timewait或回收队列均可考虑
ctx = new HashMap<String, Object>(); // depends on control dependency: [if], data = [none]
CTX_HOLDER.set(ctx); // depends on control dependency: [if], data = [(ctx]
}
ctx.put(key, value);
} } |
public class class_name {
@Restricted(DoNotUse.class) // WebOnly
public HttpResponse doPlugins() {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
JSONArray response = new JSONArray();
Map<String,JSONObject> allPlugins = new HashMap<>();
for (PluginWrapper plugin : plugins) {
JSONObject pluginInfo = new JSONObject();
pluginInfo.put("installed", true);
pluginInfo.put("name", plugin.getShortName());
pluginInfo.put("title", plugin.getDisplayName());
pluginInfo.put("active", plugin.isActive());
pluginInfo.put("enabled", plugin.isEnabled());
pluginInfo.put("bundled", plugin.isBundled);
pluginInfo.put("deleted", plugin.isDeleted());
pluginInfo.put("downgradable", plugin.isDowngradable());
pluginInfo.put("website", plugin.getUrl());
List<Dependency> dependencies = plugin.getDependencies();
if (dependencies != null && !dependencies.isEmpty()) {
Map<String, String> dependencyMap = new HashMap<>();
for (Dependency dependency : dependencies) {
dependencyMap.put(dependency.shortName, dependency.version);
}
pluginInfo.put("dependencies", dependencyMap);
} else {
pluginInfo.put("dependencies", Collections.emptyMap());
}
response.add(pluginInfo);
}
for (UpdateSite site : Jenkins.getActiveInstance().getUpdateCenter().getSiteList()) {
for (UpdateSite.Plugin plugin: site.getAvailables()) {
JSONObject pluginInfo = allPlugins.get(plugin.name);
if(pluginInfo == null) {
pluginInfo = new JSONObject();
pluginInfo.put("installed", false);
}
pluginInfo.put("name", plugin.name);
pluginInfo.put("title", plugin.getDisplayName());
pluginInfo.put("excerpt", plugin.excerpt);
pluginInfo.put("site", site.getId());
pluginInfo.put("dependencies", plugin.dependencies);
pluginInfo.put("website", plugin.wiki);
response.add(pluginInfo);
}
}
return hudson.util.HttpResponses.okJSON(response);
} } | public class class_name {
@Restricted(DoNotUse.class) // WebOnly
public HttpResponse doPlugins() {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
JSONArray response = new JSONArray();
Map<String,JSONObject> allPlugins = new HashMap<>();
for (PluginWrapper plugin : plugins) {
JSONObject pluginInfo = new JSONObject();
pluginInfo.put("installed", true); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("name", plugin.getShortName()); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("title", plugin.getDisplayName()); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("active", plugin.isActive()); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("enabled", plugin.isEnabled()); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("bundled", plugin.isBundled); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("deleted", plugin.isDeleted()); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("downgradable", plugin.isDowngradable()); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("website", plugin.getUrl()); // depends on control dependency: [for], data = [plugin]
List<Dependency> dependencies = plugin.getDependencies();
if (dependencies != null && !dependencies.isEmpty()) {
Map<String, String> dependencyMap = new HashMap<>();
for (Dependency dependency : dependencies) {
dependencyMap.put(dependency.shortName, dependency.version); // depends on control dependency: [for], data = [dependency]
}
pluginInfo.put("dependencies", dependencyMap); // depends on control dependency: [if], data = [none]
} else {
pluginInfo.put("dependencies", Collections.emptyMap()); // depends on control dependency: [if], data = [none]
}
response.add(pluginInfo); // depends on control dependency: [for], data = [plugin]
}
for (UpdateSite site : Jenkins.getActiveInstance().getUpdateCenter().getSiteList()) {
for (UpdateSite.Plugin plugin: site.getAvailables()) {
JSONObject pluginInfo = allPlugins.get(plugin.name);
if(pluginInfo == null) {
pluginInfo = new JSONObject(); // depends on control dependency: [if], data = [none]
pluginInfo.put("installed", false); // depends on control dependency: [if], data = [none]
}
pluginInfo.put("name", plugin.name); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("title", plugin.getDisplayName()); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("excerpt", plugin.excerpt); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("site", site.getId()); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("dependencies", plugin.dependencies); // depends on control dependency: [for], data = [plugin]
pluginInfo.put("website", plugin.wiki); // depends on control dependency: [for], data = [plugin]
response.add(pluginInfo); // depends on control dependency: [for], data = [plugin]
}
}
return hudson.util.HttpResponses.okJSON(response);
} } |
public class class_name {
public void visitTypeDeclaration(TypeDeclaration d) {
d.accept(pre);
for (TypeParameterDeclaration tpDecl : d.getFormalTypeParameters()) {
tpDecl.accept(this);
}
for (FieldDeclaration fieldDecl : d.getFields()) {
fieldDecl.accept(this);
}
for (MethodDeclaration methodDecl : d.getMethods()) {
methodDecl.accept(this);
}
for (TypeDeclaration typeDecl : d.getNestedTypes()) {
typeDecl.accept(this);
}
d.accept(post);
} } | public class class_name {
public void visitTypeDeclaration(TypeDeclaration d) {
d.accept(pre);
for (TypeParameterDeclaration tpDecl : d.getFormalTypeParameters()) {
tpDecl.accept(this);
// depends on control dependency: [for], data = [tpDecl]
}
for (FieldDeclaration fieldDecl : d.getFields()) {
fieldDecl.accept(this);
// depends on control dependency: [for], data = [fieldDecl]
}
for (MethodDeclaration methodDecl : d.getMethods()) {
methodDecl.accept(this);
// depends on control dependency: [for], data = [methodDecl]
}
for (TypeDeclaration typeDecl : d.getNestedTypes()) {
typeDecl.accept(this);
// depends on control dependency: [for], data = [typeDecl]
}
d.accept(post);
} } |
public class class_name {
public static String simonTreeString(Simon simon) {
if (simon == null || simon.getName() == null) {
return null;
}
StringBuilder sb = new StringBuilder();
printSimonTree(0, simon, sb);
return sb.toString();
} } | public class class_name {
public static String simonTreeString(Simon simon) {
if (simon == null || simon.getName() == null) {
return null; // depends on control dependency: [if], data = [none]
}
StringBuilder sb = new StringBuilder();
printSimonTree(0, simon, sb);
return sb.toString();
} } |
public class class_name {
public final void asString(final Format format, final StructuredDataId structuredDataId, final StringBuilder sb) {
final boolean full = Format.FULL.equals(format);
if (full) {
final String myType = getType();
if (myType == null) {
return;
}
sb.append(getType()).append(' ');
}
StructuredDataId sdId = getId();
if (sdId != null) {
sdId = sdId.makeId(structuredDataId); // returns sdId if structuredDataId is null
} else {
sdId = structuredDataId;
}
if (sdId == null || sdId.getName() == null) {
return;
}
sb.append('[');
StringBuilders.appendValue(sb, sdId); // avoids toString if implements StringBuilderFormattable
sb.append(' ');
appendMap(sb);
sb.append(']');
if (full) {
final String msg = getFormat();
if (msg != null) {
sb.append(' ').append(msg);
}
}
} } | public class class_name {
public final void asString(final Format format, final StructuredDataId structuredDataId, final StringBuilder sb) {
final boolean full = Format.FULL.equals(format);
if (full) {
final String myType = getType();
if (myType == null) {
return; // depends on control dependency: [if], data = [none]
}
sb.append(getType()).append(' '); // depends on control dependency: [if], data = [none]
}
StructuredDataId sdId = getId();
if (sdId != null) {
sdId = sdId.makeId(structuredDataId); // returns sdId if structuredDataId is null // depends on control dependency: [if], data = [none]
} else {
sdId = structuredDataId; // depends on control dependency: [if], data = [none]
}
if (sdId == null || sdId.getName() == null) {
return; // depends on control dependency: [if], data = [none]
}
sb.append('[');
StringBuilders.appendValue(sb, sdId); // avoids toString if implements StringBuilderFormattable
sb.append(' ');
appendMap(sb);
sb.append(']');
if (full) {
final String msg = getFormat();
if (msg != null) {
sb.append(' ').append(msg); // depends on control dependency: [if], data = [(msg]
}
}
} } |
public class class_name {
private void fillDetailResourceTypes(CmsListItem item, String detailId) {
CmsSearchManager searchManager = OpenCms.getSearchManager();
StringBuffer html = new StringBuffer();
String doctypeName = (String)item.get(LIST_COLUMN_NAME);
CmsSearchDocumentType docType = searchManager.getDocumentTypeConfig(doctypeName);
// output of resource types
Iterator<String> itResourcetypes = docType.getResourceTypes().iterator();
html.append("<ul>\n");
while (itResourcetypes.hasNext()) {
html.append(" <li>\n").append(" ").append(itResourcetypes.next()).append("\n");
html.append(" </li>");
}
html.append("</ul>\n");
item.set(detailId, html.toString());
} } | public class class_name {
private void fillDetailResourceTypes(CmsListItem item, String detailId) {
CmsSearchManager searchManager = OpenCms.getSearchManager();
StringBuffer html = new StringBuffer();
String doctypeName = (String)item.get(LIST_COLUMN_NAME);
CmsSearchDocumentType docType = searchManager.getDocumentTypeConfig(doctypeName);
// output of resource types
Iterator<String> itResourcetypes = docType.getResourceTypes().iterator();
html.append("<ul>\n");
while (itResourcetypes.hasNext()) {
html.append(" <li>\n").append(" ").append(itResourcetypes.next()).append("\n"); // depends on control dependency: [while], data = [none]
html.append(" </li>"); // depends on control dependency: [while], data = [none]
}
html.append("</ul>\n");
item.set(detailId, html.toString());
} } |
public class class_name {
@SuppressWarnings("unchecked")
public static <T> T evaluateExpressionGet(final FacesContext context,
final String expression) {
if (expression == null) {
return null;
}
return (T) context.getApplication().evaluateExpressionGet(context,
expression, Object.class);
} } | public class class_name {
@SuppressWarnings("unchecked")
public static <T> T evaluateExpressionGet(final FacesContext context,
final String expression) {
if (expression == null) {
return null;
// depends on control dependency: [if], data = [none]
}
return (T) context.getApplication().evaluateExpressionGet(context,
expression, Object.class);
} } |
public class class_name {
public boolean nextIndex(long index) {
if (operationIndex + 1 == index) {
currentOperation = OperationType.COMMAND;
operationIndex++;
return true;
}
return false;
} } | public class class_name {
public boolean nextIndex(long index) {
if (operationIndex + 1 == index) {
currentOperation = OperationType.COMMAND; // depends on control dependency: [if], data = [none]
operationIndex++; // depends on control dependency: [if], data = [none]
return true; // depends on control dependency: [if], data = [none]
}
return false;
} } |
public class class_name {
public void draw(final Graphics2D g, final int width, final int height) {
g.setColor(new Color(_data[0], _data[1], _data[2], _data[3]));
final GeneralPath path = new GeneralPath();
path.moveTo(_data[4]*width, _data[5]*height);
for (int j = 1; j < _length; ++j) {
path.lineTo(_data[4 + j*2]*width, _data[5 + j*2]*height);
}
path.closePath();
g.fill(path);
} } | public class class_name {
public void draw(final Graphics2D g, final int width, final int height) {
g.setColor(new Color(_data[0], _data[1], _data[2], _data[3]));
final GeneralPath path = new GeneralPath();
path.moveTo(_data[4]*width, _data[5]*height);
for (int j = 1; j < _length; ++j) {
path.lineTo(_data[4 + j*2]*width, _data[5 + j*2]*height); // depends on control dependency: [for], data = [j]
}
path.closePath();
g.fill(path);
} } |
public class class_name {
@Override
public MarginalSet computeMarginals(FactorGraph factorGraph) {
VariableNumMap variables = factorGraph.getVariables();
Preconditions.checkArgument(variables.getDiscreteVariables().size() == variables.size());
// Initialize the mean field distribution to the uniform distribution over
// all variables.
long curTime = System.currentTimeMillis();
System.out.println("init: " + (System.currentTimeMillis() - curTime));
int numVars = variables.size();
IndexedList<Integer> variableNums = new IndexedList<Integer>(variables.getVariableNums());
List<DiscreteVariable> variableTypes = variables.getDiscreteVariables();
List<Tensor> variableMarginals = Lists.newArrayListWithCapacity(numVars);
for (int i = 0; i < numVars; i++) {
int[] dimensions = new int[] { variableNums.get(i) };
int[] sizes = new int[] { variableTypes.get(i).numValues() };
variableMarginals.add(DenseTensor.constant(dimensions, sizes, 1.0 / sizes[0]));
}
System.out.println("logweights: " + (System.currentTimeMillis() - curTime));
// Get the log weights for each factor in the original factor graph.
List<Tensor> logWeights = Lists.newArrayList();
for (Factor factor : factorGraph.getFactors()) {
logWeights.add(factor.coerceToDiscrete().getWeights().elementwiseLog());
}
System.out.println("done: " + + (System.currentTimeMillis() - curTime));
double updateL2 = Double.POSITIVE_INFINITY;
int numIterations = 0;
while (updateL2 > CONVERGENCE_DELTA) {
updateL2 = 0.0;
for (int i = 0; i < numVars; i++) {
int curVarNum = variableNums.get(i);
// Accumulate the messages from each factor containing this variable.
DenseTensorBuilder messageAccumulator = new DenseTensorBuilder(
variableMarginals.get(i).getDimensionNumbers(), variableMarginals.get(i).getDimensionSizes());
Set<Integer> factorIndexes = factorGraph.getFactorsWithVariable(curVarNum);
// System.out.println(i + " " + curVarNum + ": " + factorIndexes);
for (int factorIndex : factorIndexes) {
Tensor factorMessage = getFactorMessage(curVarNum, logWeights.get(factorIndex),
variableMarginals, variableNums);
// System.out.println("factorMessage: " +
// Arrays.toString(factorMessage.getDimensionNumbers()));
// System.out.println("messageAccumulator: " +
// Arrays.toString(messageAccumulator.getDimensionNumbers()));
messageAccumulator.increment(factorMessage);
}
// Update the marginal based on the inbound messages, setting
// marginal equal to the logistic function of the accumulated messages.
messageAccumulator.exp();
double normalizingConstant = messageAccumulator.getTrace();
messageAccumulator.multiply(1.0 / normalizingConstant);
Tensor newMarginal = messageAccumulator.buildNoCopy();
// Compute the convergence criteria
Tensor delta = newMarginal.elementwiseAddition(
variableMarginals.get(i).elementwiseProduct(SparseTensor.getScalarConstant(-1.0)));
updateL2 += delta.getL2Norm();
variableMarginals.set(i, newMarginal);
}
numIterations++;
System.out.println("update L2: " + updateL2);
}
System.out.println("iterations:" + numIterations);
// Format output as factors.
List<Factor> marginals = Lists.newArrayList();
for (int i = 0; i < numVars; i++) {
marginals.add(new TableFactor(variables.intersection(variableNums.get(i)),
variableMarginals.get(i)));
}
System.out.println("really done: " + + (System.currentTimeMillis() - curTime));
return new FactorMarginalSet(marginals, 1.0, factorGraph.getConditionedVariables(),
factorGraph.getConditionedValues());
} } | public class class_name {
@Override
public MarginalSet computeMarginals(FactorGraph factorGraph) {
VariableNumMap variables = factorGraph.getVariables();
Preconditions.checkArgument(variables.getDiscreteVariables().size() == variables.size());
// Initialize the mean field distribution to the uniform distribution over
// all variables.
long curTime = System.currentTimeMillis();
System.out.println("init: " + (System.currentTimeMillis() - curTime));
int numVars = variables.size();
IndexedList<Integer> variableNums = new IndexedList<Integer>(variables.getVariableNums());
List<DiscreteVariable> variableTypes = variables.getDiscreteVariables();
List<Tensor> variableMarginals = Lists.newArrayListWithCapacity(numVars);
for (int i = 0; i < numVars; i++) {
int[] dimensions = new int[] { variableNums.get(i) };
int[] sizes = new int[] { variableTypes.get(i).numValues() };
variableMarginals.add(DenseTensor.constant(dimensions, sizes, 1.0 / sizes[0])); // depends on control dependency: [for], data = [none]
}
System.out.println("logweights: " + (System.currentTimeMillis() - curTime));
// Get the log weights for each factor in the original factor graph.
List<Tensor> logWeights = Lists.newArrayList();
for (Factor factor : factorGraph.getFactors()) {
logWeights.add(factor.coerceToDiscrete().getWeights().elementwiseLog()); // depends on control dependency: [for], data = [factor]
}
System.out.println("done: " + + (System.currentTimeMillis() - curTime));
double updateL2 = Double.POSITIVE_INFINITY;
int numIterations = 0;
while (updateL2 > CONVERGENCE_DELTA) {
updateL2 = 0.0; // depends on control dependency: [while], data = [none]
for (int i = 0; i < numVars; i++) {
int curVarNum = variableNums.get(i);
// Accumulate the messages from each factor containing this variable.
DenseTensorBuilder messageAccumulator = new DenseTensorBuilder(
variableMarginals.get(i).getDimensionNumbers(), variableMarginals.get(i).getDimensionSizes());
Set<Integer> factorIndexes = factorGraph.getFactorsWithVariable(curVarNum);
// System.out.println(i + " " + curVarNum + ": " + factorIndexes);
for (int factorIndex : factorIndexes) {
Tensor factorMessage = getFactorMessage(curVarNum, logWeights.get(factorIndex),
variableMarginals, variableNums);
// System.out.println("factorMessage: " +
// Arrays.toString(factorMessage.getDimensionNumbers()));
// System.out.println("messageAccumulator: " +
// Arrays.toString(messageAccumulator.getDimensionNumbers()));
messageAccumulator.increment(factorMessage); // depends on control dependency: [for], data = [none]
}
// Update the marginal based on the inbound messages, setting
// marginal equal to the logistic function of the accumulated messages.
messageAccumulator.exp(); // depends on control dependency: [for], data = [none]
double normalizingConstant = messageAccumulator.getTrace();
messageAccumulator.multiply(1.0 / normalizingConstant); // depends on control dependency: [for], data = [none]
Tensor newMarginal = messageAccumulator.buildNoCopy();
// Compute the convergence criteria
Tensor delta = newMarginal.elementwiseAddition(
variableMarginals.get(i).elementwiseProduct(SparseTensor.getScalarConstant(-1.0)));
updateL2 += delta.getL2Norm(); // depends on control dependency: [for], data = [none]
variableMarginals.set(i, newMarginal); // depends on control dependency: [for], data = [i]
}
numIterations++; // depends on control dependency: [while], data = [none]
System.out.println("update L2: " + updateL2); // depends on control dependency: [while], data = [none]
}
System.out.println("iterations:" + numIterations);
// Format output as factors.
List<Factor> marginals = Lists.newArrayList();
for (int i = 0; i < numVars; i++) {
marginals.add(new TableFactor(variables.intersection(variableNums.get(i)),
variableMarginals.get(i))); // depends on control dependency: [for], data = [none]
}
System.out.println("really done: " + + (System.currentTimeMillis() - curTime));
return new FactorMarginalSet(marginals, 1.0, factorGraph.getConditionedVariables(),
factorGraph.getConditionedValues());
} } |
public class class_name {
public static RangeImpl range(
EvaluationContext ctx,
Range.RangeBoundary lowBoundary,
Object lowEndPoint,
Object highEndPoint,
Range.RangeBoundary highBoundary) {
Comparable left = asComparable(lowEndPoint);
Comparable right = asComparable(highEndPoint);
if (left == null || right == null || !compatible(left, right)) {
ctx.notifyEvt(() -> new ASTEventBase(
FEELEvent.Severity.ERROR,
Msg.createMessage(
Msg.INCOMPATIBLE_TYPE_FOR_RANGE,
left.getClass().getSimpleName()
),
null));
return null;
}
return new RangeImpl(
lowBoundary,
left,
right,
highBoundary);
} } | public class class_name {
public static RangeImpl range(
EvaluationContext ctx,
Range.RangeBoundary lowBoundary,
Object lowEndPoint,
Object highEndPoint,
Range.RangeBoundary highBoundary) {
Comparable left = asComparable(lowEndPoint);
Comparable right = asComparable(highEndPoint);
if (left == null || right == null || !compatible(left, right)) {
ctx.notifyEvt(() -> new ASTEventBase(
FEELEvent.Severity.ERROR,
Msg.createMessage(
Msg.INCOMPATIBLE_TYPE_FOR_RANGE,
left.getClass().getSimpleName()
),
null)); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
return new RangeImpl(
lowBoundary,
left,
right,
highBoundary);
} } |
public class class_name {
public static int countParameterOfType(ModelMethod method, TypeName parameter) {
int counter = 0;
for (Pair<String, TypeName> item : method.getParameters()) {
if (item.value1.equals(parameter)) {
counter++;
}
}
return counter;
} } | public class class_name {
public static int countParameterOfType(ModelMethod method, TypeName parameter) {
int counter = 0;
for (Pair<String, TypeName> item : method.getParameters()) {
if (item.value1.equals(parameter)) {
counter++; // depends on control dependency: [if], data = [none]
}
}
return counter;
} } |
public class class_name {
public static List<DMNResource> sort(List<DMNResource> ins) {
// In a graph A -> B -> {C, D}
// showing that A requires B, and B requires C,D
// then a depth-first visit would satisfy required ordering, for example a valid depth first visit is also a valid sort here: C, D, B, A.
Collection<DMNResource> visited = new ArrayList<>(ins.size());
List<DMNResource> dfv = new ArrayList<>(ins.size());
for (DMNResource node : ins) {
if (!visited.contains(node)) {
dfVisit(node, ins, visited, dfv);
}
}
return dfv;
} } | public class class_name {
public static List<DMNResource> sort(List<DMNResource> ins) {
// In a graph A -> B -> {C, D}
// showing that A requires B, and B requires C,D
// then a depth-first visit would satisfy required ordering, for example a valid depth first visit is also a valid sort here: C, D, B, A.
Collection<DMNResource> visited = new ArrayList<>(ins.size());
List<DMNResource> dfv = new ArrayList<>(ins.size());
for (DMNResource node : ins) {
if (!visited.contains(node)) {
dfVisit(node, ins, visited, dfv); // depends on control dependency: [if], data = [none]
}
}
return dfv;
} } |
public class class_name {
public static String random(int len) {
final char[] chars = {'0', '1', '2', '3', '4',
'5', '6', '7', '8', '9', '$', '#', '^', '&', '_',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z',
'~', '!', '@'};
final int max = chars.length;
Random r = new Random();
StringBuilder sb = new StringBuilder(len);
while(len-- > 0) {
int i = r.nextInt(max);
sb.append(chars[i]);
}
return sb.toString();
} } | public class class_name {
public static String random(int len) {
final char[] chars = {'0', '1', '2', '3', '4',
'5', '6', '7', '8', '9', '$', '#', '^', '&', '_',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z',
'~', '!', '@'};
final int max = chars.length;
Random r = new Random();
StringBuilder sb = new StringBuilder(len);
while(len-- > 0) {
int i = r.nextInt(max);
sb.append(chars[i]); // depends on control dependency: [while], data = [none]
}
return sb.toString();
} } |
public class class_name {
public static void constraintMatrix6x3( DMatrixRMaj L_6x10 , DMatrixRMaj L_6x3 ) {
int index = 0;
for( int i = 0; i < 6; i++ ) {
L_6x3.data[index++] = L_6x10.get(i,0);
L_6x3.data[index++] = L_6x10.get(i,1);
L_6x3.data[index++] = L_6x10.get(i,4);
}
} } | public class class_name {
public static void constraintMatrix6x3( DMatrixRMaj L_6x10 , DMatrixRMaj L_6x3 ) {
int index = 0;
for( int i = 0; i < 6; i++ ) {
L_6x3.data[index++] = L_6x10.get(i,0); // depends on control dependency: [for], data = [i]
L_6x3.data[index++] = L_6x10.get(i,1); // depends on control dependency: [for], data = [i]
L_6x3.data[index++] = L_6x10.get(i,4); // depends on control dependency: [for], data = [i]
}
} } |
public class class_name {
public void record(CircuitBreakerStateImpl.CircuitBreakerResult result) {
boolean isFailure = (result == FAILURE);
if (resultCount < size) {
// Window is not yet full
resultCount++;
} else {
// Window is full, roll off the oldest result
boolean oldestResultIsFailure = results.get(nextResultIndex);
if (oldestResultIsFailure) {
failures--;
}
}
results.set(nextResultIndex, isFailure);
if (isFailure) {
failures++;
}
nextResultIndex++;
if (nextResultIndex >= size) {
nextResultIndex = 0;
}
} } | public class class_name {
public void record(CircuitBreakerStateImpl.CircuitBreakerResult result) {
boolean isFailure = (result == FAILURE);
if (resultCount < size) {
// Window is not yet full
resultCount++; // depends on control dependency: [if], data = [none]
} else {
// Window is full, roll off the oldest result
boolean oldestResultIsFailure = results.get(nextResultIndex);
if (oldestResultIsFailure) {
failures--; // depends on control dependency: [if], data = [none]
}
}
results.set(nextResultIndex, isFailure);
if (isFailure) {
failures++; // depends on control dependency: [if], data = [none]
}
nextResultIndex++;
if (nextResultIndex >= size) {
nextResultIndex = 0; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
void handleGet(Object value, MatchSpaceKey msg, EvalCache cache, Object contextValue,
SearchResults result) throws MatchingException, BadMessageFormatMatchingException
{
if (tc.isEntryEnabled())
tc.entry(this,cclass, "handleGet", new Object[] {value,msg,cache,contextValue,result});
if (!(value instanceof Number)) { // was NumericValue
return;
}
List inexact = ranges.find((Number) value); // was NumericValue
for (int i = 0; i < inexact.size(); i++)
((ContentMatcher) inexact.get(i)).get(null, msg, cache, contextValue, result);
if (haveEqualityMatches())
handleEqualityGet(new Wrapper(value), msg, cache, contextValue, result);
if (tc.isEntryEnabled())
tc.exit(this,cclass, "handleGet");
} } | public class class_name {
void handleGet(Object value, MatchSpaceKey msg, EvalCache cache, Object contextValue,
SearchResults result) throws MatchingException, BadMessageFormatMatchingException
{
if (tc.isEntryEnabled())
tc.entry(this,cclass, "handleGet", new Object[] {value,msg,cache,contextValue,result});
if (!(value instanceof Number)) { // was NumericValue
return; // depends on control dependency: [if], data = [none]
}
List inexact = ranges.find((Number) value); // was NumericValue
for (int i = 0; i < inexact.size(); i++)
((ContentMatcher) inexact.get(i)).get(null, msg, cache, contextValue, result);
if (haveEqualityMatches())
handleEqualityGet(new Wrapper(value), msg, cache, contextValue, result);
if (tc.isEntryEnabled())
tc.exit(this,cclass, "handleGet");
} } |
public class class_name {
public java.lang.String getInstanceClass() {
java.lang.Object ref = instanceClass_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
instanceClass_ = s;
return s;
}
} } | public class class_name {
public java.lang.String getInstanceClass() {
java.lang.Object ref = instanceClass_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref; // depends on control dependency: [if], data = [none]
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
instanceClass_ = s; // depends on control dependency: [if], data = [none]
return s; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public Img pressText(String pressText, Color color, Font font, int x, int y, float alpha) {
final BufferedImage targetImage = getValidSrcImg();
final Graphics2D g = targetImage.createGraphics();
if(null == font) {
// 默认字体
font = new Font("Courier", Font.PLAIN, (int)(targetImage.getHeight() * 0.75));
}
// 抗锯齿
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(color);
g.setFont(font);
// 透明度
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
// 在指定坐标绘制水印文字
final FontMetrics metrics = g.getFontMetrics(font);
final int textLength = metrics.stringWidth(pressText);
final int textHeight = metrics.getAscent() - metrics.getLeading() - metrics.getDescent();
g.drawString(pressText, Math.abs(targetImage.getWidth() - textLength) / 2 + x, Math.abs(targetImage.getHeight() + textHeight) / 2 + y);
g.dispose();
this.targetImage = targetImage;
return this;
} } | public class class_name {
public Img pressText(String pressText, Color color, Font font, int x, int y, float alpha) {
final BufferedImage targetImage = getValidSrcImg();
final Graphics2D g = targetImage.createGraphics();
if(null == font) {
// 默认字体
font = new Font("Courier", Font.PLAIN, (int)(targetImage.getHeight() * 0.75));
// depends on control dependency: [if], data = [none]
}
// 抗锯齿
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(color);
g.setFont(font);
// 透明度
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
// 在指定坐标绘制水印文字
final FontMetrics metrics = g.getFontMetrics(font);
final int textLength = metrics.stringWidth(pressText);
final int textHeight = metrics.getAscent() - metrics.getLeading() - metrics.getDescent();
g.drawString(pressText, Math.abs(targetImage.getWidth() - textLength) / 2 + x, Math.abs(targetImage.getHeight() + textHeight) / 2 + y);
g.dispose();
this.targetImage = targetImage;
return this;
} } |
public class class_name {
private String getValueString(int signum, String intString, int scale) {
/* Insert decimal point */
StringBuilder buf;
int insertionPoint = intString.length() - scale;
if (insertionPoint == 0) { /* Point goes right before intVal */
return (signum<0 ? "-0." : "0.") + intString;
} else if (insertionPoint > 0) { /* Point goes inside intVal */
buf = new StringBuilder(intString);
buf.insert(insertionPoint, '.');
if (signum < 0)
buf.insert(0, '-');
} else { /* We must insert zeros between point and intVal */
buf = new StringBuilder(3-insertionPoint + intString.length());
buf.append(signum<0 ? "-0." : "0.");
for (int i=0; i<-insertionPoint; i++)
buf.append('0');
buf.append(intString);
}
return buf.toString();
} } | public class class_name {
private String getValueString(int signum, String intString, int scale) {
/* Insert decimal point */
StringBuilder buf;
int insertionPoint = intString.length() - scale;
if (insertionPoint == 0) { /* Point goes right before intVal */
return (signum<0 ? "-0." : "0.") + intString; // depends on control dependency: [if], data = [none]
} else if (insertionPoint > 0) { /* Point goes inside intVal */
buf = new StringBuilder(intString); // depends on control dependency: [if], data = [none]
buf.insert(insertionPoint, '.'); // depends on control dependency: [if], data = [(insertionPoint]
if (signum < 0)
buf.insert(0, '-');
} else { /* We must insert zeros between point and intVal */
buf = new StringBuilder(3-insertionPoint + intString.length()); // depends on control dependency: [if], data = [none]
buf.append(signum<0 ? "-0." : "0."); // depends on control dependency: [if], data = [none]
for (int i=0; i<-insertionPoint; i++)
buf.append('0');
buf.append(intString); // depends on control dependency: [if], data = [none]
}
return buf.toString();
} } |
public class class_name {
public static Get get(String url, int connectTimeout, int readTimeout) {
try {
return new Get(url, connectTimeout, readTimeout);
} catch (Exception e) {
throw new HttpException("Failed URL: " + url, e);
}
} } | public class class_name {
public static Get get(String url, int connectTimeout, int readTimeout) {
try {
return new Get(url, connectTimeout, readTimeout); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new HttpException("Failed URL: " + url, e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public String translate(Delete d) {
final Expression table = d.getTable();
final Expression where = d.getWhere();
inject(table, where);
final List<String> temp = new ArrayList<>();
temp.add("DELETE FROM");
temp.add(table.translate());
if (where != null) {
temp.add("WHERE");
temp.add(where.translate());
}
return Joiner.on(" ").join(temp);
} } | public class class_name {
public String translate(Delete d) {
final Expression table = d.getTable();
final Expression where = d.getWhere();
inject(table, where);
final List<String> temp = new ArrayList<>();
temp.add("DELETE FROM");
temp.add(table.translate());
if (where != null) {
temp.add("WHERE"); // depends on control dependency: [if], data = [none]
temp.add(where.translate()); // depends on control dependency: [if], data = [(where]
}
return Joiner.on(" ").join(temp);
} } |
public class class_name {
public static final String GET_STG_NAME(STGroup stg){
String ret = null;
if(stg instanceof STGroupFile){
ret = ((STGroupFile)stg).fileName;
}
else if(stg instanceof STGroupString){
ret = ((STGroupString)stg).sourceName;
}
else if(stg instanceof STGroupDir){
ret = ((STGroupDir)stg).groupDirName;
}
return StringUtils.substringBeforeLast(ret, ".");
} } | public class class_name {
public static final String GET_STG_NAME(STGroup stg){
String ret = null;
if(stg instanceof STGroupFile){
ret = ((STGroupFile)stg).fileName; // depends on control dependency: [if], data = [none]
}
else if(stg instanceof STGroupString){
ret = ((STGroupString)stg).sourceName; // depends on control dependency: [if], data = [none]
}
else if(stg instanceof STGroupDir){
ret = ((STGroupDir)stg).groupDirName; // depends on control dependency: [if], data = [none]
}
return StringUtils.substringBeforeLast(ret, ".");
} } |
public class class_name {
protected T removeClient(Server server) {
T client = rxClientCache.remove(server);
if (client != null) {
client.shutdown();
}
return client;
} } | public class class_name {
protected T removeClient(Server server) {
T client = rxClientCache.remove(server);
if (client != null) {
client.shutdown(); // depends on control dependency: [if], data = [none]
}
return client;
} } |
public class class_name {
public String toHtml() {
CmsMacroResolver resolver = new CmsMacroResolver();
if (CmsStringUtil.isEmpty(m_title)) {
m_title = m_messages.key(Messages.GUI_ERROR_0, new Object[] {});
}
resolver.addMacro("title", m_title);
resolver.addMacro("label_error", m_messages.key(Messages.GUI_ERROR_0, new Object[] {}));
resolver.addMacro("errorstack", CmsException.getFormattedErrorstack(m_throwable));
resolver.addMacro("message", CmsStringUtil.escapeHtml(getErrorMessage()));
resolver.addMacro(
"styleuri",
OpenCms.getLinkManager().substituteLink(m_cms, "/system/workplace/commons/style/workplace.css"));
if (CmsStringUtil.isEmpty(m_buttons)) {
resolver.addMacro("buttons", getDefaultButtonsHtml());
} else {
resolver.addMacro("buttons", m_buttons);
resolver.addMacro("paramaction", m_paramAction);
}
if (CmsStringUtil.isNotEmpty(m_hiddenParams)) {
resolver.addMacro("hiddenparams", m_hiddenParams);
}
resolver.addMacro(
"erroricon",
OpenCms.getLinkManager().substituteLink(m_cms, "/system/workplace/resources/commons/error.png"));
Properties errorpage = new Properties();
try {
errorpage.load(CmsErrorBean.class.getClassLoader().getResourceAsStream(ERRORPAGE));
} catch (Throwable th) {
CmsLog.INIT.error(
org.opencms.main.Messages.get().getBundle().key(
org.opencms.main.Messages.INIT_ERR_LOAD_HTML_PROPERTY_FILE_1,
ERRORPAGE),
th);
}
return resolver.resolveMacros(errorpage.getProperty("ERRORPAGE"));
} } | public class class_name {
public String toHtml() {
CmsMacroResolver resolver = new CmsMacroResolver();
if (CmsStringUtil.isEmpty(m_title)) {
m_title = m_messages.key(Messages.GUI_ERROR_0, new Object[] {}); // depends on control dependency: [if], data = [none]
}
resolver.addMacro("title", m_title);
resolver.addMacro("label_error", m_messages.key(Messages.GUI_ERROR_0, new Object[] {}));
resolver.addMacro("errorstack", CmsException.getFormattedErrorstack(m_throwable));
resolver.addMacro("message", CmsStringUtil.escapeHtml(getErrorMessage()));
resolver.addMacro(
"styleuri",
OpenCms.getLinkManager().substituteLink(m_cms, "/system/workplace/commons/style/workplace.css"));
if (CmsStringUtil.isEmpty(m_buttons)) {
resolver.addMacro("buttons", getDefaultButtonsHtml());
} else {
resolver.addMacro("buttons", m_buttons);
resolver.addMacro("paramaction", m_paramAction);
}
if (CmsStringUtil.isNotEmpty(m_hiddenParams)) {
resolver.addMacro("hiddenparams", m_hiddenParams);
}
resolver.addMacro(
"erroricon",
OpenCms.getLinkManager().substituteLink(m_cms, "/system/workplace/resources/commons/error.png"));
Properties errorpage = new Properties();
try {
errorpage.load(CmsErrorBean.class.getClassLoader().getResourceAsStream(ERRORPAGE));
} catch (Throwable th) {
CmsLog.INIT.error(
org.opencms.main.Messages.get().getBundle().key(
org.opencms.main.Messages.INIT_ERR_LOAD_HTML_PROPERTY_FILE_1,
ERRORPAGE),
th);
}
return resolver.resolveMacros(errorpage.getProperty("ERRORPAGE"));
} } |
public class class_name {
public ArrayList<WebSeedEntry> webSeeds() {
web_seed_entry_vector v = ti.web_seeds();
int size = (int) v.size();
ArrayList<WebSeedEntry> l = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
l.add(new WebSeedEntry(v.get(i)));
}
return l;
} } | public class class_name {
public ArrayList<WebSeedEntry> webSeeds() {
web_seed_entry_vector v = ti.web_seeds();
int size = (int) v.size();
ArrayList<WebSeedEntry> l = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
l.add(new WebSeedEntry(v.get(i))); // depends on control dependency: [for], data = [i]
}
return l;
} } |
public class class_name {
private void writeGetter(final JavaClassSource javaClass, final Property propDef) {
if (propDef.needGetter()) {
if (!javaClass.hasMethodSignature(propDef.name())) {
final StringBuilder javadoc = new StringBuilder();
javadoc
.append("@return the sourcePath\n");
String body = "";
if (propDef.isList()) {
javaClass.addImport("java.util.stream.Collectors");
javaClass.addImport("java.util.ArrayList");
body = Templates.use(TemplateName.Getter_List, propDef);
} else if (propDef.isMap()) {
javaClass.addImport("java.util.stream.Collectors");
javaClass.addImport("java.util.HashMap");
body = Templates.use(TemplateName.Getter_Map, propDef);
} else {
body = Templates.use(TemplateName.Getter, propDef);
}
final MethodSource<?> method = javaClass.addMethod()
.setName(propDef.name())
.setPublic()
.setBody(body)
.setReturnType(propDef.type().qualifiedName());
method.getJavaDoc().setFullText(javadoc.toString());
} else {
// javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody()
// + body.toString());
}
}
} } | public class class_name {
private void writeGetter(final JavaClassSource javaClass, final Property propDef) {
if (propDef.needGetter()) {
if (!javaClass.hasMethodSignature(propDef.name())) {
final StringBuilder javadoc = new StringBuilder();
javadoc
.append("@return the sourcePath\n"); // depends on control dependency: [if], data = [none]
String body = "";
if (propDef.isList()) {
javaClass.addImport("java.util.stream.Collectors"); // depends on control dependency: [if], data = [none]
javaClass.addImport("java.util.ArrayList"); // depends on control dependency: [if], data = [none]
body = Templates.use(TemplateName.Getter_List, propDef); // depends on control dependency: [if], data = [none]
} else if (propDef.isMap()) {
javaClass.addImport("java.util.stream.Collectors"); // depends on control dependency: [if], data = [none]
javaClass.addImport("java.util.HashMap"); // depends on control dependency: [if], data = [none]
body = Templates.use(TemplateName.Getter_Map, propDef); // depends on control dependency: [if], data = [none]
} else {
body = Templates.use(TemplateName.Getter, propDef); // depends on control dependency: [if], data = [none]
}
final MethodSource<?> method = javaClass.addMethod()
.setName(propDef.name())
.setPublic()
.setBody(body)
.setReturnType(propDef.type().qualifiedName());
method.getJavaDoc().setFullText(javadoc.toString()); // depends on control dependency: [if], data = [none]
} else {
// javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody()
// + body.toString());
}
}
} } |
public class class_name {
@Nonnull
public static String getIRIFromNodeID(String nodeID) {
if (nodeID.startsWith(PREFIX_SHARED_NODE)) {
return nodeID;
}
return PREFIX_SHARED_NODE + nodeID.replace(NODE_ID_PREFIX, "");
} } | public class class_name {
@Nonnull
public static String getIRIFromNodeID(String nodeID) {
if (nodeID.startsWith(PREFIX_SHARED_NODE)) {
return nodeID; // depends on control dependency: [if], data = [none]
}
return PREFIX_SHARED_NODE + nodeID.replace(NODE_ID_PREFIX, "");
} } |
public class class_name {
static @Nullable LogMonitorSession readCurrentSession(Context context) {
if (context == null) {
throw new IllegalArgumentException("Context is null");
}
SharedPreferences prefs = getPrefs(context);
if (!prefs.contains(PREFS_KEY_EMAIL_RECIPIENTS)) {
return null;
}
LogMonitorSession session = new LogMonitorSession();
session.restored = true;
String emailRecipients = prefs.getString(PREFS_KEY_EMAIL_RECIPIENTS, null);
if (!StringUtils.isNullOrEmpty(emailRecipients)) {
session.emailRecipients = emailRecipients.split(",");
}
return session;
} } | public class class_name {
static @Nullable LogMonitorSession readCurrentSession(Context context) {
if (context == null) {
throw new IllegalArgumentException("Context is null");
}
SharedPreferences prefs = getPrefs(context);
if (!prefs.contains(PREFS_KEY_EMAIL_RECIPIENTS)) {
return null; // depends on control dependency: [if], data = [none]
}
LogMonitorSession session = new LogMonitorSession();
session.restored = true;
String emailRecipients = prefs.getString(PREFS_KEY_EMAIL_RECIPIENTS, null);
if (!StringUtils.isNullOrEmpty(emailRecipients)) {
session.emailRecipients = emailRecipients.split(","); // depends on control dependency: [if], data = [none]
}
return session;
} } |
public class class_name {
private DataAppendResult append(StoreTxLogPosition storeTxLogPosition, byte[] dataBytes) throws IOException {
DataBlock writeBlock = getWriteDataBlock();
try {
return writeBlock.append(storeTxLogPosition, dataBytes);
} catch (CapacityNotEnoughException e) {
if (!readonlyBlocks.contains(writeBlock)) {
readonlyBlocks.add(writeBlock);
}
writableBlocks.remove(writeBlock);
return append(storeTxLogPosition, dataBytes);
}
} } | public class class_name {
private DataAppendResult append(StoreTxLogPosition storeTxLogPosition, byte[] dataBytes) throws IOException {
DataBlock writeBlock = getWriteDataBlock();
try {
return writeBlock.append(storeTxLogPosition, dataBytes);
} catch (CapacityNotEnoughException e) {
if (!readonlyBlocks.contains(writeBlock)) {
readonlyBlocks.add(writeBlock); // depends on control dependency: [if], data = [none]
}
writableBlocks.remove(writeBlock);
return append(storeTxLogPosition, dataBytes);
}
} } |
public class class_name {
boolean tx(Config config, int transactionLevel, IAtom atom) {
Connection conn = config.getThreadLocalConnection();
if (conn != null) { // Nested transaction support
try {
if (conn.getTransactionIsolation() < transactionLevel)
conn.setTransactionIsolation(transactionLevel);
boolean result = atom.run();
if (result)
return true;
throw new NestedTransactionHelpException("Notice the outer transaction that the nested transaction return false"); // important:can not return false
}
catch (SQLException e) {
throw new ActiveRecordException(e);
}
}
Boolean autoCommit = null;
try {
conn = config.getConnection();
autoCommit = conn.getAutoCommit();
config.setThreadLocalConnection(conn);
conn.setTransactionIsolation(transactionLevel);
conn.setAutoCommit(false);
boolean result = atom.run();
if (result)
conn.commit();
else
conn.rollback();
return result;
} catch (NestedTransactionHelpException e) {
if (conn != null) try {conn.rollback();} catch (Exception e1) {LogKit.error(e1.getMessage(), e1);}
LogKit.logNothing(e);
return false;
} catch (Throwable t) {
if (conn != null) try {conn.rollback();} catch (Exception e1) {LogKit.error(e1.getMessage(), e1);}
throw t instanceof RuntimeException ? (RuntimeException)t : new ActiveRecordException(t);
} finally {
try {
if (conn != null) {
if (autoCommit != null)
conn.setAutoCommit(autoCommit);
conn.close();
}
} catch (Throwable t) {
LogKit.error(t.getMessage(), t); // can not throw exception here, otherwise the more important exception in previous catch block can not be thrown
} finally {
config.removeThreadLocalConnection(); // prevent memory leak
}
}
} } | public class class_name {
boolean tx(Config config, int transactionLevel, IAtom atom) {
Connection conn = config.getThreadLocalConnection();
if (conn != null) { // Nested transaction support
try {
if (conn.getTransactionIsolation() < transactionLevel)
conn.setTransactionIsolation(transactionLevel);
boolean result = atom.run();
if (result)
return true;
throw new NestedTransactionHelpException("Notice the outer transaction that the nested transaction return false"); // important:can not return false
}
catch (SQLException e) {
throw new ActiveRecordException(e);
}
// depends on control dependency: [catch], data = [none]
}
Boolean autoCommit = null;
try {
conn = config.getConnection();
// depends on control dependency: [try], data = [none]
autoCommit = conn.getAutoCommit();
// depends on control dependency: [try], data = [none]
config.setThreadLocalConnection(conn);
// depends on control dependency: [try], data = [none]
conn.setTransactionIsolation(transactionLevel);
// depends on control dependency: [try], data = [none]
conn.setAutoCommit(false);
// depends on control dependency: [try], data = [none]
boolean result = atom.run();
if (result)
conn.commit();
else
conn.rollback();
return result;
// depends on control dependency: [try], data = [none]
} catch (NestedTransactionHelpException e) {
if (conn != null) try {conn.rollback();} catch (Exception e1) {LogKit.error(e1.getMessage(), e1);}
// depends on control dependency: [try], data = [none] // depends on control dependency: [catch], data = [none]
LogKit.logNothing(e);
return false;
} catch (Throwable t) {
// depends on control dependency: [catch], data = [none]
if (conn != null) try {conn.rollback();} catch (Exception e1) {LogKit.error(e1.getMessage(), e1);}
// depends on control dependency: [try], data = [none] // depends on control dependency: [catch], data = [none]
throw t instanceof RuntimeException ? (RuntimeException)t : new ActiveRecordException(t);
} finally {
// depends on control dependency: [catch], data = [none]
try {
if (conn != null) {
if (autoCommit != null)
conn.setAutoCommit(autoCommit);
conn.close();
// depends on control dependency: [if], data = [none]
}
} catch (Throwable t) {
LogKit.error(t.getMessage(), t); // can not throw exception here, otherwise the more important exception in previous catch block can not be thrown
} finally {
// depends on control dependency: [catch], data = [none]
config.removeThreadLocalConnection(); // prevent memory leak
}
}
} } |
public class class_name {
static List<String> parseExpressionParameters(String expressionPart) {
int parenthesisOpenPos = expressionPart.indexOf('(');
int parenthesisClosePos = expressionPart.lastIndexOf(')');
if (parenthesisOpenPos > 0 && parenthesisClosePos > 0) {
expressionPart = expressionPart.substring(parenthesisOpenPos + 1,
parenthesisClosePos);
}
if (expressionPart.isEmpty()) {
return Collections.emptyList();
}
return Arrays.asList(expressionPart.split(","));
} } | public class class_name {
static List<String> parseExpressionParameters(String expressionPart) {
int parenthesisOpenPos = expressionPart.indexOf('(');
int parenthesisClosePos = expressionPart.lastIndexOf(')');
if (parenthesisOpenPos > 0 && parenthesisClosePos > 0) {
expressionPart = expressionPart.substring(parenthesisOpenPos + 1,
parenthesisClosePos); // depends on control dependency: [if], data = [(parenthesisOpenPos]
}
if (expressionPart.isEmpty()) {
return Collections.emptyList(); // depends on control dependency: [if], data = [none]
}
return Arrays.asList(expressionPart.split(","));
} } |
public class class_name {
private void compareObjectNodes(Context context) {
Node expected = context.getExpectedNode();
Node actual = context.getActualNode();
Path path = context.getActualPath();
Map<String, Node> expectedFields = getFields(expected);
Map<String, Node> actualFields = getFields(actual);
Set<String> expectedKeys = expectedFields.keySet();
Set<String> actualKeys = actualFields.keySet();
if (!expectedKeys.equals(actualKeys)) {
Set<String> missingKeys = getMissingKeys(expectedKeys, actualKeys);
Set<String> extraKeys = getExtraKeys(expectedKeys, actualKeys);
if (hasOption(Option.TREATING_NULL_AS_ABSENT)) {
extraKeys = getNotNullExtraKeys(actual, extraKeys);
}
removePathsToBeIgnored(path, extraKeys);
removeMissingIgnoredElements(expected, missingKeys);
if (!missingKeys.isEmpty() || !extraKeys.isEmpty()) {
for (String key : missingKeys) {
reportDifference(DifferenceImpl.missing(context.inField(key)));
}
for (String key : extraKeys) {
reportDifference(DifferenceImpl.extra(context.inField(key)));
}
String missingKeysMessage = getMissingKeysMessage(missingKeys, path);
String extraKeysMessage = getExtraKeysMessage(extraKeys, path);
structureDifferenceFound(context, "Different keys found in node \"%s\"%s%s, " + differenceString(), path, missingKeysMessage, extraKeysMessage, normalize(expected), normalize(actual));
}
}
for (String fieldName : commonFields(expectedFields, actualFields)) {
compareNodes(context.inField(fieldName));
}
} } | public class class_name {
private void compareObjectNodes(Context context) {
Node expected = context.getExpectedNode();
Node actual = context.getActualNode();
Path path = context.getActualPath();
Map<String, Node> expectedFields = getFields(expected);
Map<String, Node> actualFields = getFields(actual);
Set<String> expectedKeys = expectedFields.keySet();
Set<String> actualKeys = actualFields.keySet();
if (!expectedKeys.equals(actualKeys)) {
Set<String> missingKeys = getMissingKeys(expectedKeys, actualKeys);
Set<String> extraKeys = getExtraKeys(expectedKeys, actualKeys);
if (hasOption(Option.TREATING_NULL_AS_ABSENT)) {
extraKeys = getNotNullExtraKeys(actual, extraKeys); // depends on control dependency: [if], data = [none]
}
removePathsToBeIgnored(path, extraKeys); // depends on control dependency: [if], data = [none]
removeMissingIgnoredElements(expected, missingKeys); // depends on control dependency: [if], data = [none]
if (!missingKeys.isEmpty() || !extraKeys.isEmpty()) {
for (String key : missingKeys) {
reportDifference(DifferenceImpl.missing(context.inField(key))); // depends on control dependency: [for], data = [key]
}
for (String key : extraKeys) {
reportDifference(DifferenceImpl.extra(context.inField(key))); // depends on control dependency: [for], data = [key]
}
String missingKeysMessage = getMissingKeysMessage(missingKeys, path);
String extraKeysMessage = getExtraKeysMessage(extraKeys, path);
structureDifferenceFound(context, "Different keys found in node \"%s\"%s%s, " + differenceString(), path, missingKeysMessage, extraKeysMessage, normalize(expected), normalize(actual)); // depends on control dependency: [if], data = [none]
}
}
for (String fieldName : commonFields(expectedFields, actualFields)) {
compareNodes(context.inField(fieldName)); // depends on control dependency: [for], data = [fieldName]
}
} } |
public class class_name {
public HumanTaskConfig withTaskKeywords(String... taskKeywords) {
if (this.taskKeywords == null) {
setTaskKeywords(new java.util.ArrayList<String>(taskKeywords.length));
}
for (String ele : taskKeywords) {
this.taskKeywords.add(ele);
}
return this;
} } | public class class_name {
public HumanTaskConfig withTaskKeywords(String... taskKeywords) {
if (this.taskKeywords == null) {
setTaskKeywords(new java.util.ArrayList<String>(taskKeywords.length)); // depends on control dependency: [if], data = [none]
}
for (String ele : taskKeywords) {
this.taskKeywords.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
int completeTransaction(Xid xid, boolean commit) {
try {
TransactionOperationFactory factory = assertStartedAndReturnFactory();
CompleteTransactionOperation operation = factory.newCompleteTransactionOperation(xid, commit);
return operation.execute().get();
} catch (Exception e) {
getLog().debug("Exception while commit/rollback.", e);
return XAException.XA_HEURRB; //heuristically rolled-back
}
} } | public class class_name {
int completeTransaction(Xid xid, boolean commit) {
try {
TransactionOperationFactory factory = assertStartedAndReturnFactory();
CompleteTransactionOperation operation = factory.newCompleteTransactionOperation(xid, commit);
return operation.execute().get(); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
getLog().debug("Exception while commit/rollback.", e);
return XAException.XA_HEURRB; //heuristically rolled-back
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void evaluate(DoubleSolution solution) {
int numberOfVariables = getNumberOfVariables();
int numberOfObjectives = getNumberOfObjectives();
double[] f = new double[numberOfObjectives];
double[] x = new double[numberOfVariables] ;
for (int i = 0; i < numberOfVariables; i++) {
x[i] = solution.getVariableValue(i) ;
}
int k = getNumberOfVariables() - getNumberOfObjectives() + 1;
double g = 0.0;
for (int i = numberOfVariables - k; i < numberOfVariables; i++) {
g += (x[i] - 0.5) * (x[i] - 0.5);
}
for (int i = 0; i < numberOfObjectives; i++) {
f[i] = 1.0 + g;
}
for (int i = 0; i < numberOfObjectives; i++) {
for (int j = 0; j < numberOfObjectives - (i + 1); j++) {
f[i] *= Math.cos(x[j] * 0.5 * Math.PI);
}
if (i != 0) {
int aux = numberOfObjectives - (i + 1);
f[i] *= Math.sin(x[aux] * 0.5 * Math.PI);
}
}
for (int i = 0; i < numberOfObjectives; i++) {
solution.setObjective(i, f[i]);
}
} } | public class class_name {
public void evaluate(DoubleSolution solution) {
int numberOfVariables = getNumberOfVariables();
int numberOfObjectives = getNumberOfObjectives();
double[] f = new double[numberOfObjectives];
double[] x = new double[numberOfVariables] ;
for (int i = 0; i < numberOfVariables; i++) {
x[i] = solution.getVariableValue(i) ;
// depends on control dependency: [for], data = [i]
}
int k = getNumberOfVariables() - getNumberOfObjectives() + 1;
double g = 0.0;
for (int i = numberOfVariables - k; i < numberOfVariables; i++) {
g += (x[i] - 0.5) * (x[i] - 0.5);
// depends on control dependency: [for], data = [i]
}
for (int i = 0; i < numberOfObjectives; i++) {
f[i] = 1.0 + g;
// depends on control dependency: [for], data = [i]
}
for (int i = 0; i < numberOfObjectives; i++) {
for (int j = 0; j < numberOfObjectives - (i + 1); j++) {
f[i] *= Math.cos(x[j] * 0.5 * Math.PI);
// depends on control dependency: [for], data = [j]
}
if (i != 0) {
int aux = numberOfObjectives - (i + 1);
f[i] *= Math.sin(x[aux] * 0.5 * Math.PI);
// depends on control dependency: [if], data = [none]
}
}
for (int i = 0; i < numberOfObjectives; i++) {
solution.setObjective(i, f[i]);
// depends on control dependency: [for], data = [i]
}
} } |
public class class_name {
public void clearProxyObject (int origObjectId, DObject object)
{
if (_proxies.remove(object.getOid()) == null) {
log.warning("Missing proxy mapping for cleared proxy", "ooid", origObjectId);
}
_objects.remove(object.getOid());
} } | public class class_name {
public void clearProxyObject (int origObjectId, DObject object)
{
if (_proxies.remove(object.getOid()) == null) {
log.warning("Missing proxy mapping for cleared proxy", "ooid", origObjectId); // depends on control dependency: [if], data = [none]
}
_objects.remove(object.getOid());
} } |
public class class_name {
private ImmutableList<MemberDefinition> parseReadOnlyProperties(
final PolymerClassDefinition cls, Node block) {
String qualifiedPath = cls.target.getQualifiedName() + ".prototype.";
ImmutableList.Builder<MemberDefinition> readOnlyProps = ImmutableList.builder();
for (MemberDefinition prop : cls.props) {
// Generate the setter for readOnly properties.
if (prop.value.isObjectLit()) {
Node readOnlyValue = NodeUtil.getFirstPropMatchingKey(prop.value, "readOnly");
if (readOnlyValue != null && readOnlyValue.isTrue()) {
Node setter = makeReadOnlySetter(prop.name.getString(), qualifiedPath);
setter.useSourceInfoIfMissingFromForTree(prop.name);
block.addChildToBack(setter);
readOnlyProps.add(prop);
}
}
}
return readOnlyProps.build();
} } | public class class_name {
private ImmutableList<MemberDefinition> parseReadOnlyProperties(
final PolymerClassDefinition cls, Node block) {
String qualifiedPath = cls.target.getQualifiedName() + ".prototype.";
ImmutableList.Builder<MemberDefinition> readOnlyProps = ImmutableList.builder();
for (MemberDefinition prop : cls.props) {
// Generate the setter for readOnly properties.
if (prop.value.isObjectLit()) {
Node readOnlyValue = NodeUtil.getFirstPropMatchingKey(prop.value, "readOnly");
if (readOnlyValue != null && readOnlyValue.isTrue()) {
Node setter = makeReadOnlySetter(prop.name.getString(), qualifiedPath);
setter.useSourceInfoIfMissingFromForTree(prop.name); // depends on control dependency: [if], data = [none]
block.addChildToBack(setter); // depends on control dependency: [if], data = [none]
readOnlyProps.add(prop); // depends on control dependency: [if], data = [none]
}
}
}
return readOnlyProps.build();
} } |
public class class_name {
@Override
public Record nextRecord() {
Object[] next = iter.next();
invokeListeners(next);
URI location;
try {
location = new URI(conn.getMetaData().getURL());
} catch (SQLException | URISyntaxException e) {
throw new IllegalStateException("Could not get sql connection metadata", e);
}
List<Object> params = new ArrayList<>();
if (metadataIndices != null) {
for (int index : metadataIndices) {
params.add(next[index]);
}
}
RecordMetaDataJdbc rmd = new RecordMetaDataJdbc(location, this.metadataQuery, params, getClass());
return new org.datavec.api.records.impl.Record(toWritable(next), rmd);
} } | public class class_name {
@Override
public Record nextRecord() {
Object[] next = iter.next();
invokeListeners(next);
URI location;
try {
location = new URI(conn.getMetaData().getURL()); // depends on control dependency: [try], data = [none]
} catch (SQLException | URISyntaxException e) {
throw new IllegalStateException("Could not get sql connection metadata", e);
} // depends on control dependency: [catch], data = [none]
List<Object> params = new ArrayList<>();
if (metadataIndices != null) {
for (int index : metadataIndices) {
params.add(next[index]); // depends on control dependency: [for], data = [index]
}
}
RecordMetaDataJdbc rmd = new RecordMetaDataJdbc(location, this.metadataQuery, params, getClass());
return new org.datavec.api.records.impl.Record(toWritable(next), rmd);
} } |
public class class_name {
private void fireNamingObjectEvent(TrackingObject to)
{
Object[] copy;
if (_listeners == null)
return;
// create a copy of the listeners so that there isn't any modifications while we
// fire the events.
synchronized (_listeners) { copy = _listeners.toArray(); }
INameable o = (INameable) to.getWeakINameable().get();
for (int i = 0; i < copy.length; i++) {
((NamingObjectListener)copy[i]).namingObject(o, to);
}
} } | public class class_name {
private void fireNamingObjectEvent(TrackingObject to)
{
Object[] copy;
if (_listeners == null)
return;
// create a copy of the listeners so that there isn't any modifications while we
// fire the events.
synchronized (_listeners) { copy = _listeners.toArray(); }
INameable o = (INameable) to.getWeakINameable().get();
for (int i = 0; i < copy.length; i++) {
((NamingObjectListener)copy[i]).namingObject(o, to); // depends on control dependency: [for], data = [i]
}
} } |
public class class_name {
public static long parseSize(final String propertyName, final String propertyValue)
{
final int lengthMinusSuffix = propertyValue.length() - 1;
final char lastCharacter = propertyValue.charAt(lengthMinusSuffix);
if (Character.isDigit(lastCharacter))
{
return Long.valueOf(propertyValue);
}
final long value = AsciiEncoding.parseLongAscii(propertyValue, 0, lengthMinusSuffix);
switch (lastCharacter)
{
case 'k':
case 'K':
if (value > MAX_K_VALUE)
{
throw new NumberFormatException(propertyName + " would overflow long: " + propertyValue);
}
return value * 1024;
case 'm':
case 'M':
if (value > MAX_M_VALUE)
{
throw new NumberFormatException(propertyName + " would overflow long: " + propertyValue);
}
return value * 1024 * 1024;
case 'g':
case 'G':
if (value > MAX_G_VALUE)
{
throw new NumberFormatException(propertyName + " would overflow long: " + propertyValue);
}
return value * 1024 * 1024 * 1024;
default:
throw new NumberFormatException(
propertyName + ": " + propertyValue + " should end with: k, m, or g.");
}
} } | public class class_name {
public static long parseSize(final String propertyName, final String propertyValue)
{
final int lengthMinusSuffix = propertyValue.length() - 1;
final char lastCharacter = propertyValue.charAt(lengthMinusSuffix);
if (Character.isDigit(lastCharacter))
{
return Long.valueOf(propertyValue); // depends on control dependency: [if], data = [none]
}
final long value = AsciiEncoding.parseLongAscii(propertyValue, 0, lengthMinusSuffix);
switch (lastCharacter)
{
case 'k':
case 'K':
if (value > MAX_K_VALUE)
{
throw new NumberFormatException(propertyName + " would overflow long: " + propertyValue);
}
return value * 1024;
case 'm':
case 'M':
if (value > MAX_M_VALUE)
{
throw new NumberFormatException(propertyName + " would overflow long: " + propertyValue);
}
return value * 1024 * 1024;
case 'g':
case 'G':
if (value > MAX_G_VALUE)
{
throw new NumberFormatException(propertyName + " would overflow long: " + propertyValue);
}
return value * 1024 * 1024 * 1024;
default:
throw new NumberFormatException(
propertyName + ": " + propertyValue + " should end with: k, m, or g.");
}
} } |
public class class_name {
public LDAPQuery setAttributes(List<String> attributes) {
if(attributes != null && attributes.size() > 0) {
this.attributes = new String[attributes.size()];
int i = 0;
for(String attribute : attributes) {
this.attributes[i++] = attribute;
}
} else {
this.attributes = ALL_ATTRIBUTES;
}
return this;
} } | public class class_name {
public LDAPQuery setAttributes(List<String> attributes) {
if(attributes != null && attributes.size() > 0) {
this.attributes = new String[attributes.size()]; // depends on control dependency: [if], data = [none]
int i = 0;
for(String attribute : attributes) {
this.attributes[i++] = attribute; // depends on control dependency: [for], data = [attribute]
}
} else {
this.attributes = ALL_ATTRIBUTES; // depends on control dependency: [if], data = [none]
}
return this;
} } |
public class class_name {
public static INDArray max(INDArray first, INDArray second, boolean dup) {
INDArray result = first;
if (dup) {
result = first.ulike();
}
return exec(new OldMax(first, second, result));
} } | public class class_name {
public static INDArray max(INDArray first, INDArray second, boolean dup) {
INDArray result = first;
if (dup) {
result = first.ulike(); // depends on control dependency: [if], data = [none]
}
return exec(new OldMax(first, second, result));
} } |
public class class_name {
public HttpServerExchange setDispatchExecutor(final Executor executor) {
if (executor == null) {
dispatchExecutor = null;
} else {
dispatchExecutor = executor;
}
return this;
} } | public class class_name {
public HttpServerExchange setDispatchExecutor(final Executor executor) {
if (executor == null) {
dispatchExecutor = null; // depends on control dependency: [if], data = [none]
} else {
dispatchExecutor = executor; // depends on control dependency: [if], data = [none]
}
return this;
} } |
public class class_name {
private String getSubQuerySQL(Query subQuery)
{
ClassDescriptor cld = getRoot().cld.getRepository().getDescriptorFor(subQuery.getSearchClass());
String sql;
if (subQuery instanceof QueryBySQL)
{
sql = ((QueryBySQL) subQuery).getSql();
}
else
{
sql = new SqlSelectStatement(this, m_platform, cld, subQuery, m_logger).getStatement();
}
return sql;
} } | public class class_name {
private String getSubQuerySQL(Query subQuery)
{
ClassDescriptor cld = getRoot().cld.getRepository().getDescriptorFor(subQuery.getSearchClass());
String sql;
if (subQuery instanceof QueryBySQL)
{
sql = ((QueryBySQL) subQuery).getSql();
// depends on control dependency: [if], data = [none]
}
else
{
sql = new SqlSelectStatement(this, m_platform, cld, subQuery, m_logger).getStatement();
// depends on control dependency: [if], data = [none]
}
return sql;
} } |
public class class_name {
protected Map<String, Object> updateMap(Map<String, Object> target, Map<String, Object> source) {
Map<String, Object> resultMap = new HashMap<String, Object>(target);
String keyWOClassName = null;
for (String sourceKey : source.keySet()) {
keyWOClassName = InputUtils.removeClassName(sourceKey);
if (target.containsKey(sourceKey) == true) {
resultMap.put(sourceKey, source.get(sourceKey));
} else if (target.containsKey(keyWOClassName) == true) {
resultMap.put(keyWOClassName, source.get(keyWOClassName));
}
}
return resultMap;
} } | public class class_name {
protected Map<String, Object> updateMap(Map<String, Object> target, Map<String, Object> source) {
Map<String, Object> resultMap = new HashMap<String, Object>(target);
String keyWOClassName = null;
for (String sourceKey : source.keySet()) {
keyWOClassName = InputUtils.removeClassName(sourceKey); // depends on control dependency: [for], data = [sourceKey]
if (target.containsKey(sourceKey) == true) {
resultMap.put(sourceKey, source.get(sourceKey)); // depends on control dependency: [if], data = [none]
} else if (target.containsKey(keyWOClassName) == true) {
resultMap.put(keyWOClassName, source.get(keyWOClassName)); // depends on control dependency: [if], data = [none]
}
}
return resultMap;
} } |
public class class_name {
public CreateOTAUpdateRequest withFiles(OTAUpdateFile... files) {
if (this.files == null) {
setFiles(new java.util.ArrayList<OTAUpdateFile>(files.length));
}
for (OTAUpdateFile ele : files) {
this.files.add(ele);
}
return this;
} } | public class class_name {
public CreateOTAUpdateRequest withFiles(OTAUpdateFile... files) {
if (this.files == null) {
setFiles(new java.util.ArrayList<OTAUpdateFile>(files.length)); // depends on control dependency: [if], data = [none]
}
for (OTAUpdateFile ele : files) {
this.files.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public List<XCalElement> children(ICalDataType dataType) {
String localName = dataType.getName().toLowerCase();
List<XCalElement> children = new ArrayList<XCalElement>();
for (Element child : children()) {
if (localName.equals(child.getLocalName()) && XCAL_NS.equals(child.getNamespaceURI())) {
children.add(new XCalElement(child));
}
}
return children;
} } | public class class_name {
public List<XCalElement> children(ICalDataType dataType) {
String localName = dataType.getName().toLowerCase();
List<XCalElement> children = new ArrayList<XCalElement>();
for (Element child : children()) {
if (localName.equals(child.getLocalName()) && XCAL_NS.equals(child.getNamespaceURI())) {
children.add(new XCalElement(child)); // depends on control dependency: [if], data = [none]
}
}
return children;
} } |
public class class_name {
public TaskMetricGroup addTaskForJob(
final JobID jobId,
final String jobName,
final JobVertexID jobVertexId,
final ExecutionAttemptID executionAttemptId,
final String taskName,
final int subtaskIndex,
final int attemptNumber) {
Preconditions.checkNotNull(jobId);
String resolvedJobName = jobName == null || jobName.isEmpty()
? jobId.toString()
: jobName;
// we cannot strictly lock both our map modification and the job group modification
// because it might lead to a deadlock
while (true) {
// get or create a jobs metric group
TaskManagerJobMetricGroup currentJobGroup;
synchronized (this) {
currentJobGroup = jobs.get(jobId);
if (currentJobGroup == null || currentJobGroup.isClosed()) {
currentJobGroup = new TaskManagerJobMetricGroup(registry, this, jobId, resolvedJobName);
jobs.put(jobId, currentJobGroup);
}
}
// try to add another task. this may fail if we found a pre-existing job metrics
// group and it is closed concurrently
TaskMetricGroup taskGroup = currentJobGroup.addTask(
jobVertexId,
executionAttemptId,
taskName,
subtaskIndex,
attemptNumber);
if (taskGroup != null) {
// successfully added the next task
return taskGroup;
}
// else fall through the loop
}
} } | public class class_name {
public TaskMetricGroup addTaskForJob(
final JobID jobId,
final String jobName,
final JobVertexID jobVertexId,
final ExecutionAttemptID executionAttemptId,
final String taskName,
final int subtaskIndex,
final int attemptNumber) {
Preconditions.checkNotNull(jobId);
String resolvedJobName = jobName == null || jobName.isEmpty()
? jobId.toString()
: jobName;
// we cannot strictly lock both our map modification and the job group modification
// because it might lead to a deadlock
while (true) {
// get or create a jobs metric group
TaskManagerJobMetricGroup currentJobGroup;
synchronized (this) { // depends on control dependency: [while], data = [none]
currentJobGroup = jobs.get(jobId);
if (currentJobGroup == null || currentJobGroup.isClosed()) {
currentJobGroup = new TaskManagerJobMetricGroup(registry, this, jobId, resolvedJobName); // depends on control dependency: [if], data = [none]
jobs.put(jobId, currentJobGroup); // depends on control dependency: [if], data = [none]
}
}
// try to add another task. this may fail if we found a pre-existing job metrics
// group and it is closed concurrently
TaskMetricGroup taskGroup = currentJobGroup.addTask(
jobVertexId,
executionAttemptId,
taskName,
subtaskIndex,
attemptNumber);
if (taskGroup != null) {
// successfully added the next task
return taskGroup; // depends on control dependency: [if], data = [none]
}
// else fall through the loop
}
} } |
public class class_name {
public static List random(long minLen, long maxLen, Object... values) {
long len = randomLong(minLen, maxLen);
if (len > 0) {
List ret = new ArrayList();
for (int i = 0; i < len; i++) {
ret.add(randomOne(values));
}
return ret;
}
return null;
} } | public class class_name {
public static List random(long minLen, long maxLen, Object... values) {
long len = randomLong(minLen, maxLen);
if (len > 0) {
List ret = new ArrayList();
for (int i = 0; i < len; i++) {
ret.add(randomOne(values));
// depends on control dependency: [for], data = [none]
}
return ret;
// depends on control dependency: [if], data = [none]
}
return null;
} } |
public class class_name {
public String getRandomWord(final int minLength, final int maxLength) {
validateMinMaxParams(minLength, maxLength);
// special case if we need a single char
if (maxLength == 1) {
if (chance(50)) {
return "a";
}
return "I";
}
// start from random pos and find the first word of the right size
String[] words = contentDataValues.getWords();
int pos = random.nextInt(words.length);
for (int i = 0; i < words.length; i++) {
int idx = (i + pos) % words.length;
String test = words[idx];
if (test.length() >= minLength && test.length() <= maxLength) {
return test;
}
}
// we haven't a word for this length so generate one
return getRandomChars(minLength, maxLength);
} } | public class class_name {
public String getRandomWord(final int minLength, final int maxLength) {
validateMinMaxParams(minLength, maxLength);
// special case if we need a single char
if (maxLength == 1) {
if (chance(50)) {
return "a";
// depends on control dependency: [if], data = [none]
}
return "I";
// depends on control dependency: [if], data = [none]
}
// start from random pos and find the first word of the right size
String[] words = contentDataValues.getWords();
int pos = random.nextInt(words.length);
for (int i = 0; i < words.length; i++) {
int idx = (i + pos) % words.length;
String test = words[idx];
if (test.length() >= minLength && test.length() <= maxLength) {
return test;
// depends on control dependency: [if], data = [none]
}
}
// we haven't a word for this length so generate one
return getRandomChars(minLength, maxLength);
} } |
public class class_name {
Element createTopicMeta(final Element topic) {
final Document doc = rootTopicref.getOwnerDocument();
final Element topicmeta = doc.createElement(MAP_TOPICMETA.localName);
topicmeta.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_TOPICMETA.toString());
// iterate the node.
if (topic != null) {
final Element title = getElementNode(topic, TOPIC_TITLE);
final Element titlealts = getElementNode(topic, TOPIC_TITLEALTS);
final Element navtitle = titlealts != null ? getElementNode(titlealts, TOPIC_NAVTITLE) : null;
final Element shortDesc = getElementNode(topic, TOPIC_SHORTDESC);
final Element navtitleNode = doc.createElement(TOPIC_NAVTITLE.localName);
navtitleNode.setAttribute(ATTRIBUTE_NAME_CLASS, TOPIC_NAVTITLE.toString());
// append navtitle node
if (navtitle != null) {
final String text = getText(navtitle);
final Text titleText = doc.createTextNode(text);
navtitleNode.appendChild(titleText);
topicmeta.appendChild(navtitleNode);
} else {
final String text = getText(title);
final Text titleText = doc.createTextNode(text);
navtitleNode.appendChild(titleText);
topicmeta.appendChild(navtitleNode);
}
// append gentext pi
final Node pi = doc.createProcessingInstruction("ditaot", "gentext");
topicmeta.appendChild(pi);
// append linktext
final Element linkTextNode = doc.createElement(TOPIC_LINKTEXT.localName);
linkTextNode.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_LINKTEXT.toString());
final String text = getText(title);
final Text textNode = doc.createTextNode(text);
linkTextNode.appendChild(textNode);
topicmeta.appendChild(linkTextNode);
// append genshortdesc pi
final Node pii = doc.createProcessingInstruction("ditaot", "genshortdesc");
topicmeta.appendChild(pii);
// append shortdesc
final Element shortDescNode = doc.createElement(TOPIC_SHORTDESC.localName);
shortDescNode.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_SHORTDESC.toString());
final String shortDescText = getText(shortDesc);
final Text shortDescTextNode = doc.createTextNode(shortDescText);
shortDescNode.appendChild(shortDescTextNode);
topicmeta.appendChild(shortDescNode);
}
return topicmeta;
} } | public class class_name {
Element createTopicMeta(final Element topic) {
final Document doc = rootTopicref.getOwnerDocument();
final Element topicmeta = doc.createElement(MAP_TOPICMETA.localName);
topicmeta.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_TOPICMETA.toString());
// iterate the node.
if (topic != null) {
final Element title = getElementNode(topic, TOPIC_TITLE);
final Element titlealts = getElementNode(topic, TOPIC_TITLEALTS);
final Element navtitle = titlealts != null ? getElementNode(titlealts, TOPIC_NAVTITLE) : null;
final Element shortDesc = getElementNode(topic, TOPIC_SHORTDESC);
final Element navtitleNode = doc.createElement(TOPIC_NAVTITLE.localName);
navtitleNode.setAttribute(ATTRIBUTE_NAME_CLASS, TOPIC_NAVTITLE.toString()); // depends on control dependency: [if], data = [none]
// append navtitle node
if (navtitle != null) {
final String text = getText(navtitle);
final Text titleText = doc.createTextNode(text);
navtitleNode.appendChild(titleText); // depends on control dependency: [if], data = [none]
topicmeta.appendChild(navtitleNode); // depends on control dependency: [if], data = [(navtitle]
} else {
final String text = getText(title);
final Text titleText = doc.createTextNode(text);
navtitleNode.appendChild(titleText); // depends on control dependency: [if], data = [none]
topicmeta.appendChild(navtitleNode); // depends on control dependency: [if], data = [(navtitle]
}
// append gentext pi
final Node pi = doc.createProcessingInstruction("ditaot", "gentext");
topicmeta.appendChild(pi); // depends on control dependency: [if], data = [none]
// append linktext
final Element linkTextNode = doc.createElement(TOPIC_LINKTEXT.localName);
linkTextNode.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_LINKTEXT.toString()); // depends on control dependency: [if], data = [none]
final String text = getText(title);
final Text textNode = doc.createTextNode(text);
linkTextNode.appendChild(textNode); // depends on control dependency: [if], data = [none]
topicmeta.appendChild(linkTextNode); // depends on control dependency: [if], data = [none]
// append genshortdesc pi
final Node pii = doc.createProcessingInstruction("ditaot", "genshortdesc");
topicmeta.appendChild(pii); // depends on control dependency: [if], data = [none]
// append shortdesc
final Element shortDescNode = doc.createElement(TOPIC_SHORTDESC.localName);
shortDescNode.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_SHORTDESC.toString()); // depends on control dependency: [if], data = [none]
final String shortDescText = getText(shortDesc);
final Text shortDescTextNode = doc.createTextNode(shortDescText);
shortDescNode.appendChild(shortDescTextNode); // depends on control dependency: [if], data = [none]
topicmeta.appendChild(shortDescNode); // depends on control dependency: [if], data = [none]
}
return topicmeta;
} } |
public class class_name {
private String generateSafeMethodName(StorableInfo info, String prefix) {
Class type = info.getStorableType();
// Try a few times to generate a unique name. There's nothing special
// about choosing 100 as the limit.
int value = 0;
for (int i = 0; i < 100; i++) {
String name = prefix + value;
if (!methodExists(type, name)) {
return name;
}
value = name.hashCode();
}
throw new InternalError("Unable to create unique method name starting with: "
+ prefix);
} } | public class class_name {
private String generateSafeMethodName(StorableInfo info, String prefix) {
Class type = info.getStorableType();
// Try a few times to generate a unique name. There's nothing special
// about choosing 100 as the limit.
int value = 0;
for (int i = 0; i < 100; i++) {
String name = prefix + value;
if (!methodExists(type, name)) {
return name;
// depends on control dependency: [if], data = [none]
}
value = name.hashCode();
// depends on control dependency: [for], data = [none]
}
throw new InternalError("Unable to create unique method name starting with: "
+ prefix);
} } |
public class class_name {
public void setRepositories(java.util.Collection<RepositoryNameIdPair> repositories) {
if (repositories == null) {
this.repositories = null;
return;
}
this.repositories = new java.util.ArrayList<RepositoryNameIdPair>(repositories);
} } | public class class_name {
public void setRepositories(java.util.Collection<RepositoryNameIdPair> repositories) {
if (repositories == null) {
this.repositories = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.repositories = new java.util.ArrayList<RepositoryNameIdPair>(repositories);
} } |
public class class_name {
private void applyForcedChanges(){
// Disable the legacy system of API Token only if the new system was not installed
// in such case it means there was already an upgrade before
// and potentially the admin has re-enabled the features
ApiTokenPropertyConfiguration apiTokenPropertyConfiguration = ApiTokenPropertyConfiguration.get();
if(!apiTokenPropertyConfiguration.hasExistingConfigFile()){
LOGGER.log(Level.INFO, "New API token system configured with insecure options to keep legacy behavior");
apiTokenPropertyConfiguration.setCreationOfLegacyTokenEnabled(false);
apiTokenPropertyConfiguration.setTokenGenerationOnCreationEnabled(false);
}
} } | public class class_name {
private void applyForcedChanges(){
// Disable the legacy system of API Token only if the new system was not installed
// in such case it means there was already an upgrade before
// and potentially the admin has re-enabled the features
ApiTokenPropertyConfiguration apiTokenPropertyConfiguration = ApiTokenPropertyConfiguration.get();
if(!apiTokenPropertyConfiguration.hasExistingConfigFile()){
LOGGER.log(Level.INFO, "New API token system configured with insecure options to keep legacy behavior");
apiTokenPropertyConfiguration.setCreationOfLegacyTokenEnabled(false);
apiTokenPropertyConfiguration.setTokenGenerationOnCreationEnabled(false); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private Table gettableWithCreateTime(Table table, int createTime) {
if (table.isSetCreateTime() && table.getCreateTime() > 0) {
return table;
}
Table actualtable = table.deepCopy();
actualtable.setCreateTime(createTime);
return actualtable;
} } | public class class_name {
private Table gettableWithCreateTime(Table table, int createTime) {
if (table.isSetCreateTime() && table.getCreateTime() > 0) {
return table; // depends on control dependency: [if], data = [none]
}
Table actualtable = table.deepCopy();
actualtable.setCreateTime(createTime);
return actualtable;
} } |
public class class_name {
public StreamingStep withInputs(String ... inputs) {
for (String input : inputs) {
this.inputs.add(input);
}
return this;
} } | public class class_name {
public StreamingStep withInputs(String ... inputs) {
for (String input : inputs) {
this.inputs.add(input); // depends on control dependency: [for], data = [input]
}
return this;
} } |
public class class_name {
public java.util.List<String> getDeletedParameters() {
if (deletedParameters == null) {
deletedParameters = new com.amazonaws.internal.SdkInternalList<String>();
}
return deletedParameters;
} } | public class class_name {
public java.util.List<String> getDeletedParameters() {
if (deletedParameters == null) {
deletedParameters = new com.amazonaws.internal.SdkInternalList<String>(); // depends on control dependency: [if], data = [none]
}
return deletedParameters;
} } |
public class class_name {
public void marshall(ListUserProfilesRequest listUserProfilesRequest, ProtocolMarshaller protocolMarshaller) {
if (listUserProfilesRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(listUserProfilesRequest.getNextToken(), NEXTTOKEN_BINDING);
protocolMarshaller.marshall(listUserProfilesRequest.getMaxResults(), MAXRESULTS_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(ListUserProfilesRequest listUserProfilesRequest, ProtocolMarshaller protocolMarshaller) {
if (listUserProfilesRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(listUserProfilesRequest.getNextToken(), NEXTTOKEN_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(listUserProfilesRequest.getMaxResults(), MAXRESULTS_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 void updateOnAccessAndCommit(long blockId) {
synchronized (mBlockIdToLastUpdateTime) {
long currentLogicTime = mLogicTimeCount.incrementAndGet();
// update CRF value
// CRF(currentLogicTime)=CRF(lastUpdateTime)*F(currentLogicTime-lastUpdateTime)+F(0)
if (mBlockIdToCRFValue.containsKey(blockId)) {
mBlockIdToCRFValue.put(blockId, mBlockIdToCRFValue.get(blockId)
* calculateAccessWeight(currentLogicTime - mBlockIdToLastUpdateTime.get(blockId))
+ 1.0);
} else {
mBlockIdToCRFValue.put(blockId, 1.0);
}
// update currentLogicTime to lastUpdateTime
mBlockIdToLastUpdateTime.put(blockId, currentLogicTime);
}
} } | public class class_name {
private void updateOnAccessAndCommit(long blockId) {
synchronized (mBlockIdToLastUpdateTime) {
long currentLogicTime = mLogicTimeCount.incrementAndGet();
// update CRF value
// CRF(currentLogicTime)=CRF(lastUpdateTime)*F(currentLogicTime-lastUpdateTime)+F(0)
if (mBlockIdToCRFValue.containsKey(blockId)) {
mBlockIdToCRFValue.put(blockId, mBlockIdToCRFValue.get(blockId)
* calculateAccessWeight(currentLogicTime - mBlockIdToLastUpdateTime.get(blockId))
+ 1.0); // depends on control dependency: [if], data = [none]
} else {
mBlockIdToCRFValue.put(blockId, 1.0); // depends on control dependency: [if], data = [none]
}
// update currentLogicTime to lastUpdateTime
mBlockIdToLastUpdateTime.put(blockId, currentLogicTime);
}
} } |
public class class_name {
protected List<String> getModulesToDelete() {
List<String> result = new ArrayList<String>();
for (int i = 0; i < OBSOLETE_MODULES.length; i++) {
if (OpenCms.getModuleManager().hasModule(OBSOLETE_MODULES[i])) {
result.add(OBSOLETE_MODULES[i]);
}
}
return result;
} } | public class class_name {
protected List<String> getModulesToDelete() {
List<String> result = new ArrayList<String>();
for (int i = 0; i < OBSOLETE_MODULES.length; i++) {
if (OpenCms.getModuleManager().hasModule(OBSOLETE_MODULES[i])) {
result.add(OBSOLETE_MODULES[i]); // depends on control dependency: [if], data = [none]
}
}
return result;
} } |
public class class_name {
public void marshall(ResourceIdentifier resourceIdentifier, ProtocolMarshaller protocolMarshaller) {
if (resourceIdentifier == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(resourceIdentifier.getResourceType(), RESOURCETYPE_BINDING);
protocolMarshaller.marshall(resourceIdentifier.getResourceId(), RESOURCEID_BINDING);
protocolMarshaller.marshall(resourceIdentifier.getResourceName(), RESOURCENAME_BINDING);
protocolMarshaller.marshall(resourceIdentifier.getResourceDeletionTime(), RESOURCEDELETIONTIME_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(ResourceIdentifier resourceIdentifier, ProtocolMarshaller protocolMarshaller) {
if (resourceIdentifier == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(resourceIdentifier.getResourceType(), RESOURCETYPE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(resourceIdentifier.getResourceId(), RESOURCEID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(resourceIdentifier.getResourceName(), RESOURCENAME_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(resourceIdentifier.getResourceDeletionTime(), RESOURCEDELETIONTIME_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 setImportExportManager(CmsImportExportManager manager) {
m_importExportManager = manager;
if (CmsLog.INIT.isInfoEnabled()) {
CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_IMPORT_MANAGER_0));
}
} } | public class class_name {
public void setImportExportManager(CmsImportExportManager manager) {
m_importExportManager = manager;
if (CmsLog.INIT.isInfoEnabled()) {
CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_IMPORT_MANAGER_0)); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public ListGeoMatchSetsResult withGeoMatchSets(GeoMatchSetSummary... geoMatchSets) {
if (this.geoMatchSets == null) {
setGeoMatchSets(new java.util.ArrayList<GeoMatchSetSummary>(geoMatchSets.length));
}
for (GeoMatchSetSummary ele : geoMatchSets) {
this.geoMatchSets.add(ele);
}
return this;
} } | public class class_name {
public ListGeoMatchSetsResult withGeoMatchSets(GeoMatchSetSummary... geoMatchSets) {
if (this.geoMatchSets == null) {
setGeoMatchSets(new java.util.ArrayList<GeoMatchSetSummary>(geoMatchSets.length)); // depends on control dependency: [if], data = [none]
}
for (GeoMatchSetSummary ele : geoMatchSets) {
this.geoMatchSets.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public static NDArrayDoubles readFromProto(NDArrayDoublesProto.NDArrayDoubles proto) {
int[] neighborSizes = new int[proto.getDimensionSizeCount()];
for (int i = 0; i < neighborSizes.length; i++) {
neighborSizes[i] = proto.getDimensionSize(i);
}
NDArrayDoubles factor = new NDArrayDoubles(neighborSizes);
for (int i = 0; i < proto.getValuesCount(); i++) {
factor.values[i] = proto.getValues(i);
assert !Double.isNaN(factor.values[i]);
}
return factor;
} } | public class class_name {
public static NDArrayDoubles readFromProto(NDArrayDoublesProto.NDArrayDoubles proto) {
int[] neighborSizes = new int[proto.getDimensionSizeCount()];
for (int i = 0; i < neighborSizes.length; i++) {
neighborSizes[i] = proto.getDimensionSize(i); // depends on control dependency: [for], data = [i]
}
NDArrayDoubles factor = new NDArrayDoubles(neighborSizes);
for (int i = 0; i < proto.getValuesCount(); i++) {
factor.values[i] = proto.getValues(i); // depends on control dependency: [for], data = [i]
assert !Double.isNaN(factor.values[i]); // depends on control dependency: [for], data = [none] // depends on control dependency: [for], data = [i]
}
return factor;
} } |
public class class_name {
private void setUpDefaultUriComboBox(List<CmsSite> allSites) {
BeanItemContainer<CmsSite> objects = new BeanItemContainer<CmsSite>(CmsSite.class, allSites);
m_fieldDefaultURI.setContainerDataSource(objects);
m_fieldDefaultURI.setNullSelectionAllowed(false);
m_fieldDefaultURI.setTextInputAllowed(false);
m_fieldDefaultURI.setItemCaptionPropertyId("title");
//set value
String siteRoot = OpenCms.getSiteManager().getDefaultUri();
if (siteRoot.endsWith("/")) {
siteRoot = siteRoot.substring(0, siteRoot.length() - 1);
}
CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot);
m_fieldDefaultURI.setValue(site);
} } | public class class_name {
private void setUpDefaultUriComboBox(List<CmsSite> allSites) {
BeanItemContainer<CmsSite> objects = new BeanItemContainer<CmsSite>(CmsSite.class, allSites);
m_fieldDefaultURI.setContainerDataSource(objects);
m_fieldDefaultURI.setNullSelectionAllowed(false);
m_fieldDefaultURI.setTextInputAllowed(false);
m_fieldDefaultURI.setItemCaptionPropertyId("title");
//set value
String siteRoot = OpenCms.getSiteManager().getDefaultUri();
if (siteRoot.endsWith("/")) {
siteRoot = siteRoot.substring(0, siteRoot.length() - 1); // depends on control dependency: [if], data = [none]
}
CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot);
m_fieldDefaultURI.setValue(site);
} } |
public class class_name {
public static String camelCaseToUnderscore(final String camelCaseString) {
final StringBuilder sb = new StringBuilder();
for (final String camelPart : camelCaseString.split("(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])")) {
if (sb.length() > 0) {
sb.append(CASE_SEPARATOR);
}
sb.append(camelPart.toUpperCase(Locale.getDefault()));
}
return sb.toString();
} } | public class class_name {
public static String camelCaseToUnderscore(final String camelCaseString) {
final StringBuilder sb = new StringBuilder();
for (final String camelPart : camelCaseString.split("(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])")) {
if (sb.length() > 0) {
sb.append(CASE_SEPARATOR); // depends on control dependency: [if], data = [none]
}
sb.append(camelPart.toUpperCase(Locale.getDefault())); // depends on control dependency: [for], data = [camelPart]
}
return sb.toString();
} } |
public class class_name {
public void setGroupName(String name, int id) {
PreparedStatement statement = null;
try (Connection sqlConnection = sqlService.getConnection()) {
statement = sqlConnection.prepareStatement(
"UPDATE " + Constants.DB_TABLE_SERVER_GROUPS +
" SET " + Constants.GENERIC_NAME + " = ?" +
" WHERE " + Constants.GENERIC_ID + " = ?"
);
statement.setString(1, name);
statement.setInt(2, id);
statement.executeUpdate();
statement.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (Exception e) {
}
}
} } | public class class_name {
public void setGroupName(String name, int id) {
PreparedStatement statement = null;
try (Connection sqlConnection = sqlService.getConnection()) {
statement = sqlConnection.prepareStatement(
"UPDATE " + Constants.DB_TABLE_SERVER_GROUPS +
" SET " + Constants.GENERIC_NAME + " = ?" +
" WHERE " + Constants.GENERIC_ID + " = ?"
);
statement.setString(1, name);
statement.setInt(2, id);
statement.executeUpdate();
statement.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (statement != null) {
statement.close(); // depends on control dependency: [if], data = [none]
}
} catch (Exception e) {
} // depends on control dependency: [catch], data = [none]
}
} } |
public class class_name {
@Nonnull
public static String escapeString(@Nonnull String s) {
// We replace double quotes with a back slash followed
// by a double quote. We replace backslashes with a double
// backslash
if (s.indexOf('\"') == -1 && s.indexOf('\\') == -1) {
return s;
}
StringBuilder sb = new StringBuilder(s.length() + 20);
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (ch == '\\') {
sb.append("\\\\");
} else if (ch == '\"') {
sb.append("\\\"");
} else {
sb.append(ch);
}
}
return verifyNotNull(sb.toString());
} } | public class class_name {
@Nonnull
public static String escapeString(@Nonnull String s) {
// We replace double quotes with a back slash followed
// by a double quote. We replace backslashes with a double
// backslash
if (s.indexOf('\"') == -1 && s.indexOf('\\') == -1) {
return s; // depends on control dependency: [if], data = [none]
}
StringBuilder sb = new StringBuilder(s.length() + 20);
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (ch == '\\') {
sb.append("\\\\"); // depends on control dependency: [if], data = [none]
} else if (ch == '\"') {
sb.append("\\\""); // depends on control dependency: [if], data = [none]
} else {
sb.append(ch); // depends on control dependency: [if], data = [(ch]
}
}
return verifyNotNull(sb.toString());
} } |
public class class_name {
public synchronized boolean removeAny(Object element) {
if (end == start) return false;
if (end == -1) {
for (int i = array.length - 1; i >= 0; --i)
if (array[i].equals(element)) {
removeAt(i);
return true;
}
return false;
}
if (end < start) {
for (int i = array.length - 1; i >= start; --i)
if (array[i].equals(element)) {
removeAt(i);
return true;
}
for (int i = 0; i < end; ++i)
if (array[i].equals(element)) {
removeAt(i);
return true;
}
return false;
}
for (int i = start; i < end; ++i)
if (array[i].equals(element)) {
removeAt(i);
return true;
}
return false;
} } | public class class_name {
public synchronized boolean removeAny(Object element) {
if (end == start) return false;
if (end == -1) {
for (int i = array.length - 1; i >= 0; --i)
if (array[i].equals(element)) {
removeAt(i);
// depends on control dependency: [if], data = [none]
return true;
// depends on control dependency: [if], data = [none]
}
return false;
// depends on control dependency: [if], data = [none]
}
if (end < start) {
for (int i = array.length - 1; i >= start; --i)
if (array[i].equals(element)) {
removeAt(i);
// depends on control dependency: [if], data = [none]
return true;
// depends on control dependency: [if], data = [none]
}
for (int i = 0; i < end; ++i)
if (array[i].equals(element)) {
removeAt(i);
// depends on control dependency: [if], data = [none]
return true;
// depends on control dependency: [if], data = [none]
}
return false;
// depends on control dependency: [if], data = [none]
}
for (int i = start; i < end; ++i)
if (array[i].equals(element)) {
removeAt(i);
// depends on control dependency: [if], data = [none]
return true;
// depends on control dependency: [if], data = [none]
}
return false;
} } |
public class class_name {
public ServiceCall<Voice> getVoice(GetVoiceOptions getVoiceOptions) {
Validator.notNull(getVoiceOptions, "getVoiceOptions cannot be null");
String[] pathSegments = { "v1/voices" };
String[] pathParameters = { getVoiceOptions.voice() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoice");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getVoiceOptions.customizationId() != null) {
builder.query("customization_id", getVoiceOptions.customizationId());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Voice.class));
} } | public class class_name {
public ServiceCall<Voice> getVoice(GetVoiceOptions getVoiceOptions) {
Validator.notNull(getVoiceOptions, "getVoiceOptions cannot be null");
String[] pathSegments = { "v1/voices" };
String[] pathParameters = { getVoiceOptions.voice() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoice");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue()); // depends on control dependency: [for], data = [header]
}
builder.header("Accept", "application/json");
if (getVoiceOptions.customizationId() != null) {
builder.query("customization_id", getVoiceOptions.customizationId()); // depends on control dependency: [if], data = [none]
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Voice.class));
} } |
public class class_name {
boolean hasFinally(JCTree target, Env<GenContext> env) {
while (env.tree != target) {
if (env.tree.hasTag(TRY) && env.info.finalize.hasFinalizer())
return true;
env = env.next;
}
return false;
} } | public class class_name {
boolean hasFinally(JCTree target, Env<GenContext> env) {
while (env.tree != target) {
if (env.tree.hasTag(TRY) && env.info.finalize.hasFinalizer())
return true;
env = env.next; // depends on control dependency: [while], data = [none]
}
return false;
} } |
public class class_name {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void doTransform(ITransformable transformable, float comp)
{
if (listTransformations.size() == 0)
return;
if (reversed)
elapsedTimeCurrentLoop = Math.max(0, duration - elapsedTimeCurrentLoop);
for (Transformation transformation : listTransformations)
{
transformation.transform(transformable, elapsedTimeCurrentLoop);
elapsedTimeCurrentLoop -= transformation.totalDuration();
}
} } | public class class_name {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void doTransform(ITransformable transformable, float comp)
{
if (listTransformations.size() == 0)
return;
if (reversed)
elapsedTimeCurrentLoop = Math.max(0, duration - elapsedTimeCurrentLoop);
for (Transformation transformation : listTransformations)
{
transformation.transform(transformable, elapsedTimeCurrentLoop); // depends on control dependency: [for], data = [transformation]
elapsedTimeCurrentLoop -= transformation.totalDuration(); // depends on control dependency: [for], data = [transformation]
}
} } |
public class class_name {
public final void constructorDeclaratorRest() throws RecognitionException {
int constructorDeclaratorRest_StartIndex = input.index();
try {
if ( state.backtracking>0 && alreadyParsedRule(input, 36) ) { return; }
// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:443:5: ( formalParameters ( 'throws' qualifiedNameList )? methodBody )
// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:443:7: formalParameters ( 'throws' qualifiedNameList )? methodBody
{
pushFollow(FOLLOW_formalParameters_in_constructorDeclaratorRest1258);
formalParameters();
state._fsp--;
if (state.failed) return;
// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:443:24: ( 'throws' qualifiedNameList )?
int alt52=2;
int LA52_0 = input.LA(1);
if ( (LA52_0==113) ) {
alt52=1;
}
switch (alt52) {
case 1 :
// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:443:25: 'throws' qualifiedNameList
{
match(input,113,FOLLOW_113_in_constructorDeclaratorRest1261); if (state.failed) return;
pushFollow(FOLLOW_qualifiedNameList_in_constructorDeclaratorRest1263);
qualifiedNameList();
state._fsp--;
if (state.failed) return;
}
break;
}
pushFollow(FOLLOW_methodBody_in_constructorDeclaratorRest1267);
methodBody();
state._fsp--;
if (state.failed) return;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
if ( state.backtracking>0 ) { memoize(input, 36, constructorDeclaratorRest_StartIndex); }
}
} } | public class class_name {
public final void constructorDeclaratorRest() throws RecognitionException {
int constructorDeclaratorRest_StartIndex = input.index();
try {
if ( state.backtracking>0 && alreadyParsedRule(input, 36) ) { return; } // depends on control dependency: [if], data = [none]
// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:443:5: ( formalParameters ( 'throws' qualifiedNameList )? methodBody )
// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:443:7: formalParameters ( 'throws' qualifiedNameList )? methodBody
{
pushFollow(FOLLOW_formalParameters_in_constructorDeclaratorRest1258);
formalParameters();
state._fsp--;
if (state.failed) return;
// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:443:24: ( 'throws' qualifiedNameList )?
int alt52=2;
int LA52_0 = input.LA(1);
if ( (LA52_0==113) ) {
alt52=1; // depends on control dependency: [if], data = [none]
}
switch (alt52) {
case 1 :
// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:443:25: 'throws' qualifiedNameList
{
match(input,113,FOLLOW_113_in_constructorDeclaratorRest1261); if (state.failed) return;
pushFollow(FOLLOW_qualifiedNameList_in_constructorDeclaratorRest1263);
qualifiedNameList();
state._fsp--;
if (state.failed) return;
}
break;
}
pushFollow(FOLLOW_methodBody_in_constructorDeclaratorRest1267);
methodBody();
state._fsp--;
if (state.failed) return;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
if ( state.backtracking>0 ) { memoize(input, 36, constructorDeclaratorRest_StartIndex); } // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public GetPatchBaselineResult withPatchGroups(String... patchGroups) {
if (this.patchGroups == null) {
setPatchGroups(new com.amazonaws.internal.SdkInternalList<String>(patchGroups.length));
}
for (String ele : patchGroups) {
this.patchGroups.add(ele);
}
return this;
} } | public class class_name {
public GetPatchBaselineResult withPatchGroups(String... patchGroups) {
if (this.patchGroups == null) {
setPatchGroups(new com.amazonaws.internal.SdkInternalList<String>(patchGroups.length)); // depends on control dependency: [if], data = [none]
}
for (String ele : patchGroups) {
this.patchGroups.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public Integer getCountAtOrAbove(final long version) {
if (versionsStored < versionWindow.length) {
return null;
}
int count = 0;
for (int versionIdx = 0; versionIdx < versionWindow.length; versionIdx++) {
if (versionWindow[versionIdx] >= version) {
count++;
}
}
return count;
} } | public class class_name {
public Integer getCountAtOrAbove(final long version) {
if (versionsStored < versionWindow.length) {
return null; // depends on control dependency: [if], data = [none]
}
int count = 0;
for (int versionIdx = 0; versionIdx < versionWindow.length; versionIdx++) {
if (versionWindow[versionIdx] >= version) {
count++; // depends on control dependency: [if], data = [none]
}
}
return count;
} } |
public class class_name {
public static String encodeParam(String textParam) {
if(textParam == null) {
return null;
}
try {
return URLEncoder.encode(textParam,ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
} } | public class class_name {
public static String encodeParam(String textParam) {
if(textParam == null) {
return null; // depends on control dependency: [if], data = [none]
}
try {
return URLEncoder.encode(textParam,ENCODING_UTF_8); // depends on control dependency: [try], data = [none]
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} // depends on control dependency: [catch], data = [none]
return null;
} } |
public class class_name {
public void fatal(Object message, Throwable t)
{
if (IS12)
{
getLogger().log(FQCN, Level.FATAL, message, t);
}
else
{
getLogger().log(FQCN, Level.FATAL, message, t);
}
} } | public class class_name {
public void fatal(Object message, Throwable t)
{
if (IS12)
{
getLogger().log(FQCN, Level.FATAL, message, t); // depends on control dependency: [if], data = [none]
}
else
{
getLogger().log(FQCN, Level.FATAL, message, t); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public String getTemplatedURL( ServletContext servletContext,
ServletRequest request, MutableURI uri,
String key, URIContext uriContext )
{
// Look for the template config and get the right template.
// If it is found, apply the value to the template.
String result = null;
URLTemplate template = null;
URLTemplatesFactory factory = URLTemplatesFactory.getURLTemplatesFactory( request );
if ( factory != null )
{
String templateName = factory.getTemplateNameByRef( DEFAULT_TEMPLATE_REF, key );
if ( templateName != null )
{
template = factory.getURLTemplate( templateName );
}
}
if ( template != null )
{
result = formatURIWithTemplate( request, uri, uriContext, template );
}
else
{
// no template found, just return the uri as a String...
result = uri.getURIString( uriContext );
}
return result;
} } | public class class_name {
public String getTemplatedURL( ServletContext servletContext,
ServletRequest request, MutableURI uri,
String key, URIContext uriContext )
{
// Look for the template config and get the right template.
// If it is found, apply the value to the template.
String result = null;
URLTemplate template = null;
URLTemplatesFactory factory = URLTemplatesFactory.getURLTemplatesFactory( request );
if ( factory != null )
{
String templateName = factory.getTemplateNameByRef( DEFAULT_TEMPLATE_REF, key );
if ( templateName != null )
{
template = factory.getURLTemplate( templateName ); // depends on control dependency: [if], data = [( templateName]
}
}
if ( template != null )
{
result = formatURIWithTemplate( request, uri, uriContext, template ); // depends on control dependency: [if], data = [none]
}
else
{
// no template found, just return the uri as a String...
result = uri.getURIString( uriContext ); // depends on control dependency: [if], data = [none]
}
return result;
} } |
public class class_name {
public ServiceCall<TrainingDataSet> listTrainingData(ListTrainingDataOptions listTrainingDataOptions) {
Validator.notNull(listTrainingDataOptions, "listTrainingDataOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data" };
String[] pathParameters = { listTrainingDataOptions.environmentId(), listTrainingDataOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listTrainingData");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingDataSet.class));
} } | public class class_name {
public ServiceCall<TrainingDataSet> listTrainingData(ListTrainingDataOptions listTrainingDataOptions) {
Validator.notNull(listTrainingDataOptions, "listTrainingDataOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data" };
String[] pathParameters = { listTrainingDataOptions.environmentId(), listTrainingDataOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listTrainingData");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue()); // depends on control dependency: [for], data = [header]
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingDataSet.class));
} } |
public class class_name {
@POST
@Path("{uuid}")
public Result migrate(@FormParam("description") String desc,
@PathParam("uuid") String uuid) {
MigrationFeature.checkMigrationId(uuid);
String generatedDesc = (mode.isDev() ? "dev " : "") + "migrate";
if (StringUtils.isNotBlank(desc)) {
generatedDesc = desc;
}
Map<String, Migration> migrations = getMigrations();
for (String dbName : migrations.keySet()) {
Migration migration = migrations.get(dbName);
ScriptInfo info = migration.generate();
info.setDescription(generatedDesc);
Flyway flyway = locator.getService(Flyway.class, dbName);
flyway.setBaselineDescription(info.getDescription());
flyway.setBaselineVersionAsString(info.getRevision());
flyway.setValidateOnMigrate(false);
try {
flyway.migrate();
migration.persist();
migration.reset();
} catch (Throwable err) {
if (failMigrations == null) {
synchronized (this) {
if (failMigrations == null) {
failMigrations = Maps.newHashMap();
}
}
}
failMigrations.put(dbName, MigrationFail.create(flyway, err, migration));
}
}
if (failMigrations == null || failMigrations.isEmpty()) {
return Result.success();
} else {
return Result.failure();
}
} } | public class class_name {
@POST
@Path("{uuid}")
public Result migrate(@FormParam("description") String desc,
@PathParam("uuid") String uuid) {
MigrationFeature.checkMigrationId(uuid);
String generatedDesc = (mode.isDev() ? "dev " : "") + "migrate";
if (StringUtils.isNotBlank(desc)) {
generatedDesc = desc; // depends on control dependency: [if], data = [none]
}
Map<String, Migration> migrations = getMigrations();
for (String dbName : migrations.keySet()) {
Migration migration = migrations.get(dbName);
ScriptInfo info = migration.generate();
info.setDescription(generatedDesc); // depends on control dependency: [for], data = [none]
Flyway flyway = locator.getService(Flyway.class, dbName);
flyway.setBaselineDescription(info.getDescription()); // depends on control dependency: [for], data = [none]
flyway.setBaselineVersionAsString(info.getRevision()); // depends on control dependency: [for], data = [none]
flyway.setValidateOnMigrate(false); // depends on control dependency: [for], data = [none]
try {
flyway.migrate(); // depends on control dependency: [try], data = [none]
migration.persist(); // depends on control dependency: [try], data = [none]
migration.reset(); // depends on control dependency: [try], data = [none]
} catch (Throwable err) {
if (failMigrations == null) {
synchronized (this) { // depends on control dependency: [if], data = [none]
if (failMigrations == null) {
failMigrations = Maps.newHashMap(); // depends on control dependency: [if], data = [none]
}
}
}
failMigrations.put(dbName, MigrationFail.create(flyway, err, migration));
} // depends on control dependency: [catch], data = [none]
}
if (failMigrations == null || failMigrations.isEmpty()) {
return Result.success(); // depends on control dependency: [if], data = [none]
} else {
return Result.failure(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
protected void writeDecoratedPage(final Writer out, final char[] decoratorContent, final char[] pageContent, final DecoraTag[] decoraTags) throws IOException {
int ndx = 0;
for (DecoraTag decoraTag : decoraTags) {
// [1] just copy content before the Decora tag
int decoratorLen = decoraTag.getStartIndex() - ndx;
if (decoratorLen <= 0) {
continue;
}
out.write(decoratorContent, ndx, decoratorLen);
ndx = decoraTag.getEndIndex();
// [2] now write region at the place of Decora tag
int regionLen = decoraTag.getRegionLength();
if (regionLen == 0) {
if (decoraTag.hasDefaultValue()) {
out.write(decoratorContent, decoraTag.getDefaultValueStart(), decoraTag.getDefaultValueLength());
}
} else {
writeRegion(out, pageContent, decoraTag, decoraTags);
}
}
// write remaining content
out.write(decoratorContent, ndx, decoratorContent.length - ndx);
} } | public class class_name {
protected void writeDecoratedPage(final Writer out, final char[] decoratorContent, final char[] pageContent, final DecoraTag[] decoraTags) throws IOException {
int ndx = 0;
for (DecoraTag decoraTag : decoraTags) {
// [1] just copy content before the Decora tag
int decoratorLen = decoraTag.getStartIndex() - ndx;
if (decoratorLen <= 0) {
continue;
}
out.write(decoratorContent, ndx, decoratorLen);
ndx = decoraTag.getEndIndex();
// [2] now write region at the place of Decora tag
int regionLen = decoraTag.getRegionLength();
if (regionLen == 0) {
if (decoraTag.hasDefaultValue()) {
out.write(decoratorContent, decoraTag.getDefaultValueStart(), decoraTag.getDefaultValueLength()); // depends on control dependency: [if], data = [none]
}
} else {
writeRegion(out, pageContent, decoraTag, decoraTags); // depends on control dependency: [if], data = [none]
}
}
// write remaining content
out.write(decoratorContent, ndx, decoratorContent.length - ndx);
} } |
public class class_name {
public CheckResponse getRawCheckResponse() {
if (!checkCalled) {
setupMaxTries();
setupWaitTime();
addResultsToValuesForCheck(getCurrentRowValues());
long startTime = currentTimeMillis();
try {
executeCheckWithRetry();
} finally {
checkTime = currentTimeMillis() - startTime;
}
}
return checkResponse;
} } | public class class_name {
public CheckResponse getRawCheckResponse() {
if (!checkCalled) {
setupMaxTries(); // depends on control dependency: [if], data = [none]
setupWaitTime(); // depends on control dependency: [if], data = [none]
addResultsToValuesForCheck(getCurrentRowValues()); // depends on control dependency: [if], data = [none]
long startTime = currentTimeMillis();
try {
executeCheckWithRetry(); // depends on control dependency: [try], data = [none]
} finally {
checkTime = currentTimeMillis() - startTime;
}
}
return checkResponse;
} } |
public class class_name {
void updateCatalog(String diffCmds, CatalogContext context)
{
if (m_shuttingDown) {
return;
}
m_catalogContext = context;
// Wipe out all the idle sites with stale catalogs.
// Non-idle sites will get killed and replaced when they finish
// whatever they started before the catalog update
Iterator<MpRoSiteContext> siterator = m_idleSites.iterator();
while (siterator.hasNext()) {
MpRoSiteContext site = siterator.next();
if (site.getCatalogCRC() != m_catalogContext.getCatalogCRC()
|| site.getCatalogVersion() != m_catalogContext.catalogVersion) {
site.shutdown();
m_idleSites.remove(site);
m_allSites.remove(site);
}
}
} } | public class class_name {
void updateCatalog(String diffCmds, CatalogContext context)
{
if (m_shuttingDown) {
return; // depends on control dependency: [if], data = [none]
}
m_catalogContext = context;
// Wipe out all the idle sites with stale catalogs.
// Non-idle sites will get killed and replaced when they finish
// whatever they started before the catalog update
Iterator<MpRoSiteContext> siterator = m_idleSites.iterator();
while (siterator.hasNext()) {
MpRoSiteContext site = siterator.next();
if (site.getCatalogCRC() != m_catalogContext.getCatalogCRC()
|| site.getCatalogVersion() != m_catalogContext.catalogVersion) {
site.shutdown(); // depends on control dependency: [if], data = [none]
m_idleSites.remove(site); // depends on control dependency: [if], data = [none]
m_allSites.remove(site); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public FileRepositoryCollection createFileRepositoryCollection(File file) {
Class<? extends FileRepositoryCollection> clazz;
String extension =
FileExtensionUtils.findExtensionFromPossibilities(
file.getName(), fileRepositoryCollections.keySet());
clazz = fileRepositoryCollections.get(extension);
if (clazz == null) {
throw new MolgenisDataException("Unknown extension for file '" + file.getName() + "'");
}
Constructor<? extends FileRepositoryCollection> ctor;
try {
ctor = clazz.getConstructor(File.class);
} catch (Exception e) {
throw new MolgenisDataException(
"Exception creating ["
+ clazz
+ "] missing constructor FileRepositorySource(File file)");
}
FileRepositoryCollection fileRepositoryCollection = BeanUtils.instantiateClass(ctor, file);
autowireCapableBeanFactory.autowireBeanProperties(
fileRepositoryCollection, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
try {
fileRepositoryCollection.init();
} catch (IOException e) {
throw new RuntimeException(e);
}
return fileRepositoryCollection;
} } | public class class_name {
public FileRepositoryCollection createFileRepositoryCollection(File file) {
Class<? extends FileRepositoryCollection> clazz;
String extension =
FileExtensionUtils.findExtensionFromPossibilities(
file.getName(), fileRepositoryCollections.keySet());
clazz = fileRepositoryCollections.get(extension);
if (clazz == null) {
throw new MolgenisDataException("Unknown extension for file '" + file.getName() + "'");
}
Constructor<? extends FileRepositoryCollection> ctor;
try {
ctor = clazz.getConstructor(File.class); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new MolgenisDataException(
"Exception creating ["
+ clazz
+ "] missing constructor FileRepositorySource(File file)");
} // depends on control dependency: [catch], data = [none]
FileRepositoryCollection fileRepositoryCollection = BeanUtils.instantiateClass(ctor, file);
autowireCapableBeanFactory.autowireBeanProperties(
fileRepositoryCollection, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
try {
fileRepositoryCollection.init(); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
throw new RuntimeException(e);
} // depends on control dependency: [catch], data = [none]
return fileRepositoryCollection;
} } |
public class class_name {
static String md5(String input) {
if (input == null || input.length() == 0) {
throw new IllegalArgumentException("Input string must not be blank.");
}
try {
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(input.getBytes());
byte[] messageDigest = algorithm.digest();
StringBuilder hexString = new StringBuilder();
for (byte messageByte : messageDigest) {
hexString.append(Integer.toHexString((messageByte & 0xFF) | 0x100).substring(1, 3));
}
return hexString.toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
} } | public class class_name {
static String md5(String input) {
if (input == null || input.length() == 0) {
throw new IllegalArgumentException("Input string must not be blank.");
}
try {
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset(); // depends on control dependency: [try], data = [none]
algorithm.update(input.getBytes()); // depends on control dependency: [try], data = [none]
byte[] messageDigest = algorithm.digest();
StringBuilder hexString = new StringBuilder();
for (byte messageByte : messageDigest) {
hexString.append(Integer.toHexString((messageByte & 0xFF) | 0x100).substring(1, 3)); // depends on control dependency: [for], data = [messageByte]
}
return hexString.toString(); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new RuntimeException(e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
protected void processContext(ActionContext actionContext) throws ServletException, IOException {
Action action = null;
try {
// Find action binding
ActionBinding actionBinding = findActionBinding(actionContext);
// Create action
if (actionBinding != null) {
action = actionBinding.create(actionContext);
}
if (action == null) {
throw new ActionException("No action bound to path " + actionContext.getPath());
}
// Read request parameters
action.readParameters();
// Execute action (generate response)
action.execute();
} catch (ActionException actionException) {
// Handle action errors
try {
ErrorAction errorAction = new ErrorAction(actionContext);
errorAction.setError(actionException);
errorAction.execute();
} catch (ActionException actionException1) {
throw new ServletException(actionException);
}
}
} } | public class class_name {
protected void processContext(ActionContext actionContext) throws ServletException, IOException {
Action action = null;
try {
// Find action binding
ActionBinding actionBinding = findActionBinding(actionContext);
// Create action
if (actionBinding != null) {
action = actionBinding.create(actionContext);
// depends on control dependency: [if], data = [none]
}
if (action == null) {
throw new ActionException("No action bound to path " + actionContext.getPath());
}
// Read request parameters
action.readParameters();
// Execute action (generate response)
action.execute();
} catch (ActionException actionException) {
// Handle action errors
try {
ErrorAction errorAction = new ErrorAction(actionContext);
errorAction.setError(actionException);
// depends on control dependency: [try], data = [none]
errorAction.execute();
// depends on control dependency: [try], data = [none]
} catch (ActionException actionException1) {
throw new ServletException(actionException);
}
// depends on control dependency: [catch], data = [none]
}
} } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.