code stringlengths 130 281k | code_dependency stringlengths 182 306k |
|---|---|
public class class_name {
@UiThread
public void notifyChildMoved(int parentPosition, int fromChildPosition, int toChildPosition) {
P parent = mParentList.get(parentPosition);
int flatParentPosition = getFlatParentPosition(parentPosition);
ExpandableWrapper<P, C> parentWrapper = mFlatItemList.get(flatParentPosition);
parentWrapper.setParent(parent);
if (parentWrapper.isExpanded()) {
ExpandableWrapper<P, C> fromChild = mFlatItemList.remove(flatParentPosition + 1 + fromChildPosition);
mFlatItemList.add(flatParentPosition + 1 + toChildPosition, fromChild);
notifyItemMoved(flatParentPosition + 1 + fromChildPosition, flatParentPosition + 1 + toChildPosition);
}
} } | public class class_name {
@UiThread
public void notifyChildMoved(int parentPosition, int fromChildPosition, int toChildPosition) {
P parent = mParentList.get(parentPosition);
int flatParentPosition = getFlatParentPosition(parentPosition);
ExpandableWrapper<P, C> parentWrapper = mFlatItemList.get(flatParentPosition);
parentWrapper.setParent(parent);
if (parentWrapper.isExpanded()) {
ExpandableWrapper<P, C> fromChild = mFlatItemList.remove(flatParentPosition + 1 + fromChildPosition);
mFlatItemList.add(flatParentPosition + 1 + toChildPosition, fromChild); // depends on control dependency: [if], data = [none]
notifyItemMoved(flatParentPosition + 1 + fromChildPosition, flatParentPosition + 1 + toChildPosition); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public int rouletteWheel(BoundedRandomGenerator<Double> randomGenerator) {
//Calculate the inverse sum
double inverseSum = 0.0;
for (int hypercube : hypercubes) {
if (hypercube > 0) {
inverseSum += 1.0 / (double) hypercube;
}
}
//Calculate a random value between 0 and sumaInversa
double random = randomGenerator.getRandomValue(0.0, inverseSum);
int hypercube = 0;
double accumulatedSum = 0.0;
while (hypercube < hypercubes.length) {
if (hypercubes[hypercube] > 0) {
accumulatedSum += 1.0 / (double) hypercubes[hypercube];
}
if (accumulatedSum > random) {
return hypercube;
}
hypercube++;
}
return hypercube;
} } | public class class_name {
public int rouletteWheel(BoundedRandomGenerator<Double> randomGenerator) {
//Calculate the inverse sum
double inverseSum = 0.0;
for (int hypercube : hypercubes) {
if (hypercube > 0) {
inverseSum += 1.0 / (double) hypercube;
// depends on control dependency: [if], data = [none]
}
}
//Calculate a random value between 0 and sumaInversa
double random = randomGenerator.getRandomValue(0.0, inverseSum);
int hypercube = 0;
double accumulatedSum = 0.0;
while (hypercube < hypercubes.length) {
if (hypercubes[hypercube] > 0) {
accumulatedSum += 1.0 / (double) hypercubes[hypercube];
// depends on control dependency: [if], data = [none]
}
if (accumulatedSum > random) {
return hypercube;
// depends on control dependency: [if], data = [none]
}
hypercube++;
// depends on control dependency: [while], data = [none]
}
return hypercube;
} } |
public class class_name {
public void destroy() {
if (mApplicationDepot != null) {
mLog.info("Destroying ApplicationDepot");
mApplicationDepot.destroy();
}
for (Iterator i = getPlugins().values().iterator(); i.hasNext(); )
((Plugin) i.next()).destroy();
} } | public class class_name {
public void destroy() {
if (mApplicationDepot != null) {
mLog.info("Destroying ApplicationDepot"); // depends on control dependency: [if], data = [none]
mApplicationDepot.destroy(); // depends on control dependency: [if], data = [none]
}
for (Iterator i = getPlugins().values().iterator(); i.hasNext(); )
((Plugin) i.next()).destroy();
} } |
public class class_name {
private void addQueryParams(final Request request) {
if (to != null) {
request.addQueryParam("To", to.toString());
}
if (from != null) {
request.addQueryParam("From", from.toString());
}
if (parentCallSid != null) {
request.addQueryParam("ParentCallSid", parentCallSid);
}
if (status != null) {
request.addQueryParam("Status", status.toString());
}
if (absoluteStartTime != null) {
request.addQueryParam("StartTime", absoluteStartTime.toString(Request.QUERY_STRING_DATE_TIME_FORMAT));
} else if (rangeStartTime != null) {
request.addQueryDateTimeRange("StartTime", rangeStartTime);
}
if (absoluteEndTime != null) {
request.addQueryParam("EndTime", absoluteEndTime.toString(Request.QUERY_STRING_DATE_TIME_FORMAT));
} else if (rangeEndTime != null) {
request.addQueryDateTimeRange("EndTime", rangeEndTime);
}
if (getPageSize() != null) {
request.addQueryParam("PageSize", Integer.toString(getPageSize()));
}
} } | public class class_name {
private void addQueryParams(final Request request) {
if (to != null) {
request.addQueryParam("To", to.toString()); // depends on control dependency: [if], data = [none]
}
if (from != null) {
request.addQueryParam("From", from.toString()); // depends on control dependency: [if], data = [none]
}
if (parentCallSid != null) {
request.addQueryParam("ParentCallSid", parentCallSid); // depends on control dependency: [if], data = [none]
}
if (status != null) {
request.addQueryParam("Status", status.toString()); // depends on control dependency: [if], data = [none]
}
if (absoluteStartTime != null) {
request.addQueryParam("StartTime", absoluteStartTime.toString(Request.QUERY_STRING_DATE_TIME_FORMAT)); // depends on control dependency: [if], data = [none]
} else if (rangeStartTime != null) {
request.addQueryDateTimeRange("StartTime", rangeStartTime); // depends on control dependency: [if], data = [none]
}
if (absoluteEndTime != null) {
request.addQueryParam("EndTime", absoluteEndTime.toString(Request.QUERY_STRING_DATE_TIME_FORMAT)); // depends on control dependency: [if], data = [none]
} else if (rangeEndTime != null) {
request.addQueryDateTimeRange("EndTime", rangeEndTime); // depends on control dependency: [if], data = [none]
}
if (getPageSize() != null) {
request.addQueryParam("PageSize", Integer.toString(getPageSize())); // depends on control dependency: [if], data = [(getPageSize()]
}
} } |
public class class_name {
private boolean writeContent(CmsObject cmsObject, I_CmsReport report, CmsFile file, byte[] content) {
boolean success = true;
// get current lock from file
try {
// try to lock the resource
if (!lockResource(cmsObject, file, report)) {
report.println(
Messages.get().container(Messages.RPT_SOURCESEARCH_LOCKED_FILE_0, cmsObject.getSitePath(file)),
I_CmsReport.FORMAT_ERROR);
success = false;
}
} catch (CmsException e) {
report.println(
Messages.get().container(Messages.RPT_SOURCESEARCH_LOCKED_FILE_0, cmsObject.getSitePath(file)),
I_CmsReport.FORMAT_ERROR);
if (LOG.isErrorEnabled()) {
LOG.error(e.getMessageContainer(), e);
}
success = false;
}
// write the file content
try {
file.setContents(content);
cmsObject.writeFile(file);
} catch (Exception e) {
m_errorUpdate += 1;
report.println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_FAILED_0),
I_CmsReport.FORMAT_ERROR);
if (LOG.isErrorEnabled()) {
LOG.error(e.toString());
}
success = false;
}
// unlock the resource
try {
cmsObject.unlockResource(cmsObject.getSitePath(file));
} catch (CmsException e) {
m_errorUpdate += 1;
report.println(
Messages.get().container(Messages.RPT_SOURCESEARCH_UNLOCK_FILE_0),
I_CmsReport.FORMAT_WARNING);
if (LOG.isErrorEnabled()) {
LOG.error(e.getMessageContainer(), e);
}
success = false;
}
if (success) {
// successfully updated
report.println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
I_CmsReport.FORMAT_OK);
}
return success;
} } | public class class_name {
private boolean writeContent(CmsObject cmsObject, I_CmsReport report, CmsFile file, byte[] content) {
boolean success = true;
// get current lock from file
try {
// try to lock the resource
if (!lockResource(cmsObject, file, report)) {
report.println(
Messages.get().container(Messages.RPT_SOURCESEARCH_LOCKED_FILE_0, cmsObject.getSitePath(file)),
I_CmsReport.FORMAT_ERROR); // depends on control dependency: [if], data = [none]
success = false; // depends on control dependency: [if], data = [none]
}
} catch (CmsException e) {
report.println(
Messages.get().container(Messages.RPT_SOURCESEARCH_LOCKED_FILE_0, cmsObject.getSitePath(file)),
I_CmsReport.FORMAT_ERROR);
if (LOG.isErrorEnabled()) {
LOG.error(e.getMessageContainer(), e); // depends on control dependency: [if], data = [none]
}
success = false;
} // depends on control dependency: [catch], data = [none]
// write the file content
try {
file.setContents(content); // depends on control dependency: [try], data = [none]
cmsObject.writeFile(file); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
m_errorUpdate += 1;
report.println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_FAILED_0),
I_CmsReport.FORMAT_ERROR);
if (LOG.isErrorEnabled()) {
LOG.error(e.toString()); // depends on control dependency: [if], data = [none]
}
success = false;
} // depends on control dependency: [catch], data = [none]
// unlock the resource
try {
cmsObject.unlockResource(cmsObject.getSitePath(file)); // depends on control dependency: [try], data = [none]
} catch (CmsException e) {
m_errorUpdate += 1;
report.println(
Messages.get().container(Messages.RPT_SOURCESEARCH_UNLOCK_FILE_0),
I_CmsReport.FORMAT_WARNING);
if (LOG.isErrorEnabled()) {
LOG.error(e.getMessageContainer(), e); // depends on control dependency: [if], data = [none]
}
success = false;
} // depends on control dependency: [catch], data = [none]
if (success) {
// successfully updated
report.println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
I_CmsReport.FORMAT_OK); // depends on control dependency: [if], data = [none]
}
return success;
} } |
public class class_name {
private static void updateFilterSDASet(double mib, List<SteepDownArea> sdaset, double ixi) {
Iterator<SteepDownArea> iter = sdaset.iterator();
while(iter.hasNext()) {
SteepDownArea sda = iter.next();
if(sda.getMaximum() * ixi <= mib) {
iter.remove();
}
else {
// Update
if(mib > sda.getMib()) {
sda.setMib(mib);
}
}
}
} } | public class class_name {
private static void updateFilterSDASet(double mib, List<SteepDownArea> sdaset, double ixi) {
Iterator<SteepDownArea> iter = sdaset.iterator();
while(iter.hasNext()) {
SteepDownArea sda = iter.next();
if(sda.getMaximum() * ixi <= mib) {
iter.remove(); // depends on control dependency: [if], data = [none]
}
else {
// Update
if(mib > sda.getMib()) {
sda.setMib(mib); // depends on control dependency: [if], data = [(mib]
}
}
}
} } |
public class class_name {
public String generateChecksum(InputStream inStream) {
try {
byte[] buf = new byte[4096];
int numRead = 0;
long totalBytesRead = 0;
while ((numRead = readFromStream(inStream, buf)) != -1) {
digest.update(buf, 0, numRead);
totalBytesRead += numRead;
if (log.isDebugEnabled()) {
if (totalBytesRead % (1000 * 1000 * 1000) == 0) {
log.debug("Total bytes read: {}", totalBytesRead);
}
}
}
return checksumBytesToString(digest.digest());
} finally {
digest.reset();
}
} } | public class class_name {
public String generateChecksum(InputStream inStream) {
try {
byte[] buf = new byte[4096];
int numRead = 0;
long totalBytesRead = 0;
while ((numRead = readFromStream(inStream, buf)) != -1) {
digest.update(buf, 0, numRead); // depends on control dependency: [while], data = [none]
totalBytesRead += numRead; // depends on control dependency: [while], data = [none]
if (log.isDebugEnabled()) {
if (totalBytesRead % (1000 * 1000 * 1000) == 0) {
log.debug("Total bytes read: {}", totalBytesRead); // depends on control dependency: [if], data = [none]
}
}
}
return checksumBytesToString(digest.digest()); // depends on control dependency: [try], data = [none]
} finally {
digest.reset();
}
} } |
public class class_name {
@Override
public void flush() throws IOException {
List<Exception> flushExceptions = new ArrayList<>(delegates.size());
for (Writer delegate : delegates) {
try {
delegate.flush();
} catch (IOException | RuntimeException flushException) {
flushExceptions.add(flushException);
}
}
if (!flushExceptions.isEmpty()) {
throw mergeExceptions("flushing", flushExceptions);
}
} } | public class class_name {
@Override
public void flush() throws IOException {
List<Exception> flushExceptions = new ArrayList<>(delegates.size());
for (Writer delegate : delegates) {
try {
delegate.flush(); // depends on control dependency: [try], data = [none]
} catch (IOException | RuntimeException flushException) {
flushExceptions.add(flushException);
} // depends on control dependency: [catch], data = [none]
}
if (!flushExceptions.isEmpty()) {
throw mergeExceptions("flushing", flushExceptions);
}
} } |
public class class_name {
public double populationVariance() {
checkState(count > 0);
if (isNaN(sumOfSquaresOfDeltas)) {
return NaN;
}
if (count == 1) {
return 0.0;
}
return ensureNonNegative(sumOfSquaresOfDeltas) / count();
} } | public class class_name {
public double populationVariance() {
checkState(count > 0);
if (isNaN(sumOfSquaresOfDeltas)) {
return NaN; // depends on control dependency: [if], data = [none]
}
if (count == 1) {
return 0.0; // depends on control dependency: [if], data = [none]
}
return ensureNonNegative(sumOfSquaresOfDeltas) / count();
} } |
public class class_name {
public static String convertConsulSerivceId(URL url) {
if (url == null) {
return null;
}
return convertServiceId(url.getHost(), url.getPort(), url.getPath());
} } | public class class_name {
public static String convertConsulSerivceId(URL url) {
if (url == null) {
return null; // depends on control dependency: [if], data = [none]
}
return convertServiceId(url.getHost(), url.getPort(), url.getPath());
} } |
public class class_name {
@SuppressWarnings("unchecked")
@Override
public <C> IConverter<C> getConverter(final Class<C> type)
{
if (Temporal.class.isAssignableFrom(type))
{
return (IConverter<C>)converter;
}
else
{
return super.getConverter(type);
}
} } | public class class_name {
@SuppressWarnings("unchecked")
@Override
public <C> IConverter<C> getConverter(final Class<C> type)
{
if (Temporal.class.isAssignableFrom(type))
{
return (IConverter<C>)converter; // depends on control dependency: [if], data = [none]
}
else
{
return super.getConverter(type); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private List<CmsResultItemBean> buildSearchResultList(
List<CmsGallerySearchResult> searchResult,
CmsGallerySearchResult presetResult) {
ArrayList<CmsResultItemBean> list = new ArrayList<CmsResultItemBean>();
if ((searchResult == null) || (searchResult.size() == 0)) {
return list;
}
CmsObject cms = getCmsObject();
for (CmsGallerySearchResult sResult : searchResult) {
try {
CmsResultItemBean bean = buildSingleSearchResultItem(cms, sResult, presetResult);
list.add(bean);
} catch (Exception e) {
logError(e);
}
}
return list;
} } | public class class_name {
private List<CmsResultItemBean> buildSearchResultList(
List<CmsGallerySearchResult> searchResult,
CmsGallerySearchResult presetResult) {
ArrayList<CmsResultItemBean> list = new ArrayList<CmsResultItemBean>();
if ((searchResult == null) || (searchResult.size() == 0)) {
return list; // depends on control dependency: [if], data = [none]
}
CmsObject cms = getCmsObject();
for (CmsGallerySearchResult sResult : searchResult) {
try {
CmsResultItemBean bean = buildSingleSearchResultItem(cms, sResult, presetResult);
list.add(bean); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
logError(e);
} // depends on control dependency: [catch], data = [none]
}
return list;
} } |
public class class_name {
public void allocateMemory(int memorySize) {
this.memorySize = memorySize;
memory = new PairDblInt[memorySize][numLabels];
for (int i = 0; i < memorySize; i++) {
for (int j = 0; j < numLabels; j++) {
memory[i][j] = new PairDblInt();
}
}
} } | public class class_name {
public void allocateMemory(int memorySize) {
this.memorySize = memorySize;
memory = new PairDblInt[memorySize][numLabels];
for (int i = 0; i < memorySize; i++) {
for (int j = 0; j < numLabels; j++) {
memory[i][j] = new PairDblInt(); // depends on control dependency: [for], data = [j]
}
}
} } |
public class class_name {
public synchronized void shutdown() {
this.shutdownManagementWatchdogs();
// deactivate all Watchdogs ....
Iterator iter = registeredWachdogs.values().iterator();
while (iter.hasNext()) {
IWatchdog th = (IWatchdog) iter.next();
th.deactivate();
if (log.isInfoEnabled()) {
log.info(". . . Deactivating Watchdog " + th.getId());
}
}
this.kill();
} } | public class class_name {
public synchronized void shutdown() {
this.shutdownManagementWatchdogs();
// deactivate all Watchdogs ....
Iterator iter = registeredWachdogs.values().iterator();
while (iter.hasNext()) {
IWatchdog th = (IWatchdog) iter.next();
th.deactivate(); // depends on control dependency: [while], data = [none]
if (log.isInfoEnabled()) {
log.info(". . . Deactivating Watchdog " + th.getId()); // depends on control dependency: [if], data = [none]
}
}
this.kill();
} } |
public class class_name {
public void setStepExecutions(java.util.Collection<StepExecution> stepExecutions) {
if (stepExecutions == null) {
this.stepExecutions = null;
return;
}
this.stepExecutions = new com.amazonaws.internal.SdkInternalList<StepExecution>(stepExecutions);
} } | public class class_name {
public void setStepExecutions(java.util.Collection<StepExecution> stepExecutions) {
if (stepExecutions == null) {
this.stepExecutions = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.stepExecutions = new com.amazonaws.internal.SdkInternalList<StepExecution>(stepExecutions);
} } |
public class class_name {
public String[] tags(TagSet tagSet)
{
assert tagArray != null;
String[] tags = new String[tagArray.length];
for (int i = 0; i < tags.length; i++)
{
tags[i] = tagSet.stringOf(tagArray[i]);
}
return tags;
} } | public class class_name {
public String[] tags(TagSet tagSet)
{
assert tagArray != null;
String[] tags = new String[tagArray.length];
for (int i = 0; i < tags.length; i++)
{
tags[i] = tagSet.stringOf(tagArray[i]); // depends on control dependency: [for], data = [i]
}
return tags;
} } |
public class class_name {
protected Node<V> cleanNode(int bitNumber)
{
Node<V> node=cleanNodePath(bitNumber, config.layout, root);
if(node!=null)
{
Node<V> pre=node.getPre();
Node<V> next=node.getNext();
if(pre!=null)
{
pre.setNext(next);
node.setPre(null);
}else
{//设置头节点
firstAdd=next;
}
if(next!=null)
{
next.setPre(pre);
node.setNext(null);
}else
{//设置尾节点
lastAdd=pre;
}
size--;
}
return node;
} } | public class class_name {
protected Node<V> cleanNode(int bitNumber)
{
Node<V> node=cleanNodePath(bitNumber, config.layout, root);
if(node!=null)
{
Node<V> pre=node.getPre();
Node<V> next=node.getNext();
if(pre!=null)
{
pre.setNext(next);
// depends on control dependency: [if], data = [none]
node.setPre(null);
// depends on control dependency: [if], data = [null)]
}else
{//设置头节点
firstAdd=next;
// depends on control dependency: [if], data = [none]
}
if(next!=null)
{
next.setPre(pre);
// depends on control dependency: [if], data = [none]
node.setNext(null);
// depends on control dependency: [if], data = [null)]
}else
{//设置尾节点
lastAdd=pre;
// depends on control dependency: [if], data = [none]
}
size--;
// depends on control dependency: [if], data = [none]
}
return node;
} } |
public class class_name {
public WikiFormat addStyle(WikiStyle style)
{
if (fStyles.contains(style)) {
return this;
}
WikiFormat clone = getClone();
clone.fStyles.add(style);
return clone;
} } | public class class_name {
public WikiFormat addStyle(WikiStyle style)
{
if (fStyles.contains(style)) {
return this; // depends on control dependency: [if], data = [none]
}
WikiFormat clone = getClone();
clone.fStyles.add(style);
return clone;
} } |
public class class_name {
public void marshall(DeleteHsmRequest deleteHsmRequest, ProtocolMarshaller protocolMarshaller) {
if (deleteHsmRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(deleteHsmRequest.getClusterId(), CLUSTERID_BINDING);
protocolMarshaller.marshall(deleteHsmRequest.getHsmId(), HSMID_BINDING);
protocolMarshaller.marshall(deleteHsmRequest.getEniId(), ENIID_BINDING);
protocolMarshaller.marshall(deleteHsmRequest.getEniIp(), ENIIP_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(DeleteHsmRequest deleteHsmRequest, ProtocolMarshaller protocolMarshaller) {
if (deleteHsmRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(deleteHsmRequest.getClusterId(), CLUSTERID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(deleteHsmRequest.getHsmId(), HSMID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(deleteHsmRequest.getEniId(), ENIID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(deleteHsmRequest.getEniIp(), ENIIP_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 IPlatformAdapter getInstance() {
if (svInstance != null) {
return svInstance;
}
synchronized (PlatformAdapterAccessor.class) {
if (svInstance != null) {
// need to check again in case one thread waited on sync block while
// another
// initialized the instance
return svInstance;
}
String adapterClassName = null;
try {
adapterClassName = AccessController.doPrivileged(new PrivilegedExceptionAction<String>()
{
@Override
public String run() throws Exception
{
return System.getProperty(ADAPTER_NAME_PROP);
}
});
if (adapterClassName != null) {
// The loaded class must be an instanceof IPlatformAdapter - if not,
// the following
// line will throw a ClassCastException indicating that the specified
// value of the
// adapterName property was not a class that implemented
// IPlatformAdapter.
// This should be a very rare occurrence.
Class<? extends IPlatformAdapter> clazz = (Class<? extends IPlatformAdapter>) Class.forName(adapterClassName);
svInstance = clazz.newInstance();
} else {
// Expected on Sun/Hybrid/Java 6 VMs
svInstance = new DefaultPlatformAdapter();
}
} catch (Throwable t) {
// this means we are in a Harmony Java 7 VM, but are unable to
// initialize
// the Harmony platform adapter - this is a fatal error to most WAS
// processes - must log FFDC and error message, and throw an exception
// TODO: NLS-ize
Tr.error(tc, "<Need new error message> - Failed to initialize {0}", new Object[] { adapterClassName });
// Alex Ffdc.log(t, PlatformAdapterAccessor.class, CLASSNAME, "46");
// throw new
// IllegalStateException("Unable to initialize VM PlatformAdapter: " +
// adapterClassName, t);
// in this case, we need to use the default adapter -- but expect
// erroneous behavior...
svInstance = new DefaultPlatformAdapter();
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "chosen adapter is: " + svInstance.getClass().getName());
}
return svInstance;
} } | public class class_name {
public static IPlatformAdapter getInstance() {
if (svInstance != null) {
return svInstance; // depends on control dependency: [if], data = [none]
}
synchronized (PlatformAdapterAccessor.class) {
if (svInstance != null) {
// need to check again in case one thread waited on sync block while
// another
// initialized the instance
return svInstance; // depends on control dependency: [if], data = [none]
}
String adapterClassName = null;
try {
adapterClassName = AccessController.doPrivileged(new PrivilegedExceptionAction<String>()
{
@Override
public String run() throws Exception
{
return System.getProperty(ADAPTER_NAME_PROP);
}
}); // depends on control dependency: [try], data = [none]
if (adapterClassName != null) {
// The loaded class must be an instanceof IPlatformAdapter - if not,
// the following
// line will throw a ClassCastException indicating that the specified
// value of the
// adapterName property was not a class that implemented
// IPlatformAdapter.
// This should be a very rare occurrence.
Class<? extends IPlatformAdapter> clazz = (Class<? extends IPlatformAdapter>) Class.forName(adapterClassName);
svInstance = clazz.newInstance();
} else {
// Expected on Sun/Hybrid/Java 6 VMs
svInstance = new DefaultPlatformAdapter(); // depends on control dependency: [if], data = [none]
}
} catch (Throwable t) {
// this means we are in a Harmony Java 7 VM, but are unable to
// initialize
// the Harmony platform adapter - this is a fatal error to most WAS
// processes - must log FFDC and error message, and throw an exception
// TODO: NLS-ize
Tr.error(tc, "<Need new error message> - Failed to initialize {0}", new Object[] { adapterClassName });
// Alex Ffdc.log(t, PlatformAdapterAccessor.class, CLASSNAME, "46");
// throw new
// IllegalStateException("Unable to initialize VM PlatformAdapter: " +
// adapterClassName, t);
// in this case, we need to use the default adapter -- but expect
// erroneous behavior...
svInstance = new DefaultPlatformAdapter();
} // depends on control dependency: [catch], data = [none]
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "chosen adapter is: " + svInstance.getClass().getName()); // depends on control dependency: [if], data = [none]
}
return svInstance;
} } |
public class class_name {
@NonNull
protected String buildSubject(@NonNull Context context) {
final String subject = mailConfig.subject();
if (subject != null) {
return subject;
}
return context.getPackageName() + " Crash Report";
} } | public class class_name {
@NonNull
protected String buildSubject(@NonNull Context context) {
final String subject = mailConfig.subject();
if (subject != null) {
return subject; // depends on control dependency: [if], data = [none]
}
return context.getPackageName() + " Crash Report";
} } |
public class class_name {
public void setClipboardEnabled(boolean enabled, String disabledReason) {
if (m_clipboardButton != null) {
if (enabled) {
m_clipboardButton.enable();
} else {
m_clipboardButton.disable(disabledReason);
}
}
} } | public class class_name {
public void setClipboardEnabled(boolean enabled, String disabledReason) {
if (m_clipboardButton != null) {
if (enabled) {
m_clipboardButton.enable(); // depends on control dependency: [if], data = [none]
} else {
m_clipboardButton.disable(disabledReason); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
protected CmsObject getCmsObject(CmsCmisCallContext context) {
try {
if (context.getUsername() == null) {
// user name can be null
CmsObject cms = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest());
cms.getRequestContext().setCurrentProject(m_adminCms.getRequestContext().getCurrentProject());
return cms;
} else {
CmsObject cms = OpenCms.initCmsObject(m_adminCms);
CmsProject projectBeforeLogin = cms.getRequestContext().getCurrentProject();
cms.loginUser(context.getUsername(), context.getPassword());
cms.getRequestContext().setCurrentProject(projectBeforeLogin);
return cms;
}
} catch (CmsException e) {
throw new CmisPermissionDeniedException(e.getLocalizedMessage(), e);
}
} } | public class class_name {
protected CmsObject getCmsObject(CmsCmisCallContext context) {
try {
if (context.getUsername() == null) {
// user name can be null
CmsObject cms = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest());
cms.getRequestContext().setCurrentProject(m_adminCms.getRequestContext().getCurrentProject());
// depends on control dependency: [if], data = [none]
return cms;
// depends on control dependency: [if], data = [none]
} else {
CmsObject cms = OpenCms.initCmsObject(m_adminCms);
CmsProject projectBeforeLogin = cms.getRequestContext().getCurrentProject();
cms.loginUser(context.getUsername(), context.getPassword());
// depends on control dependency: [if], data = [(context.getUsername()]
cms.getRequestContext().setCurrentProject(projectBeforeLogin);
// depends on control dependency: [if], data = [none]
return cms;
// depends on control dependency: [if], data = [none]
}
} catch (CmsException e) {
throw new CmisPermissionDeniedException(e.getLocalizedMessage(), e);
}
// depends on control dependency: [catch], data = [none]
} } |
public class class_name {
protected <T> ResponseEntity<T> sendRequest(
String pathFragment,
HttpMethod method,
List<? extends NameValuePair> getParams,
Object postData,
Class<T> returnType) {
HttpHeaders headers = new HttpHeaders();
headers.add(XAPI_VERSION_HEADER, XAPI_VERSION_VALUE);
// make multipart data is handled correctly.
if (postData instanceof MultiValueMap) {
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
}
URI fullURI = buildRequestURI(pathFragment, getParams);
HttpEntity<?> entity = new HttpEntity<>(postData, headers);
ResponseEntity<T> response = restTemplate.exchange(fullURI, method, entity, returnType);
return response;
} } | public class class_name {
protected <T> ResponseEntity<T> sendRequest(
String pathFragment,
HttpMethod method,
List<? extends NameValuePair> getParams,
Object postData,
Class<T> returnType) {
HttpHeaders headers = new HttpHeaders();
headers.add(XAPI_VERSION_HEADER, XAPI_VERSION_VALUE);
// make multipart data is handled correctly.
if (postData instanceof MultiValueMap) {
headers.setContentType(MediaType.MULTIPART_FORM_DATA); // depends on control dependency: [if], data = [none]
}
URI fullURI = buildRequestURI(pathFragment, getParams);
HttpEntity<?> entity = new HttpEntity<>(postData, headers);
ResponseEntity<T> response = restTemplate.exchange(fullURI, method, entity, returnType);
return response;
} } |
public class class_name {
public static OperationInvoker apply(OperationInvoker invoker, long timeToLive) {
if (timeToLive > 0) {
return new CachingOperationInvoker(invoker, timeToLive);
}
return invoker;
} } | public class class_name {
public static OperationInvoker apply(OperationInvoker invoker, long timeToLive) {
if (timeToLive > 0) {
return new CachingOperationInvoker(invoker, timeToLive); // depends on control dependency: [if], data = [none]
}
return invoker;
} } |
public class class_name {
public Rational pow(int exponent) {
if (exponent == 0) {
return new Rational(1, 1);
}
BigInteger num = a.pow(Math.abs(exponent));
BigInteger deno = b.pow(Math.abs(exponent));
if (exponent > 0) {
return (new Rational(num, deno));
} else {
return (new Rational(deno, num));
}
} } | public class class_name {
public Rational pow(int exponent) {
if (exponent == 0) {
return new Rational(1, 1); // depends on control dependency: [if], data = [none]
}
BigInteger num = a.pow(Math.abs(exponent));
BigInteger deno = b.pow(Math.abs(exponent));
if (exponent > 0) {
return (new Rational(num, deno)); // depends on control dependency: [if], data = [none]
} else {
return (new Rational(deno, num)); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
static String unescape(final String text, final XmlEscapeSymbols symbols) {
if (text == null) {
return null;
}
StringBuilder strBuilder = null;
final int offset = 0;
final int max = text.length();
int readOffset = offset;
int referenceOffset = offset;
for (int i = offset; i < max; i++) {
final char c = text.charAt(i);
/*
* Check the need for an unescape operation at this point
*/
if (c != REFERENCE_PREFIX || (i + 1) >= max) {
continue;
}
int codepoint = 0;
if (c == REFERENCE_PREFIX) {
final char c1 = text.charAt(i + 1);
if (c1 == '\u0020' || // SPACE
c1 == '\n' || // LF
c1 == '\u0009' || // TAB
c1 == '\u000C' || // FF
c1 == '\u003C' || // LES-THAN SIGN
c1 == '\u0026') { // AMPERSAND
// Not a character references. No characters are consumed, and nothing is returned.
continue;
} else if (c1 == REFERENCE_NUMERIC_PREFIX2) {
if (i + 2 >= max) {
// No reference possible
continue;
}
final char c2 = text.charAt(i + 2);
if (c2 == REFERENCE_HEXA_PREFIX3 && (i + 3) < max) {
// This is a hexadecimal reference
int f = i + 3;
while (f < max) {
final char cf = text.charAt(f);
if (!((cf >= '0' && cf <= '9') || (cf >= 'A' && cf <= 'F') || (cf >= 'a' && cf <= 'f'))) {
break;
}
f++;
}
if ((f - (i + 3)) <= 0) {
// We weren't able to consume any hexa chars
continue;
}
if ((f >= max) || text.charAt(f) != REFERENCE_SUFFIX) {
continue;
}
f++; // Count the REFERENCE_SUFFIX (semi-colon)
codepoint = parseIntFromReference(text, i + 3, f - 1, 16);
referenceOffset = f - 1;
// Don't continue here, just let the unescape code below do its job
} else if (c2 >= '0' && c2 <= '9') {
// This is a decimal reference
int f = i + 2;
while (f < max) {
final char cf = text.charAt(f);
if (!(cf >= '0' && cf <= '9')) {
break;
}
f++;
}
if ((f - (i + 2)) <= 0) {
// We weren't able to consume any decimal chars
continue;
}
if ((f >= max) || text.charAt(f) != REFERENCE_SUFFIX) {
continue;
}
f++; // Count the REFERENCE_SUFFIX (semi-colon)
codepoint = parseIntFromReference(text, i + 2, f - 1, 10);
referenceOffset = f - 1;
// Don't continue here, just let the unescape code below do its job
} else {
// This is not a valid reference, just discard
continue;
}
} else {
// This is a named reference, must be comprised only of ALPHABETIC chars
int f = i + 1;
while (f < max) {
final char cf = text.charAt(f);
if (!((cf >= 'a' && cf <= 'z') || (cf >= 'A' && cf <= 'Z') || (cf >= '0' && cf <= '9'))) {
break;
}
f++;
}
if ((f - (i + 1)) <= 0) {
// We weren't able to consume any alphanumeric
continue;
}
if ((f < max) && text.charAt(f) == REFERENCE_SUFFIX) {
f++;
}
final int ncrPosition = XmlEscapeSymbols.binarySearch(symbols.SORTED_CERS, text, i, f);
if (ncrPosition >= 0) {
codepoint = symbols.SORTED_CODEPOINTS_BY_CER[ncrPosition];
} else {
// Not found! Just ignore our efforts to find a match.
continue;
}
referenceOffset = f - 1;
}
}
/*
* At this point we know for sure we will need some kind of unescape, so we
* can increase the offset and initialize the string builder if needed, along with
* copying to it all the contents pending up to this point.
*/
if (strBuilder == null) {
strBuilder = new StringBuilder(max + 5);
}
if (i - readOffset > 0) {
strBuilder.append(text, readOffset, i);
}
i = referenceOffset;
readOffset = i + 1;
/*
* --------------------------
*
* Perform the real unescape
*
* --------------------------
*/
if (codepoint > '\uFFFF') {
strBuilder.append(Character.toChars(codepoint));
} else {
strBuilder.append((char)codepoint);
}
}
/*
* -----------------------------------------------------------------------------------------------
* Final cleaning: return the original String object if no unescape was actually needed. Otherwise
* append the remaining escaped text to the string builder and return.
* -----------------------------------------------------------------------------------------------
*/
if (strBuilder == null) {
return text;
}
if (max - readOffset > 0) {
strBuilder.append(text, readOffset, max);
}
return strBuilder.toString();
} } | public class class_name {
static String unescape(final String text, final XmlEscapeSymbols symbols) {
if (text == null) {
return null; // depends on control dependency: [if], data = [none]
}
StringBuilder strBuilder = null;
final int offset = 0;
final int max = text.length();
int readOffset = offset;
int referenceOffset = offset;
for (int i = offset; i < max; i++) {
final char c = text.charAt(i);
/*
* Check the need for an unescape operation at this point
*/
if (c != REFERENCE_PREFIX || (i + 1) >= max) {
continue;
}
int codepoint = 0;
if (c == REFERENCE_PREFIX) {
final char c1 = text.charAt(i + 1);
if (c1 == '\u0020' || // SPACE
c1 == '\n' || // LF
c1 == '\u0009' || // TAB
c1 == '\u000C' || // FF
c1 == '\u003C' || // LES-THAN SIGN
c1 == '\u0026') { // AMPERSAND
// Not a character references. No characters are consumed, and nothing is returned.
continue;
} else if (c1 == REFERENCE_NUMERIC_PREFIX2) {
if (i + 2 >= max) {
// No reference possible
continue;
}
final char c2 = text.charAt(i + 2);
if (c2 == REFERENCE_HEXA_PREFIX3 && (i + 3) < max) {
// This is a hexadecimal reference
int f = i + 3;
while (f < max) {
final char cf = text.charAt(f);
if (!((cf >= '0' && cf <= '9') || (cf >= 'A' && cf <= 'F') || (cf >= 'a' && cf <= 'f'))) {
break;
}
f++; // depends on control dependency: [while], data = [none]
}
if ((f - (i + 3)) <= 0) {
// We weren't able to consume any hexa chars
continue;
}
if ((f >= max) || text.charAt(f) != REFERENCE_SUFFIX) {
continue;
}
f++; // Count the REFERENCE_SUFFIX (semi-colon) // depends on control dependency: [if], data = [none]
codepoint = parseIntFromReference(text, i + 3, f - 1, 16); // depends on control dependency: [if], data = [none]
referenceOffset = f - 1; // depends on control dependency: [if], data = [none]
// Don't continue here, just let the unescape code below do its job
} else if (c2 >= '0' && c2 <= '9') {
// This is a decimal reference
int f = i + 2;
while (f < max) {
final char cf = text.charAt(f);
if (!(cf >= '0' && cf <= '9')) {
break;
}
f++; // depends on control dependency: [while], data = [none]
}
if ((f - (i + 2)) <= 0) {
// We weren't able to consume any decimal chars
continue;
}
if ((f >= max) || text.charAt(f) != REFERENCE_SUFFIX) {
continue;
}
f++; // Count the REFERENCE_SUFFIX (semi-colon) // depends on control dependency: [if], data = [none]
codepoint = parseIntFromReference(text, i + 2, f - 1, 10); // depends on control dependency: [if], data = [none]
referenceOffset = f - 1; // depends on control dependency: [if], data = [none]
// Don't continue here, just let the unescape code below do its job
} else {
// This is not a valid reference, just discard
continue;
}
} else {
// This is a named reference, must be comprised only of ALPHABETIC chars
int f = i + 1;
while (f < max) {
final char cf = text.charAt(f);
if (!((cf >= 'a' && cf <= 'z') || (cf >= 'A' && cf <= 'Z') || (cf >= '0' && cf <= '9'))) {
break;
}
f++; // depends on control dependency: [while], data = [none]
}
if ((f - (i + 1)) <= 0) {
// We weren't able to consume any alphanumeric
continue;
}
if ((f < max) && text.charAt(f) == REFERENCE_SUFFIX) {
f++; // depends on control dependency: [if], data = [none]
}
final int ncrPosition = XmlEscapeSymbols.binarySearch(symbols.SORTED_CERS, text, i, f);
if (ncrPosition >= 0) {
codepoint = symbols.SORTED_CODEPOINTS_BY_CER[ncrPosition]; // depends on control dependency: [if], data = [none]
} else {
// Not found! Just ignore our efforts to find a match.
continue;
}
referenceOffset = f - 1; // depends on control dependency: [if], data = [none]
}
}
/*
* At this point we know for sure we will need some kind of unescape, so we
* can increase the offset and initialize the string builder if needed, along with
* copying to it all the contents pending up to this point.
*/
if (strBuilder == null) {
strBuilder = new StringBuilder(max + 5); // depends on control dependency: [if], data = [none]
}
if (i - readOffset > 0) {
strBuilder.append(text, readOffset, i); // depends on control dependency: [if], data = [none]
}
i = referenceOffset; // depends on control dependency: [for], data = [i]
readOffset = i + 1; // depends on control dependency: [for], data = [i]
/*
* --------------------------
*
* Perform the real unescape
*
* --------------------------
*/
if (codepoint > '\uFFFF') {
strBuilder.append(Character.toChars(codepoint)); // depends on control dependency: [if], data = [(codepoint]
} else {
strBuilder.append((char)codepoint); // depends on control dependency: [if], data = [none]
}
}
/*
* -----------------------------------------------------------------------------------------------
* Final cleaning: return the original String object if no unescape was actually needed. Otherwise
* append the remaining escaped text to the string builder and return.
* -----------------------------------------------------------------------------------------------
*/
if (strBuilder == null) {
return text; // depends on control dependency: [if], data = [none]
}
if (max - readOffset > 0) {
strBuilder.append(text, readOffset, max); // depends on control dependency: [if], data = [none]
}
return strBuilder.toString();
} } |
public class class_name {
public static void deleteFeatureStyle(GeoPackageCore geoPackage,
String table) {
FeatureCoreStyleExtension featureStyleExtension = getFeatureStyleExtension(geoPackage);
if (featureStyleExtension.has(table)) {
featureStyleExtension.deleteRelationships(table);
}
} } | public class class_name {
public static void deleteFeatureStyle(GeoPackageCore geoPackage,
String table) {
FeatureCoreStyleExtension featureStyleExtension = getFeatureStyleExtension(geoPackage);
if (featureStyleExtension.has(table)) {
featureStyleExtension.deleteRelationships(table); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public boolean isNodePresent(String host, int port, String transport, String version) {
if(getNode(host, port, transport, version) != null) {
return true;
}
return false;
} } | public class class_name {
public boolean isNodePresent(String host, int port, String transport, String version) {
if(getNode(host, port, transport, version) != null) {
return true; // depends on control dependency: [if], data = [none]
}
return false;
} } |
public class class_name {
protected void removeBy(BaseCell data) {
VirtualLayoutManager layoutManager = getLayoutManager();
if (data != null && mGroupBasicAdapter != null && layoutManager != null) {
int removePosition = mGroupBasicAdapter.getPositionByItem(data);
if (removePosition >= 0) {
int cardIdx = mGroupBasicAdapter.findCardIdxFor(removePosition);
Card card = mGroupBasicAdapter.getCardRange(cardIdx).second;
card.removeCellSilently(data);
List<LayoutHelper> layoutHelpers = layoutManager.getLayoutHelpers();
LayoutHelper emptyLayoutHelper = null;
if (layoutHelpers != null && cardIdx >= 0 && cardIdx < layoutHelpers.size()) {
for (int i = 0, size = layoutHelpers.size(); i < size; i++) {
LayoutHelper layoutHelper = layoutHelpers.get(i);
int start = layoutHelper.getRange().getLower();
int end = layoutHelper.getRange().getUpper();
if (end < removePosition) {
//do nothing
} else if (start <= removePosition && removePosition <= end) {
int itemCount = layoutHelper.getItemCount() - 1;
if (itemCount > 0) {
layoutHelper.setItemCount(itemCount);
layoutHelper.setRange(start, end - 1);
} else {
emptyLayoutHelper = layoutHelper;
}
} else if (removePosition < start) {
layoutHelper.setRange(start - 1, end - 1);
}
}
if (emptyLayoutHelper != null) {
final List<LayoutHelper> newLayoutHelpers = new LinkedList<>(layoutHelpers);
newLayoutHelpers.remove(emptyLayoutHelper);
layoutManager.setLayoutHelpers(newLayoutHelpers);
}
mGroupBasicAdapter.removeComponent(data);
}
}
}
} } | public class class_name {
protected void removeBy(BaseCell data) {
VirtualLayoutManager layoutManager = getLayoutManager();
if (data != null && mGroupBasicAdapter != null && layoutManager != null) {
int removePosition = mGroupBasicAdapter.getPositionByItem(data);
if (removePosition >= 0) {
int cardIdx = mGroupBasicAdapter.findCardIdxFor(removePosition);
Card card = mGroupBasicAdapter.getCardRange(cardIdx).second;
card.removeCellSilently(data); // depends on control dependency: [if], data = [none]
List<LayoutHelper> layoutHelpers = layoutManager.getLayoutHelpers();
LayoutHelper emptyLayoutHelper = null;
if (layoutHelpers != null && cardIdx >= 0 && cardIdx < layoutHelpers.size()) {
for (int i = 0, size = layoutHelpers.size(); i < size; i++) {
LayoutHelper layoutHelper = layoutHelpers.get(i);
int start = layoutHelper.getRange().getLower();
int end = layoutHelper.getRange().getUpper();
if (end < removePosition) {
//do nothing
} else if (start <= removePosition && removePosition <= end) {
int itemCount = layoutHelper.getItemCount() - 1;
if (itemCount > 0) {
layoutHelper.setItemCount(itemCount); // depends on control dependency: [if], data = [(itemCount]
layoutHelper.setRange(start, end - 1); // depends on control dependency: [if], data = [none]
} else {
emptyLayoutHelper = layoutHelper; // depends on control dependency: [if], data = [none]
}
} else if (removePosition < start) {
layoutHelper.setRange(start - 1, end - 1); // depends on control dependency: [if], data = [none]
}
}
if (emptyLayoutHelper != null) {
final List<LayoutHelper> newLayoutHelpers = new LinkedList<>(layoutHelpers);
newLayoutHelpers.remove(emptyLayoutHelper); // depends on control dependency: [if], data = [(emptyLayoutHelper]
layoutManager.setLayoutHelpers(newLayoutHelpers); // depends on control dependency: [if], data = [none]
}
mGroupBasicAdapter.removeComponent(data); // depends on control dependency: [if], data = [none]
}
}
}
} } |
public class class_name {
public SendMessageResponse sendMessage(SendMessageRequest request) {
checkNotNull(request, "object request should not be null.");
assertStringNotNullOrEmpty(request.getTemplateId(),
"string templateId of request should not be null or empty.");
assertListNotNullOrEmpty(request.getReceiver(), "list receiver of request should not be null or empty.");
// allow params is empty
// assertStringNotNullOrEmpty(request.getContentVar(), "contentVar should not be null or empty.");
// validate the receiver
for (String receiver : request.getReceiver()) {
assertStringNotNullOrEmpty(receiver, "receiver should not be null or empty.");
}
InternalRequest internalRequest = this.createRequest("message", request, HttpMethodName.POST);
// fill in the request payload
internalRequest = fillRequestPayload(internalRequest, JsonUtils.toJsonString(request));
return this.invokeHttpClient(internalRequest, SendMessageResponse.class);
} } | public class class_name {
public SendMessageResponse sendMessage(SendMessageRequest request) {
checkNotNull(request, "object request should not be null.");
assertStringNotNullOrEmpty(request.getTemplateId(),
"string templateId of request should not be null or empty.");
assertListNotNullOrEmpty(request.getReceiver(), "list receiver of request should not be null or empty.");
// allow params is empty
// assertStringNotNullOrEmpty(request.getContentVar(), "contentVar should not be null or empty.");
// validate the receiver
for (String receiver : request.getReceiver()) {
assertStringNotNullOrEmpty(receiver, "receiver should not be null or empty."); // depends on control dependency: [for], data = [receiver]
}
InternalRequest internalRequest = this.createRequest("message", request, HttpMethodName.POST);
// fill in the request payload
internalRequest = fillRequestPayload(internalRequest, JsonUtils.toJsonString(request));
return this.invokeHttpClient(internalRequest, SendMessageResponse.class);
} } |
public class class_name {
public static boolean isPrimitive(String type) {
boolean isPrimitive = false;
if ( "byte".equals( type ) || "char".equals( type ) || "double".equals( type ) || "float".equals( type ) || "int".equals( type ) || "long".equals( type ) || "short".equals( type ) || "boolean".equals( type ) || "void".equals( type ) ) {
isPrimitive = true;
}
return isPrimitive;
} } | public class class_name {
public static boolean isPrimitive(String type) {
boolean isPrimitive = false;
if ( "byte".equals( type ) || "char".equals( type ) || "double".equals( type ) || "float".equals( type ) || "int".equals( type ) || "long".equals( type ) || "short".equals( type ) || "boolean".equals( type ) || "void".equals( type ) ) {
isPrimitive = true; // depends on control dependency: [if], data = [none]
}
return isPrimitive;
} } |
public class class_name {
public Object recv(Integer taskId, int flags) {
try {
DisruptorQueue recvQueue = deserializeQueues.get(taskId);
if ((flags & 0x01) == 0x01) {
return recvQueue.poll();
// non-blocking
} else {
return recvQueue.take();
}
} catch (Exception e) {
LOG.warn("Unknown exception ", e);
return null;
}
} } | public class class_name {
public Object recv(Integer taskId, int flags) {
try {
DisruptorQueue recvQueue = deserializeQueues.get(taskId);
if ((flags & 0x01) == 0x01) {
return recvQueue.poll(); // depends on control dependency: [if], data = [none]
// non-blocking
} else {
return recvQueue.take(); // depends on control dependency: [if], data = [none]
}
} catch (Exception e) {
LOG.warn("Unknown exception ", e);
return null;
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void populateGroupsLegendByValidation(final RolloutGroupsValidation validation,
final List<RolloutGroupCreate> groups) {
loadingLabel.setVisible(false);
if (validation == null) {
return;
}
final List<Long> targetsPerGroup = validation.getTargetsPerGroup();
final long unassigned = validation.getTotalTargets() - validation.getTargetsInGroups();
final int labelsToUpdate = (unassigned > 0) ? (getGroupsWithoutToBeContinuedLabel(groups.size()) - 1)
: groupsLegend.getComponentCount();
for (int i = 0; i < getGroupsWithoutToBeContinuedLabel(groups.size()); i++) {
final Component component = groupsLegend.getComponent(i);
final Label label = (Label) component;
if (targetsPerGroup.size() > i && groups.size() > i && labelsToUpdate > i) {
final Long targetCount = targetsPerGroup.get(i);
final String groupName = groups.get(i).build().getName();
label.setValue(getTargetsInGroupMessage(targetCount, groupName));
label.setVisible(true);
} else {
label.setValue("");
label.setVisible(false);
}
}
showOrHideToBeContinueLabel(groups);
if (unassigned > 0) {
unassignedTargetsLabel.setValue(getTargetsInGroupMessage(unassigned, "Unassigned"));
unassignedTargetsLabel.setVisible(true);
} else {
unassignedTargetsLabel.setValue("");
unassignedTargetsLabel.setVisible(false);
}
} } | public class class_name {
public void populateGroupsLegendByValidation(final RolloutGroupsValidation validation,
final List<RolloutGroupCreate> groups) {
loadingLabel.setVisible(false);
if (validation == null) {
return; // depends on control dependency: [if], data = [none]
}
final List<Long> targetsPerGroup = validation.getTargetsPerGroup();
final long unassigned = validation.getTotalTargets() - validation.getTargetsInGroups();
final int labelsToUpdate = (unassigned > 0) ? (getGroupsWithoutToBeContinuedLabel(groups.size()) - 1)
: groupsLegend.getComponentCount();
for (int i = 0; i < getGroupsWithoutToBeContinuedLabel(groups.size()); i++) {
final Component component = groupsLegend.getComponent(i);
final Label label = (Label) component;
if (targetsPerGroup.size() > i && groups.size() > i && labelsToUpdate > i) {
final Long targetCount = targetsPerGroup.get(i);
final String groupName = groups.get(i).build().getName();
label.setValue(getTargetsInGroupMessage(targetCount, groupName)); // depends on control dependency: [if], data = [none]
label.setVisible(true); // depends on control dependency: [if], data = [none]
} else {
label.setValue(""); // depends on control dependency: [if], data = [none]
label.setVisible(false); // depends on control dependency: [if], data = [none]
}
}
showOrHideToBeContinueLabel(groups);
if (unassigned > 0) {
unassignedTargetsLabel.setValue(getTargetsInGroupMessage(unassigned, "Unassigned")); // depends on control dependency: [if], data = [(unassigned]
unassignedTargetsLabel.setVisible(true); // depends on control dependency: [if], data = [none]
} else {
unassignedTargetsLabel.setValue(""); // depends on control dependency: [if], data = [none]
unassignedTargetsLabel.setVisible(false); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static void addValueHashCodeCall(CodeBuilder b,
TypeDesc valueType,
boolean testForNull,
boolean mixIn)
{
LocalVariable value = null;
if (mixIn) {
value = b.createLocalVariable(null, valueType);
b.storeLocal(value);
// Multiply current hashcode by 31 before adding more to it.
b.loadConstant(31);
b.math(Opcode.IMUL);
b.loadLocal(value);
}
switch (valueType.getTypeCode()) {
case TypeDesc.FLOAT_CODE:
b.invokeStatic(TypeDesc.FLOAT.toObjectType(), "floatToIntBits",
TypeDesc.INT, new TypeDesc[]{TypeDesc.FLOAT});
// Fall through
case TypeDesc.INT_CODE:
case TypeDesc.CHAR_CODE:
case TypeDesc.SHORT_CODE:
case TypeDesc.BYTE_CODE:
case TypeDesc.BOOLEAN_CODE:
if (mixIn) {
b.math(Opcode.IADD);
}
break;
case TypeDesc.DOUBLE_CODE:
b.invokeStatic(TypeDesc.DOUBLE.toObjectType(), "doubleToLongBits",
TypeDesc.LONG, new TypeDesc[]{TypeDesc.DOUBLE});
// Fall through
case TypeDesc.LONG_CODE:
b.dup2();
b.loadConstant(32);
b.math(Opcode.LUSHR);
b.math(Opcode.LXOR);
b.convert(TypeDesc.LONG, TypeDesc.INT);
if (mixIn) {
b.math(Opcode.IADD);
}
break;
case TypeDesc.OBJECT_CODE:
default:
if (testForNull) {
if (value == null) {
value = b.createLocalVariable(null, valueType);
b.storeLocal(value);
b.loadLocal(value);
}
}
if (mixIn) {
Label isNull = b.createLabel();
if (testForNull) {
b.ifNullBranch(isNull, true);
b.loadLocal(value);
}
addValueHashCodeCallTo(b, valueType);
b.math(Opcode.IADD);
if (testForNull) {
isNull.setLocation();
}
} else {
Label cont = b.createLabel();
if (testForNull) {
Label notNull = b.createLabel();
b.ifNullBranch(notNull, false);
b.loadConstant(0);
b.branch(cont);
notNull.setLocation();
b.loadLocal(value);
}
addValueHashCodeCallTo(b, valueType);
if (testForNull) {
cont.setLocation();
}
}
break;
}
} } | public class class_name {
public static void addValueHashCodeCall(CodeBuilder b,
TypeDesc valueType,
boolean testForNull,
boolean mixIn)
{
LocalVariable value = null;
if (mixIn) {
value = b.createLocalVariable(null, valueType);
// depends on control dependency: [if], data = [none]
b.storeLocal(value);
// depends on control dependency: [if], data = [none]
// Multiply current hashcode by 31 before adding more to it.
b.loadConstant(31);
// depends on control dependency: [if], data = [none]
b.math(Opcode.IMUL);
// depends on control dependency: [if], data = [none]
b.loadLocal(value);
// depends on control dependency: [if], data = [none]
}
switch (valueType.getTypeCode()) {
case TypeDesc.FLOAT_CODE:
b.invokeStatic(TypeDesc.FLOAT.toObjectType(), "floatToIntBits",
TypeDesc.INT, new TypeDesc[]{TypeDesc.FLOAT});
// Fall through
case TypeDesc.INT_CODE:
case TypeDesc.CHAR_CODE:
case TypeDesc.SHORT_CODE:
case TypeDesc.BYTE_CODE:
case TypeDesc.BOOLEAN_CODE:
if (mixIn) {
b.math(Opcode.IADD);
// depends on control dependency: [if], data = [none]
}
break;
case TypeDesc.DOUBLE_CODE:
b.invokeStatic(TypeDesc.DOUBLE.toObjectType(), "doubleToLongBits",
TypeDesc.LONG, new TypeDesc[]{TypeDesc.DOUBLE});
// Fall through
case TypeDesc.LONG_CODE:
b.dup2();
b.loadConstant(32);
b.math(Opcode.LUSHR);
b.math(Opcode.LXOR);
b.convert(TypeDesc.LONG, TypeDesc.INT);
if (mixIn) {
b.math(Opcode.IADD);
// depends on control dependency: [if], data = [none]
}
break;
case TypeDesc.OBJECT_CODE:
default:
if (testForNull) {
if (value == null) {
value = b.createLocalVariable(null, valueType);
// depends on control dependency: [if], data = [none]
b.storeLocal(value);
// depends on control dependency: [if], data = [(value]
b.loadLocal(value);
// depends on control dependency: [if], data = [(value]
}
}
if (mixIn) {
Label isNull = b.createLabel();
if (testForNull) {
b.ifNullBranch(isNull, true);
// depends on control dependency: [if], data = [none]
b.loadLocal(value);
// depends on control dependency: [if], data = [none]
}
addValueHashCodeCallTo(b, valueType);
// depends on control dependency: [if], data = [none]
b.math(Opcode.IADD);
// depends on control dependency: [if], data = [none]
if (testForNull) {
isNull.setLocation();
// depends on control dependency: [if], data = [none]
}
} else {
Label cont = b.createLabel();
if (testForNull) {
Label notNull = b.createLabel();
b.ifNullBranch(notNull, false);
// depends on control dependency: [if], data = [none]
b.loadConstant(0);
// depends on control dependency: [if], data = [none]
b.branch(cont);
// depends on control dependency: [if], data = [none]
notNull.setLocation();
// depends on control dependency: [if], data = [none]
b.loadLocal(value);
// depends on control dependency: [if], data = [none]
}
addValueHashCodeCallTo(b, valueType);
// depends on control dependency: [if], data = [none]
if (testForNull) {
cont.setLocation();
// depends on control dependency: [if], data = [none]
}
}
break;
}
} } |
public class class_name {
@Override
public EClass getIfcMotorConnectionType() {
if (ifcMotorConnectionTypeEClass == null) {
ifcMotorConnectionTypeEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(387);
}
return ifcMotorConnectionTypeEClass;
} } | public class class_name {
@Override
public EClass getIfcMotorConnectionType() {
if (ifcMotorConnectionTypeEClass == null) {
ifcMotorConnectionTypeEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(387);
// depends on control dependency: [if], data = [none]
}
return ifcMotorConnectionTypeEClass;
} } |
public class class_name {
@Override
public EClass getIfcSimpleValue() {
if (ifcSimpleValueEClass == null) {
ifcSimpleValueEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(1158);
}
return ifcSimpleValueEClass;
} } | public class class_name {
@Override
public EClass getIfcSimpleValue() {
if (ifcSimpleValueEClass == null) {
ifcSimpleValueEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(1158);
// depends on control dependency: [if], data = [none]
}
return ifcSimpleValueEClass;
} } |
public class class_name {
public static synchronized void schedule(TimerTask task, int evictorDelayCheckSeconds,
int evictorCheckPeriodSeconds) {
if (null == timer) {
timer = new Timer(true);
}
usageCount.incrementAndGet();
timer.schedule(task, evictorDelayCheckSeconds * 1000, evictorCheckPeriodSeconds * 1000);
} } | public class class_name {
public static synchronized void schedule(TimerTask task, int evictorDelayCheckSeconds,
int evictorCheckPeriodSeconds) {
if (null == timer) {
timer = new Timer(true); // depends on control dependency: [if], data = [none]
}
usageCount.incrementAndGet();
timer.schedule(task, evictorDelayCheckSeconds * 1000, evictorCheckPeriodSeconds * 1000);
} } |
public class class_name {
private MethodSpec.Builder generateExecuteMethod(String packageName, SQLiteEntity entity) {
ParameterizedTypeName parameterizedReturnTypeName = ParameterizedTypeName.get(className(ArrayList.class), className(packageName,entity.getSimpleName()));
//@formatter:off
MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("execute")
.addJavadoc("<p>Execute the cursor and read all rows from database.</p>\n\n")
.addJavadoc("@return list of beans\n")
.addModifiers(Modifier.PUBLIC)
.returns(parameterizedReturnTypeName);
//@formatter:on
TypeName entityClass= typeName(entity.getElement());
methodBuilder.addCode("\n");
methodBuilder.addCode("$T resultList=new $T(cursor.getCount());\n",parameterizedReturnTypeName, parameterizedReturnTypeName);
methodBuilder.addCode("$T resultBean=new $T();\n",entityClass, entityClass);
methodBuilder.addCode("\n");
methodBuilder.beginControlFlow("if (cursor.moveToFirst())");
methodBuilder.beginControlFlow("do\n");
methodBuilder.addCode("resultBean=new $T();\n\n",entityClass);
// generate mapping
int i=0;
for (ModelProperty item : entity.getCollection()) {
methodBuilder.addCode("if (index$L>=0 && !cursor.isNull(index$L)) { ",i,i);
SQLTransformer.cursor2Java(methodBuilder, entityClass, item, "resultBean", "cursor","index"+i+"");
methodBuilder.addCode(";");
methodBuilder.addCode("}\n");
i++;
}
methodBuilder.addCode("\n");
methodBuilder.addCode("resultList.add(resultBean);\n");
methodBuilder.endControlFlow("while (cursor.moveToNext())");
methodBuilder.endControlFlow();
methodBuilder.addCode("cursor.close();\n");
methodBuilder.addCode("\n");
methodBuilder.addCode("return resultList;\n");
return methodBuilder;
} } | public class class_name {
private MethodSpec.Builder generateExecuteMethod(String packageName, SQLiteEntity entity) {
ParameterizedTypeName parameterizedReturnTypeName = ParameterizedTypeName.get(className(ArrayList.class), className(packageName,entity.getSimpleName()));
//@formatter:off
MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("execute")
.addJavadoc("<p>Execute the cursor and read all rows from database.</p>\n\n")
.addJavadoc("@return list of beans\n")
.addModifiers(Modifier.PUBLIC)
.returns(parameterizedReturnTypeName);
//@formatter:on
TypeName entityClass= typeName(entity.getElement());
methodBuilder.addCode("\n");
methodBuilder.addCode("$T resultList=new $T(cursor.getCount());\n",parameterizedReturnTypeName, parameterizedReturnTypeName);
methodBuilder.addCode("$T resultBean=new $T();\n",entityClass, entityClass);
methodBuilder.addCode("\n");
methodBuilder.beginControlFlow("if (cursor.moveToFirst())");
methodBuilder.beginControlFlow("do\n");
methodBuilder.addCode("resultBean=new $T();\n\n",entityClass);
// generate mapping
int i=0;
for (ModelProperty item : entity.getCollection()) {
methodBuilder.addCode("if (index$L>=0 && !cursor.isNull(index$L)) { ",i,i); // depends on control dependency: [for], data = [none]
SQLTransformer.cursor2Java(methodBuilder, entityClass, item, "resultBean", "cursor","index"+i+""); // depends on control dependency: [for], data = [item]
methodBuilder.addCode(";"); // depends on control dependency: [for], data = [none]
methodBuilder.addCode("}\n"); // depends on control dependency: [for], data = [none]
i++; // depends on control dependency: [for], data = [none]
}
methodBuilder.addCode("\n");
methodBuilder.addCode("resultList.add(resultBean);\n");
methodBuilder.endControlFlow("while (cursor.moveToNext())");
methodBuilder.endControlFlow();
methodBuilder.addCode("cursor.close();\n");
methodBuilder.addCode("\n");
methodBuilder.addCode("return resultList;\n");
return methodBuilder;
} } |
public class class_name {
public long getLong(int index)
{
Object value = _values[index - 1];
if (value instanceof Long) {
return (Long) value;
}
else if (value instanceof Integer) {
return (Integer) value;
}
else {
return Long.valueOf(value.toString());
}
} } | public class class_name {
public long getLong(int index)
{
Object value = _values[index - 1];
if (value instanceof Long) {
return (Long) value; // depends on control dependency: [if], data = [none]
}
else if (value instanceof Integer) {
return (Integer) value; // depends on control dependency: [if], data = [none]
}
else {
return Long.valueOf(value.toString()); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static <T> T meldProperty(T a, T b) {
if (a == null && b == null) {
return null;
} else if (a == null && b != null) {
return b;
} else if (a != null && b == null) {
return a;
} else {
return ConfigUtils.mergeProperty(a, b);
}
} } | public class class_name {
public static <T> T meldProperty(T a, T b) {
if (a == null && b == null) {
return null; // depends on control dependency: [if], data = [none]
} else if (a == null && b != null) {
return b; // depends on control dependency: [if], data = [none]
} else if (a != null && b == null) {
return a; // depends on control dependency: [if], data = [none]
} else {
return ConfigUtils.mergeProperty(a, b); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private int selectTypes(Trigger<? super S> trigger) {
Class<? extends Trigger> triggerClass = trigger.getClass();
int types = 0;
if (overridesOneMethod(triggerClass, INSERT_METHODS)) {
types |= FOR_INSERT;
}
if (overridesOneMethod(triggerClass, UPDATE_METHODS)) {
types |= FOR_UPDATE;
}
if (overridesOneMethod(triggerClass, DELETE_METHODS)) {
types |= FOR_DELETE;
}
if (overridesMethod(triggerClass, AFTER_LOAD_METHOD)) {
types |= FOR_LOAD;
}
return types;
} } | public class class_name {
private int selectTypes(Trigger<? super S> trigger) {
Class<? extends Trigger> triggerClass = trigger.getClass();
int types = 0;
if (overridesOneMethod(triggerClass, INSERT_METHODS)) {
types |= FOR_INSERT;
// depends on control dependency: [if], data = [none]
}
if (overridesOneMethod(triggerClass, UPDATE_METHODS)) {
types |= FOR_UPDATE;
// depends on control dependency: [if], data = [none]
}
if (overridesOneMethod(triggerClass, DELETE_METHODS)) {
types |= FOR_DELETE;
// depends on control dependency: [if], data = [none]
}
if (overridesMethod(triggerClass, AFTER_LOAD_METHOD)) {
types |= FOR_LOAD;
// depends on control dependency: [if], data = [none]
}
return types;
} } |
public class class_name {
public static ToIntFunction<IntTuple> indexer(Order order, IntTuple size)
{
if (order == Order.COLEXICOGRAPHICAL)
{
return colexicographicalIndexer(size);
}
return lexicographicalIndexer(size);
} } | public class class_name {
public static ToIntFunction<IntTuple> indexer(Order order, IntTuple size)
{
if (order == Order.COLEXICOGRAPHICAL)
{
return colexicographicalIndexer(size);
// depends on control dependency: [if], data = [none]
}
return lexicographicalIndexer(size);
} } |
public class class_name {
@Override protected void handleEvents(final String EVENT_TYPE) {
super.handleEvents(EVENT_TYPE);
if ("RECALC".equals(EVENT_TYPE)) {
minValue = gauge.getMinValue();
maxValue = gauge.getMaxValue();
range = gauge.getRange();
redraw();
} else if ("VISIBILITY".equals(EVENT_TYPE)) {
Helper.enableNode(titleText, !gauge.getTitle().isEmpty());
Helper.enableNode(valueText, gauge.isValueVisible());
Helper.enableNode(unitText, !gauge.getUnit().isEmpty());
Helper.enableNode(subTitleText, !gauge.getSubTitle().isEmpty());
Helper.enableNode(averageLine, gauge.isAverageVisible());
Helper.enableNode(averageText, gauge.isAverageVisible());
Helper.enableNode(stdDeviationArea, gauge.isAverageVisible());
redraw();
} else if ("SECTION".equals(EVENT_TYPE)) {
} else if ("ALERT".equals(EVENT_TYPE)) {
} else if ("VALUE".equals(EVENT_TYPE)) {
if(gauge.isAnimated()) { gauge.setAnimated(false); }
if (!gauge.isAveragingEnabled()) { gauge.setAveragingEnabled(true); }
double value = clamp(minValue, maxValue, gauge.getValue());
addData(value);
drawChart(value);
} else if ("AVERAGING_PERIOD".equals(EVENT_TYPE)) {
noOfDatapoints = gauge.getAveragingPeriod();
// To get smooth lines in the chart we need at least 4 values
if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3.");
for (int i = 0; i < noOfDatapoints; i++) { dataList.add(minValue); }
pathElements.clear();
pathElements.add(0, new MoveTo());
for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }
sparkLine.getElements().setAll(pathElements);
redraw();
}
} } | public class class_name {
@Override protected void handleEvents(final String EVENT_TYPE) {
super.handleEvents(EVENT_TYPE);
if ("RECALC".equals(EVENT_TYPE)) {
minValue = gauge.getMinValue(); // depends on control dependency: [if], data = [none]
maxValue = gauge.getMaxValue(); // depends on control dependency: [if], data = [none]
range = gauge.getRange(); // depends on control dependency: [if], data = [none]
redraw(); // depends on control dependency: [if], data = [none]
} else if ("VISIBILITY".equals(EVENT_TYPE)) {
Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); // depends on control dependency: [if], data = [none]
Helper.enableNode(valueText, gauge.isValueVisible()); // depends on control dependency: [if], data = [none]
Helper.enableNode(unitText, !gauge.getUnit().isEmpty()); // depends on control dependency: [if], data = [none]
Helper.enableNode(subTitleText, !gauge.getSubTitle().isEmpty()); // depends on control dependency: [if], data = [none]
Helper.enableNode(averageLine, gauge.isAverageVisible()); // depends on control dependency: [if], data = [none]
Helper.enableNode(averageText, gauge.isAverageVisible()); // depends on control dependency: [if], data = [none]
Helper.enableNode(stdDeviationArea, gauge.isAverageVisible()); // depends on control dependency: [if], data = [none]
redraw(); // depends on control dependency: [if], data = [none]
} else if ("SECTION".equals(EVENT_TYPE)) {
} else if ("ALERT".equals(EVENT_TYPE)) {
} else if ("VALUE".equals(EVENT_TYPE)) {
if(gauge.isAnimated()) { gauge.setAnimated(false); } // depends on control dependency: [if], data = [none]
if (!gauge.isAveragingEnabled()) { gauge.setAveragingEnabled(true); } // depends on control dependency: [if], data = [none]
double value = clamp(minValue, maxValue, gauge.getValue());
addData(value); // depends on control dependency: [if], data = [none]
drawChart(value); // depends on control dependency: [if], data = [none]
} else if ("AVERAGING_PERIOD".equals(EVENT_TYPE)) {
noOfDatapoints = gauge.getAveragingPeriod(); // depends on control dependency: [if], data = [none]
// To get smooth lines in the chart we need at least 4 values
if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3.");
for (int i = 0; i < noOfDatapoints; i++) { dataList.add(minValue); } // depends on control dependency: [for], data = [none]
pathElements.clear(); // depends on control dependency: [if], data = [none]
pathElements.add(0, new MoveTo()); // depends on control dependency: [if], data = [none]
for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); } // depends on control dependency: [for], data = [i]
sparkLine.getElements().setAll(pathElements); // depends on control dependency: [if], data = [none]
redraw(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
protected void setOffsetPixels(float offsetPixels) {
final int oldOffset = (int) mOffsetPixels;
final int newOffset = (int) offsetPixels;
mOffsetPixels = offsetPixels;
if (newOffset != oldOffset) {
onOffsetPixelsChanged(newOffset);
mSwipeBackViewVisible = newOffset != 0;
// Notify any attached listeners of the current open ratio
final float openRatio = ((float) Math.abs(newOffset)) / mSwipeBackViewSize;
dispatchOnDrawerSlide(openRatio, newOffset);
}
} } | public class class_name {
protected void setOffsetPixels(float offsetPixels) {
final int oldOffset = (int) mOffsetPixels;
final int newOffset = (int) offsetPixels;
mOffsetPixels = offsetPixels;
if (newOffset != oldOffset) {
onOffsetPixelsChanged(newOffset); // depends on control dependency: [if], data = [(newOffset]
mSwipeBackViewVisible = newOffset != 0; // depends on control dependency: [if], data = [none]
// Notify any attached listeners of the current open ratio
final float openRatio = ((float) Math.abs(newOffset)) / mSwipeBackViewSize;
dispatchOnDrawerSlide(openRatio, newOffset); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public SuperToast setTextSize(@Style.TextSize int textSize) {
if (textSize < Style.TEXTSIZE_VERY_SMALL) {
Log.e(getClass().getName(), "SuperToast text size cannot be below 12.");
this.mStyle.messageTextSize = Style.TEXTSIZE_VERY_SMALL;
return this;
} else if (textSize > Style.TEXTSIZE_VERY_LARGE) {
Log.e(getClass().getName(), "SuperToast text size cannot be above 20.");
this.mStyle.messageTextSize = Style.TEXTSIZE_VERY_LARGE;
return this;
}
this.mStyle.messageTextSize = textSize;
return this;
} } | public class class_name {
public SuperToast setTextSize(@Style.TextSize int textSize) {
if (textSize < Style.TEXTSIZE_VERY_SMALL) {
Log.e(getClass().getName(), "SuperToast text size cannot be below 12.");
// depends on control dependency: [if], data = [none]
this.mStyle.messageTextSize = Style.TEXTSIZE_VERY_SMALL;
// depends on control dependency: [if], data = [none]
return this;
// depends on control dependency: [if], data = [none]
} else if (textSize > Style.TEXTSIZE_VERY_LARGE) {
Log.e(getClass().getName(), "SuperToast text size cannot be above 20.");
// depends on control dependency: [if], data = [none]
this.mStyle.messageTextSize = Style.TEXTSIZE_VERY_LARGE;
// depends on control dependency: [if], data = [none]
return this;
// depends on control dependency: [if], data = [none]
}
this.mStyle.messageTextSize = textSize;
return this;
} } |
public class class_name {
public java.util.List<ResourceCount> getResourceCounts() {
if (resourceCounts == null) {
resourceCounts = new com.amazonaws.internal.SdkInternalList<ResourceCount>();
}
return resourceCounts;
} } | public class class_name {
public java.util.List<ResourceCount> getResourceCounts() {
if (resourceCounts == null) {
resourceCounts = new com.amazonaws.internal.SdkInternalList<ResourceCount>(); // depends on control dependency: [if], data = [none]
}
return resourceCounts;
} } |
public class class_name {
@Override
public final void execute(Tuple tuple, BasicOutputCollector collector) {
if (TupleUtils.isTick(tuple)) {
getLogger().debug("Received tick tuple, triggering emit of current rankings");
emitRankings(collector);
} else {
updateRankingsWithTuple(tuple);
}
} } | public class class_name {
@Override
public final void execute(Tuple tuple, BasicOutputCollector collector) {
if (TupleUtils.isTick(tuple)) {
getLogger().debug("Received tick tuple, triggering emit of current rankings"); // depends on control dependency: [if], data = [none]
emitRankings(collector); // depends on control dependency: [if], data = [none]
} else {
updateRankingsWithTuple(tuple); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public double getCount(Object o) {
if (depth > 1) {
wrongDepth();
}
Number count = (Number) map.get(o);
if (count != null) {
return count.doubleValue();
} else {
return 0.0;
}
} } | public class class_name {
public double getCount(Object o) {
if (depth > 1) {
wrongDepth();
// depends on control dependency: [if], data = [none]
}
Number count = (Number) map.get(o);
if (count != null) {
return count.doubleValue();
// depends on control dependency: [if], data = [none]
} else {
return 0.0;
// depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private static void getElementsFromPath(Node document, boolean caseSensitive, int idxStart,
List<Element> result, String... path) {
assert document != null : AssertMessages.notNullParameter(0);
if (path != null && (path.length - idxStart) >= 1) {
final NodeList nodes = document.getChildNodes();
final int len = nodes.getLength();
for (int i = 0; i < len; ++i) {
final Node node = nodes.item(i);
if (node instanceof Element) {
final Element element = (Element) node;
final String name = element.getNodeName();
if (name != null
&& ((caseSensitive && name.equals(path[idxStart]))
|| (!caseSensitive && name.equalsIgnoreCase(path[idxStart])))) {
if ((path.length - idxStart) == 1) {
result.add(element);
} else {
getElementsFromPath(element, caseSensitive, idxStart + 1, result, path);
}
}
}
}
}
} } | public class class_name {
private static void getElementsFromPath(Node document, boolean caseSensitive, int idxStart,
List<Element> result, String... path) {
assert document != null : AssertMessages.notNullParameter(0);
if (path != null && (path.length - idxStart) >= 1) {
final NodeList nodes = document.getChildNodes();
final int len = nodes.getLength();
for (int i = 0; i < len; ++i) {
final Node node = nodes.item(i);
if (node instanceof Element) {
final Element element = (Element) node;
final String name = element.getNodeName();
if (name != null
&& ((caseSensitive && name.equals(path[idxStart]))
|| (!caseSensitive && name.equalsIgnoreCase(path[idxStart])))) {
if ((path.length - idxStart) == 1) {
result.add(element); // depends on control dependency: [if], data = [none]
} else {
getElementsFromPath(element, caseSensitive, idxStart + 1, result, path); // depends on control dependency: [if], data = [none]
}
}
}
}
}
} } |
public class class_name {
private void addPackageJavadoc(CompilationUnit unit, String qualifiedMainType) {
Javadoc javadoc = unit.getPackage().getJavadoc();
if (javadoc == null) {
return;
}
SourceBuilder builder = new SourceBuilder(false);
JavadocGenerator.printDocComment(builder, javadoc);
javadocBlocks.put(qualifiedMainType, builder.toString());
} } | public class class_name {
private void addPackageJavadoc(CompilationUnit unit, String qualifiedMainType) {
Javadoc javadoc = unit.getPackage().getJavadoc();
if (javadoc == null) {
return; // depends on control dependency: [if], data = [none]
}
SourceBuilder builder = new SourceBuilder(false);
JavadocGenerator.printDocComment(builder, javadoc);
javadocBlocks.put(qualifiedMainType, builder.toString());
} } |
public class class_name {
@Override
public UnixSshPath getParent() {
//if ( parts.length == 0 && !isAbsolute() ) {
if ( parts.length == 0 || ( parts.length == 1 && !isAbsolute() ) ) {
return null;
}
if ( parts.length <= 1 ) {
return new UnixSshPath( getFileSystem(), isAbsolute() );
}
return new UnixSshPath( getFileSystem(), isAbsolute(),
Arrays.copyOfRange( parts, 0, parts.length - 1 ) );
} } | public class class_name {
@Override
public UnixSshPath getParent() {
//if ( parts.length == 0 && !isAbsolute() ) {
if ( parts.length == 0 || ( parts.length == 1 && !isAbsolute() ) ) {
return null; // depends on control dependency: [if], data = [none]
}
if ( parts.length <= 1 ) {
return new UnixSshPath( getFileSystem(), isAbsolute() ); // depends on control dependency: [if], data = [none]
}
return new UnixSshPath( getFileSystem(), isAbsolute(),
Arrays.copyOfRange( parts, 0, parts.length - 1 ) );
} } |
public class class_name {
public void onUpgradeDatabase(SQLiteDatabase database, int oldVersion, int newVersion) {
for (ContractHolder contract : contracts) {
if (!openHelper.hasTableInDatabase(database, contract)) {
openHelper.createTable(database, contract);
} else {
openHelper.addMissingColumnsInTable(database, contract);
}
}
} } | public class class_name {
public void onUpgradeDatabase(SQLiteDatabase database, int oldVersion, int newVersion) {
for (ContractHolder contract : contracts) {
if (!openHelper.hasTableInDatabase(database, contract)) {
openHelper.createTable(database, contract);
// depends on control dependency: [if], data = [none]
} else {
openHelper.addMissingColumnsInTable(database, contract);
// depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public RamlModelResult loadRaml(String name) {
final File file = new File(CACHE_DIR, escaped(loader.config()) + "-" + escaped(simpleName(name)) + ".braml");
if (!file.exists()) {
return parseAndSave(loader, name, file);
}
final InputStream in = loader.fetchResource(name, file.lastModified());
if (in != null) {
final byte[] data = loadedData(name, in);
return parseAndSave(new PreloadedLoader(loader, name, data), name, file);
}
try {
return load(file);
} catch (IOException | ClassNotFoundException e) {
return parseAndSave(loader, name, file);
}
} } | public class class_name {
public RamlModelResult loadRaml(String name) {
final File file = new File(CACHE_DIR, escaped(loader.config()) + "-" + escaped(simpleName(name)) + ".braml");
if (!file.exists()) {
return parseAndSave(loader, name, file); // depends on control dependency: [if], data = [none]
}
final InputStream in = loader.fetchResource(name, file.lastModified());
if (in != null) {
final byte[] data = loadedData(name, in);
return parseAndSave(new PreloadedLoader(loader, name, data), name, file); // depends on control dependency: [if], data = [none]
}
try {
return load(file); // depends on control dependency: [try], data = [none]
} catch (IOException | ClassNotFoundException e) {
return parseAndSave(loader, name, file);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
protected void saveQueryParamValue(final int position, final Object obj) {
final String strValue;
if (obj instanceof String || obj instanceof Date) {
strValue = "'" + obj + '\''; // if we have a String or Date, include '' in the saved value
} else if (obj instanceof LocalDateTime || obj instanceof LocalDate || obj instanceof LocalTime) {
strValue = "'" + Converter.get().toString(obj) + '\''; // time as string with '
} else if (obj == null) {
strValue = "<null>"; // convert null to the string null
} else {
strValue = Converter.get().toString(obj); // all other objects (includes all Numbers, arrays, etc)
}
// if we are setting a position larger than current size of parameterValues,
// first make it larger
if (parameterValues == null) {
parameterValues = new ArrayList<>();
}
while (position >= parameterValues.size()) {
parameterValues.add(null);
}
parameterValues.set(position, strValue);
} } | public class class_name {
protected void saveQueryParamValue(final int position, final Object obj) {
final String strValue;
if (obj instanceof String || obj instanceof Date) {
strValue = "'" + obj + '\''; // if we have a String or Date, include '' in the saved value // depends on control dependency: [if], data = [none]
} else if (obj instanceof LocalDateTime || obj instanceof LocalDate || obj instanceof LocalTime) {
strValue = "'" + Converter.get().toString(obj) + '\''; // time as string with ' // depends on control dependency: [if], data = [none]
} else if (obj == null) {
strValue = "<null>"; // convert null to the string null // depends on control dependency: [if], data = [none]
} else {
strValue = Converter.get().toString(obj); // all other objects (includes all Numbers, arrays, etc) // depends on control dependency: [if], data = [(obj]
}
// if we are setting a position larger than current size of parameterValues,
// first make it larger
if (parameterValues == null) {
parameterValues = new ArrayList<>(); // depends on control dependency: [if], data = [none]
}
while (position >= parameterValues.size()) {
parameterValues.add(null); // depends on control dependency: [while], data = [none]
}
parameterValues.set(position, strValue);
} } |
public class class_name {
private Node parseParametersType(JsDocToken token) {
Node paramsType = newNode(Token.PARAM_LIST);
boolean isVarArgs = false;
Node paramType = null;
if (token != JsDocToken.RIGHT_PAREN) {
do {
if (paramType != null) {
// skip past the comma
next();
skipEOLs();
token = next();
}
if (token == JsDocToken.ELLIPSIS) {
// In the latest ES4 proposal, there are no type constraints allowed
// on variable arguments. We support the old syntax for backwards
// compatibility, but we should gradually tear it out.
skipEOLs();
if (match(JsDocToken.RIGHT_PAREN)) {
paramType = newNode(Token.ELLIPSIS);
} else {
skipEOLs();
paramType = wrapNode(Token.ELLIPSIS, parseTypeExpression(next()));
skipEOLs();
}
isVarArgs = true;
} else {
paramType = parseTypeExpression(token);
if (match(JsDocToken.EQUALS)) {
skipEOLs();
next();
paramType = wrapNode(Token.EQUALS, paramType);
}
}
if (paramType == null) {
return null;
}
paramsType.addChildToBack(paramType);
if (isVarArgs) {
break;
}
} while (match(JsDocToken.COMMA));
}
if (isVarArgs && match(JsDocToken.COMMA)) {
return reportTypeSyntaxWarning("msg.jsdoc.function.varargs");
}
// The right paren will be checked by parseFunctionType
return paramsType;
} } | public class class_name {
private Node parseParametersType(JsDocToken token) {
Node paramsType = newNode(Token.PARAM_LIST);
boolean isVarArgs = false;
Node paramType = null;
if (token != JsDocToken.RIGHT_PAREN) {
do {
if (paramType != null) {
// skip past the comma
next(); // depends on control dependency: [if], data = [none]
skipEOLs(); // depends on control dependency: [if], data = [none]
token = next(); // depends on control dependency: [if], data = [none]
}
if (token == JsDocToken.ELLIPSIS) {
// In the latest ES4 proposal, there are no type constraints allowed
// on variable arguments. We support the old syntax for backwards
// compatibility, but we should gradually tear it out.
skipEOLs(); // depends on control dependency: [if], data = [none]
if (match(JsDocToken.RIGHT_PAREN)) {
paramType = newNode(Token.ELLIPSIS); // depends on control dependency: [if], data = [none]
} else {
skipEOLs(); // depends on control dependency: [if], data = [none]
paramType = wrapNode(Token.ELLIPSIS, parseTypeExpression(next())); // depends on control dependency: [if], data = [none]
skipEOLs(); // depends on control dependency: [if], data = [none]
}
isVarArgs = true; // depends on control dependency: [if], data = [none]
} else {
paramType = parseTypeExpression(token); // depends on control dependency: [if], data = [(token]
if (match(JsDocToken.EQUALS)) {
skipEOLs(); // depends on control dependency: [if], data = [none]
next(); // depends on control dependency: [if], data = [none]
paramType = wrapNode(Token.EQUALS, paramType); // depends on control dependency: [if], data = [none]
}
}
if (paramType == null) {
return null; // depends on control dependency: [if], data = [none]
}
paramsType.addChildToBack(paramType);
if (isVarArgs) {
break;
}
} while (match(JsDocToken.COMMA));
}
if (isVarArgs && match(JsDocToken.COMMA)) {
return reportTypeSyntaxWarning("msg.jsdoc.function.varargs"); // depends on control dependency: [if], data = [none]
}
// The right paren will be checked by parseFunctionType
return paramsType;
} } |
public class class_name {
public void setResult(java.util.Collection<WorkspacesIpGroup> result) {
if (result == null) {
this.result = null;
return;
}
this.result = new com.amazonaws.internal.SdkInternalList<WorkspacesIpGroup>(result);
} } | public class class_name {
public void setResult(java.util.Collection<WorkspacesIpGroup> result) {
if (result == null) {
this.result = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.result = new com.amazonaws.internal.SdkInternalList<WorkspacesIpGroup>(result);
} } |
public class class_name {
private boolean shouldEscapeAsCodePoint(int codeUnit, int index, int firstCodeUnit)
{
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is U+007F, [...]
if (isInRange(codeUnit, 0x0001, 0x001F) || codeUnit == 0x007F) {
return true;
} else if (index == 0 && isInRange(codeUnit, 0x0030, 0x0039)) {
// If the character is the first character and is in the range [0-9] (U+0030 to U+0039), [...]
return true;
} else {
// If the character is the second character and is in the range [0-9] (U+0030 to U+0039) and the first
// character is a '-' (U+002D), [...]
return index == 1 && isInRange(codeUnit, 0x0030, 0x0039) && firstCodeUnit == 0x002D;
}
} } | public class class_name {
private boolean shouldEscapeAsCodePoint(int codeUnit, int index, int firstCodeUnit)
{
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is U+007F, [...]
if (isInRange(codeUnit, 0x0001, 0x001F) || codeUnit == 0x007F) {
return true; // depends on control dependency: [if], data = [none]
} else if (index == 0 && isInRange(codeUnit, 0x0030, 0x0039)) {
// If the character is the first character and is in the range [0-9] (U+0030 to U+0039), [...]
return true; // depends on control dependency: [if], data = [none]
} else {
// If the character is the second character and is in the range [0-9] (U+0030 to U+0039) and the first
// character is a '-' (U+002D), [...]
return index == 1 && isInRange(codeUnit, 0x0030, 0x0039) && firstCodeUnit == 0x002D; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public DirectoryConnectSettings withCustomerDnsIps(String... customerDnsIps) {
if (this.customerDnsIps == null) {
setCustomerDnsIps(new com.amazonaws.internal.SdkInternalList<String>(customerDnsIps.length));
}
for (String ele : customerDnsIps) {
this.customerDnsIps.add(ele);
}
return this;
} } | public class class_name {
public DirectoryConnectSettings withCustomerDnsIps(String... customerDnsIps) {
if (this.customerDnsIps == null) {
setCustomerDnsIps(new com.amazonaws.internal.SdkInternalList<String>(customerDnsIps.length)); // depends on control dependency: [if], data = [none]
}
for (String ele : customerDnsIps) {
this.customerDnsIps.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public static LightblueClientConfiguration fromResource(String resourcePath,
ClassLoader classLoader) {
InputStream propertiesStream = classLoader.getResourceAsStream(resourcePath);
if (propertiesStream == null) {
LOGGER.error("Could not find properties resource at " + resourcePath);
throw new LightblueClientConfigurationException("Could not find properties resource "
+ "at " + resourcePath);
}
return fromInputStream(propertiesStream);
} } | public class class_name {
public static LightblueClientConfiguration fromResource(String resourcePath,
ClassLoader classLoader) {
InputStream propertiesStream = classLoader.getResourceAsStream(resourcePath);
if (propertiesStream == null) {
LOGGER.error("Could not find properties resource at " + resourcePath); // depends on control dependency: [if], data = [none]
throw new LightblueClientConfigurationException("Could not find properties resource "
+ "at " + resourcePath);
}
return fromInputStream(propertiesStream);
} } |
public class class_name {
private void recordIndex(int index) {
stateLock.writeLock().lock();
try {
int insertionPoint = -Arrays.binarySearch(effectiveIndex, index) - 1;
System.arraycopy(effectiveIndex, insertionPoint, effectiveIndex, insertionPoint + 1, effectiveIndex.length - insertionPoint - 1);
effectiveIndex[insertionPoint] = index;
} finally {
stateLock.writeLock().unlock();
}
} } | public class class_name {
private void recordIndex(int index) {
stateLock.writeLock().lock();
try {
int insertionPoint = -Arrays.binarySearch(effectiveIndex, index) - 1;
System.arraycopy(effectiveIndex, insertionPoint, effectiveIndex, insertionPoint + 1, effectiveIndex.length - insertionPoint - 1); // depends on control dependency: [try], data = [none]
effectiveIndex[insertionPoint] = index; // depends on control dependency: [try], data = [none]
} finally {
stateLock.writeLock().unlock();
}
} } |
public class class_name {
public static void p(int i, Regex r) {
if (0 == i) {
System.out.println(i + ": " + r.stringMatched());
} else {
System.out.println(i + ": " + r.stringMatched(i));
}
} } | public class class_name {
public static void p(int i, Regex r) {
if (0 == i) {
System.out.println(i + ": " + r.stringMatched()); // depends on control dependency: [if], data = [none]
} else {
System.out.println(i + ": " + r.stringMatched(i)); // depends on control dependency: [if], data = [i)]
}
} } |
public class class_name {
public MessageDataDesc getMessageDataDesc(String strParam)
{
if (strParam == null)
return this;
if (strParam.equals(this.getKey()))
return this;
if (m_messageDataDescChildren == null)
{
m_messageDataDescChildren = new HashMap<String,MessageDataDesc>();
this.setupMessageDataDesc();
}
return (MessageDataDesc)m_messageDataDescChildren.get(strParam);
} } | public class class_name {
public MessageDataDesc getMessageDataDesc(String strParam)
{
if (strParam == null)
return this;
if (strParam.equals(this.getKey()))
return this;
if (m_messageDataDescChildren == null)
{
m_messageDataDescChildren = new HashMap<String,MessageDataDesc>(); // depends on control dependency: [if], data = [none]
this.setupMessageDataDesc(); // depends on control dependency: [if], data = [none]
}
return (MessageDataDesc)m_messageDataDescChildren.get(strParam);
} } |
public class class_name {
public void zoomToFit() {
//Tools.log("zoomToFit invoked");
sclPic.setScaleSize( getSize() );
// prevent useless rescale events when the picture is not ready
if ( sclPic.getStatusCode() == sclPic.LOADED
|| sclPic.getStatusCode() == sclPic.READY ) {
sclPic.createScaledPictureInThread( Thread.MAX_PRIORITY );
}
} } | public class class_name {
public void zoomToFit() {
//Tools.log("zoomToFit invoked");
sclPic.setScaleSize( getSize() );
// prevent useless rescale events when the picture is not ready
if ( sclPic.getStatusCode() == sclPic.LOADED
|| sclPic.getStatusCode() == sclPic.READY ) {
sclPic.createScaledPictureInThread( Thread.MAX_PRIORITY ); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
@Override
public void initialize() throws InitializationException
{
// Set descriptor
setDescriptor(new DefaultExtensionRepositoryDescriptor("remote"));
// Load default extension repositories
for (ExtensionRepositorySource repositoriesSource : this.repositoriesSources) {
for (ExtensionRepositoryDescriptor repositoryDescriptor : repositoriesSource
.getExtensionRepositoryDescriptors()) {
try {
addRepository(repositoryDescriptor, repositoriesSource.getPriority());
} catch (ExtensionRepositoryException e) {
this.logger.error("Failed to add repository [" + repositoryDescriptor + "]", e);
}
}
}
} } | public class class_name {
@Override
public void initialize() throws InitializationException
{
// Set descriptor
setDescriptor(new DefaultExtensionRepositoryDescriptor("remote"));
// Load default extension repositories
for (ExtensionRepositorySource repositoriesSource : this.repositoriesSources) {
for (ExtensionRepositoryDescriptor repositoryDescriptor : repositoriesSource
.getExtensionRepositoryDescriptors()) {
try {
addRepository(repositoryDescriptor, repositoriesSource.getPriority()); // depends on control dependency: [try], data = [none]
} catch (ExtensionRepositoryException e) {
this.logger.error("Failed to add repository [" + repositoryDescriptor + "]", e);
} // depends on control dependency: [catch], data = [none]
}
}
} } |
public class class_name {
public void setWarnings(java.util.Collection<String> warnings) {
if (warnings == null) {
this.warnings = null;
return;
}
this.warnings = new java.util.ArrayList<String>(warnings);
} } | public class class_name {
public void setWarnings(java.util.Collection<String> warnings) {
if (warnings == null) {
this.warnings = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.warnings = new java.util.ArrayList<String>(warnings);
} } |
public class class_name {
private String getContentId(File baseDir, File file) {
String filePath = file.getPath();
String basePath = baseDir.getPath();
int index = filePath.indexOf(basePath);
if (index == -1) {
StringBuilder sb = new StringBuilder("Invalid basePath for file: ");
sb.append("b: '" + basePath + "', ");
sb.append("f: '" + filePath + "'");
throw new DuraCloudRuntimeException(sb.toString());
}
String contentId = filePath.substring(index + basePath.length());
if (contentId.startsWith(File.separator)) {
contentId = contentId.substring(1, contentId.length());
}
// Replace backslash (\) with forward slash (/) for all content IDs
contentId = contentId.replaceAll("\\\\", "/");
return contentId;
} } | public class class_name {
private String getContentId(File baseDir, File file) {
String filePath = file.getPath();
String basePath = baseDir.getPath();
int index = filePath.indexOf(basePath);
if (index == -1) {
StringBuilder sb = new StringBuilder("Invalid basePath for file: ");
sb.append("b: '" + basePath + "', "); // depends on control dependency: [if], data = [none]
sb.append("f: '" + filePath + "'"); // depends on control dependency: [if], data = [none]
throw new DuraCloudRuntimeException(sb.toString());
}
String contentId = filePath.substring(index + basePath.length());
if (contentId.startsWith(File.separator)) {
contentId = contentId.substring(1, contentId.length()); // depends on control dependency: [if], data = [none]
}
// Replace backslash (\) with forward slash (/) for all content IDs
contentId = contentId.replaceAll("\\\\", "/");
return contentId;
} } |
public class class_name {
private BigInteger toBigInteger(ByteBuffer bb, int significantBytes) {
byte[] bytes = Bytes.getArray(bb);
byte[] target;
if (significantBytes != bytes.length) {
target = new byte[significantBytes];
System.arraycopy(bytes, 0, target, 0, bytes.length);
} else {
target = bytes;
}
return new BigInteger(1, target);
} } | public class class_name {
private BigInteger toBigInteger(ByteBuffer bb, int significantBytes) {
byte[] bytes = Bytes.getArray(bb);
byte[] target;
if (significantBytes != bytes.length) {
target = new byte[significantBytes]; // depends on control dependency: [if], data = [none]
System.arraycopy(bytes, 0, target, 0, bytes.length); // depends on control dependency: [if], data = [bytes.length)]
} else {
target = bytes; // depends on control dependency: [if], data = [none]
}
return new BigInteger(1, target);
} } |
public class class_name {
public static void decodeUtf8To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys)
throws IOException {
synchronized (map) {
Utf8StringBuilder buffer = new Utf8StringBuilder();
String key = null;
String value = null;
int b;
int totalLength = 0;
while ((b = in.read()) >= 0) {
switch ((char) b) {
case '&':
value = buffer.toReplacedString();
buffer.reset();
if (key != null) {
map.add(key, value);
} else if (value != null && value.length() > 0) {
map.add(value, "");
}
key = null;
value = null;
if (maxKeys > 0 && map.size() > maxKeys)
throw new IllegalStateException(String.format("Form with too many keys [%d > %d]", map.size(), maxKeys));
break;
case '=':
if (key != null) {
buffer.append((byte) b);
break;
}
key = buffer.toReplacedString();
buffer.reset();
break;
case '+':
buffer.append((byte) ' ');
break;
case '%':
char code0 = (char) in.read();
char code1 = (char) in.read();
buffer.append(decodeHexByte(code0, code1));
break;
default:
buffer.append((byte) b);
break;
}
if (maxLength >= 0 && (++totalLength > maxLength))
throw new IllegalStateException("Form is too large");
}
if (key != null) {
value = buffer.toReplacedString();
buffer.reset();
map.add(key, value);
} else if (buffer.length() > 0) {
map.add(buffer.toReplacedString(), "");
}
}
} } | public class class_name {
public static void decodeUtf8To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys)
throws IOException {
synchronized (map) {
Utf8StringBuilder buffer = new Utf8StringBuilder();
String key = null;
String value = null;
int b;
int totalLength = 0;
while ((b = in.read()) >= 0) {
switch ((char) b) { // depends on control dependency: [while], data = [none]
case '&':
value = buffer.toReplacedString();
buffer.reset();
if (key != null) {
map.add(key, value); // depends on control dependency: [if], data = [(key]
} else if (value != null && value.length() > 0) {
map.add(value, ""); // depends on control dependency: [if], data = [(value]
}
key = null;
value = null;
if (maxKeys > 0 && map.size() > maxKeys)
throw new IllegalStateException(String.format("Form with too many keys [%d > %d]", map.size(), maxKeys));
break;
case '=':
if (key != null) {
buffer.append((byte) b); // depends on control dependency: [if], data = [none]
break;
}
key = buffer.toReplacedString();
buffer.reset();
break;
case '+':
buffer.append((byte) ' ');
break;
case '%':
char code0 = (char) in.read();
char code1 = (char) in.read();
buffer.append(decodeHexByte(code0, code1));
break;
default:
buffer.append((byte) b);
break;
}
if (maxLength >= 0 && (++totalLength > maxLength))
throw new IllegalStateException("Form is too large");
}
if (key != null) {
value = buffer.toReplacedString(); // depends on control dependency: [if], data = [none]
buffer.reset(); // depends on control dependency: [if], data = [none]
map.add(key, value); // depends on control dependency: [if], data = [(key]
} else if (buffer.length() > 0) {
map.add(buffer.toReplacedString(), ""); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public CalendarPeriod GetCalendarPeriod()
{
CalendarPeriod res = new CalendarPeriod();
List<Period> periods = new ArrayList<Period>();
for( int i = 0; i < this.periods.size(); i++ )
{
PeriodAssociative<T> p = this.periods.get( i );
periods.add( new Period( p.getFrom(), p.getTo() ) );
}
// use merge to merge jointed periods...
res.setPeriods( res._Merge( periods ) );
return res;
} } | public class class_name {
public CalendarPeriod GetCalendarPeriod()
{
CalendarPeriod res = new CalendarPeriod();
List<Period> periods = new ArrayList<Period>();
for( int i = 0; i < this.periods.size(); i++ )
{
PeriodAssociative<T> p = this.periods.get( i );
periods.add( new Period( p.getFrom(), p.getTo() ) ); // depends on control dependency: [for], data = [none]
}
// use merge to merge jointed periods...
res.setPeriods( res._Merge( periods ) );
return res;
} } |
public class class_name {
private static void getIndexReaders(List<IndexReader> readers, IndexReader reader)
{
if (reader instanceof MultiIndexReader)
{
for (IndexReader r : ((MultiIndexReader)reader).getIndexReaders())
{
getIndexReaders(readers, r);
}
}
else
{
readers.add(reader);
}
} } | public class class_name {
private static void getIndexReaders(List<IndexReader> readers, IndexReader reader)
{
if (reader instanceof MultiIndexReader)
{
for (IndexReader r : ((MultiIndexReader)reader).getIndexReaders())
{
getIndexReaders(readers, r); // depends on control dependency: [for], data = [r]
}
}
else
{
readers.add(reader); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static ConnectionInfo parser(String url) {
if (null == url) {
return ConnectionInfo.UNKNOWN_CONNECTION_INFO;
}
String lowerCaseUrl = url.toLowerCase();
ConnectionURLParser parser = findURLParser(lowerCaseUrl);
if (parser == null) {
return ConnectionInfo.UNKNOWN_CONNECTION_INFO;
}
try {
return parser.parse(url);
} catch (Exception e) {
log.log(Level.WARNING, "error occurs when paring jdbc url");
}
return ConnectionInfo.UNKNOWN_CONNECTION_INFO;
} } | public class class_name {
public static ConnectionInfo parser(String url) {
if (null == url) {
return ConnectionInfo.UNKNOWN_CONNECTION_INFO; // depends on control dependency: [if], data = [none]
}
String lowerCaseUrl = url.toLowerCase();
ConnectionURLParser parser = findURLParser(lowerCaseUrl);
if (parser == null) {
return ConnectionInfo.UNKNOWN_CONNECTION_INFO; // depends on control dependency: [if], data = [none]
}
try {
return parser.parse(url); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
log.log(Level.WARNING, "error occurs when paring jdbc url");
} // depends on control dependency: [catch], data = [none]
return ConnectionInfo.UNKNOWN_CONNECTION_INFO;
} } |
public class class_name {
public void removePort(TCPPort endPoint) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "removePort: " + endPoint.getServerSocket());
}
synchronized (this) {
NBAcceptChannelSelector accept = endPointToAccept.get(endPoint);
if (accept != null) {
// PK44756 - prevent hang on System.exit by accept selector
if (3100 <= accept.numExceptions) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Ignoring removePort call on fatal selector/system.exit path");
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "removePort");
}
return;
}
EndPointActionInfo work = new EndPointActionInfo(REMOVE_ENDPOINT, endPoint, workSync);
synchronized (workSync) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(this, tc, "Passing remove to selector; " + endPoint.getServerSocket());
}
accept.addWork(work);
try {
workSync.wait();
} catch (InterruptedException x) {
// nothing to do
}
} // end-sync
if (accept == sharedAccept && accept.getUsageCount() <= 0) {
sharedAccept = null;
}
} else {
IllegalArgumentException iae = new IllegalArgumentException("TCP Port to be removed is not registered.");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Throwing IllegalArgumentException");
}
FFDCFilter.processException(iae, CLASS_NAME + ".removePort", "387", this);
throw iae;
}
} // end-sync-this
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "removePort");
}
} } | public class class_name {
public void removePort(TCPPort endPoint) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "removePort: " + endPoint.getServerSocket()); // depends on control dependency: [if], data = [none]
}
synchronized (this) {
NBAcceptChannelSelector accept = endPointToAccept.get(endPoint);
if (accept != null) {
// PK44756 - prevent hang on System.exit by accept selector
if (3100 <= accept.numExceptions) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Ignoring removePort call on fatal selector/system.exit path"); // depends on control dependency: [if], data = [none]
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "removePort"); // depends on control dependency: [if], data = [none]
}
return; // depends on control dependency: [if], data = [none]
}
EndPointActionInfo work = new EndPointActionInfo(REMOVE_ENDPOINT, endPoint, workSync);
synchronized (workSync) { // depends on control dependency: [if], data = [none]
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(this, tc, "Passing remove to selector; " + endPoint.getServerSocket()); // depends on control dependency: [if], data = [none]
}
accept.addWork(work);
try {
workSync.wait(); // depends on control dependency: [try], data = [none]
} catch (InterruptedException x) {
// nothing to do
} // depends on control dependency: [catch], data = [none]
} // end-sync
if (accept == sharedAccept && accept.getUsageCount() <= 0) {
sharedAccept = null; // depends on control dependency: [if], data = [none]
}
} else {
IllegalArgumentException iae = new IllegalArgumentException("TCP Port to be removed is not registered.");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Throwing IllegalArgumentException"); // depends on control dependency: [if], data = [none]
}
FFDCFilter.processException(iae, CLASS_NAME + ".removePort", "387", this); // depends on control dependency: [if], data = [none]
throw iae;
}
} // end-sync-this
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "removePort"); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public boolean is(String property, Type type) {
if (super.has(property)) {
return get(property).is(type);
}
return false;
} } | public class class_name {
public boolean is(String property, Type type) {
if (super.has(property)) {
return get(property).is(type); // depends on control dependency: [if], data = [none]
}
return false;
} } |
public class class_name {
public static ClassLoader getServiceClassLoader(String serviceUniqueName) {
ClassLoader appClassLoader = SERVICE_CLASSLOADER_MAP.get(serviceUniqueName);
if (appClassLoader == null) {
return ClassLoaderUtils.getCurrentClassLoader();
} else {
return appClassLoader;
}
} } | public class class_name {
public static ClassLoader getServiceClassLoader(String serviceUniqueName) {
ClassLoader appClassLoader = SERVICE_CLASSLOADER_MAP.get(serviceUniqueName);
if (appClassLoader == null) {
return ClassLoaderUtils.getCurrentClassLoader(); // depends on control dependency: [if], data = [none]
} else {
return appClassLoader; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static PathImpl getWorkPath()
{
PathImpl workPath = WorkDir.getLocalWorkDir();
if (workPath != null)
return workPath;
PathImpl path = WorkDir.getTmpWorkDir();
try {
path.mkdirs();
} catch (IOException e) {
}
return path;
} } | public class class_name {
public static PathImpl getWorkPath()
{
PathImpl workPath = WorkDir.getLocalWorkDir();
if (workPath != null)
return workPath;
PathImpl path = WorkDir.getTmpWorkDir();
try {
path.mkdirs(); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
} // depends on control dependency: [catch], data = [none]
return path;
} } |
public class class_name {
@Override
public Collection<Response> getResponses(String earliest) {
Collection<Response> responses = new ArrayList<>();
TTransport transport = getTransport();
final TProtocol protocol = new TBinaryProtocol(transport);
final AppSensorApi.Client client = new AppSensorApi.Client(protocol);
//All hooked up, start using the service
try {
Collection<org.owasp.appsensor.rpc.thrift.generated.Response> thriftResponses = client.getResponses(earliest, clientApplicationName);
for (org.owasp.appsensor.rpc.thrift.generated.Response thriftResponse : thriftResponses) {
Response response = mapper.map(thriftResponse, Response.class);
responses.add(response);
}
transport.close();
} catch(Exception e) {
logger.error("Could not complete event add.", e);
}
return responses;
} } | public class class_name {
@Override
public Collection<Response> getResponses(String earliest) {
Collection<Response> responses = new ArrayList<>();
TTransport transport = getTransport();
final TProtocol protocol = new TBinaryProtocol(transport);
final AppSensorApi.Client client = new AppSensorApi.Client(protocol);
//All hooked up, start using the service
try {
Collection<org.owasp.appsensor.rpc.thrift.generated.Response> thriftResponses = client.getResponses(earliest, clientApplicationName);
for (org.owasp.appsensor.rpc.thrift.generated.Response thriftResponse : thriftResponses) {
Response response = mapper.map(thriftResponse, Response.class);
responses.add(response); // depends on control dependency: [for], data = [none]
}
transport.close(); // depends on control dependency: [try], data = [none]
} catch(Exception e) {
logger.error("Could not complete event add.", e);
} // depends on control dependency: [catch], data = [none]
return responses;
} } |
public class class_name {
@Override
public final void setItem(final InvItem pGoods) {
this.item = pGoods;
if (this.itsId == null) {
this.itsId = new PriceGoodsId();
}
this.itsId.setItem(this.item);
} } | public class class_name {
@Override
public final void setItem(final InvItem pGoods) {
this.item = pGoods;
if (this.itsId == null) {
this.itsId = new PriceGoodsId(); // depends on control dependency: [if], data = [none]
}
this.itsId.setItem(this.item);
} } |
public class class_name {
public void addRequestPanelDisplayedMessageChangedListener(DisplayedMessageChangedListener messageChangedListener){
if (requestPanelDisplayedMessageChangedListener == null) {
requestPanelDisplayedMessageChangedListener = createList();
}
requestPanelDisplayedMessageChangedListener.add(messageChangedListener);
} } | public class class_name {
public void addRequestPanelDisplayedMessageChangedListener(DisplayedMessageChangedListener messageChangedListener){
if (requestPanelDisplayedMessageChangedListener == null) {
requestPanelDisplayedMessageChangedListener = createList();
// depends on control dependency: [if], data = [none]
}
requestPanelDisplayedMessageChangedListener.add(messageChangedListener);
} } |
public class class_name {
private void doAppendLine(final String... fields) throws IOException {
if (null != fields) {
for (int i = 0; i < fields.length; i++) {
appendField(fields[i]);
}
writer.write(config.lineDelimiter);
newline = true;
}
} } | public class class_name {
private void doAppendLine(final String... fields) throws IOException {
if (null != fields) {
for (int i = 0; i < fields.length; i++) {
appendField(fields[i]); // depends on control dependency: [for], data = [i]
}
writer.write(config.lineDelimiter); // depends on control dependency: [if], data = [none]
newline = true; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
protected Element findAndReplaceSimpleLists(Counter counter, Element parent, java.util.Collection list,
String parentName, String childName)
{
boolean shouldExist = (list != null) && (list.size() > 0);
Element element = updateElement(counter, parent, parentName, shouldExist);
if (shouldExist)
{
Iterator it = list.iterator();
Iterator elIt = element.getChildren(childName, element.getNamespace()).iterator();
if (!elIt.hasNext())
{
elIt = null;
}
Counter innerCount = new Counter(counter.getDepth() + 1);
while (it.hasNext())
{
String value = (String) it.next();
Element el;
if ((elIt != null) && elIt.hasNext())
{
el = (Element) elIt.next();
if (!elIt.hasNext())
{
elIt = null;
}
}
else
{
el = factory.element(childName, element.getNamespace());
insertAtPreferredLocation(element, el, innerCount);
}
el.setText(value);
innerCount.increaseCount();
}
if (elIt != null)
{
while (elIt.hasNext())
{
elIt.next();
elIt.remove();
}
}
}
return element;
} } | public class class_name {
protected Element findAndReplaceSimpleLists(Counter counter, Element parent, java.util.Collection list,
String parentName, String childName)
{
boolean shouldExist = (list != null) && (list.size() > 0);
Element element = updateElement(counter, parent, parentName, shouldExist);
if (shouldExist)
{
Iterator it = list.iterator();
Iterator elIt = element.getChildren(childName, element.getNamespace()).iterator();
if (!elIt.hasNext())
{
elIt = null; // depends on control dependency: [if], data = [none]
}
Counter innerCount = new Counter(counter.getDepth() + 1);
while (it.hasNext())
{
String value = (String) it.next();
Element el;
if ((elIt != null) && elIt.hasNext())
{
el = (Element) elIt.next(); // depends on control dependency: [if], data = [none]
if (!elIt.hasNext())
{
elIt = null; // depends on control dependency: [if], data = [none]
}
}
else
{
el = factory.element(childName, element.getNamespace()); // depends on control dependency: [if], data = [none]
insertAtPreferredLocation(element, el, innerCount); // depends on control dependency: [if], data = [none]
}
el.setText(value); // depends on control dependency: [while], data = [none]
innerCount.increaseCount(); // depends on control dependency: [while], data = [none]
}
if (elIt != null)
{
while (elIt.hasNext())
{
elIt.next(); // depends on control dependency: [while], data = [none]
elIt.remove(); // depends on control dependency: [while], data = [none]
}
}
}
return element;
} } |
public class class_name {
public static MarvinImage binaryToRgb(MarvinImage img) {
MarvinImage resultImage = new MarvinImage(img.getWidth(), img.getHeight(), MarvinImage.COLOR_MODEL_RGB);
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
if (img.getBinaryColor(x, y)) {
resultImage.setIntColor(x, y, 0, 0, 0);
} else {
resultImage.setIntColor(x, y, 255, 255, 255);
}
}
}
return resultImage;
} } | public class class_name {
public static MarvinImage binaryToRgb(MarvinImage img) {
MarvinImage resultImage = new MarvinImage(img.getWidth(), img.getHeight(), MarvinImage.COLOR_MODEL_RGB);
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
if (img.getBinaryColor(x, y)) {
resultImage.setIntColor(x, y, 0, 0, 0); // depends on control dependency: [if], data = [none]
} else {
resultImage.setIntColor(x, y, 255, 255, 255); // depends on control dependency: [if], data = [none]
}
}
}
return resultImage;
} } |
public class class_name {
@Override
public String fromClassNameToComponentName(final String className) { // *important
if (LdiStringUtil.isEmpty(className)) {
throw new EmptyRuntimeException("className");
}
final String interfaceClassName = toInterfaceClassName(className);
final String suffix = fromClassNameToSuffix(interfaceClassName);
final String middlePackageName = fromSuffixToPackageName(suffix);
String name = null;
for (int i = 0; i < rootPackageNames.length; ++i) {
String prefix = rootPackageNames[i] + "." + middlePackageName + ".";
if (interfaceClassName.startsWith(prefix)) {
name = interfaceClassName.substring(prefix.length());
}
}
if (LdiStringUtil.isEmpty(name)) {
for (int i = 0; i < rootPackageNames.length; ++i) {
final String webPackagePrefix = buildRootAndWebPackagePrefix(i);
if (interfaceClassName.startsWith(webPackagePrefix)) {
name = interfaceClassName.substring(webPackagePrefix.length());
} else {
final String jobPackagePrefix = buildRootAndJobPackagePrefix(i); // #since_lasta_di for LastaJob
if (interfaceClassName.startsWith(jobPackagePrefix)) {
name = interfaceClassName.substring(jobPackagePrefix.length());
}
}
}
if (LdiStringUtil.isEmpty(name)) {
return fromClassNameToShortComponentName(className);
}
}
final String[] array = LdiStringUtil.split(name, ".");
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < array.length; ++i) {
if (i == array.length - 1) {
sb.append(LdiStringUtil.decapitalize(array[i]));
} else {
sb.append(array[i]).append('_');
}
}
return sb.toString();
} } | public class class_name {
@Override
public String fromClassNameToComponentName(final String className) { // *important
if (LdiStringUtil.isEmpty(className)) {
throw new EmptyRuntimeException("className");
}
final String interfaceClassName = toInterfaceClassName(className);
final String suffix = fromClassNameToSuffix(interfaceClassName);
final String middlePackageName = fromSuffixToPackageName(suffix);
String name = null;
for (int i = 0; i < rootPackageNames.length; ++i) {
String prefix = rootPackageNames[i] + "." + middlePackageName + ".";
if (interfaceClassName.startsWith(prefix)) {
name = interfaceClassName.substring(prefix.length()); // depends on control dependency: [if], data = [none]
}
}
if (LdiStringUtil.isEmpty(name)) {
for (int i = 0; i < rootPackageNames.length; ++i) {
final String webPackagePrefix = buildRootAndWebPackagePrefix(i);
if (interfaceClassName.startsWith(webPackagePrefix)) {
name = interfaceClassName.substring(webPackagePrefix.length()); // depends on control dependency: [if], data = [none]
} else {
final String jobPackagePrefix = buildRootAndJobPackagePrefix(i); // #since_lasta_di for LastaJob
if (interfaceClassName.startsWith(jobPackagePrefix)) {
name = interfaceClassName.substring(jobPackagePrefix.length()); // depends on control dependency: [if], data = [none]
}
}
}
if (LdiStringUtil.isEmpty(name)) {
return fromClassNameToShortComponentName(className); // depends on control dependency: [if], data = [none]
}
}
final String[] array = LdiStringUtil.split(name, ".");
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < array.length; ++i) {
if (i == array.length - 1) {
sb.append(LdiStringUtil.decapitalize(array[i])); // depends on control dependency: [if], data = [none]
} else {
sb.append(array[i]).append('_'); // depends on control dependency: [if], data = [none]
}
}
return sb.toString();
} } |
public class class_name {
public static double getDouble(Cursor cursor, String columnName) {
if (cursor == null) {
return -1;
}
return cursor.getDouble(cursor.getColumnIndex(columnName));
} } | public class class_name {
public static double getDouble(Cursor cursor, String columnName) {
if (cursor == null) {
return -1; // depends on control dependency: [if], data = [none]
}
return cursor.getDouble(cursor.getColumnIndex(columnName));
} } |
public class class_name {
public static List<String> requiredColumns(String idColumnName) {
if (idColumnName == null) {
idColumnName = COLUMN_ID;
}
List<String> requiredColumns = new ArrayList<>();
requiredColumns.add(idColumnName);
requiredColumns.add(COLUMN_DATA);
requiredColumns.add(COLUMN_CONTENT_TYPE);
return requiredColumns;
} } | public class class_name {
public static List<String> requiredColumns(String idColumnName) {
if (idColumnName == null) {
idColumnName = COLUMN_ID; // depends on control dependency: [if], data = [none]
}
List<String> requiredColumns = new ArrayList<>();
requiredColumns.add(idColumnName);
requiredColumns.add(COLUMN_DATA);
requiredColumns.add(COLUMN_CONTENT_TYPE);
return requiredColumns;
} } |
public class class_name {
private String getActualComponentType(String componentType) {
if (componentType == null) {
throw new IllegalArgumentException("参数不能为null.");
}
int lastIndex = componentType.lastIndexOf(ARRAY_PREFIX);
if (lastIndex != -1) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < lastIndex + 1; i++) {
sb.append(ARRAY_PREFIX);
}
sb.append("L");
sb.append(componentType.substring(lastIndex + 1));
sb.append(";");
return sb.toString();
}
return componentType;
} } | public class class_name {
private String getActualComponentType(String componentType) {
if (componentType == null) {
throw new IllegalArgumentException("参数不能为null.");
}
int lastIndex = componentType.lastIndexOf(ARRAY_PREFIX);
if (lastIndex != -1) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < lastIndex + 1; i++) {
sb.append(ARRAY_PREFIX); // depends on control dependency: [for], data = [none]
}
sb.append("L"); // depends on control dependency: [if], data = [none]
sb.append(componentType.substring(lastIndex + 1)); // depends on control dependency: [if], data = [(lastIndex]
sb.append(";"); // depends on control dependency: [if], data = [none]
return sb.toString(); // depends on control dependency: [if], data = [none]
}
return componentType;
} } |
public class class_name {
private void loadXmlConfiguration(URL url, I_CmsXmlConfiguration configuration) throws SAXException, IOException {
// generate the file URL for the XML input
URL fileUrl = new URL(url, configuration.getXmlFileName());
CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_LOAD_CONFIG_XMLFILE_1, fileUrl));
// Check transformation rule here so we have the XML file / XSLT file log output together
boolean hasTransformation = hasTransformation();
// create a backup of the configuration
backupXmlConfiguration(configuration);
// instantiate Digester and enable XML validation
m_digester = new Digester();
m_digester.setUseContextClassLoader(true);
//TODO: For this to work with transformed configurations, we need to add the correct DOCTYPE declarations to the transformed files
m_digester.setValidating(true);
m_digester.setEntityResolver(new CmsXmlEntityResolver(null));
m_digester.setRuleNamespaceURI(null);
m_digester.setErrorHandler(new CmsXmlErrorHandler(fileUrl.getFile()));
// add this class to the Digester
m_digester.push(configuration);
configuration.addXmlDigesterRules(m_digester);
InputSource inputSource = null;
if (hasTransformation) {
try {
inputSource = transformConfiguration(url, configuration);
} catch (Exception e) {
LOG.error("Error transforming " + configuration.getXmlFileName() + ": " + e.getLocalizedMessage(), e);
}
}
if (inputSource == null) {
inputSource = new InputSource(fileUrl.openStream());
}
// start the parsing process
m_digester.parse(inputSource);
} } | public class class_name {
private void loadXmlConfiguration(URL url, I_CmsXmlConfiguration configuration) throws SAXException, IOException {
// generate the file URL for the XML input
URL fileUrl = new URL(url, configuration.getXmlFileName());
CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_LOAD_CONFIG_XMLFILE_1, fileUrl));
// Check transformation rule here so we have the XML file / XSLT file log output together
boolean hasTransformation = hasTransformation();
// create a backup of the configuration
backupXmlConfiguration(configuration);
// instantiate Digester and enable XML validation
m_digester = new Digester();
m_digester.setUseContextClassLoader(true);
//TODO: For this to work with transformed configurations, we need to add the correct DOCTYPE declarations to the transformed files
m_digester.setValidating(true);
m_digester.setEntityResolver(new CmsXmlEntityResolver(null));
m_digester.setRuleNamespaceURI(null);
m_digester.setErrorHandler(new CmsXmlErrorHandler(fileUrl.getFile()));
// add this class to the Digester
m_digester.push(configuration);
configuration.addXmlDigesterRules(m_digester);
InputSource inputSource = null;
if (hasTransformation) {
try {
inputSource = transformConfiguration(url, configuration); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
LOG.error("Error transforming " + configuration.getXmlFileName() + ": " + e.getLocalizedMessage(), e);
} // depends on control dependency: [catch], data = [none]
}
if (inputSource == null) {
inputSource = new InputSource(fileUrl.openStream());
}
// start the parsing process
m_digester.parse(inputSource);
} } |
public class class_name {
public int getPropertyValueEnum(int property, CharSequence alias) {
int valueMapIndex=findProperty(property);
if(valueMapIndex==0) {
throw new IllegalArgumentException(
"Invalid property enum "+property+" (0x"+Integer.toHexString(property)+")");
}
valueMapIndex=valueMaps[valueMapIndex+1];
if(valueMapIndex==0) {
throw new IllegalArgumentException(
"Property "+property+" (0x"+Integer.toHexString(property)+
") does not have named values");
}
// valueMapIndex is the start of the property's valueMap,
// where the first word is the BytesTrie offset.
return getPropertyOrValueEnum(valueMaps[valueMapIndex], alias);
} } | public class class_name {
public int getPropertyValueEnum(int property, CharSequence alias) {
int valueMapIndex=findProperty(property);
if(valueMapIndex==0) {
throw new IllegalArgumentException(
"Invalid property enum "+property+" (0x"+Integer.toHexString(property)+")");
}
valueMapIndex=valueMaps[valueMapIndex+1];
if(valueMapIndex==0) {
throw new IllegalArgumentException(
"Property "+property+" (0x"+Integer.toHexString(property)+
") does not have named values");
}
// valueMapIndex is the start of the property's valueMap,
// where the first word is the BytesTrie offset.
return getPropertyOrValueEnum(valueMaps[valueMapIndex], alias); // depends on control dependency: [if], data = [none]
} } |
public class class_name {
public static String getInstrumentationLevelString() {
if (disabled)
return null;
Map modules = moduleRoot.children;
if (modules == null) {
return "";
} else {
PerfLevelDescriptor[] plds = new PerfLevelDescriptor[modules.size()];
Iterator values = modules.values().iterator();
int i = 0;
while (values.hasNext()) {
PmiModule instance = ((ModuleItem) values.next()).getInstance();
plds[i++] = new PerfLevelDescriptor(instance.getPath(),
instance.getInstrumentationLevel(),
instance.getModuleID());
}
return PmiUtil.getStringFromPerfLevelSpecs(plds);
}
} } | public class class_name {
public static String getInstrumentationLevelString() {
if (disabled)
return null;
Map modules = moduleRoot.children;
if (modules == null) {
return ""; // depends on control dependency: [if], data = [none]
} else {
PerfLevelDescriptor[] plds = new PerfLevelDescriptor[modules.size()];
Iterator values = modules.values().iterator();
int i = 0;
while (values.hasNext()) {
PmiModule instance = ((ModuleItem) values.next()).getInstance();
plds[i++] = new PerfLevelDescriptor(instance.getPath(),
instance.getInstrumentationLevel(),
instance.getModuleID()); // depends on control dependency: [while], data = [none]
}
return PmiUtil.getStringFromPerfLevelSpecs(plds); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static boolean go_downstream( int[] colRow, double flowdirection ) {
int n = (int) flowdirection;
if (n == 10) {
return true;
} else if (n < 1 || n > 9) {
return false;
} else {
colRow[1] += DIR[n][0];
colRow[0] += DIR[n][1];
return true;
}
} } | public class class_name {
public static boolean go_downstream( int[] colRow, double flowdirection ) {
int n = (int) flowdirection;
if (n == 10) {
return true; // depends on control dependency: [if], data = [none]
} else if (n < 1 || n > 9) {
return false; // depends on control dependency: [if], data = [none]
} else {
colRow[1] += DIR[n][0]; // depends on control dependency: [if], data = [none]
colRow[0] += DIR[n][1]; // depends on control dependency: [if], data = [none]
return true; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static <T extends ImageGray<T>,Desc extends TupleDesc>
StereoVisualOdometry<T> stereoQuadPnP( double inlierPixelTol ,
double epipolarPixelTol ,
double maxDistanceF2F,
double maxAssociationError,
int ransacIterations ,
int refineIterations ,
DetectDescribeMulti<T,Desc> detector,
Class<T> imageType )
{
EstimateNofPnP pnp = FactoryMultiView.pnp_N(EnumPNP.P3P_FINSTERWALDER, -1);
DistanceFromModelMultiView<Se3_F64,Point2D3D> distanceMono = new PnPDistanceReprojectionSq();
PnPStereoDistanceReprojectionSq distanceStereo = new PnPStereoDistanceReprojectionSq();
PnPStereoEstimator pnpStereo = new PnPStereoEstimator(pnp,distanceMono,0);
ModelManagerSe3_F64 manager = new ModelManagerSe3_F64();
EstimatorToGenerator<Se3_F64,Stereo2D3D> generator = new EstimatorToGenerator<>(pnpStereo);
// euclidean error squared from left + right images
double ransacTOL = 2*inlierPixelTol * inlierPixelTol;
ModelMatcher<Se3_F64, Stereo2D3D> motion =
new Ransac<>(2323, manager, generator, distanceStereo, ransacIterations, ransacTOL);
RefinePnPStereo refinePnP = null;
if( refineIterations > 0 ) {
refinePnP = new PnPStereoRefineRodrigues(1e-12,refineIterations);
}
Class<Desc> descType = detector.getDescriptionType();
ScoreAssociation<Desc> scorer = FactoryAssociation.defaultScore(descType);
// TODO need a better way to keep track of what error is squared and not
AssociateDescription2D<Desc> assocSame;
if( maxDistanceF2F > 0 ) {
AssociateMaxDistanceNaive<Desc> a = new AssociateMaxDistanceNaive<>(scorer, true, maxAssociationError);
a.setSquaredDistance(true);
a.setMaxDistance(maxDistanceF2F);
assocSame = a;
} else {
assocSame = new AssociateDescTo2D<>(FactoryAssociation.greedy(scorer, maxAssociationError, true));
}
AssociateStereo2D<Desc> associateStereo = new AssociateStereo2D<>(scorer, epipolarPixelTol, descType);
Triangulate2ViewsMetric triangulate = FactoryMultiView.triangulate2ViewMetric(
new ConfigTriangulation(ConfigTriangulation.Type.GEOMETRIC));
associateStereo.setMaxScoreThreshold(maxAssociationError);
VisOdomQuadPnP<T,Desc> alg = new VisOdomQuadPnP<>(
detector, assocSame, associateStereo, triangulate, motion, refinePnP);
return new WrapVisOdomQuadPnP<>(alg, refinePnP, associateStereo, distanceStereo, distanceMono, imageType);
} } | public class class_name {
public static <T extends ImageGray<T>,Desc extends TupleDesc>
StereoVisualOdometry<T> stereoQuadPnP( double inlierPixelTol ,
double epipolarPixelTol ,
double maxDistanceF2F,
double maxAssociationError,
int ransacIterations ,
int refineIterations ,
DetectDescribeMulti<T,Desc> detector,
Class<T> imageType )
{
EstimateNofPnP pnp = FactoryMultiView.pnp_N(EnumPNP.P3P_FINSTERWALDER, -1);
DistanceFromModelMultiView<Se3_F64,Point2D3D> distanceMono = new PnPDistanceReprojectionSq();
PnPStereoDistanceReprojectionSq distanceStereo = new PnPStereoDistanceReprojectionSq();
PnPStereoEstimator pnpStereo = new PnPStereoEstimator(pnp,distanceMono,0);
ModelManagerSe3_F64 manager = new ModelManagerSe3_F64();
EstimatorToGenerator<Se3_F64,Stereo2D3D> generator = new EstimatorToGenerator<>(pnpStereo);
// euclidean error squared from left + right images
double ransacTOL = 2*inlierPixelTol * inlierPixelTol;
ModelMatcher<Se3_F64, Stereo2D3D> motion =
new Ransac<>(2323, manager, generator, distanceStereo, ransacIterations, ransacTOL);
RefinePnPStereo refinePnP = null;
if( refineIterations > 0 ) {
refinePnP = new PnPStereoRefineRodrigues(1e-12,refineIterations); // depends on control dependency: [if], data = [none]
}
Class<Desc> descType = detector.getDescriptionType();
ScoreAssociation<Desc> scorer = FactoryAssociation.defaultScore(descType);
// TODO need a better way to keep track of what error is squared and not
AssociateDescription2D<Desc> assocSame;
if( maxDistanceF2F > 0 ) {
AssociateMaxDistanceNaive<Desc> a = new AssociateMaxDistanceNaive<>(scorer, true, maxAssociationError);
a.setSquaredDistance(true);
a.setMaxDistance(maxDistanceF2F);
assocSame = a;
} else {
assocSame = new AssociateDescTo2D<>(FactoryAssociation.greedy(scorer, maxAssociationError, true));
}
AssociateStereo2D<Desc> associateStereo = new AssociateStereo2D<>(scorer, epipolarPixelTol, descType);
Triangulate2ViewsMetric triangulate = FactoryMultiView.triangulate2ViewMetric(
new ConfigTriangulation(ConfigTriangulation.Type.GEOMETRIC));
associateStereo.setMaxScoreThreshold(maxAssociationError);
VisOdomQuadPnP<T,Desc> alg = new VisOdomQuadPnP<>(
detector, assocSame, associateStereo, triangulate, motion, refinePnP);
return new WrapVisOdomQuadPnP<>(alg, refinePnP, associateStereo, distanceStereo, distanceMono, imageType);
} } |
public class class_name {
public void marshall(SuggestionMatch suggestionMatch, ProtocolMarshaller protocolMarshaller) {
if (suggestionMatch == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(suggestionMatch.getSuggestion(), SUGGESTION_BINDING);
protocolMarshaller.marshall(suggestionMatch.getScore(), SCORE_BINDING);
protocolMarshaller.marshall(suggestionMatch.getId(), ID_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(SuggestionMatch suggestionMatch, ProtocolMarshaller protocolMarshaller) {
if (suggestionMatch == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(suggestionMatch.getSuggestion(), SUGGESTION_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(suggestionMatch.getScore(), SCORE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(suggestionMatch.getId(), ID_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 DateTime getEnd() {
try {
final rh_protoClient client = getRpcClient(OncRpcProtocols.ONCRPC_UDP);
try {
return decodeTimestamp(BlockingWrapper.execute(() -> client.getEnd_1()));
} finally {
client.close();
}
} catch (OncRpcException | IOException | InterruptedException | RuntimeException ex) {
LOG.log(Level.SEVERE, "getEnd RPC call failed", ex);
throw new RuntimeException("RPC call failed", ex);
}
} } | public class class_name {
@Override
public DateTime getEnd() {
try {
final rh_protoClient client = getRpcClient(OncRpcProtocols.ONCRPC_UDP);
try {
return decodeTimestamp(BlockingWrapper.execute(() -> client.getEnd_1())); // depends on control dependency: [try], data = [none]
} finally {
client.close();
}
} catch (OncRpcException | IOException | InterruptedException | RuntimeException ex) {
LOG.log(Level.SEVERE, "getEnd RPC call failed", ex);
throw new RuntimeException("RPC call failed", ex);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public synchronized void record(String historyKey, LaJobHistory jobHistory, int limit) {
if (historyMap.size() >= limit) {
final String removedKey = historyKeyList.remove(0);
historyMap.remove(removedKey);
}
historyMap.put(historyKey, jobHistory);
historyKeyList.add(historyKey);
} } | public class class_name {
public synchronized void record(String historyKey, LaJobHistory jobHistory, int limit) {
if (historyMap.size() >= limit) {
final String removedKey = historyKeyList.remove(0);
historyMap.remove(removedKey); // depends on control dependency: [if], data = [none]
}
historyMap.put(historyKey, jobHistory);
historyKeyList.add(historyKey);
} } |
public class class_name {
public static void loading(boolean visible, Panel container) {
loader.setType(LoaderType.CIRCULAR);
loader.setContainer(container);
if (visible) {
loader.show();
} else {
loader.hide();
}
} } | public class class_name {
public static void loading(boolean visible, Panel container) {
loader.setType(LoaderType.CIRCULAR);
loader.setContainer(container);
if (visible) {
loader.show(); // depends on control dependency: [if], data = [none]
} else {
loader.hide(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
void add0(PoolChunk<T> chunk) {
chunk.parent = this;
if (head == null) {
head = chunk;
chunk.prev = null;
chunk.next = null;
} else {
chunk.prev = null;
chunk.next = head;
head.prev = chunk;
head = chunk;
}
} } | public class class_name {
void add0(PoolChunk<T> chunk) {
chunk.parent = this;
if (head == null) {
head = chunk; // depends on control dependency: [if], data = [none]
chunk.prev = null; // depends on control dependency: [if], data = [none]
chunk.next = null; // depends on control dependency: [if], data = [none]
} else {
chunk.prev = null; // depends on control dependency: [if], data = [none]
chunk.next = head; // depends on control dependency: [if], data = [none]
head.prev = chunk; // depends on control dependency: [if], data = [none]
head = chunk; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static int setAbstract(int modifier, boolean b) {
if (b) {
return (modifier | ABSTRACT) &
(~FINAL & ~VOLATILE & ~TRANSIENT & ~NATIVE &
~SYNCHRONIZED & ~STRICT);
}
else {
return modifier & ~ABSTRACT & ~INTERFACE;
}
} } | public class class_name {
public static int setAbstract(int modifier, boolean b) {
if (b) {
return (modifier | ABSTRACT) &
(~FINAL & ~VOLATILE & ~TRANSIENT & ~NATIVE &
~SYNCHRONIZED & ~STRICT); // depends on control dependency: [if], data = [none]
}
else {
return modifier & ~ABSTRACT & ~INTERFACE; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private static void parseMessageTextNode(Builder builder, Node node)
throws MalformedException {
String value = extractStringFromStringExprNode(node);
while (true) {
int phBegin = value.indexOf(PH_JS_PREFIX);
if (phBegin < 0) {
// Just a string literal
builder.appendStringPart(value);
return;
} else {
if (phBegin > 0) {
// A string literal followed by a placeholder
builder.appendStringPart(value.substring(0, phBegin));
}
// A placeholder. Find where it ends
int phEnd = value.indexOf(PH_JS_SUFFIX, phBegin);
if (phEnd < 0) {
throw new MalformedException(
"Placeholder incorrectly formatted in: " + builder.getKey(),
node);
}
String phName = value.substring(phBegin + PH_JS_PREFIX.length(),
phEnd);
builder.appendPlaceholderReference(phName);
int nextPos = phEnd + PH_JS_SUFFIX.length();
if (nextPos < value.length()) {
// Iterate on the rest of the message value
value = value.substring(nextPos);
} else {
// The message is parsed
return;
}
}
}
} } | public class class_name {
private static void parseMessageTextNode(Builder builder, Node node)
throws MalformedException {
String value = extractStringFromStringExprNode(node);
while (true) {
int phBegin = value.indexOf(PH_JS_PREFIX);
if (phBegin < 0) {
// Just a string literal
builder.appendStringPart(value); // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
} else {
if (phBegin > 0) {
// A string literal followed by a placeholder
builder.appendStringPart(value.substring(0, phBegin)); // depends on control dependency: [if], data = [none]
}
// A placeholder. Find where it ends
int phEnd = value.indexOf(PH_JS_SUFFIX, phBegin);
if (phEnd < 0) {
throw new MalformedException(
"Placeholder incorrectly formatted in: " + builder.getKey(),
node);
}
String phName = value.substring(phBegin + PH_JS_PREFIX.length(),
phEnd);
builder.appendPlaceholderReference(phName); // depends on control dependency: [if], data = [none]
int nextPos = phEnd + PH_JS_SUFFIX.length();
if (nextPos < value.length()) {
// Iterate on the rest of the message value
value = value.substring(nextPos); // depends on control dependency: [if], data = [(nextPos]
} else {
// The message is parsed
return; // depends on control dependency: [if], data = [none]
}
}
}
} } |
public class class_name {
@Override
public boolean isAuthenticationRequired(HttpServletRequest request) {
String ctxPath = request.getContextPath();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Context path:" + ctxPath);
}
// return !(KnownSocialLoginUrl.SOCIAL_LOGIN_CONTEXT_PATH.equals(ctxPath));
return false;
} } | public class class_name {
@Override
public boolean isAuthenticationRequired(HttpServletRequest request) {
String ctxPath = request.getContextPath();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Context path:" + ctxPath); // depends on control dependency: [if], data = [none]
}
// return !(KnownSocialLoginUrl.SOCIAL_LOGIN_CONTEXT_PATH.equals(ctxPath));
return false;
} } |
public class class_name {
@Override
public void update(double extrp, Handlables featurables)
{
for (final Updatable updatable : featurables.get(Updatable.class))
{
updatable.update(extrp);
}
} } | public class class_name {
@Override
public void update(double extrp, Handlables featurables)
{
for (final Updatable updatable : featurables.get(Updatable.class))
{
updatable.update(extrp);
// depends on control dependency: [for], data = [updatable]
}
} } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.