code stringlengths 130 281k | code_dependency stringlengths 182 306k |
|---|---|
public class class_name {
private static String[] convertParameters(Class<?>[] params)
{
List<String> tmp = new ArrayList<String>();
for (Class<?> c : params)
{
if (c.isArray())
{
StringBuffer sb = new StringBuffer();
Class<?> subType = c.getComponentType();
sb.append(subType.getName());
// Convert to type[][]...[]
while (subType != null)
{
sb.append("[]");
subType = subType.getComponentType();
}
tmp.add(sb.toString());
}
else
{
tmp.add(c.getName());
}
}
String[] sig = new String[tmp.size()];
tmp.toArray(sig);
return sig;
} } | public class class_name {
private static String[] convertParameters(Class<?>[] params)
{
List<String> tmp = new ArrayList<String>();
for (Class<?> c : params)
{
if (c.isArray())
{
StringBuffer sb = new StringBuffer();
Class<?> subType = c.getComponentType();
sb.append(subType.getName());
// Convert to type[][]...[]
while (subType != null)
{
sb.append("[]"); // depends on control dependency: [while], data = [none]
subType = subType.getComponentType(); // depends on control dependency: [while], data = [none]
}
tmp.add(sb.toString()); // depends on control dependency: [if], data = [none]
}
else
{
tmp.add(c.getName()); // depends on control dependency: [if], data = [none]
}
}
String[] sig = new String[tmp.size()];
tmp.toArray(sig);
return sig;
} } |
public class class_name {
public void addTranslation (String oldname, String newname)
{
if (_translations == null) {
_translations = Maps.newHashMap();
}
_translations.put(oldname, newname);
} } | public class class_name {
public void addTranslation (String oldname, String newname)
{
if (_translations == null) {
_translations = Maps.newHashMap(); // depends on control dependency: [if], data = [none]
}
_translations.put(oldname, newname);
} } |
public class class_name {
private NamedOutputBlockContext findAndRemoveBlock(List<NamedOutputBlockContext> blocks, String name) {
if(blocks == null) {
return null;
}
Iterator<NamedOutputBlockContext> blockIter = blocks.iterator();
while (blockIter.hasNext()) {
NamedOutputBlockContext block = blockIter.next();
String blockName = name(block);
if(name.equals(blockName)) {
blockIter.remove();
return block;
}
}
return null;
} } | public class class_name {
private NamedOutputBlockContext findAndRemoveBlock(List<NamedOutputBlockContext> blocks, String name) {
if(blocks == null) {
return null; // depends on control dependency: [if], data = [none]
}
Iterator<NamedOutputBlockContext> blockIter = blocks.iterator();
while (blockIter.hasNext()) {
NamedOutputBlockContext block = blockIter.next();
String blockName = name(block);
if(name.equals(blockName)) {
blockIter.remove(); // depends on control dependency: [if], data = [none]
return block; // depends on control dependency: [if], data = [none]
}
}
return null;
} } |
public class class_name {
public void marshall(GetContentModerationRequest getContentModerationRequest, ProtocolMarshaller protocolMarshaller) {
if (getContentModerationRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(getContentModerationRequest.getJobId(), JOBID_BINDING);
protocolMarshaller.marshall(getContentModerationRequest.getMaxResults(), MAXRESULTS_BINDING);
protocolMarshaller.marshall(getContentModerationRequest.getNextToken(), NEXTTOKEN_BINDING);
protocolMarshaller.marshall(getContentModerationRequest.getSortBy(), SORTBY_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(GetContentModerationRequest getContentModerationRequest, ProtocolMarshaller protocolMarshaller) {
if (getContentModerationRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(getContentModerationRequest.getJobId(), JOBID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(getContentModerationRequest.getMaxResults(), MAXRESULTS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(getContentModerationRequest.getNextToken(), NEXTTOKEN_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(getContentModerationRequest.getSortBy(), SORTBY_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 void partialSortUsingHeap(Quicksortable q, int k, int size) {
Quicksortable revq = reverseQuicksortable(q);
makeHeap(revq, k);
for (int i = k; i < size; i++) {
if (q.compare(0, i) > 0) {
q.swap(0, i);
heapifyDown(revq, 0, k);
}
}
sortheap(revq, k);
} } | public class class_name {
public static void partialSortUsingHeap(Quicksortable q, int k, int size) {
Quicksortable revq = reverseQuicksortable(q);
makeHeap(revq, k);
for (int i = k; i < size; i++) {
if (q.compare(0, i) > 0) {
q.swap(0, i); // depends on control dependency: [if], data = [none]
heapifyDown(revq, 0, k); // depends on control dependency: [if], data = [none]
}
}
sortheap(revq, k);
} } |
public class class_name {
@Override
public void delete(Object entity, Object rowKey)
{
EntityMetadata m = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entity.getClass());
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
m.getPersistenceUnit());
if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()))
{
rowKey = KunderaCoreUtils.prepareCompositeKey(m, rowKey);
}
deleteByColumn(m.getSchema(), m.getTableName(), null, rowKey);
} } | public class class_name {
@Override
public void delete(Object entity, Object rowKey)
{
EntityMetadata m = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entity.getClass());
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
m.getPersistenceUnit());
if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()))
{
rowKey = KunderaCoreUtils.prepareCompositeKey(m, rowKey); // depends on control dependency: [if], data = [none]
}
deleteByColumn(m.getSchema(), m.getTableName(), null, rowKey);
} } |
public class class_name {
public synchronized void addDeployedExtension(ModuleIdentifier identifier, ExtensionInfo extensionInfo) {
final ExtensionJar extensionJar = new ExtensionJar(identifier, extensionInfo);
Set<ExtensionJar> jars = this.extensions.get(extensionInfo.getName());
if (jars == null) {
this.extensions.put(extensionInfo.getName(), jars = new HashSet<ExtensionJar>());
}
jars.add(extensionJar);
} } | public class class_name {
public synchronized void addDeployedExtension(ModuleIdentifier identifier, ExtensionInfo extensionInfo) {
final ExtensionJar extensionJar = new ExtensionJar(identifier, extensionInfo);
Set<ExtensionJar> jars = this.extensions.get(extensionInfo.getName());
if (jars == null) {
this.extensions.put(extensionInfo.getName(), jars = new HashSet<ExtensionJar>()); // depends on control dependency: [if], data = [none]
}
jars.add(extensionJar);
} } |
public class class_name {
private void parseLiteral(String token) {
Matcher m = Pattern.compile(String.format(ESCAPED_LITERAL_PATTERN_TEMPLATE, escapeCharacter)).matcher(token);
while (m.find()) {
cleanedToken = trimSpecialCharacters(m.group(1));
if (tokenHasContent()) {
mergedTokens.add(new LiteralToken(cleanedToken));
}
}
} } | public class class_name {
private void parseLiteral(String token) {
Matcher m = Pattern.compile(String.format(ESCAPED_LITERAL_PATTERN_TEMPLATE, escapeCharacter)).matcher(token);
while (m.find()) {
cleanedToken = trimSpecialCharacters(m.group(1)); // depends on control dependency: [while], data = [none]
if (tokenHasContent()) {
mergedTokens.add(new LiteralToken(cleanedToken)); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public static Distribution create(
long count,
double sum,
double sumOfSquaredDeviations,
BucketOptions bucketOptions,
List<Bucket> buckets) {
Utils.checkArgument(count >= 0, "count should be non-negative.");
Utils.checkArgument(
sumOfSquaredDeviations >= 0, "sum of squared deviations should be non-negative.");
if (count == 0) {
Utils.checkArgument(sum == 0, "sum should be 0 if count is 0.");
Utils.checkArgument(
sumOfSquaredDeviations == 0, "sum of squared deviations should be 0 if count is 0.");
}
Utils.checkNotNull(bucketOptions, "bucketOptions");
List<Bucket> bucketsCopy =
Collections.unmodifiableList(new ArrayList<Bucket>(Utils.checkNotNull(buckets, "buckets")));
Utils.checkListElementNotNull(bucketsCopy, "bucket");
return new AutoValue_Distribution(
count, sum, sumOfSquaredDeviations, bucketOptions, bucketsCopy);
} } | public class class_name {
public static Distribution create(
long count,
double sum,
double sumOfSquaredDeviations,
BucketOptions bucketOptions,
List<Bucket> buckets) {
Utils.checkArgument(count >= 0, "count should be non-negative.");
Utils.checkArgument(
sumOfSquaredDeviations >= 0, "sum of squared deviations should be non-negative.");
if (count == 0) {
Utils.checkArgument(sum == 0, "sum should be 0 if count is 0."); // depends on control dependency: [if], data = [none]
Utils.checkArgument(
sumOfSquaredDeviations == 0, "sum of squared deviations should be 0 if count is 0."); // depends on control dependency: [if], data = [none]
}
Utils.checkNotNull(bucketOptions, "bucketOptions");
List<Bucket> bucketsCopy =
Collections.unmodifiableList(new ArrayList<Bucket>(Utils.checkNotNull(buckets, "buckets")));
Utils.checkListElementNotNull(bucketsCopy, "bucket");
return new AutoValue_Distribution(
count, sum, sumOfSquaredDeviations, bucketOptions, bucketsCopy);
} } |
public class class_name {
public String getTypeString() {
if (CmsResource.COPY_AS_SIBLING == m_type) {
return CmsConfigurationCopyResource.COPY_AS_SIBLING;
} else if (CmsResource.COPY_PRESERVE_SIBLING == m_type) {
return CmsConfigurationCopyResource.COPY_AS_PRESERVE;
}
return CmsConfigurationCopyResource.COPY_AS_NEW;
} } | public class class_name {
public String getTypeString() {
if (CmsResource.COPY_AS_SIBLING == m_type) {
return CmsConfigurationCopyResource.COPY_AS_SIBLING; // depends on control dependency: [if], data = [none]
} else if (CmsResource.COPY_PRESERVE_SIBLING == m_type) {
return CmsConfigurationCopyResource.COPY_AS_PRESERVE; // depends on control dependency: [if], data = [none]
}
return CmsConfigurationCopyResource.COPY_AS_NEW;
} } |
public class class_name {
private static String[] split(String input) {
char macroStart = MACRO_START.charAt(0);
char macroEnd = MACRO_END.charAt(0);
int startIndex = 0;
boolean inMacro = false;
List<String> list = new ArrayList<String>();
for (int endIndex = 0; endIndex < input.length(); endIndex++) {
char chr = input.charAt(endIndex);
if (!inMacro) {
if (chr == macroStart) {
String result = input.substring(startIndex, endIndex);
if (result.length() > 0) {
list.add(result);
}
inMacro = true;
startIndex = endIndex;
}
} else {
if (chr == macroEnd) {
String result = input.substring(startIndex, endIndex + 1);
if (result.length() > 0) {
list.add(result);
}
inMacro = false;
startIndex = endIndex + 1;
}
}
}
String result = input.substring(startIndex);
if (result.length() > 0) {
list.add(result);
}
return list.toArray(new String[list.size()]);
} } | public class class_name {
private static String[] split(String input) {
char macroStart = MACRO_START.charAt(0);
char macroEnd = MACRO_END.charAt(0);
int startIndex = 0;
boolean inMacro = false;
List<String> list = new ArrayList<String>();
for (int endIndex = 0; endIndex < input.length(); endIndex++) {
char chr = input.charAt(endIndex);
if (!inMacro) {
if (chr == macroStart) {
String result = input.substring(startIndex, endIndex);
if (result.length() > 0) {
list.add(result); // depends on control dependency: [if], data = [none]
}
inMacro = true; // depends on control dependency: [if], data = [none]
startIndex = endIndex; // depends on control dependency: [if], data = [none]
}
} else {
if (chr == macroEnd) {
String result = input.substring(startIndex, endIndex + 1);
if (result.length() > 0) {
list.add(result); // depends on control dependency: [if], data = [none]
}
inMacro = false; // depends on control dependency: [if], data = [none]
startIndex = endIndex + 1; // depends on control dependency: [if], data = [none]
}
}
}
String result = input.substring(startIndex);
if (result.length() > 0) {
list.add(result); // depends on control dependency: [if], data = [none]
}
return list.toArray(new String[list.size()]);
} } |
public class class_name {
@Override
public boolean addAll(int index, Collection<? extends Float> c) {
if (index < 0 || index > size) {
throw new IndexOutOfBoundsException();
}
ensureCapacity(size + c.size());
size += c.size();
for (int i = size + c.size() - 1, j = size - 1; j >= index; i--, j--) {
elements[i] = elements[j];
}
for (float e : c) {
elements[index++] = e;
}
return c.size() > 0;
} } | public class class_name {
@Override
public boolean addAll(int index, Collection<? extends Float> c) {
if (index < 0 || index > size) {
throw new IndexOutOfBoundsException();
}
ensureCapacity(size + c.size());
size += c.size();
for (int i = size + c.size() - 1, j = size - 1; j >= index; i--, j--) {
elements[i] = elements[j]; // depends on control dependency: [for], data = [i]
}
for (float e : c) {
elements[index++] = e; // depends on control dependency: [for], data = [e]
}
return c.size() > 0;
} } |
public class class_name {
protected void fillItem(Item item, CmsUser user) {
item.getItemProperty(TableProperty.Name).setValue(user.getSimpleName());
item.getItemProperty(TableProperty.FullName).setValue(user.getFullName());
item.getItemProperty(TableProperty.SystemName).setValue(user.getName());
boolean disabled = !user.isEnabled();
item.getItemProperty(TableProperty.DISABLED).setValue(new Boolean(disabled));
boolean newUser = user.getLastlogin() == 0L;
item.getItemProperty(TableProperty.NEWUSER).setValue(new Boolean(newUser));
try {
item.getItemProperty(TableProperty.OU).setValue(
OpenCms.getOrgUnitManager().readOrganizationalUnit(m_cms, user.getOuFqn()).getDisplayName(
A_CmsUI.get().getLocale()));
} catch (CmsException e) {
LOG.error("Can't read OU", e);
}
item.getItemProperty(TableProperty.LastLogin).setValue(new Long(user.getLastlogin()));
item.getItemProperty(TableProperty.Created).setValue(new Long(user.getDateCreated()));
item.getItemProperty(TableProperty.INDIRECT).setValue(new Boolean(m_indirects.contains(user)));
item.getItemProperty(TableProperty.FROMOTHEROU).setValue(new Boolean(!user.getOuFqn().equals(m_ou)));
item.getItemProperty(TableProperty.STATUS).setValue(getStatusInt(disabled, newUser));
} } | public class class_name {
protected void fillItem(Item item, CmsUser user) {
item.getItemProperty(TableProperty.Name).setValue(user.getSimpleName());
item.getItemProperty(TableProperty.FullName).setValue(user.getFullName());
item.getItemProperty(TableProperty.SystemName).setValue(user.getName());
boolean disabled = !user.isEnabled();
item.getItemProperty(TableProperty.DISABLED).setValue(new Boolean(disabled));
boolean newUser = user.getLastlogin() == 0L;
item.getItemProperty(TableProperty.NEWUSER).setValue(new Boolean(newUser));
try {
item.getItemProperty(TableProperty.OU).setValue(
OpenCms.getOrgUnitManager().readOrganizationalUnit(m_cms, user.getOuFqn()).getDisplayName(
A_CmsUI.get().getLocale())); // depends on control dependency: [try], data = [none]
} catch (CmsException e) {
LOG.error("Can't read OU", e);
} // depends on control dependency: [catch], data = [none]
item.getItemProperty(TableProperty.LastLogin).setValue(new Long(user.getLastlogin()));
item.getItemProperty(TableProperty.Created).setValue(new Long(user.getDateCreated()));
item.getItemProperty(TableProperty.INDIRECT).setValue(new Boolean(m_indirects.contains(user)));
item.getItemProperty(TableProperty.FROMOTHEROU).setValue(new Boolean(!user.getOuFqn().equals(m_ou)));
item.getItemProperty(TableProperty.STATUS).setValue(getStatusInt(disabled, newUser));
} } |
public class class_name {
private void loadOverridesFromCommandLine() {
final List<String> disallowedKeys = Arrays.asList("java.version", "java.vendorjava.vendor.url", "java.home", "java.vm.specification.version", "java.vm.specification.vendor", "java.vm.specification.name", "java.vm.version",
"java.vm.vendor", "java.vm.name", "java.specification.version", "java.specification.vendor", "java.specification.name", "java.class.version", "java.class.path", "java.library.path", "java.io.tmpdir", "java.compiler",
"java.ext.dirs", "os.name", "os.arch", "os.version", "file.separator", "path.separator", "line.separator", "user.name", "user.home", "user.dir", "java.runtime.name", "sun.boot.library.path", "java.vendor.url", "file.encoding.pkg",
"sun.java.launcher", "user.country", "sun.os.patch.level", "java.runtime.version", "java.awt.graphicsenv", "java.endorsed.dirs", "user.variant", "sun.jnu.encoding", "sun.management.compiler", "user.timezone", "java.awt.printerjob",
"file.encoding", "sun.arch.data.model", "user.language", "awt.toolkit", "java.vm.info", "sun.boot.class.path", "java.vendor", "java.vendor.url.bug", "sun.io.unicode.encoding", "sun.cpu.endian", "sun.desktop", "sun.cpu.isalist");
final Properties sysProperties = System.getProperties();
for (final Object obj : sysProperties.keySet()) {
final String key = (String) obj;
// We don't override for the default defined system keys.
if (disallowedKeys.contains(key)) {
continue;
}
final String value = sysProperties.getProperty(key);
final boolean doSecurely = key.startsWith("_");
if (doSecurely) {
logger.warning("Pulling override from System.getProperty: '" + key + "'=***PROTECTED***");
} else {
logger.warning("Pulling override from System.getProperty: '" + key + "'='" + value + "'");
}
setOverride(key, value);
}
} } | public class class_name {
private void loadOverridesFromCommandLine() {
final List<String> disallowedKeys = Arrays.asList("java.version", "java.vendorjava.vendor.url", "java.home", "java.vm.specification.version", "java.vm.specification.vendor", "java.vm.specification.name", "java.vm.version",
"java.vm.vendor", "java.vm.name", "java.specification.version", "java.specification.vendor", "java.specification.name", "java.class.version", "java.class.path", "java.library.path", "java.io.tmpdir", "java.compiler",
"java.ext.dirs", "os.name", "os.arch", "os.version", "file.separator", "path.separator", "line.separator", "user.name", "user.home", "user.dir", "java.runtime.name", "sun.boot.library.path", "java.vendor.url", "file.encoding.pkg",
"sun.java.launcher", "user.country", "sun.os.patch.level", "java.runtime.version", "java.awt.graphicsenv", "java.endorsed.dirs", "user.variant", "sun.jnu.encoding", "sun.management.compiler", "user.timezone", "java.awt.printerjob",
"file.encoding", "sun.arch.data.model", "user.language", "awt.toolkit", "java.vm.info", "sun.boot.class.path", "java.vendor", "java.vendor.url.bug", "sun.io.unicode.encoding", "sun.cpu.endian", "sun.desktop", "sun.cpu.isalist");
final Properties sysProperties = System.getProperties();
for (final Object obj : sysProperties.keySet()) {
final String key = (String) obj;
// We don't override for the default defined system keys.
if (disallowedKeys.contains(key)) {
continue;
}
final String value = sysProperties.getProperty(key);
final boolean doSecurely = key.startsWith("_");
if (doSecurely) {
logger.warning("Pulling override from System.getProperty: '" + key + "'=***PROTECTED***");
// depends on control dependency: [if], data = [none]
} else {
logger.warning("Pulling override from System.getProperty: '" + key + "'='" + value + "'");
// depends on control dependency: [if], data = [none]
}
setOverride(key, value);
// depends on control dependency: [for], data = [none]
}
} } |
public class class_name {
public static void setProperty(final Map<String, String> map,
final String key, final String value) {
if (value != null && !"".equals(value)) {
map.put(key, value);
}
} } | public class class_name {
public static void setProperty(final Map<String, String> map,
final String key, final String value) {
if (value != null && !"".equals(value)) {
map.put(key, value); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static void write(Writer out, Object object) throws IOException {
if (object instanceof String) {
out.write((String) object);
} else if (object instanceof Object[]) {
out.write(toArrayString((Object[]) object));
} else if (object instanceof Map) {
out.write(toMapString((Map) object));
} else if (object instanceof Collection) {
out.write(toListString((Collection) object));
} else if (object instanceof Writable) {
Writable writable = (Writable) object;
writable.writeTo(out);
} else if (object instanceof InputStream || object instanceof Reader) {
// Copy stream to stream
Reader reader;
if (object instanceof InputStream) {
reader = new InputStreamReader((InputStream) object);
} else {
reader = (Reader) object;
}
try (Reader r = reader) {
char[] chars = new char[8192];
for (int i; (i = r.read(chars)) != -1; ) {
out.write(chars, 0, i);
}
}
} else {
out.write(toString(object));
}
} } | public class class_name {
public static void write(Writer out, Object object) throws IOException {
if (object instanceof String) {
out.write((String) object);
} else if (object instanceof Object[]) {
out.write(toArrayString((Object[]) object));
} else if (object instanceof Map) {
out.write(toMapString((Map) object));
} else if (object instanceof Collection) {
out.write(toListString((Collection) object));
} else if (object instanceof Writable) {
Writable writable = (Writable) object;
writable.writeTo(out);
} else if (object instanceof InputStream || object instanceof Reader) {
// Copy stream to stream
Reader reader;
if (object instanceof InputStream) {
reader = new InputStreamReader((InputStream) object); // depends on control dependency: [if], data = [none]
} else {
reader = (Reader) object; // depends on control dependency: [if], data = [none]
}
try (Reader r = reader) {
char[] chars = new char[8192];
for (int i; (i = r.read(chars)) != -1; ) {
out.write(chars, 0, i); // depends on control dependency: [for], data = [none]
}
}
} else {
out.write(toString(object));
}
} } |
public class class_name {
public com.google.type.TimeOfDayOrBuilder getTimeValueOrBuilder() {
if (typeCase_ == 6) {
return (com.google.type.TimeOfDay) type_;
}
return com.google.type.TimeOfDay.getDefaultInstance();
} } | public class class_name {
public com.google.type.TimeOfDayOrBuilder getTimeValueOrBuilder() {
if (typeCase_ == 6) {
return (com.google.type.TimeOfDay) type_; // depends on control dependency: [if], data = [none]
}
return com.google.type.TimeOfDay.getDefaultInstance();
} } |
public class class_name {
protected final File createTempDir(String prefix) {
try {
File tempDir = File.createTempFile(prefix + ".", "." + getPort());
tempDir.delete();
tempDir.mkdir();
tempDir.deleteOnExit();
return tempDir;
}
catch (IOException ex) {
throw new WebServerException(
"Unable to create tempDir. java.io.tmpdir is set to "
+ System.getProperty("java.io.tmpdir"),
ex);
}
} } | public class class_name {
protected final File createTempDir(String prefix) {
try {
File tempDir = File.createTempFile(prefix + ".", "." + getPort());
tempDir.delete(); // depends on control dependency: [try], data = [none]
tempDir.mkdir(); // depends on control dependency: [try], data = [none]
tempDir.deleteOnExit(); // depends on control dependency: [try], data = [none]
return tempDir; // depends on control dependency: [try], data = [none]
}
catch (IOException ex) {
throw new WebServerException(
"Unable to create tempDir. java.io.tmpdir is set to "
+ System.getProperty("java.io.tmpdir"),
ex);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void visitTypeInsn(int opcode, String type) {
if (mv != null) {
mv.visitTypeInsn(opcode, type);
}
} } | public class class_name {
public void visitTypeInsn(int opcode, String type) {
if (mv != null) {
mv.visitTypeInsn(opcode, type); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void setRelatedFindingsProductArn(java.util.Collection<StringFilter> relatedFindingsProductArn) {
if (relatedFindingsProductArn == null) {
this.relatedFindingsProductArn = null;
return;
}
this.relatedFindingsProductArn = new java.util.ArrayList<StringFilter>(relatedFindingsProductArn);
} } | public class class_name {
public void setRelatedFindingsProductArn(java.util.Collection<StringFilter> relatedFindingsProductArn) {
if (relatedFindingsProductArn == null) {
this.relatedFindingsProductArn = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.relatedFindingsProductArn = new java.util.ArrayList<StringFilter>(relatedFindingsProductArn);
} } |
public class class_name {
public byte[] toBytesFull(boolean withHeader)
{
int size = getFullStorageSize(numBuckets);
if (withHeader) {
size += SERDE_HEADER_SIZE;
}
ByteBuffer buf = ByteBuffer.allocate(size);
writeByteBufferFull(buf, withHeader);
return buf.array();
} } | public class class_name {
public byte[] toBytesFull(boolean withHeader)
{
int size = getFullStorageSize(numBuckets);
if (withHeader) {
size += SERDE_HEADER_SIZE; // depends on control dependency: [if], data = [none]
}
ByteBuffer buf = ByteBuffer.allocate(size);
writeByteBufferFull(buf, withHeader);
return buf.array();
} } |
public class class_name {
public static int getType(String tag) {
if (ElementTags.SUBJECT.equals(tag)) {
return Element.SUBJECT;
}
if (ElementTags.KEYWORDS.equals(tag)) {
return Element.KEYWORDS;
}
if (ElementTags.AUTHOR.equals(tag)) {
return Element.AUTHOR;
}
if (ElementTags.TITLE.equals(tag)) {
return Element.TITLE;
}
if (ElementTags.PRODUCER.equals(tag)) {
return Element.PRODUCER;
}
if (ElementTags.CREATIONDATE.equals(tag)) {
return Element.CREATIONDATE;
}
return Element.HEADER;
} } | public class class_name {
public static int getType(String tag) {
if (ElementTags.SUBJECT.equals(tag)) {
return Element.SUBJECT; // depends on control dependency: [if], data = [none]
}
if (ElementTags.KEYWORDS.equals(tag)) {
return Element.KEYWORDS; // depends on control dependency: [if], data = [none]
}
if (ElementTags.AUTHOR.equals(tag)) {
return Element.AUTHOR; // depends on control dependency: [if], data = [none]
}
if (ElementTags.TITLE.equals(tag)) {
return Element.TITLE; // depends on control dependency: [if], data = [none]
}
if (ElementTags.PRODUCER.equals(tag)) {
return Element.PRODUCER; // depends on control dependency: [if], data = [none]
}
if (ElementTags.CREATIONDATE.equals(tag)) {
return Element.CREATIONDATE; // depends on control dependency: [if], data = [none]
}
return Element.HEADER;
} } |
public class class_name {
private static Collection<Location> findMissedClassesDueToLackOfPackageEntry(
Iterable<URL> classpath, NormalizedResourceName resourceName) {
Set<Location> result = new HashSet<>();
for (Location location : archiveLocationsOf(classpath)) {
if (containsEntryWithPrefix(location, resourceName)) {
result.add(location.append(resourceName.toString()));
}
}
return result;
} } | public class class_name {
private static Collection<Location> findMissedClassesDueToLackOfPackageEntry(
Iterable<URL> classpath, NormalizedResourceName resourceName) {
Set<Location> result = new HashSet<>();
for (Location location : archiveLocationsOf(classpath)) {
if (containsEntryWithPrefix(location, resourceName)) {
result.add(location.append(resourceName.toString())); // depends on control dependency: [if], data = [none]
}
}
return result;
} } |
public class class_name {
@Override
public EClass getIfcTextFontName() {
if (ifcTextFontNameEClass == null) {
ifcTextFontNameEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(877);
}
return ifcTextFontNameEClass;
} } | public class class_name {
@Override
public EClass getIfcTextFontName() {
if (ifcTextFontNameEClass == null) {
ifcTextFontNameEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(877);
// depends on control dependency: [if], data = [none]
}
return ifcTextFontNameEClass;
} } |
public class class_name {
protected void removeRencentlyLeastAccess(
Set<Map.Entry<K, ValueEntry>> entries) {
// 最小使用次数
int least = 0;
// 最久没有被访问
long earliest = 0;
K toBeRemovedByCount = null;
K toBeRemovedByTime = null;
Iterator<Map.Entry<K, ValueEntry>> it = entries.iterator();
if (it.hasNext()) {
Map.Entry<K, ValueEntry> valueEntry = it.next();
least = valueEntry.getValue().count.get();
toBeRemovedByCount = valueEntry.getKey();
earliest = valueEntry.getValue().lastAccess.get();
toBeRemovedByTime = valueEntry.getKey();
}
while (it.hasNext()) {
Map.Entry<K, ValueEntry> valueEntry = it.next();
if (valueEntry.getValue().count.get() < least) {
least = valueEntry.getValue().count.get();
toBeRemovedByCount = valueEntry.getKey();
}
if (valueEntry.getValue().lastAccess.get() < earliest) {
earliest = valueEntry.getValue().count.get();
toBeRemovedByTime = valueEntry.getKey();
}
}
// System.out.println("remove:" + toBeRemoved);
// 如果最少使用次数大于MINI_ACCESS,那么移除访问时间最早的项(也就是最久没有被访问的项)
if (least > MINI_ACCESS) {
map.remove(toBeRemovedByTime);
} else {
map.remove(toBeRemovedByCount);
}
} } | public class class_name {
protected void removeRencentlyLeastAccess(
Set<Map.Entry<K, ValueEntry>> entries) {
// 最小使用次数
int least = 0;
// 最久没有被访问
long earliest = 0;
K toBeRemovedByCount = null;
K toBeRemovedByTime = null;
Iterator<Map.Entry<K, ValueEntry>> it = entries.iterator();
if (it.hasNext()) {
Map.Entry<K, ValueEntry> valueEntry = it.next();
least = valueEntry.getValue().count.get(); // depends on control dependency: [if], data = [none]
toBeRemovedByCount = valueEntry.getKey(); // depends on control dependency: [if], data = [none]
earliest = valueEntry.getValue().lastAccess.get(); // depends on control dependency: [if], data = [none]
toBeRemovedByTime = valueEntry.getKey(); // depends on control dependency: [if], data = [none]
}
while (it.hasNext()) {
Map.Entry<K, ValueEntry> valueEntry = it.next();
if (valueEntry.getValue().count.get() < least) {
least = valueEntry.getValue().count.get(); // depends on control dependency: [if], data = [none]
toBeRemovedByCount = valueEntry.getKey(); // depends on control dependency: [if], data = [none]
}
if (valueEntry.getValue().lastAccess.get() < earliest) {
earliest = valueEntry.getValue().count.get(); // depends on control dependency: [if], data = [none]
toBeRemovedByTime = valueEntry.getKey(); // depends on control dependency: [if], data = [none]
}
}
// System.out.println("remove:" + toBeRemoved);
// 如果最少使用次数大于MINI_ACCESS,那么移除访问时间最早的项(也就是最久没有被访问的项)
if (least > MINI_ACCESS) {
map.remove(toBeRemovedByTime); // depends on control dependency: [if], data = [none]
} else {
map.remove(toBeRemovedByCount); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
protected void internalResetLabelProvider() {
try {
final PackageExplorerLabelProvider provider = createLabelProvider();
this.reflect.set(this, "fLabelProvider", provider); //$NON-NLS-1$
provider.setIsFlatLayout(isFlatLayout());
final DecoratingJavaLabelProvider decoratingProvider = new DecoratingJavaLabelProvider(
provider, false, isFlatLayout());
this.reflect.set(this, "fDecoratingLabelProvider", decoratingProvider); //$NON-NLS-1$
getViewer().setLabelProvider(decoratingProvider);
} catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
throw new Error(e);
}
} } | public class class_name {
protected void internalResetLabelProvider() {
try {
final PackageExplorerLabelProvider provider = createLabelProvider();
this.reflect.set(this, "fLabelProvider", provider); //$NON-NLS-1$ // depends on control dependency: [try], data = [none]
provider.setIsFlatLayout(isFlatLayout()); // depends on control dependency: [try], data = [none]
final DecoratingJavaLabelProvider decoratingProvider = new DecoratingJavaLabelProvider(
provider, false, isFlatLayout());
this.reflect.set(this, "fDecoratingLabelProvider", decoratingProvider); //$NON-NLS-1$ // depends on control dependency: [try], data = [none]
getViewer().setLabelProvider(decoratingProvider); // depends on control dependency: [try], data = [none]
} catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
throw new Error(e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public static boolean createNewResourceEL(Resource res) {
try {
res.createFile(false);
return true;
}
catch (IOException e) {
return false;
}
} } | public class class_name {
public static boolean createNewResourceEL(Resource res) {
try {
res.createFile(false); // depends on control dependency: [try], data = [none]
return true; // depends on control dependency: [try], data = [none]
}
catch (IOException e) {
return false;
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void increaseFontSize() {
// move INTO range if we have just moved OUT of lower virtual
if (inRange() || (atMin() && atLowerBoundary())) {
currentFontIndex++;
} else if (atMax()) {
upperVirtualCount++;
} else if (atMin() && inLower()) {
lowerVirtualCount++;
}
} } | public class class_name {
public void increaseFontSize() {
// move INTO range if we have just moved OUT of lower virtual
if (inRange() || (atMin() && atLowerBoundary())) {
currentFontIndex++; // depends on control dependency: [if], data = [none]
} else if (atMax()) {
upperVirtualCount++; // depends on control dependency: [if], data = [none]
} else if (atMin() && inLower()) {
lowerVirtualCount++; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static InputStream openConfigurationFile(String filepath, ClassLoader classLoader) throws FileNotFoundException {
File file = getConfigurationFile(filepath);
if (file.exists()) {
logger.info("Located configuration file: " + file.getAbsolutePath());
return new FileInputStream(file);
}
// last resort is classLoader classpath
InputStream is = classLoader.getResourceAsStream(filepath);
if (is == null) {
if (ApplicationContext.getDeployPath() != null) {
// try META-INF/mdw
String deployPath = ApplicationContext.getDeployPath();
if (!deployPath.endsWith("/"))
deployPath += "/";
file = new File(deployPath + "META-INF/mdw/" + filepath);
if (file.exists()) {
logger.info("Located configuration file: " + file.getAbsolutePath());
is = new FileInputStream(file);
}
}
if (is == null)
throw new FileNotFoundException(filepath); // give up
}
return is;
} } | public class class_name {
public static InputStream openConfigurationFile(String filepath, ClassLoader classLoader) throws FileNotFoundException {
File file = getConfigurationFile(filepath);
if (file.exists()) {
logger.info("Located configuration file: " + file.getAbsolutePath());
return new FileInputStream(file);
}
// last resort is classLoader classpath
InputStream is = classLoader.getResourceAsStream(filepath);
if (is == null) {
if (ApplicationContext.getDeployPath() != null) {
// try META-INF/mdw
String deployPath = ApplicationContext.getDeployPath();
if (!deployPath.endsWith("/"))
deployPath += "/";
file = new File(deployPath + "META-INF/mdw/" + filepath);
if (file.exists()) {
logger.info("Located configuration file: " + file.getAbsolutePath()); // depends on control dependency: [if], data = [none]
is = new FileInputStream(file); // depends on control dependency: [if], data = [none]
}
}
if (is == null)
throw new FileNotFoundException(filepath); // give up
}
return is;
} } |
public class class_name {
public static void validateAttributeValueLength(Object obj) throws IllegalArgumentException {
if (null != obj) {
Class cls = obj.getClass();
Field[] fields = cls.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {// 遍历
try {
Field field = fields[i];
Annotation[] annotations = field.getAnnotations();
ValidateLength dataLength = null;
for (Annotation annotation : annotations)
if (annotation instanceof ValidateLength)
dataLength = (ValidateLength) annotation;
if (null != dataLength) {
field.setAccessible(true); // 打开私有访问
String name = field.getName();// 获取属性
Object value = field.get(obj);// 获取属性值
if (value == null && !dataLength.nullable())
throw new IllegalArgumentException(name + " is null");
int length = dataLength.value();// 指定的长度
int valueLength = 0;// 数据的长度
String data;
if (value instanceof String) {// 一个个赋值
data = (String) value;
valueLength = data.length();
}
if (valueLength > length)
throw new IllegalArgumentException(name + " length:" + valueLength + " too long");
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
} } | public class class_name {
public static void validateAttributeValueLength(Object obj) throws IllegalArgumentException {
if (null != obj) {
Class cls = obj.getClass();
Field[] fields = cls.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {// 遍历
try {
Field field = fields[i];
Annotation[] annotations = field.getAnnotations();
ValidateLength dataLength = null;
for (Annotation annotation : annotations)
if (annotation instanceof ValidateLength)
dataLength = (ValidateLength) annotation;
if (null != dataLength) {
field.setAccessible(true); // 打开私有访问 // depends on control dependency: [if], data = [none]
String name = field.getName();// 获取属性
Object value = field.get(obj);// 获取属性值
if (value == null && !dataLength.nullable())
throw new IllegalArgumentException(name + " is null");
int length = dataLength.value();// 指定的长度
int valueLength = 0;// 数据的长度
String data;
if (value instanceof String) {// 一个个赋值
data = (String) value; // depends on control dependency: [if], data = [none]
valueLength = data.length(); // depends on control dependency: [if], data = [none]
}
if (valueLength > length)
throw new IllegalArgumentException(name + " length:" + valueLength + " too long");
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} // depends on control dependency: [catch], data = [none]
}
}
} } |
public class class_name {
public static <T> T[] arrayCopy(T[] items, int length, Class<T> tClass) {
// Make an array of the appropriate size. It's too bad that the JVM bothers to
// initialize this with nulls.
@SuppressWarnings("unchecked")
T[] newItems = (T[]) ((tClass == null) ? new Object[length]
: Array.newInstance(tClass, length) );
// array-copy the items up to the new length.
if (length > 0) {
System.arraycopy(items, 0, newItems, 0,
items.length < length ? items.length
: length);
}
return newItems;
} } | public class class_name {
public static <T> T[] arrayCopy(T[] items, int length, Class<T> tClass) {
// Make an array of the appropriate size. It's too bad that the JVM bothers to
// initialize this with nulls.
@SuppressWarnings("unchecked")
T[] newItems = (T[]) ((tClass == null) ? new Object[length]
: Array.newInstance(tClass, length) );
// array-copy the items up to the new length.
if (length > 0) {
System.arraycopy(items, 0, newItems, 0,
items.length < length ? items.length
: length); // depends on control dependency: [if], data = [none]
}
return newItems;
} } |
public class class_name {
public static void showChannels(Object... channels){
// TODO this could share more code with the other show/hide(Only)Channels methods
for(LogRecordHandler handler : handlers){
if(handler instanceof VisibilityHandler){
VisibilityHandler visHandler = (VisibilityHandler) handler;
for (Object channel : channels) {
visHandler.alsoShow(channel);
}
}
}
} } | public class class_name {
public static void showChannels(Object... channels){
// TODO this could share more code with the other show/hide(Only)Channels methods
for(LogRecordHandler handler : handlers){
if(handler instanceof VisibilityHandler){
VisibilityHandler visHandler = (VisibilityHandler) handler;
for (Object channel : channels) {
visHandler.alsoShow(channel);
// depends on control dependency: [for], data = [channel]
}
}
}
} } |
public class class_name {
public RuntimeEventListener getRuntimeEventListener() {
if (TraceComponent.isAnyTracingEnabled()
&& tc.isEntryEnabled()) {
SibTr.entry(tc, "getRuntimeEventListener");
SibTr.exit(tc, "getRuntimeEventListener", _runtimeEventListener);
}
return _runtimeEventListener;
} } | public class class_name {
public RuntimeEventListener getRuntimeEventListener() {
if (TraceComponent.isAnyTracingEnabled()
&& tc.isEntryEnabled()) {
SibTr.entry(tc, "getRuntimeEventListener"); // depends on control dependency: [if], data = [none]
SibTr.exit(tc, "getRuntimeEventListener", _runtimeEventListener); // depends on control dependency: [if], data = [none]
}
return _runtimeEventListener;
} } |
public class class_name {
public ServiceCall<InputStream> getCoreMlModel(GetCoreMlModelOptions getCoreMlModelOptions) {
Validator.notNull(getCoreMlModelOptions, "getCoreMlModelOptions cannot be null");
String[] pathSegments = { "v3/classifiers", "core_ml_model" };
String[] pathParameters = { getCoreMlModelOptions.classifierId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "getCoreMlModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/octet-stream");
return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream());
} } | public class class_name {
public ServiceCall<InputStream> getCoreMlModel(GetCoreMlModelOptions getCoreMlModelOptions) {
Validator.notNull(getCoreMlModelOptions, "getCoreMlModelOptions cannot be null");
String[] pathSegments = { "v3/classifiers", "core_ml_model" };
String[] pathParameters = { getCoreMlModelOptions.classifierId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "getCoreMlModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue()); // depends on control dependency: [for], data = [header]
}
builder.header("Accept", "application/octet-stream");
return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream());
} } |
public class class_name {
void visitSubroutine(final Label JSR, final long id, final int nbSubroutines)
{
if (JSR != null) {
if ((status & VISITED) != 0) {
return;
}
status |= VISITED;
// adds JSR to the successors of this block, if it is a RET block
if ((status & RET) != 0) {
if (!inSameSubroutine(JSR)) {
Edge e = new Edge();
e.info = inputStackTop;
e.successor = JSR.successors.successor;
e.next = successors;
successors = e;
}
}
} else {
// if this block already belongs to subroutine 'id', returns
if (inSubroutine(id)) {
return;
}
// marks this block as belonging to subroutine 'id'
addToSubroutine(id, nbSubroutines);
}
// calls this method recursively on each successor, except JSR targets
Edge e = successors;
while (e != null) {
// if this block is a JSR block, then 'successors.next' leads
// to the JSR target (see {@link #visitJumpInsn}) and must therefore
// not be followed
if ((status & Label.JSR) == 0 || e != successors.next) {
e.successor.visitSubroutine(JSR, id, nbSubroutines);
}
e = e.next;
}
} } | public class class_name {
void visitSubroutine(final Label JSR, final long id, final int nbSubroutines)
{
if (JSR != null) {
if ((status & VISITED) != 0) {
return; // depends on control dependency: [if], data = [none]
}
status |= VISITED; // depends on control dependency: [if], data = [none]
// adds JSR to the successors of this block, if it is a RET block
if ((status & RET) != 0) {
if (!inSameSubroutine(JSR)) {
Edge e = new Edge();
e.info = inputStackTop; // depends on control dependency: [if], data = [none]
e.successor = JSR.successors.successor; // depends on control dependency: [if], data = [none]
e.next = successors; // depends on control dependency: [if], data = [none]
successors = e; // depends on control dependency: [if], data = [none]
}
}
} else {
// if this block already belongs to subroutine 'id', returns
if (inSubroutine(id)) {
return; // depends on control dependency: [if], data = [none]
}
// marks this block as belonging to subroutine 'id'
addToSubroutine(id, nbSubroutines); // depends on control dependency: [if], data = [none]
}
// calls this method recursively on each successor, except JSR targets
Edge e = successors;
while (e != null) {
// if this block is a JSR block, then 'successors.next' leads
// to the JSR target (see {@link #visitJumpInsn}) and must therefore
// not be followed
if ((status & Label.JSR) == 0 || e != successors.next) {
e.successor.visitSubroutine(JSR, id, nbSubroutines); // depends on control dependency: [if], data = [none]
}
e = e.next; // depends on control dependency: [while], data = [none]
}
} } |
public class class_name {
private static Object transformType(Object value) {
if (value == null) {
return null;
}
String valueString = value.toString();
// check for boolean
boolean boolValue = BooleanUtils.toBoolean(valueString);
if (StringUtils.equals(valueString, Boolean.toString(boolValue))) {
return boolValue;
}
// check for integer
int intValue = NumberUtils.toInt(valueString);
if (StringUtils.equals(valueString, Integer.toString(intValue))) {
return intValue;
}
return value;
} } | public class class_name {
private static Object transformType(Object value) {
if (value == null) {
return null; // depends on control dependency: [if], data = [none]
}
String valueString = value.toString();
// check for boolean
boolean boolValue = BooleanUtils.toBoolean(valueString);
if (StringUtils.equals(valueString, Boolean.toString(boolValue))) {
return boolValue; // depends on control dependency: [if], data = [none]
}
// check for integer
int intValue = NumberUtils.toInt(valueString);
if (StringUtils.equals(valueString, Integer.toString(intValue))) {
return intValue; // depends on control dependency: [if], data = [none]
}
return value;
} } |
public class class_name {
public void removeIndividual(Member member, String studyId) {
// Sanity check
if (member == null) {
logger.error("Individual is null.");
return;
}
removeIndividual(member.getName(), studyId);
} } | public class class_name {
public void removeIndividual(Member member, String studyId) {
// Sanity check
if (member == null) {
logger.error("Individual is null."); // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
removeIndividual(member.getName(), studyId);
} } |
public class class_name {
public void addMatch(String name, PseudoClassType pseudoClass)
{
if (names == null)
names = new HashMap<String, Set<PseudoClassType>>();
Set<PseudoClassType> classes = names.get(name);
if (classes == null)
{
classes = new HashSet<PseudoClassType>(2);
names.put(name, classes);
}
classes.add(pseudoClass);
} } | public class class_name {
public void addMatch(String name, PseudoClassType pseudoClass)
{
if (names == null)
names = new HashMap<String, Set<PseudoClassType>>();
Set<PseudoClassType> classes = names.get(name);
if (classes == null)
{
classes = new HashSet<PseudoClassType>(2); // depends on control dependency: [if], data = [none]
names.put(name, classes); // depends on control dependency: [if], data = [none]
}
classes.add(pseudoClass);
} } |
public class class_name {
public static ClassNode getNextSuperClass(ClassNode clazz, ClassNode goalClazz) {
if (clazz.isArray()) {
if (!goalClazz.isArray()) return null;
ClassNode cn = getNextSuperClass(clazz.getComponentType(), goalClazz.getComponentType());
if (cn != null) cn = cn.makeArray();
return cn;
}
if (!goalClazz.isInterface()) {
if (clazz.isInterface()) {
if (OBJECT_TYPE.equals(clazz)) return null;
return OBJECT_TYPE;
} else {
return clazz.getUnresolvedSuperClass();
}
}
ClassNode[] interfaces = clazz.getUnresolvedInterfaces();
for (ClassNode anInterface : interfaces) {
if (StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(anInterface, goalClazz)) {
return anInterface;
}
}
//none of the interfaces here match, so continue with super class
return clazz.getUnresolvedSuperClass();
} } | public class class_name {
public static ClassNode getNextSuperClass(ClassNode clazz, ClassNode goalClazz) {
if (clazz.isArray()) {
if (!goalClazz.isArray()) return null;
ClassNode cn = getNextSuperClass(clazz.getComponentType(), goalClazz.getComponentType());
if (cn != null) cn = cn.makeArray();
return cn; // depends on control dependency: [if], data = [none]
}
if (!goalClazz.isInterface()) {
if (clazz.isInterface()) {
if (OBJECT_TYPE.equals(clazz)) return null;
return OBJECT_TYPE; // depends on control dependency: [if], data = [none]
} else {
return clazz.getUnresolvedSuperClass(); // depends on control dependency: [if], data = [none]
}
}
ClassNode[] interfaces = clazz.getUnresolvedInterfaces();
for (ClassNode anInterface : interfaces) {
if (StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(anInterface, goalClazz)) {
return anInterface; // depends on control dependency: [if], data = [none]
}
}
//none of the interfaces here match, so continue with super class
return clazz.getUnresolvedSuperClass();
} } |
public class class_name {
private void setSentenceSpan(JSONObject cNode, JSONObject parent) {
try {
JSONObject data = cNode.getJSONObject("data");
int leftPosC = data.getInt(SENTENCE_LEFT);
int rightPosC = data.getInt(SENTENCE_RIGHT);
data = parent.getJSONObject("data");
if (data.has(SENTENCE_LEFT)) {
data.put(SENTENCE_LEFT, Math.min(leftPosC, data.getInt(SENTENCE_LEFT)));
} else {
data.put(SENTENCE_LEFT, leftPosC);
}
if (data.has(SENTENCE_RIGHT)) {
data.put(SENTENCE_RIGHT,
Math.max(rightPosC, data.getInt(SENTENCE_RIGHT)));
} else {
data.put(SENTENCE_RIGHT, rightPosC);
}
} catch (JSONException ex) {
log.debug("error while setting left and right position for sentences", ex);
}
} } | public class class_name {
private void setSentenceSpan(JSONObject cNode, JSONObject parent) {
try {
JSONObject data = cNode.getJSONObject("data");
int leftPosC = data.getInt(SENTENCE_LEFT);
int rightPosC = data.getInt(SENTENCE_RIGHT);
data = parent.getJSONObject("data"); // depends on control dependency: [try], data = [none]
if (data.has(SENTENCE_LEFT)) {
data.put(SENTENCE_LEFT, Math.min(leftPosC, data.getInt(SENTENCE_LEFT))); // depends on control dependency: [if], data = [none]
} else {
data.put(SENTENCE_LEFT, leftPosC); // depends on control dependency: [if], data = [none]
}
if (data.has(SENTENCE_RIGHT)) {
data.put(SENTENCE_RIGHT,
Math.max(rightPosC, data.getInt(SENTENCE_RIGHT))); // depends on control dependency: [if], data = [none]
} else {
data.put(SENTENCE_RIGHT, rightPosC); // depends on control dependency: [if], data = [none]
}
} catch (JSONException ex) {
log.debug("error while setting left and right position for sentences", ex);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
protected BigRational getFactor(int index) {
while (factors.size() <= index) {
BigRational factor = getCurrentFactor();
factors.add(factor);
calculateNextFactor();
}
return factors.get(index);
} } | public class class_name {
protected BigRational getFactor(int index) {
while (factors.size() <= index) {
BigRational factor = getCurrentFactor();
factors.add(factor);
// depends on control dependency: [while], data = [none]
calculateNextFactor();
// depends on control dependency: [while], data = [none]
}
return factors.get(index);
} } |
public class class_name {
public void marshall(PutTraceSegmentsRequest putTraceSegmentsRequest, ProtocolMarshaller protocolMarshaller) {
if (putTraceSegmentsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(putTraceSegmentsRequest.getTraceSegmentDocuments(), TRACESEGMENTDOCUMENTS_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(PutTraceSegmentsRequest putTraceSegmentsRequest, ProtocolMarshaller protocolMarshaller) {
if (putTraceSegmentsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(putTraceSegmentsRequest.getTraceSegmentDocuments(), TRACESEGMENTDOCUMENTS_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public static final String formatPath(String path) {
if (path == null) {
return "";
}
path = path.trim();
if (path.isEmpty()) {
return path;
}
if (!path.startsWith("/")) {
path = '/' + path;
}
while (path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
return path;
} } | public class class_name {
public static final String formatPath(String path) {
if (path == null) {
return "";
// depends on control dependency: [if], data = [none]
}
path = path.trim();
if (path.isEmpty()) {
return path;
// depends on control dependency: [if], data = [none]
}
if (!path.startsWith("/")) {
path = '/' + path;
// depends on control dependency: [if], data = [none]
}
while (path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
// depends on control dependency: [while], data = [none]
}
return path;
} } |
public class class_name {
public void perform(TaskRequest req, TaskResponse res) {
HttpServletResponse sres = (HttpServletResponse) response.evaluate(req, res);
String rsc = (String) resource.evaluate(req, res);
try {
// Send the redirect (HTTP status code 302)
sres.sendRedirect(rsc);
} catch (Throwable t) {
String msg = "Error redirecting to the specified resource: " + rsc;
throw new RuntimeException(msg, t);
}
} } | public class class_name {
public void perform(TaskRequest req, TaskResponse res) {
HttpServletResponse sres = (HttpServletResponse) response.evaluate(req, res);
String rsc = (String) resource.evaluate(req, res);
try {
// Send the redirect (HTTP status code 302)
sres.sendRedirect(rsc); // depends on control dependency: [try], data = [none]
} catch (Throwable t) {
String msg = "Error redirecting to the specified resource: " + rsc;
throw new RuntimeException(msg, t);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private void applyAce(final AccessControllable node, final Ace toAdd, final boolean revoke) throws FrameworkException {
final String principalId = toAdd.getPrincipalId();
final List<String> permissions = toAdd.getPermissions();
final Principal principal = CMISObjectWrapper.translateUsernameToPrincipal(principalId);
if (principal != null) {
for (final String permissionString : permissions) {
final Permission permission = Permissions.valueOf(permissionString);
if (permission != null) {
if (revoke) {
node.revoke(permission, principal);
} else {
node.grant(permission, principal);
}
} else {
throw new CmisInvalidArgumentException("Permission with ID " + permissionString + " does not exist");
}
}
} else {
throw new CmisObjectNotFoundException("Principal with ID " + principalId + " does not exist");
}
} } | public class class_name {
private void applyAce(final AccessControllable node, final Ace toAdd, final boolean revoke) throws FrameworkException {
final String principalId = toAdd.getPrincipalId();
final List<String> permissions = toAdd.getPermissions();
final Principal principal = CMISObjectWrapper.translateUsernameToPrincipal(principalId);
if (principal != null) {
for (final String permissionString : permissions) {
final Permission permission = Permissions.valueOf(permissionString);
if (permission != null) {
if (revoke) {
node.revoke(permission, principal); // depends on control dependency: [if], data = [none]
} else {
node.grant(permission, principal); // depends on control dependency: [if], data = [none]
}
} else {
throw new CmisInvalidArgumentException("Permission with ID " + permissionString + " does not exist");
}
}
} else {
throw new CmisObjectNotFoundException("Principal with ID " + principalId + " does not exist");
}
} } |
public class class_name {
public final static void fireProbe(long probeId, Object instance, Object target, Object args) {
// Load statics onto the stack to avoid a window where they can be cleared
// between the test for null and the invocation of the method
Object proxyTarget = fireProbeTarget;
Method method = fireProbeMethod;
if (proxyTarget == null || method == null) {
return;
}
try {
method.invoke(proxyTarget, probeId, instance, target, args);
} catch (Throwable t) {
t.printStackTrace();
}
} } | public class class_name {
public final static void fireProbe(long probeId, Object instance, Object target, Object args) {
// Load statics onto the stack to avoid a window where they can be cleared
// between the test for null and the invocation of the method
Object proxyTarget = fireProbeTarget;
Method method = fireProbeMethod;
if (proxyTarget == null || method == null) {
return; // depends on control dependency: [if], data = [none]
}
try {
method.invoke(proxyTarget, probeId, instance, target, args); // depends on control dependency: [try], data = [none]
} catch (Throwable t) {
t.printStackTrace();
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public static Inet6Address getByAddress(String host, byte[] addr, int scope_id)
throws UnknownHostException {
if (host != null && host.length() > 0 && host.charAt(0) == '[') {
if (host.charAt(host.length()-1) == ']') {
host = host.substring(1, host.length() -1);
}
}
if (addr != null) {
if (addr.length == Inet6Address.INADDRSZ) {
return new Inet6Address(host, addr, scope_id);
}
}
throw new UnknownHostException("addr is of illegal length");
} } | public class class_name {
public static Inet6Address getByAddress(String host, byte[] addr, int scope_id)
throws UnknownHostException {
if (host != null && host.length() > 0 && host.charAt(0) == '[') {
if (host.charAt(host.length()-1) == ']') {
host = host.substring(1, host.length() -1); // depends on control dependency: [if], data = [none]
}
}
if (addr != null) {
if (addr.length == Inet6Address.INADDRSZ) {
return new Inet6Address(host, addr, scope_id);
}
}
throw new UnknownHostException("addr is of illegal length");
} } |
public class class_name {
private String getDataFieldValue(String dataHeader, String fieldName) {
String value = null;
String token = StrUtil.format("{}=\"", fieldName);
int pos = dataHeader.indexOf(token);
if (pos > 0) {
int start = pos + token.length();
int end = dataHeader.indexOf('"', start);
if ((start > 0) && (end > 0)) {
value = dataHeader.substring(start, end);
}
}
return value;
} } | public class class_name {
private String getDataFieldValue(String dataHeader, String fieldName) {
String value = null;
String token = StrUtil.format("{}=\"", fieldName);
int pos = dataHeader.indexOf(token);
if (pos > 0) {
int start = pos + token.length();
int end = dataHeader.indexOf('"', start);
if ((start > 0) && (end > 0)) {
value = dataHeader.substring(start, end);
// depends on control dependency: [if], data = [none]
}
}
return value;
} } |
public class class_name {
public String removePrefix(final String path, final String prefix) {
String pathWithoutPrefix = path;
if (pathWithoutPrefix.startsWith(prefix)) {
pathWithoutPrefix = pathWithoutPrefix.substring(prefix.length());
while (pathWithoutPrefix.startsWith("/") || pathWithoutPrefix.startsWith("\\")) {
pathWithoutPrefix = pathWithoutPrefix.substring(1);
}
}
return pathWithoutPrefix;
} } | public class class_name {
public String removePrefix(final String path, final String prefix) {
String pathWithoutPrefix = path;
if (pathWithoutPrefix.startsWith(prefix)) {
pathWithoutPrefix = pathWithoutPrefix.substring(prefix.length()); // depends on control dependency: [if], data = [none]
while (pathWithoutPrefix.startsWith("/") || pathWithoutPrefix.startsWith("\\")) {
pathWithoutPrefix = pathWithoutPrefix.substring(1); // depends on control dependency: [while], data = [none]
}
}
return pathWithoutPrefix;
} } |
public class class_name {
public void setGenre(String genre, int type)
{
if (allow(type&ID3V1))
{
id3v1.setGenreString(genre);
}
if (allow(type&ID3V2))
{
id3v2.setTextFrame(ID3v2Frames.CONTENT_TYPE, genre);
}
} } | public class class_name {
public void setGenre(String genre, int type)
{
if (allow(type&ID3V1))
{
id3v1.setGenreString(genre); // depends on control dependency: [if], data = [none]
}
if (allow(type&ID3V2))
{
id3v2.setTextFrame(ID3v2Frames.CONTENT_TYPE, genre); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static String[] getRootFolders() {
Configuration config = ConfigUtils.getCurrentConfig();
if (config != null) {
return config.getStringArray(ROOT_FOLDERS_CONFIG_KEY);
} else {
return null;
}
} } | public class class_name {
public static String[] getRootFolders() {
Configuration config = ConfigUtils.getCurrentConfig();
if (config != null) {
return config.getStringArray(ROOT_FOLDERS_CONFIG_KEY); // depends on control dependency: [if], data = [none]
} else {
return null; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private void updateMax(int idx, long v) {
AtomicLong current = max.getCurrent(idx);
long m = current.get();
while (v > m) {
if (current.compareAndSet(m, v)) {
break;
}
m = current.get();
}
} } | public class class_name {
private void updateMax(int idx, long v) {
AtomicLong current = max.getCurrent(idx);
long m = current.get();
while (v > m) {
if (current.compareAndSet(m, v)) {
break;
}
m = current.get(); // depends on control dependency: [while], data = [none]
}
} } |
public class class_name {
private static boolean mockitoInvocation(Tree tree, VisitorState state) {
if (!(tree instanceof JCMethodInvocation)) {
return false;
}
JCMethodInvocation invocation = (JCMethodInvocation) tree;
if (!(invocation.getMethodSelect() instanceof JCFieldAccess)) {
return false;
}
ExpressionTree receiver = ASTHelpers.getReceiver(invocation);
return MOCKITO_MATCHER.matches(receiver, state);
} } | public class class_name {
private static boolean mockitoInvocation(Tree tree, VisitorState state) {
if (!(tree instanceof JCMethodInvocation)) {
return false; // depends on control dependency: [if], data = [none]
}
JCMethodInvocation invocation = (JCMethodInvocation) tree;
if (!(invocation.getMethodSelect() instanceof JCFieldAccess)) {
return false; // depends on control dependency: [if], data = [none]
}
ExpressionTree receiver = ASTHelpers.getReceiver(invocation);
return MOCKITO_MATCHER.matches(receiver, state);
} } |
public class class_name {
public static long offset(long[] strides, long[] offsets) {
int ret = 0;
if (ArrayUtil.prod(offsets) == 1) {
for (int i = 0; i < offsets.length; i++) {
ret += offsets[i] * strides[i];
}
} else {
for (int i = 0; i < offsets.length; i++) {
ret += offsets[i] * strides[i];
}
}
return ret;
} } | public class class_name {
public static long offset(long[] strides, long[] offsets) {
int ret = 0;
if (ArrayUtil.prod(offsets) == 1) {
for (int i = 0; i < offsets.length; i++) {
ret += offsets[i] * strides[i]; // depends on control dependency: [for], data = [i]
}
} else {
for (int i = 0; i < offsets.length; i++) {
ret += offsets[i] * strides[i]; // depends on control dependency: [for], data = [i]
}
}
return ret;
} } |
public class class_name {
private static String getRegistrationId(Context context) {
final SharedPreferences prefs = getGcmPreferences(context);
String registrationId = prefs.getString(PROPERTY_REG_ID, "");
if (registrationId.isEmpty()) {
return "";
}
// Check if app was updated; if so, it must clear the registration ID
// since the existing regID is not guaranteed to work with the new
// app version.
int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
int currentVersion = getAppVersion(context);
if (registeredVersion != currentVersion) {
return "";
}
if (OrtcClient.getOnRegistrationId() != null){
OrtcClient.getOnRegistrationId().run(registrationId);
}
return registrationId;
} } | public class class_name {
private static String getRegistrationId(Context context) {
final SharedPreferences prefs = getGcmPreferences(context);
String registrationId = prefs.getString(PROPERTY_REG_ID, "");
if (registrationId.isEmpty()) {
return ""; // depends on control dependency: [if], data = [none]
}
// Check if app was updated; if so, it must clear the registration ID
// since the existing regID is not guaranteed to work with the new
// app version.
int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
int currentVersion = getAppVersion(context);
if (registeredVersion != currentVersion) {
return ""; // depends on control dependency: [if], data = [none]
}
if (OrtcClient.getOnRegistrationId() != null){
OrtcClient.getOnRegistrationId().run(registrationId); // depends on control dependency: [if], data = [none]
}
return registrationId;
} } |
public class class_name {
protected List<String> buildCommand(GitCommitOptions options, String message, List<File> paths) {
// TODO (jhl388): Add a unit test for this method (CliGitCommit.buildCommand()).
List<String> cmd = new ArrayList<String>();
cmd.add(JavaGitConfiguration.getGitCommand());
cmd.add("commit");
if (null != options) {
if (options.isOptAll()) {
cmd.add("-a");
}
if (options.isOptInclude()) {
cmd.add("-i");
}
if (options.isOptNoVerify()) {
cmd.add("--no-verify");
}
if (options.isOptOnly()) {
cmd.add("-o");
}
if (options.isOptSignoff()) {
cmd.add("-s");
}
String author = options.getAuthor();
if (null != author && author.length() > 0) {
cmd.add("--author");
cmd.add(options.getAuthor());
}
}
cmd.add("-m");
cmd.add(message);
if (null != paths) {
cmd.add("--");
for (File f : paths) {
cmd.add(f.getPath());
}
}
return cmd;
} } | public class class_name {
protected List<String> buildCommand(GitCommitOptions options, String message, List<File> paths) {
// TODO (jhl388): Add a unit test for this method (CliGitCommit.buildCommand()).
List<String> cmd = new ArrayList<String>();
cmd.add(JavaGitConfiguration.getGitCommand());
cmd.add("commit");
if (null != options) {
if (options.isOptAll()) {
cmd.add("-a"); // depends on control dependency: [if], data = [none]
}
if (options.isOptInclude()) {
cmd.add("-i"); // depends on control dependency: [if], data = [none]
}
if (options.isOptNoVerify()) {
cmd.add("--no-verify"); // depends on control dependency: [if], data = [none]
}
if (options.isOptOnly()) {
cmd.add("-o"); // depends on control dependency: [if], data = [none]
}
if (options.isOptSignoff()) {
cmd.add("-s"); // depends on control dependency: [if], data = [none]
}
String author = options.getAuthor();
if (null != author && author.length() > 0) {
cmd.add("--author"); // depends on control dependency: [if], data = [none]
cmd.add(options.getAuthor()); // depends on control dependency: [if], data = [none]
}
}
cmd.add("-m");
cmd.add(message);
if (null != paths) {
cmd.add("--"); // depends on control dependency: [if], data = [none]
for (File f : paths) {
cmd.add(f.getPath()); // depends on control dependency: [for], data = [f]
}
}
return cmd;
} } |
public class class_name {
public void appendWorkSheetColumns(WorkSheet worksheet) throws Exception {
ArrayList<String> newColumns = worksheet.getColumns();
this.addColumns(newColumns, "");
ArrayList<String> rows = this.getRows();
for (String row : rows) {
for (String col : newColumns) {
if (worksheet.isValidRow(row)) {
String value = worksheet.getCell(row, col);
this.addCell(row, col, value);
}
}
}
} } | public class class_name {
public void appendWorkSheetColumns(WorkSheet worksheet) throws Exception {
ArrayList<String> newColumns = worksheet.getColumns();
this.addColumns(newColumns, "");
ArrayList<String> rows = this.getRows();
for (String row : rows) {
for (String col : newColumns) {
if (worksheet.isValidRow(row)) {
String value = worksheet.getCell(row, col);
this.addCell(row, col, value); // depends on control dependency: [if], data = [none]
}
}
}
} } |
public class class_name {
public BatchDisableStandardsRequest withStandardsSubscriptionArns(String... standardsSubscriptionArns) {
if (this.standardsSubscriptionArns == null) {
setStandardsSubscriptionArns(new java.util.ArrayList<String>(standardsSubscriptionArns.length));
}
for (String ele : standardsSubscriptionArns) {
this.standardsSubscriptionArns.add(ele);
}
return this;
} } | public class class_name {
public BatchDisableStandardsRequest withStandardsSubscriptionArns(String... standardsSubscriptionArns) {
if (this.standardsSubscriptionArns == null) {
setStandardsSubscriptionArns(new java.util.ArrayList<String>(standardsSubscriptionArns.length)); // depends on control dependency: [if], data = [none]
}
for (String ele : standardsSubscriptionArns) {
this.standardsSubscriptionArns.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public BreakpointInfo copyWithReplaceIdAndUrl(int replaceId, String newUrl) {
final BreakpointInfo info = new BreakpointInfo(replaceId, newUrl, parentFile,
filenameHolder.get(), taskOnlyProvidedParentPath);
info.chunked = this.chunked;
for (BlockInfo blockInfo : blockInfoList) {
info.blockInfoList.add(blockInfo.copy());
}
return info;
} } | public class class_name {
public BreakpointInfo copyWithReplaceIdAndUrl(int replaceId, String newUrl) {
final BreakpointInfo info = new BreakpointInfo(replaceId, newUrl, parentFile,
filenameHolder.get(), taskOnlyProvidedParentPath);
info.chunked = this.chunked;
for (BlockInfo blockInfo : blockInfoList) {
info.blockInfoList.add(blockInfo.copy()); // depends on control dependency: [for], data = [blockInfo]
}
return info;
} } |
public class class_name {
public List<IoDevice> getCompatibleIoDevices() {
List<IoDevice> ioDevices = new LinkedList<IoDevice>();
for (PriorityIoDeviceTuple tuple : mCompatibleDevices) {
ioDevices.add(tuple.getIoDevice());
}
return ioDevices;
} } | public class class_name {
public List<IoDevice> getCompatibleIoDevices() {
List<IoDevice> ioDevices = new LinkedList<IoDevice>();
for (PriorityIoDeviceTuple tuple : mCompatibleDevices) {
ioDevices.add(tuple.getIoDevice()); // depends on control dependency: [for], data = [tuple]
}
return ioDevices;
} } |
public class class_name {
@Override
public boolean hasNext() {
try {
return hasNextValue();
} catch (JsonMappingException e) {
throw new RuntimeJsonMappingException(e.getMessage(), e);
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
} } | public class class_name {
@Override
public boolean hasNext() {
try {
return hasNextValue(); // depends on control dependency: [try], data = [none]
} catch (JsonMappingException e) {
throw new RuntimeJsonMappingException(e.getMessage(), e);
} catch (IOException e) { // depends on control dependency: [catch], data = [none]
throw new RuntimeException(e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
@Override
public void run() {
// early exit check
if (!running) {
return;
}
// this is the means to talk to FlinkKafkaConsumer's main thread
final Handover handover = this.handover;
// This method initializes the KafkaConsumer and guarantees it is torn down properly.
// This is important, because the consumer has multi-threading issues,
// including concurrent 'close()' calls.
try {
this.consumer = getConsumer(kafkaProperties);
}
catch (Throwable t) {
handover.reportError(t);
return;
}
// from here on, the consumer is guaranteed to be closed properly
try {
// register Kafka's very own metrics in Flink's metric reporters
if (useMetrics) {
// register Kafka metrics to Flink
Map<MetricName, ? extends Metric> metrics = consumer.metrics();
if (metrics == null) {
// MapR's Kafka implementation returns null here.
log.info("Consumer implementation does not support metrics");
} else {
// we have Kafka metrics, register them
for (Map.Entry<MetricName, ? extends Metric> metric: metrics.entrySet()) {
consumerMetricGroup.gauge(metric.getKey().name(), new KafkaMetricWrapper(metric.getValue()));
// TODO this metric is kept for compatibility purposes; should remove in the future
subtaskMetricGroup.gauge(metric.getKey().name(), new KafkaMetricWrapper(metric.getValue()));
}
}
}
// early exit check
if (!running) {
return;
}
// the latest bulk of records. May carry across the loop if the thread is woken up
// from blocking on the handover
ConsumerRecords<byte[], byte[]> records = null;
// reused variable to hold found unassigned new partitions.
// found partitions are not carried across loops using this variable;
// they are carried across via re-adding them to the unassigned partitions queue
List<KafkaTopicPartitionState<TopicPartition>> newPartitions;
// main fetch loop
while (running) {
// check if there is something to commit
if (!commitInProgress) {
// get and reset the work-to-be committed, so we don't repeatedly commit the same
final Tuple2<Map<TopicPartition, OffsetAndMetadata>, KafkaCommitCallback> commitOffsetsAndCallback =
nextOffsetsToCommit.getAndSet(null);
if (commitOffsetsAndCallback != null) {
log.debug("Sending async offset commit request to Kafka broker");
// also record that a commit is already in progress
// the order here matters! first set the flag, then send the commit command.
commitInProgress = true;
consumer.commitAsync(commitOffsetsAndCallback.f0, new CommitCallback(commitOffsetsAndCallback.f1));
}
}
try {
if (hasAssignedPartitions) {
newPartitions = unassignedPartitionsQueue.pollBatch();
}
else {
// if no assigned partitions block until we get at least one
// instead of hot spinning this loop. We rely on a fact that
// unassignedPartitionsQueue will be closed on a shutdown, so
// we don't block indefinitely
newPartitions = unassignedPartitionsQueue.getBatchBlocking();
}
if (newPartitions != null) {
reassignPartitions(newPartitions);
}
} catch (AbortedReassignmentException e) {
continue;
}
if (!hasAssignedPartitions) {
// Without assigned partitions KafkaConsumer.poll will throw an exception
continue;
}
// get the next batch of records, unless we did not manage to hand the old batch over
if (records == null) {
try {
records = consumer.poll(pollTimeout);
}
catch (WakeupException we) {
continue;
}
}
try {
handover.produce(records);
records = null;
}
catch (Handover.WakeupException e) {
// fall through the loop
}
}
// end main fetch loop
}
catch (Throwable t) {
// let the main thread know and exit
// it may be that this exception comes because the main thread closed the handover, in
// which case the below reporting is irrelevant, but does not hurt either
handover.reportError(t);
}
finally {
// make sure the handover is closed if it is not already closed or has an error
handover.close();
// make sure the KafkaConsumer is closed
try {
consumer.close();
}
catch (Throwable t) {
log.warn("Error while closing Kafka consumer", t);
}
}
} } | public class class_name {
@Override
public void run() {
// early exit check
if (!running) {
return; // depends on control dependency: [if], data = [none]
}
// this is the means to talk to FlinkKafkaConsumer's main thread
final Handover handover = this.handover;
// This method initializes the KafkaConsumer and guarantees it is torn down properly.
// This is important, because the consumer has multi-threading issues,
// including concurrent 'close()' calls.
try {
this.consumer = getConsumer(kafkaProperties); // depends on control dependency: [try], data = [none]
}
catch (Throwable t) {
handover.reportError(t);
return;
} // depends on control dependency: [catch], data = [none]
// from here on, the consumer is guaranteed to be closed properly
try {
// register Kafka's very own metrics in Flink's metric reporters
if (useMetrics) {
// register Kafka metrics to Flink
Map<MetricName, ? extends Metric> metrics = consumer.metrics();
if (metrics == null) {
// MapR's Kafka implementation returns null here.
log.info("Consumer implementation does not support metrics"); // depends on control dependency: [if], data = [none]
} else {
// we have Kafka metrics, register them
for (Map.Entry<MetricName, ? extends Metric> metric: metrics.entrySet()) {
consumerMetricGroup.gauge(metric.getKey().name(), new KafkaMetricWrapper(metric.getValue())); // depends on control dependency: [for], data = [metric]
// TODO this metric is kept for compatibility purposes; should remove in the future
subtaskMetricGroup.gauge(metric.getKey().name(), new KafkaMetricWrapper(metric.getValue())); // depends on control dependency: [for], data = [metric]
}
}
}
// early exit check
if (!running) {
return; // depends on control dependency: [if], data = [none]
}
// the latest bulk of records. May carry across the loop if the thread is woken up
// from blocking on the handover
ConsumerRecords<byte[], byte[]> records = null;
// reused variable to hold found unassigned new partitions.
// found partitions are not carried across loops using this variable;
// they are carried across via re-adding them to the unassigned partitions queue
List<KafkaTopicPartitionState<TopicPartition>> newPartitions;
// main fetch loop
while (running) {
// check if there is something to commit
if (!commitInProgress) {
// get and reset the work-to-be committed, so we don't repeatedly commit the same
final Tuple2<Map<TopicPartition, OffsetAndMetadata>, KafkaCommitCallback> commitOffsetsAndCallback =
nextOffsetsToCommit.getAndSet(null);
if (commitOffsetsAndCallback != null) {
log.debug("Sending async offset commit request to Kafka broker"); // depends on control dependency: [if], data = [none]
// also record that a commit is already in progress
// the order here matters! first set the flag, then send the commit command.
commitInProgress = true; // depends on control dependency: [if], data = [none]
consumer.commitAsync(commitOffsetsAndCallback.f0, new CommitCallback(commitOffsetsAndCallback.f1)); // depends on control dependency: [if], data = [(commitOffsetsAndCallback]
}
}
try {
if (hasAssignedPartitions) {
newPartitions = unassignedPartitionsQueue.pollBatch(); // depends on control dependency: [if], data = [none]
}
else {
// if no assigned partitions block until we get at least one
// instead of hot spinning this loop. We rely on a fact that
// unassignedPartitionsQueue will be closed on a shutdown, so
// we don't block indefinitely
newPartitions = unassignedPartitionsQueue.getBatchBlocking(); // depends on control dependency: [if], data = [none]
}
if (newPartitions != null) {
reassignPartitions(newPartitions); // depends on control dependency: [if], data = [(newPartitions]
}
} catch (AbortedReassignmentException e) {
continue;
} // depends on control dependency: [catch], data = [none]
if (!hasAssignedPartitions) {
// Without assigned partitions KafkaConsumer.poll will throw an exception
continue;
}
// get the next batch of records, unless we did not manage to hand the old batch over
if (records == null) {
try {
records = consumer.poll(pollTimeout); // depends on control dependency: [try], data = [none]
}
catch (WakeupException we) {
continue;
} // depends on control dependency: [catch], data = [none]
}
try {
handover.produce(records); // depends on control dependency: [try], data = [none]
records = null; // depends on control dependency: [try], data = [none]
}
catch (Handover.WakeupException e) {
// fall through the loop
} // depends on control dependency: [catch], data = [none]
}
// end main fetch loop
}
catch (Throwable t) {
// let the main thread know and exit
// it may be that this exception comes because the main thread closed the handover, in
// which case the below reporting is irrelevant, but does not hurt either
handover.reportError(t);
} // depends on control dependency: [catch], data = [none]
finally {
// make sure the handover is closed if it is not already closed or has an error
handover.close();
// make sure the KafkaConsumer is closed
try {
consumer.close(); // depends on control dependency: [try], data = [none]
}
catch (Throwable t) {
log.warn("Error while closing Kafka consumer", t);
} // depends on control dependency: [catch], data = [none]
}
} } |
public class class_name {
private static boolean polygonContainsEnvelope_(Polygon polygon_a,
Envelope envelope_b, double tolerance,
ProgressTracker progress_tracker) {
// Quick envelope rejection test
Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
polygon_a.queryEnvelope2D(env_a);
envelope_b.queryEnvelope2D(env_b);
if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance))
return false;
// Quick rasterize test to see whether the the geometries are disjoint,
// or if one is contained in the other.
int relation = tryRasterizedContainsOrDisjoint_(polygon_a, envelope_b,
tolerance, false);
if (relation == Relation.disjoint || relation == Relation.within)
return false;
if (relation == Relation.contains)
return true;
if (env_b.getWidth() <= tolerance && env_b.getHeight() <= tolerance) {// treat
// as
// point
Point2D pt_b = envelope_b.getCenterXY();
return polygonContainsPointImpl_(polygon_a, pt_b, tolerance,
progress_tracker);
}
if (env_b.getWidth() <= tolerance || env_b.getHeight() <= tolerance) {// treat
// as
// polyline
Polyline polyline_b = new Polyline();
Point p = new Point();
envelope_b.queryCornerByVal(0, p);
polyline_b.startPath(p);
envelope_b.queryCornerByVal(2, p);
polyline_b.lineTo(p);
return polygonContainsPolylineImpl_(polygon_a, polyline_b,
tolerance, null);
}
// treat as polygon
Polygon polygon_b = new Polygon();
polygon_b.addEnvelope(envelope_b, false);
return polygonContainsPolygonImpl_(polygon_a, polygon_b, tolerance,
null);
} } | public class class_name {
private static boolean polygonContainsEnvelope_(Polygon polygon_a,
Envelope envelope_b, double tolerance,
ProgressTracker progress_tracker) {
// Quick envelope rejection test
Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
polygon_a.queryEnvelope2D(env_a);
envelope_b.queryEnvelope2D(env_b);
if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance))
return false;
// Quick rasterize test to see whether the the geometries are disjoint,
// or if one is contained in the other.
int relation = tryRasterizedContainsOrDisjoint_(polygon_a, envelope_b,
tolerance, false);
if (relation == Relation.disjoint || relation == Relation.within)
return false;
if (relation == Relation.contains)
return true;
if (env_b.getWidth() <= tolerance && env_b.getHeight() <= tolerance) {// treat
// as
// point
Point2D pt_b = envelope_b.getCenterXY();
return polygonContainsPointImpl_(polygon_a, pt_b, tolerance,
progress_tracker); // depends on control dependency: [if], data = [none]
}
if (env_b.getWidth() <= tolerance || env_b.getHeight() <= tolerance) {// treat
// as
// polyline
Polyline polyline_b = new Polyline();
Point p = new Point();
envelope_b.queryCornerByVal(0, p); // depends on control dependency: [if], data = [none]
polyline_b.startPath(p); // depends on control dependency: [if], data = [none]
envelope_b.queryCornerByVal(2, p); // depends on control dependency: [if], data = [none]
polyline_b.lineTo(p); // depends on control dependency: [if], data = [none]
return polygonContainsPolylineImpl_(polygon_a, polyline_b,
tolerance, null); // depends on control dependency: [if], data = [none]
}
// treat as polygon
Polygon polygon_b = new Polygon();
polygon_b.addEnvelope(envelope_b, false);
return polygonContainsPolygonImpl_(polygon_a, polygon_b, tolerance,
null);
} } |
public class class_name {
public static String clientOS(HttpServletRequest req) {
String userAgent = req.getHeader("User-Agent");
String cos = "unknow os";
Pattern p = Pattern.compile(".*(Windows NT 6\\.2).*");
Matcher m = p.matcher(userAgent);
if (m.find()) {
cos = "Win 8";
return cos;
}
p = Pattern.compile(".*(Windows NT 6\\.1).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Win 7";
return cos;
}
p = Pattern.compile(".*(Windows NT 5\\.1|Windows XP).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "WinXP";
return cos;
}
p = Pattern.compile(".*(Windows NT 5\\.2).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Win2003";
return cos;
}
p = Pattern.compile(".*(Win2000|Windows 2000|Windows NT 5\\.0).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Win2000";
return cos;
}
p = Pattern.compile(".*(Mac|apple|MacOS8).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "MAC";
return cos;
}
p = Pattern.compile(".*(WinNT|Windows NT).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "WinNT";
return cos;
}
p = Pattern.compile(".*Linux.*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Linux";
return cos;
}
p = Pattern.compile(".*(68k|68000).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Mac68k";
return cos;
}
p = Pattern
.compile(".*(9x 4.90|Win9(5|8)|Windows 9(5|8)|95/NT|Win32|32bit).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Win9x";
return cos;
}
return cos;
} } | public class class_name {
public static String clientOS(HttpServletRequest req) {
String userAgent = req.getHeader("User-Agent");
String cos = "unknow os";
Pattern p = Pattern.compile(".*(Windows NT 6\\.2).*");
Matcher m = p.matcher(userAgent);
if (m.find()) {
cos = "Win 8"; // depends on control dependency: [if], data = [none]
return cos; // depends on control dependency: [if], data = [none]
}
p = Pattern.compile(".*(Windows NT 6\\.1).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Win 7"; // depends on control dependency: [if], data = [none]
return cos; // depends on control dependency: [if], data = [none]
}
p = Pattern.compile(".*(Windows NT 5\\.1|Windows XP).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "WinXP"; // depends on control dependency: [if], data = [none]
return cos; // depends on control dependency: [if], data = [none]
}
p = Pattern.compile(".*(Windows NT 5\\.2).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Win2003"; // depends on control dependency: [if], data = [none]
return cos; // depends on control dependency: [if], data = [none]
}
p = Pattern.compile(".*(Win2000|Windows 2000|Windows NT 5\\.0).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Win2000"; // depends on control dependency: [if], data = [none]
return cos; // depends on control dependency: [if], data = [none]
}
p = Pattern.compile(".*(Mac|apple|MacOS8).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "MAC"; // depends on control dependency: [if], data = [none]
return cos; // depends on control dependency: [if], data = [none]
}
p = Pattern.compile(".*(WinNT|Windows NT).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "WinNT"; // depends on control dependency: [if], data = [none]
return cos; // depends on control dependency: [if], data = [none]
}
p = Pattern.compile(".*Linux.*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Linux"; // depends on control dependency: [if], data = [none]
return cos; // depends on control dependency: [if], data = [none]
}
p = Pattern.compile(".*(68k|68000).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Mac68k"; // depends on control dependency: [if], data = [none]
return cos; // depends on control dependency: [if], data = [none]
}
p = Pattern
.compile(".*(9x 4.90|Win9(5|8)|Windows 9(5|8)|95/NT|Win32|32bit).*");
m = p.matcher(userAgent);
if (m.find()) {
cos = "Win9x"; // depends on control dependency: [if], data = [none]
return cos; // depends on control dependency: [if], data = [none]
}
return cos;
} } |
public class class_name {
public static void serializeTo( AbstractMessage message , RawDataBuffer out )
{
// Do we have a cached version of the raw message ?
RawDataBuffer rawMsg = message.getRawMessage();
if (rawMsg != null)
{
out.writeInt(rawMsg.size());
rawMsg.writeTo(out);
}
else
{
// Serialize the message
out.writeInt(0); // Write a dummy size
int startPos = out.size();
out.writeByte(message.getType());
message.serializeTo(out);
int endPos = out.size();
out.writeInt(endPos-startPos,startPos-4); // Update the actual size
}
} } | public class class_name {
public static void serializeTo( AbstractMessage message , RawDataBuffer out )
{
// Do we have a cached version of the raw message ?
RawDataBuffer rawMsg = message.getRawMessage();
if (rawMsg != null)
{
out.writeInt(rawMsg.size()); // depends on control dependency: [if], data = [(rawMsg]
rawMsg.writeTo(out); // depends on control dependency: [if], data = [none]
}
else
{
// Serialize the message
out.writeInt(0); // Write a dummy size // depends on control dependency: [if], data = [none]
int startPos = out.size();
out.writeByte(message.getType()); // depends on control dependency: [if], data = [none]
message.serializeTo(out); // depends on control dependency: [if], data = [none]
int endPos = out.size();
out.writeInt(endPos-startPos,startPos-4); // Update the actual size // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public Optional<? extends MethodExecutionHandle<?, Object>> findFallbackMethod(MethodInvocationContext<Object, Object> context) {
Class<?> declaringType = context.getDeclaringType();
Optional<? extends MethodExecutionHandle<?, Object>> result = beanContext
.findExecutionHandle(declaringType, Qualifiers.byStereotype(Fallback.class), context.getMethodName(), context.getArgumentTypes());
if (!result.isPresent()) {
Set<Class> allInterfaces = ReflectionUtils.getAllInterfaces(declaringType);
for (Class i : allInterfaces) {
result = beanContext
.findExecutionHandle(i, Qualifiers.byStereotype(Fallback.class), context.getMethodName(), context.getArgumentTypes());
if (result.isPresent()) {
return result;
}
}
}
return result;
} } | public class class_name {
public Optional<? extends MethodExecutionHandle<?, Object>> findFallbackMethod(MethodInvocationContext<Object, Object> context) {
Class<?> declaringType = context.getDeclaringType();
Optional<? extends MethodExecutionHandle<?, Object>> result = beanContext
.findExecutionHandle(declaringType, Qualifiers.byStereotype(Fallback.class), context.getMethodName(), context.getArgumentTypes());
if (!result.isPresent()) {
Set<Class> allInterfaces = ReflectionUtils.getAllInterfaces(declaringType);
for (Class i : allInterfaces) {
result = beanContext
.findExecutionHandle(i, Qualifiers.byStereotype(Fallback.class), context.getMethodName(), context.getArgumentTypes()); // depends on control dependency: [for], data = [none]
if (result.isPresent()) {
return result; // depends on control dependency: [if], data = [none]
}
}
}
return result;
} } |
public class class_name {
private void convertColumnType(final int columnIndex, final Class<?> targetType) {
final List<Object> column = _columnList.get(columnIndex);
Object newValue = null;
for (int i = 0, len = size(); i < len; i++) {
newValue = N.convert(column.get(i), targetType);
column.set(i, newValue);
}
modCount++;
} } | public class class_name {
private void convertColumnType(final int columnIndex, final Class<?> targetType) {
final List<Object> column = _columnList.get(columnIndex);
Object newValue = null;
for (int i = 0, len = size(); i < len; i++) {
newValue = N.convert(column.get(i), targetType);
// depends on control dependency: [for], data = [i]
column.set(i, newValue);
// depends on control dependency: [for], data = [i]
}
modCount++;
} } |
public class class_name {
public OAuthAccessToken getAccessToken(Token requestToken, String verificationCode) throws JinxException {
JinxUtils.validateParams(requestToken, verificationCode);
try {
Verifier verifier = new Verifier(verificationCode);
Token accessToken = this.oAuthService.getAccessToken(requestToken, verifier);
if (accessToken != null) {
this.oAuthAccessToken = new OAuthAccessToken();
this.oAuthAccessToken.setOauthToken(accessToken.getToken());
this.oAuthAccessToken.setOauthTokenSecret(accessToken.getSecret());
// parse the raw response to get nsid, username, fullname
// flickr response looks like this:
// fullname=Jeremy%20Brooks&oauth_token=72157632924811715-b9b1f0bf94982fba&oauth_token_secret=d25a168a2e923649&user_nsid=85853333%40N00&username=Jeremy%20Brooks
StringTokenizer tok = new StringTokenizer(accessToken.getRawResponse(), "&");
while (tok.hasMoreTokens()) {
String token = tok.nextToken();
int index = token.indexOf("=");
String key = token.substring(0, index);
String value = URLDecoder.decode(token.substring(index + 1), "UTF-8").trim();
if (key.equals("fullname")) {
this.oAuthAccessToken.setFullname(value);
} else if (key.equals("user_nsid")) {
this.oAuthAccessToken.setNsid(value);
} else if (key.equals("username")) {
this.oAuthAccessToken.setUsername(value);
}
}
}
} catch (Exception e) {
throw new JinxException("Error while getting access token.", e);
}
return this.oAuthAccessToken;
} } | public class class_name {
public OAuthAccessToken getAccessToken(Token requestToken, String verificationCode) throws JinxException {
JinxUtils.validateParams(requestToken, verificationCode);
try {
Verifier verifier = new Verifier(verificationCode);
Token accessToken = this.oAuthService.getAccessToken(requestToken, verifier);
if (accessToken != null) {
this.oAuthAccessToken = new OAuthAccessToken(); // depends on control dependency: [if], data = [none]
this.oAuthAccessToken.setOauthToken(accessToken.getToken()); // depends on control dependency: [if], data = [(accessToken]
this.oAuthAccessToken.setOauthTokenSecret(accessToken.getSecret()); // depends on control dependency: [if], data = [(accessToken]
// parse the raw response to get nsid, username, fullname
// flickr response looks like this:
// fullname=Jeremy%20Brooks&oauth_token=72157632924811715-b9b1f0bf94982fba&oauth_token_secret=d25a168a2e923649&user_nsid=85853333%40N00&username=Jeremy%20Brooks
StringTokenizer tok = new StringTokenizer(accessToken.getRawResponse(), "&");
while (tok.hasMoreTokens()) {
String token = tok.nextToken();
int index = token.indexOf("=");
String key = token.substring(0, index);
String value = URLDecoder.decode(token.substring(index + 1), "UTF-8").trim();
if (key.equals("fullname")) {
this.oAuthAccessToken.setFullname(value); // depends on control dependency: [if], data = [none]
} else if (key.equals("user_nsid")) {
this.oAuthAccessToken.setNsid(value); // depends on control dependency: [if], data = [none]
} else if (key.equals("username")) {
this.oAuthAccessToken.setUsername(value); // depends on control dependency: [if], data = [none]
}
}
}
} catch (Exception e) {
throw new JinxException("Error while getting access token.", e);
}
return this.oAuthAccessToken;
} } |
public class class_name {
public void addProfile(Profile profile) {
if (PROFILE_KIND.equals(profile.getKind())) {
this.profileList.add(profile.getSettings());
}
} } | public class class_name {
public void addProfile(Profile profile) {
if (PROFILE_KIND.equals(profile.getKind())) {
this.profileList.add(profile.getSettings()); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private String escapeQuotes(String value)
{
StringBuilder sb = new StringBuilder();
int length = value.length();
char c;
sb.append('"');
for (int index = 0; index < length; index++)
{
c = value.charAt(index);
sb.append(c);
if (c == '"')
{
sb.append('"');
}
}
sb.append('"');
return (sb.toString());
} } | public class class_name {
private String escapeQuotes(String value)
{
StringBuilder sb = new StringBuilder();
int length = value.length();
char c;
sb.append('"');
for (int index = 0; index < length; index++)
{
c = value.charAt(index); // depends on control dependency: [for], data = [index]
sb.append(c); // depends on control dependency: [for], data = [none]
if (c == '"')
{
sb.append('"'); // depends on control dependency: [if], data = ['"')]
}
}
sb.append('"');
return (sb.toString());
} } |
public class class_name {
public FlatDataList getXColumn(Object column) {
FlatDataList flatDataList = new FlatDataList();
for(Record r : values()) {
flatDataList.add(r.getX().get(column));
}
return flatDataList;
} } | public class class_name {
public FlatDataList getXColumn(Object column) {
FlatDataList flatDataList = new FlatDataList();
for(Record r : values()) {
flatDataList.add(r.getX().get(column)); // depends on control dependency: [for], data = [r]
}
return flatDataList;
} } |
public class class_name {
@Override
public StringBuffer format(android.icu.math.BigDecimal number,
StringBuffer toAppendTo,
FieldPosition pos) {
if (MIN_VALUE.compareTo(number) >= 0 || MAX_VALUE.compareTo(number) <= 0) {
// We're outside of our normal range that this framework can handle.
// The DecimalFormat will provide more accurate results.
return getDecimalFormat().format(number, toAppendTo, pos);
}
if (number.scale() == 0) {
return format(number.longValue(), toAppendTo, pos);
}
return format(number.doubleValue(), toAppendTo, pos);
} } | public class class_name {
@Override
public StringBuffer format(android.icu.math.BigDecimal number,
StringBuffer toAppendTo,
FieldPosition pos) {
if (MIN_VALUE.compareTo(number) >= 0 || MAX_VALUE.compareTo(number) <= 0) {
// We're outside of our normal range that this framework can handle.
// The DecimalFormat will provide more accurate results.
return getDecimalFormat().format(number, toAppendTo, pos); // depends on control dependency: [if], data = [none]
}
if (number.scale() == 0) {
return format(number.longValue(), toAppendTo, pos); // depends on control dependency: [if], data = [none]
}
return format(number.doubleValue(), toAppendTo, pos);
} } |
public class class_name {
public static void useGeneratedKeys(XmlElement element, IntrospectedTable introspectedTable, String prefix) {
GeneratedKey gk = introspectedTable.getGeneratedKey();
if (gk != null) {
IntrospectedColumn introspectedColumn = IntrospectedTableTools.safeGetColumn(introspectedTable, gk.getColumn());
// if the column is null, then it's a configuration error. The
// warning has already been reported
if (introspectedColumn != null) {
// 使用JDBC的getGenereatedKeys方法获取主键并赋值到keyProperty设置的领域模型属性中。所以只支持MYSQL和SQLServer
element.addAttribute(new Attribute("useGeneratedKeys", "true"));
element.addAttribute(new Attribute("keyProperty", (prefix == null ? "" : prefix) + introspectedColumn.getJavaProperty()));
element.addAttribute(new Attribute("keyColumn", introspectedColumn.getActualColumnName()));
}
}
} } | public class class_name {
public static void useGeneratedKeys(XmlElement element, IntrospectedTable introspectedTable, String prefix) {
GeneratedKey gk = introspectedTable.getGeneratedKey();
if (gk != null) {
IntrospectedColumn introspectedColumn = IntrospectedTableTools.safeGetColumn(introspectedTable, gk.getColumn());
// if the column is null, then it's a configuration error. The
// warning has already been reported
if (introspectedColumn != null) {
// 使用JDBC的getGenereatedKeys方法获取主键并赋值到keyProperty设置的领域模型属性中。所以只支持MYSQL和SQLServer
element.addAttribute(new Attribute("useGeneratedKeys", "true")); // depends on control dependency: [if], data = [none]
element.addAttribute(new Attribute("keyProperty", (prefix == null ? "" : prefix) + introspectedColumn.getJavaProperty())); // depends on control dependency: [if], data = [none]
element.addAttribute(new Attribute("keyColumn", introspectedColumn.getActualColumnName())); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public static int lastIndexOfSeparator(String filePath) {
if (StrUtil.isNotEmpty(filePath)) {
int i = filePath.length();
char c;
while (--i >= 0) {
c = filePath.charAt(i);
if (CharUtil.isFileSeparator(c)) {
return i;
}
}
}
return -1;
} } | public class class_name {
public static int lastIndexOfSeparator(String filePath) {
if (StrUtil.isNotEmpty(filePath)) {
int i = filePath.length();
char c;
while (--i >= 0) {
c = filePath.charAt(i);
// depends on control dependency: [while], data = [none]
if (CharUtil.isFileSeparator(c)) {
return i;
// depends on control dependency: [if], data = [none]
}
}
}
return -1;
} } |
public class class_name {
public void validate(String destName, String busName) throws SINotPossibleInCurrentConfigurationException
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "validate", new Object[] { destName, busName });
if (collector.contains(destName, busName))
{
// Throw out exception detailing loop
// Add the destination name which has triggered the exception to the end
// of the list, making the problem obvious.
String chainText = toStringPlus(destName, busName);
CompoundName firstInChain = getFirstInChain();
String nlsMessage = nls.getFormattedMessage(
"ALIAS_CIRCULAR_DEPENDENCY_ERROR_CWSIP0621",
new Object[] { firstInChain, chainText, busName },
null);
SINotPossibleInCurrentConfigurationException e
= new SINotPossibleInCurrentConfigurationException(nlsMessage);
SibTr.exception(tc, e);
if (tc.isEntryEnabled())
SibTr.exit(tc, "validate", nlsMessage);
throw e;
}
collector.add(destName, busName);
if (tc.isEntryEnabled())
SibTr.exit(tc, "validate");
} } | public class class_name {
public void validate(String destName, String busName) throws SINotPossibleInCurrentConfigurationException
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "validate", new Object[] { destName, busName });
if (collector.contains(destName, busName))
{
// Throw out exception detailing loop
// Add the destination name which has triggered the exception to the end
// of the list, making the problem obvious.
String chainText = toStringPlus(destName, busName);
CompoundName firstInChain = getFirstInChain();
String nlsMessage = nls.getFormattedMessage(
"ALIAS_CIRCULAR_DEPENDENCY_ERROR_CWSIP0621",
new Object[] { firstInChain, chainText, busName },
null);
SINotPossibleInCurrentConfigurationException e
= new SINotPossibleInCurrentConfigurationException(nlsMessage);
SibTr.exception(tc, e); // depends on control dependency: [if], data = [none]
if (tc.isEntryEnabled())
SibTr.exit(tc, "validate", nlsMessage);
throw e;
}
collector.add(destName, busName);
if (tc.isEntryEnabled())
SibTr.exit(tc, "validate");
} } |
public class class_name {
public boolean add(Object listener) {
if (listener == null) {
return false;
}
checkListenerType(listener);
synchronized (this) {
if (listeners == EMPTY_OBJECT_ARRAY) {
listeners = new Object[] { listener };
}
else {
int listenersLength = listeners.length;
for (int i = 0; i < listenersLength; i++) {
if (listeners[i] == listener) {
return false;
}
}
Object[] tmp = new Object[listenersLength + 1];
tmp[listenersLength] = listener;
System.arraycopy(listeners, 0, tmp, 0, listenersLength);
listeners = tmp;
}
}
return true;
} } | public class class_name {
public boolean add(Object listener) {
if (listener == null) {
return false; // depends on control dependency: [if], data = [none]
}
checkListenerType(listener);
synchronized (this) {
if (listeners == EMPTY_OBJECT_ARRAY) {
listeners = new Object[] { listener }; // depends on control dependency: [if], data = [none]
}
else {
int listenersLength = listeners.length;
for (int i = 0; i < listenersLength; i++) {
if (listeners[i] == listener) {
return false; // depends on control dependency: [if], data = [none]
}
}
Object[] tmp = new Object[listenersLength + 1];
tmp[listenersLength] = listener; // depends on control dependency: [if], data = [none]
System.arraycopy(listeners, 0, tmp, 0, listenersLength); // depends on control dependency: [if], data = [(listeners]
listeners = tmp; // depends on control dependency: [if], data = [none]
}
}
return true;
} } |
public class class_name {
public static boolean isFraction(final String text, final int start, final int len){
if(len < 3){
return false;
}
int index = -1;
for(int i=start; i<start+len; i++){
char c = text.charAt(i);
if(c=='.' || c=='/' || c=='/' || c=='.' || c=='·'){
index = i;
break;
}
}
if(index == -1 || index == start || index == start+len-1){
return false;
}
int beforeLen = index-start;
return isNumber(text, start, beforeLen) && isNumber(text, index+1, len-(beforeLen+1));
} } | public class class_name {
public static boolean isFraction(final String text, final int start, final int len){
if(len < 3){
return false; // depends on control dependency: [if], data = [none]
}
int index = -1;
for(int i=start; i<start+len; i++){
char c = text.charAt(i);
if(c=='.' || c=='/' || c=='/' || c=='.' || c=='·'){
index = i; // depends on control dependency: [if], data = [none]
break;
}
}
if(index == -1 || index == start || index == start+len-1){
return false; // depends on control dependency: [if], data = [none]
}
int beforeLen = index-start;
return isNumber(text, start, beforeLen) && isNumber(text, index+1, len-(beforeLen+1));
} } |
public class class_name {
protected void removeWorkspace(ManageableRepository mr, String workspaceName) throws RepositoryException
{
boolean isExists = false;
for (String wsName : mr.getWorkspaceNames())
if (workspaceName.equals(wsName))
{
isExists = true;
break;
}
if (isExists)
{
if (!mr.canRemoveWorkspace(workspaceName))
{
WorkspaceContainerFacade wc = mr.getWorkspaceContainer(workspaceName);
SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
sessionRegistry.closeSessions(workspaceName);
}
mr.removeWorkspace(workspaceName);
}
} } | public class class_name {
protected void removeWorkspace(ManageableRepository mr, String workspaceName) throws RepositoryException
{
boolean isExists = false;
for (String wsName : mr.getWorkspaceNames())
if (workspaceName.equals(wsName))
{
isExists = true;
break;
}
if (isExists)
{
if (!mr.canRemoveWorkspace(workspaceName))
{
WorkspaceContainerFacade wc = mr.getWorkspaceContainer(workspaceName);
SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
sessionRegistry.closeSessions(workspaceName); // depends on control dependency: [if], data = [none]
}
mr.removeWorkspace(workspaceName);
}
} } |
public class class_name {
public synchronized void start(final StartContext context) throws StartException {
final JMSServerManager jmsManager = jmsServer.getValue();
final Runnable task = new Runnable() {
@Override
public void run() {
try {
jmsManager.createConnectionFactory(false, configuration, configuration.getBindings());
context.complete();
} catch (Throwable e) {
context.failed(MessagingLogger.ROOT_LOGGER.failedToCreate(e, "connection-factory"));
}
}
};
try {
executorInjector.getValue().execute(task);
} catch (RejectedExecutionException e) {
task.run();
} finally {
context.asynchronous();
}
} } | public class class_name {
public synchronized void start(final StartContext context) throws StartException {
final JMSServerManager jmsManager = jmsServer.getValue();
final Runnable task = new Runnable() {
@Override
public void run() {
try {
jmsManager.createConnectionFactory(false, configuration, configuration.getBindings()); // depends on control dependency: [try], data = [none]
context.complete(); // depends on control dependency: [try], data = [none]
} catch (Throwable e) {
context.failed(MessagingLogger.ROOT_LOGGER.failedToCreate(e, "connection-factory"));
} // depends on control dependency: [catch], data = [none]
}
};
try {
executorInjector.getValue().execute(task);
} catch (RejectedExecutionException e) {
task.run();
} finally {
context.asynchronous();
}
} } |
public class class_name {
@Override
protected void channelSelectorClose() {
synchronized (wqm.shutdownSync) {
try {
selector.close();
} catch (IOException e) {
// No FFDC code or exception handling needed since we are shutting down
}
// mark this channel's CS index as inactive.
// This index will now available for a new CS entry.
wqm.updateCount(countIndex, WorkQueueManager.CS_NULL, channelType);
}
} } | public class class_name {
@Override
protected void channelSelectorClose() {
synchronized (wqm.shutdownSync) {
try {
selector.close(); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
// No FFDC code or exception handling needed since we are shutting down
} // depends on control dependency: [catch], data = [none]
// mark this channel's CS index as inactive.
// This index will now available for a new CS entry.
wqm.updateCount(countIndex, WorkQueueManager.CS_NULL, channelType);
}
} } |
public class class_name {
private boolean rule5(double sample) {
if (!hasMean()) {
return false;
}
if (rule5LastThree.size() == 3) {
switch (rule5LastThree.removeLast()) {
case ">":
--rule5Above;
break;
case "<":
--rule5Below;
break;
}
}
if (Math.abs(sample - mean.getResult()) > twoDeviations) {
if (sample > mean.getResult()) {
++rule5Above;
rule5LastThree.push(">");
} else {
++rule5Below;
rule5LastThree.push("<");
}
} else {
rule5LastThree.push("");
}
return rule5Above >= 2 || rule5Below >= 2;
} } | public class class_name {
private boolean rule5(double sample) {
if (!hasMean()) {
return false; // depends on control dependency: [if], data = [none]
}
if (rule5LastThree.size() == 3) {
switch (rule5LastThree.removeLast()) {
case ">":
--rule5Above;
break;
case "<":
--rule5Below;
break;
}
}
if (Math.abs(sample - mean.getResult()) > twoDeviations) {
if (sample > mean.getResult()) {
++rule5Above; // depends on control dependency: [if], data = [none]
rule5LastThree.push(">"); // depends on control dependency: [if], data = [none]
} else {
++rule5Below; // depends on control dependency: [if], data = [none]
rule5LastThree.push("<"); // depends on control dependency: [if], data = [none]
}
} else {
rule5LastThree.push(""); // depends on control dependency: [if], data = [none]
}
return rule5Above >= 2 || rule5Below >= 2;
} } |
public class class_name {
public void setEmailTags(java.util.Collection<MessageTag> emailTags) {
if (emailTags == null) {
this.emailTags = null;
return;
}
this.emailTags = new java.util.ArrayList<MessageTag>(emailTags);
} } | public class class_name {
public void setEmailTags(java.util.Collection<MessageTag> emailTags) {
if (emailTags == null) {
this.emailTags = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.emailTags = new java.util.ArrayList<MessageTag>(emailTags);
} } |
public class class_name {
public static BufferedImage loadImage(InputStream is){
try {
BufferedImage bimg = ImageIO.read(is);
if(bimg == null){
throw new ImageLoaderException("Could not load Image! ImageIO.read() returned null.");
}
return bimg;
} catch (IOException e) {
throw new ImageLoaderException(e);
}
} } | public class class_name {
public static BufferedImage loadImage(InputStream is){
try {
BufferedImage bimg = ImageIO.read(is);
if(bimg == null){
throw new ImageLoaderException("Could not load Image! ImageIO.read() returned null.");
}
return bimg; // depends on control dependency: [try], data = [none]
} catch (IOException e) {
throw new ImageLoaderException(e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private void getResPathKeys(String[] keys, int depth) {
ICUResourceBundle b = this;
while (depth > 0) {
keys[--depth] = b.key;
b = b.container;
assert (depth == 0) == (b.container == null);
}
} } | public class class_name {
private void getResPathKeys(String[] keys, int depth) {
ICUResourceBundle b = this;
while (depth > 0) {
keys[--depth] = b.key; // depends on control dependency: [while], data = [none]
b = b.container; // depends on control dependency: [while], data = [none]
assert (depth == 0) == (b.container == null); // depends on control dependency: [while], data = [(depth]
}
} } |
public class class_name {
private InternalCacheEntry<WrappedBytes, WrappedBytes> performRemove(long bucketHeadAddress, long actualAddress,
WrappedBytes key, WrappedBytes value, boolean requireReturn) {
long prevAddress = 0;
// We only use the head pointer for the first iteration
long address = bucketHeadAddress;
InternalCacheEntry<WrappedBytes, WrappedBytes> ice = null;
while (address != 0) {
long nextAddress = offHeapEntryFactory.getNext(address);
boolean removeThisAddress;
// If the actualAddress was not known, check key equality otherwise just compare with the address
removeThisAddress = actualAddress == 0 ? offHeapEntryFactory.equalsKey(address, key) : actualAddress == address;
if (removeThisAddress) {
if (value != null) {
ice = offHeapEntryFactory.fromMemory(address);
// If value doesn't match and was provided then don't remove it
if (!value.equalsWrappedBytes(ice.getValue())) {
ice = null;
break;
}
}
if (requireReturn && ice == null) {
ice = offHeapEntryFactory.fromMemory(address);
}
entryRemoved(address);
if (prevAddress != 0) {
offHeapEntryFactory.setNext(prevAddress, nextAddress);
} else {
memoryLookup.putMemoryAddress(key, nextAddress);
}
size.decrementAndGet();
break;
}
prevAddress = address;
address = nextAddress;
}
return ice;
} } | public class class_name {
private InternalCacheEntry<WrappedBytes, WrappedBytes> performRemove(long bucketHeadAddress, long actualAddress,
WrappedBytes key, WrappedBytes value, boolean requireReturn) {
long prevAddress = 0;
// We only use the head pointer for the first iteration
long address = bucketHeadAddress;
InternalCacheEntry<WrappedBytes, WrappedBytes> ice = null;
while (address != 0) {
long nextAddress = offHeapEntryFactory.getNext(address);
boolean removeThisAddress;
// If the actualAddress was not known, check key equality otherwise just compare with the address
removeThisAddress = actualAddress == 0 ? offHeapEntryFactory.equalsKey(address, key) : actualAddress == address; // depends on control dependency: [while], data = [(address]
if (removeThisAddress) {
if (value != null) {
ice = offHeapEntryFactory.fromMemory(address); // depends on control dependency: [if], data = [none]
// If value doesn't match and was provided then don't remove it
if (!value.equalsWrappedBytes(ice.getValue())) {
ice = null; // depends on control dependency: [if], data = [none]
break;
}
}
if (requireReturn && ice == null) {
ice = offHeapEntryFactory.fromMemory(address); // depends on control dependency: [if], data = [none]
}
entryRemoved(address); // depends on control dependency: [if], data = [none]
if (prevAddress != 0) {
offHeapEntryFactory.setNext(prevAddress, nextAddress); // depends on control dependency: [if], data = [(prevAddress]
} else {
memoryLookup.putMemoryAddress(key, nextAddress); // depends on control dependency: [if], data = [none]
}
size.decrementAndGet(); // depends on control dependency: [if], data = [none]
break;
}
prevAddress = address; // depends on control dependency: [while], data = [none]
address = nextAddress; // depends on control dependency: [while], data = [none]
}
return ice;
} } |
public class class_name {
protected List<String> getCellLines(String explanation) {
int startPos = 0;
List<String> cellLines = new ArrayList<>();
for (int commaPos = 0; commaPos > -1;) {
commaPos = explanation.indexOf(",", startPos);
if (commaPos >= 0) {
String cellLine = (explanation.substring(startPos, commaPos).trim());
explanation = explanation.substring(commaPos + 1);
if (cellLine.length() > 0) {
cellLines.add(cellLine);
}
} else if (explanation.length() > 0) {
cellLines.add(explanation.trim());
}
}
return cellLines;
} } | public class class_name {
protected List<String> getCellLines(String explanation) {
int startPos = 0;
List<String> cellLines = new ArrayList<>();
for (int commaPos = 0; commaPos > -1;) {
commaPos = explanation.indexOf(",", startPos); // depends on control dependency: [for], data = [commaPos]
if (commaPos >= 0) {
String cellLine = (explanation.substring(startPos, commaPos).trim());
explanation = explanation.substring(commaPos + 1); // depends on control dependency: [if], data = [(commaPos]
if (cellLine.length() > 0) {
cellLines.add(cellLine); // depends on control dependency: [if], data = [none]
}
} else if (explanation.length() > 0) {
cellLines.add(explanation.trim()); // depends on control dependency: [if], data = [none]
}
}
return cellLines;
} } |
public class class_name {
static public WsByteBuffer[] putByteArray(WsByteBuffer[] buffers, byte[] value, int inOffset, int length, BNFHeadersImpl bnfObj) {
// LIDB2356-41: byte[]/offset/length support
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
// verify the input buffer information
if (null == buffers) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Null buffers sent to putByteArray");
}
return null;
}
// verify the input value information
if (null == value || 0 == value.length) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Empty value provided to putByteArray: " + value);
}
// return no changes
return buffers;
}
}
int offset = inOffset;
WsByteBuffer buffer = buffers[buffers.length - 1];
try {
buffer.put(value, offset, length);
} catch (BufferOverflowException boe) {
// no FFDC required
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "putByteArray overflow: " + buffer);
}
// put what we can and get more space
// available data in current buffer
int avail = buffer.capacity() - buffer.position();
buffer.put(value, offset, avail);
buffer.flip();
offset += avail;
int remaining = length - offset;
int numBuffers = (remaining / bnfObj.getOutgoingBufferSize());
// see if there are "leftover" bytes that need another buffer
if (0 != (remaining % bnfObj.getOutgoingBufferSize())) {
numBuffers++;
}
// allocate new buffers and put data in as we go along
WsByteBuffer[] newBuffers = new WsByteBuffer[numBuffers];
for (int i = 0; i < numBuffers; i++) {
newBuffers[i] = bnfObj.allocateBuffer(bnfObj.getOutgoingBufferSize());
avail = newBuffers[i].capacity();
// if the available space is enough for the rest of the data,
// add it and we're done
if (remaining <= avail) {
newBuffers[i].put(value, offset, remaining);
break;
}
// if it's not, then we need to put what we can and then
// expand the buffer[]
newBuffers[i].put(value, offset, avail);
newBuffers[i].flip();
offset += avail;
remaining -= avail;
}
return WsByteBufferUtils.expandBufferArray(buffers, newBuffers);
}
return buffers;
} } | public class class_name {
static public WsByteBuffer[] putByteArray(WsByteBuffer[] buffers, byte[] value, int inOffset, int length, BNFHeadersImpl bnfObj) {
// LIDB2356-41: byte[]/offset/length support
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
// verify the input buffer information
if (null == buffers) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Null buffers sent to putByteArray"); // depends on control dependency: [if], data = [none]
}
return null; // depends on control dependency: [if], data = [none]
}
// verify the input value information
if (null == value || 0 == value.length) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Empty value provided to putByteArray: " + value); // depends on control dependency: [if], data = [none]
}
// return no changes
return buffers; // depends on control dependency: [if], data = [none]
}
}
int offset = inOffset;
WsByteBuffer buffer = buffers[buffers.length - 1];
try {
buffer.put(value, offset, length); // depends on control dependency: [try], data = [none]
} catch (BufferOverflowException boe) {
// no FFDC required
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "putByteArray overflow: " + buffer); // depends on control dependency: [if], data = [none]
}
// put what we can and get more space
// available data in current buffer
int avail = buffer.capacity() - buffer.position();
buffer.put(value, offset, avail);
buffer.flip();
offset += avail;
int remaining = length - offset;
int numBuffers = (remaining / bnfObj.getOutgoingBufferSize());
// see if there are "leftover" bytes that need another buffer
if (0 != (remaining % bnfObj.getOutgoingBufferSize())) {
numBuffers++; // depends on control dependency: [if], data = [none]
}
// allocate new buffers and put data in as we go along
WsByteBuffer[] newBuffers = new WsByteBuffer[numBuffers];
for (int i = 0; i < numBuffers; i++) {
newBuffers[i] = bnfObj.allocateBuffer(bnfObj.getOutgoingBufferSize()); // depends on control dependency: [for], data = [i]
avail = newBuffers[i].capacity(); // depends on control dependency: [for], data = [i]
// if the available space is enough for the rest of the data,
// add it and we're done
if (remaining <= avail) {
newBuffers[i].put(value, offset, remaining); // depends on control dependency: [if], data = [none]
break;
}
// if it's not, then we need to put what we can and then
// expand the buffer[]
newBuffers[i].put(value, offset, avail); // depends on control dependency: [for], data = [i]
newBuffers[i].flip(); // depends on control dependency: [for], data = [i]
offset += avail; // depends on control dependency: [for], data = [none]
remaining -= avail; // depends on control dependency: [for], data = [none]
}
return WsByteBufferUtils.expandBufferArray(buffers, newBuffers);
} // depends on control dependency: [catch], data = [none]
return buffers;
} } |
public class class_name {
public void setStreamNames(java.util.Collection<String> streamNames) {
if (streamNames == null) {
this.streamNames = null;
return;
}
this.streamNames = new com.amazonaws.internal.SdkInternalList<String>(streamNames);
} } | public class class_name {
public void setStreamNames(java.util.Collection<String> streamNames) {
if (streamNames == null) {
this.streamNames = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.streamNames = new com.amazonaws.internal.SdkInternalList<String>(streamNames);
} } |
public class class_name {
public void setPathScore(Term from, Map<String, Double> relationMap) {
// 维特比进行最优路径的构建
double score = MathUtil.compuScore(from, this, relationMap);
if (this.from == null || this.score == 0 || this.score >= score) {
this.setFromAndScore(from, score);
}
} } | public class class_name {
public void setPathScore(Term from, Map<String, Double> relationMap) {
// 维特比进行最优路径的构建
double score = MathUtil.compuScore(from, this, relationMap);
if (this.from == null || this.score == 0 || this.score >= score) {
this.setFromAndScore(from, score); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
private C4Document save(Document document, C4Document base, boolean deletion)
throws LiteCoreException {
FLSliceResult body = null;
try {
int revFlags = 0;
if (deletion) { revFlags = C4Constants.RevisionFlags.DELETED; }
if (!deletion && !document.isEmpty()) {
// Encode properties to Fleece data:
body = document.encode();
if (C4Document.dictContainsBlobs(body, sharedKeys.getFLSharedKeys())) {
revFlags |= C4Constants.RevisionFlags.HAS_ATTACHMENTS;
}
}
// Save to database:
final C4Document c4Doc = base != null ? base : document.getC4doc();
if (c4Doc != null) { return c4Doc.update(body, revFlags); }
return getC4Database().create(document.getId(), body, revFlags);
}
finally {
if (body != null) { body.free(); }
}
} } | public class class_name {
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
private C4Document save(Document document, C4Document base, boolean deletion)
throws LiteCoreException {
FLSliceResult body = null;
try {
int revFlags = 0;
if (deletion) { revFlags = C4Constants.RevisionFlags.DELETED; } // depends on control dependency: [if], data = [none]
if (!deletion && !document.isEmpty()) {
// Encode properties to Fleece data:
body = document.encode(); // depends on control dependency: [if], data = [none]
if (C4Document.dictContainsBlobs(body, sharedKeys.getFLSharedKeys())) {
revFlags |= C4Constants.RevisionFlags.HAS_ATTACHMENTS; // depends on control dependency: [if], data = [none]
}
}
// Save to database:
final C4Document c4Doc = base != null ? base : document.getC4doc();
if (c4Doc != null) { return c4Doc.update(body, revFlags); } // depends on control dependency: [if], data = [none]
return getC4Database().create(document.getId(), body, revFlags);
}
finally {
if (body != null) { body.free(); } // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static String stringFor(int n)
{
if (n == 0)
{
return "INVALID CUmemAttach_flags: "+n;
}
String result = "";
if ((n & CU_MEM_ATTACH_GLOBAL) != 0) result += "CU_MEM_ATTACH_GLOBAL ";
if ((n & CU_MEM_ATTACH_HOST) != 0) result += "CU_MEM_ATTACH_HOST ";
if ((n & CU_MEM_ATTACH_SINGLE) != 0) result += "CU_MEM_ATTACH_SINGLE ";
return result;
} } | public class class_name {
public static String stringFor(int n)
{
if (n == 0)
{
return "INVALID CUmemAttach_flags: "+n;
// depends on control dependency: [if], data = [none]
}
String result = "";
if ((n & CU_MEM_ATTACH_GLOBAL) != 0) result += "CU_MEM_ATTACH_GLOBAL ";
if ((n & CU_MEM_ATTACH_HOST) != 0) result += "CU_MEM_ATTACH_HOST ";
if ((n & CU_MEM_ATTACH_SINGLE) != 0) result += "CU_MEM_ATTACH_SINGLE ";
return result;
} } |
public class class_name {
public final boolean overrideAllowed(final File file) {
if (isOverride()) {
// In general it's allowed to recreate existing files
if (overrideExclude == null) {
return true;
} else {
return !getOverrideExcludeFilter().accept(file);
}
} else {
// It's NOT allowed to recreate existing files
if (overrideInclude == null) {
return false;
} else {
return getOverrideIncludeFilter().accept(file);
}
}
} } | public class class_name {
public final boolean overrideAllowed(final File file) {
if (isOverride()) {
// In general it's allowed to recreate existing files
if (overrideExclude == null) {
return true;
// depends on control dependency: [if], data = [none]
} else {
return !getOverrideExcludeFilter().accept(file);
// depends on control dependency: [if], data = [none]
}
} else {
// It's NOT allowed to recreate existing files
if (overrideInclude == null) {
return false;
// depends on control dependency: [if], data = [none]
} else {
return getOverrideIncludeFilter().accept(file);
// depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public M sequence(String sequenceKey, Long initialValue, Boolean increment) {
SequenceConfig cfg = defaultSequenceConfig();
if (null != initialValue) {
cfg.setInitialValue(initialValue);
}
if (null != increment) {
cfg.setDecrement(!increment);
}
getSequence(sequenceKey, cfg);
return THIS();
} } | public class class_name {
public M sequence(String sequenceKey, Long initialValue, Boolean increment) {
SequenceConfig cfg = defaultSequenceConfig();
if (null != initialValue) {
cfg.setInitialValue(initialValue); // depends on control dependency: [if], data = [initialValue)]
}
if (null != increment) {
cfg.setDecrement(!increment); // depends on control dependency: [if], data = [increment)]
}
getSequence(sequenceKey, cfg);
return THIS();
} } |
public class class_name {
private static Point getShapeIntersection(Shape shape,
Line2D.Double line) {
PathIterator it = shape.getPathIterator(null);
double[] coords = new double[6];
double[] pos = new double[2];
Line2D.Double l = new Line2D.Double();
while (!it.isDone()) {
int type = it.currentSegment(coords);
switch (type) {
case PathIterator.SEG_MOVETO:
pos[0] = coords[0];
pos[1] = coords[1];
break;
case PathIterator.SEG_LINETO:
l = new Line2D.Double(pos[0],
pos[1],
coords[0],
coords[1]);
if (line.intersectsLine(l)) {
return getLinesIntersection(line,
l);
}
pos[0] = coords[0];
pos[1] = coords[1];
break;
case PathIterator.SEG_CLOSE:
break;
default:
// whatever
}
it.next();
}
return null;
} } | public class class_name {
private static Point getShapeIntersection(Shape shape,
Line2D.Double line) {
PathIterator it = shape.getPathIterator(null);
double[] coords = new double[6];
double[] pos = new double[2];
Line2D.Double l = new Line2D.Double();
while (!it.isDone()) {
int type = it.currentSegment(coords);
switch (type) {
case PathIterator.SEG_MOVETO:
pos[0] = coords[0];
pos[1] = coords[1];
break;
case PathIterator.SEG_LINETO:
l = new Line2D.Double(pos[0],
pos[1],
coords[0],
coords[1]);
if (line.intersectsLine(l)) {
return getLinesIntersection(line,
l); // depends on control dependency: [if], data = [none]
}
pos[0] = coords[0];
pos[1] = coords[1];
break;
case PathIterator.SEG_CLOSE:
break;
default:
// whatever
}
it.next(); // depends on control dependency: [while], data = [none]
}
return null;
} } |
public class class_name {
public List<Message> getFilteredList( EMessageType messageType, Long fromTsMillis, Long toTsMillis, long limit )
throws Exception {
String tableName = TABLE_MESSAGES;
String sql = "select " + getQueryFieldsString() + " from " + tableName;
List<String> wheresList = new ArrayList<>();
if (messageType != null && messageType != EMessageType.ALL) {
String where = type_NAME + "=" + messageType.getCode();
wheresList.add(where);
}
if (fromTsMillis != null) {
String where = TimeStamp_NAME + ">" + fromTsMillis;
wheresList.add(where);
}
if (toTsMillis != null) {
String where = TimeStamp_NAME + "<" + toTsMillis;
wheresList.add(where);
}
if (wheresList.size() > 0) {
sql += " WHERE ";
for( int i = 0; i < wheresList.size(); i++ ) {
if (i > 0) {
sql += " AND ";
}
sql += wheresList.get(i);
}
}
sql += " order by " + ID_NAME + " desc";
if (limit > 0) {
sql += " limit " + limit;
}
String _sql = sql;
List<Message> messages = new ArrayList<Message>();
logDb.execOnConnection(connection -> {
try (IHMStatement stmt = connection.createStatement(); IHMResultSet rs = stmt.executeQuery(_sql);) {
while( rs.next() ) {
Message event = resultSetToItem(rs);
messages.add(event);
}
}
return null;
});
return messages;
} } | public class class_name {
public List<Message> getFilteredList( EMessageType messageType, Long fromTsMillis, Long toTsMillis, long limit )
throws Exception {
String tableName = TABLE_MESSAGES;
String sql = "select " + getQueryFieldsString() + " from " + tableName;
List<String> wheresList = new ArrayList<>();
if (messageType != null && messageType != EMessageType.ALL) {
String where = type_NAME + "=" + messageType.getCode();
wheresList.add(where);
}
if (fromTsMillis != null) {
String where = TimeStamp_NAME + ">" + fromTsMillis;
wheresList.add(where);
}
if (toTsMillis != null) {
String where = TimeStamp_NAME + "<" + toTsMillis;
wheresList.add(where);
}
if (wheresList.size() > 0) {
sql += " WHERE ";
for( int i = 0; i < wheresList.size(); i++ ) {
if (i > 0) {
sql += " AND "; // depends on control dependency: [if], data = [none]
}
sql += wheresList.get(i);
}
}
sql += " order by " + ID_NAME + " desc";
if (limit > 0) {
sql += " limit " + limit;
}
String _sql = sql;
List<Message> messages = new ArrayList<Message>();
logDb.execOnConnection(connection -> {
try (IHMStatement stmt = connection.createStatement(); IHMResultSet rs = stmt.executeQuery(_sql);) {
while( rs.next() ) {
Message event = resultSetToItem(rs);
messages.add(event);
}
}
return null;
});
return messages;
} } |
public class class_name {
String getHost() {
LOGGER.entering();
String val = "";
InstanceType type = getType();
if (commands.contains(HOST_ARG)) {
val = commands.get(commands.indexOf(HOST_ARG) + 1);
LOGGER.exiting(val);
return val;
}
try {
if (type.equals(InstanceType.SELENIUM_NODE) || type.equals(InstanceType.SELENIUM_HUB)) {
val = getSeleniumConfigAsJsonObject().get("host").getAsString();
}
} catch (JsonParseException | NullPointerException e) {
// ignore
}
// return the value if it looks okay, otherwise return "localhost" as a last ditch effort
val = (StringUtils.isNotEmpty(val) && !val.equalsIgnoreCase("ip")) ? val : "localhost";
LOGGER.exiting(val);
return val;
} } | public class class_name {
String getHost() {
LOGGER.entering();
String val = "";
InstanceType type = getType();
if (commands.contains(HOST_ARG)) {
val = commands.get(commands.indexOf(HOST_ARG) + 1); // depends on control dependency: [if], data = [none]
LOGGER.exiting(val); // depends on control dependency: [if], data = [none]
return val; // depends on control dependency: [if], data = [none]
}
try {
if (type.equals(InstanceType.SELENIUM_NODE) || type.equals(InstanceType.SELENIUM_HUB)) {
val = getSeleniumConfigAsJsonObject().get("host").getAsString(); // depends on control dependency: [if], data = [none]
}
} catch (JsonParseException | NullPointerException e) {
// ignore
} // depends on control dependency: [catch], data = [none]
// return the value if it looks okay, otherwise return "localhost" as a last ditch effort
val = (StringUtils.isNotEmpty(val) && !val.equalsIgnoreCase("ip")) ? val : "localhost";
LOGGER.exiting(val);
return val;
} } |
public class class_name {
public static Function<GHEventsSubscriber, Void> processEvent(final GHSubscriberEvent event) {
return new NullSafeFunction<GHEventsSubscriber, Void>() {
@Override
protected Void applyNullSafe(@Nonnull GHEventsSubscriber subscriber) {
try {
subscriber.onEvent(event);
} catch (Throwable t) {
LOGGER.error("Subscriber {} failed to process {} hook, skipping...",
subscriber.getClass().getName(), event, t);
}
return null;
}
};
} } | public class class_name {
public static Function<GHEventsSubscriber, Void> processEvent(final GHSubscriberEvent event) {
return new NullSafeFunction<GHEventsSubscriber, Void>() {
@Override
protected Void applyNullSafe(@Nonnull GHEventsSubscriber subscriber) {
try {
subscriber.onEvent(event); // depends on control dependency: [try], data = [none]
} catch (Throwable t) {
LOGGER.error("Subscriber {} failed to process {} hook, skipping...",
subscriber.getClass().getName(), event, t);
} // depends on control dependency: [catch], data = [none]
return null;
}
};
} } |
public class class_name {
public void marshall(DescribeActivationsFilter describeActivationsFilter, ProtocolMarshaller protocolMarshaller) {
if (describeActivationsFilter == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(describeActivationsFilter.getFilterKey(), FILTERKEY_BINDING);
protocolMarshaller.marshall(describeActivationsFilter.getFilterValues(), FILTERVALUES_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(DescribeActivationsFilter describeActivationsFilter, ProtocolMarshaller protocolMarshaller) {
if (describeActivationsFilter == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(describeActivationsFilter.getFilterKey(), FILTERKEY_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(describeActivationsFilter.getFilterValues(), FILTERVALUES_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 File archiveMessage(final MailMessage message) {
try {
String subject = message.getSubject();
String fileName = subject == null
? "no_subject"
: INVALID_FILE_NAME_CHARS.matcher(subject).replaceAll("_");
MutableInt counter = counterProvider.get();
File dir = new File("e-mails", "unread");
File file = new File(dir, String.format(FILE_NAME_FORMAT, counter.intValue(), fileName));
file = new File(moduleArchiveDirProvider.get(), file.getPath());
createParentDirs(file);
log.debug("Archiving e-mail: {}", file);
StrBuilder sb = new StrBuilder(500);
for (Entry<String, String> header : message.getHeaders().entries()) {
sb.append(header.getKey()).append('=').appendln(header.getValue());
}
sb.appendln("");
sb.append(message.getText());
write(sb.toString(), file, Charsets.UTF_8);
counter.increment();
return file;
} catch (IOException ex) {
throw new MailException("Error archiving mail.", ex);
}
} } | public class class_name {
public File archiveMessage(final MailMessage message) {
try {
String subject = message.getSubject();
String fileName = subject == null
? "no_subject"
: INVALID_FILE_NAME_CHARS.matcher(subject).replaceAll("_");
MutableInt counter = counterProvider.get();
File dir = new File("e-mails", "unread");
File file = new File(dir, String.format(FILE_NAME_FORMAT, counter.intValue(), fileName));
file = new File(moduleArchiveDirProvider.get(), file.getPath()); // depends on control dependency: [try], data = [none]
createParentDirs(file); // depends on control dependency: [try], data = [none]
log.debug("Archiving e-mail: {}", file); // depends on control dependency: [try], data = [none]
StrBuilder sb = new StrBuilder(500);
for (Entry<String, String> header : message.getHeaders().entries()) {
sb.append(header.getKey()).append('=').appendln(header.getValue()); // depends on control dependency: [for], data = [header]
}
sb.appendln(""); // depends on control dependency: [try], data = [none]
sb.append(message.getText()); // depends on control dependency: [try], data = [none]
write(sb.toString(), file, Charsets.UTF_8); // depends on control dependency: [try], data = [none]
counter.increment(); // depends on control dependency: [try], data = [none]
return file; // depends on control dependency: [try], data = [none]
} catch (IOException ex) {
throw new MailException("Error archiving mail.", ex);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void eachInRow(int i, VectorProcedure procedure) {
VectorIterator it = iteratorOfRow(i);
while (it.hasNext()) {
double x = it.next();
int j = it.index();
procedure.apply(j, x);
}
} } | public class class_name {
public void eachInRow(int i, VectorProcedure procedure) {
VectorIterator it = iteratorOfRow(i);
while (it.hasNext()) {
double x = it.next();
int j = it.index();
procedure.apply(j, x); // depends on control dependency: [while], data = [none]
}
} } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.