code stringlengths 130 281k | code_dependency stringlengths 182 306k |
|---|---|
public class class_name {
public static ForwardCurve createForwardCurveFromForwards(String name, double[] times, double[] givenForwards, double paymentOffset) {
ForwardCurve forwardCurve = new ForwardCurve(name, paymentOffset, InterpolationEntityForward.FORWARD, null);
for(int timeIndex=0; timeIndex<times.length;timeIndex++) {
double fixingTime = times[timeIndex];
boolean isParameter = (fixingTime > 0);
forwardCurve.addForward(null, fixingTime, givenForwards[timeIndex], isParameter);
}
return forwardCurve;
} } | public class class_name {
public static ForwardCurve createForwardCurveFromForwards(String name, double[] times, double[] givenForwards, double paymentOffset) {
ForwardCurve forwardCurve = new ForwardCurve(name, paymentOffset, InterpolationEntityForward.FORWARD, null);
for(int timeIndex=0; timeIndex<times.length;timeIndex++) {
double fixingTime = times[timeIndex];
boolean isParameter = (fixingTime > 0);
forwardCurve.addForward(null, fixingTime, givenForwards[timeIndex], isParameter); // depends on control dependency: [for], data = [timeIndex]
}
return forwardCurve;
} } |
public class class_name {
public void setNavigationDrawer(final int status){
final View homeView = getter.getView("home", 0);
final View leftDrawer = getter.getView("left_drawer", 0);
try{
switch (status) {
case CLOSED:
if(leftDrawer != null && homeView != null && leftDrawer.isShown()){
clicker.clickOnScreen(homeView);
}
break;
case OPENED:
if(leftDrawer != null && homeView != null && !leftDrawer.isShown()){
clicker.clickOnScreen(homeView);
Condition condition = new Condition() {
@Override
public boolean isSatisfied() {
return leftDrawer.isShown();
}
};
waiter.waitForCondition(condition, Timeout.getSmallTimeout());
}
break;
}
}catch (Exception ignored){}
} } | public class class_name {
public void setNavigationDrawer(final int status){
final View homeView = getter.getView("home", 0);
final View leftDrawer = getter.getView("left_drawer", 0);
try{
switch (status) {
case CLOSED:
if(leftDrawer != null && homeView != null && leftDrawer.isShown()){
clicker.clickOnScreen(homeView); // depends on control dependency: [if], data = [none]
}
break;
case OPENED:
if(leftDrawer != null && homeView != null && !leftDrawer.isShown()){
clicker.clickOnScreen(homeView); // depends on control dependency: [if], data = [none]
Condition condition = new Condition() {
@Override
public boolean isSatisfied() {
return leftDrawer.isShown();
}
};
waiter.waitForCondition(condition, Timeout.getSmallTimeout()); // depends on control dependency: [if], data = [none]
}
break;
}
}catch (Exception ignored){} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private ScanStatus resplitPartiallyCompleteTasks(ScanStatus status) {
boolean anyUpdated = false;
int nextTaskId = -1;
for (ScanRangeStatus complete : status.getCompleteScanRanges()) {
if (complete.getResplitRange().isPresent()) {
// This task only partially completed; there are still more data to scan.
if (nextTaskId == -1) {
nextTaskId = getNextTaskId(status);
}
ScanRange resplitRange = complete.getResplitRange().get();
// Resplit the un-scanned portion into new ranges
List<ScanRange> subRanges = resplit(complete.getPlacement(), resplitRange, status.getOptions().getRangeScanSplitSize());
// Create new tasks for each subrange that are immediately available for being queued.
List<ScanRangeStatus> resplitStatuses = Lists.newArrayListWithCapacity(subRanges.size());
for (ScanRange subRange : subRanges) {
resplitStatuses.add(
new ScanRangeStatus(nextTaskId++, complete.getPlacement(), subRange,
complete.getBatchId(), complete.getBlockedByBatchId(), complete.getConcurrencyId()));
}
_scanStatusDAO.resplitScanRangeTask(status.getScanId(), complete.getTaskId(), resplitStatuses);
anyUpdated = true;
}
}
if (!anyUpdated) {
return status;
}
// Slightly inefficient to reload but less risky than trying to keep the DAO and in-memory object in sync
return _scanStatusDAO.getScanStatus(status.getScanId());
} } | public class class_name {
private ScanStatus resplitPartiallyCompleteTasks(ScanStatus status) {
boolean anyUpdated = false;
int nextTaskId = -1;
for (ScanRangeStatus complete : status.getCompleteScanRanges()) {
if (complete.getResplitRange().isPresent()) {
// This task only partially completed; there are still more data to scan.
if (nextTaskId == -1) {
nextTaskId = getNextTaskId(status); // depends on control dependency: [if], data = [none]
}
ScanRange resplitRange = complete.getResplitRange().get();
// Resplit the un-scanned portion into new ranges
List<ScanRange> subRanges = resplit(complete.getPlacement(), resplitRange, status.getOptions().getRangeScanSplitSize());
// Create new tasks for each subrange that are immediately available for being queued.
List<ScanRangeStatus> resplitStatuses = Lists.newArrayListWithCapacity(subRanges.size());
for (ScanRange subRange : subRanges) {
resplitStatuses.add(
new ScanRangeStatus(nextTaskId++, complete.getPlacement(), subRange,
complete.getBatchId(), complete.getBlockedByBatchId(), complete.getConcurrencyId())); // depends on control dependency: [for], data = [none]
}
_scanStatusDAO.resplitScanRangeTask(status.getScanId(), complete.getTaskId(), resplitStatuses); // depends on control dependency: [if], data = [none]
anyUpdated = true; // depends on control dependency: [if], data = [none]
}
}
if (!anyUpdated) {
return status; // depends on control dependency: [if], data = [none]
}
// Slightly inefficient to reload but less risky than trying to keep the DAO and in-memory object in sync
return _scanStatusDAO.getScanStatus(status.getScanId());
} } |
public class class_name {
private void garbageCollectCompletedTasks() {
for (Iterator<TaskAttemptID> iter = tasks.keySet().iterator();
iter.hasNext();) {
TaskAttemptID taskId = iter.next();
SimulatorTaskInProgress tip = tasks.get(taskId);
if (tip.getTaskStatus().getRunState() != State.RUNNING) {
iter.remove();
if (LOG.isDebugEnabled()) {
LOG.debug("Garbage collected SimulatorTIP, taskId=" + taskId);
}
// We don't have to / must not touch usedMapSlots and usedReduceSlots
// as those were already updated by processTaskAttemptCompletionEvent()
// when the task switched its state from running
}
}
} } | public class class_name {
private void garbageCollectCompletedTasks() {
for (Iterator<TaskAttemptID> iter = tasks.keySet().iterator();
iter.hasNext();) {
TaskAttemptID taskId = iter.next();
SimulatorTaskInProgress tip = tasks.get(taskId);
if (tip.getTaskStatus().getRunState() != State.RUNNING) {
iter.remove(); // depends on control dependency: [if], data = [none]
if (LOG.isDebugEnabled()) {
LOG.debug("Garbage collected SimulatorTIP, taskId=" + taskId); // depends on control dependency: [if], data = [none]
}
// We don't have to / must not touch usedMapSlots and usedReduceSlots
// as those were already updated by processTaskAttemptCompletionEvent()
// when the task switched its state from running
}
}
} } |
public class class_name {
static Asset createFromFile(final String fileName, AccessMode mode)
{
File file = new File(fileName);
if (!file.exists()) {
return null;
}
throw new UnsupportedOperationException();
// _FileAsset pAsset;
// int result;
// long length;
// int fd;
//
// fd = open(fileName, O_RDONLY | O_BINARY);
// if (fd < 0)
// return null;
//
// /*
// * Under Linux, the lseek fails if we actually opened a directory. To
// * be correct we should test the file type explicitly, but since we
// * always open things read-only it doesn't really matter, so there's
// * no value in incurring the extra overhead of an fstat() call.
// */
// // TODO(kroot): replace this with fstat despite the plea above.
// #if 1
// length = lseek64(fd, 0, SEEK_END);
// if (length < 0) {
// ::close(fd);
// return null;
// }
// (void) lseek64(fd, 0, SEEK_SET);
// #else
// struct stat st;
// if (fstat(fd, &st) < 0) {
// ::close(fd);
// return null;
// }
//
// if (!S_ISREG(st.st_mode)) {
// ::close(fd);
// return null;
// }
// #endif
//
// pAsset = new _FileAsset;
// result = pAsset.openChunk(fileName, fd, 0, length);
// if (result != NO_ERROR) {
// delete pAsset;
// return null;
// }
//
// pAsset.mAccessMode = mode;
// return pAsset;
} } | public class class_name {
static Asset createFromFile(final String fileName, AccessMode mode)
{
File file = new File(fileName);
if (!file.exists()) {
return null; // depends on control dependency: [if], data = [none]
}
throw new UnsupportedOperationException();
// _FileAsset pAsset;
// int result;
// long length;
// int fd;
//
// fd = open(fileName, O_RDONLY | O_BINARY);
// if (fd < 0)
// return null;
//
// /*
// * Under Linux, the lseek fails if we actually opened a directory. To
// * be correct we should test the file type explicitly, but since we
// * always open things read-only it doesn't really matter, so there's
// * no value in incurring the extra overhead of an fstat() call.
// */
// // TODO(kroot): replace this with fstat despite the plea above.
// #if 1
// length = lseek64(fd, 0, SEEK_END);
// if (length < 0) {
// ::close(fd);
// return null;
// }
// (void) lseek64(fd, 0, SEEK_SET);
// #else
// struct stat st;
// if (fstat(fd, &st) < 0) {
// ::close(fd);
// return null;
// }
//
// if (!S_ISREG(st.st_mode)) {
// ::close(fd);
// return null;
// }
// #endif
//
// pAsset = new _FileAsset;
// result = pAsset.openChunk(fileName, fd, 0, length);
// if (result != NO_ERROR) {
// delete pAsset;
// return null;
// }
//
// pAsset.mAccessMode = mode;
// return pAsset;
} } |
public class class_name {
public void marshall(PutThirdPartyJobSuccessResultRequest putThirdPartyJobSuccessResultRequest, ProtocolMarshaller protocolMarshaller) {
if (putThirdPartyJobSuccessResultRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(putThirdPartyJobSuccessResultRequest.getJobId(), JOBID_BINDING);
protocolMarshaller.marshall(putThirdPartyJobSuccessResultRequest.getClientToken(), CLIENTTOKEN_BINDING);
protocolMarshaller.marshall(putThirdPartyJobSuccessResultRequest.getCurrentRevision(), CURRENTREVISION_BINDING);
protocolMarshaller.marshall(putThirdPartyJobSuccessResultRequest.getContinuationToken(), CONTINUATIONTOKEN_BINDING);
protocolMarshaller.marshall(putThirdPartyJobSuccessResultRequest.getExecutionDetails(), EXECUTIONDETAILS_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(PutThirdPartyJobSuccessResultRequest putThirdPartyJobSuccessResultRequest, ProtocolMarshaller protocolMarshaller) {
if (putThirdPartyJobSuccessResultRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(putThirdPartyJobSuccessResultRequest.getJobId(), JOBID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(putThirdPartyJobSuccessResultRequest.getClientToken(), CLIENTTOKEN_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(putThirdPartyJobSuccessResultRequest.getCurrentRevision(), CURRENTREVISION_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(putThirdPartyJobSuccessResultRequest.getContinuationToken(), CONTINUATIONTOKEN_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(putThirdPartyJobSuccessResultRequest.getExecutionDetails(), EXECUTIONDETAILS_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 static boolean castToBoolean(Object object) {
// null is always false
if (object == null) {
return false;
}
// equality check is enough and faster than instanceof check, no need to check superclasses since Boolean is final
if (object.getClass() == Boolean.class) {
return (Boolean) object;
}
// if the object is not null and no Boolean, try to call an asBoolean() method on the object
return (Boolean) InvokerHelper.invokeMethod(object, "asBoolean", InvokerHelper.EMPTY_ARGS);
} } | public class class_name {
public static boolean castToBoolean(Object object) {
// null is always false
if (object == null) {
return false; // depends on control dependency: [if], data = [none]
}
// equality check is enough and faster than instanceof check, no need to check superclasses since Boolean is final
if (object.getClass() == Boolean.class) {
return (Boolean) object; // depends on control dependency: [if], data = [none]
}
// if the object is not null and no Boolean, try to call an asBoolean() method on the object
return (Boolean) InvokerHelper.invokeMethod(object, "asBoolean", InvokerHelper.EMPTY_ARGS);
} } |
public class class_name {
public void pause() {
synchronized (taskInfo) {
if (taskInfo.getStatus() == HttpDownStatus.PAUSE
|| taskInfo.getStatus() == HttpDownStatus.DONE) {
return;
}
long time = System.currentTimeMillis();
taskInfo.setStatus(HttpDownStatus.PAUSE);
taskInfo.setLastPauseTime(time);
for (ChunkInfo chunkInfo : taskInfo.getChunkInfoList()) {
if (chunkInfo.getStatus() != HttpDownStatus.DONE) {
chunkInfo.setStatus(HttpDownStatus.PAUSE);
chunkInfo.setLastPauseTime(time);
}
}
close();
}
if (callback != null) {
callback.onPause(this);
}
} } | public class class_name {
public void pause() {
synchronized (taskInfo) {
if (taskInfo.getStatus() == HttpDownStatus.PAUSE
|| taskInfo.getStatus() == HttpDownStatus.DONE) {
return; // depends on control dependency: [if], data = [none]
}
long time = System.currentTimeMillis();
taskInfo.setStatus(HttpDownStatus.PAUSE);
taskInfo.setLastPauseTime(time);
for (ChunkInfo chunkInfo : taskInfo.getChunkInfoList()) {
if (chunkInfo.getStatus() != HttpDownStatus.DONE) {
chunkInfo.setStatus(HttpDownStatus.PAUSE); // depends on control dependency: [if], data = [none]
chunkInfo.setLastPauseTime(time); // depends on control dependency: [if], data = [none]
}
}
close();
}
if (callback != null) {
callback.onPause(this); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static String getMapContents(Map m) {
StringBuffer sb = new StringBuffer(1000);
Object[] sortedArray = m.keySet().toArray();
Arrays.sort(sortedArray);
for (Object element : sortedArray) {
sb.append(element.toString() + " - " + m.get(element) + System.getProperty("line.separator"));
}
return sb.toString();
} } | public class class_name {
public static String getMapContents(Map m) {
StringBuffer sb = new StringBuffer(1000);
Object[] sortedArray = m.keySet().toArray();
Arrays.sort(sortedArray);
for (Object element : sortedArray) {
sb.append(element.toString() + " - " + m.get(element) + System.getProperty("line.separator"));
}
return sb.toString(); // depends on control dependency: [for], data = [none]
} } |
public class class_name {
public static int getPage(final HttpServletRequest request) {
int ret = 1;
final String p = request.getParameter("p");
if (Strings.isNumeric(p)) {
try {
ret = Integer.parseInt(p);
} catch (final Exception e) {
// ignored
}
}
if (1 > ret) {
ret = 1;
}
return ret;
} } | public class class_name {
public static int getPage(final HttpServletRequest request) {
int ret = 1;
final String p = request.getParameter("p");
if (Strings.isNumeric(p)) {
try {
ret = Integer.parseInt(p); // depends on control dependency: [try], data = [none]
} catch (final Exception e) {
// ignored
} // depends on control dependency: [catch], data = [none]
}
if (1 > ret) {
ret = 1; // depends on control dependency: [if], data = [none]
}
return ret;
} } |
public class class_name {
private SummaryMetricFamily fromHistogram(List<Map.Entry<MetricName, Histogram>> histogramsWithSameName) {
final SummaryMetricFamily summaryMetricFamily = getSummaryMetricFamily(histogramsWithSameName, "");
for (Map.Entry<MetricName, Histogram> entry : histogramsWithSameName) {
addSummaryMetric(summaryMetricFamily, entry.getKey(), entry.getValue().getSnapshot(), 1.0D, entry.getValue().getCount());
}
return summaryMetricFamily;
} } | public class class_name {
private SummaryMetricFamily fromHistogram(List<Map.Entry<MetricName, Histogram>> histogramsWithSameName) {
final SummaryMetricFamily summaryMetricFamily = getSummaryMetricFamily(histogramsWithSameName, "");
for (Map.Entry<MetricName, Histogram> entry : histogramsWithSameName) {
addSummaryMetric(summaryMetricFamily, entry.getKey(), entry.getValue().getSnapshot(), 1.0D, entry.getValue().getCount()); // depends on control dependency: [for], data = [entry]
}
return summaryMetricFamily;
} } |
public class class_name {
public String getPrefixedString(int fieldSize, Charset cs) {
int len = 0;
switch (fieldSize) {
case 1:
len = _buf.get();
break;
case 2:
len = _buf.getShort();
break;
case 4:
len = _buf.getInt();
break;
default:
throw new IllegalArgumentException("Illegal argument, field size should be 1,2 or 4 and fieldSize is: " + fieldSize);
}
if (len == 0) {
return "";
}
int oldLimit = _buf.limit();
try {
_buf.limit(_buf.position() + len);
byte[] bytes = new byte[len];
_buf.get(bytes, 0, len);
String retVal = cs.decode(java.nio.ByteBuffer.wrap(bytes)).toString();
return retVal;
} finally {
_buf.limit(oldLimit);
}
} } | public class class_name {
public String getPrefixedString(int fieldSize, Charset cs) {
int len = 0;
switch (fieldSize) {
case 1:
len = _buf.get();
break;
case 2:
len = _buf.getShort();
break;
case 4:
len = _buf.getInt();
break;
default:
throw new IllegalArgumentException("Illegal argument, field size should be 1,2 or 4 and fieldSize is: " + fieldSize);
}
if (len == 0) {
return ""; // depends on control dependency: [if], data = [none]
}
int oldLimit = _buf.limit();
try {
_buf.limit(_buf.position() + len); // depends on control dependency: [try], data = [none]
byte[] bytes = new byte[len];
_buf.get(bytes, 0, len); // depends on control dependency: [try], data = [none]
String retVal = cs.decode(java.nio.ByteBuffer.wrap(bytes)).toString();
return retVal; // depends on control dependency: [try], data = [none]
} finally {
_buf.limit(oldLimit);
}
} } |
public class class_name {
public void waitForState(State state, Timespan timeout)
throws TimeoutException, InterruptedException
{
long endTime = timeout == null ? 0 : timeout.futureTimeMillis(_clock);
synchronized(_lock)
{
while(_state != state)
{
ConcurrentUtils.awaitUntil(_clock, _lock, endTime);
}
}
} } | public class class_name {
public void waitForState(State state, Timespan timeout)
throws TimeoutException, InterruptedException
{
long endTime = timeout == null ? 0 : timeout.futureTimeMillis(_clock);
synchronized(_lock)
{
while(_state != state)
{
ConcurrentUtils.awaitUntil(_clock, _lock, endTime); // depends on control dependency: [while], data = [none]
}
}
} } |
public class class_name {
protected void computeOutboundInterfaces() {
if(logger.isDebugEnabled()) {
logger.debug("Outbound Interface List : ");
}
List<SipURI> newlyComputedOutboundInterfaces = new CopyOnWriteArrayList<SipURI>();
Set<String> newlyComputedOutboundInterfacesIpAddresses = new CopyOnWriteArraySet<String>();
Iterator<MobicentsExtendedListeningPoint> it = getExtendedListeningPoints();
while (it.hasNext()) {
MobicentsExtendedListeningPoint extendedListeningPoint = it
.next();
for(String ipAddress : extendedListeningPoint.getIpAddresses()) {
try {
newlyComputedOutboundInterfacesIpAddresses.add(ipAddress);
javax.sip.address.SipURI jainSipURI = SipFactoryImpl.addressFactory.createSipURI(
null, ipAddress);
jainSipURI.setPort(extendedListeningPoint.getPort());
jainSipURI.setTransportParam(extendedListeningPoint.getTransport());
SipURI sipURI = new SipURIImpl(jainSipURI, ModifiableRule.NotModifiable);
newlyComputedOutboundInterfaces.add(sipURI);
if(logger.isDebugEnabled()) {
logger.debug("Outbound Interface : " + jainSipURI);
}
} catch (ParseException e) {
logger.error("cannot add the following listening point " +
ipAddress + ":" +
extendedListeningPoint.getPort() + ";transport=" +
extendedListeningPoint.getTransport() + " to the outbound interfaces", e);
}
}
}
outboundInterfaces = newlyComputedOutboundInterfaces;
outboundInterfacesIpAddresses = newlyComputedOutboundInterfacesIpAddresses;
} } | public class class_name {
protected void computeOutboundInterfaces() {
if(logger.isDebugEnabled()) {
logger.debug("Outbound Interface List : "); // depends on control dependency: [if], data = [none]
}
List<SipURI> newlyComputedOutboundInterfaces = new CopyOnWriteArrayList<SipURI>();
Set<String> newlyComputedOutboundInterfacesIpAddresses = new CopyOnWriteArraySet<String>();
Iterator<MobicentsExtendedListeningPoint> it = getExtendedListeningPoints();
while (it.hasNext()) {
MobicentsExtendedListeningPoint extendedListeningPoint = it
.next();
for(String ipAddress : extendedListeningPoint.getIpAddresses()) {
try {
newlyComputedOutboundInterfacesIpAddresses.add(ipAddress);
javax.sip.address.SipURI jainSipURI = SipFactoryImpl.addressFactory.createSipURI(
null, ipAddress);
jainSipURI.setPort(extendedListeningPoint.getPort());
jainSipURI.setTransportParam(extendedListeningPoint.getTransport());
SipURI sipURI = new SipURIImpl(jainSipURI, ModifiableRule.NotModifiable);
newlyComputedOutboundInterfaces.add(sipURI);
if(logger.isDebugEnabled()) {
logger.debug("Outbound Interface : " + jainSipURI); // depends on control dependency: [if], data = [none]
}
} catch (ParseException e) {
logger.error("cannot add the following listening point " +
ipAddress + ":" +
extendedListeningPoint.getPort() + ";transport=" +
extendedListeningPoint.getTransport() + " to the outbound interfaces", e);
}
}
}
outboundInterfaces = newlyComputedOutboundInterfaces;
outboundInterfacesIpAddresses = newlyComputedOutboundInterfacesIpAddresses;
} } |
public class class_name {
public static String getRequestURI(HttpServletRequest httpRequest) {
final StringBuilder url = new StringBuilder(100).append(httpRequest.getRequestURI());
if (httpRequest.getQueryString() != null) {
url.append('?').append(httpRequest.getQueryString());
}
return url.toString();
} } | public class class_name {
public static String getRequestURI(HttpServletRequest httpRequest) {
final StringBuilder url = new StringBuilder(100).append(httpRequest.getRequestURI());
if (httpRequest.getQueryString() != null) {
url.append('?').append(httpRequest.getQueryString()); // depends on control dependency: [if], data = [(httpRequest.getQueryString()]
}
return url.toString();
} } |
public class class_name {
public void setVolumesModifications(java.util.Collection<VolumeModification> volumesModifications) {
if (volumesModifications == null) {
this.volumesModifications = null;
return;
}
this.volumesModifications = new com.amazonaws.internal.SdkInternalList<VolumeModification>(volumesModifications);
} } | public class class_name {
public void setVolumesModifications(java.util.Collection<VolumeModification> volumesModifications) {
if (volumesModifications == null) {
this.volumesModifications = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.volumesModifications = new com.amazonaws.internal.SdkInternalList<VolumeModification>(volumesModifications);
} } |
public class class_name {
private void transformRollupQueryToDownSampler() {
if (rollup_query != null) {
// TODO - clean up and handle fill
downsampler = new DownsamplingSpecification(
rollup_query.getRollupInterval().getIntervalSeconds() * 1000,
rollup_query.getRollupAgg(),
(downsampler != null ? downsampler.getFillPolicy() :
FillPolicy.ZERO));
rollup_query = null;
}
} } | public class class_name {
private void transformRollupQueryToDownSampler() {
if (rollup_query != null) {
// TODO - clean up and handle fill
downsampler = new DownsamplingSpecification(
rollup_query.getRollupInterval().getIntervalSeconds() * 1000,
rollup_query.getRollupAgg(),
(downsampler != null ? downsampler.getFillPolicy() :
FillPolicy.ZERO)); // depends on control dependency: [if], data = [none]
rollup_query = null; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public String generateBlackDuckNoticesReport(ProjectVersionView version, ReportFormatType reportFormat) throws InterruptedException, IntegrationException {
if (version.hasLink(ProjectVersionView.LICENSEREPORTS_LINK)) {
try {
logger.debug("Starting the Notices Report generation.");
String reportUrl = startGeneratingBlackDuckNoticesReport(version, reportFormat);
logger.debug("Waiting for the Notices Report to complete.");
ReportView reportInfo = isReportFinishedGenerating(reportUrl);
String contentLink = reportInfo.getFirstLink(ReportView.CONTENT_LINK).orElse(null);
if (contentLink == null) {
throw new BlackDuckIntegrationException("Could not find content link for the report at : " + reportUrl);
}
logger.debug("Getting the Notices Report content.");
String noticesReport = getNoticesReportContent(contentLink);
logger.debug("Finished retrieving the Notices Report.");
logger.debug("Cleaning up the Notices Report on the server.");
deleteBlackDuckReport(reportUrl);
return noticesReport;
} catch (IntegrationRestException e) {
if (e.getHttpStatusCode() == 402) {
// unlike the policy module, the licenseReports link is still present when the module is not enabled
logger.warn("Can not create the notice report, the Black Duck notice module is not enabled.");
} else {
throw e;
}
}
} else {
logger.warn("Can not create the notice report, the Black Duck notice module is not enabled.");
}
return null;
} } | public class class_name {
public String generateBlackDuckNoticesReport(ProjectVersionView version, ReportFormatType reportFormat) throws InterruptedException, IntegrationException {
if (version.hasLink(ProjectVersionView.LICENSEREPORTS_LINK)) {
try {
logger.debug("Starting the Notices Report generation."); // depends on control dependency: [try], data = [none]
String reportUrl = startGeneratingBlackDuckNoticesReport(version, reportFormat);
logger.debug("Waiting for the Notices Report to complete."); // depends on control dependency: [try], data = [none]
ReportView reportInfo = isReportFinishedGenerating(reportUrl);
String contentLink = reportInfo.getFirstLink(ReportView.CONTENT_LINK).orElse(null);
if (contentLink == null) {
throw new BlackDuckIntegrationException("Could not find content link for the report at : " + reportUrl);
}
logger.debug("Getting the Notices Report content."); // depends on control dependency: [try], data = [none]
String noticesReport = getNoticesReportContent(contentLink);
logger.debug("Finished retrieving the Notices Report."); // depends on control dependency: [try], data = [none]
logger.debug("Cleaning up the Notices Report on the server."); // depends on control dependency: [try], data = [none]
deleteBlackDuckReport(reportUrl); // depends on control dependency: [try], data = [none]
return noticesReport; // depends on control dependency: [try], data = [none]
} catch (IntegrationRestException e) {
if (e.getHttpStatusCode() == 402) {
// unlike the policy module, the licenseReports link is still present when the module is not enabled
logger.warn("Can not create the notice report, the Black Duck notice module is not enabled."); // depends on control dependency: [if], data = [none]
} else {
throw e;
}
} // depends on control dependency: [catch], data = [none]
} else {
logger.warn("Can not create the notice report, the Black Duck notice module is not enabled.");
}
return null;
} } |
public class class_name {
public double getPValue(final String method) {
double p = Double.NaN;
if ("t".equals(method)) {
double[] baselineValues = new double[baselineMetricPerDimension.values().size()];
int i = 0;
for (Double d : baselineMetricPerDimension.values()) {
baselineValues[i] = d;
i++;
}
double[] testValues = new double[testMetricPerDimension.values().size()];
i = 0;
for (Double d : testMetricPerDimension.values()) {
testValues[i] = d;
i++;
}
p = TestUtils.tTest(baselineValues, testValues);
} else {
double[] baselineValues = new double[dimensions.size()];
int i = 0;
for (Object d : dimensions) {
baselineValues[i] = baselineMetricPerDimension.get(d);
i++;
}
double[] testValues = new double[dimensions.size()];
i = 0;
for (Object d : dimensions) {
testValues[i] = testMetricPerDimension.get(d);
i++;
}
if ("pairedT".equals(method)) {
p = TestUtils.pairedTTest(baselineValues, testValues);
} else if ("wilcoxon".equals(method)) {
p = new WilcoxonSignedRankTest().wilcoxonSignedRankTest(baselineValues, testValues, false);
}
}
return p;
} } | public class class_name {
public double getPValue(final String method) {
double p = Double.NaN;
if ("t".equals(method)) {
double[] baselineValues = new double[baselineMetricPerDimension.values().size()];
int i = 0;
for (Double d : baselineMetricPerDimension.values()) {
baselineValues[i] = d; // depends on control dependency: [for], data = [d]
i++; // depends on control dependency: [for], data = [none]
}
double[] testValues = new double[testMetricPerDimension.values().size()];
i = 0; // depends on control dependency: [if], data = [none]
for (Double d : testMetricPerDimension.values()) {
testValues[i] = d; // depends on control dependency: [for], data = [d]
i++; // depends on control dependency: [for], data = [none]
}
p = TestUtils.tTest(baselineValues, testValues); // depends on control dependency: [if], data = [none]
} else {
double[] baselineValues = new double[dimensions.size()];
int i = 0;
for (Object d : dimensions) {
baselineValues[i] = baselineMetricPerDimension.get(d); // depends on control dependency: [for], data = [d]
i++; // depends on control dependency: [for], data = [none]
}
double[] testValues = new double[dimensions.size()];
i = 0; // depends on control dependency: [if], data = [none]
for (Object d : dimensions) {
testValues[i] = testMetricPerDimension.get(d); // depends on control dependency: [for], data = [d]
i++; // depends on control dependency: [for], data = [none]
}
if ("pairedT".equals(method)) {
p = TestUtils.pairedTTest(baselineValues, testValues); // depends on control dependency: [if], data = [none]
} else if ("wilcoxon".equals(method)) {
p = new WilcoxonSignedRankTest().wilcoxonSignedRankTest(baselineValues, testValues, false); // depends on control dependency: [if], data = [none]
}
}
return p;
} } |
public class class_name {
private MethodRefAmp findLocalMethod()
{
ServiceRefAmp serviceRefLocal = _serviceRef.getLocalService();
if (serviceRefLocal == null) {
return null;
}
MethodRefActive methodRefLocal = _methodRefLocal;
MethodRefAmp methodRef;
if (methodRefLocal != null) {
methodRef = methodRefLocal.getMethod(serviceRefLocal);
if (methodRef != null) {
return methodRef;
}
}
if (_type != null) {
methodRef = serviceRefLocal.methodByName(_name, _type);
}
else {
methodRef = serviceRefLocal.methodByName(_name);
}
_methodRefLocal = new MethodRefActive(serviceRefLocal, methodRef);
return methodRef;
} } | public class class_name {
private MethodRefAmp findLocalMethod()
{
ServiceRefAmp serviceRefLocal = _serviceRef.getLocalService();
if (serviceRefLocal == null) {
return null; // depends on control dependency: [if], data = [none]
}
MethodRefActive methodRefLocal = _methodRefLocal;
MethodRefAmp methodRef;
if (methodRefLocal != null) {
methodRef = methodRefLocal.getMethod(serviceRefLocal); // depends on control dependency: [if], data = [none]
if (methodRef != null) {
return methodRef; // depends on control dependency: [if], data = [none]
}
}
if (_type != null) {
methodRef = serviceRefLocal.methodByName(_name, _type); // depends on control dependency: [if], data = [none]
}
else {
methodRef = serviceRefLocal.methodByName(_name); // depends on control dependency: [if], data = [none]
}
_methodRefLocal = new MethodRefActive(serviceRefLocal, methodRef);
return methodRef;
} } |
public class class_name {
public void disableTab (Tab tab, boolean disable) {
checkIfTabsBelongsToThisPane(tab);
TabButtonTable buttonTable = tabsButtonMap.get(tab);
buttonTable.button.setDisabled(disable);
if (activeTab == tab && disable) {
if (selectFirstEnabledTab()) {
return;
}
// there isn't any tab we can switch to
activeTab = null;
notifyListenersSwitched(null);
}
if (activeTab == null && allowTabDeselect == false) {
selectFirstEnabledTab();
}
} } | public class class_name {
public void disableTab (Tab tab, boolean disable) {
checkIfTabsBelongsToThisPane(tab);
TabButtonTable buttonTable = tabsButtonMap.get(tab);
buttonTable.button.setDisabled(disable);
if (activeTab == tab && disable) {
if (selectFirstEnabledTab()) {
return; // depends on control dependency: [if], data = [none]
}
// there isn't any tab we can switch to
activeTab = null; // depends on control dependency: [if], data = [none]
notifyListenersSwitched(null); // depends on control dependency: [if], data = [none]
}
if (activeTab == null && allowTabDeselect == false) {
selectFirstEnabledTab(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void marshall(ELBInfo eLBInfo, ProtocolMarshaller protocolMarshaller) {
if (eLBInfo == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(eLBInfo.getName(), NAME_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(ELBInfo eLBInfo, ProtocolMarshaller protocolMarshaller) {
if (eLBInfo == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(eLBInfo.getName(), NAME_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
@Override
public void suspend()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(tc, "suspend");
_suspendedUOWType = ((UOWCurrent) _tranManager).getUOWType();
switch (_suspendedUOWType)
{
case UOWCurrent.UOW_LOCAL:
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "suspending (local)");
}
_suspendedUOW = LocalTranCurrentSet.instance().suspend();
break;
case UOWCurrent.UOW_GLOBAL:
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "suspending (global)");
}
_suspendedUOW = _tranManager.suspend();
break;
case UOWCurrent.UOW_NONE:
_suspendedUOW = null;
break;
default:
break;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "suspend", _suspendedUOWType);
} } | public class class_name {
@Override
public void suspend()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(tc, "suspend");
_suspendedUOWType = ((UOWCurrent) _tranManager).getUOWType();
switch (_suspendedUOWType)
{
case UOWCurrent.UOW_LOCAL:
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "suspending (local)"); // depends on control dependency: [if], data = [none]
}
_suspendedUOW = LocalTranCurrentSet.instance().suspend();
break;
case UOWCurrent.UOW_GLOBAL:
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "suspending (global)"); // depends on control dependency: [if], data = [none]
}
_suspendedUOW = _tranManager.suspend();
break;
case UOWCurrent.UOW_NONE:
_suspendedUOW = null;
break;
default:
break;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "suspend", _suspendedUOWType);
} } |
public class class_name {
public List<? extends TypeMirror> interfaceGenericTypesFor(TypeElement element, String interfaceName) {
for (TypeMirror tm : element.getInterfaces()) {
DeclaredType declaredType = (DeclaredType) tm;
Element declaredElement = declaredType.asElement();
if (declaredElement instanceof TypeElement) {
TypeElement te = (TypeElement) declaredElement;
if (interfaceName.equals(te.getQualifiedName().toString())) {
return declaredType.getTypeArguments();
}
}
}
return Collections.emptyList();
} } | public class class_name {
public List<? extends TypeMirror> interfaceGenericTypesFor(TypeElement element, String interfaceName) {
for (TypeMirror tm : element.getInterfaces()) {
DeclaredType declaredType = (DeclaredType) tm;
Element declaredElement = declaredType.asElement();
if (declaredElement instanceof TypeElement) {
TypeElement te = (TypeElement) declaredElement;
if (interfaceName.equals(te.getQualifiedName().toString())) {
return declaredType.getTypeArguments(); // depends on control dependency: [if], data = [none]
}
}
}
return Collections.emptyList();
} } |
public class class_name {
@Override
public <T> T unwrap(Class<T> paramClass)
{
try
{
return (T) this;
}
catch (ClassCastException ccex)
{
throw new PersistenceException("Provider does not support the call for class type:[" + paramClass + "]");
}
} } | public class class_name {
@Override
public <T> T unwrap(Class<T> paramClass)
{
try
{
return (T) this; // depends on control dependency: [try], data = [none]
}
catch (ClassCastException ccex)
{
throw new PersistenceException("Provider does not support the call for class type:[" + paramClass + "]");
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public String dump(int maxLen) {
String s = dump();
if (s.length() > maxLen) {
if (maxLen > 3) {
s = s.substring(0, maxLen - 3) + "...";
} else {
s = s.substring(0, maxLen);
}
}
return s;
} } | public class class_name {
public String dump(int maxLen) {
String s = dump();
if (s.length() > maxLen) {
if (maxLen > 3) {
s = s.substring(0, maxLen - 3) + "..."; // depends on control dependency: [if], data = [3)]
} else {
s = s.substring(0, maxLen); // depends on control dependency: [if], data = [none]
}
}
return s;
} } |
public class class_name {
private <T extends Attribute.Compound> void complete(Annotate.AnnotateRepeatedContext<T> ctx) {
Log log = ctx.log;
Env<AttrContext> env = ctx.env;
JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
try {
// TODO: can we reduce duplication in the following branches?
if (ctx.isTypeCompound) {
Assert.check(!isTypesEmpty());
if (isTypesEmpty()) {
return;
}
List<Attribute.TypeCompound> result = List.nil();
for (Attribute.TypeCompound a : getTypeAttributes()) {
if (a instanceof Placeholder) {
@SuppressWarnings("unchecked")
Placeholder<Attribute.TypeCompound> ph = (Placeholder<Attribute.TypeCompound>) a;
Attribute.TypeCompound replacement = replaceOne(ph, ph.getRepeatedContext());
if (null != replacement) {
result = result.prepend(replacement);
}
} else {
result = result.prepend(a);
}
}
type_attributes = result.reverse();
Assert.check(SymbolMetadata.this.getTypePlaceholders().isEmpty());
} else {
Assert.check(!pendingCompletion());
if (isEmpty()) {
return;
}
List<Attribute.Compound> result = List.nil();
for (Attribute.Compound a : getDeclarationAttributes()) {
if (a instanceof Placeholder) {
@SuppressWarnings("unchecked")
Attribute.Compound replacement = replaceOne((Placeholder<T>) a, ctx);
if (null != replacement) {
result = result.prepend(replacement);
}
} else {
result = result.prepend(a);
}
}
attributes = result.reverse();
Assert.check(SymbolMetadata.this.getPlaceholders().isEmpty());
}
} finally {
log.useSource(oldSource);
}
} } | public class class_name {
private <T extends Attribute.Compound> void complete(Annotate.AnnotateRepeatedContext<T> ctx) {
Log log = ctx.log;
Env<AttrContext> env = ctx.env;
JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
try {
// TODO: can we reduce duplication in the following branches?
if (ctx.isTypeCompound) {
Assert.check(!isTypesEmpty()); // depends on control dependency: [if], data = [none]
if (isTypesEmpty()) {
return; // depends on control dependency: [if], data = [none]
}
List<Attribute.TypeCompound> result = List.nil();
for (Attribute.TypeCompound a : getTypeAttributes()) {
if (a instanceof Placeholder) {
@SuppressWarnings("unchecked")
Placeholder<Attribute.TypeCompound> ph = (Placeholder<Attribute.TypeCompound>) a;
Attribute.TypeCompound replacement = replaceOne(ph, ph.getRepeatedContext());
if (null != replacement) {
result = result.prepend(replacement); // depends on control dependency: [if], data = [replacement)]
}
} else {
result = result.prepend(a); // depends on control dependency: [if], data = [none]
}
}
type_attributes = result.reverse(); // depends on control dependency: [if], data = [none]
Assert.check(SymbolMetadata.this.getTypePlaceholders().isEmpty()); // depends on control dependency: [if], data = [none]
} else {
Assert.check(!pendingCompletion()); // depends on control dependency: [if], data = [none]
if (isEmpty()) {
return; // depends on control dependency: [if], data = [none]
}
List<Attribute.Compound> result = List.nil();
for (Attribute.Compound a : getDeclarationAttributes()) {
if (a instanceof Placeholder) {
@SuppressWarnings("unchecked")
Attribute.Compound replacement = replaceOne((Placeholder<T>) a, ctx);
if (null != replacement) {
result = result.prepend(replacement); // depends on control dependency: [if], data = [replacement)]
}
} else {
result = result.prepend(a); // depends on control dependency: [if], data = [none]
}
}
attributes = result.reverse(); // depends on control dependency: [if], data = [none]
Assert.check(SymbolMetadata.this.getPlaceholders().isEmpty()); // depends on control dependency: [if], data = [none]
}
} finally {
log.useSource(oldSource);
}
} } |
public class class_name {
@Override
public Map<Integer, byte[]> traverseStreamGraphAndGenerateHashes(StreamGraph streamGraph) {
// The hash function used to generate the hash
final HashFunction hashFunction = Hashing.murmur3_128(0);
final Map<Integer, byte[]> hashes = new HashMap<>();
Set<Integer> visited = new HashSet<>();
Queue<StreamNode> remaining = new ArrayDeque<>();
// We need to make the source order deterministic. The source IDs are
// not returned in the same order, which means that submitting the same
// program twice might result in different traversal, which breaks the
// deterministic hash assignment.
List<Integer> sources = new ArrayList<>();
for (Integer sourceNodeId : streamGraph.getSourceIDs()) {
sources.add(sourceNodeId);
}
Collections.sort(sources);
//
// Traverse the graph in a breadth-first manner. Keep in mind that
// the graph is not a tree and multiple paths to nodes can exist.
//
// Start with source nodes
for (Integer sourceNodeId : sources) {
remaining.add(streamGraph.getStreamNode(sourceNodeId));
visited.add(sourceNodeId);
}
StreamNode currentNode;
while ((currentNode = remaining.poll()) != null) {
// Generate the hash code. Because multiple path exist to each
// node, we might not have all required inputs available to
// generate the hash code.
if (generateNodeHash(currentNode, hashFunction, hashes, streamGraph.isChainingEnabled(), streamGraph)) {
// Add the child nodes
for (StreamEdge outEdge : currentNode.getOutEdges()) {
StreamNode child = streamGraph.getTargetVertex(outEdge);
if (!visited.contains(child.getId())) {
remaining.add(child);
visited.add(child.getId());
}
}
} else {
// We will revisit this later.
visited.remove(currentNode.getId());
}
}
return hashes;
} } | public class class_name {
@Override
public Map<Integer, byte[]> traverseStreamGraphAndGenerateHashes(StreamGraph streamGraph) {
// The hash function used to generate the hash
final HashFunction hashFunction = Hashing.murmur3_128(0);
final Map<Integer, byte[]> hashes = new HashMap<>();
Set<Integer> visited = new HashSet<>();
Queue<StreamNode> remaining = new ArrayDeque<>();
// We need to make the source order deterministic. The source IDs are
// not returned in the same order, which means that submitting the same
// program twice might result in different traversal, which breaks the
// deterministic hash assignment.
List<Integer> sources = new ArrayList<>();
for (Integer sourceNodeId : streamGraph.getSourceIDs()) {
sources.add(sourceNodeId); // depends on control dependency: [for], data = [sourceNodeId]
}
Collections.sort(sources);
//
// Traverse the graph in a breadth-first manner. Keep in mind that
// the graph is not a tree and multiple paths to nodes can exist.
//
// Start with source nodes
for (Integer sourceNodeId : sources) {
remaining.add(streamGraph.getStreamNode(sourceNodeId)); // depends on control dependency: [for], data = [sourceNodeId]
visited.add(sourceNodeId); // depends on control dependency: [for], data = [sourceNodeId]
}
StreamNode currentNode;
while ((currentNode = remaining.poll()) != null) {
// Generate the hash code. Because multiple path exist to each
// node, we might not have all required inputs available to
// generate the hash code.
if (generateNodeHash(currentNode, hashFunction, hashes, streamGraph.isChainingEnabled(), streamGraph)) {
// Add the child nodes
for (StreamEdge outEdge : currentNode.getOutEdges()) {
StreamNode child = streamGraph.getTargetVertex(outEdge);
if (!visited.contains(child.getId())) {
remaining.add(child); // depends on control dependency: [if], data = [none]
visited.add(child.getId()); // depends on control dependency: [if], data = [none]
}
}
} else {
// We will revisit this later.
visited.remove(currentNode.getId()); // depends on control dependency: [if], data = [none]
}
}
return hashes;
} } |
public class class_name {
private void initializeUrlEncodedOrTextPlain(PageContext pc, char delimiter, boolean scriptProteced) {
BufferedReader reader = null;
try {
reader = pc.getHttpServletRequest().getReader();
raw = setFrom___(IOUtil.toString(reader, false), delimiter);
fillDecoded(raw, encoding, scriptProteced, pc.getApplicationContext().getSameFieldAsArray(SCOPE_FORM));
}
catch (Exception e) {
Log log = ThreadLocalPageContext.getConfig(pc).getLog("application");
if (log != null) log.error("form.scope", e);
fillDecodedEL(new URLItem[0], encoding, scriptProteced, pc.getApplicationContext().getSameFieldAsArray(SCOPE_FORM));
initException = e;
}
finally {
IOUtil.closeEL(reader);
}
} } | public class class_name {
private void initializeUrlEncodedOrTextPlain(PageContext pc, char delimiter, boolean scriptProteced) {
BufferedReader reader = null;
try {
reader = pc.getHttpServletRequest().getReader(); // depends on control dependency: [try], data = [none]
raw = setFrom___(IOUtil.toString(reader, false), delimiter); // depends on control dependency: [try], data = [none]
fillDecoded(raw, encoding, scriptProteced, pc.getApplicationContext().getSameFieldAsArray(SCOPE_FORM)); // depends on control dependency: [try], data = [none]
}
catch (Exception e) {
Log log = ThreadLocalPageContext.getConfig(pc).getLog("application");
if (log != null) log.error("form.scope", e);
fillDecodedEL(new URLItem[0], encoding, scriptProteced, pc.getApplicationContext().getSameFieldAsArray(SCOPE_FORM));
initException = e;
} // depends on control dependency: [catch], data = [none]
finally {
IOUtil.closeEL(reader);
}
} } |
public class class_name {
@Override
public void removeListener(IChemObjectListener col) {
if (chemObjectListeners == null) {
return;
}
List<IChemObjectListener> listeners = lazyChemObjectListeners();
if (listeners.contains(col)) {
listeners.remove(col);
}
} } | public class class_name {
@Override
public void removeListener(IChemObjectListener col) {
if (chemObjectListeners == null) {
return; // depends on control dependency: [if], data = [none]
}
List<IChemObjectListener> listeners = lazyChemObjectListeners();
if (listeners.contains(col)) {
listeners.remove(col); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private static List<Object> convertRepeatedFieldToList(Group g, int fieldIndex, boolean binaryAsString)
{
Type t = g.getType().getFields().get(fieldIndex);
assert t.getRepetition().equals(Type.Repetition.REPEATED);
int repeated = g.getFieldRepetitionCount(fieldIndex);
List<Object> vals = new ArrayList<>();
for (int i = 0; i < repeated; i++) {
if (t.isPrimitive()) {
vals.add(convertPrimitiveField(g, fieldIndex, i, binaryAsString));
} else {
vals.add(g.getGroup(fieldIndex, i));
}
}
return vals;
} } | public class class_name {
private static List<Object> convertRepeatedFieldToList(Group g, int fieldIndex, boolean binaryAsString)
{
Type t = g.getType().getFields().get(fieldIndex);
assert t.getRepetition().equals(Type.Repetition.REPEATED);
int repeated = g.getFieldRepetitionCount(fieldIndex);
List<Object> vals = new ArrayList<>();
for (int i = 0; i < repeated; i++) {
if (t.isPrimitive()) {
vals.add(convertPrimitiveField(g, fieldIndex, i, binaryAsString)); // depends on control dependency: [if], data = [none]
} else {
vals.add(g.getGroup(fieldIndex, i)); // depends on control dependency: [if], data = [none]
}
}
return vals;
} } |
public class class_name {
public static String simpleClassName(Class<?> clazz) {
String className = checkNotNull(clazz, "clazz").getName();
final int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
if (lastDotIdx > -1) {
return className.substring(lastDotIdx + 1);
}
return className;
} } | public class class_name {
public static String simpleClassName(Class<?> clazz) {
String className = checkNotNull(clazz, "clazz").getName();
final int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
if (lastDotIdx > -1) {
return className.substring(lastDotIdx + 1); // depends on control dependency: [if], data = [(lastDotIdx]
}
return className;
} } |
public class class_name {
private void registerModule(String[] packageList)
{
if (TraceComponent.isAnyTracingEnabled() && _tc.isEntryEnabled()) SibTr.entry(_tc, "registerModule", new Object[] { this, packageList });
for (int i = 0, rc = 0;(rc == 0) && (i < packageList.length); i++)
{
if (TraceComponent.isAnyTracingEnabled() && _tc.isDebugEnabled()) SibTr.debug(_tc, "Registering diagnostic module " + this +" for package: " + packageList[i]);
rc = FFDC.registerDiagnosticModule(this, packageList[i]);
if (rc != 0)
{
if (TraceComponent.isAnyTracingEnabled() && _tc.isDebugEnabled()) SibTr.debug(_tc, "Registration failed, return code=" + rc);
}
}
if (TraceComponent.isAnyTracingEnabled() && _tc.isEntryEnabled()) SibTr.exit(_tc, "registerModule");
} } | public class class_name {
private void registerModule(String[] packageList)
{
if (TraceComponent.isAnyTracingEnabled() && _tc.isEntryEnabled()) SibTr.entry(_tc, "registerModule", new Object[] { this, packageList });
for (int i = 0, rc = 0;(rc == 0) && (i < packageList.length); i++)
{
if (TraceComponent.isAnyTracingEnabled() && _tc.isDebugEnabled()) SibTr.debug(_tc, "Registering diagnostic module " + this +" for package: " + packageList[i]);
rc = FFDC.registerDiagnosticModule(this, packageList[i]); // depends on control dependency: [for], data = [i]
if (rc != 0)
{
if (TraceComponent.isAnyTracingEnabled() && _tc.isDebugEnabled()) SibTr.debug(_tc, "Registration failed, return code=" + rc);
}
}
if (TraceComponent.isAnyTracingEnabled() && _tc.isEntryEnabled()) SibTr.exit(_tc, "registerModule");
} } |
public class class_name {
public java.util.List<String> getInstancesToProtect() {
if (instancesToProtect == null) {
instancesToProtect = new com.amazonaws.internal.SdkInternalList<String>();
}
return instancesToProtect;
} } | public class class_name {
public java.util.List<String> getInstancesToProtect() {
if (instancesToProtect == null) {
instancesToProtect = new com.amazonaws.internal.SdkInternalList<String>(); // depends on control dependency: [if], data = [none]
}
return instancesToProtect;
} } |
public class class_name {
@BindTypeVariable
public Typed<SOURCE> getSourceType() {
final Position.Readable<SOURCE> source = getSourcePosition();
final Type result = narrow(source);
if (!TypeUtils.equals(result, source.getType())) {
return new Typed<SOURCE>() {
@Override
public Type getType() {
return result;
}
};
}
return source;
} } | public class class_name {
@BindTypeVariable
public Typed<SOURCE> getSourceType() {
final Position.Readable<SOURCE> source = getSourcePosition();
final Type result = narrow(source);
if (!TypeUtils.equals(result, source.getType())) {
return new Typed<SOURCE>() {
@Override
public Type getType() {
return result;
}
}; // depends on control dependency: [if], data = [none]
}
return source;
} } |
public class class_name {
@SuppressWarnings("unchecked")
public static BasicDBObjectBuilder start(final Map documentAsMap) {
BasicDBObjectBuilder builder = new BasicDBObjectBuilder();
Iterator<Map.Entry> i = documentAsMap.entrySet().iterator();
while (i.hasNext()) {
Map.Entry entry = i.next();
builder.add(entry.getKey().toString(), entry.getValue());
}
return builder;
} } | public class class_name {
@SuppressWarnings("unchecked")
public static BasicDBObjectBuilder start(final Map documentAsMap) {
BasicDBObjectBuilder builder = new BasicDBObjectBuilder();
Iterator<Map.Entry> i = documentAsMap.entrySet().iterator();
while (i.hasNext()) {
Map.Entry entry = i.next();
builder.add(entry.getKey().toString(), entry.getValue()); // depends on control dependency: [while], data = [none]
}
return builder;
} } |
public class class_name {
public Set<GraphObject> run()
{
/**
* Candidate contains all the graph objects that are the results of BFS.
* Eliminating nodes from candidate according to the reached counts
* will yield result.
*/
Map<GraphObject, Integer> candidate = new HashMap<GraphObject, Integer>();
Set<GraphObject> result = new HashSet<GraphObject>();
//for each set of states of entity, run BFS separately
for (Set<Node> source : sourceSet)
{
//run BFS for set of states of each entity
BFS bfs = new BFS (source, null, direction, limit);
Map<GraphObject, Integer> BFSResult = new HashMap<GraphObject, Integer>();
BFSResult.putAll(bfs.run());
/**
* Reached counts of the graph objects that are in BFSResult will
* be incremented by 1.
*/
for (GraphObject go : BFSResult.keySet())
{
setLabel(go, (getLabel(go) + 1));
}
//put BFS Result into candidate set
candidate.putAll(BFSResult);
}
/**
* Having a reached count equal to number of nodes in the source set
* indicates being in common stream.
*/
for(GraphObject go : candidate.keySet())
{
if (getLabel(go) == sourceSet.size())
{
result.add(go);
}
}
//Return the result of query
return result;
} } | public class class_name {
public Set<GraphObject> run()
{
/**
* Candidate contains all the graph objects that are the results of BFS.
* Eliminating nodes from candidate according to the reached counts
* will yield result.
*/
Map<GraphObject, Integer> candidate = new HashMap<GraphObject, Integer>();
Set<GraphObject> result = new HashSet<GraphObject>();
//for each set of states of entity, run BFS separately
for (Set<Node> source : sourceSet)
{
//run BFS for set of states of each entity
BFS bfs = new BFS (source, null, direction, limit);
Map<GraphObject, Integer> BFSResult = new HashMap<GraphObject, Integer>();
BFSResult.putAll(bfs.run());
// depends on control dependency: [for], data = [none]
/**
* Reached counts of the graph objects that are in BFSResult will
* be incremented by 1.
*/
for (GraphObject go : BFSResult.keySet())
{
setLabel(go, (getLabel(go) + 1));
// depends on control dependency: [for], data = [go]
}
//put BFS Result into candidate set
candidate.putAll(BFSResult);
// depends on control dependency: [for], data = [none]
}
/**
* Having a reached count equal to number of nodes in the source set
* indicates being in common stream.
*/
for(GraphObject go : candidate.keySet())
{
if (getLabel(go) == sourceSet.size())
{
result.add(go);
// depends on control dependency: [if], data = [none]
}
}
//Return the result of query
return result;
} } |
public class class_name {
public static <T extends GridDialect> T getDelegateOrNull(GridDialect gridDialect, Class<T> delegateType) {
if ( gridDialect.getClass() == delegateType ) {
return delegateType.cast( gridDialect );
}
else if ( gridDialect instanceof ForwardingGridDialect ) {
return getDelegateOrNull( ( (ForwardingGridDialect<?>) gridDialect ).getGridDialect(), delegateType );
}
else {
return null;
}
} } | public class class_name {
public static <T extends GridDialect> T getDelegateOrNull(GridDialect gridDialect, Class<T> delegateType) {
if ( gridDialect.getClass() == delegateType ) {
return delegateType.cast( gridDialect ); // depends on control dependency: [if], data = [none]
}
else if ( gridDialect instanceof ForwardingGridDialect ) {
return getDelegateOrNull( ( (ForwardingGridDialect<?>) gridDialect ).getGridDialect(), delegateType ); // depends on control dependency: [if], data = [none]
}
else {
return null; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public String[][] convertToStringArray() {
int numberOfProps = numberOfProperties;
String[][] props = new String[numberOfProps][2];
while(numberOfProps--!=0) {
RelatedItemAdditionalProperty prop = additionalProperties[numberOfProps];
props[numberOfProps][0] = new String(prop.name,0,prop.nameLength);
props[numberOfProps][1] = new String(prop.value,0,prop.valueLength);
}
return props;
} } | public class class_name {
public String[][] convertToStringArray() {
int numberOfProps = numberOfProperties;
String[][] props = new String[numberOfProps][2];
while(numberOfProps--!=0) {
RelatedItemAdditionalProperty prop = additionalProperties[numberOfProps];
props[numberOfProps][0] = new String(prop.name,0,prop.nameLength); // depends on control dependency: [while], data = [none]
props[numberOfProps][1] = new String(prop.value,0,prop.valueLength); // depends on control dependency: [while], data = [none]
}
return props;
} } |
public class class_name {
public static String urlToUserInfo(String url) {
String lcUrl = url.toLowerCase();
if(lcUrl.startsWith(DNS_SCHEME)) {
return null;
}
for(String scheme : ALL_SCHEMES) {
if(lcUrl.startsWith(scheme)) {
int authorityIdx = scheme.length();
Matcher m =
USERINFO_REGEX_SIMPLE.matcher(lcUrl.substring(authorityIdx));
if(m.find()) {
return m.group(1);
}
}
}
return null;
} } | public class class_name {
public static String urlToUserInfo(String url) {
String lcUrl = url.toLowerCase();
if(lcUrl.startsWith(DNS_SCHEME)) {
return null; // depends on control dependency: [if], data = [none]
}
for(String scheme : ALL_SCHEMES) {
if(lcUrl.startsWith(scheme)) {
int authorityIdx = scheme.length();
Matcher m =
USERINFO_REGEX_SIMPLE.matcher(lcUrl.substring(authorityIdx));
if(m.find()) {
return m.group(1); // depends on control dependency: [if], data = [none]
}
}
}
return null;
} } |
public class class_name {
public byte[] toByteArray() {
// computes the real size of the bytecode of this class
int size = 24 + 2 * interfaceCount;
int nbFields = 0;
FieldWriter fb = firstField;
while (fb != null) {
++nbFields;
size += fb.getSize();
fb = fb.next;
}
int nbMethods = 0;
MethodWriter mb = firstMethod;
while (mb != null) {
++nbMethods;
size += mb.getSize();
mb = mb.next;
}
int attributeCount = 0;
if (ClassReader.SIGNATURES && signature != 0) {
++attributeCount;
size += 8;
newUTF8("Signature");
}
if (sourceFile != 0) {
++attributeCount;
size += 8;
newUTF8("SourceFile");
}
if (sourceDebug != null) {
++attributeCount;
size += sourceDebug.length + 4;
newUTF8("SourceDebugExtension");
}
if (enclosingMethodOwner != 0) {
++attributeCount;
size += 10;
newUTF8("EnclosingMethod");
}
if ((access & Opcodes.ACC_DEPRECATED) != 0) {
++attributeCount;
size += 6;
newUTF8("Deprecated");
}
if ((access & Opcodes.ACC_SYNTHETIC) != 0
&& (version & 0xffff) < Opcodes.V1_5)
{
++attributeCount;
size += 6;
newUTF8("Synthetic");
}
if (innerClasses != null) {
++attributeCount;
size += 8 + innerClasses.length;
newUTF8("InnerClasses");
}
if (ClassReader.ANNOTATIONS && anns != null) {
++attributeCount;
size += 8 + anns.getSize();
newUTF8("RuntimeVisibleAnnotations");
}
if (ClassReader.ANNOTATIONS && ianns != null) {
++attributeCount;
size += 8 + ianns.getSize();
newUTF8("RuntimeInvisibleAnnotations");
}
if (attrs != null) {
attributeCount += attrs.getCount();
size += attrs.getSize(this, null, 0, -1, -1);
}
size += pool.length;
// allocates a byte vector of this size, in order to avoid unnecessary
// arraycopy operations in the ByteVector.enlarge() method
ByteVector out = new ByteVector(size);
out.putInt(0xCAFEBABE).putInt(version);
out.putShort(index).putByteArray(pool.data, 0, pool.length);
out.putShort(access).putShort(name).putShort(superName);
out.putShort(interfaceCount);
for (int i = 0; i < interfaceCount; ++i) {
out.putShort(interfaces[i]);
}
out.putShort(nbFields);
fb = firstField;
while (fb != null) {
fb.put(out);
fb = fb.next;
}
out.putShort(nbMethods);
mb = firstMethod;
while (mb != null) {
mb.put(out);
mb = mb.next;
}
out.putShort(attributeCount);
if (ClassReader.SIGNATURES && signature != 0) {
out.putShort(newUTF8("Signature")).putInt(2).putShort(signature);
}
if (sourceFile != 0) {
out.putShort(newUTF8("SourceFile")).putInt(2).putShort(sourceFile);
}
if (sourceDebug != null) {
int len = sourceDebug.length - 2;
out.putShort(newUTF8("SourceDebugExtension")).putInt(len);
out.putByteArray(sourceDebug.data, 2, len);
}
if (enclosingMethodOwner != 0) {
out.putShort(newUTF8("EnclosingMethod")).putInt(4);
out.putShort(enclosingMethodOwner).putShort(enclosingMethod);
}
if ((access & Opcodes.ACC_DEPRECATED) != 0) {
out.putShort(newUTF8("Deprecated")).putInt(0);
}
if ((access & Opcodes.ACC_SYNTHETIC) != 0
&& (version & 0xffff) < Opcodes.V1_5)
{
out.putShort(newUTF8("Synthetic")).putInt(0);
}
if (innerClasses != null) {
out.putShort(newUTF8("InnerClasses"));
out.putInt(innerClasses.length + 2).putShort(innerClassesCount);
out.putByteArray(innerClasses.data, 0, innerClasses.length);
}
if (ClassReader.ANNOTATIONS && anns != null) {
out.putShort(newUTF8("RuntimeVisibleAnnotations"));
anns.put(out);
}
if (ClassReader.ANNOTATIONS && ianns != null) {
out.putShort(newUTF8("RuntimeInvisibleAnnotations"));
ianns.put(out);
}
if (attrs != null) {
attrs.put(this, null, 0, -1, -1, out);
}
if (invalidFrames) {
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
new ClassReader(out.data).accept(cw, ClassReader.SKIP_FRAMES);
return cw.toByteArray();
}
return out.data;
} } | public class class_name {
public byte[] toByteArray() {
// computes the real size of the bytecode of this class
int size = 24 + 2 * interfaceCount;
int nbFields = 0;
FieldWriter fb = firstField;
while (fb != null) {
++nbFields; // depends on control dependency: [while], data = [none]
size += fb.getSize(); // depends on control dependency: [while], data = [none]
fb = fb.next; // depends on control dependency: [while], data = [none]
}
int nbMethods = 0;
MethodWriter mb = firstMethod;
while (mb != null) {
++nbMethods; // depends on control dependency: [while], data = [none]
size += mb.getSize(); // depends on control dependency: [while], data = [none]
mb = mb.next; // depends on control dependency: [while], data = [none]
}
int attributeCount = 0;
if (ClassReader.SIGNATURES && signature != 0) {
++attributeCount; // depends on control dependency: [if], data = [none]
size += 8; // depends on control dependency: [if], data = [none]
newUTF8("Signature"); // depends on control dependency: [if], data = [none]
}
if (sourceFile != 0) {
++attributeCount; // depends on control dependency: [if], data = [none]
size += 8; // depends on control dependency: [if], data = [none]
newUTF8("SourceFile"); // depends on control dependency: [if], data = [none]
}
if (sourceDebug != null) {
++attributeCount; // depends on control dependency: [if], data = [none]
size += sourceDebug.length + 4; // depends on control dependency: [if], data = [none]
newUTF8("SourceDebugExtension"); // depends on control dependency: [if], data = [none]
}
if (enclosingMethodOwner != 0) {
++attributeCount; // depends on control dependency: [if], data = [none]
size += 10; // depends on control dependency: [if], data = [none]
newUTF8("EnclosingMethod"); // depends on control dependency: [if], data = [none]
}
if ((access & Opcodes.ACC_DEPRECATED) != 0) {
++attributeCount; // depends on control dependency: [if], data = [none]
size += 6; // depends on control dependency: [if], data = [none]
newUTF8("Deprecated"); // depends on control dependency: [if], data = [none]
}
if ((access & Opcodes.ACC_SYNTHETIC) != 0
&& (version & 0xffff) < Opcodes.V1_5)
{
++attributeCount; // depends on control dependency: [if], data = [none]
size += 6; // depends on control dependency: [if], data = [none]
newUTF8("Synthetic"); // depends on control dependency: [if], data = [none]
}
if (innerClasses != null) {
++attributeCount; // depends on control dependency: [if], data = [none]
size += 8 + innerClasses.length; // depends on control dependency: [if], data = [none]
newUTF8("InnerClasses"); // depends on control dependency: [if], data = [none]
}
if (ClassReader.ANNOTATIONS && anns != null) {
++attributeCount; // depends on control dependency: [if], data = [none]
size += 8 + anns.getSize(); // depends on control dependency: [if], data = [none]
newUTF8("RuntimeVisibleAnnotations"); // depends on control dependency: [if], data = [none]
}
if (ClassReader.ANNOTATIONS && ianns != null) {
++attributeCount; // depends on control dependency: [if], data = [none]
size += 8 + ianns.getSize(); // depends on control dependency: [if], data = [none]
newUTF8("RuntimeInvisibleAnnotations"); // depends on control dependency: [if], data = [none]
}
if (attrs != null) {
attributeCount += attrs.getCount(); // depends on control dependency: [if], data = [none]
size += attrs.getSize(this, null, 0, -1, -1); // depends on control dependency: [if], data = [none]
}
size += pool.length;
// allocates a byte vector of this size, in order to avoid unnecessary
// arraycopy operations in the ByteVector.enlarge() method
ByteVector out = new ByteVector(size);
out.putInt(0xCAFEBABE).putInt(version);
out.putShort(index).putByteArray(pool.data, 0, pool.length);
out.putShort(access).putShort(name).putShort(superName);
out.putShort(interfaceCount);
for (int i = 0; i < interfaceCount; ++i) {
out.putShort(interfaces[i]); // depends on control dependency: [for], data = [i]
}
out.putShort(nbFields);
fb = firstField;
while (fb != null) {
fb.put(out); // depends on control dependency: [while], data = [none]
fb = fb.next; // depends on control dependency: [while], data = [none]
}
out.putShort(nbMethods);
mb = firstMethod;
while (mb != null) {
mb.put(out); // depends on control dependency: [while], data = [none]
mb = mb.next; // depends on control dependency: [while], data = [none]
}
out.putShort(attributeCount);
if (ClassReader.SIGNATURES && signature != 0) {
out.putShort(newUTF8("Signature")).putInt(2).putShort(signature); // depends on control dependency: [if], data = [none]
}
if (sourceFile != 0) {
out.putShort(newUTF8("SourceFile")).putInt(2).putShort(sourceFile); // depends on control dependency: [if], data = [(sourceFile]
}
if (sourceDebug != null) {
int len = sourceDebug.length - 2;
out.putShort(newUTF8("SourceDebugExtension")).putInt(len); // depends on control dependency: [if], data = [none]
out.putByteArray(sourceDebug.data, 2, len); // depends on control dependency: [if], data = [(sourceDebug]
}
if (enclosingMethodOwner != 0) {
out.putShort(newUTF8("EnclosingMethod")).putInt(4); // depends on control dependency: [if], data = [none]
out.putShort(enclosingMethodOwner).putShort(enclosingMethod); // depends on control dependency: [if], data = [(enclosingMethodOwner]
}
if ((access & Opcodes.ACC_DEPRECATED) != 0) {
out.putShort(newUTF8("Deprecated")).putInt(0); // depends on control dependency: [if], data = [0)]
}
if ((access & Opcodes.ACC_SYNTHETIC) != 0
&& (version & 0xffff) < Opcodes.V1_5)
{
out.putShort(newUTF8("Synthetic")).putInt(0); // depends on control dependency: [if], data = [0]
}
if (innerClasses != null) {
out.putShort(newUTF8("InnerClasses")); // depends on control dependency: [if], data = [none]
out.putInt(innerClasses.length + 2).putShort(innerClassesCount); // depends on control dependency: [if], data = [(innerClasses]
out.putByteArray(innerClasses.data, 0, innerClasses.length); // depends on control dependency: [if], data = [(innerClasses]
}
if (ClassReader.ANNOTATIONS && anns != null) {
out.putShort(newUTF8("RuntimeVisibleAnnotations")); // depends on control dependency: [if], data = [none]
anns.put(out); // depends on control dependency: [if], data = [none]
}
if (ClassReader.ANNOTATIONS && ianns != null) {
out.putShort(newUTF8("RuntimeInvisibleAnnotations")); // depends on control dependency: [if], data = [none]
ianns.put(out); // depends on control dependency: [if], data = [none]
}
if (attrs != null) {
attrs.put(this, null, 0, -1, -1, out); // depends on control dependency: [if], data = [none]
}
if (invalidFrames) {
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
new ClassReader(out.data).accept(cw, ClassReader.SKIP_FRAMES); // depends on control dependency: [if], data = [none]
return cw.toByteArray(); // depends on control dependency: [if], data = [none]
}
return out.data;
} } |
public class class_name {
@Override
public boolean simpleEvaluation(Agent currentAgent) {
Agent agent = currentAgent;
if (bodyId != null) {
agent = agent.getAgentsAppState().getAgent(bodyId);
if(agent == null) {
logger.log(Level.SEVERE, "Body {0} does not exists!", new Object[]{bodyId});
return false;
}
}
if(agent instanceof HumanAgent) {
return ((HumanAgent)agent).getBodyPosture().name().equals(bodyState);
}
return false;
} } | public class class_name {
@Override
public boolean simpleEvaluation(Agent currentAgent) {
Agent agent = currentAgent;
if (bodyId != null) {
agent = agent.getAgentsAppState().getAgent(bodyId); // depends on control dependency: [if], data = [(bodyId]
if(agent == null) {
logger.log(Level.SEVERE, "Body {0} does not exists!", new Object[]{bodyId}); // depends on control dependency: [if], data = [none]
return false; // depends on control dependency: [if], data = [none]
}
}
if(agent instanceof HumanAgent) {
return ((HumanAgent)agent).getBodyPosture().name().equals(bodyState); // depends on control dependency: [if], data = [none]
}
return false;
} } |
public class class_name {
@SuppressWarnings("unchecked")
public UserAuthentication getOrCreateUser(App app, String accessToken) throws IOException {
UserAuthentication userAuth = null;
User user = new User();
if (accessToken != null) {
String ctype = null;
HttpEntity respEntity = null;
CloseableHttpResponse resp2 = null;
try {
HttpGet profileGet = new HttpGet(PROFILE_URL + accessToken);
resp2 = httpclient.execute(profileGet);
respEntity = resp2.getEntity();
ctype = resp2.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();
} catch (Exception e) {
logger.warn("Facebook auth request failed: GET " + PROFILE_URL + accessToken, e);
}
if (respEntity != null && Utils.isJsonType(ctype)) {
Map<String, Object> profile = jreader.readValue(respEntity.getContent());
if (profile != null && profile.containsKey("id")) {
String fbId = (String) profile.get("id");
String email = (String) profile.get("email");
String name = (String) profile.get("name");
user.setAppid(getAppid(app));
user.setIdentifier(Config.FB_PREFIX.concat(fbId));
user.setEmail(email);
user = User.readUserForIdentifier(user);
if (user == null) {
//user is new
user = new User();
user.setActive(true);
user.setAppid(getAppid(app));
user.setEmail(StringUtils.isBlank(email) ? fbId + "@facebook.com" : email);
user.setName(StringUtils.isBlank(name) ? "No Name" : name);
user.setPassword(Utils.generateSecurityToken());
user.setPicture(getPicture(fbId));
user.setIdentifier(Config.FB_PREFIX.concat(fbId));
String id = user.create();
if (id == null) {
throw new AuthenticationServiceException("Authentication failed: cannot create new user.");
}
} else {
String picture = getPicture(fbId);
boolean update = false;
if (!StringUtils.equals(user.getPicture(), picture)) {
user.setPicture(picture);
update = true;
}
if (!StringUtils.isBlank(email) && !StringUtils.equals(user.getEmail(), email)) {
user.setEmail(email);
update = true;
}
if (update) {
user.update();
}
}
userAuth = new UserAuthentication(new AuthenticatedUserDetails(user));
}
EntityUtils.consumeQuietly(respEntity);
}
}
return SecurityUtils.checkIfActive(userAuth, user, false);
} } | public class class_name {
@SuppressWarnings("unchecked")
public UserAuthentication getOrCreateUser(App app, String accessToken) throws IOException {
UserAuthentication userAuth = null;
User user = new User();
if (accessToken != null) {
String ctype = null;
HttpEntity respEntity = null;
CloseableHttpResponse resp2 = null;
try {
HttpGet profileGet = new HttpGet(PROFILE_URL + accessToken);
resp2 = httpclient.execute(profileGet);
respEntity = resp2.getEntity();
ctype = resp2.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();
} catch (Exception e) {
logger.warn("Facebook auth request failed: GET " + PROFILE_URL + accessToken, e);
}
if (respEntity != null && Utils.isJsonType(ctype)) {
Map<String, Object> profile = jreader.readValue(respEntity.getContent());
if (profile != null && profile.containsKey("id")) {
String fbId = (String) profile.get("id");
String email = (String) profile.get("email");
String name = (String) profile.get("name");
user.setAppid(getAppid(app)); // depends on control dependency: [if], data = [none]
user.setIdentifier(Config.FB_PREFIX.concat(fbId)); // depends on control dependency: [if], data = [none]
user.setEmail(email); // depends on control dependency: [if], data = [none]
user = User.readUserForIdentifier(user); // depends on control dependency: [if], data = [none]
if (user == null) {
//user is new
user = new User(); // depends on control dependency: [if], data = [none]
user.setActive(true); // depends on control dependency: [if], data = [none]
user.setAppid(getAppid(app)); // depends on control dependency: [if], data = [none]
user.setEmail(StringUtils.isBlank(email) ? fbId + "@facebook.com" : email); // depends on control dependency: [if], data = [none]
user.setName(StringUtils.isBlank(name) ? "No Name" : name); // depends on control dependency: [if], data = [none]
user.setPassword(Utils.generateSecurityToken()); // depends on control dependency: [if], data = [none]
user.setPicture(getPicture(fbId)); // depends on control dependency: [if], data = [none]
user.setIdentifier(Config.FB_PREFIX.concat(fbId)); // depends on control dependency: [if], data = [none]
String id = user.create();
if (id == null) {
throw new AuthenticationServiceException("Authentication failed: cannot create new user.");
}
} else {
String picture = getPicture(fbId);
boolean update = false;
if (!StringUtils.equals(user.getPicture(), picture)) {
user.setPicture(picture); // depends on control dependency: [if], data = [none]
update = true; // depends on control dependency: [if], data = [none]
}
if (!StringUtils.isBlank(email) && !StringUtils.equals(user.getEmail(), email)) {
user.setEmail(email); // depends on control dependency: [if], data = [none]
update = true; // depends on control dependency: [if], data = [none]
}
if (update) {
user.update(); // depends on control dependency: [if], data = [none]
}
}
userAuth = new UserAuthentication(new AuthenticatedUserDetails(user)); // depends on control dependency: [if], data = [none]
}
EntityUtils.consumeQuietly(respEntity);
}
}
return SecurityUtils.checkIfActive(userAuth, user, false);
} } |
public class class_name {
@Override protected void resize() {
width = clock.getWidth() - clock.getInsets().getLeft() - clock.getInsets().getRight();
height = clock.getHeight() - clock.getInsets().getTop() - clock.getInsets().getBottom();
if (aspectRatio * width > height) {
width = 1 / (aspectRatio / height);
} else if (1 / (aspectRatio / height) > width) {
height = aspectRatio * width;
}
if (width > 0 && height > 0) {
pane.setMaxSize(width, height);
pane.relocate((clock.getWidth() - height) * 0.5, (clock.getHeight() - height) * 0.5);
canvas.setWidth(width);
canvas.setHeight(height);
dotSize = height * 0.045455;
spacer = height * 0.022727;
digitWidth = 8 * dotSize + 7 * spacer;
digitHeight = 15 * dotSize + 14 * spacer;
digitSpacer = height * 0.09090909;
}
} } | public class class_name {
@Override protected void resize() {
width = clock.getWidth() - clock.getInsets().getLeft() - clock.getInsets().getRight();
height = clock.getHeight() - clock.getInsets().getTop() - clock.getInsets().getBottom();
if (aspectRatio * width > height) {
width = 1 / (aspectRatio / height); // depends on control dependency: [if], data = [height)]
} else if (1 / (aspectRatio / height) > width) {
height = aspectRatio * width; // depends on control dependency: [if], data = [none]
}
if (width > 0 && height > 0) {
pane.setMaxSize(width, height); // depends on control dependency: [if], data = [(width]
pane.relocate((clock.getWidth() - height) * 0.5, (clock.getHeight() - height) * 0.5); // depends on control dependency: [if], data = [none]
canvas.setWidth(width); // depends on control dependency: [if], data = [(width]
canvas.setHeight(height); // depends on control dependency: [if], data = [none]
dotSize = height * 0.045455; // depends on control dependency: [if], data = [none]
spacer = height * 0.022727; // depends on control dependency: [if], data = [none]
digitWidth = 8 * dotSize + 7 * spacer; // depends on control dependency: [if], data = [none]
digitHeight = 15 * dotSize + 14 * spacer; // depends on control dependency: [if], data = [none]
digitSpacer = height * 0.09090909; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public boolean addAll(int index, FloatArray items) {
if (index < 0 || index > size) {
throw new IndexOutOfBoundsException();
}
ensureCapacity(size + items.size);
if (index < size) {
for (int i = size - 1; i >= index; i--) {
elements[i + items.size] = elements[i];
}
}
for (int i = 0; i < items.size; i++) {
elements[index++] = items.elements[i];
}
size += items.size;
return items.size > 0;
} } | public class class_name {
public boolean addAll(int index, FloatArray items) {
if (index < 0 || index > size) {
throw new IndexOutOfBoundsException();
}
ensureCapacity(size + items.size);
if (index < size) {
for (int i = size - 1; i >= index; i--) {
elements[i + items.size] = elements[i]; // depends on control dependency: [for], data = [i]
}
}
for (int i = 0; i < items.size; i++) {
elements[index++] = items.elements[i]; // depends on control dependency: [for], data = [i]
}
size += items.size;
return items.size > 0;
} } |
public class class_name {
public void onDetach() {
this.getOverlayManager().onDetach(this);
mTileProvider.detach();
mOldZoomController.setVisible(false);
if (mZoomController != null) {
mZoomController.onDetach();
}
//https://github.com/osmdroid/osmdroid/issues/390
if (mTileRequestCompleteHandler instanceof SimpleInvalidationHandler) {
((SimpleInvalidationHandler) mTileRequestCompleteHandler).destroy();
}
mTileRequestCompleteHandler=null;
if (mProjection!=null)
mProjection.detach();
mProjection=null;
mRepository.onDetach();
mListners.clear();
} } | public class class_name {
public void onDetach() {
this.getOverlayManager().onDetach(this);
mTileProvider.detach();
mOldZoomController.setVisible(false);
if (mZoomController != null) {
mZoomController.onDetach(); // depends on control dependency: [if], data = [none]
}
//https://github.com/osmdroid/osmdroid/issues/390
if (mTileRequestCompleteHandler instanceof SimpleInvalidationHandler) {
((SimpleInvalidationHandler) mTileRequestCompleteHandler).destroy(); // depends on control dependency: [if], data = [none]
}
mTileRequestCompleteHandler=null;
if (mProjection!=null)
mProjection.detach();
mProjection=null;
mRepository.onDetach();
mListners.clear();
} } |
public class class_name {
private int findNextParaPos(int startPara, String paraStr) {
if (allParas == null || allParas.size() < 1) {
return -1;
}
if (startPara >= allParas.size() || startPara < 0) {
startPara = 0;
}
if (startPara + 1 < allParas.size() && paraStr.equals(allParas.get(startPara + 1))) {
return startPara + 1;
}
if (paraStr.equals(allParas.get(startPara))) {
return startPara;
}
if (startPara - 1 >= 0 && paraStr.equals(allParas.get(startPara - 1))) {
return startPara - 1;
}
return -1;
} } | public class class_name {
private int findNextParaPos(int startPara, String paraStr) {
if (allParas == null || allParas.size() < 1) {
return -1; // depends on control dependency: [if], data = [none]
}
if (startPara >= allParas.size() || startPara < 0) {
startPara = 0; // depends on control dependency: [if], data = [none]
}
if (startPara + 1 < allParas.size() && paraStr.equals(allParas.get(startPara + 1))) {
return startPara + 1; // depends on control dependency: [if], data = [none]
}
if (paraStr.equals(allParas.get(startPara))) {
return startPara; // depends on control dependency: [if], data = [none]
}
if (startPara - 1 >= 0 && paraStr.equals(allParas.get(startPara - 1))) {
return startPara - 1; // depends on control dependency: [if], data = [none]
}
return -1;
} } |
public class class_name {
synchronized int reserveNextCorrelationId(VersionedIoFuture future) {
Integer next = getNextCorrelationId();
// Not likely but possible to use all IDs and start back at beginning while
// old request still in progress.
while (requests.containsKey(next)) {
next = getNextCorrelationId();
}
requests.put(next, future);
return next;
} } | public class class_name {
synchronized int reserveNextCorrelationId(VersionedIoFuture future) {
Integer next = getNextCorrelationId();
// Not likely but possible to use all IDs and start back at beginning while
// old request still in progress.
while (requests.containsKey(next)) {
next = getNextCorrelationId(); // depends on control dependency: [while], data = [none]
}
requests.put(next, future);
return next;
} } |
public class class_name {
public void marshall(UpdateMethodRequest updateMethodRequest, ProtocolMarshaller protocolMarshaller) {
if (updateMethodRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(updateMethodRequest.getRestApiId(), RESTAPIID_BINDING);
protocolMarshaller.marshall(updateMethodRequest.getResourceId(), RESOURCEID_BINDING);
protocolMarshaller.marshall(updateMethodRequest.getHttpMethod(), HTTPMETHOD_BINDING);
protocolMarshaller.marshall(updateMethodRequest.getPatchOperations(), PATCHOPERATIONS_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(UpdateMethodRequest updateMethodRequest, ProtocolMarshaller protocolMarshaller) {
if (updateMethodRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(updateMethodRequest.getRestApiId(), RESTAPIID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(updateMethodRequest.getResourceId(), RESOURCEID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(updateMethodRequest.getHttpMethod(), HTTPMETHOD_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(updateMethodRequest.getPatchOperations(), PATCHOPERATIONS_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void marshall(TextDetection textDetection, ProtocolMarshaller protocolMarshaller) {
if (textDetection == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(textDetection.getDetectedText(), DETECTEDTEXT_BINDING);
protocolMarshaller.marshall(textDetection.getType(), TYPE_BINDING);
protocolMarshaller.marshall(textDetection.getId(), ID_BINDING);
protocolMarshaller.marshall(textDetection.getParentId(), PARENTID_BINDING);
protocolMarshaller.marshall(textDetection.getConfidence(), CONFIDENCE_BINDING);
protocolMarshaller.marshall(textDetection.getGeometry(), GEOMETRY_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(TextDetection textDetection, ProtocolMarshaller protocolMarshaller) {
if (textDetection == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(textDetection.getDetectedText(), DETECTEDTEXT_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(textDetection.getType(), TYPE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(textDetection.getId(), ID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(textDetection.getParentId(), PARENTID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(textDetection.getConfidence(), CONFIDENCE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(textDetection.getGeometry(), GEOMETRY_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 boolean startConnection()
{
State state = _state.get();
if (state.isActive()) {
// when active, always start a connection
_connectionCount.incrementAndGet();
return true;
}
long now = CurrentTime.currentTime();
long lastFailTime = _lastFailTime;
long recoverTimeout = _dynamicRecoverTimeout.get();
if (now < lastFailTime + recoverTimeout) {
// if the fail recover hasn't timed out, return false
return false;
}
// when fail, only start a single connection
int count;
do {
count = _connectionCount.get();
if (count > 0) {
return false;
}
} while (! _connectionCount.compareAndSet(count, count + 1));
return true;
} } | public class class_name {
public boolean startConnection()
{
State state = _state.get();
if (state.isActive()) {
// when active, always start a connection
_connectionCount.incrementAndGet(); // depends on control dependency: [if], data = [none]
return true; // depends on control dependency: [if], data = [none]
}
long now = CurrentTime.currentTime();
long lastFailTime = _lastFailTime;
long recoverTimeout = _dynamicRecoverTimeout.get();
if (now < lastFailTime + recoverTimeout) {
// if the fail recover hasn't timed out, return false
return false; // depends on control dependency: [if], data = [none]
}
// when fail, only start a single connection
int count;
do {
count = _connectionCount.get();
if (count > 0) {
return false; // depends on control dependency: [if], data = [none]
}
} while (! _connectionCount.compareAndSet(count, count + 1));
return true;
} } |
public class class_name {
public static void getAllSplits(final Set<String> splits, final File path, final String trainingSuffix, final String testSuffix) {
if (path == null) {
return;
}
File[] files = path.listFiles();
if (files == null) {
return;
}
for (File file : files) {
if (file.isDirectory()) {
getAllSplits(splits, file, trainingSuffix, testSuffix);
} else if (file.getName().endsWith(trainingSuffix)) {
splits.add(file.getAbsolutePath().replaceAll(trainingSuffix + "$", ""));
} else if (file.getName().endsWith(testSuffix)) {
splits.add(file.getAbsolutePath().replaceAll(testSuffix + "$", ""));
}
}
} } | public class class_name {
public static void getAllSplits(final Set<String> splits, final File path, final String trainingSuffix, final String testSuffix) {
if (path == null) {
return; // depends on control dependency: [if], data = [none]
}
File[] files = path.listFiles();
if (files == null) {
return; // depends on control dependency: [if], data = [none]
}
for (File file : files) {
if (file.isDirectory()) {
getAllSplits(splits, file, trainingSuffix, testSuffix); // depends on control dependency: [if], data = [none]
} else if (file.getName().endsWith(trainingSuffix)) {
splits.add(file.getAbsolutePath().replaceAll(trainingSuffix + "$", "")); // depends on control dependency: [if], data = [none]
} else if (file.getName().endsWith(testSuffix)) {
splits.add(file.getAbsolutePath().replaceAll(testSuffix + "$", "")); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public void marshall(AudioCodecSettings audioCodecSettings, ProtocolMarshaller protocolMarshaller) {
if (audioCodecSettings == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(audioCodecSettings.getAacSettings(), AACSETTINGS_BINDING);
protocolMarshaller.marshall(audioCodecSettings.getAc3Settings(), AC3SETTINGS_BINDING);
protocolMarshaller.marshall(audioCodecSettings.getAiffSettings(), AIFFSETTINGS_BINDING);
protocolMarshaller.marshall(audioCodecSettings.getCodec(), CODEC_BINDING);
protocolMarshaller.marshall(audioCodecSettings.getEac3Settings(), EAC3SETTINGS_BINDING);
protocolMarshaller.marshall(audioCodecSettings.getMp2Settings(), MP2SETTINGS_BINDING);
protocolMarshaller.marshall(audioCodecSettings.getWavSettings(), WAVSETTINGS_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(AudioCodecSettings audioCodecSettings, ProtocolMarshaller protocolMarshaller) {
if (audioCodecSettings == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(audioCodecSettings.getAacSettings(), AACSETTINGS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(audioCodecSettings.getAc3Settings(), AC3SETTINGS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(audioCodecSettings.getAiffSettings(), AIFFSETTINGS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(audioCodecSettings.getCodec(), CODEC_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(audioCodecSettings.getEac3Settings(), EAC3SETTINGS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(audioCodecSettings.getMp2Settings(), MP2SETTINGS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(audioCodecSettings.getWavSettings(), WAVSETTINGS_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 {
@Override
public int executeBatch()
{
Map<Key, List<TableOperation>> operations = new HashMap<Key, List<TableOperation>>();
for (Node node : nodes)
{
if (node.isDirty())
{
node.handlePreEvent();
// delete can not be executed in batch
if (node.isInState(RemovedState.class))
{
delete(node.getData(), node.getEntityId());
}
else
{
EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
node.getDataClass());
List<RelationHolder> relationHolders = getRelationHolders(node);
// KunderaCoreUtils.showQuery("Execute batch for" +
// metadata.getSchema() + "." + metadata.getTableName(),
// showQuery);
Row row = createRow(metadata, node.getData(), node.getEntityId(), relationHolders);
Table schemaTable = tableAPI.getTable(metadata.getTableName());
addOps(operations, schemaTable, row);
}
node.handlePostEvent();
}
}
execute(operations);
return nodes.size();
} } | public class class_name {
@Override
public int executeBatch()
{
Map<Key, List<TableOperation>> operations = new HashMap<Key, List<TableOperation>>();
for (Node node : nodes)
{
if (node.isDirty())
{
node.handlePreEvent(); // depends on control dependency: [if], data = [none]
// delete can not be executed in batch
if (node.isInState(RemovedState.class))
{
delete(node.getData(), node.getEntityId()); // depends on control dependency: [if], data = [none]
}
else
{
EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
node.getDataClass());
List<RelationHolder> relationHolders = getRelationHolders(node);
// KunderaCoreUtils.showQuery("Execute batch for" +
// metadata.getSchema() + "." + metadata.getTableName(),
// showQuery);
Row row = createRow(metadata, node.getData(), node.getEntityId(), relationHolders);
Table schemaTable = tableAPI.getTable(metadata.getTableName());
addOps(operations, schemaTable, row); // depends on control dependency: [if], data = [none]
}
node.handlePostEvent(); // depends on control dependency: [if], data = [none]
}
}
execute(operations);
return nodes.size();
} } |
public class class_name {
public static Point3D_F64 mean( List<Point3D_F64> points , Point3D_F64 mean ) {
if( mean == null )
mean = new Point3D_F64();
double x = 0, y = 0, z = 0;
for( Point3D_F64 p : points ) {
x += p.x;
y += p.y;
z += p.z;
}
mean.x = x / points.size();
mean.y = y / points.size();
mean.z = z / points.size();
return mean;
} } | public class class_name {
public static Point3D_F64 mean( List<Point3D_F64> points , Point3D_F64 mean ) {
if( mean == null )
mean = new Point3D_F64();
double x = 0, y = 0, z = 0;
for( Point3D_F64 p : points ) {
x += p.x; // depends on control dependency: [for], data = [p]
y += p.y; // depends on control dependency: [for], data = [p]
z += p.z; // depends on control dependency: [for], data = [p]
}
mean.x = x / points.size();
mean.y = y / points.size();
mean.z = z / points.size();
return mean;
} } |
public class class_name {
static ObjectName createObjectName(final String domain, final PathAddress pathAddress, ObjectNameCreationContext context) {
if (pathAddress.size() == 0) {
return ModelControllerMBeanHelper.createRootObjectName(domain);
}
final StringBuilder sb = new StringBuilder(domain);
sb.append(":");
boolean first = true;
for (PathElement element : pathAddress) {
if (first) {
first = false;
} else {
sb.append(",");
}
escapeKey(ESCAPED_KEY_CHARACTERS, sb, element.getKey(), context);
sb.append("=");
escapeValue(sb, element.getValue(), context);
}
try {
return ObjectName.getInstance(sb.toString());
} catch (MalformedObjectNameException e) {
throw JmxLogger.ROOT_LOGGER.cannotCreateObjectName(e, pathAddress, sb.toString());
}
} } | public class class_name {
static ObjectName createObjectName(final String domain, final PathAddress pathAddress, ObjectNameCreationContext context) {
if (pathAddress.size() == 0) {
return ModelControllerMBeanHelper.createRootObjectName(domain); // depends on control dependency: [if], data = [none]
}
final StringBuilder sb = new StringBuilder(domain);
sb.append(":");
boolean first = true;
for (PathElement element : pathAddress) {
if (first) {
first = false; // depends on control dependency: [if], data = [none]
} else {
sb.append(","); // depends on control dependency: [if], data = [none]
}
escapeKey(ESCAPED_KEY_CHARACTERS, sb, element.getKey(), context); // depends on control dependency: [for], data = [element]
sb.append("="); // depends on control dependency: [for], data = [none]
escapeValue(sb, element.getValue(), context); // depends on control dependency: [for], data = [element]
}
try {
return ObjectName.getInstance(sb.toString()); // depends on control dependency: [try], data = [none]
} catch (MalformedObjectNameException e) {
throw JmxLogger.ROOT_LOGGER.cannotCreateObjectName(e, pathAddress, sb.toString());
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private GeoPoint getLocation() {
//sample data
//{"timestamp": 1483742439, "iss_position": {"latitude": "-50.8416", "longitude": "-41.2701"}, "message": "success"}
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
GeoPoint pt = null;
if (isConnected) {
try {
JSONObject jsonObject = json.makeHttpRequest(url_select);
JSONObject iss_position = (JSONObject) jsonObject.get("iss_position");
double lat = iss_position.getDouble("latitude");
double lon = iss_position.getDouble("longitude");
//valid the data
if (lat <= 90d && lat >= -90d && lon >= -180d && lon <= 180d) {
pt = new GeoPoint(lat, lon);
} else
Log.e(TAG, "invalid lat,lon received");
} catch (Throwable e) {
Log.e(TAG, "error fetching json", e);
}
}
return pt;
} } | public class class_name {
private GeoPoint getLocation() {
//sample data
//{"timestamp": 1483742439, "iss_position": {"latitude": "-50.8416", "longitude": "-41.2701"}, "message": "success"}
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
GeoPoint pt = null;
if (isConnected) {
try {
JSONObject jsonObject = json.makeHttpRequest(url_select);
JSONObject iss_position = (JSONObject) jsonObject.get("iss_position");
double lat = iss_position.getDouble("latitude");
double lon = iss_position.getDouble("longitude");
//valid the data
if (lat <= 90d && lat >= -90d && lon >= -180d && lon <= 180d) {
pt = new GeoPoint(lat, lon); // depends on control dependency: [if], data = [none]
} else
Log.e(TAG, "invalid lat,lon received");
} catch (Throwable e) {
Log.e(TAG, "error fetching json", e);
} // depends on control dependency: [catch], data = [none]
}
return pt;
} } |
public class class_name {
public java.util.List<ComplianceItem> getComplianceItems() {
if (complianceItems == null) {
complianceItems = new com.amazonaws.internal.SdkInternalList<ComplianceItem>();
}
return complianceItems;
} } | public class class_name {
public java.util.List<ComplianceItem> getComplianceItems() {
if (complianceItems == null) {
complianceItems = new com.amazonaws.internal.SdkInternalList<ComplianceItem>(); // depends on control dependency: [if], data = [none]
}
return complianceItems;
} } |
public class class_name {
public String getScriptUsage() {
StringBuffer scriptUsage = new StringBuffer(NL);
scriptUsage.append(getHelpPart("usage", COMMAND));
scriptUsage.append(" {");
ExeAction[] tasks = ExeAction.values();
for (int i = 0; i < tasks.length; i++) {
ExeAction task = tasks[i];
scriptUsage.append(task.toString());
if (i != (tasks.length - 1)) {
scriptUsage.append("|");
}
}
scriptUsage.append("} [");
scriptUsage.append(getHelpPart("global.options.lower"));
scriptUsage.append("]");
scriptUsage.append(NL);
return scriptUsage.toString();
} } | public class class_name {
public String getScriptUsage() {
StringBuffer scriptUsage = new StringBuffer(NL);
scriptUsage.append(getHelpPart("usage", COMMAND));
scriptUsage.append(" {");
ExeAction[] tasks = ExeAction.values();
for (int i = 0; i < tasks.length; i++) {
ExeAction task = tasks[i];
scriptUsage.append(task.toString()); // depends on control dependency: [for], data = [none]
if (i != (tasks.length - 1)) {
scriptUsage.append("|"); // depends on control dependency: [if], data = [none]
}
}
scriptUsage.append("} [");
scriptUsage.append(getHelpPart("global.options.lower"));
scriptUsage.append("]");
scriptUsage.append(NL);
return scriptUsage.toString();
} } |
public class class_name {
public void addTimeInterval(T interval){
timeIntervals.add(interval);
minBorders.setStart(Math.max(minBorders.getStart(), interval.getStart()));
minBorders.setEnd(Math.min(minBorders.getEnd(), interval.getEnd()));
if(maxBorders == null){
maxBorders = interval.clone();
} else {
maxBorders.setStart(Math.min(maxBorders.getStart(), interval.getStart()));
maxBorders.setEnd(Math.max(maxBorders.getEnd(), interval.getEnd()));
}
} } | public class class_name {
public void addTimeInterval(T interval){
timeIntervals.add(interval);
minBorders.setStart(Math.max(minBorders.getStart(), interval.getStart()));
minBorders.setEnd(Math.min(minBorders.getEnd(), interval.getEnd()));
if(maxBorders == null){
maxBorders = interval.clone(); // depends on control dependency: [if], data = [none]
} else {
maxBorders.setStart(Math.min(maxBorders.getStart(), interval.getStart())); // depends on control dependency: [if], data = [(maxBorders]
maxBorders.setEnd(Math.max(maxBorders.getEnd(), interval.getEnd())); // depends on control dependency: [if], data = [(maxBorders]
}
} } |
public class class_name {
public static void drawEdgeContours( List<EdgeContour> contours , int color , Bitmap output , byte[] storage ) {
if( output.getConfig() != Bitmap.Config.ARGB_8888 )
throw new IllegalArgumentException("Only ARGB_8888 is supported");
if( storage == null )
storage = declareStorage(output,null);
else
Arrays.fill(storage,(byte)0);
byte r = (byte)((color >> 16) & 0xFF);
byte g = (byte)((color >> 8) & 0xFF);
byte b = (byte)( color );
for( int i = 0; i < contours.size(); i++ ) {
EdgeContour e = contours.get(i);
for( int j = 0; j < e.segments.size(); j++ ) {
EdgeSegment s = e.segments.get(j);
for( int k = 0; k < s.points.size(); k++ ) {
Point2D_I32 p = s.points.get(k);
int index = p.y*4*output.getWidth() + p.x*4;
storage[index++] = b;
storage[index++] = g;
storage[index++] = r;
storage[index] = (byte)0xFF;
}
}
}
output.copyPixelsFromBuffer(ByteBuffer.wrap(storage));
} } | public class class_name {
public static void drawEdgeContours( List<EdgeContour> contours , int color , Bitmap output , byte[] storage ) {
if( output.getConfig() != Bitmap.Config.ARGB_8888 )
throw new IllegalArgumentException("Only ARGB_8888 is supported");
if( storage == null )
storage = declareStorage(output,null);
else
Arrays.fill(storage,(byte)0);
byte r = (byte)((color >> 16) & 0xFF);
byte g = (byte)((color >> 8) & 0xFF);
byte b = (byte)( color );
for( int i = 0; i < contours.size(); i++ ) {
EdgeContour e = contours.get(i);
for( int j = 0; j < e.segments.size(); j++ ) {
EdgeSegment s = e.segments.get(j);
for( int k = 0; k < s.points.size(); k++ ) {
Point2D_I32 p = s.points.get(k);
int index = p.y*4*output.getWidth() + p.x*4;
storage[index++] = b; // depends on control dependency: [for], data = [none]
storage[index++] = g; // depends on control dependency: [for], data = [none]
storage[index++] = r; // depends on control dependency: [for], data = [none]
storage[index] = (byte)0xFF; // depends on control dependency: [for], data = [none]
}
}
}
output.copyPixelsFromBuffer(ByteBuffer.wrap(storage));
} } |
public class class_name {
boolean skipUnlockedNavtitle(final Element metadataContainer, final Element checkForNavtitle) {
if (!TOPIC_TITLEALTS.matches(metadataContainer) ||
!TOPIC_NAVTITLE.matches(checkForNavtitle)) {
return false;
} else if (checkForNavtitle.getAttributeNodeNS(DITA_OT_NS, ATTRIBUTE_NAME_LOCKTITLE) == null) {
return false;
} else if (ATTRIBUTE_NAME_LOCKTITLE_VALUE_YES.matches(checkForNavtitle.getAttributeNodeNS(DITA_OT_NS, ATTRIBUTE_NAME_LOCKTITLE).getValue())) {
return false;
}
return true;
} } | public class class_name {
boolean skipUnlockedNavtitle(final Element metadataContainer, final Element checkForNavtitle) {
if (!TOPIC_TITLEALTS.matches(metadataContainer) ||
!TOPIC_NAVTITLE.matches(checkForNavtitle)) {
return false; // depends on control dependency: [if], data = [none]
} else if (checkForNavtitle.getAttributeNodeNS(DITA_OT_NS, ATTRIBUTE_NAME_LOCKTITLE) == null) {
return false; // depends on control dependency: [if], data = [none]
} else if (ATTRIBUTE_NAME_LOCKTITLE_VALUE_YES.matches(checkForNavtitle.getAttributeNodeNS(DITA_OT_NS, ATTRIBUTE_NAME_LOCKTITLE).getValue())) {
return false; // depends on control dependency: [if], data = [none]
}
return true;
} } |
public class class_name {
@Override
public <T> List<T> convertListOfMapsToObjects(List<Map> list, Class<T> componentType) {
List<Object> newList = new ArrayList<>( list.size() );
for ( Object obj : list ) {
if ( obj instanceof Value) {
obj = ( ( Value ) obj ).toValue();
}
if ( obj instanceof Map ) {
Map map = ( Map ) obj;
if ( map instanceof ValueMapImpl) {
newList.add( fromValueMap( ( Map<String, Value> ) map, componentType ) );
} else {
newList.add( fromMap( map, componentType ) );
}
} else {
newList.add( Conversions.coerce(componentType, obj) );
}
}
return ( List<T> ) newList;
} } | public class class_name {
@Override
public <T> List<T> convertListOfMapsToObjects(List<Map> list, Class<T> componentType) {
List<Object> newList = new ArrayList<>( list.size() );
for ( Object obj : list ) {
if ( obj instanceof Value) {
obj = ( ( Value ) obj ).toValue(); // depends on control dependency: [if], data = [none]
}
if ( obj instanceof Map ) {
Map map = ( Map ) obj;
if ( map instanceof ValueMapImpl) {
newList.add( fromValueMap( ( Map<String, Value> ) map, componentType ) ); // depends on control dependency: [if], data = [none]
} else {
newList.add( fromMap( map, componentType ) ); // depends on control dependency: [if], data = [none]
}
} else {
newList.add( Conversions.coerce(componentType, obj) ); // depends on control dependency: [if], data = [none]
}
}
return ( List<T> ) newList;
} } |
public class class_name {
public SQLRouteResult shard(final String sql, final List<Object> parameters) {
List<Object> clonedParameters = cloneParameters(parameters);
SQLRouteResult result = executeRoute(sql, clonedParameters);
result.getRouteUnits().addAll(HintManager.isDatabaseShardingOnly() ? convert(sql, clonedParameters, result) : rewriteAndConvert(sql, clonedParameters, result));
if (shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW)) {
boolean showSimple = shardingProperties.getValue(ShardingPropertiesConstant.SQL_SIMPLE);
SQLLogger.logSQL(sql, showSimple, result.getSqlStatement(), result.getRouteUnits());
}
return result;
} } | public class class_name {
public SQLRouteResult shard(final String sql, final List<Object> parameters) {
List<Object> clonedParameters = cloneParameters(parameters);
SQLRouteResult result = executeRoute(sql, clonedParameters);
result.getRouteUnits().addAll(HintManager.isDatabaseShardingOnly() ? convert(sql, clonedParameters, result) : rewriteAndConvert(sql, clonedParameters, result));
if (shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW)) {
boolean showSimple = shardingProperties.getValue(ShardingPropertiesConstant.SQL_SIMPLE);
SQLLogger.logSQL(sql, showSimple, result.getSqlStatement(), result.getRouteUnits()); // depends on control dependency: [if], data = [none]
}
return result;
} } |
public class class_name {
@SuppressWarnings("unchecked")
public final void integrityCheck(AbstractRStarTree<N, E, ?> tree) {
// leaf node
if(isLeaf()) {
for(int i = 0; i < getCapacity(); i++) {
E e = getEntry(i);
if(i < getNumEntries() && e == null) {
throw new RuntimeException("i < numEntries && entry == null");
}
if(i >= getNumEntries() && e != null) {
throw new RuntimeException("i >= numEntries && entry != null");
}
}
}
// dir node
else {
N tmp = tree.getNode(getEntry(0));
boolean childIsLeaf = tmp.isLeaf();
for(int i = 0; i < getCapacity(); i++) {
E e = getEntry(i);
if(i < getNumEntries() && e == null) {
throw new RuntimeException("i < numEntries && entry == null");
}
if(i >= getNumEntries() && e != null) {
throw new RuntimeException("i >= numEntries && entry != null");
}
if(e != null) {
N node = tree.getNode(e);
if(childIsLeaf && !node.isLeaf()) {
for(int k = 0; k < getNumEntries(); k++) {
tree.getNode(getEntry(k));
}
throw new RuntimeException("Wrong Child in " + this + " at " + i);
}
if(!childIsLeaf && node.isLeaf()) {
throw new RuntimeException("Wrong Child: child id no leaf, but node is leaf!");
}
node.integrityCheckParameters((N) this, i);
node.integrityCheck(tree);
}
}
if(LoggingConfiguration.DEBUG) {
Logger.getLogger(this.getClass().getName()).fine("DirNode " + getPageID() + " ok!");
}
}
} } | public class class_name {
@SuppressWarnings("unchecked")
public final void integrityCheck(AbstractRStarTree<N, E, ?> tree) {
// leaf node
if(isLeaf()) {
for(int i = 0; i < getCapacity(); i++) {
E e = getEntry(i);
if(i < getNumEntries() && e == null) {
throw new RuntimeException("i < numEntries && entry == null");
}
if(i >= getNumEntries() && e != null) {
throw new RuntimeException("i >= numEntries && entry != null");
}
}
}
// dir node
else {
N tmp = tree.getNode(getEntry(0));
boolean childIsLeaf = tmp.isLeaf();
for(int i = 0; i < getCapacity(); i++) {
E e = getEntry(i);
if(i < getNumEntries() && e == null) {
throw new RuntimeException("i < numEntries && entry == null");
}
if(i >= getNumEntries() && e != null) {
throw new RuntimeException("i >= numEntries && entry != null");
}
if(e != null) {
N node = tree.getNode(e);
if(childIsLeaf && !node.isLeaf()) {
for(int k = 0; k < getNumEntries(); k++) {
tree.getNode(getEntry(k)); // depends on control dependency: [for], data = [k]
}
throw new RuntimeException("Wrong Child in " + this + " at " + i);
}
if(!childIsLeaf && node.isLeaf()) {
throw new RuntimeException("Wrong Child: child id no leaf, but node is leaf!");
}
node.integrityCheckParameters((N) this, i); // depends on control dependency: [if], data = [none]
node.integrityCheck(tree); // depends on control dependency: [if], data = [none]
}
}
if(LoggingConfiguration.DEBUG) {
Logger.getLogger(this.getClass().getName()).fine("DirNode " + getPageID() + " ok!"); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public static String percentDecode(final String input) {
if (input.isEmpty()) {
return input;
}
try {
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
int idx = 0;
while (idx < input.length()) {
boolean isEOF = idx >= input.length();
int c = (isEOF)? 0x00 : input.codePointAt(idx);
while (!isEOF && c != '%') {
if (c <= 0x7F) { // String.getBytes is slow, so do not perform encoding
// if not needed
bytes.write((byte) c);
idx++;
} else {
bytes.write(new String(Character.toChars(c)).getBytes(UTF_8));
idx += Character.charCount(c);
}
isEOF = idx >= input.length();
c = (isEOF)? 0x00 : input.codePointAt(idx);
}
if (c == '%' && (input.length() <= idx + 2 ||
!isASCIIHexDigit(input.charAt(idx + 1)) ||
!isASCIIHexDigit(input.charAt(idx + 2)))) {
if (c <= 0x7F) { // String.getBytes is slow, so do not perform encoding
// if not needed
bytes.write((byte) c);
idx++;
} else {
bytes.write(new String(Character.toChars(c)).getBytes(UTF_8));
idx += Character.charCount(c);
}
} else {
while (c == '%' && input.length() > idx + 2 &&
isASCIIHexDigit(input.charAt(idx + 1)) &&
isASCIIHexDigit(input.charAt(idx + 2))) {
bytes.write(hexToInt(input.charAt(idx + 1), input.charAt(idx + 2)));
idx += 3;
c = (input.length() <= idx)? 0x00 : input.codePointAt(idx);
}
}
}
return new String(bytes.toByteArray(), UTF_8);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
} } | public class class_name {
public static String percentDecode(final String input) {
if (input.isEmpty()) {
return input; // depends on control dependency: [if], data = [none]
}
try {
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
int idx = 0;
while (idx < input.length()) {
boolean isEOF = idx >= input.length();
int c = (isEOF)? 0x00 : input.codePointAt(idx);
while (!isEOF && c != '%') {
if (c <= 0x7F) { // String.getBytes is slow, so do not perform encoding
// if not needed
bytes.write((byte) c); // depends on control dependency: [if], data = [none]
idx++; // depends on control dependency: [if], data = [none]
} else {
bytes.write(new String(Character.toChars(c)).getBytes(UTF_8)); // depends on control dependency: [if], data = [(c]
idx += Character.charCount(c); // depends on control dependency: [if], data = [(c]
}
isEOF = idx >= input.length(); // depends on control dependency: [while], data = [none]
c = (isEOF)? 0x00 : input.codePointAt(idx); // depends on control dependency: [while], data = [none]
}
if (c == '%' && (input.length() <= idx + 2 ||
!isASCIIHexDigit(input.charAt(idx + 1)) ||
!isASCIIHexDigit(input.charAt(idx + 2)))) {
if (c <= 0x7F) { // String.getBytes is slow, so do not perform encoding
// if not needed
bytes.write((byte) c); // depends on control dependency: [if], data = [none]
idx++; // depends on control dependency: [if], data = [none]
} else {
bytes.write(new String(Character.toChars(c)).getBytes(UTF_8)); // depends on control dependency: [if], data = [(c]
idx += Character.charCount(c); // depends on control dependency: [if], data = [(c]
}
} else {
while (c == '%' && input.length() > idx + 2 &&
isASCIIHexDigit(input.charAt(idx + 1)) &&
isASCIIHexDigit(input.charAt(idx + 2))) {
bytes.write(hexToInt(input.charAt(idx + 1), input.charAt(idx + 2))); // depends on control dependency: [while], data = [none]
idx += 3; // depends on control dependency: [while], data = [none]
c = (input.length() <= idx)? 0x00 : input.codePointAt(idx); // depends on control dependency: [while], data = [none]
}
}
}
return new String(bytes.toByteArray(), UTF_8); // depends on control dependency: [try], data = [none]
} catch (IOException ex) {
throw new RuntimeException(ex);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void setMonth(String monthStr) {
final Month month = Month.valueOf(monthStr);
if ((m_model.getMonth() == null) || !m_model.getMonth().equals(monthStr)) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setMonth(month);
onValueChange();
}
});
}
} } | public class class_name {
public void setMonth(String monthStr) {
final Month month = Month.valueOf(monthStr);
if ((m_model.getMonth() == null) || !m_model.getMonth().equals(monthStr)) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setMonth(month);
onValueChange();
}
}); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private static void addPanels(TabbedPanel2 tabbedPanel, List<AbstractPanel> panels, boolean visible) {
for (AbstractPanel panel : panels) {
addPanel(tabbedPanel, panel, visible);
}
tabbedPanel.revalidate();
} } | public class class_name {
private static void addPanels(TabbedPanel2 tabbedPanel, List<AbstractPanel> panels, boolean visible) {
for (AbstractPanel panel : panels) {
addPanel(tabbedPanel, panel, visible);
// depends on control dependency: [for], data = [panel]
}
tabbedPanel.revalidate();
} } |
public class class_name {
public static <T extends Throwable> Throwable peel(final Throwable t, Class<T> allowedType,
String message, RuntimeExceptionFactory runtimeExceptionFactory) {
if (t instanceof RuntimeException) {
return t;
}
if (t instanceof ExecutionException || t instanceof InvocationTargetException) {
final Throwable cause = t.getCause();
if (cause != null) {
return peel(cause, allowedType, message, runtimeExceptionFactory);
} else {
return runtimeExceptionFactory.create(t, message);
}
}
if (allowedType != null && allowedType.isAssignableFrom(t.getClass())) {
return t;
}
return runtimeExceptionFactory.create(t, message);
} } | public class class_name {
public static <T extends Throwable> Throwable peel(final Throwable t, Class<T> allowedType,
String message, RuntimeExceptionFactory runtimeExceptionFactory) {
if (t instanceof RuntimeException) {
return t; // depends on control dependency: [if], data = [none]
}
if (t instanceof ExecutionException || t instanceof InvocationTargetException) {
final Throwable cause = t.getCause();
if (cause != null) {
return peel(cause, allowedType, message, runtimeExceptionFactory); // depends on control dependency: [if], data = [(cause]
} else {
return runtimeExceptionFactory.create(t, message); // depends on control dependency: [if], data = [none]
}
}
if (allowedType != null && allowedType.isAssignableFrom(t.getClass())) {
return t; // depends on control dependency: [if], data = [none]
}
return runtimeExceptionFactory.create(t, message);
} } |
public class class_name {
protected static PackageInfo getPackageInfo(Context ctx) {
try {
return ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Error getting package info.", e);
return null;
}
} } | public class class_name {
protected static PackageInfo getPackageInfo(Context ctx) {
try {
return ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0); // depends on control dependency: [try], data = [none]
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Error getting package info.", e);
return null;
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private static boolean isDefaultHttpOrHttpsPort(String scheme, int port) {
if (port == DEFAULT_HTTP_PORT && isHttp(scheme)) {
return true;
}
if (port == DEFAULT_HTTPS_PORT && isHttps(scheme)) {
return true;
}
return false;
} } | public class class_name {
private static boolean isDefaultHttpOrHttpsPort(String scheme, int port) {
if (port == DEFAULT_HTTP_PORT && isHttp(scheme)) {
return true; // depends on control dependency: [if], data = [none]
}
if (port == DEFAULT_HTTPS_PORT && isHttps(scheme)) {
return true; // depends on control dependency: [if], data = [none]
}
return false;
} } |
public class class_name {
public static PathImpl getLocalWorkDir(ClassLoader loader)
{
PathImpl path = _localWorkDir.get(loader);
if (path != null)
return path;
path = getTmpWorkDir();
_localWorkDir.setGlobal(path);
try {
path.mkdirs();
} catch (java.io.IOException e) {
}
return path;
} } | public class class_name {
public static PathImpl getLocalWorkDir(ClassLoader loader)
{
PathImpl path = _localWorkDir.get(loader);
if (path != null)
return path;
path = getTmpWorkDir();
_localWorkDir.setGlobal(path);
try {
path.mkdirs(); // depends on control dependency: [try], data = [none]
} catch (java.io.IOException e) {
} // depends on control dependency: [catch], data = [none]
return path;
} } |
public class class_name {
protected String getLastPathLevel(String path) {
path = path.trim();
if (path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
if (path.contains("/")) {
path = path.substring(path.lastIndexOf("/"));
}
return path;
} } | public class class_name {
protected String getLastPathLevel(String path) {
path = path.trim();
if (path.endsWith("/")) {
path = path.substring(0, path.length() - 1); // depends on control dependency: [if], data = [none]
}
if (path.contains("/")) {
path = path.substring(path.lastIndexOf("/")); // depends on control dependency: [if], data = [none]
}
return path;
} } |
public class class_name {
private static String toLanguageTag(Locale locale) {
if (locale == null) {
return null;
}
StringBuilder tag = new StringBuilder();
tag.append(locale.getLanguage().toLowerCase());
if (!locale.getCountry().isEmpty()) {
tag.append("-");
tag.append(locale.getCountry().toUpperCase());
}
return tag.toString();
} } | public class class_name {
private static String toLanguageTag(Locale locale) {
if (locale == null) {
return null; // depends on control dependency: [if], data = [none]
}
StringBuilder tag = new StringBuilder();
tag.append(locale.getLanguage().toLowerCase());
if (!locale.getCountry().isEmpty()) {
tag.append("-"); // depends on control dependency: [if], data = [none]
tag.append(locale.getCountry().toUpperCase()); // depends on control dependency: [if], data = [none]
}
return tag.toString();
} } |
public class class_name {
private StorageDirView selectEvictableDirFromTier(StorageTierView tierView, long availableBytes) {
for (StorageDirView dirView : tierView.getDirViews()) {
if (canEvictBlocksFromDir(dirView, availableBytes)) {
return dirView;
}
}
return null;
} } | public class class_name {
private StorageDirView selectEvictableDirFromTier(StorageTierView tierView, long availableBytes) {
for (StorageDirView dirView : tierView.getDirViews()) {
if (canEvictBlocksFromDir(dirView, availableBytes)) {
return dirView; // depends on control dependency: [if], data = [none]
}
}
return null;
} } |
public class class_name {
public BranchEvent addCustomDataProperty(String propertyName, String propertyValue) {
try {
this.customProperties.put(propertyName, propertyValue);
} catch (JSONException e) {
e.printStackTrace();
}
return this;
} } | public class class_name {
public BranchEvent addCustomDataProperty(String propertyName, String propertyValue) {
try {
this.customProperties.put(propertyName, propertyValue); // depends on control dependency: [try], data = [none]
} catch (JSONException e) {
e.printStackTrace();
} // depends on control dependency: [catch], data = [none]
return this;
} } |
public class class_name {
@Nullable
public static double[] optDoubleArray(@Nullable Bundle bundle, @Nullable String key, @Nullable double[] fallback) {
if (bundle == null) {
return fallback;
}
return bundle.getDoubleArray(key);
} } | public class class_name {
@Nullable
public static double[] optDoubleArray(@Nullable Bundle bundle, @Nullable String key, @Nullable double[] fallback) {
if (bundle == null) {
return fallback; // depends on control dependency: [if], data = [none]
}
return bundle.getDoubleArray(key);
} } |
public class class_name {
public void marshall(SmartHomeAppliance smartHomeAppliance, ProtocolMarshaller protocolMarshaller) {
if (smartHomeAppliance == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(smartHomeAppliance.getFriendlyName(), FRIENDLYNAME_BINDING);
protocolMarshaller.marshall(smartHomeAppliance.getDescription(), DESCRIPTION_BINDING);
protocolMarshaller.marshall(smartHomeAppliance.getManufacturerName(), MANUFACTURERNAME_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(SmartHomeAppliance smartHomeAppliance, ProtocolMarshaller protocolMarshaller) {
if (smartHomeAppliance == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(smartHomeAppliance.getFriendlyName(), FRIENDLYNAME_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(smartHomeAppliance.getDescription(), DESCRIPTION_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(smartHomeAppliance.getManufacturerName(), MANUFACTURERNAME_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 static final BigInteger printWorkUnits(TimeUnit value)
{
int result;
if (value == null)
{
value = TimeUnit.HOURS;
}
switch (value)
{
case MINUTES:
{
result = 1;
break;
}
case DAYS:
{
result = 3;
break;
}
case WEEKS:
{
result = 4;
break;
}
case MONTHS:
{
result = 5;
break;
}
case YEARS:
{
result = 7;
break;
}
default:
case HOURS:
{
result = 2;
break;
}
}
return (BigInteger.valueOf(result));
} } | public class class_name {
public static final BigInteger printWorkUnits(TimeUnit value)
{
int result;
if (value == null)
{
value = TimeUnit.HOURS; // depends on control dependency: [if], data = [none]
}
switch (value)
{
case MINUTES:
{
result = 1;
break;
}
case DAYS:
{
result = 3;
break;
}
case WEEKS:
{
result = 4;
break;
}
case MONTHS:
{
result = 5;
break;
}
case YEARS:
{
result = 7;
break;
}
default:
case HOURS:
{
result = 2;
break;
}
}
return (BigInteger.valueOf(result));
} } |
public class class_name {
public void marshall(GetGeoMatchSetRequest getGeoMatchSetRequest, ProtocolMarshaller protocolMarshaller) {
if (getGeoMatchSetRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(getGeoMatchSetRequest.getGeoMatchSetId(), GEOMATCHSETID_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(GetGeoMatchSetRequest getGeoMatchSetRequest, ProtocolMarshaller protocolMarshaller) {
if (getGeoMatchSetRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(getGeoMatchSetRequest.getGeoMatchSetId(), GEOMATCHSETID_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 byte[] buildHeader(HeaderFieldType xIndexingType, String xHeaderName, String xHeaderValue, long xHeaderIndex) {
byte headerStaticIndex = -1;
byte[] retArray = null;
LongEncoder enc = new LongEncoder();
if (xHeaderName != null) {
headerStaticIndex = utils.getIndexNumber(xHeaderName);
}
if (xIndexingType == HeaderFieldType.INDEXED) {
if (headerStaticIndex != -1) {
// one of the headers defined in the spec static table
retArray = new byte[1];
retArray[0] = (byte) (0x80 | headerStaticIndex);
} else {
// user passed in the headerIndex that we are to use
retArray = enc.encode(xHeaderIndex, 7);
retArray[0] = (byte) (0x80 | retArray[0]);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Indexed header built array: " + utils.printArray(retArray));
}
return retArray;
}
if ((xIndexingType == HeaderFieldType.LITERAL_INCREMENTAL_INDEXING)
|| (xIndexingType == HeaderFieldType.LITERAL_NEVER_INDEXED_INDEXED_NAME)
|| (xIndexingType == HeaderFieldType.LITERAL_WITHOUT_INDEXING_AND_INDEXED_NAME)) {
byte[] idxArray = null;
if (xHeaderName != null) {
headerStaticIndex = utils.getIndexNumber(xHeaderName);
}
// user passed in the headerIndex that we are to use
if (xIndexingType == HeaderFieldType.LITERAL_INCREMENTAL_INDEXING) {
idxArray = enc.encode(headerStaticIndex, 6);
// set first two bits to "01"
idxArray[0] = (byte) (0x40 | idxArray[0]);
idxArray[0] = (byte) (0x7F & idxArray[0]);
} else if (xIndexingType == HeaderFieldType.LITERAL_NEVER_INDEXED_INDEXED_NAME) {
idxArray = enc.encode(headerStaticIndex, 4);
// set first four bits to "0001"
idxArray[0] = (byte) (0x10 | idxArray[0]);
idxArray[0] = (byte) (0x1F & idxArray[0]);
} else if ((xIndexingType == HeaderFieldType.LITERAL_WITHOUT_INDEXING_AND_INDEXED_NAME)) {
idxArray = enc.encode(headerStaticIndex, 4);
// set first four bits to "0000"
idxArray[0] = (byte) (0x0F & idxArray[0]);
}
byte[] ba = xHeaderValue.getBytes(); // may need to deal with string encoding later
byte[] hArrayValue = HuffmanEncoder.convertAsciiToHuffman(ba);
byte[] hArrayLength = enc.encode(hArrayValue.length, 7);
hArrayLength[0] = (byte) (0x80 | hArrayLength[0]);
int totalLength = idxArray.length + hArrayLength.length + hArrayValue.length;
retArray = new byte[totalLength];
System.arraycopy(idxArray, 0, retArray, 0, idxArray.length);
System.arraycopy(hArrayLength, 0, retArray, idxArray.length, hArrayLength.length);
System.arraycopy(hArrayValue, 0, retArray, idxArray.length + hArrayLength.length, hArrayValue.length);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Literal Header Field with Incremental Indexing built array: " + utils.printArray(retArray));
}
return retArray;
}
if ((xIndexingType == HeaderFieldType.LITERAL_WITHOUT_INDEXING_AND_NEW_NAME) ||
(xIndexingType == HeaderFieldType.LITERAL_NEVER_INDEXED_NEW_NAME) ||
(xIndexingType == HeaderFieldType.LITERAL_INCREMENTAL_INDEXING_NEW_NAME)) {
byte[] ba = xHeaderName.getBytes(); // may need to deal with string encoding later
byte[] hName = HuffmanEncoder.convertAsciiToHuffman(ba);
byte[] hNameLength = enc.encode(hName.length, 7);
hNameLength[0] = (byte) (0x80 | hNameLength[0]);
ba = xHeaderValue.getBytes(); // may need to deal with string encoding later
byte[] hValue = HuffmanEncoder.convertAsciiToHuffman(ba);
byte[] hValueLength = enc.encode(hValue.length, 7);
hValueLength[0] = (byte) (0x80 | hValueLength[0]);
int totalLength = 1 + hNameLength.length + hName.length + hValueLength.length + hValue.length;
retArray = new byte[totalLength];
if (xIndexingType == HeaderFieldType.LITERAL_WITHOUT_INDEXING_AND_NEW_NAME) {
retArray[0] = 0x00;
} else if (xIndexingType == HeaderFieldType.LITERAL_NEVER_INDEXED_NEW_NAME) {
retArray[0] = 0x10;
} else if (xIndexingType == HeaderFieldType.LITERAL_INCREMENTAL_INDEXING_NEW_NAME) {
retArray[0] = 0x40;
}
System.arraycopy(hNameLength, 0, retArray, 1, hNameLength.length);
System.arraycopy(hName, 0, retArray, 1 + hNameLength.length, hName.length);
System.arraycopy(hValueLength, 0, retArray, 1 + hNameLength.length + hName.length, hValueLength.length);
System.arraycopy(hValue, 0, retArray, 1 + hNameLength.length + hName.length + hValueLength.length, hValue.length);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Literal Header Field without Indexing - new Name built array: "
+ utils.printArray(retArray));
}
return retArray;
}
return null;
} } | public class class_name {
public byte[] buildHeader(HeaderFieldType xIndexingType, String xHeaderName, String xHeaderValue, long xHeaderIndex) {
byte headerStaticIndex = -1;
byte[] retArray = null;
LongEncoder enc = new LongEncoder();
if (xHeaderName != null) {
headerStaticIndex = utils.getIndexNumber(xHeaderName); // depends on control dependency: [if], data = [(xHeaderName]
}
if (xIndexingType == HeaderFieldType.INDEXED) {
if (headerStaticIndex != -1) {
// one of the headers defined in the spec static table
retArray = new byte[1]; // depends on control dependency: [if], data = [none]
retArray[0] = (byte) (0x80 | headerStaticIndex); // depends on control dependency: [if], data = [none]
} else {
// user passed in the headerIndex that we are to use
retArray = enc.encode(xHeaderIndex, 7); // depends on control dependency: [if], data = [none]
retArray[0] = (byte) (0x80 | retArray[0]); // depends on control dependency: [if], data = [none]
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Indexed header built array: " + utils.printArray(retArray)); // depends on control dependency: [if], data = [none]
}
return retArray; // depends on control dependency: [if], data = [none]
}
if ((xIndexingType == HeaderFieldType.LITERAL_INCREMENTAL_INDEXING)
|| (xIndexingType == HeaderFieldType.LITERAL_NEVER_INDEXED_INDEXED_NAME)
|| (xIndexingType == HeaderFieldType.LITERAL_WITHOUT_INDEXING_AND_INDEXED_NAME)) {
byte[] idxArray = null;
if (xHeaderName != null) {
headerStaticIndex = utils.getIndexNumber(xHeaderName); // depends on control dependency: [if], data = [(xHeaderName]
}
// user passed in the headerIndex that we are to use
if (xIndexingType == HeaderFieldType.LITERAL_INCREMENTAL_INDEXING) {
idxArray = enc.encode(headerStaticIndex, 6); // depends on control dependency: [if], data = [none]
// set first two bits to "01"
idxArray[0] = (byte) (0x40 | idxArray[0]); // depends on control dependency: [if], data = [none]
idxArray[0] = (byte) (0x7F & idxArray[0]); // depends on control dependency: [if], data = [none]
} else if (xIndexingType == HeaderFieldType.LITERAL_NEVER_INDEXED_INDEXED_NAME) {
idxArray = enc.encode(headerStaticIndex, 4); // depends on control dependency: [if], data = [none]
// set first four bits to "0001"
idxArray[0] = (byte) (0x10 | idxArray[0]); // depends on control dependency: [if], data = [none]
idxArray[0] = (byte) (0x1F & idxArray[0]); // depends on control dependency: [if], data = [none]
} else if ((xIndexingType == HeaderFieldType.LITERAL_WITHOUT_INDEXING_AND_INDEXED_NAME)) {
idxArray = enc.encode(headerStaticIndex, 4); // depends on control dependency: [if], data = [none]
// set first four bits to "0000"
idxArray[0] = (byte) (0x0F & idxArray[0]); // depends on control dependency: [if], data = [none]
}
byte[] ba = xHeaderValue.getBytes(); // may need to deal with string encoding later
byte[] hArrayValue = HuffmanEncoder.convertAsciiToHuffman(ba);
byte[] hArrayLength = enc.encode(hArrayValue.length, 7);
hArrayLength[0] = (byte) (0x80 | hArrayLength[0]); // depends on control dependency: [if], data = [none]
int totalLength = idxArray.length + hArrayLength.length + hArrayValue.length;
retArray = new byte[totalLength]; // depends on control dependency: [if], data = [none]
System.arraycopy(idxArray, 0, retArray, 0, idxArray.length); // depends on control dependency: [if], data = [none]
System.arraycopy(hArrayLength, 0, retArray, idxArray.length, hArrayLength.length); // depends on control dependency: [if], data = [none]
System.arraycopy(hArrayValue, 0, retArray, idxArray.length + hArrayLength.length, hArrayValue.length); // depends on control dependency: [if], data = [none]
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Literal Header Field with Incremental Indexing built array: " + utils.printArray(retArray)); // depends on control dependency: [if], data = [none]
}
return retArray; // depends on control dependency: [if], data = [none]
}
if ((xIndexingType == HeaderFieldType.LITERAL_WITHOUT_INDEXING_AND_NEW_NAME) ||
(xIndexingType == HeaderFieldType.LITERAL_NEVER_INDEXED_NEW_NAME) ||
(xIndexingType == HeaderFieldType.LITERAL_INCREMENTAL_INDEXING_NEW_NAME)) {
byte[] ba = xHeaderName.getBytes(); // may need to deal with string encoding later
byte[] hName = HuffmanEncoder.convertAsciiToHuffman(ba);
byte[] hNameLength = enc.encode(hName.length, 7);
hNameLength[0] = (byte) (0x80 | hNameLength[0]); // depends on control dependency: [if], data = [none]
ba = xHeaderValue.getBytes(); // may need to deal with string encoding later // depends on control dependency: [if], data = [none]
byte[] hValue = HuffmanEncoder.convertAsciiToHuffman(ba);
byte[] hValueLength = enc.encode(hValue.length, 7);
hValueLength[0] = (byte) (0x80 | hValueLength[0]); // depends on control dependency: [if], data = [none]
int totalLength = 1 + hNameLength.length + hName.length + hValueLength.length + hValue.length;
retArray = new byte[totalLength]; // depends on control dependency: [if], data = [none]
if (xIndexingType == HeaderFieldType.LITERAL_WITHOUT_INDEXING_AND_NEW_NAME) {
retArray[0] = 0x00; // depends on control dependency: [if], data = [none]
} else if (xIndexingType == HeaderFieldType.LITERAL_NEVER_INDEXED_NEW_NAME) {
retArray[0] = 0x10; // depends on control dependency: [if], data = [none]
} else if (xIndexingType == HeaderFieldType.LITERAL_INCREMENTAL_INDEXING_NEW_NAME) {
retArray[0] = 0x40; // depends on control dependency: [if], data = [none]
}
System.arraycopy(hNameLength, 0, retArray, 1, hNameLength.length); // depends on control dependency: [if], data = [none]
System.arraycopy(hName, 0, retArray, 1 + hNameLength.length, hName.length); // depends on control dependency: [if], data = [none]
System.arraycopy(hValueLength, 0, retArray, 1 + hNameLength.length + hName.length, hValueLength.length); // depends on control dependency: [if], data = [none]
System.arraycopy(hValue, 0, retArray, 1 + hNameLength.length + hName.length + hValueLength.length, hValue.length); // depends on control dependency: [if], data = [none]
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Literal Header Field without Indexing - new Name built array: "
+ utils.printArray(retArray)); // depends on control dependency: [if], data = [none]
}
return retArray; // depends on control dependency: [if], data = [none]
}
return null;
} } |
public class class_name {
private void add(String name, double time) {
allData.add(name, time, 1);
if (time > SLOW_TIME) {
slowData.add(name, time, 1);
}
if (time > VERYSLOW_TIME) {
verySlowData.add(name, time, 1);
}
// this.allData.addMinute(name, time, 1);
} } | public class class_name {
private void add(String name, double time) {
allData.add(name, time, 1);
if (time > SLOW_TIME) {
slowData.add(name, time, 1); // depends on control dependency: [if], data = [none]
}
if (time > VERYSLOW_TIME) {
verySlowData.add(name, time, 1); // depends on control dependency: [if], data = [none]
}
// this.allData.addMinute(name, time, 1);
} } |
public class class_name {
public void setStatusText(String strStatus, int iWarningLevel)
{
if (strStatus == null)
strStatus = Constants.BLANK;
m_strCurrentStatus = strStatus;
m_iCurrentWarningLevel = iWarningLevel;
//xif (this.getApplet() != null)
//x ((BaseApplet)this.getApplet()).showStatus(strStatus);
//xelse
//x{
if (iWarningLevel != Constants.ERROR)
{ // Warning or information
ImageIcon icon = null;
if (iWarningLevel == Constants.INFORMATION)
icon = this.loadImageIcon(ThinMenuConstants.INFORMATION);
else if (iWarningLevel == Constants.WARNING)
icon = this.loadImageIcon(ThinMenuConstants.WARNING);
else if (iWarningLevel == Constants.WAIT)
icon = this.loadImageIcon(ThinMenuConstants.WAIT);
else if (iWarningLevel == Constants.ERROR)
icon = this.loadImageIcon(ThinMenuConstants.ERROR);
if (this.getStatusbar() != null)
this.getStatusbar().showStatus(strStatus, icon, iWarningLevel);
}
else
{ // Full blown error message (show dialog)
Container frame = BaseApplet.getSharedInstance();
while ((frame = frame.getParent()) != null)
{
if (frame instanceof JFrame)
{
JOptionPane.showMessageDialog((JFrame)frame, strStatus, "Error: ", JOptionPane.WARNING_MESSAGE);
break;
}
}
}
//x}
} } | public class class_name {
public void setStatusText(String strStatus, int iWarningLevel)
{
if (strStatus == null)
strStatus = Constants.BLANK;
m_strCurrentStatus = strStatus;
m_iCurrentWarningLevel = iWarningLevel;
//xif (this.getApplet() != null)
//x ((BaseApplet)this.getApplet()).showStatus(strStatus);
//xelse
//x{
if (iWarningLevel != Constants.ERROR)
{ // Warning or information
ImageIcon icon = null;
if (iWarningLevel == Constants.INFORMATION)
icon = this.loadImageIcon(ThinMenuConstants.INFORMATION);
else if (iWarningLevel == Constants.WARNING)
icon = this.loadImageIcon(ThinMenuConstants.WARNING);
else if (iWarningLevel == Constants.WAIT)
icon = this.loadImageIcon(ThinMenuConstants.WAIT);
else if (iWarningLevel == Constants.ERROR)
icon = this.loadImageIcon(ThinMenuConstants.ERROR);
if (this.getStatusbar() != null)
this.getStatusbar().showStatus(strStatus, icon, iWarningLevel);
}
else
{ // Full blown error message (show dialog)
Container frame = BaseApplet.getSharedInstance();
while ((frame = frame.getParent()) != null)
{
if (frame instanceof JFrame)
{
JOptionPane.showMessageDialog((JFrame)frame, strStatus, "Error: ", JOptionPane.WARNING_MESSAGE); // depends on control dependency: [if], data = [none]
break;
}
}
}
//x}
} } |
public class class_name {
@SuppressWarnings("WeakerAccess")
@UiThread
public boolean popToRoot(@Nullable ControllerChangeHandler changeHandler) {
ThreadUtils.ensureMainThread();
if (backstack.size() > 1) {
//noinspection ConstantConditions
popToTransaction(backstack.root(), changeHandler);
return true;
} else {
return false;
}
} } | public class class_name {
@SuppressWarnings("WeakerAccess")
@UiThread
public boolean popToRoot(@Nullable ControllerChangeHandler changeHandler) {
ThreadUtils.ensureMainThread();
if (backstack.size() > 1) {
//noinspection ConstantConditions
popToTransaction(backstack.root(), changeHandler); // depends on control dependency: [if], data = [none]
return true; // depends on control dependency: [if], data = [none]
} else {
return false; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void clickOnScreen(float x, float y, View view) {
boolean successfull = false;
int retry = 0;
SecurityException ex = null;
while(!successfull && retry < 20) {
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_DOWN, x, y, 0);
MotionEvent event2 = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_UP, x, y, 0);
try{
inst.sendPointerSync(event);
inst.sendPointerSync(event2);
successfull = true;
}catch(SecurityException e){
ex = e;
dialogUtils.hideSoftKeyboard(null, false, true);
sleeper.sleep(MINI_WAIT);
retry++;
View identicalView = viewFetcher.getIdenticalView(view);
if(identicalView != null){
float[] xyToClick = getClickCoordinates(identicalView);
x = xyToClick[0];
y = xyToClick[1];
}
}
}
if(!successfull) {
Assert.fail("Click at ("+x+", "+y+") can not be completed! ("+(ex != null ? ex.getClass().getName()+": "+ex.getMessage() : "null")+")");
}
} } | public class class_name {
public void clickOnScreen(float x, float y, View view) {
boolean successfull = false;
int retry = 0;
SecurityException ex = null;
while(!successfull && retry < 20) {
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_DOWN, x, y, 0);
MotionEvent event2 = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_UP, x, y, 0);
try{
inst.sendPointerSync(event); // depends on control dependency: [try], data = [none]
inst.sendPointerSync(event2); // depends on control dependency: [try], data = [none]
successfull = true; // depends on control dependency: [try], data = [none]
}catch(SecurityException e){
ex = e;
dialogUtils.hideSoftKeyboard(null, false, true);
sleeper.sleep(MINI_WAIT);
retry++;
View identicalView = viewFetcher.getIdenticalView(view);
if(identicalView != null){
float[] xyToClick = getClickCoordinates(identicalView);
x = xyToClick[0]; // depends on control dependency: [if], data = [none]
y = xyToClick[1]; // depends on control dependency: [if], data = [none]
}
} // depends on control dependency: [catch], data = [none]
}
if(!successfull) {
Assert.fail("Click at ("+x+", "+y+") can not be completed! ("+(ex != null ? ex.getClass().getName()+": "+ex.getMessage() : "null")+")");
}
} } |
public class class_name {
public static <E> Counter<E> linearCombination(Counter<E> c1, double w1, Counter<E> c2, double w2) {
Counter<E> result = c1.getFactory().create();
for (E o : c1.keySet()) {
result.incrementCount(o, c1.getCount(o) * w1);
}
for (E o : c2.keySet()) {
result.incrementCount(o, c2.getCount(o) * w2);
}
return result;
} } | public class class_name {
public static <E> Counter<E> linearCombination(Counter<E> c1, double w1, Counter<E> c2, double w2) {
Counter<E> result = c1.getFactory().create();
for (E o : c1.keySet()) {
result.incrementCount(o, c1.getCount(o) * w1);
// depends on control dependency: [for], data = [o]
}
for (E o : c2.keySet()) {
result.incrementCount(o, c2.getCount(o) * w2);
// depends on control dependency: [for], data = [o]
}
return result;
} } |
public class class_name {
public void quit() {
try {
this.keepOn = false;
if (this.serverSocket != null && !this.serverSocket.isClosed()) {
this.serverSocket.close();
this.serverSocket = null;
}
} catch (final IOException e) {
throw new RuntimeException(e);
}
} } | public class class_name {
public void quit() {
try {
this.keepOn = false; // depends on control dependency: [try], data = [none]
if (this.serverSocket != null && !this.serverSocket.isClosed()) {
this.serverSocket.close(); // depends on control dependency: [if], data = [none]
this.serverSocket = null; // depends on control dependency: [if], data = [none]
}
} catch (final IOException e) {
throw new RuntimeException(e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public static String fill(char c, int size) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < size; i++) {
builder.append(c);
}
return builder.toString();
} } | public class class_name {
public static String fill(char c, int size) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < size; i++) {
builder.append(c); // depends on control dependency: [for], data = [none]
}
return builder.toString();
} } |
public class class_name {
@Override
public long getByteHighWaterMark() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
{
SibTr.entry(tc, "getByteHighWaterMark");
SibTr.exit(tc, "getByteHighWaterMark");
}
return -1;
} } | public class class_name {
@Override
public long getByteHighWaterMark() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
{
SibTr.entry(tc, "getByteHighWaterMark"); // depends on control dependency: [if], data = [none]
SibTr.exit(tc, "getByteHighWaterMark"); // depends on control dependency: [if], data = [none]
}
return -1;
} } |
public class class_name {
public static boolean recursiveDelete (final File pFile) {
if (pFile.isDirectory()) {
for (final File child : pFile.listFiles()) {
if (!recursiveDelete(child)) { return false; }
}
}
return pFile.delete();
} } | public class class_name {
public static boolean recursiveDelete (final File pFile) {
if (pFile.isDirectory()) {
for (final File child : pFile.listFiles()) {
if (!recursiveDelete(child)) { return false; }
// depends on control dependency: [if], data = [none]
}
}
return pFile.delete();
} } |
public class class_name {
public Object nextElement()
{
if (_array == null)
{
return null;
}
else
{
synchronized(this){
if (_index < _array.length)
{
Object obj = _array[_index];
_index++;
return obj;
}
else
{
return null;
}
}
}
} } | public class class_name {
public Object nextElement()
{
if (_array == null)
{
return null; // depends on control dependency: [if], data = [none]
}
else
{
synchronized(this){ // depends on control dependency: [if], data = [none]
if (_index < _array.length)
{
Object obj = _array[_index];
_index++; // depends on control dependency: [if], data = [none]
return obj; // depends on control dependency: [if], data = [none]
}
else
{
return null; // depends on control dependency: [if], data = [none]
}
}
}
} } |
public class class_name {
private static Object readFieldValue(final Object obj, final Field field) {
try {
return field.get(obj);
} catch (Exception ex) {
throw new JBBPException("Can't get value from field [" + field + ']', ex);
}
} } | public class class_name {
private static Object readFieldValue(final Object obj, final Field field) {
try {
return field.get(obj); // depends on control dependency: [try], data = [none]
} catch (Exception ex) {
throw new JBBPException("Can't get value from field [" + field + ']', ex);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private void handleLastFrame(AbstractFramedStreamSourceChannel newChannel) {
//make a defensive copy
Set<AbstractFramedStreamSourceChannel<C, R, S>> receivers = new HashSet<>(getReceivers());
for(AbstractFramedStreamSourceChannel<C, R, S> r : receivers) {
if(r != newChannel) {
r.markStreamBroken();
}
}
} } | public class class_name {
private void handleLastFrame(AbstractFramedStreamSourceChannel newChannel) {
//make a defensive copy
Set<AbstractFramedStreamSourceChannel<C, R, S>> receivers = new HashSet<>(getReceivers());
for(AbstractFramedStreamSourceChannel<C, R, S> r : receivers) {
if(r != newChannel) {
r.markStreamBroken(); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
private boolean checkForBadModuleReference(Name name, Ref ref) {
JSModuleGraph moduleGraph = compiler.getModuleGraph();
if (name.getGlobalSets() == 0 || ref.type == Ref.Type.SET_FROM_GLOBAL) {
// Back off if either 1) this name was never set, or 2) this reference /is/ a set.
return false;
}
if (name.getGlobalSets() == 1) {
// there is only one global set - it should be set as name.declaration
// just look at that declaration instead of iterating through every single reference.
Ref declaration = checkNotNull(name.getDeclaration());
return !isSetFromPrecedingModule(ref, declaration, moduleGraph);
}
// there are multiple sets, so check if any of them happens in this module or a module earlier
// in the dependency chain.
for (Ref set : name.getRefs()) {
if (isSetFromPrecedingModule(ref, set, moduleGraph)) {
return false;
}
}
return true;
} } | public class class_name {
private boolean checkForBadModuleReference(Name name, Ref ref) {
JSModuleGraph moduleGraph = compiler.getModuleGraph();
if (name.getGlobalSets() == 0 || ref.type == Ref.Type.SET_FROM_GLOBAL) {
// Back off if either 1) this name was never set, or 2) this reference /is/ a set.
return false; // depends on control dependency: [if], data = [none]
}
if (name.getGlobalSets() == 1) {
// there is only one global set - it should be set as name.declaration
// just look at that declaration instead of iterating through every single reference.
Ref declaration = checkNotNull(name.getDeclaration());
return !isSetFromPrecedingModule(ref, declaration, moduleGraph); // depends on control dependency: [if], data = [none]
}
// there are multiple sets, so check if any of them happens in this module or a module earlier
// in the dependency chain.
for (Ref set : name.getRefs()) {
if (isSetFromPrecedingModule(ref, set, moduleGraph)) {
return false; // depends on control dependency: [if], data = [none]
}
}
return true;
} } |
public class class_name {
public void marshall(DeregisterWebhookWithThirdPartyRequest deregisterWebhookWithThirdPartyRequest, ProtocolMarshaller protocolMarshaller) {
if (deregisterWebhookWithThirdPartyRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(deregisterWebhookWithThirdPartyRequest.getWebhookName(), WEBHOOKNAME_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(DeregisterWebhookWithThirdPartyRequest deregisterWebhookWithThirdPartyRequest, ProtocolMarshaller protocolMarshaller) {
if (deregisterWebhookWithThirdPartyRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(deregisterWebhookWithThirdPartyRequest.getWebhookName(), WEBHOOKNAME_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 static ICDATASectionProcessor unwrap(final ICDATASectionProcessor processor) {
if (processor == null) {
return null;
}
if (processor instanceof AbstractProcessorWrapper) {
return (ICDATASectionProcessor)((AbstractProcessorWrapper) processor).unwrap();
}
return processor;
} } | public class class_name {
public static ICDATASectionProcessor unwrap(final ICDATASectionProcessor processor) {
if (processor == null) {
return null; // depends on control dependency: [if], data = [none]
}
if (processor instanceof AbstractProcessorWrapper) {
return (ICDATASectionProcessor)((AbstractProcessorWrapper) processor).unwrap(); // depends on control dependency: [if], data = [none]
}
return processor;
} } |
public class class_name {
public Observable<ServiceResponse<List<String>>> listDomainsWithServiceResponseAsync() {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint());
return service.listDomains(this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<String>>>>() {
@Override
public Observable<ServiceResponse<List<String>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<List<String>> clientResponse = listDomainsDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
} } | public class class_name {
public Observable<ServiceResponse<List<String>>> listDomainsWithServiceResponseAsync() {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint());
return service.listDomains(this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<String>>>>() {
@Override
public Observable<ServiceResponse<List<String>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<List<String>> clientResponse = listDomainsDelegate(response);
return Observable.just(clientResponse); // depends on control dependency: [try], data = [none]
} catch (Throwable t) {
return Observable.error(t);
} // depends on control dependency: [catch], data = [none]
}
});
} } |
public class class_name {
public void setBaseConfigurationItems(java.util.Collection<BaseConfigurationItem> baseConfigurationItems) {
if (baseConfigurationItems == null) {
this.baseConfigurationItems = null;
return;
}
this.baseConfigurationItems = new com.amazonaws.internal.SdkInternalList<BaseConfigurationItem>(baseConfigurationItems);
} } | public class class_name {
public void setBaseConfigurationItems(java.util.Collection<BaseConfigurationItem> baseConfigurationItems) {
if (baseConfigurationItems == null) {
this.baseConfigurationItems = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.baseConfigurationItems = new com.amazonaws.internal.SdkInternalList<BaseConfigurationItem>(baseConfigurationItems);
} } |
public class class_name {
public boolean logModified(Logger log)
{
if (_isDigestModified) {
log.info(_source.getNativePath() + " digest is modified.");
return true;
}
long sourceLastModified = _source.getLastModified();
long sourceLength = _source.length();
// if the source was deleted and we need the source
if (! _requireSource && sourceLastModified == 0) {
return false;
}
// if the length changed
else if (sourceLength != _length) {
log.info(_source.getNativePath() + " length is modified (" +
_length + " -> " + sourceLength + ")");
return true;
}
// if the source is newer than the old value
else if (sourceLastModified != _lastModified) {
log.info(_source.getNativePath() + " time is modified.");
return true;
}
else
return false;
} } | public class class_name {
public boolean logModified(Logger log)
{
if (_isDigestModified) {
log.info(_source.getNativePath() + " digest is modified."); // depends on control dependency: [if], data = [none]
return true; // depends on control dependency: [if], data = [none]
}
long sourceLastModified = _source.getLastModified();
long sourceLength = _source.length();
// if the source was deleted and we need the source
if (! _requireSource && sourceLastModified == 0) {
return false;
}
// if the length changed
else if (sourceLength != _length) {
log.info(_source.getNativePath() + " length is modified (" +
_length + " -> " + sourceLength + ")");
return true;
}
// if the source is newer than the old value
else if (sourceLastModified != _lastModified) {
log.info(_source.getNativePath() + " time is modified.");
return true;
}
else
return false;
} } |
public class class_name {
public String fieldAndTypeList(List<RecordTemplateSpec.Field> fields) {
StringBuilder sb = new StringBuilder();
Iterator<RecordTemplateSpec.Field> iter = fields.iterator();
while(iter.hasNext()) {
RecordTemplateSpec.Field field = iter.next();
sb.append(toOptionalType(field.getType(), field.getSchemaField().getOptional()));
sb.append(" ");
sb.append(escapeKeyword(field.getSchemaField().getName()));
if (iter.hasNext()) sb.append(", ");
}
return sb.toString();
} } | public class class_name {
public String fieldAndTypeList(List<RecordTemplateSpec.Field> fields) {
StringBuilder sb = new StringBuilder();
Iterator<RecordTemplateSpec.Field> iter = fields.iterator();
while(iter.hasNext()) {
RecordTemplateSpec.Field field = iter.next();
sb.append(toOptionalType(field.getType(), field.getSchemaField().getOptional())); // depends on control dependency: [while], data = [none]
sb.append(" "); // depends on control dependency: [while], data = [none]
sb.append(escapeKeyword(field.getSchemaField().getName())); // depends on control dependency: [while], data = [none]
if (iter.hasNext()) sb.append(", ");
}
return sb.toString();
} } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.