code
stringlengths 130
281k
| code_dependency
stringlengths 182
306k
|
---|---|
public class class_name {
public void update() {
if (settings != null && getWidth() > 0 && getHeight() > 0) {
// Updating finder area rectangle
GravityUtils.getMovementAreaPosition(settings, tmpRect);
rect.set(tmpRect);
rect.offset(getPaddingLeft(), getPaddingTop());
// We want to stroke outside of finder rectangle, while by default stroke is centered
strokeRect.set(rect);
float halfStroke = 0.5f * paintStroke.getStrokeWidth();
strokeRect.inset(-halfStroke, -halfStroke);
invalidate();
}
} } | public class class_name {
public void update() {
if (settings != null && getWidth() > 0 && getHeight() > 0) {
// Updating finder area rectangle
GravityUtils.getMovementAreaPosition(settings, tmpRect); // depends on control dependency: [if], data = [(settings]
rect.set(tmpRect); // depends on control dependency: [if], data = [none]
rect.offset(getPaddingLeft(), getPaddingTop()); // depends on control dependency: [if], data = [none]
// We want to stroke outside of finder rectangle, while by default stroke is centered
strokeRect.set(rect); // depends on control dependency: [if], data = [none]
float halfStroke = 0.5f * paintStroke.getStrokeWidth();
strokeRect.inset(-halfStroke, -halfStroke); // depends on control dependency: [if], data = [none]
invalidate(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static Vector2D_F64 transform( Affine2D_F64 se, Vector2D_F64 orig, Vector2D_F64 result ) {
if( result == null ) {
result = new Vector2D_F64();
}
// copy the values so that no errors happen if orig and result are the same instance
double x = orig.x;
double y = orig.y;
result.x = se.a11 * x + se.a12 * y;
result.y = se.a21 * x + se.a22 * y;
return result;
} } | public class class_name {
public static Vector2D_F64 transform( Affine2D_F64 se, Vector2D_F64 orig, Vector2D_F64 result ) {
if( result == null ) {
result = new Vector2D_F64(); // depends on control dependency: [if], data = [none]
}
// copy the values so that no errors happen if orig and result are the same instance
double x = orig.x;
double y = orig.y;
result.x = se.a11 * x + se.a12 * y;
result.y = se.a21 * x + se.a22 * y;
return result;
} } |
public class class_name {
static DataBlock[] getDataBlocks(byte[] rawCodewords,
Version version,
ErrorCorrectionLevel ecLevel) {
if (rawCodewords.length != version.getTotalCodewords()) {
throw new IllegalArgumentException();
}
// Figure out the number and size of data blocks used by this version and
// error correction level
Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel);
// First count the total number of data blocks
int totalBlocks = 0;
Version.ECB[] ecBlockArray = ecBlocks.getECBlocks();
for (Version.ECB ecBlock : ecBlockArray) {
totalBlocks += ecBlock.getCount();
}
// Now establish DataBlocks of the appropriate size and number of data codewords
DataBlock[] result = new DataBlock[totalBlocks];
int numResultBlocks = 0;
for (Version.ECB ecBlock : ecBlockArray) {
for (int i = 0; i < ecBlock.getCount(); i++) {
int numDataCodewords = ecBlock.getDataCodewords();
int numBlockCodewords = ecBlocks.getECCodewordsPerBlock() + numDataCodewords;
result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]);
}
}
// All blocks have the same amount of data, except that the last n
// (where n may be 0) have 1 more byte. Figure out where these start.
int shorterBlocksTotalCodewords = result[0].codewords.length;
int longerBlocksStartAt = result.length - 1;
while (longerBlocksStartAt >= 0) {
int numCodewords = result[longerBlocksStartAt].codewords.length;
if (numCodewords == shorterBlocksTotalCodewords) {
break;
}
longerBlocksStartAt--;
}
longerBlocksStartAt++;
int shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.getECCodewordsPerBlock();
// The last elements of result may be 1 element longer;
// first fill out as many elements as all of them have
int rawCodewordsOffset = 0;
for (int i = 0; i < shorterBlocksNumDataCodewords; i++) {
for (int j = 0; j < numResultBlocks; j++) {
result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
}
}
// Fill out the last data block in the longer ones
for (int j = longerBlocksStartAt; j < numResultBlocks; j++) {
result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
}
// Now add in error correction blocks
int max = result[0].codewords.length;
for (int i = shorterBlocksNumDataCodewords; i < max; i++) {
for (int j = 0; j < numResultBlocks; j++) {
int iOffset = j < longerBlocksStartAt ? i : i + 1;
result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
}
}
return result;
} } | public class class_name {
static DataBlock[] getDataBlocks(byte[] rawCodewords,
Version version,
ErrorCorrectionLevel ecLevel) {
if (rawCodewords.length != version.getTotalCodewords()) {
throw new IllegalArgumentException();
}
// Figure out the number and size of data blocks used by this version and
// error correction level
Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel);
// First count the total number of data blocks
int totalBlocks = 0;
Version.ECB[] ecBlockArray = ecBlocks.getECBlocks();
for (Version.ECB ecBlock : ecBlockArray) {
totalBlocks += ecBlock.getCount(); // depends on control dependency: [for], data = [ecBlock]
}
// Now establish DataBlocks of the appropriate size and number of data codewords
DataBlock[] result = new DataBlock[totalBlocks];
int numResultBlocks = 0;
for (Version.ECB ecBlock : ecBlockArray) {
for (int i = 0; i < ecBlock.getCount(); i++) {
int numDataCodewords = ecBlock.getDataCodewords();
int numBlockCodewords = ecBlocks.getECCodewordsPerBlock() + numDataCodewords;
result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]); // depends on control dependency: [for], data = [none]
}
}
// All blocks have the same amount of data, except that the last n
// (where n may be 0) have 1 more byte. Figure out where these start.
int shorterBlocksTotalCodewords = result[0].codewords.length;
int longerBlocksStartAt = result.length - 1;
while (longerBlocksStartAt >= 0) {
int numCodewords = result[longerBlocksStartAt].codewords.length;
if (numCodewords == shorterBlocksTotalCodewords) {
break;
}
longerBlocksStartAt--; // depends on control dependency: [while], data = [none]
}
longerBlocksStartAt++;
int shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.getECCodewordsPerBlock();
// The last elements of result may be 1 element longer;
// first fill out as many elements as all of them have
int rawCodewordsOffset = 0;
for (int i = 0; i < shorterBlocksNumDataCodewords; i++) {
for (int j = 0; j < numResultBlocks; j++) {
result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; // depends on control dependency: [for], data = [j]
}
}
// Fill out the last data block in the longer ones
for (int j = longerBlocksStartAt; j < numResultBlocks; j++) {
result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; // depends on control dependency: [for], data = [j]
}
// Now add in error correction blocks
int max = result[0].codewords.length;
for (int i = shorterBlocksNumDataCodewords; i < max; i++) {
for (int j = 0; j < numResultBlocks; j++) {
int iOffset = j < longerBlocksStartAt ? i : i + 1;
result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; // depends on control dependency: [for], data = [j]
}
}
return result;
} } |
public class class_name {
public BareJid getOwnJid() {
if (ownJid == null && connection().isAuthenticated()) {
ownJid = connection().getUser().asBareJid();
}
return ownJid;
} } | public class class_name {
public BareJid getOwnJid() {
if (ownJid == null && connection().isAuthenticated()) {
ownJid = connection().getUser().asBareJid(); // depends on control dependency: [if], data = [none]
}
return ownJid;
} } |
public class class_name {
@Override
public void setValue(Object value)
{
FacesContext facesContext = getFacesContext();
if (facesContext != null && facesContext.isProjectStage(ProjectStage.Development))
{
// extended debug-info when in Development mode
_createFieldDebugInfo(facesContext, "localValue",
getLocalValue(), value, 1);
}
setLocalValueSet(true);
super.setValue(value);
} } | public class class_name {
@Override
public void setValue(Object value)
{
FacesContext facesContext = getFacesContext();
if (facesContext != null && facesContext.isProjectStage(ProjectStage.Development))
{
// extended debug-info when in Development mode
_createFieldDebugInfo(facesContext, "localValue",
getLocalValue(), value, 1); // depends on control dependency: [if], data = [(facesContext]
}
setLocalValueSet(true);
super.setValue(value);
} } |
public class class_name {
public static boolean hasPossibleStaticMethod(ClassNode cNode, String name, Expression arguments, boolean trySpread) {
int count = 0;
boolean foundSpread = false;
if (arguments instanceof TupleExpression) {
TupleExpression tuple = (TupleExpression) arguments;
for (Expression arg : tuple.getExpressions()) {
if (arg instanceof SpreadExpression) {
foundSpread = true;
} else {
count++;
}
}
} else if (arguments instanceof MapExpression) {
count = 1;
}
for (MethodNode method : cNode.getMethods(name)) {
if (method.isStatic()) {
Parameter[] parameters = method.getParameters();
// do fuzzy match for spread case: count will be number of non-spread args
if (trySpread && foundSpread && parameters.length >= count) return true;
if (parameters.length == count) return true;
// handle varargs case
if (parameters.length > 0 && parameters[parameters.length - 1].getType().isArray()) {
if (count >= parameters.length - 1) return true;
// fuzzy match any spread to a varargs
if (trySpread && foundSpread) return true;
}
// handle parameters with default values
int nonDefaultParameters = 0;
for (Parameter parameter : parameters) {
if (!parameter.hasInitialExpression()) {
nonDefaultParameters++;
}
}
if (count < parameters.length && nonDefaultParameters <= count) {
return true;
}
// TODO handle spread with nonDefaultParams?
}
}
return false;
} } | public class class_name {
public static boolean hasPossibleStaticMethod(ClassNode cNode, String name, Expression arguments, boolean trySpread) {
int count = 0;
boolean foundSpread = false;
if (arguments instanceof TupleExpression) {
TupleExpression tuple = (TupleExpression) arguments;
for (Expression arg : tuple.getExpressions()) {
if (arg instanceof SpreadExpression) {
foundSpread = true; // depends on control dependency: [if], data = [none]
} else {
count++; // depends on control dependency: [if], data = [none]
}
}
} else if (arguments instanceof MapExpression) {
count = 1; // depends on control dependency: [if], data = [none]
}
for (MethodNode method : cNode.getMethods(name)) {
if (method.isStatic()) {
Parameter[] parameters = method.getParameters();
// do fuzzy match for spread case: count will be number of non-spread args
if (trySpread && foundSpread && parameters.length >= count) return true;
if (parameters.length == count) return true;
// handle varargs case
if (parameters.length > 0 && parameters[parameters.length - 1].getType().isArray()) {
if (count >= parameters.length - 1) return true;
// fuzzy match any spread to a varargs
if (trySpread && foundSpread) return true;
}
// handle parameters with default values
int nonDefaultParameters = 0;
for (Parameter parameter : parameters) {
if (!parameter.hasInitialExpression()) {
nonDefaultParameters++; // depends on control dependency: [if], data = [none]
}
}
if (count < parameters.length && nonDefaultParameters <= count) {
return true; // depends on control dependency: [if], data = [none]
}
// TODO handle spread with nonDefaultParams?
}
}
return false;
} } |
public class class_name {
public void setPendingRequests(java.util.Collection<Workspace> pendingRequests) {
if (pendingRequests == null) {
this.pendingRequests = null;
return;
}
this.pendingRequests = new com.amazonaws.internal.SdkInternalList<Workspace>(pendingRequests);
} } | public class class_name {
public void setPendingRequests(java.util.Collection<Workspace> pendingRequests) {
if (pendingRequests == null) {
this.pendingRequests = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.pendingRequests = new com.amazonaws.internal.SdkInternalList<Workspace>(pendingRequests);
} } |
public class class_name {
private InternalCacheEntry<WrappedBytes, WrappedBytes> performPut(long bucketHeadAddress, long actualAddress,
long newAddress, WrappedBytes key, boolean requireReturn) {
// Have to start new linked node list
if (bucketHeadAddress == 0) {
memoryLookup.putMemoryAddress(key, newAddress);
entryCreated(newAddress);
size.incrementAndGet();
return null;
} else {
boolean replaceHead = false;
boolean foundPrevious = false;
// Whether the key was found or not - short circuit equality checks
InternalCacheEntry<WrappedBytes, WrappedBytes> previousValue = null;
long address = bucketHeadAddress;
// Holds the previous linked list address
long prevAddress = 0;
// Keep looping until we get the tail end - we always append the put to the end
while (address != 0) {
long nextAddress = offHeapEntryFactory.getNext(address);
if (!foundPrevious) {
// If the actualAddress was not known check key equality otherwise just compare with the address
if (actualAddress == 0 ? offHeapEntryFactory.equalsKey(address, key) : actualAddress == address) {
foundPrevious = true;
if (requireReturn) {
previousValue = offHeapEntryFactory.fromMemory(address);
}
entryReplaced(newAddress, address);
// If this is true it means this was the first node in the linked list
if (prevAddress == 0) {
if (nextAddress == 0) {
// This branch is the case where our key is the only one in the linked list
replaceHead = true;
} else {
// This branch is the case where our key is the first with another after
memoryLookup.putMemoryAddress(key, nextAddress);
}
} else {
// This branch means our node was not the first, so we have to update the address before ours
// to the one we previously referenced
offHeapEntryFactory.setNext(prevAddress, nextAddress);
// We purposely don't update prevAddress, because we have to keep it as the current pointer
// since we removed ours
address = nextAddress;
continue;
}
}
}
prevAddress = address;
address = nextAddress;
}
// If we didn't find the key previous, it means we are a new entry
if (!foundPrevious) {
entryCreated(newAddress);
size.incrementAndGet();
}
if (replaceHead) {
memoryLookup.putMemoryAddress(key, newAddress);
} else {
// Now prevAddress should be the last link so we fix our link
offHeapEntryFactory.setNext(prevAddress, newAddress);
}
return previousValue;
}
} } | public class class_name {
private InternalCacheEntry<WrappedBytes, WrappedBytes> performPut(long bucketHeadAddress, long actualAddress,
long newAddress, WrappedBytes key, boolean requireReturn) {
// Have to start new linked node list
if (bucketHeadAddress == 0) {
memoryLookup.putMemoryAddress(key, newAddress); // depends on control dependency: [if], data = [none]
entryCreated(newAddress); // depends on control dependency: [if], data = [none]
size.incrementAndGet(); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
} else {
boolean replaceHead = false;
boolean foundPrevious = false;
// Whether the key was found or not - short circuit equality checks
InternalCacheEntry<WrappedBytes, WrappedBytes> previousValue = null;
long address = bucketHeadAddress;
// Holds the previous linked list address
long prevAddress = 0;
// Keep looping until we get the tail end - we always append the put to the end
while (address != 0) {
long nextAddress = offHeapEntryFactory.getNext(address);
if (!foundPrevious) {
// If the actualAddress was not known check key equality otherwise just compare with the address
if (actualAddress == 0 ? offHeapEntryFactory.equalsKey(address, key) : actualAddress == address) {
foundPrevious = true; // depends on control dependency: [if], data = [none]
if (requireReturn) {
previousValue = offHeapEntryFactory.fromMemory(address); // depends on control dependency: [if], data = [none]
}
entryReplaced(newAddress, address); // depends on control dependency: [if], data = [none]
// If this is true it means this was the first node in the linked list
if (prevAddress == 0) {
if (nextAddress == 0) {
// This branch is the case where our key is the only one in the linked list
replaceHead = true; // depends on control dependency: [if], data = [none]
} else {
// This branch is the case where our key is the first with another after
memoryLookup.putMemoryAddress(key, nextAddress); // depends on control dependency: [if], data = [none]
}
} else {
// This branch means our node was not the first, so we have to update the address before ours
// to the one we previously referenced
offHeapEntryFactory.setNext(prevAddress, nextAddress); // depends on control dependency: [if], data = [(prevAddress]
// We purposely don't update prevAddress, because we have to keep it as the current pointer
// since we removed ours
address = nextAddress; // depends on control dependency: [if], data = [none]
continue;
}
}
}
prevAddress = address; // depends on control dependency: [while], data = [none]
address = nextAddress; // depends on control dependency: [while], data = [none]
}
// If we didn't find the key previous, it means we are a new entry
if (!foundPrevious) {
entryCreated(newAddress); // depends on control dependency: [if], data = [none]
size.incrementAndGet(); // depends on control dependency: [if], data = [none]
}
if (replaceHead) {
memoryLookup.putMemoryAddress(key, newAddress); // depends on control dependency: [if], data = [none]
} else {
// Now prevAddress should be the last link so we fix our link
offHeapEntryFactory.setNext(prevAddress, newAddress); // depends on control dependency: [if], data = [none]
}
return previousValue; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static void printWarnings(Connection conn, PrintWriter pw) {
if (conn != null) {
try {
printStackTrace(conn.getWarnings(), pw);
} catch (SQLException e) {
printStackTrace(e, pw);
}
}
} } | public class class_name {
public static void printWarnings(Connection conn, PrintWriter pw) {
if (conn != null) {
try {
printStackTrace(conn.getWarnings(), pw); // depends on control dependency: [try], data = [none]
} catch (SQLException e) {
printStackTrace(e, pw);
} // depends on control dependency: [catch], data = [none]
}
} } |
public class class_name {
public void setSupportedFeatureNames(java.util.Collection<String> supportedFeatureNames) {
if (supportedFeatureNames == null) {
this.supportedFeatureNames = null;
return;
}
this.supportedFeatureNames = new com.amazonaws.internal.SdkInternalList<String>(supportedFeatureNames);
} } | public class class_name {
public void setSupportedFeatureNames(java.util.Collection<String> supportedFeatureNames) {
if (supportedFeatureNames == null) {
this.supportedFeatureNames = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.supportedFeatureNames = new com.amazonaws.internal.SdkInternalList<String>(supportedFeatureNames);
} } |
public class class_name {
public Map buildSortQueryParamsMap(String sortExpression) {
SortModel sortModel = getDataGridState().getSortModel();
SortStrategy sortStrategy = sortModel.getSortStrategy();
List currSorts = sortModel.getSorts();
ArrayList newSorts = new ArrayList();
if(currSorts == null || currSorts.size() == 0) {
Sort sort = new Sort();
sort.setSortExpression(sortExpression);
sort.setDirection(sortStrategy.getDefaultDirection());
newSorts.add(sort);
}
else {
boolean foundSort = false;
for(int i = 0; i < currSorts.size(); i++) {
Sort sort = (Sort)currSorts.get(i);
if(!sort.getSortExpression().equals(sortExpression)) {
newSorts.add(sort);
}
else {
Sort newSort = new Sort();
newSort.setSortExpression(sortExpression);
newSort.setDirection(sortStrategy.nextDirection(sort.getDirection()));
newSorts.add(newSort);
foundSort = true;
}
}
if(!foundSort) {
Sort newSort = new Sort();
newSort.setSortExpression(sortExpression);
newSort.setDirection(sortStrategy.getDefaultDirection());
newSorts.add(newSort);
}
}
Map params = _codec.getExistingParams();
Map newParams = new HashMap();
Map tmp = _codec.buildSortParamMap(newSorts);
if(tmp != null)
newParams.putAll(tmp);
addFilterParams(newParams);
addPagerParams(newParams);
params = mergeMaps(params, newParams);
params = transformMap(params);
return params;
} } | public class class_name {
public Map buildSortQueryParamsMap(String sortExpression) {
SortModel sortModel = getDataGridState().getSortModel();
SortStrategy sortStrategy = sortModel.getSortStrategy();
List currSorts = sortModel.getSorts();
ArrayList newSorts = new ArrayList();
if(currSorts == null || currSorts.size() == 0) {
Sort sort = new Sort();
sort.setSortExpression(sortExpression); // depends on control dependency: [if], data = [none]
sort.setDirection(sortStrategy.getDefaultDirection()); // depends on control dependency: [if], data = [none]
newSorts.add(sort); // depends on control dependency: [if], data = [none]
}
else {
boolean foundSort = false;
for(int i = 0; i < currSorts.size(); i++) {
Sort sort = (Sort)currSorts.get(i);
if(!sort.getSortExpression().equals(sortExpression)) {
newSorts.add(sort); // depends on control dependency: [if], data = [none]
}
else {
Sort newSort = new Sort();
newSort.setSortExpression(sortExpression); // depends on control dependency: [if], data = [none]
newSort.setDirection(sortStrategy.nextDirection(sort.getDirection())); // depends on control dependency: [if], data = [none]
newSorts.add(newSort); // depends on control dependency: [if], data = [none]
foundSort = true; // depends on control dependency: [if], data = [none]
}
}
if(!foundSort) {
Sort newSort = new Sort();
newSort.setSortExpression(sortExpression); // depends on control dependency: [if], data = [none]
newSort.setDirection(sortStrategy.getDefaultDirection()); // depends on control dependency: [if], data = [none]
newSorts.add(newSort); // depends on control dependency: [if], data = [none]
}
}
Map params = _codec.getExistingParams();
Map newParams = new HashMap();
Map tmp = _codec.buildSortParamMap(newSorts);
if(tmp != null)
newParams.putAll(tmp);
addFilterParams(newParams);
addPagerParams(newParams);
params = mergeMaps(params, newParams);
params = transformMap(params);
return params;
} } |
public class class_name {
public void addDatatype(String pluralDatatype, String datatype) {
pluralDatatype = Utils.noSpaces(Utils.stripAndTrim(pluralDatatype, " "), "-");
datatype = Utils.noSpaces(Utils.stripAndTrim(datatype, " "), "-");
if (StringUtils.isBlank(pluralDatatype) || StringUtils.isBlank(datatype)) {
return;
}
if (getDatatypes().size() >= Config.MAX_DATATYPES_PER_APP) {
LoggerFactory.getLogger(App.class).warn("Maximum number of types per app reached - {}.",
Config.MAX_DATATYPES_PER_APP);
return;
}
if (!getDatatypes().containsKey(pluralDatatype) && !getDatatypes().containsValue(datatype) &&
!ParaObjectUtils.getCoreTypes().containsKey(pluralDatatype)) {
getDatatypes().put(pluralDatatype, datatype);
}
} } | public class class_name {
public void addDatatype(String pluralDatatype, String datatype) {
pluralDatatype = Utils.noSpaces(Utils.stripAndTrim(pluralDatatype, " "), "-");
datatype = Utils.noSpaces(Utils.stripAndTrim(datatype, " "), "-");
if (StringUtils.isBlank(pluralDatatype) || StringUtils.isBlank(datatype)) {
return;
}
if (getDatatypes().size() >= Config.MAX_DATATYPES_PER_APP) {
LoggerFactory.getLogger(App.class).warn("Maximum number of types per app reached - {}.",
Config.MAX_DATATYPES_PER_APP);
return;
}
if (!getDatatypes().containsKey(pluralDatatype) && !getDatatypes().containsValue(datatype) &&
!ParaObjectUtils.getCoreTypes().containsKey(pluralDatatype)) {
getDatatypes().put(pluralDatatype, datatype); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void hiccup()
{
// If termination is already under way do nothing.
if (state != State.ACTIVE) {
return;
}
// We'll drop the pointer to the inpipe. From now on, the peer is
// responsible for deallocating it.
inpipe = null;
// Create new inpipe.
if (conflate) {
inpipe = new YPipeConflate<>();
}
else {
inpipe = new YPipe<>(Config.MESSAGE_PIPE_GRANULARITY.getValue());
}
inActive = true;
// Notify the peer about the hiccup.
sendHiccup(peer, inpipe);
} } | public class class_name {
public void hiccup()
{
// If termination is already under way do nothing.
if (state != State.ACTIVE) {
return; // depends on control dependency: [if], data = [none]
}
// We'll drop the pointer to the inpipe. From now on, the peer is
// responsible for deallocating it.
inpipe = null;
// Create new inpipe.
if (conflate) {
inpipe = new YPipeConflate<>(); // depends on control dependency: [if], data = [none]
}
else {
inpipe = new YPipe<>(Config.MESSAGE_PIPE_GRANULARITY.getValue()); // depends on control dependency: [if], data = [none]
}
inActive = true;
// Notify the peer about the hiccup.
sendHiccup(peer, inpipe);
} } |
public class class_name {
public Map<String, Reflector> fields() {
Map<String, Reflector> result;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
result = new ArrayMap<>();
} else {
result = new HashMap<>();
}
Class<?> type = type();
do {
// all field
for (Field field : type.getDeclaredFields()) {
if (!isClass ^ Modifier.isStatic(field.getModifiers())) {
String name = field.getName();
// add
if (!result.containsKey(name))
result.put(name, field(name));
}
}
type = type.getSuperclass();
}
while (type != null);
return result;
} } | public class class_name {
public Map<String, Reflector> fields() {
Map<String, Reflector> result;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
result = new ArrayMap<>(); // depends on control dependency: [if], data = [none]
} else {
result = new HashMap<>(); // depends on control dependency: [if], data = [none]
}
Class<?> type = type();
do {
// all field
for (Field field : type.getDeclaredFields()) {
if (!isClass ^ Modifier.isStatic(field.getModifiers())) {
String name = field.getName();
// add
if (!result.containsKey(name))
result.put(name, field(name));
}
}
type = type.getSuperclass();
}
while (type != null);
return result;
} } |
public class class_name {
@Override
public EClass getIfcPreDefinedCurveFont() {
if (ifcPreDefinedCurveFontEClass == null) {
ifcPreDefinedCurveFontEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(441);
}
return ifcPreDefinedCurveFontEClass;
} } | public class class_name {
@Override
public EClass getIfcPreDefinedCurveFont() {
if (ifcPreDefinedCurveFontEClass == null) {
ifcPreDefinedCurveFontEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(441);
// depends on control dependency: [if], data = [none]
}
return ifcPreDefinedCurveFontEClass;
} } |
public class class_name {
public static void sleep(long length, TimeUnit unit) {
try {
unit.sleep(length);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
} } | public class class_name {
public static void sleep(long length, TimeUnit unit) {
try {
unit.sleep(length); // depends on control dependency: [try], data = [none]
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private Token unwindTo(int targetIndent, Token copyFrom) {
assert dentsBuffer.isEmpty() : dentsBuffer;
dentsBuffer.add(createToken(nlToken, copyFrom));
// To make things easier, we'll queue up ALL of the dedents, and then pop off the first one.
// For example, here's how some text is analyzed:
//
// Text : Indentation : Action : Indents Deque
// [ baseline ] : 0 : nothing : [0]
// [ foo ] : 2 : INDENT : [0, 2]
// [ bar ] : 3 : INDENT : [0, 2, 3]
// [ baz ] : 0 : DEDENT x2 : [0]
while (true) {
int prevIndent = indentations.pop();
if (prevIndent == targetIndent) {
break;
}
if (targetIndent > prevIndent) {
// "weird" condition above
indentations.push(prevIndent); // restore previous indentation, since we've indented from it
dentsBuffer.add(createToken(indentToken, copyFrom));
break;
}
dentsBuffer.add(createToken(dedentToken, copyFrom));
}
indentations.push(targetIndent);
return dentsBuffer.remove();
} } | public class class_name {
private Token unwindTo(int targetIndent, Token copyFrom) {
assert dentsBuffer.isEmpty() : dentsBuffer;
dentsBuffer.add(createToken(nlToken, copyFrom));
// To make things easier, we'll queue up ALL of the dedents, and then pop off the first one.
// For example, here's how some text is analyzed:
//
// Text : Indentation : Action : Indents Deque
// [ baseline ] : 0 : nothing : [0]
// [ foo ] : 2 : INDENT : [0, 2]
// [ bar ] : 3 : INDENT : [0, 2, 3]
// [ baz ] : 0 : DEDENT x2 : [0]
while (true) {
int prevIndent = indentations.pop();
if (prevIndent == targetIndent) {
break;
}
if (targetIndent > prevIndent) {
// "weird" condition above
indentations.push(prevIndent); // restore previous indentation, since we've indented from it // depends on control dependency: [if], data = [prevIndent)]
dentsBuffer.add(createToken(indentToken, copyFrom)); // depends on control dependency: [if], data = [none]
break;
}
dentsBuffer.add(createToken(dedentToken, copyFrom)); // depends on control dependency: [while], data = [none]
}
indentations.push(targetIndent);
return dentsBuffer.remove();
} } |
public class class_name {
private boolean isLongOption(String token)
{
if (!token.startsWith("-") || token.length() == 1)
{
return false;
}
int pos = token.indexOf("=");
String t = pos == -1 ? token : token.substring(0, pos);
if (!options.getMatchingOptions(t).isEmpty())
{
// long or partial long options (--L, -L, --L=V, -L=V, --l, --l=V)
return true;
}
else if (getLongPrefix(token) != null && !token.startsWith("--"))
{
// -LV
return true;
}
return false;
} } | public class class_name {
private boolean isLongOption(String token)
{
if (!token.startsWith("-") || token.length() == 1)
{
return false; // depends on control dependency: [if], data = [none]
}
int pos = token.indexOf("=");
String t = pos == -1 ? token : token.substring(0, pos);
if (!options.getMatchingOptions(t).isEmpty())
{
// long or partial long options (--L, -L, --L=V, -L=V, --l, --l=V)
return true; // depends on control dependency: [if], data = [none]
}
else if (getLongPrefix(token) != null && !token.startsWith("--"))
{
// -LV
return true; // depends on control dependency: [if], data = [none]
}
return false;
} } |
public class class_name {
public static String getSafeFileName(String orig)
{
if (orig != null)
{
return orig.replaceAll("[^0-9A-Za-z-]", "_");
}
else
{
return UUID.randomUUID().toString();
}
} } | public class class_name {
public static String getSafeFileName(String orig)
{
if (orig != null)
{
return orig.replaceAll("[^0-9A-Za-z-]", "_"); // depends on control dependency: [if], data = [none]
}
else
{
return UUID.randomUUID().toString(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private void authorize() {
Map<String, String> param = new HashMap<>();
param.put("clientId", clientId);
param.put("authorizeToken", authorizeToken);
String result = HttpUtils.sendPost(authorizeUrl, param);
Map<String, String> resultMap = parseHttpKvString(result);
if (resultMap.isEmpty()) {
throw new GetSequenceFailedException("clientId:" + clientId + " authorize failed, return message is empty");
} else {
if (resultMap.get("errorCode") != null) {
throw new GetSequenceFailedException("clientId:" + clientId + " authorize failed, return message is: "
+ result);
}
String accessUrl = resultMap.get("accessUrl");
String accessToken = resultMap.get("accessToken");
if (accessUrl == null || accessToken == null) {
throw new GetSequenceFailedException(
"clientId:"
+ clientId
+ " authorize failed, accessUrl or accessToken is null, detail message is "
+ result);
}
try {
accessUrl = URLDecoder.decode(accessUrl.trim(), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new GetSequenceFailedException(e);
}
this.accessUrl = accessUrl;
this.accessToken = accessToken;
}
} } | public class class_name {
private void authorize() {
Map<String, String> param = new HashMap<>();
param.put("clientId", clientId);
param.put("authorizeToken", authorizeToken);
String result = HttpUtils.sendPost(authorizeUrl, param);
Map<String, String> resultMap = parseHttpKvString(result);
if (resultMap.isEmpty()) {
throw new GetSequenceFailedException("clientId:" + clientId + " authorize failed, return message is empty");
} else {
if (resultMap.get("errorCode") != null) {
throw new GetSequenceFailedException("clientId:" + clientId + " authorize failed, return message is: "
+ result);
}
String accessUrl = resultMap.get("accessUrl");
String accessToken = resultMap.get("accessToken");
if (accessUrl == null || accessToken == null) {
throw new GetSequenceFailedException(
"clientId:"
+ clientId
+ " authorize failed, accessUrl or accessToken is null, detail message is "
+ result);
}
try {
accessUrl = URLDecoder.decode(accessUrl.trim(), "UTF-8"); // depends on control dependency: [try], data = [none]
} catch (UnsupportedEncodingException e) {
throw new GetSequenceFailedException(e);
} // depends on control dependency: [catch], data = [none]
this.accessUrl = accessUrl; // depends on control dependency: [if], data = [none]
this.accessToken = accessToken; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static <K, V> V getOrDefault(final Map<K, V> map, final K key, final Function<K, V> supplier)
{
V value = map.get(key);
if (value == null)
{
value = supplier.apply(key);
map.put(key, value);
}
return value;
} } | public class class_name {
public static <K, V> V getOrDefault(final Map<K, V> map, final K key, final Function<K, V> supplier)
{
V value = map.get(key);
if (value == null)
{
value = supplier.apply(key); // depends on control dependency: [if], data = [none]
map.put(key, value); // depends on control dependency: [if], data = [none]
}
return value;
} } |
public class class_name {
@Override
public LoadBalancerFilter and(LoadBalancerFilter otherFilter) {
checkNotNull(otherFilter, "Other filter must be not a null");
if (evaluation instanceof SingleFilterEvaluation &&
otherFilter.evaluation instanceof SingleFilterEvaluation) {
return
new LoadBalancerFilter(
getDataCenterFilter().and(otherFilter.getDataCenterFilter()),
getPredicate().and(otherFilter.getPredicate())
);
} else {
evaluation = new AndEvaluation<>(evaluation, otherFilter, LoadBalancerMetadata::getName);
return this;
}
} } | public class class_name {
@Override
public LoadBalancerFilter and(LoadBalancerFilter otherFilter) {
checkNotNull(otherFilter, "Other filter must be not a null");
if (evaluation instanceof SingleFilterEvaluation &&
otherFilter.evaluation instanceof SingleFilterEvaluation) {
return
new LoadBalancerFilter(
getDataCenterFilter().and(otherFilter.getDataCenterFilter()),
getPredicate().and(otherFilter.getPredicate())
); // depends on control dependency: [if], data = [none]
} else {
evaluation = new AndEvaluation<>(evaluation, otherFilter, LoadBalancerMetadata::getName); // depends on control dependency: [if], data = [none]
return this; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
@Override
public void solve(DefaultSolverScope<Solution_> solverScope) {
CustomPhaseScope<Solution_> phaseScope = new CustomPhaseScope<>(solverScope);
phaseStarted(phaseScope);
CustomStepScope<Solution_> stepScope = new CustomStepScope<>(phaseScope);
for (CustomPhaseCommand<Solution_> customPhaseCommand : customPhaseCommandList) {
solverScope.checkYielding();
if (termination.isPhaseTerminated(phaseScope)) {
break;
}
stepStarted(stepScope);
doStep(stepScope, customPhaseCommand);
stepEnded(stepScope);
phaseScope.setLastCompletedStepScope(stepScope);
stepScope = new CustomStepScope<>(phaseScope);
}
phaseEnded(phaseScope);
} } | public class class_name {
@Override
public void solve(DefaultSolverScope<Solution_> solverScope) {
CustomPhaseScope<Solution_> phaseScope = new CustomPhaseScope<>(solverScope);
phaseStarted(phaseScope);
CustomStepScope<Solution_> stepScope = new CustomStepScope<>(phaseScope);
for (CustomPhaseCommand<Solution_> customPhaseCommand : customPhaseCommandList) {
solverScope.checkYielding(); // depends on control dependency: [for], data = [none]
if (termination.isPhaseTerminated(phaseScope)) {
break;
}
stepStarted(stepScope); // depends on control dependency: [for], data = [none]
doStep(stepScope, customPhaseCommand); // depends on control dependency: [for], data = [customPhaseCommand]
stepEnded(stepScope); // depends on control dependency: [for], data = [none]
phaseScope.setLastCompletedStepScope(stepScope); // depends on control dependency: [for], data = [none]
stepScope = new CustomStepScope<>(phaseScope); // depends on control dependency: [for], data = [none]
}
phaseEnded(phaseScope);
} } |
public class class_name {
private List<Float> interpolateDownwards(float max, int steps) {
List<Float> result = new ArrayList<Float>();
if (max > 0) {
// We try to generate a "nice" descending list of non-negative floats
// where the step size is bigger for bigger "max" values.
float base = (max > 1) ? (float)Math.floor(max) : max;
float stepSize = 1000f;
// reduce step size until the smallest element is greater than max/10.
while ((base - (steps * stepSize)) < (max / 10.0f)) {
stepSize = reduceStepSize(stepSize);
}
// we have determined the step size, now we generate the actual numbers
for (int i = 0; i < steps; i++) {
result.add(new Float(base - ((i + 1) * stepSize)));
}
Collections.reverse(result);
} else {
LOG.warn("Invalid navpos value: " + max);
for (int i = 0; i < steps; i++) {
result.add(new Float(max - (i + 1)));
}
Collections.reverse(result);
}
return result;
} } | public class class_name {
private List<Float> interpolateDownwards(float max, int steps) {
List<Float> result = new ArrayList<Float>();
if (max > 0) {
// We try to generate a "nice" descending list of non-negative floats
// where the step size is bigger for bigger "max" values.
float base = (max > 1) ? (float)Math.floor(max) : max;
float stepSize = 1000f;
// reduce step size until the smallest element is greater than max/10.
while ((base - (steps * stepSize)) < (max / 10.0f)) {
stepSize = reduceStepSize(stepSize);
// depends on control dependency: [while], data = [none]
}
// we have determined the step size, now we generate the actual numbers
for (int i = 0; i < steps; i++) {
result.add(new Float(base - ((i + 1) * stepSize)));
// depends on control dependency: [for], data = [i]
}
Collections.reverse(result);
} else {
LOG.warn("Invalid navpos value: " + max);
for (int i = 0; i < steps; i++) {
result.add(new Float(max - (i + 1)));
}
Collections.reverse(result);
}
return result;
} } |
public class class_name {
@Override
public String getProperty(final String _name)
{
String value = super.getProperty(_name);
if (value == null && getParentType() != null) {
value = getParentType().getProperty(_name);
}
return value;
} } | public class class_name {
@Override
public String getProperty(final String _name)
{
String value = super.getProperty(_name);
if (value == null && getParentType() != null) {
value = getParentType().getProperty(_name); // depends on control dependency: [if], data = [none]
}
return value;
} } |
public class class_name {
@Override
public void generateWriteProperty(Builder methodBuilder, String editorName, TypeName beanClass, String beanName,
PrefsProperty property) {
if (nullable) {
methodBuilder.beginControlFlow("if ($L!=null) ", getter(beanName, beanClass, property));
}
methodBuilder.addCode("$L.put" + PREFS_TYPE + "($S,", editorName, property.getPreferenceKey());
if (property.hasTypeAdapter()) {
methodBuilder.addCode("$T.getAdapter($T.class).toData(", PrefsTypeAdapterUtils.class,
TypeUtility.typeName(property.typeAdapter.adapterClazz));
}
methodBuilder.addCode(PREFS_CONVERT + "$L", getter(beanName, beanClass, property));
if (property.hasTypeAdapter()) {
methodBuilder.addCode(")");
}
methodBuilder.addCode(");\n");
if (nullable) {
methodBuilder.endControlFlow();
}
} } | public class class_name {
@Override
public void generateWriteProperty(Builder methodBuilder, String editorName, TypeName beanClass, String beanName,
PrefsProperty property) {
if (nullable) {
methodBuilder.beginControlFlow("if ($L!=null) ", getter(beanName, beanClass, property)); // depends on control dependency: [if], data = [none]
}
methodBuilder.addCode("$L.put" + PREFS_TYPE + "($S,", editorName, property.getPreferenceKey());
if (property.hasTypeAdapter()) {
methodBuilder.addCode("$T.getAdapter($T.class).toData(", PrefsTypeAdapterUtils.class,
TypeUtility.typeName(property.typeAdapter.adapterClazz)); // depends on control dependency: [if], data = [none]
}
methodBuilder.addCode(PREFS_CONVERT + "$L", getter(beanName, beanClass, property));
if (property.hasTypeAdapter()) {
methodBuilder.addCode(")"); // depends on control dependency: [if], data = [none]
}
methodBuilder.addCode(");\n");
if (nullable) {
methodBuilder.endControlFlow(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private long getDashboardRefreshRate(final DashboardConfig selectedDashboardConfig) {
if (selectedDashboardConfig == null) {
return DEFAULT_DASHBOARD_REFRESH_RATE;
}
return TimeUnit.SECONDS.toMillis(selectedDashboardConfig.getRefresh());
} } | public class class_name {
private long getDashboardRefreshRate(final DashboardConfig selectedDashboardConfig) {
if (selectedDashboardConfig == null) {
return DEFAULT_DASHBOARD_REFRESH_RATE; // depends on control dependency: [if], data = [none]
}
return TimeUnit.SECONDS.toMillis(selectedDashboardConfig.getRefresh());
} } |
public class class_name {
@Override
public final CharSequence getStringValueCS() {
String mValue = "";
try {
final INodeReadTrx rtx = createRtxAndMove();
switch (nodeKind) {
case ROOT:
case ELEMENT:
mValue = expandString();
break;
case ATTRIBUTE:
mValue = emptyIfNull(rtx.getValueOfCurrentNode());
break;
case TEXT:
mValue = rtx.getValueOfCurrentNode();
break;
case COMMENT:
case PROCESSING:
mValue = emptyIfNull(rtx.getValueOfCurrentNode());
break;
default:
mValue = "";
}
} catch (final TTException exc) {
LOGGER.error(exc.toString());
}
return mValue;
} } | public class class_name {
@Override
public final CharSequence getStringValueCS() {
String mValue = "";
try {
final INodeReadTrx rtx = createRtxAndMove();
switch (nodeKind) {
case ROOT:
case ELEMENT:
mValue = expandString();
break;
case ATTRIBUTE:
mValue = emptyIfNull(rtx.getValueOfCurrentNode());
break;
case TEXT:
mValue = rtx.getValueOfCurrentNode();
break;
case COMMENT:
case PROCESSING:
mValue = emptyIfNull(rtx.getValueOfCurrentNode());
break;
default:
mValue = "";
}
} catch (final TTException exc) {
LOGGER.error(exc.toString());
} // depends on control dependency: [catch], data = [none]
return mValue;
} } |
public class class_name {
public static Date convertTimeToDate(Date time)
{
if (time != null)
{
DataConverters.initGlobals();
Calendar calendar = DataConverters.gCalendar;
calendar.setTime(time);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
time = calendar.getTime();
}
return time;
} } | public class class_name {
public static Date convertTimeToDate(Date time)
{
if (time != null)
{
DataConverters.initGlobals(); // depends on control dependency: [if], data = [none]
Calendar calendar = DataConverters.gCalendar;
calendar.setTime(time); // depends on control dependency: [if], data = [(time]
calendar.set(Calendar.HOUR_OF_DAY, 0); // depends on control dependency: [if], data = [none]
calendar.set(Calendar.MINUTE, 0); // depends on control dependency: [if], data = [none]
calendar.set(Calendar.SECOND, 0); // depends on control dependency: [if], data = [none]
calendar.set(Calendar.MILLISECOND, 0); // depends on control dependency: [if], data = [none]
time = calendar.getTime(); // depends on control dependency: [if], data = [none]
}
return time;
} } |
public class class_name {
@Nullable
public TransitionValues getTransitionValues(@NonNull View view, boolean start) {
if (mParent != null) {
return mParent.getTransitionValues(view, start);
}
TransitionValuesMaps valuesMaps = start ? mStartValues : mEndValues;
return valuesMaps.viewValues.get(view);
} } | public class class_name {
@Nullable
public TransitionValues getTransitionValues(@NonNull View view, boolean start) {
if (mParent != null) {
return mParent.getTransitionValues(view, start); // depends on control dependency: [if], data = [none]
}
TransitionValuesMaps valuesMaps = start ? mStartValues : mEndValues;
return valuesMaps.viewValues.get(view);
} } |
public class class_name {
public static double quantile(double val, double mu, double sigma, double k) {
if(val < 0.0 || val > 1.0) {
return Double.NaN;
}
if(k < 0) {
return mu + sigma * Math.max((1. - FastMath.pow(-FastMath.log(val), k)) / k, 1. / k);
}
else if(k > 0) {
return mu + sigma * Math.min((1. - FastMath.pow(-FastMath.log(val), k)) / k, 1. / k);
}
else { // Gumbel
return mu + sigma * FastMath.log(1. / FastMath.log(1. / val));
}
} } | public class class_name {
public static double quantile(double val, double mu, double sigma, double k) {
if(val < 0.0 || val > 1.0) {
return Double.NaN; // depends on control dependency: [if], data = [none]
}
if(k < 0) {
return mu + sigma * Math.max((1. - FastMath.pow(-FastMath.log(val), k)) / k, 1. / k); // depends on control dependency: [if], data = [none]
}
else if(k > 0) {
return mu + sigma * Math.min((1. - FastMath.pow(-FastMath.log(val), k)) / k, 1. / k); // depends on control dependency: [if], data = [none]
}
else { // Gumbel
return mu + sigma * FastMath.log(1. / FastMath.log(1. / val)); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
protected JsonResult login() {
T authToken;
authToken = loginViaBasicAuth(servletRequest);
if (authToken == null) {
authToken = loginViaRequestParams(servletRequest);
}
if (authToken == null) {
log.warn("Login failed.");
return JsonResult.of(HttpStatus.error401().unauthorized("Login failed."));
}
log.info("login OK!");
final UserSession<T> userSession = new UserSession<>(authToken, userAuth.tokenValue(authToken));
userSession.start(servletRequest, servletResponse);
// return token
return tokenAsJson(authToken);
} } | public class class_name {
protected JsonResult login() {
T authToken;
authToken = loginViaBasicAuth(servletRequest);
if (authToken == null) {
authToken = loginViaRequestParams(servletRequest); // depends on control dependency: [if], data = [none]
}
if (authToken == null) {
log.warn("Login failed."); // depends on control dependency: [if], data = [none]
return JsonResult.of(HttpStatus.error401().unauthorized("Login failed.")); // depends on control dependency: [if], data = [none]
}
log.info("login OK!");
final UserSession<T> userSession = new UserSession<>(authToken, userAuth.tokenValue(authToken));
userSession.start(servletRequest, servletResponse);
// return token
return tokenAsJson(authToken);
} } |
public class class_name {
public static CommandResult execCommand(String[] commands, boolean isRoot, boolean isNeedResultMsg) {
int result = -1;
if (commands == null || commands.length == 0) {
return new CommandResult(result, null, null);
}
Process process = null;
BufferedReader successResult = null;
BufferedReader errorResult = null;
StringBuilder successMsg = null;
StringBuilder errorMsg = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec(isRoot ? COMMAND_SU : COMMAND_SH);
os = new DataOutputStream(process.getOutputStream());
for (String command : commands) {
if (command == null) {
continue;
}
// donnot use os.writeBytes(commmand), avoid chinese charset error
os.write(command.getBytes());
os.writeBytes(COMMAND_LINE_END);
os.flush();
}
os.writeBytes(COMMAND_EXIT);
os.flush();
result = process.waitFor();
// get command result
if (isNeedResultMsg) {
successMsg = new StringBuilder();
errorMsg = new StringBuilder();
successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String s;
while ((s = successResult.readLine()) != null) {
successMsg.append(s);
}
while ((s = errorResult.readLine()) != null) {
errorMsg.append(s);
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (os != null) {
os.close();
}
if (successResult != null) {
successResult.close();
}
if (errorResult != null) {
errorResult.close();
}
} catch (IOException e) {
e.printStackTrace();
}
if (process != null) {
process.destroy();
}
}
return new CommandResult(result, successMsg == null ? null : successMsg.toString(), errorMsg == null ? null
: errorMsg.toString());
} } | public class class_name {
public static CommandResult execCommand(String[] commands, boolean isRoot, boolean isNeedResultMsg) {
int result = -1;
if (commands == null || commands.length == 0) {
return new CommandResult(result, null, null); // depends on control dependency: [if], data = [none]
}
Process process = null;
BufferedReader successResult = null;
BufferedReader errorResult = null;
StringBuilder successMsg = null;
StringBuilder errorMsg = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec(isRoot ? COMMAND_SU : COMMAND_SH); // depends on control dependency: [try], data = [none]
os = new DataOutputStream(process.getOutputStream()); // depends on control dependency: [try], data = [none]
for (String command : commands) {
if (command == null) {
continue;
}
// donnot use os.writeBytes(commmand), avoid chinese charset error
os.write(command.getBytes()); // depends on control dependency: [for], data = [command]
os.writeBytes(COMMAND_LINE_END); // depends on control dependency: [for], data = [none]
os.flush(); // depends on control dependency: [for], data = [none]
}
os.writeBytes(COMMAND_EXIT); // depends on control dependency: [try], data = [none]
os.flush(); // depends on control dependency: [try], data = [none]
result = process.waitFor(); // depends on control dependency: [try], data = [none]
// get command result
if (isNeedResultMsg) {
successMsg = new StringBuilder(); // depends on control dependency: [if], data = [none]
errorMsg = new StringBuilder(); // depends on control dependency: [if], data = [none]
successResult = new BufferedReader(new InputStreamReader(process.getInputStream())); // depends on control dependency: [if], data = [none]
errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream())); // depends on control dependency: [if], data = [none]
String s;
while ((s = successResult.readLine()) != null) {
successMsg.append(s); // depends on control dependency: [while], data = [none]
}
while ((s = errorResult.readLine()) != null) {
errorMsg.append(s); // depends on control dependency: [while], data = [none]
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) { // depends on control dependency: [catch], data = [none]
e.printStackTrace();
} finally { // depends on control dependency: [catch], data = [none]
try {
if (os != null) {
os.close(); // depends on control dependency: [if], data = [none]
}
if (successResult != null) {
successResult.close(); // depends on control dependency: [if], data = [none]
}
if (errorResult != null) {
errorResult.close(); // depends on control dependency: [if], data = [none]
}
} catch (IOException e) {
e.printStackTrace();
} // depends on control dependency: [catch], data = [none]
if (process != null) {
process.destroy(); // depends on control dependency: [if], data = [none]
}
}
return new CommandResult(result, successMsg == null ? null : successMsg.toString(), errorMsg == null ? null
: errorMsg.toString());
} } |
public class class_name {
@Override
protected PathHessian buildParentPath(QueryBuilder builder)
{
PathMapHessian pathMap = _parent.buildPathMap(builder);
PathHessian subPath = pathMap.get(_name);
if (subPath == null) {
PathMapHessian pathMapSelf = buildPathMap(builder);
subPath = new PathHessianFieldParent(this, pathMapSelf, _name);
pathMap.put(_name, subPath);
}
return subPath;
} } | public class class_name {
@Override
protected PathHessian buildParentPath(QueryBuilder builder)
{
PathMapHessian pathMap = _parent.buildPathMap(builder);
PathHessian subPath = pathMap.get(_name);
if (subPath == null) {
PathMapHessian pathMapSelf = buildPathMap(builder);
subPath = new PathHessianFieldParent(this, pathMapSelf, _name); // depends on control dependency: [if], data = [none]
pathMap.put(_name, subPath); // depends on control dependency: [if], data = [none]
}
return subPath;
} } |
public class class_name {
public double calculatePathProbability(SimulationPath path) {
Connection connection = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
connection = bamDataSource.getConnection();
// collect information about node enter events
pstmt = connection.prepareStatement(PROCESS_INSTANCE_COUNT_QUERY);
pstmt.setString(1, processId);
rs = pstmt.executeQuery();
Integer instanceCount = 1;
if (rs.next()) {
instanceCount = rs.getInt(1);
}
String parameters = buildParameterPlaceHolder(path.getActivityIds().size());
String query = PROCESS_INSTANCE_COUNT_FOR_PATH_QUERY.replaceFirst("@1", parameters);
pstmt = connection.prepareStatement(query);
pstmt.setString(1, processId);
int parameterIndex = 2;
for (String node : path.getActivityIds()) {
pstmt.setString(parameterIndex, node.replaceFirst("_", ""));
parameterIndex++;
}
rs = pstmt.executeQuery();
Integer pathcount = 0;
if (rs.next()) {
pathcount = rs.getInt(1)/2;
}
double result = (100 * pathcount) / instanceCount;
path.setProbability(result);
return result;
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
}
}
if (pstmt != null) {
try {
pstmt.close();
} catch (SQLException e) {
}
}
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
}
}
}
return -1;
} } | public class class_name {
public double calculatePathProbability(SimulationPath path) {
Connection connection = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
connection = bamDataSource.getConnection(); // depends on control dependency: [try], data = [none]
// collect information about node enter events
pstmt = connection.prepareStatement(PROCESS_INSTANCE_COUNT_QUERY); // depends on control dependency: [try], data = [none]
pstmt.setString(1, processId); // depends on control dependency: [try], data = [none]
rs = pstmt.executeQuery(); // depends on control dependency: [try], data = [none]
Integer instanceCount = 1;
if (rs.next()) {
instanceCount = rs.getInt(1); // depends on control dependency: [if], data = [none]
}
String parameters = buildParameterPlaceHolder(path.getActivityIds().size());
String query = PROCESS_INSTANCE_COUNT_FOR_PATH_QUERY.replaceFirst("@1", parameters);
pstmt = connection.prepareStatement(query); // depends on control dependency: [try], data = [none]
pstmt.setString(1, processId); // depends on control dependency: [try], data = [none]
int parameterIndex = 2;
for (String node : path.getActivityIds()) {
pstmt.setString(parameterIndex, node.replaceFirst("_", "")); // depends on control dependency: [for], data = [node]
parameterIndex++; // depends on control dependency: [for], data = [none]
}
rs = pstmt.executeQuery(); // depends on control dependency: [try], data = [none]
Integer pathcount = 0;
if (rs.next()) {
pathcount = rs.getInt(1)/2; // depends on control dependency: [if], data = [none]
}
double result = (100 * pathcount) / instanceCount;
path.setProbability(result); // depends on control dependency: [try], data = [none]
return result; // depends on control dependency: [try], data = [none]
} catch (SQLException e) {
e.printStackTrace();
} finally { // depends on control dependency: [catch], data = [none]
if (rs != null) {
try {
rs.close(); // depends on control dependency: [try], data = [none]
} catch (SQLException e) {
} // depends on control dependency: [catch], data = [none]
}
if (pstmt != null) {
try {
pstmt.close(); // depends on control dependency: [try], data = [none]
} catch (SQLException e) {
} // depends on control dependency: [catch], data = [none]
}
if (connection != null) {
try {
connection.close(); // depends on control dependency: [try], data = [none]
} catch (SQLException e) {
} // depends on control dependency: [catch], data = [none]
}
}
return -1;
} } |
public class class_name {
public void update(CmsPublishedResource res) {
try {
update(res.getStructureId(), res.getRootPath(), res.getType(), res.getState());
} catch (CmsRuntimeException e) {
// may happen during import of org.opencms.base module
LOG.warn(e.getLocalizedMessage(), e);
}
} } | public class class_name {
public void update(CmsPublishedResource res) {
try {
update(res.getStructureId(), res.getRootPath(), res.getType(), res.getState());
// depends on control dependency: [try], data = [none]
} catch (CmsRuntimeException e) {
// may happen during import of org.opencms.base module
LOG.warn(e.getLocalizedMessage(), e);
}
// depends on control dependency: [catch], data = [none]
} } |
public class class_name {
protected final void run(Block block) {
if (stopping) {
return;
}
final Authentication auth = Jenkins.getAuthentication();
task = GeneralNonBlockingStepExecutionUtils.getExecutorService().submit(() -> {
threadName = Thread.currentThread().getName();
try {
try (ACLContext acl = ACL.as(auth)) {
block.run();
}
} catch (Throwable e) {
if (!stopping) {
getContext().onFailure(e);
}
} finally {
threadName = null;
task = null;
}
});
} } | public class class_name {
protected final void run(Block block) {
if (stopping) {
return; // depends on control dependency: [if], data = [none]
}
final Authentication auth = Jenkins.getAuthentication();
task = GeneralNonBlockingStepExecutionUtils.getExecutorService().submit(() -> {
threadName = Thread.currentThread().getName();
try {
try (ACLContext acl = ACL.as(auth)) {
block.run();
}
} catch (Throwable e) {
if (!stopping) {
getContext().onFailure(e); // depends on control dependency: [if], data = [none]
}
} finally { // depends on control dependency: [catch], data = [none]
threadName = null;
task = null;
}
});
} } |
public class class_name {
public StreamRecord<T> getStreamRecord() {
StreamRecord<T> streamRecord = new StreamRecord<>(value);
if (hasTimestamp) {
streamRecord.setTimestamp(timestamp);
}
return streamRecord;
} } | public class class_name {
public StreamRecord<T> getStreamRecord() {
StreamRecord<T> streamRecord = new StreamRecord<>(value);
if (hasTimestamp) {
streamRecord.setTimestamp(timestamp); // depends on control dependency: [if], data = [none]
}
return streamRecord;
} } |
public class class_name {
public void marshall(PutLoggingConfigurationRequest putLoggingConfigurationRequest, ProtocolMarshaller protocolMarshaller) {
if (putLoggingConfigurationRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(putLoggingConfigurationRequest.getLoggingConfiguration(), LOGGINGCONFIGURATION_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(PutLoggingConfigurationRequest putLoggingConfigurationRequest, ProtocolMarshaller protocolMarshaller) {
if (putLoggingConfigurationRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(putLoggingConfigurationRequest.getLoggingConfiguration(), LOGGINGCONFIGURATION_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 java.util.List<String> getTaskArns() {
if (taskArns == null) {
taskArns = new com.amazonaws.internal.SdkInternalList<String>();
}
return taskArns;
} } | public class class_name {
public java.util.List<String> getTaskArns() {
if (taskArns == null) {
taskArns = new com.amazonaws.internal.SdkInternalList<String>(); // depends on control dependency: [if], data = [none]
}
return taskArns;
} } |
public class class_name {
public static boolean writeToFile(Bitmap bmp, String fileName) {
if (bmp == null || StringUtils.isNullOrEmpty(fileName))
return false;
FileOutputStream fos = null;
try {
fos = new FileOutputStream(fileName);
bmp.compress(CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
} catch (Exception e) {
return false;
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return true;
} } | public class class_name {
public static boolean writeToFile(Bitmap bmp, String fileName) {
if (bmp == null || StringUtils.isNullOrEmpty(fileName))
return false;
FileOutputStream fos = null;
try {
fos = new FileOutputStream(fileName); // depends on control dependency: [try], data = [none]
bmp.compress(CompressFormat.PNG, 100, fos); // depends on control dependency: [try], data = [none]
fos.flush(); // depends on control dependency: [try], data = [none]
fos.close(); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
return false;
} finally { // depends on control dependency: [catch], data = [none]
if (fos != null) {
try {
fos.close(); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // depends on control dependency: [catch], data = [none]
}
}
return true;
} } |
public class class_name {
private String getHalfMatrixString(Permutation permutation) {
StringBuilder builder = new StringBuilder(permutation.size());
int size = permutation.size();
for (int indexI = 0; indexI < size - 1; indexI++) {
for (int indexJ = indexI + 1; indexJ < size; indexJ++) {
builder.append(getConnectivity(permutation.get(indexI), permutation.get(indexJ)));
}
}
return builder.toString();
} } | public class class_name {
private String getHalfMatrixString(Permutation permutation) {
StringBuilder builder = new StringBuilder(permutation.size());
int size = permutation.size();
for (int indexI = 0; indexI < size - 1; indexI++) {
for (int indexJ = indexI + 1; indexJ < size; indexJ++) {
builder.append(getConnectivity(permutation.get(indexI), permutation.get(indexJ))); // depends on control dependency: [for], data = [indexJ]
}
}
return builder.toString();
} } |
public class class_name {
public ConfusionMatrix getTransposedMatrix()
{
ConfusionMatrix result = new ConfusionMatrix();
for (Map.Entry<String, Map<String, Integer>> gold : this.map.entrySet()) {
for (Map.Entry<String, Integer> predicted : gold.getValue().entrySet()) {
int value = predicted.getValue();
// add reverted values
result.increaseValue(predicted.getKey(), gold.getKey(), value);
}
}
return result;
} } | public class class_name {
public ConfusionMatrix getTransposedMatrix()
{
ConfusionMatrix result = new ConfusionMatrix();
for (Map.Entry<String, Map<String, Integer>> gold : this.map.entrySet()) {
for (Map.Entry<String, Integer> predicted : gold.getValue().entrySet()) {
int value = predicted.getValue();
// add reverted values
result.increaseValue(predicted.getKey(), gold.getKey(), value); // depends on control dependency: [for], data = [predicted]
}
}
return result;
} } |
public class class_name {
public void marshall(WorkflowTypeInfo workflowTypeInfo, ProtocolMarshaller protocolMarshaller) {
if (workflowTypeInfo == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(workflowTypeInfo.getWorkflowType(), WORKFLOWTYPE_BINDING);
protocolMarshaller.marshall(workflowTypeInfo.getStatus(), STATUS_BINDING);
protocolMarshaller.marshall(workflowTypeInfo.getDescription(), DESCRIPTION_BINDING);
protocolMarshaller.marshall(workflowTypeInfo.getCreationDate(), CREATIONDATE_BINDING);
protocolMarshaller.marshall(workflowTypeInfo.getDeprecationDate(), DEPRECATIONDATE_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(WorkflowTypeInfo workflowTypeInfo, ProtocolMarshaller protocolMarshaller) {
if (workflowTypeInfo == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(workflowTypeInfo.getWorkflowType(), WORKFLOWTYPE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(workflowTypeInfo.getStatus(), STATUS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(workflowTypeInfo.getDescription(), DESCRIPTION_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(workflowTypeInfo.getCreationDate(), CREATIONDATE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(workflowTypeInfo.getDeprecationDate(), DEPRECATIONDATE_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 Observable<ServiceResponse<Page<JobExecutionInner>>> listByStepWithServiceResponseAsync(final String resourceGroupName, final String serverName, final String jobAgentName, final String jobName, final UUID jobExecutionId, final String stepName) {
return listByStepSinglePageAsync(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName)
.concatMap(new Func1<ServiceResponse<Page<JobExecutionInner>>, Observable<ServiceResponse<Page<JobExecutionInner>>>>() {
@Override
public Observable<ServiceResponse<Page<JobExecutionInner>>> call(ServiceResponse<Page<JobExecutionInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listByStepNextWithServiceResponseAsync(nextPageLink));
}
});
} } | public class class_name {
public Observable<ServiceResponse<Page<JobExecutionInner>>> listByStepWithServiceResponseAsync(final String resourceGroupName, final String serverName, final String jobAgentName, final String jobName, final UUID jobExecutionId, final String stepName) {
return listByStepSinglePageAsync(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId, stepName)
.concatMap(new Func1<ServiceResponse<Page<JobExecutionInner>>, Observable<ServiceResponse<Page<JobExecutionInner>>>>() {
@Override
public Observable<ServiceResponse<Page<JobExecutionInner>>> call(ServiceResponse<Page<JobExecutionInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page); // depends on control dependency: [if], data = [none]
}
return Observable.just(page).concatWith(listByStepNextWithServiceResponseAsync(nextPageLink));
}
});
} } |
public class class_name {
@Nonnull
public static Homoglyph build (@Nonnull @WillClose final Reader aReader) throws IOException
{
ValueEnforcer.notNull (aReader, "reader");
try (final NonBlockingBufferedReader aBR = new NonBlockingBufferedReader (aReader))
{
final ICommonsList <IntSet> aList = new CommonsArrayList <> ();
String sLine;
while ((sLine = aBR.readLine ()) != null)
{
sLine = sLine.trim ();
if (sLine.startsWith ("#") || sLine.length () == 0)
continue;
final IntSet aSet = new IntSet (sLine.length () / 3);
for (final String sCharCode : StringHelper.getExploded (',', sLine))
{
final int nVal = StringParser.parseInt (sCharCode, 16, -1);
if (nVal >= 0)
aSet.add (nVal);
}
aList.add (aSet);
}
return new Homoglyph (aList);
}
} } | public class class_name {
@Nonnull
public static Homoglyph build (@Nonnull @WillClose final Reader aReader) throws IOException
{
ValueEnforcer.notNull (aReader, "reader");
try (final NonBlockingBufferedReader aBR = new NonBlockingBufferedReader (aReader))
{
final ICommonsList <IntSet> aList = new CommonsArrayList <> ();
String sLine;
while ((sLine = aBR.readLine ()) != null)
{
sLine = sLine.trim (); // depends on control dependency: [while], data = [none]
if (sLine.startsWith ("#") || sLine.length () == 0)
continue;
final IntSet aSet = new IntSet (sLine.length () / 3);
for (final String sCharCode : StringHelper.getExploded (',', sLine))
{
final int nVal = StringParser.parseInt (sCharCode, 16, -1);
if (nVal >= 0)
aSet.add (nVal);
}
aList.add (aSet); // depends on control dependency: [while], data = [none]
}
return new Homoglyph (aList);
}
} } |
public class class_name {
public static void sort(double[] doubleArray) {
boolean swapped = true;
while(swapped) {
swapped = false;
for(int i = 0; i < (doubleArray.length - 1 ); i++) {
if(doubleArray[i] > doubleArray[i + 1]) {
TrivialSwap.swap(doubleArray, i, i + 1);
swapped = true;
}
}
}
} } | public class class_name {
public static void sort(double[] doubleArray) {
boolean swapped = true;
while(swapped) {
swapped = false; // depends on control dependency: [while], data = [none]
for(int i = 0; i < (doubleArray.length - 1 ); i++) {
if(doubleArray[i] > doubleArray[i + 1]) {
TrivialSwap.swap(doubleArray, i, i + 1); // depends on control dependency: [if], data = [none]
swapped = true; // depends on control dependency: [if], data = [none]
}
}
}
} } |
public class class_name {
public void mapNodeToCliqueFamily(OpenBitSet[] varNodeToCliques, JunctionTreeClique[] jtNodes) {
for ( int i = 0; i < varNodeToCliques.length; i++ ) {
GraphNode<BayesVariable> varNode = graph.getNode( i );
// Get OpenBitSet for parents
OpenBitSet parents = new OpenBitSet();
int count = 0;
for ( Edge edge : varNode.getInEdges() ) {
parents.set( edge.getOutGraphNode().getId() );
count++;
}
if ( count == 0 ) {
// node has no parents, so simply find the smallest clique it's in.
}
OpenBitSet cliques = varNodeToCliques[i];
if ( cliques == null ) {
throw new IllegalStateException("Node exists, that is not part of a clique. " + varNode.toString());
}
int bestWeight = -1;
int clique = -1;
// finds the smallest node, that contains all the parents
for ( int j = cliques.nextSetBit(0); j >= 0; j = cliques.nextSetBit( j+ 1 ) ) {
JunctionTreeClique jtNode = jtNodes[j];
// if the node has parents, we find the small clique it's in.
// If it has parents then is jtNode a supserset of parents, visa-vis is parents a subset of jtNode
if ( (count == 0 || OpenBitSet.andNotCount(parents, jtNode.getBitSet()) == 0 ) && ( clique == -1 || jtNode.getBitSet().cardinality() < bestWeight ) ) {
bestWeight = (int) jtNode.getBitSet().cardinality();
clique = j;
}
}
if ( clique == -1 ) {
throw new IllegalStateException("No clique for node found." + varNode.toString());
}
varNode.getContent().setFamily( clique );
jtNodes[clique].addToFamily( varNode.getContent() );
}
} } | public class class_name {
public void mapNodeToCliqueFamily(OpenBitSet[] varNodeToCliques, JunctionTreeClique[] jtNodes) {
for ( int i = 0; i < varNodeToCliques.length; i++ ) {
GraphNode<BayesVariable> varNode = graph.getNode( i );
// Get OpenBitSet for parents
OpenBitSet parents = new OpenBitSet();
int count = 0;
for ( Edge edge : varNode.getInEdges() ) {
parents.set( edge.getOutGraphNode().getId() ); // depends on control dependency: [for], data = [edge]
count++; // depends on control dependency: [for], data = [none]
}
if ( count == 0 ) {
// node has no parents, so simply find the smallest clique it's in.
}
OpenBitSet cliques = varNodeToCliques[i];
if ( cliques == null ) {
throw new IllegalStateException("Node exists, that is not part of a clique. " + varNode.toString());
}
int bestWeight = -1;
int clique = -1;
// finds the smallest node, that contains all the parents
for ( int j = cliques.nextSetBit(0); j >= 0; j = cliques.nextSetBit( j+ 1 ) ) {
JunctionTreeClique jtNode = jtNodes[j];
// if the node has parents, we find the small clique it's in.
// If it has parents then is jtNode a supserset of parents, visa-vis is parents a subset of jtNode
if ( (count == 0 || OpenBitSet.andNotCount(parents, jtNode.getBitSet()) == 0 ) && ( clique == -1 || jtNode.getBitSet().cardinality() < bestWeight ) ) {
bestWeight = (int) jtNode.getBitSet().cardinality(); // depends on control dependency: [if], data = [none]
clique = j; // depends on control dependency: [if], data = [none]
}
}
if ( clique == -1 ) {
throw new IllegalStateException("No clique for node found." + varNode.toString());
}
varNode.getContent().setFamily( clique ); // depends on control dependency: [for], data = [none]
jtNodes[clique].addToFamily( varNode.getContent() ); // depends on control dependency: [for], data = [none]
}
} } |
public class class_name {
public void marshall(PortProbeDetail portProbeDetail, ProtocolMarshaller protocolMarshaller) {
if (portProbeDetail == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(portProbeDetail.getLocalPortDetails(), LOCALPORTDETAILS_BINDING);
protocolMarshaller.marshall(portProbeDetail.getRemoteIpDetails(), REMOTEIPDETAILS_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(PortProbeDetail portProbeDetail, ProtocolMarshaller protocolMarshaller) {
if (portProbeDetail == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(portProbeDetail.getLocalPortDetails(), LOCALPORTDETAILS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(portProbeDetail.getRemoteIpDetails(), REMOTEIPDETAILS_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 Observable<ServiceResponse<KeyBundle>> updateKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, List<JsonWebKeyOperation> keyOps, KeyAttributes keyAttributes, Map<String, String> tags) {
if (vaultBaseUrl == null) {
throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
}
if (keyName == null) {
throw new IllegalArgumentException("Parameter keyName is required and cannot be null.");
}
if (keyVersion == null) {
throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null.");
}
if (this.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
}
Validator.validate(keyOps);
Validator.validate(keyAttributes);
Validator.validate(tags);
KeyUpdateParameters parameters = new KeyUpdateParameters();
parameters.withKeyOps(keyOps);
parameters.withKeyAttributes(keyAttributes);
parameters.withTags(tags);
String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
return service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyBundle>>>() {
@Override
public Observable<ServiceResponse<KeyBundle>> call(Response<ResponseBody> response) {
try {
ServiceResponse<KeyBundle> clientResponse = updateKeyDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
} } | public class class_name {
public Observable<ServiceResponse<KeyBundle>> updateKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, List<JsonWebKeyOperation> keyOps, KeyAttributes keyAttributes, Map<String, String> tags) {
if (vaultBaseUrl == null) {
throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
}
if (keyName == null) {
throw new IllegalArgumentException("Parameter keyName is required and cannot be null.");
}
if (keyVersion == null) {
throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null.");
}
if (this.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
}
Validator.validate(keyOps);
Validator.validate(keyAttributes);
Validator.validate(tags);
KeyUpdateParameters parameters = new KeyUpdateParameters();
parameters.withKeyOps(keyOps);
parameters.withKeyAttributes(keyAttributes);
parameters.withTags(tags);
String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
return service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyBundle>>>() {
@Override
public Observable<ServiceResponse<KeyBundle>> call(Response<ResponseBody> response) {
try {
ServiceResponse<KeyBundle> clientResponse = updateKeyDelegate(response);
return Observable.just(clientResponse); // depends on control dependency: [try], data = [none]
} catch (Throwable t) {
return Observable.error(t);
} // depends on control dependency: [catch], data = [none]
}
});
} } |
public class class_name {
public RedBlackTreeNode<Key, Value> floorNode(Key key) {
if (isEmpty()) {
return null;
}
RedBlackTreeNode<Key, Value> x = floor(root, key);
if (x == null) {
return null;
} else {
return x;
}
} } | public class class_name {
public RedBlackTreeNode<Key, Value> floorNode(Key key) {
if (isEmpty()) {
return null; // depends on control dependency: [if], data = [none]
}
RedBlackTreeNode<Key, Value> x = floor(root, key);
if (x == null) {
return null; // depends on control dependency: [if], data = [none]
} else {
return x; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private static Set<String> findFiles(File sourceFolder, File baseFile) {
Set<String> retval = new HashSet<String>();
if (!sourceFolder.exists() || sourceFolder.isHidden()
|| !sourceFolder.isDirectory() || !sourceFolder.canRead()
|| isGitMetaDataFolder(sourceFolder)) {
return retval;
}
for (File file : sourceFolder.listFiles()) {
if (file.isDirectory()) {
retval.addAll(findFiles(file, sourceFolder));
} else {
retval.add(file.getAbsolutePath());
}
}
return retval;
} } | public class class_name {
private static Set<String> findFiles(File sourceFolder, File baseFile) {
Set<String> retval = new HashSet<String>();
if (!sourceFolder.exists() || sourceFolder.isHidden()
|| !sourceFolder.isDirectory() || !sourceFolder.canRead()
|| isGitMetaDataFolder(sourceFolder)) {
return retval; // depends on control dependency: [if], data = [none]
}
for (File file : sourceFolder.listFiles()) {
if (file.isDirectory()) {
retval.addAll(findFiles(file, sourceFolder)); // depends on control dependency: [if], data = [none]
} else {
retval.add(file.getAbsolutePath()); // depends on control dependency: [if], data = [none]
}
}
return retval;
} } |
public class class_name {
private void processMarkdown(List<MarkdownDTO> markdownDTOs, int options, final Map<String, Attributes> attributesMap) throws MojoExecutionException {
getLog().debug("Process Markdown");
getLog().debug("inputEncoding: '" + getInputEncoding() + "', outputEncoding: '" + getOutputEncoding() + "'");
//getLog().debug("parsingTimeout: " + getParsingTimeoutInMillis() + " ms");
getLog().debug("applyFiltering: " + applyFiltering);
MutableDataHolder flexmarkOptions = PegdownOptionsAdapter.flexmarkOptions(options).toMutable();
ArrayList<Extension> extensions = new ArrayList<Extension>();
for (Extension extension : flexmarkOptions.get(Parser.EXTENSIONS)) {
extensions.add(extension);
}
if (transformRelativeMarkdownLinks) {
flexmarkOptions.set(PageGeneratorExtension.INPUT_FILE_EXTENSIONS, inputFileExtensions);
extensions.add(PageGeneratorExtension.create());
}
if (!attributesMap.isEmpty()) {
flexmarkOptions.set(AttributesExtension.ATTRIBUTE_MAP, attributesMap);
extensions.add(AttributesExtension.create());
}
flexmarkOptions.set(Parser.EXTENSIONS, extensions);
Parser parser = Parser.builder(flexmarkOptions).build();
HtmlRenderer renderer = HtmlRenderer.builder(flexmarkOptions).build();
for (MarkdownDTO dto : markdownDTOs) {
getLog().debug("dto: " + dto);
try {
String headerHtml = "";
String footerHtml = "";
try {
if (StringUtils.isNotEmpty(headerHtmlFile)) {
headerHtml = FileUtils.readFileToString(new File(headerHtmlFile), getInputEncoding());
headerHtml = addTitleToHtmlFile(headerHtml, dto.title);
headerHtml = replaceVariables(headerHtml, dto.substitutes);
headerHtml = updateRelativePaths(headerHtml, dto.folderDepth);
}
if (StringUtils.isNotEmpty(footerHtmlFile)) {
footerHtml = FileUtils.readFileToString(new File(footerHtmlFile), getInputEncoding());
footerHtml = replaceVariables(footerHtml, dto.substitutes);
footerHtml = updateRelativePaths(footerHtml, dto.folderDepth);
}
} catch (FileNotFoundException e) {
if (failIfFilesAreMissing) {
throw e;
} else {
getLog().warn("header and/or footer file is missing.");
headerHtml = "";
footerHtml = "";
}
} catch (Exception e) {
throw new MojoExecutionException("Error while processing header/footer: " + e.getMessage(), e);
}
String markdown = FileUtils.readFileToString(dto.markdownFile, getInputEncoding());
markdown = replaceVariables(markdown, dto.substitutes);
// getLog().debug(markdown);
String markdownAsHtml;
Node document = parser.parse(markdown);
markdownAsHtml = renderer.render(document);
String data = headerHtml + markdownAsHtml + footerHtml;
FileUtils.writeStringToFile(dto.htmlFile, data, getOutputEncoding());
} catch (MojoExecutionException e) {
throw e;
} catch (IOException e) {
getLog().error("Error : " + e.getMessage(), e);
throw new MojoExecutionException("Unable to write file " + e.getMessage(), e);
}
}
} } | public class class_name {
private void processMarkdown(List<MarkdownDTO> markdownDTOs, int options, final Map<String, Attributes> attributesMap) throws MojoExecutionException {
getLog().debug("Process Markdown");
getLog().debug("inputEncoding: '" + getInputEncoding() + "', outputEncoding: '" + getOutputEncoding() + "'");
//getLog().debug("parsingTimeout: " + getParsingTimeoutInMillis() + " ms");
getLog().debug("applyFiltering: " + applyFiltering);
MutableDataHolder flexmarkOptions = PegdownOptionsAdapter.flexmarkOptions(options).toMutable();
ArrayList<Extension> extensions = new ArrayList<Extension>();
for (Extension extension : flexmarkOptions.get(Parser.EXTENSIONS)) {
extensions.add(extension);
}
if (transformRelativeMarkdownLinks) {
flexmarkOptions.set(PageGeneratorExtension.INPUT_FILE_EXTENSIONS, inputFileExtensions);
extensions.add(PageGeneratorExtension.create());
}
if (!attributesMap.isEmpty()) {
flexmarkOptions.set(AttributesExtension.ATTRIBUTE_MAP, attributesMap);
extensions.add(AttributesExtension.create());
}
flexmarkOptions.set(Parser.EXTENSIONS, extensions);
Parser parser = Parser.builder(flexmarkOptions).build();
HtmlRenderer renderer = HtmlRenderer.builder(flexmarkOptions).build();
for (MarkdownDTO dto : markdownDTOs) {
getLog().debug("dto: " + dto);
try {
String headerHtml = "";
String footerHtml = "";
try {
if (StringUtils.isNotEmpty(headerHtmlFile)) {
headerHtml = FileUtils.readFileToString(new File(headerHtmlFile), getInputEncoding()); // depends on control dependency: [if], data = [none]
headerHtml = addTitleToHtmlFile(headerHtml, dto.title); // depends on control dependency: [if], data = [none]
headerHtml = replaceVariables(headerHtml, dto.substitutes); // depends on control dependency: [if], data = [none]
headerHtml = updateRelativePaths(headerHtml, dto.folderDepth); // depends on control dependency: [if], data = [none]
}
if (StringUtils.isNotEmpty(footerHtmlFile)) {
footerHtml = FileUtils.readFileToString(new File(footerHtmlFile), getInputEncoding()); // depends on control dependency: [if], data = [none]
footerHtml = replaceVariables(footerHtml, dto.substitutes); // depends on control dependency: [if], data = [none]
footerHtml = updateRelativePaths(footerHtml, dto.folderDepth); // depends on control dependency: [if], data = [none]
}
} catch (FileNotFoundException e) {
if (failIfFilesAreMissing) {
throw e;
} else {
getLog().warn("header and/or footer file is missing."); // depends on control dependency: [if], data = [none]
headerHtml = "";
footerHtml = ""; // depends on control dependency: [if], data = [none]
}
} catch (Exception e) { // depends on control dependency: [catch], data = [none]
throw new MojoExecutionException("Error while processing header/footer: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
String markdown = FileUtils.readFileToString(dto.markdownFile, getInputEncoding());
markdown = replaceVariables(markdown, dto.substitutes); // depends on control dependency: [try], data = [none]
// getLog().debug(markdown);
String markdownAsHtml;
Node document = parser.parse(markdown);
markdownAsHtml = renderer.render(document); // depends on control dependency: [try], data = [none]
String data = headerHtml + markdownAsHtml + footerHtml;
FileUtils.writeStringToFile(dto.htmlFile, data, getOutputEncoding()); // depends on control dependency: [try], data = [none]
} catch (MojoExecutionException e) {
throw e;
} catch (IOException e) { // depends on control dependency: [catch], data = [none]
getLog().error("Error : " + e.getMessage(), e);
throw new MojoExecutionException("Unable to write file " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
}
} } |
public class class_name {
public List<ExpandedAnnotation> expand(final Annotation targetAnno) {
Objects.requireNonNull(targetAnno);
final List<ExpandedAnnotation> expandedList = new ArrayList<>();
if(isRepeated(targetAnno)) {
// 繰り返しのアノテーションの場合、要素を抽出する。
try {
final Method method = targetAnno.getClass().getMethod("value");
final Annotation[] annos = (Annotation[]) method.invoke(targetAnno);
int index = 0;
for(Annotation anno : annos) {
final List<ExpandedAnnotation> repeatedAnnos = expand(anno);
for(ExpandedAnnotation repeatedAnno : repeatedAnnos) {
repeatedAnno.setIndex(index);
}
expandedList.addAll(repeatedAnnos);
index++;
}
} catch (Exception e) {
throw new RuntimeException("fail get repeated value attribute.", e);
}
} else if(isComposed(targetAnno)) {
final ExpandedAnnotation composedAnno = new ExpandedAnnotation(targetAnno, true);
// 合成のアノテーションの場合、メタアノテーションを子供としてさらに抽出する。
final List<Annotation> childAnnos = Arrays.asList(targetAnno.annotationType().getAnnotations());
for(Annotation anno : childAnnos) {
final List<ExpandedAnnotation> nestedAnnos = expand(anno).stream()
.map(nestedAnno -> overrideAttribute(targetAnno, nestedAnno))
.collect(Collectors.toList());
composedAnno.addChilds(nestedAnnos);
}
Collections.sort(composedAnno.getChilds(), comparator);
expandedList.add(composedAnno);
} else {
// 通常のアノテーションの場合
expandedList.add(new ExpandedAnnotation(targetAnno, false));
}
Collections.sort(expandedList, comparator);
return expandedList;
} } | public class class_name {
public List<ExpandedAnnotation> expand(final Annotation targetAnno) {
Objects.requireNonNull(targetAnno);
final List<ExpandedAnnotation> expandedList = new ArrayList<>();
if(isRepeated(targetAnno)) {
// 繰り返しのアノテーションの場合、要素を抽出する。
try {
final Method method = targetAnno.getClass().getMethod("value");
final Annotation[] annos = (Annotation[]) method.invoke(targetAnno);
int index = 0;
for(Annotation anno : annos) {
final List<ExpandedAnnotation> repeatedAnnos = expand(anno);
for(ExpandedAnnotation repeatedAnno : repeatedAnnos) {
repeatedAnno.setIndex(index);
// depends on control dependency: [for], data = [repeatedAnno]
}
expandedList.addAll(repeatedAnnos);
// depends on control dependency: [for], data = [none]
index++;
// depends on control dependency: [for], data = [none]
}
} catch (Exception e) {
throw new RuntimeException("fail get repeated value attribute.", e);
}
// depends on control dependency: [catch], data = [none]
} else if(isComposed(targetAnno)) {
final ExpandedAnnotation composedAnno = new ExpandedAnnotation(targetAnno, true);
// 合成のアノテーションの場合、メタアノテーションを子供としてさらに抽出する。
final List<Annotation> childAnnos = Arrays.asList(targetAnno.annotationType().getAnnotations());
for(Annotation anno : childAnnos) {
final List<ExpandedAnnotation> nestedAnnos = expand(anno).stream()
.map(nestedAnno -> overrideAttribute(targetAnno, nestedAnno))
.collect(Collectors.toList());
composedAnno.addChilds(nestedAnnos);
// depends on control dependency: [for], data = [none]
}
Collections.sort(composedAnno.getChilds(), comparator);
// depends on control dependency: [if], data = [none]
expandedList.add(composedAnno);
// depends on control dependency: [if], data = [none]
} else {
// 通常のアノテーションの場合
expandedList.add(new ExpandedAnnotation(targetAnno, false));
// depends on control dependency: [if], data = [none]
}
Collections.sort(expandedList, comparator);
return expandedList;
} } |
public class class_name {
private String[] halfMatchI(String longtext, String shorttext, int i) {
// Start with a 1/4 length substring at position i as a seed.
String seed = longtext.substring(i, i + longtext.length() / 4);
int j = -1;
String best_common = "";
String best_longtext_a = "", best_longtext_b = "";
String best_shorttext_a = "", best_shorttext_b = "";
while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
int prefixLength = commonPrefix(longtext.substring(i),
shorttext.substring(j));
int suffixLength = commonSuffix(longtext.substring(0, i),
shorttext.substring(0, j));
if (best_common.length() < suffixLength + prefixLength) {
best_common = shorttext.substring(j - suffixLength, j)
+ shorttext.substring(j, j + prefixLength);
best_longtext_a = longtext.substring(0, i - suffixLength);
best_longtext_b = longtext.substring(i + prefixLength);
best_shorttext_a = shorttext.substring(0, j - suffixLength);
best_shorttext_b = shorttext.substring(j + prefixLength);
}
}
if (best_common.length() * 2 >= longtext.length()) {
return new String[]{best_longtext_a, best_longtext_b,
best_shorttext_a, best_shorttext_b, best_common};
} else {
return null;
}
} } | public class class_name {
private String[] halfMatchI(String longtext, String shorttext, int i) {
// Start with a 1/4 length substring at position i as a seed.
String seed = longtext.substring(i, i + longtext.length() / 4);
int j = -1;
String best_common = "";
String best_longtext_a = "", best_longtext_b = "";
String best_shorttext_a = "", best_shorttext_b = "";
while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
int prefixLength = commonPrefix(longtext.substring(i),
shorttext.substring(j));
int suffixLength = commonSuffix(longtext.substring(0, i),
shorttext.substring(0, j));
if (best_common.length() < suffixLength + prefixLength) {
best_common = shorttext.substring(j - suffixLength, j)
+ shorttext.substring(j, j + prefixLength); // depends on control dependency: [if], data = [none]
best_longtext_a = longtext.substring(0, i - suffixLength); // depends on control dependency: [if], data = [none]
best_longtext_b = longtext.substring(i + prefixLength); // depends on control dependency: [if], data = [none]
best_shorttext_a = shorttext.substring(0, j - suffixLength); // depends on control dependency: [if], data = [none]
best_shorttext_b = shorttext.substring(j + prefixLength); // depends on control dependency: [if], data = [none]
}
}
if (best_common.length() * 2 >= longtext.length()) {
return new String[]{best_longtext_a, best_longtext_b,
best_shorttext_a, best_shorttext_b, best_common}; // depends on control dependency: [if], data = [none]
} else {
return null; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static void setBackgroundResource(EfficientCacheView cacheView, int viewId,
@DrawableRes int resid) {
View view = cacheView.findViewByIdEfficient(viewId);
if (view != null) {
view.setBackgroundResource(resid);
}
} } | public class class_name {
public static void setBackgroundResource(EfficientCacheView cacheView, int viewId,
@DrawableRes int resid) {
View view = cacheView.findViewByIdEfficient(viewId);
if (view != null) {
view.setBackgroundResource(resid); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public long nextLong(int radix) {
// Check cached result
if ((typeCache != null) && (typeCache instanceof Long)
&& this.radix == radix) {
long val = ((Long)typeCache).longValue();
useTypeCache();
return val;
}
setRadix(radix);
clearCaches();
try {
String s = next(integerPattern());
if (matcher.group(SIMPLE_GROUP_INDEX) == null)
s = processIntegerToken(s);
return Long.parseLong(s, radix);
} catch (NumberFormatException nfe) {
position = matcher.start(); // don't skip bad token
throw new InputMismatchException(nfe.getMessage());
}
} } | public class class_name {
public long nextLong(int radix) {
// Check cached result
if ((typeCache != null) && (typeCache instanceof Long)
&& this.radix == radix) {
long val = ((Long)typeCache).longValue();
useTypeCache(); // depends on control dependency: [if], data = [none]
return val; // depends on control dependency: [if], data = [none]
}
setRadix(radix);
clearCaches();
try {
String s = next(integerPattern());
if (matcher.group(SIMPLE_GROUP_INDEX) == null)
s = processIntegerToken(s);
return Long.parseLong(s, radix); // depends on control dependency: [try], data = [none]
} catch (NumberFormatException nfe) {
position = matcher.start(); // don't skip bad token
throw new InputMismatchException(nfe.getMessage());
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private boolean isParentFirst(String resourceName) {
// default to the global setting and then see
// if this class belongs to a package which has been
// designated to use a specific loader first
// (this one or the parent one)
// TODO shouldn't this always return false in isolated mode?
boolean useParentFirst = parentFirst;
for (Enumeration e = systemPackages.elements(); e.hasMoreElements();) {
String packageName = (String) e.nextElement();
if (resourceName.startsWith(packageName)) {
useParentFirst = true;
break;
}
}
for (Enumeration e = loaderPackages.elements(); e.hasMoreElements();) {
String packageName = (String) e.nextElement();
if (resourceName.startsWith(packageName)) {
useParentFirst = false;
break;
}
}
return useParentFirst;
} } | public class class_name {
private boolean isParentFirst(String resourceName) {
// default to the global setting and then see
// if this class belongs to a package which has been
// designated to use a specific loader first
// (this one or the parent one)
// TODO shouldn't this always return false in isolated mode?
boolean useParentFirst = parentFirst;
for (Enumeration e = systemPackages.elements(); e.hasMoreElements();) {
String packageName = (String) e.nextElement();
if (resourceName.startsWith(packageName)) {
useParentFirst = true; // depends on control dependency: [if], data = [none]
break;
}
}
for (Enumeration e = loaderPackages.elements(); e.hasMoreElements();) {
String packageName = (String) e.nextElement();
if (resourceName.startsWith(packageName)) {
useParentFirst = false; // depends on control dependency: [if], data = [none]
break;
}
}
return useParentFirst;
} } |
public class class_name {
public KeyStore getKeyStore(String name, String type, String provider, String fileName, String password, boolean create, SSLConfig sslConfig) throws Exception {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(tc, "getKeyStore", new Object[] { name, type, provider, fileName, Boolean.valueOf(create), SSLConfigManager.mask(password) });
if (name != null && !create) {
WSKeyStore keystore = keyStoreMap.get(name);
if (keystore != null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "getKeyStore (from WSKeyStore)");
return keystore.getKeyStore(false, false);
}
}
KeyStore keyStore = null;
InputStream inputStream = null;
boolean not_finished = true;
int retry_count = 0;
boolean fileBased = true;
List<String> keyStoreTypes = new ArrayList<String>();
// Loop until flag indicates a key store was found or failure occured.
while (not_finished) {
// Get a base instance of the keystore based on the type and or the
// provider.
if (Constants.KEYSTORE_TYPE_JCERACFKS.equals(type) || Constants.KEYSTORE_TYPE_JCECCARACFKS.equals(type) || Constants.KEYSTORE_TYPE_JCEHYBRIDRACFKS.equals(type))
fileBased = false;
else
fileBased = true;
// Get a base instance of the keystore based on the type and or the
// provider.
char[] passphrase = null;
keyStore = KeyStore.getInstance(type);
// Convert the key store password into a char array.
if (password != null) {
passphrase = WSKeyStore.decodePassword(password).toCharArray();
}
// Open the file specified by the input parms as the keystore file.
try {
if (Constants.KEYSTORE_TYPE_JAVACRYPTO.equals(type)) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "Creating PKCS11 keystore.");
WSPKCSInKeyStore pKS = pkcsStoreList.insert(type, fileName, password, false, provider);
if (pKS != null) {
keyStore = pKS.getKS();
not_finished = false;
}
} else if (null == fileName) {
keyStore.load(null, passphrase);
not_finished = false;
} else {
File f = new File(fileName);
FileExistsAction action = new FileExistsAction(f);
Boolean fileExists = AccessController.doPrivileged(action);
if (!fileExists.booleanValue() && fileBased) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "getKeyStore created new KeyStore: " + fileName);
}
keyStore.load(null, passphrase);
not_finished = false;
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "getKeyStore created a new inputStream: " + fileName);
}
// Access the keystore input stream from a File or URL
inputStream = getInputStream(fileName, create);
keyStore.load(inputStream, passphrase);
not_finished = false;
}
}
} catch (IOException e) {
// Check for well known error conditions.
if (e.getMessage().equalsIgnoreCase("Invalid keystore format") || e.getMessage().indexOf("DerInputStream.getLength()") != -1) {
if (retry_count == 0) {
String alias = "unknown";
if (sslConfig != null) {
alias = sslConfig.getProperty(Constants.SSLPROP_ALIAS);
}
Tr.warning(tc, "ssl.keystore.type.invalid.CWPKI0018W", new Object[] { type, alias });
keyStoreTypes = new ArrayList<String>(Security.getAlgorithms("KeyStore"));
}
// Limit the number of retries.
if (retry_count >= keyStoreTypes.size()) {
throw e;
}
// Adjust the type for another try.
// We'll go through all available types.
type = keyStoreTypes.get(retry_count++);
if (type.equals("PKCS11") || type.equals("IBMCMSKS")) {
type = keyStoreTypes.get(retry_count++);
}
} else {
// Unknown error condition.
throw e;
}
} finally {
if (inputStream != null)
inputStream.close();
}
} // end while
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "getKeyStore (from SSLConfig properties)");
return keyStore;
} } | public class class_name {
public KeyStore getKeyStore(String name, String type, String provider, String fileName, String password, boolean create, SSLConfig sslConfig) throws Exception {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(tc, "getKeyStore", new Object[] { name, type, provider, fileName, Boolean.valueOf(create), SSLConfigManager.mask(password) });
if (name != null && !create) {
WSKeyStore keystore = keyStoreMap.get(name);
if (keystore != null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "getKeyStore (from WSKeyStore)");
return keystore.getKeyStore(false, false); // depends on control dependency: [if], data = [none]
}
}
KeyStore keyStore = null;
InputStream inputStream = null;
boolean not_finished = true;
int retry_count = 0;
boolean fileBased = true;
List<String> keyStoreTypes = new ArrayList<String>();
// Loop until flag indicates a key store was found or failure occured.
while (not_finished) {
// Get a base instance of the keystore based on the type and or the
// provider.
if (Constants.KEYSTORE_TYPE_JCERACFKS.equals(type) || Constants.KEYSTORE_TYPE_JCECCARACFKS.equals(type) || Constants.KEYSTORE_TYPE_JCEHYBRIDRACFKS.equals(type))
fileBased = false;
else
fileBased = true;
// Get a base instance of the keystore based on the type and or the
// provider.
char[] passphrase = null;
keyStore = KeyStore.getInstance(type); // depends on control dependency: [while], data = [none]
// Convert the key store password into a char array.
if (password != null) {
passphrase = WSKeyStore.decodePassword(password).toCharArray(); // depends on control dependency: [if], data = [(password]
}
// Open the file specified by the input parms as the keystore file.
try {
if (Constants.KEYSTORE_TYPE_JAVACRYPTO.equals(type)) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "Creating PKCS11 keystore.");
WSPKCSInKeyStore pKS = pkcsStoreList.insert(type, fileName, password, false, provider);
if (pKS != null) {
keyStore = pKS.getKS(); // depends on control dependency: [if], data = [none]
not_finished = false; // depends on control dependency: [if], data = [none]
}
} else if (null == fileName) {
keyStore.load(null, passphrase); // depends on control dependency: [if], data = [(null]
not_finished = false; // depends on control dependency: [if], data = [none]
} else {
File f = new File(fileName);
FileExistsAction action = new FileExistsAction(f);
Boolean fileExists = AccessController.doPrivileged(action);
if (!fileExists.booleanValue() && fileBased) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "getKeyStore created new KeyStore: " + fileName); // depends on control dependency: [if], data = [none]
}
keyStore.load(null, passphrase); // depends on control dependency: [if], data = [none]
not_finished = false; // depends on control dependency: [if], data = [none]
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "getKeyStore created a new inputStream: " + fileName); // depends on control dependency: [if], data = [none]
}
// Access the keystore input stream from a File or URL
inputStream = getInputStream(fileName, create); // depends on control dependency: [if], data = [none]
keyStore.load(inputStream, passphrase); // depends on control dependency: [if], data = [none]
not_finished = false; // depends on control dependency: [if], data = [none]
}
}
} catch (IOException e) {
// Check for well known error conditions.
if (e.getMessage().equalsIgnoreCase("Invalid keystore format") || e.getMessage().indexOf("DerInputStream.getLength()") != -1) {
if (retry_count == 0) {
String alias = "unknown";
if (sslConfig != null) {
alias = sslConfig.getProperty(Constants.SSLPROP_ALIAS); // depends on control dependency: [if], data = [none]
}
Tr.warning(tc, "ssl.keystore.type.invalid.CWPKI0018W", new Object[] { type, alias }); // depends on control dependency: [if], data = [none]
keyStoreTypes = new ArrayList<String>(Security.getAlgorithms("KeyStore")); // depends on control dependency: [if], data = [none]
}
// Limit the number of retries.
if (retry_count >= keyStoreTypes.size()) {
throw e;
}
// Adjust the type for another try.
// We'll go through all available types.
type = keyStoreTypes.get(retry_count++); // depends on control dependency: [if], data = [none]
if (type.equals("PKCS11") || type.equals("IBMCMSKS")) {
type = keyStoreTypes.get(retry_count++); // depends on control dependency: [if], data = [none]
}
} else {
// Unknown error condition.
throw e;
}
} finally { // depends on control dependency: [catch], data = [none]
if (inputStream != null)
inputStream.close();
}
} // end while
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "getKeyStore (from SSLConfig properties)");
return keyStore;
} } |
public class class_name {
protected byte[] getThriftColumnValue(Object e, Attribute attribute)
{
byte[] value = null;
Field field = (Field) ((Attribute) attribute).getJavaMember();
try
{
if (attribute != null && field.get(e) != null)
{
if (CassandraDataTranslator.isCassandraDataTypeClass(((AbstractAttribute) attribute)
.getBindableJavaType()))
{
value = CassandraDataTranslator.compose(((AbstractAttribute) attribute).getBindableJavaType(),
field.get(e), false);
}
else
{
value = PropertyAccessorHelper.get(e, field);
}
}
}
catch (IllegalArgumentException iae)
{
log.error("Error while persisting data, Caused by: .", iae);
throw new IllegalArgumentException(iae);
}
catch (IllegalAccessException iace)
{
log.error("Error while persisting data, Caused by: .", iace);
}
return value;
} } | public class class_name {
protected byte[] getThriftColumnValue(Object e, Attribute attribute)
{
byte[] value = null;
Field field = (Field) ((Attribute) attribute).getJavaMember();
try
{
if (attribute != null && field.get(e) != null)
{
if (CassandraDataTranslator.isCassandraDataTypeClass(((AbstractAttribute) attribute)
.getBindableJavaType()))
{
value = CassandraDataTranslator.compose(((AbstractAttribute) attribute).getBindableJavaType(),
field.get(e), false); // depends on control dependency: [if], data = [none]
}
else
{
value = PropertyAccessorHelper.get(e, field); // depends on control dependency: [if], data = [none]
}
}
}
catch (IllegalArgumentException iae)
{
log.error("Error while persisting data, Caused by: .", iae);
throw new IllegalArgumentException(iae);
} // depends on control dependency: [catch], data = [none]
catch (IllegalAccessException iace)
{
log.error("Error while persisting data, Caused by: .", iace);
} // depends on control dependency: [catch], data = [none]
return value;
} } |
public class class_name {
public final List<Form> searchAndConvertHitsToFormWithAllFields(
QueryBuilder qbParam,
String indexParam,
int offsetParam,
int limitParam,
Long ... formTypesParam
) {
SearchHits searchHits = this.searchWithHits(
qbParam,
indexParam,
false,
offsetParam,
limitParam,
formTypesParam);
List<Form> returnVal = null;
long totalHits;
if (searchHits != null && (totalHits = searchHits.getTotalHits()) > 0) {
returnVal = new ArrayList();
if((searchHits.getHits().length != totalHits) &&
(searchHits.getHits().length != limitParam)) {
throw new FluidElasticSearchException(
"The Hits and fetch count has mismatch. Total hits is '"+totalHits+"' while hits is '"+
searchHits.getHits().length+"'.");
}
long iterationMax = totalHits;
if(limitParam > 0 && totalHits > limitParam) {
iterationMax = limitParam;
}
//Iterate...
for(int index = 0;index < iterationMax;index++) {
SearchHit searchHit = searchHits.getAt(index);
String source;
if((source = searchHit.getSourceAsString()) == null) {
continue;
}
this.printInfoOnSourceFromES(searchHit);
Form formFromSource = new Form();
JSONObject jsonObject = new JSONObject(source);
List<Field> fieldsForForm = null;
//Is Form Type available...
if(jsonObject.has(Form.JSONMapping.FORM_TYPE_ID)) {
if(this.fieldUtil == null) {
throw new FluidElasticSearchException(
"Field Util is not set. Use a different constructor.");
}
fieldsForForm = formFromSource.convertTo(
this.fieldUtil.getFormFieldMappingForFormDefinition(
jsonObject.getLong(Form.JSONMapping.FORM_TYPE_ID)));
}
formFromSource.populateFromElasticSearchJson(
jsonObject, fieldsForForm);
returnVal.add(formFromSource);
}
}
return returnVal;
} } | public class class_name {
public final List<Form> searchAndConvertHitsToFormWithAllFields(
QueryBuilder qbParam,
String indexParam,
int offsetParam,
int limitParam,
Long ... formTypesParam
) {
SearchHits searchHits = this.searchWithHits(
qbParam,
indexParam,
false,
offsetParam,
limitParam,
formTypesParam);
List<Form> returnVal = null;
long totalHits;
if (searchHits != null && (totalHits = searchHits.getTotalHits()) > 0) {
returnVal = new ArrayList(); // depends on control dependency: [if], data = [none]
if((searchHits.getHits().length != totalHits) &&
(searchHits.getHits().length != limitParam)) {
throw new FluidElasticSearchException(
"The Hits and fetch count has mismatch. Total hits is '"+totalHits+"' while hits is '"+
searchHits.getHits().length+"'.");
}
long iterationMax = totalHits;
if(limitParam > 0 && totalHits > limitParam) {
iterationMax = limitParam; // depends on control dependency: [if], data = [none]
}
//Iterate...
for(int index = 0;index < iterationMax;index++) {
SearchHit searchHit = searchHits.getAt(index);
String source;
if((source = searchHit.getSourceAsString()) == null) {
continue;
}
this.printInfoOnSourceFromES(searchHit); // depends on control dependency: [for], data = [none]
Form formFromSource = new Form();
JSONObject jsonObject = new JSONObject(source);
List<Field> fieldsForForm = null;
//Is Form Type available...
if(jsonObject.has(Form.JSONMapping.FORM_TYPE_ID)) {
if(this.fieldUtil == null) {
throw new FluidElasticSearchException(
"Field Util is not set. Use a different constructor.");
}
fieldsForForm = formFromSource.convertTo(
this.fieldUtil.getFormFieldMappingForFormDefinition(
jsonObject.getLong(Form.JSONMapping.FORM_TYPE_ID))); // depends on control dependency: [if], data = [none]
}
formFromSource.populateFromElasticSearchJson(
jsonObject, fieldsForForm); // depends on control dependency: [for], data = [none]
returnVal.add(formFromSource); // depends on control dependency: [for], data = [none]
}
}
return returnVal;
} } |
public class class_name {
public NullnessHint analyzeReturnType() {
if (method.getReturnType().isPrimitiveType()) {
LOG(DEBUG, "DEBUG", "Skipping method with primitive return type: " + method.getSignature());
return NullnessHint.UNKNOWN;
}
LOG(DEBUG, "DEBUG", "@ Return type analysis for: " + method.getSignature());
// Get ExceptionPrunedCFG
if (prunedCFG == null) {
prunedCFG = ExceptionPrunedCFG.make(cfg);
}
// In case the only control flows are exceptional, simply return.
if (prunedCFG.getNumberOfNodes() == 2
&& prunedCFG.containsNode(cfg.entry())
&& prunedCFG.containsNode(cfg.exit())
&& GraphUtil.countEdges(prunedCFG) == 0) {
return NullnessHint.UNKNOWN;
}
for (ISSABasicBlock bb : prunedCFG.getNormalPredecessors(prunedCFG.exit())) {
for (int i = bb.getFirstInstructionIndex(); i <= bb.getLastInstructionIndex(); i++) {
SSAInstruction instr = ir.getInstructions()[i];
if (instr instanceof SSAReturnInstruction) {
SSAReturnInstruction retInstr = (SSAReturnInstruction) instr;
if (ir.getSymbolTable().isNullConstant(retInstr.getResult())) {
LOG(DEBUG, "DEBUG", "Nullable return in method: " + method.getSignature());
return NullnessHint.NULLABLE;
}
}
}
}
return NullnessHint.UNKNOWN;
} } | public class class_name {
public NullnessHint analyzeReturnType() {
if (method.getReturnType().isPrimitiveType()) {
LOG(DEBUG, "DEBUG", "Skipping method with primitive return type: " + method.getSignature()); // depends on control dependency: [if], data = [none]
return NullnessHint.UNKNOWN; // depends on control dependency: [if], data = [none]
}
LOG(DEBUG, "DEBUG", "@ Return type analysis for: " + method.getSignature());
// Get ExceptionPrunedCFG
if (prunedCFG == null) {
prunedCFG = ExceptionPrunedCFG.make(cfg); // depends on control dependency: [if], data = [none]
}
// In case the only control flows are exceptional, simply return.
if (prunedCFG.getNumberOfNodes() == 2
&& prunedCFG.containsNode(cfg.entry())
&& prunedCFG.containsNode(cfg.exit())
&& GraphUtil.countEdges(prunedCFG) == 0) {
return NullnessHint.UNKNOWN; // depends on control dependency: [if], data = [none]
}
for (ISSABasicBlock bb : prunedCFG.getNormalPredecessors(prunedCFG.exit())) {
for (int i = bb.getFirstInstructionIndex(); i <= bb.getLastInstructionIndex(); i++) {
SSAInstruction instr = ir.getInstructions()[i];
if (instr instanceof SSAReturnInstruction) {
SSAReturnInstruction retInstr = (SSAReturnInstruction) instr;
if (ir.getSymbolTable().isNullConstant(retInstr.getResult())) {
LOG(DEBUG, "DEBUG", "Nullable return in method: " + method.getSignature()); // depends on control dependency: [if], data = [none]
return NullnessHint.NULLABLE; // depends on control dependency: [if], data = [none]
}
}
}
}
return NullnessHint.UNKNOWN;
} } |
public class class_name {
public EClass getIfcStructuralAction() {
if (ifcStructuralActionEClass == null) {
ifcStructuralActionEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc2x3tc1Package.eNS_URI)
.getEClassifiers().get(534);
}
return ifcStructuralActionEClass;
} } | public class class_name {
public EClass getIfcStructuralAction() {
if (ifcStructuralActionEClass == null) {
ifcStructuralActionEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc2x3tc1Package.eNS_URI)
.getEClassifiers().get(534);
// depends on control dependency: [if], data = [none]
}
return ifcStructuralActionEClass;
} } |
public class class_name {
public void setEventSelectors(java.util.Collection<EventSelector> eventSelectors) {
if (eventSelectors == null) {
this.eventSelectors = null;
return;
}
this.eventSelectors = new com.amazonaws.internal.SdkInternalList<EventSelector>(eventSelectors);
} } | public class class_name {
public void setEventSelectors(java.util.Collection<EventSelector> eventSelectors) {
if (eventSelectors == null) {
this.eventSelectors = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.eventSelectors = new com.amazonaws.internal.SdkInternalList<EventSelector>(eventSelectors);
} } |
public class class_name {
public final void normalize(Quaternion q1) {
double norm;
norm = (q1.x*q1.x + q1.y*q1.y + q1.z*q1.z + q1.w*q1.w);
if (norm > 0f) {
norm = 1f/Math.sqrt(norm);
this.x = norm*q1.x;
this.y = norm*q1.y;
this.z = norm*q1.z;
this.w = norm*q1.w;
} else {
this.x = 0f;
this.y = 0f;
this.z = 0f;
this.w = 0f;
}
} } | public class class_name {
public final void normalize(Quaternion q1) {
double norm;
norm = (q1.x*q1.x + q1.y*q1.y + q1.z*q1.z + q1.w*q1.w);
if (norm > 0f) {
norm = 1f/Math.sqrt(norm); // depends on control dependency: [if], data = [(norm]
this.x = norm*q1.x; // depends on control dependency: [if], data = [none]
this.y = norm*q1.y; // depends on control dependency: [if], data = [none]
this.z = norm*q1.z; // depends on control dependency: [if], data = [none]
this.w = norm*q1.w; // depends on control dependency: [if], data = [none]
} else {
this.x = 0f; // depends on control dependency: [if], data = [none]
this.y = 0f; // depends on control dependency: [if], data = [none]
this.z = 0f; // depends on control dependency: [if], data = [none]
this.w = 0f; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
@Override
public GeolocationApi.Response read(JsonReader reader) throws IOException {
if (reader.peek() == JsonToken.NULL) {
reader.nextNull();
return null;
}
GeolocationApi.Response response = new GeolocationApi.Response();
LatLngAdapter latLngAdapter = new LatLngAdapter();
reader.beginObject(); // opening {
while (reader.hasNext()) {
String name = reader.nextName();
// two different objects could be returned a success object containing "location" and
// "accuracy" keys or an error object containing an "error" key
if (name.equals("location")) {
// we already have a parser for the LatLng object so lets use that
response.location = latLngAdapter.read(reader);
} else if (name.equals("accuracy")) {
response.accuracy = reader.nextDouble();
} else if (name.equals("error")) {
reader.beginObject(); // the error key leads to another object...
while (reader.hasNext()) {
String errName = reader.nextName();
// ...with keys "errors", "code" and "message"
if (errName.equals("code")) {
response.code = reader.nextInt();
} else if (errName.equals("message")) {
response.message = reader.nextString();
} else if (errName.equals("errors")) {
reader.beginArray(); // its plural because its an array of errors...
while (reader.hasNext()) {
reader.beginObject(); // ...and each error array element is an object...
while (reader.hasNext()) {
errName = reader.nextName();
// ...with keys "reason", "domain", "debugInfo", "location", "locationType", and
// "message" (again)
if (errName.equals("reason")) {
response.reason = reader.nextString();
} else if (errName.equals("domain")) {
response.domain = reader.nextString();
} else if (errName.equals("debugInfo")) {
response.debugInfo = reader.nextString();
} else if (errName.equals("message")) {
// have this already
reader.nextString();
} else if (errName.equals("location")) {
reader.nextString();
} else if (errName.equals("locationType")) {
reader.nextString();
}
}
reader.endObject();
}
reader.endArray();
}
}
reader.endObject(); // closing }
}
}
reader.endObject();
return response;
} } | public class class_name {
@Override
public GeolocationApi.Response read(JsonReader reader) throws IOException {
if (reader.peek() == JsonToken.NULL) {
reader.nextNull();
return null;
}
GeolocationApi.Response response = new GeolocationApi.Response();
LatLngAdapter latLngAdapter = new LatLngAdapter();
reader.beginObject(); // opening {
while (reader.hasNext()) {
String name = reader.nextName();
// two different objects could be returned a success object containing "location" and
// "accuracy" keys or an error object containing an "error" key
if (name.equals("location")) {
// we already have a parser for the LatLng object so lets use that
response.location = latLngAdapter.read(reader);
} else if (name.equals("accuracy")) {
response.accuracy = reader.nextDouble();
} else if (name.equals("error")) {
reader.beginObject(); // the error key leads to another object...
while (reader.hasNext()) {
String errName = reader.nextName();
// ...with keys "errors", "code" and "message"
if (errName.equals("code")) {
response.code = reader.nextInt(); // depends on control dependency: [if], data = [none]
} else if (errName.equals("message")) {
response.message = reader.nextString(); // depends on control dependency: [if], data = [none]
} else if (errName.equals("errors")) {
reader.beginArray(); // its plural because its an array of errors... // depends on control dependency: [if], data = [none]
while (reader.hasNext()) {
reader.beginObject(); // ...and each error array element is an object... // depends on control dependency: [while], data = [none]
while (reader.hasNext()) {
errName = reader.nextName(); // depends on control dependency: [while], data = [none]
// ...with keys "reason", "domain", "debugInfo", "location", "locationType", and
// "message" (again)
if (errName.equals("reason")) {
response.reason = reader.nextString(); // depends on control dependency: [if], data = [none]
} else if (errName.equals("domain")) {
response.domain = reader.nextString(); // depends on control dependency: [if], data = [none]
} else if (errName.equals("debugInfo")) {
response.debugInfo = reader.nextString(); // depends on control dependency: [if], data = [none]
} else if (errName.equals("message")) {
// have this already
reader.nextString(); // depends on control dependency: [if], data = [none]
} else if (errName.equals("location")) {
reader.nextString(); // depends on control dependency: [if], data = [none]
} else if (errName.equals("locationType")) {
reader.nextString(); // depends on control dependency: [if], data = [none]
}
}
reader.endObject(); // depends on control dependency: [while], data = [none]
}
reader.endArray(); // depends on control dependency: [if], data = [none]
}
}
reader.endObject(); // closing }
}
}
reader.endObject();
return response;
} } |
public class class_name {
public void registerDefaults() {
typeToRenderer.clear();
ServiceLoader<TableCellRenderer> serviceLoader = ServiceLoader.load(TableCellRenderer.class);
Iterator<TableCellRenderer> iterator = serviceLoader.iterator();
while (iterator.hasNext()) {
TableCellRenderer next = iterator.next();
try {
RendererRegistry annotation = next.getClass().getAnnotation(RendererRegistry.class);
if (annotation != null) {
for (Class<?> clazz : annotation.type()) {
registerRenderer(clazz, next);
}
}
Method m = next.getClass().getMethod("setShowOddAndEvenRows", boolean.class);
if (m != null) {
m.invoke(next, false);
}
} catch (NoSuchMethodException ex) {
} catch (SecurityException ex) {
} catch (IllegalAccessException ex) {
} catch (IllegalArgumentException ex) {
} catch (InvocationTargetException ex) {
}
}
} } | public class class_name {
public void registerDefaults() {
typeToRenderer.clear();
ServiceLoader<TableCellRenderer> serviceLoader = ServiceLoader.load(TableCellRenderer.class);
Iterator<TableCellRenderer> iterator = serviceLoader.iterator();
while (iterator.hasNext()) {
TableCellRenderer next = iterator.next();
try {
RendererRegistry annotation = next.getClass().getAnnotation(RendererRegistry.class);
if (annotation != null) {
for (Class<?> clazz : annotation.type()) {
registerRenderer(clazz, next); // depends on control dependency: [for], data = [clazz]
}
}
Method m = next.getClass().getMethod("setShowOddAndEvenRows", boolean.class);
if (m != null) {
m.invoke(next, false); // depends on control dependency: [if], data = [none]
}
} catch (NoSuchMethodException ex) {
} catch (SecurityException ex) { // depends on control dependency: [catch], data = [none]
} catch (IllegalAccessException ex) { // depends on control dependency: [catch], data = [none]
} catch (IllegalArgumentException ex) { // depends on control dependency: [catch], data = [none]
} catch (InvocationTargetException ex) { // depends on control dependency: [catch], data = [none]
} // depends on control dependency: [catch], data = [none]
}
} } |
public class class_name {
@Override
public void sawOpcode(int seen) {
Integer userValue = null;
if ((conditionalTarget != -1) && (getPC() >= conditionalTarget)) {
conditionalTarget = -1;
sawMethodWeight = 0;
}
try {
switch (seen) {
case Const.INVOKESPECIAL:
case Const.INVOKESTATIC:
case Const.INVOKEINTERFACE:
case Const.INVOKEVIRTUAL:
String signature = getSigConstantOperand();
if (Values.SIG_VOID.equals(SignatureUtils.getReturnSignature(signature))) {
sawMethodWeight = 0;
return;
}
String clsName = getClassConstantOperand();
MethodInfo mi = Statistics.getStatistics().getMethodStatistics(clsName, getNameConstantOperand(), signature);
if ((mi == null) || (mi.getNumBytes() == 0)) {
userValue = Values.ONE;
} else {
userValue = Integer.valueOf(mi.getNumBytes());
}
break;
case Const.LCMP:
case Const.FCMPL:
case Const.FCMPG:
case Const.DCMPL:
case Const.DCMPG:
case Const.IAND:
case Const.IOR:
case Const.IXOR:
if (stack.getStackDepth() >= 2) {
for (int i = 0; i <= 1; i++) {
OpcodeStack.Item itm = stack.getStackItem(i);
userValue = (Integer) itm.getUserValue();
if (userValue != null) {
break;
}
}
} else {
sawMethodWeight = 0;
}
break;
case Const.IF_ICMPEQ:
case Const.IF_ICMPNE:
case Const.IF_ICMPLT:
case Const.IF_ICMPGE:
case Const.IF_ICMPGT:
case Const.IF_ICMPLE:
case Const.IF_ACMPEQ:
case Const.IF_ACMPNE:
if (conditionalTarget < 0) {
conditionalTarget = getBranchTarget();
} else if (conditionalTarget != getBranchTarget()) {
conditionalTarget = -1;
sawMethodWeight = 0;
return;
}
if (stack.getStackDepth() >= 2) {
int expWeight = 0;
for (int i = 0; i <= 1; i++) {
OpcodeStack.Item itm = stack.getStackItem(i);
Integer uv = (Integer) itm.getUserValue();
if (uv != null) {
expWeight = Math.max(uv.intValue(), expWeight);
}
}
if ((expWeight == 0) && (sawMethodWeight > 0)) {
bugReporter.reportBug(new BugInstance(this, BugType.SEO_SUBOPTIMAL_EXPRESSION_ORDER.name(),
sawMethodWeight >= NORMAL_WEIGHT_LIMIT ? NORMAL_PRIORITY : LOW_PRIORITY).addClass(this).addMethod(this)
.addSourceLine(this));
sawMethodWeight = 0;
conditionalTarget = Integer.MAX_VALUE;
} else {
sawMethodWeight = Math.max(sawMethodWeight, expWeight);
}
}
break;
case Const.IFEQ:
case Const.IFNE:
case Const.IFLT:
case Const.IFGE:
case Const.IFGT:
case Const.IFLE:
case Const.IFNULL:
case Const.IFNONNULL:
if (conditionalTarget < 0) {
conditionalTarget = getBranchTarget();
} else if (conditionalTarget != getBranchTarget()) {
conditionalTarget = -1;
sawMethodWeight = 0;
return;
}
if (stack.getStackDepth() >= 1) {
OpcodeStack.Item itm = stack.getStackItem(0);
Integer uv = (Integer) itm.getUserValue();
if (uv == null) {
if (sawMethodWeight > 0) {
bugReporter.reportBug(new BugInstance(this, BugType.SEO_SUBOPTIMAL_EXPRESSION_ORDER.name(),
sawMethodWeight >= NORMAL_WEIGHT_LIMIT ? NORMAL_PRIORITY : LOW_PRIORITY).addClass(this).addMethod(this)
.addSourceLine(this));
sawMethodWeight = 0;
conditionalTarget = Integer.MAX_VALUE;
}
} else {
sawMethodWeight = Math.max(sawMethodWeight, uv.intValue());
}
}
break;
case Const.ISTORE:
case Const.LSTORE:
case Const.FSTORE:
case Const.DSTORE:
case Const.ASTORE:
case Const.ISTORE_0:
case Const.ISTORE_1:
case Const.ISTORE_2:
case Const.ISTORE_3:
case Const.LSTORE_0:
case Const.LSTORE_1:
case Const.LSTORE_2:
case Const.LSTORE_3:
case Const.FSTORE_0:
case Const.FSTORE_1:
case Const.FSTORE_2:
case Const.FSTORE_3:
case Const.DSTORE_0:
case Const.DSTORE_1:
case Const.DSTORE_2:
case Const.DSTORE_3:
case Const.ASTORE_0:
case Const.ASTORE_1:
case Const.ASTORE_2:
case Const.ASTORE_3:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
itm.setUserValue(null);
}
sawMethodWeight = 0;
conditionalTarget = -1;
break;
case Const.ATHROW:
case Const.POP:
case Const.POP2:
case Const.GOTO:
case Const.GOTO_W:
case Const.PUTFIELD:
case Const.PUTSTATIC:
case Const.IINC:
case Const.INSTANCEOF:
case Const.RETURN:
case Const.ARETURN:
case Const.IRETURN:
case Const.LRETURN:
case Const.FRETURN:
case Const.DRETURN:
sawMethodWeight = 0;
conditionalTarget = -1;
break;
case Const.ARRAYLENGTH:
case Const.CHECKCAST:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
userValue = (Integer) itm.getUserValue();
}
break;
case Const.GETFIELD:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
if (itm.getReturnValueOf() != null) {
sawMethodWeight = 0;
conditionalTarget = -1;
}
}
break;
}
} finally {
stack.sawOpcode(this, seen);
if ((userValue != null) && (stack.getStackDepth() > 0)) {
OpcodeStack.Item itm = stack.getStackItem(0);
itm.setUserValue(userValue);
}
}
} } | public class class_name {
@Override
public void sawOpcode(int seen) {
Integer userValue = null;
if ((conditionalTarget != -1) && (getPC() >= conditionalTarget)) {
conditionalTarget = -1; // depends on control dependency: [if], data = [none]
sawMethodWeight = 0; // depends on control dependency: [if], data = [none]
}
try {
switch (seen) {
case Const.INVOKESPECIAL:
case Const.INVOKESTATIC:
case Const.INVOKEINTERFACE:
case Const.INVOKEVIRTUAL:
String signature = getSigConstantOperand();
if (Values.SIG_VOID.equals(SignatureUtils.getReturnSignature(signature))) {
sawMethodWeight = 0; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
String clsName = getClassConstantOperand();
MethodInfo mi = Statistics.getStatistics().getMethodStatistics(clsName, getNameConstantOperand(), signature);
if ((mi == null) || (mi.getNumBytes() == 0)) {
userValue = Values.ONE; // depends on control dependency: [if], data = [none]
} else {
userValue = Integer.valueOf(mi.getNumBytes()); // depends on control dependency: [if], data = [none]
}
break;
case Const.LCMP:
case Const.FCMPL:
case Const.FCMPG:
case Const.DCMPL:
case Const.DCMPG:
case Const.IAND:
case Const.IOR:
case Const.IXOR:
if (stack.getStackDepth() >= 2) {
for (int i = 0; i <= 1; i++) {
OpcodeStack.Item itm = stack.getStackItem(i);
userValue = (Integer) itm.getUserValue(); // depends on control dependency: [for], data = [none]
if (userValue != null) {
break;
}
}
} else {
sawMethodWeight = 0; // depends on control dependency: [if], data = [none]
}
break;
case Const.IF_ICMPEQ:
case Const.IF_ICMPNE:
case Const.IF_ICMPLT:
case Const.IF_ICMPGE:
case Const.IF_ICMPGT:
case Const.IF_ICMPLE:
case Const.IF_ACMPEQ:
case Const.IF_ACMPNE:
if (conditionalTarget < 0) {
conditionalTarget = getBranchTarget(); // depends on control dependency: [if], data = [none]
} else if (conditionalTarget != getBranchTarget()) {
conditionalTarget = -1; // depends on control dependency: [if], data = [none]
sawMethodWeight = 0; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
if (stack.getStackDepth() >= 2) {
int expWeight = 0;
for (int i = 0; i <= 1; i++) {
OpcodeStack.Item itm = stack.getStackItem(i);
Integer uv = (Integer) itm.getUserValue();
if (uv != null) {
expWeight = Math.max(uv.intValue(), expWeight); // depends on control dependency: [if], data = [(uv]
}
}
if ((expWeight == 0) && (sawMethodWeight > 0)) {
bugReporter.reportBug(new BugInstance(this, BugType.SEO_SUBOPTIMAL_EXPRESSION_ORDER.name(),
sawMethodWeight >= NORMAL_WEIGHT_LIMIT ? NORMAL_PRIORITY : LOW_PRIORITY).addClass(this).addMethod(this)
.addSourceLine(this)); // depends on control dependency: [if], data = [none]
sawMethodWeight = 0; // depends on control dependency: [if], data = [none]
conditionalTarget = Integer.MAX_VALUE; // depends on control dependency: [if], data = [none]
} else {
sawMethodWeight = Math.max(sawMethodWeight, expWeight); // depends on control dependency: [if], data = [none]
}
}
break;
case Const.IFEQ:
case Const.IFNE:
case Const.IFLT:
case Const.IFGE:
case Const.IFGT:
case Const.IFLE:
case Const.IFNULL:
case Const.IFNONNULL:
if (conditionalTarget < 0) {
conditionalTarget = getBranchTarget(); // depends on control dependency: [if], data = [none]
} else if (conditionalTarget != getBranchTarget()) {
conditionalTarget = -1; // depends on control dependency: [if], data = [none]
sawMethodWeight = 0; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
if (stack.getStackDepth() >= 1) {
OpcodeStack.Item itm = stack.getStackItem(0);
Integer uv = (Integer) itm.getUserValue();
if (uv == null) {
if (sawMethodWeight > 0) {
bugReporter.reportBug(new BugInstance(this, BugType.SEO_SUBOPTIMAL_EXPRESSION_ORDER.name(),
sawMethodWeight >= NORMAL_WEIGHT_LIMIT ? NORMAL_PRIORITY : LOW_PRIORITY).addClass(this).addMethod(this)
.addSourceLine(this)); // depends on control dependency: [if], data = [none]
sawMethodWeight = 0; // depends on control dependency: [if], data = [none]
conditionalTarget = Integer.MAX_VALUE; // depends on control dependency: [if], data = [none]
}
} else {
sawMethodWeight = Math.max(sawMethodWeight, uv.intValue()); // depends on control dependency: [if], data = [none]
}
}
break;
case Const.ISTORE:
case Const.LSTORE:
case Const.FSTORE:
case Const.DSTORE:
case Const.ASTORE:
case Const.ISTORE_0:
case Const.ISTORE_1:
case Const.ISTORE_2:
case Const.ISTORE_3:
case Const.LSTORE_0:
case Const.LSTORE_1:
case Const.LSTORE_2:
case Const.LSTORE_3:
case Const.FSTORE_0:
case Const.FSTORE_1:
case Const.FSTORE_2:
case Const.FSTORE_3:
case Const.DSTORE_0:
case Const.DSTORE_1:
case Const.DSTORE_2:
case Const.DSTORE_3:
case Const.ASTORE_0:
case Const.ASTORE_1:
case Const.ASTORE_2:
case Const.ASTORE_3:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
itm.setUserValue(null); // depends on control dependency: [if], data = [none]
}
sawMethodWeight = 0;
conditionalTarget = -1;
break;
case Const.ATHROW:
case Const.POP:
case Const.POP2:
case Const.GOTO:
case Const.GOTO_W:
case Const.PUTFIELD:
case Const.PUTSTATIC:
case Const.IINC:
case Const.INSTANCEOF:
case Const.RETURN:
case Const.ARETURN:
case Const.IRETURN:
case Const.LRETURN:
case Const.FRETURN:
case Const.DRETURN:
sawMethodWeight = 0;
conditionalTarget = -1;
break;
case Const.ARRAYLENGTH:
case Const.CHECKCAST:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
userValue = (Integer) itm.getUserValue(); // depends on control dependency: [if], data = [none]
}
break;
case Const.GETFIELD:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
if (itm.getReturnValueOf() != null) {
sawMethodWeight = 0; // depends on control dependency: [if], data = [none]
conditionalTarget = -1; // depends on control dependency: [if], data = [none]
}
}
break;
}
} finally {
stack.sawOpcode(this, seen);
if ((userValue != null) && (stack.getStackDepth() > 0)) {
OpcodeStack.Item itm = stack.getStackItem(0);
itm.setUserValue(userValue); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public ColorRecord[] enumerateColors (String className)
{
// make sure the class exists
ClassRecord record = getClassRecord(className);
if (record == null) {
return null;
}
// create the array
ColorRecord[] crecs = new ColorRecord[record.colors.size()];
Iterator<ColorRecord> iter = record.colors.values().iterator();
for (int ii = 0; iter.hasNext(); ii++) {
crecs[ii] = iter.next();
}
return crecs;
} } | public class class_name {
public ColorRecord[] enumerateColors (String className)
{
// make sure the class exists
ClassRecord record = getClassRecord(className);
if (record == null) {
return null; // depends on control dependency: [if], data = [none]
}
// create the array
ColorRecord[] crecs = new ColorRecord[record.colors.size()];
Iterator<ColorRecord> iter = record.colors.values().iterator();
for (int ii = 0; iter.hasNext(); ii++) {
crecs[ii] = iter.next(); // depends on control dependency: [for], data = [ii]
}
return crecs;
} } |
public class class_name {
@Override
public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
final String sourceMethod = "getMBeanInfo";
checkConnection();
URL mbeanURL = null;
HttpsURLConnection connection = null;
try {
// Get URL for MBean
mbeanURL = getMBeanURL(name);
// Get connection to server
connection = getConnection(mbeanURL, HttpMethod.GET);
} catch (IOException io) {
throw getRequestErrorException(sourceMethod, io, mbeanURL);
}
// Check response code from server
int responseCode = 0;
try {
responseCode = connection.getResponseCode();
} catch (ConnectException ce) {
recoverConnection(ce);
// Server is down; not a client bug
throw ce;
}
switch (responseCode) {
case HttpURLConnection.HTTP_OK:
JSONConverter converter = JSONConverter.getConverter();
try {
// Process and return server response, which should be an MBeanInfoWrapper
MBeanInfoWrapper wrapper = converter.readMBeanInfo(connection.getInputStream());
mbeanAttributesURLMap.put(name, new DynamicURL(connector, wrapper.attributesURL));
//Attributes
Map<String, DynamicURL> attributeURLsMap = mbeanAttributeURLsMap.get(name);
final boolean updateAttributes = attributeURLsMap != null;
if (!updateAttributes) {
// Create a new Map - this map is used for future requests and must be thread safe
attributeURLsMap = new ConcurrentHashMap<String, DynamicURL>();
}
processAttributeOrOperationURLs(attributeURLsMap, wrapper.attributeURLs, updateAttributes);
if (!updateAttributes) {
//Another thread might have created/set this Map already and is about to use it, which is why
//we wait until *after* we have a valid Map and are ready to push that in.
mbeanAttributeURLsMap.putIfAbsent(name, attributeURLsMap);
}
//Operations
Map<String, DynamicURL> operationURLsMap = mbeanOperationURLsMap.get(name);
final boolean updateOperations = operationURLsMap != null;
if (!updateOperations) {
// Create a new Map - this map is used for future requests and must be thread safe
operationURLsMap = new ConcurrentHashMap<String, DynamicURL>();
}
processAttributeOrOperationURLs(operationURLsMap, wrapper.operationURLs, updateOperations);
if (!updateOperations) {
//Another thread might have created/set this Map already and is about to use it, which is why
//we wait until *after* we have a valid Map and are ready to push that in.
mbeanOperationURLsMap.putIfAbsent(name, operationURLsMap);
}
return wrapper.mbeanInfo;
} catch (ClassNotFoundException cnf) {
// Not a REST connector bug per se; not need to log this case
throw new IOException(RESTClientMessagesUtil.getMessage(RESTClientMessagesUtil.SERVER_RESULT_EXCEPTION), cnf);
} catch (Exception e) {
throw getResponseErrorException(sourceMethod, e, mbeanURL);
} finally {
JSONConverter.returnConverter(converter);
}
case HttpURLConnection.HTTP_BAD_REQUEST:
case HttpURLConnection.HTTP_INTERNAL_ERROR:
try {
// Server response should be a serialized Throwable
throw getServerThrowable(sourceMethod, connection);
} catch (IntrospectionException ie) {
throw ie;
} catch (InstanceNotFoundException inf) {
throw inf;
} catch (ReflectionException re) {
throw re;
} catch (IOException io) {
throw io;
} catch (Throwable t) {
throw new IOException(RESTClientMessagesUtil.getMessage(RESTClientMessagesUtil.UNEXPECTED_SERVER_THROWABLE), t);
}
case HttpURLConnection.HTTP_UNAUTHORIZED:
case HttpURLConnection.HTTP_FORBIDDEN:
throw getBadCredentialsException(responseCode, connection);
case HttpURLConnection.HTTP_GONE:
case HttpURLConnection.HTTP_NOT_FOUND:
IOException ioe = getResponseCodeErrorException(sourceMethod, responseCode, connection);
recoverConnection(ioe);
throw ioe;
default:
throw getResponseCodeErrorException(sourceMethod, responseCode, connection);
}
} } | public class class_name {
@Override
public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
final String sourceMethod = "getMBeanInfo";
checkConnection();
URL mbeanURL = null;
HttpsURLConnection connection = null;
try {
// Get URL for MBean
mbeanURL = getMBeanURL(name);
// Get connection to server
connection = getConnection(mbeanURL, HttpMethod.GET);
} catch (IOException io) {
throw getRequestErrorException(sourceMethod, io, mbeanURL);
}
// Check response code from server
int responseCode = 0;
try {
responseCode = connection.getResponseCode();
} catch (ConnectException ce) {
recoverConnection(ce);
// Server is down; not a client bug
throw ce;
}
switch (responseCode) {
case HttpURLConnection.HTTP_OK:
JSONConverter converter = JSONConverter.getConverter();
try {
// Process and return server response, which should be an MBeanInfoWrapper
MBeanInfoWrapper wrapper = converter.readMBeanInfo(connection.getInputStream());
mbeanAttributesURLMap.put(name, new DynamicURL(connector, wrapper.attributesURL)); // depends on control dependency: [try], data = [none]
//Attributes
Map<String, DynamicURL> attributeURLsMap = mbeanAttributeURLsMap.get(name);
final boolean updateAttributes = attributeURLsMap != null;
if (!updateAttributes) {
// Create a new Map - this map is used for future requests and must be thread safe
attributeURLsMap = new ConcurrentHashMap<String, DynamicURL>(); // depends on control dependency: [if], data = [none]
}
processAttributeOrOperationURLs(attributeURLsMap, wrapper.attributeURLs, updateAttributes); // depends on control dependency: [try], data = [none]
if (!updateAttributes) {
//Another thread might have created/set this Map already and is about to use it, which is why
//we wait until *after* we have a valid Map and are ready to push that in.
mbeanAttributeURLsMap.putIfAbsent(name, attributeURLsMap); // depends on control dependency: [if], data = [none]
}
//Operations
Map<String, DynamicURL> operationURLsMap = mbeanOperationURLsMap.get(name);
final boolean updateOperations = operationURLsMap != null;
if (!updateOperations) {
// Create a new Map - this map is used for future requests and must be thread safe
operationURLsMap = new ConcurrentHashMap<String, DynamicURL>(); // depends on control dependency: [if], data = [none]
}
processAttributeOrOperationURLs(operationURLsMap, wrapper.operationURLs, updateOperations); // depends on control dependency: [try], data = [none]
if (!updateOperations) {
//Another thread might have created/set this Map already and is about to use it, which is why
//we wait until *after* we have a valid Map and are ready to push that in.
mbeanOperationURLsMap.putIfAbsent(name, operationURLsMap); // depends on control dependency: [if], data = [none]
}
return wrapper.mbeanInfo; // depends on control dependency: [try], data = [none]
} catch (ClassNotFoundException cnf) {
// Not a REST connector bug per se; not need to log this case
throw new IOException(RESTClientMessagesUtil.getMessage(RESTClientMessagesUtil.SERVER_RESULT_EXCEPTION), cnf);
} catch (Exception e) { // depends on control dependency: [catch], data = [none]
throw getResponseErrorException(sourceMethod, e, mbeanURL);
} finally { // depends on control dependency: [catch], data = [none]
JSONConverter.returnConverter(converter);
}
case HttpURLConnection.HTTP_BAD_REQUEST:
case HttpURLConnection.HTTP_INTERNAL_ERROR:
try {
// Server response should be a serialized Throwable
throw getServerThrowable(sourceMethod, connection);
} catch (IntrospectionException ie) {
throw ie;
} catch (InstanceNotFoundException inf) { // depends on control dependency: [catch], data = [none]
throw inf;
} catch (ReflectionException re) { // depends on control dependency: [catch], data = [none]
throw re;
} catch (IOException io) { // depends on control dependency: [catch], data = [none]
throw io;
} catch (Throwable t) { // depends on control dependency: [catch], data = [none]
throw new IOException(RESTClientMessagesUtil.getMessage(RESTClientMessagesUtil.UNEXPECTED_SERVER_THROWABLE), t);
} // depends on control dependency: [catch], data = [none]
case HttpURLConnection.HTTP_UNAUTHORIZED:
case HttpURLConnection.HTTP_FORBIDDEN:
throw getBadCredentialsException(responseCode, connection);
case HttpURLConnection.HTTP_GONE:
case HttpURLConnection.HTTP_NOT_FOUND:
IOException ioe = getResponseCodeErrorException(sourceMethod, responseCode, connection);
recoverConnection(ioe);
throw ioe;
default:
throw getResponseCodeErrorException(sourceMethod, responseCode, connection);
}
} } |
public class class_name {
private static void removeRangesFromShiftMap(
final NavigableMap<String, ConfigRangeAttrs> shiftMap,
final List<String> removeFullNameList) {
for (String fname : removeFullNameList) {
shiftMap.remove(fname);
}
} } | public class class_name {
private static void removeRangesFromShiftMap(
final NavigableMap<String, ConfigRangeAttrs> shiftMap,
final List<String> removeFullNameList) {
for (String fname : removeFullNameList) {
shiftMap.remove(fname);
// depends on control dependency: [for], data = [fname]
}
} } |
public class class_name {
public void marshall(UpdateGameSessionRequest updateGameSessionRequest, ProtocolMarshaller protocolMarshaller) {
if (updateGameSessionRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(updateGameSessionRequest.getGameSessionId(), GAMESESSIONID_BINDING);
protocolMarshaller.marshall(updateGameSessionRequest.getMaximumPlayerSessionCount(), MAXIMUMPLAYERSESSIONCOUNT_BINDING);
protocolMarshaller.marshall(updateGameSessionRequest.getName(), NAME_BINDING);
protocolMarshaller.marshall(updateGameSessionRequest.getPlayerSessionCreationPolicy(), PLAYERSESSIONCREATIONPOLICY_BINDING);
protocolMarshaller.marshall(updateGameSessionRequest.getProtectionPolicy(), PROTECTIONPOLICY_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(UpdateGameSessionRequest updateGameSessionRequest, ProtocolMarshaller protocolMarshaller) {
if (updateGameSessionRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(updateGameSessionRequest.getGameSessionId(), GAMESESSIONID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(updateGameSessionRequest.getMaximumPlayerSessionCount(), MAXIMUMPLAYERSESSIONCOUNT_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(updateGameSessionRequest.getName(), NAME_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(updateGameSessionRequest.getPlayerSessionCreationPolicy(), PLAYERSESSIONCREATIONPOLICY_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(updateGameSessionRequest.getProtectionPolicy(), PROTECTIONPOLICY_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void deleteSubnet(DeleteSubnetRequest deleteSubnetRequest) {
checkNotNull(deleteSubnetRequest, "request should not be null.");
checkNotNull(deleteSubnetRequest.getSubnetId(), "request subnetId should not be null.");
if (Strings.isNullOrEmpty(deleteSubnetRequest.getClientToken())) {
deleteSubnetRequest.setClientToken(this.generateClientToken());
}
InternalRequest internalRequest = this.createRequest(
deleteSubnetRequest, HttpMethodName.DELETE, SUBNET_PREFIX, deleteSubnetRequest.getSubnetId());
internalRequest.addParameter("clientToken", deleteSubnetRequest.getClientToken());
this.invokeHttpClient(internalRequest, AbstractBceResponse.class);
} } | public class class_name {
public void deleteSubnet(DeleteSubnetRequest deleteSubnetRequest) {
checkNotNull(deleteSubnetRequest, "request should not be null.");
checkNotNull(deleteSubnetRequest.getSubnetId(), "request subnetId should not be null.");
if (Strings.isNullOrEmpty(deleteSubnetRequest.getClientToken())) {
deleteSubnetRequest.setClientToken(this.generateClientToken()); // depends on control dependency: [if], data = [none]
}
InternalRequest internalRequest = this.createRequest(
deleteSubnetRequest, HttpMethodName.DELETE, SUBNET_PREFIX, deleteSubnetRequest.getSubnetId());
internalRequest.addParameter("clientToken", deleteSubnetRequest.getClientToken());
this.invokeHttpClient(internalRequest, AbstractBceResponse.class);
} } |
public class class_name {
public static boolean plays(Role role, String r) {
if (r == null) {
throw new IllegalArgumentException("null role");
}
if (role == null) {
return false;
}
return role.value().contains(r);
} } | public class class_name {
public static boolean plays(Role role, String r) {
if (r == null) {
throw new IllegalArgumentException("null role");
}
if (role == null) {
return false; // depends on control dependency: [if], data = [none]
}
return role.value().contains(r);
} } |
public class class_name {
public static void copy(InputStream is, OutputStream os) throws IOException {
Asserts.notNullParameter("is", is);
Asserts.notNullParameter("os", os);
try {
byte[] buf = new byte[1024];
int len = 0;
while((len = is.read(buf)) > 0) {
os.write(buf, 0, len);
}
} finally {
if(os != null) {
try {
os.close();
} catch (IOException e) {
// ignore
}
}
if(is != null) {
try {
is.close();
} catch (IOException e) {
// ignore
}
}
}
} } | public class class_name {
public static void copy(InputStream is, OutputStream os) throws IOException {
Asserts.notNullParameter("is", is);
Asserts.notNullParameter("os", os);
try {
byte[] buf = new byte[1024];
int len = 0;
while((len = is.read(buf)) > 0) {
os.write(buf, 0, len); // depends on control dependency: [while], data = [none]
}
} finally {
if(os != null) {
try {
os.close(); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
// ignore
} // depends on control dependency: [catch], data = [none]
}
if(is != null) {
try {
is.close(); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
// ignore
} // depends on control dependency: [catch], data = [none]
}
}
} } |
public class class_name {
private WorkUnitProcessor<ClasspathEntryWorkUnit> newClasspathEntryWorkUnitProcessor(
final Set<ClasspathElement> openedClasspathElementsSet,
final Queue<Entry<Integer, ClasspathElement>> toplevelClasspathEltOrder) {
return new WorkUnitProcessor<ClasspathEntryWorkUnit>() {
@Override
public void processWorkUnit(final ClasspathEntryWorkUnit workUnit,
final WorkQueue<ClasspathEntryWorkUnit> workQueue, final LogNode log)
throws InterruptedException {
try {
// Create a ClasspathElementZip or ClasspathElementDir for each entry in the classpath
ClasspathElement classpathElt;
try {
classpathElt = classpathEntryToClasspathElementSingletonMap.get(workUnit.rawClasspathEntry,
log);
} catch (final NullSingletonException e) {
throw new IOException("Cannot get classpath element for classpath entry "
+ workUnit.rawClasspathEntry + " : " + e);
}
// Only run open() once per ClasspathElement (it is possible for there to be
// multiple classpath elements with different non-canonical paths that map to
// the same canonical path, i.e. to the same ClasspathElement)
if (openedClasspathElementsSet.add(classpathElt)) {
// Check if the classpath element is valid (classpathElt.skipClasspathElement
// will be set if not). In case of ClasspathElementZip, open or extract nested
// jars as LogicalZipFile instances. Read manifest files for jarfiles to look
// for Class-Path manifest entries. Adds extra classpath elements to the work
// queue if they are found.
classpathElt.open(workQueue, log);
// Create a new tuple consisting of the order of the new classpath element
// within its parent, and the new classpath element.
// N.B. even if skipClasspathElement is true, still possibly need to scan child
// classpath elements (so still need to connect parent to child here)
final SimpleEntry<Integer, ClasspathElement> classpathEltEntry = //
new SimpleEntry<>(workUnit.orderWithinParentClasspathElement, classpathElt);
if (workUnit.parentClasspathElement != null) {
// Link classpath element to its parent, if it is not a toplevel element
workUnit.parentClasspathElement.childClasspathElementsIndexed.add(classpathEltEntry);
} else {
// Record toplevel elements
toplevelClasspathEltOrder.add(classpathEltEntry);
}
}
} catch (final IOException | SecurityException e) {
if (log != null) {
log.log("Skipping invalid classpath element " + workUnit.rawClasspathEntry.getKey() + " : "
+ e);
}
}
}
};
} } | public class class_name {
private WorkUnitProcessor<ClasspathEntryWorkUnit> newClasspathEntryWorkUnitProcessor(
final Set<ClasspathElement> openedClasspathElementsSet,
final Queue<Entry<Integer, ClasspathElement>> toplevelClasspathEltOrder) {
return new WorkUnitProcessor<ClasspathEntryWorkUnit>() {
@Override
public void processWorkUnit(final ClasspathEntryWorkUnit workUnit,
final WorkQueue<ClasspathEntryWorkUnit> workQueue, final LogNode log)
throws InterruptedException {
try {
// Create a ClasspathElementZip or ClasspathElementDir for each entry in the classpath
ClasspathElement classpathElt;
try {
classpathElt = classpathEntryToClasspathElementSingletonMap.get(workUnit.rawClasspathEntry,
log);
} catch (final NullSingletonException e) {
throw new IOException("Cannot get classpath element for classpath entry "
+ workUnit.rawClasspathEntry + " : " + e);
}
// Only run open() once per ClasspathElement (it is possible for there to be
// multiple classpath elements with different non-canonical paths that map to
// the same canonical path, i.e. to the same ClasspathElement)
if (openedClasspathElementsSet.add(classpathElt)) {
// Check if the classpath element is valid (classpathElt.skipClasspathElement
// will be set if not). In case of ClasspathElementZip, open or extract nested
// jars as LogicalZipFile instances. Read manifest files for jarfiles to look
// for Class-Path manifest entries. Adds extra classpath elements to the work
// queue if they are found.
classpathElt.open(workQueue, log);
// Create a new tuple consisting of the order of the new classpath element
// within its parent, and the new classpath element.
// N.B. even if skipClasspathElement is true, still possibly need to scan child
// classpath elements (so still need to connect parent to child here)
final SimpleEntry<Integer, ClasspathElement> classpathEltEntry = //
new SimpleEntry<>(workUnit.orderWithinParentClasspathElement, classpathElt);
if (workUnit.parentClasspathElement != null) {
// Link classpath element to its parent, if it is not a toplevel element
workUnit.parentClasspathElement.childClasspathElementsIndexed.add(classpathEltEntry); // depends on control dependency: [if], data = [none]
} else {
// Record toplevel elements
toplevelClasspathEltOrder.add(classpathEltEntry); // depends on control dependency: [if], data = [none]
}
}
} catch (final IOException | SecurityException e) {
if (log != null) {
log.log("Skipping invalid classpath element " + workUnit.rawClasspathEntry.getKey() + " : "
+ e); // depends on control dependency: [if], data = [none]
}
}
}
};
} } |
public class class_name {
public void marshall(EndpointConfigSummary endpointConfigSummary, ProtocolMarshaller protocolMarshaller) {
if (endpointConfigSummary == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(endpointConfigSummary.getEndpointConfigName(), ENDPOINTCONFIGNAME_BINDING);
protocolMarshaller.marshall(endpointConfigSummary.getEndpointConfigArn(), ENDPOINTCONFIGARN_BINDING);
protocolMarshaller.marshall(endpointConfigSummary.getCreationTime(), CREATIONTIME_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(EndpointConfigSummary endpointConfigSummary, ProtocolMarshaller protocolMarshaller) {
if (endpointConfigSummary == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(endpointConfigSummary.getEndpointConfigName(), ENDPOINTCONFIGNAME_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(endpointConfigSummary.getEndpointConfigArn(), ENDPOINTCONFIGARN_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(endpointConfigSummary.getCreationTime(), CREATIONTIME_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 {
protected long toLongSafe(String toParseParam) {
if (toParseParam == null || toParseParam.trim().isEmpty()) {
return -1;
}
try {
return Long.parseLong(toParseParam.trim());
} catch (NumberFormatException e) {
return -1;
}
} } | public class class_name {
protected long toLongSafe(String toParseParam) {
if (toParseParam == null || toParseParam.trim().isEmpty()) {
return -1; // depends on control dependency: [if], data = [none]
}
try {
return Long.parseLong(toParseParam.trim()); // depends on control dependency: [try], data = [none]
} catch (NumberFormatException e) {
return -1;
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public static <T extends Model> List<T> processCursor(Class<T> cls, Cursor cursor) {
final List<T> entities = new ArrayList<T>();
try {
Constructor<T> entityConstructor = cls.getConstructor();
if (cursor.moveToFirst()) {
do {
T entity = getEntity(cls, cursor.getLong(cursor.getColumnIndex(BaseColumns._ID)));
if (entity == null) {
entity = entityConstructor.newInstance();
}
entity.load(cursor);
entities.add(entity);
}
while (cursor.moveToNext());
}
} catch (Exception e) {
Log.e(TAG, "Failed to process cursor.", e);
}
return entities;
} } | public class class_name {
public static <T extends Model> List<T> processCursor(Class<T> cls, Cursor cursor) {
final List<T> entities = new ArrayList<T>();
try {
Constructor<T> entityConstructor = cls.getConstructor();
if (cursor.moveToFirst()) {
do {
T entity = getEntity(cls, cursor.getLong(cursor.getColumnIndex(BaseColumns._ID)));
if (entity == null) {
entity = entityConstructor.newInstance(); // depends on control dependency: [if], data = [none]
}
entity.load(cursor);
entities.add(entity);
}
while (cursor.moveToNext());
}
} catch (Exception e) {
Log.e(TAG, "Failed to process cursor.", e);
} // depends on control dependency: [catch], data = [none]
return entities;
} } |
public class class_name {
public java.util.List<String> getLabels() {
if (labels == null) {
labels = new com.amazonaws.internal.SdkInternalList<String>();
}
return labels;
} } | public class class_name {
public java.util.List<String> getLabels() {
if (labels == null) {
labels = new com.amazonaws.internal.SdkInternalList<String>(); // depends on control dependency: [if], data = [none]
}
return labels;
} } |
public class class_name {
static Map<String, ExtendedEntityManager> getCurrentCall() {
ArrayList<Map<String, ExtendedEntityManager>> stack = currentSFSBCallStack();
Map<String, ExtendedEntityManager> result = null;
if (stack != null) {
result = stack.get(stack.size() - 1);
}
return result;
} } | public class class_name {
static Map<String, ExtendedEntityManager> getCurrentCall() {
ArrayList<Map<String, ExtendedEntityManager>> stack = currentSFSBCallStack();
Map<String, ExtendedEntityManager> result = null;
if (stack != null) {
result = stack.get(stack.size() - 1); // depends on control dependency: [if], data = [(stack]
}
return result;
} } |
public class class_name {
private WFSExceptionWriter getFeature(PrintWriter out, HttpServletRequest hsreq, SimpleGeometryCSBuilder sgcs, String ftName, String fullFtName) {
List<SimpleGeometry> geometryList = new ArrayList<SimpleGeometry>();
GeometryType geoT = sgcs.getGeometryType(ftName);
if(geoT == null){
return new WFSExceptionWriter("Feature Type of " + fullFtName + " not found.", "GetFeature" , "OperationProcessingFailed");
}
try {
switch(geoT) {
case POINT:
Point pt = sgcs.getPoint(ftName, 0);
int j = 0;
while(pt != null) {
geometryList.add(pt);
j++;
pt = sgcs.getPoint(ftName, j);
}
break;
case LINE:
Line line = sgcs.getLine(ftName, 0);
int k = 0;
while(line != null) {
geometryList.add(line);
k++;
line = sgcs.getLine(ftName, k);
}
break;
case POLYGON:
Polygon poly = sgcs.getPolygon(ftName, 0);
int i = 0;
while(poly != null) {
geometryList.add(poly);
i++;
poly = sgcs.getPolygon(ftName, i);
}
break;
}
}
// Perhaps will change this to be implemented in the CFPolygon class
catch(ArrayIndexOutOfBoundsException aout){
}
WFSGetFeatureWriter gfdw = new WFSGetFeatureWriter(out, WFSController.constructServerPath(hsreq), WFSController.getXMLNamespaceXMLNSValue(hsreq), geometryList, ftName);
gfdw.startXML();
gfdw.writeMembers();
gfdw.finishXML();
return null;
} } | public class class_name {
private WFSExceptionWriter getFeature(PrintWriter out, HttpServletRequest hsreq, SimpleGeometryCSBuilder sgcs, String ftName, String fullFtName) {
List<SimpleGeometry> geometryList = new ArrayList<SimpleGeometry>();
GeometryType geoT = sgcs.getGeometryType(ftName);
if(geoT == null){
return new WFSExceptionWriter("Feature Type of " + fullFtName + " not found.", "GetFeature" , "OperationProcessingFailed");
// depends on control dependency: [if], data = [none]
}
try {
switch(geoT) {
case POINT:
Point pt = sgcs.getPoint(ftName, 0);
int j = 0;
while(pt != null) {
geometryList.add(pt);
// depends on control dependency: [while], data = [(pt]
j++;
// depends on control dependency: [while], data = [none]
pt = sgcs.getPoint(ftName, j);
// depends on control dependency: [while], data = [none]
}
break;
case LINE:
Line line = sgcs.getLine(ftName, 0);
int k = 0;
while(line != null) {
geometryList.add(line);
// depends on control dependency: [while], data = [(line]
k++;
// depends on control dependency: [while], data = [none]
line = sgcs.getLine(ftName, k);
// depends on control dependency: [while], data = [none]
}
break;
case POLYGON:
Polygon poly = sgcs.getPolygon(ftName, 0);
int i = 0;
while(poly != null) {
geometryList.add(poly);
// depends on control dependency: [while], data = [(poly]
i++;
// depends on control dependency: [while], data = [none]
poly = sgcs.getPolygon(ftName, i);
// depends on control dependency: [while], data = [none]
}
break;
}
}
// Perhaps will change this to be implemented in the CFPolygon class
catch(ArrayIndexOutOfBoundsException aout){
}
// depends on control dependency: [catch], data = [none]
WFSGetFeatureWriter gfdw = new WFSGetFeatureWriter(out, WFSController.constructServerPath(hsreq), WFSController.getXMLNamespaceXMLNSValue(hsreq), geometryList, ftName);
gfdw.startXML();
gfdw.writeMembers();
gfdw.finishXML();
return null;
} } |
public class class_name {
public static String[][] genSequence(String sent){
CharType[] tags = Chars.getType(sent);
int len = sent.length();
ArrayList<String> words = new ArrayList<String>();
ArrayList<String> types = new ArrayList<String>();
int begin =0;
for(int j=0; j<len; j++) {
if(j<len-1 && tags[j]==CharType.L && tags[j+1]==CharType.L){//当前是连续英文
continue;
}else if(j<len-1 &&tags[j]==CharType.D && tags[j+1]==CharType.D){//当前是连续数字
continue;
}
StringType st = Chars.char2StringType(tags[j]);
String w = sent.substring(begin,j+1);
words.add(w);
types.add(st.toString());
begin = j+1;
}
String[][] data = new String[2][];
data[0] = words.toArray(new String[words.size()]);
data[1] = types.toArray(new String[types.size()]);
return data;
} } | public class class_name {
public static String[][] genSequence(String sent){
CharType[] tags = Chars.getType(sent);
int len = sent.length();
ArrayList<String> words = new ArrayList<String>();
ArrayList<String> types = new ArrayList<String>();
int begin =0;
for(int j=0; j<len; j++) {
if(j<len-1 && tags[j]==CharType.L && tags[j+1]==CharType.L){//当前是连续英文
continue;
}else if(j<len-1 &&tags[j]==CharType.D && tags[j+1]==CharType.D){//当前是连续数字
continue;
}
StringType st = Chars.char2StringType(tags[j]);
String w = sent.substring(begin,j+1);
words.add(w); // depends on control dependency: [for], data = [none]
types.add(st.toString()); // depends on control dependency: [for], data = [none]
begin = j+1; // depends on control dependency: [for], data = [j]
}
String[][] data = new String[2][];
data[0] = words.toArray(new String[words.size()]);
data[1] = types.toArray(new String[types.size()]);
return data;
} } |
public class class_name {
@Override
public DocumentBuilderFactory createDocumentBuilderFactory() {
DocumentBuilderFactory instance = DocumentBuilderFactory.newInstance();
instance.setXIncludeAware(this.isXIncludeAware);
instance.setExpandEntityReferences(this.isExpandEntityReferences);
// for (String featureDefault : FEATURE_DEFAULTS) {
// String[] featureValue = featureDefault.split("#");
// try {
// instance.setFeature(featureValue[0], Boolean.valueOf(featureValue[1]));
// } catch (ParserConfigurationException e) {
// // No worries if one feature is not supported.
// }
// }
if (!NamespacePhilosophy.AGNOSTIC.equals(namespacePhilosophy)) {
instance.setNamespaceAware(NamespacePhilosophy.HEDONISTIC.equals(namespacePhilosophy));
}
return instance;
} } | public class class_name {
@Override
public DocumentBuilderFactory createDocumentBuilderFactory() {
DocumentBuilderFactory instance = DocumentBuilderFactory.newInstance();
instance.setXIncludeAware(this.isXIncludeAware);
instance.setExpandEntityReferences(this.isExpandEntityReferences);
// for (String featureDefault : FEATURE_DEFAULTS) {
// String[] featureValue = featureDefault.split("#");
// try {
// instance.setFeature(featureValue[0], Boolean.valueOf(featureValue[1]));
// } catch (ParserConfigurationException e) {
// // No worries if one feature is not supported.
// }
// }
if (!NamespacePhilosophy.AGNOSTIC.equals(namespacePhilosophy)) {
instance.setNamespaceAware(NamespacePhilosophy.HEDONISTIC.equals(namespacePhilosophy)); // depends on control dependency: [if], data = [none]
}
return instance;
} } |
public class class_name {
public static String escapeForXML(String inString) {
if (inString == null)
return null;
String outString = inString;
outString = replace(outString, "&", "&");
outString = replace(outString, "<", "<");
outString = replace(outString, ">", ">");
outString = replace(outString, "\"", """);
outString = replace(outString, "'", "'");
// We'll escape all chars not in this set (Safe)
String validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 &#;-_=+:,.?/";
for (int i = 0; i < outString.length(); i++) {
char c = outString.charAt(i);
if (validChars.indexOf(c) == -1) {
// Escape the character
outString = replace(outString, "" + c, "&#" + ((int) c) + ";");
}
}
return outString;
} } | public class class_name {
public static String escapeForXML(String inString) {
if (inString == null)
return null;
String outString = inString;
outString = replace(outString, "&", "&");
outString = replace(outString, "<", "<");
outString = replace(outString, ">", ">");
outString = replace(outString, "\"", """);
outString = replace(outString, "'", "'");
// We'll escape all chars not in this set (Safe)
String validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 &#;-_=+:,.?/";
for (int i = 0; i < outString.length(); i++) {
char c = outString.charAt(i);
if (validChars.indexOf(c) == -1) {
// Escape the character
outString = replace(outString, "" + c, "&#" + ((int) c) + ";");
// depends on control dependency: [if], data = [none]
}
}
return outString;
} } |
public class class_name {
@Override
public int chown(String path, @uid_t long uid, @gid_t long gid) {
if (!mIsUserGroupTranslation) {
LOG.info("Cannot change the owner/group of path {}. Please set {} to be true to enable "
+ "user group translation in Alluxio-FUSE.",
path, PropertyKey.FUSE_USER_GROUP_TRANSLATION_ENABLED.getName());
return -ErrorCodes.EOPNOTSUPP();
}
try {
SetAttributePOptions.Builder optionsBuilder = SetAttributePOptions.newBuilder();
final AlluxioURI uri = mPathResolverCache.getUnchecked(path);
String userName = "";
if (uid != ID_NOT_SET_VALUE && uid != ID_NOT_SET_VALUE_UNSIGNED) {
userName = AlluxioFuseUtils.getUserName(uid);
if (userName.isEmpty()) {
// This should never be reached
LOG.error("Failed to get user name from uid {}", uid);
return -ErrorCodes.EINVAL();
}
optionsBuilder.setOwner(userName);
}
String groupName = "";
if (gid != ID_NOT_SET_VALUE && gid != ID_NOT_SET_VALUE_UNSIGNED) {
groupName = AlluxioFuseUtils.getGroupName(gid);
if (groupName.isEmpty()) {
// This should never be reached
LOG.error("Failed to get group name from gid {}", gid);
return -ErrorCodes.EINVAL();
}
optionsBuilder.setGroup(groupName);
} else if (!userName.isEmpty()) {
groupName = AlluxioFuseUtils.getGroupName(userName);
optionsBuilder.setGroup(groupName);
}
if (userName.isEmpty() && groupName.isEmpty()) {
// This should never be reached
LOG.info("Unable to change owner and group of file {} when uid is {} and gid is {}", path,
userName, groupName);
} else if (userName.isEmpty()) {
LOG.info("Change group of file {} to {}", path, groupName);
mFileSystem.setAttribute(uri, optionsBuilder.build());
} else {
LOG.info("Change owner of file {} to {}", path, groupName);
mFileSystem.setAttribute(uri, optionsBuilder.build());
}
} catch (Throwable t) {
LOG.error("Failed to chown {} to uid {} and gid {}", path, uid, gid, t);
return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
} } | public class class_name {
@Override
public int chown(String path, @uid_t long uid, @gid_t long gid) {
if (!mIsUserGroupTranslation) {
LOG.info("Cannot change the owner/group of path {}. Please set {} to be true to enable "
+ "user group translation in Alluxio-FUSE.",
path, PropertyKey.FUSE_USER_GROUP_TRANSLATION_ENABLED.getName()); // depends on control dependency: [if], data = [none]
return -ErrorCodes.EOPNOTSUPP(); // depends on control dependency: [if], data = [none]
}
try {
SetAttributePOptions.Builder optionsBuilder = SetAttributePOptions.newBuilder();
final AlluxioURI uri = mPathResolverCache.getUnchecked(path);
String userName = "";
if (uid != ID_NOT_SET_VALUE && uid != ID_NOT_SET_VALUE_UNSIGNED) {
userName = AlluxioFuseUtils.getUserName(uid); // depends on control dependency: [if], data = [(uid]
if (userName.isEmpty()) {
// This should never be reached
LOG.error("Failed to get user name from uid {}", uid); // depends on control dependency: [if], data = [none]
return -ErrorCodes.EINVAL(); // depends on control dependency: [if], data = [none]
}
optionsBuilder.setOwner(userName); // depends on control dependency: [if], data = [none]
}
String groupName = "";
if (gid != ID_NOT_SET_VALUE && gid != ID_NOT_SET_VALUE_UNSIGNED) {
groupName = AlluxioFuseUtils.getGroupName(gid); // depends on control dependency: [if], data = [(gid]
if (groupName.isEmpty()) {
// This should never be reached
LOG.error("Failed to get group name from gid {}", gid); // depends on control dependency: [if], data = [none]
return -ErrorCodes.EINVAL(); // depends on control dependency: [if], data = [none]
}
optionsBuilder.setGroup(groupName); // depends on control dependency: [if], data = [none]
} else if (!userName.isEmpty()) {
groupName = AlluxioFuseUtils.getGroupName(userName); // depends on control dependency: [if], data = [none]
optionsBuilder.setGroup(groupName); // depends on control dependency: [if], data = [none]
}
if (userName.isEmpty() && groupName.isEmpty()) {
// This should never be reached
LOG.info("Unable to change owner and group of file {} when uid is {} and gid is {}", path,
userName, groupName); // depends on control dependency: [if], data = [none]
} else if (userName.isEmpty()) {
LOG.info("Change group of file {} to {}", path, groupName); // depends on control dependency: [if], data = [none]
mFileSystem.setAttribute(uri, optionsBuilder.build()); // depends on control dependency: [if], data = [none]
} else {
LOG.info("Change owner of file {} to {}", path, groupName); // depends on control dependency: [if], data = [none]
mFileSystem.setAttribute(uri, optionsBuilder.build()); // depends on control dependency: [if], data = [none]
}
} catch (Throwable t) {
LOG.error("Failed to chown {} to uid {} and gid {}", path, uid, gid, t);
return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
} } |
public class class_name {
public static <T> AsyncCallback<T> disabler (AsyncCallback<T> callback,
final HasEnabled... disablees)
{
for (HasEnabled widget : disablees) {
widget.setEnabled(false);
}
return new ChainedCallback<T, T>(callback) {
@Override public void onSuccess (T result) {
for (HasEnabled widget : disablees) {
widget.setEnabled(true);
}
forwardSuccess(result);
}
@Override public void onFailure (Throwable cause) {
for (HasEnabled widget : disablees) {
widget.setEnabled(true);
}
super.onFailure(cause);
}
};
} } | public class class_name {
public static <T> AsyncCallback<T> disabler (AsyncCallback<T> callback,
final HasEnabled... disablees)
{
for (HasEnabled widget : disablees) {
widget.setEnabled(false); // depends on control dependency: [for], data = [widget]
}
return new ChainedCallback<T, T>(callback) {
@Override public void onSuccess (T result) {
for (HasEnabled widget : disablees) {
widget.setEnabled(true); // depends on control dependency: [for], data = [widget]
}
forwardSuccess(result);
}
@Override public void onFailure (Throwable cause) {
for (HasEnabled widget : disablees) {
widget.setEnabled(true); // depends on control dependency: [for], data = [widget]
}
super.onFailure(cause);
}
};
} } |
public class class_name {
private List<CmsResource> internalReadResourceList(CmsObject cms, List<CmsUUID> uuidList) {
List<CmsResource> resList = new ArrayList<CmsResource>(uuidList.size());
for (Iterator<CmsUUID> i = uuidList.iterator(); i.hasNext();) {
try {
CmsResource res = cms.readResource(i.next(), CmsResourceFilter.ALL);
resList.add(res);
} catch (CmsException exc) {
LOG.error(exc.getLocalizedMessage(), exc);
}
}
return resList;
} } | public class class_name {
private List<CmsResource> internalReadResourceList(CmsObject cms, List<CmsUUID> uuidList) {
List<CmsResource> resList = new ArrayList<CmsResource>(uuidList.size());
for (Iterator<CmsUUID> i = uuidList.iterator(); i.hasNext();) {
try {
CmsResource res = cms.readResource(i.next(), CmsResourceFilter.ALL);
resList.add(res); // depends on control dependency: [try], data = [none]
} catch (CmsException exc) {
LOG.error(exc.getLocalizedMessage(), exc);
} // depends on control dependency: [catch], data = [none]
}
return resList;
} } |
public class class_name {
public void marshall(BillingModeSummary billingModeSummary, ProtocolMarshaller protocolMarshaller) {
if (billingModeSummary == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(billingModeSummary.getBillingMode(), BILLINGMODE_BINDING);
protocolMarshaller.marshall(billingModeSummary.getLastUpdateToPayPerRequestDateTime(), LASTUPDATETOPAYPERREQUESTDATETIME_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(BillingModeSummary billingModeSummary, ProtocolMarshaller protocolMarshaller) {
if (billingModeSummary == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(billingModeSummary.getBillingMode(), BILLINGMODE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(billingModeSummary.getLastUpdateToPayPerRequestDateTime(), LASTUPDATETOPAYPERREQUESTDATETIME_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 {
void getProperties(Connection connection, long id, LoggingEvent event)
throws SQLException {
PreparedStatement statement = connection.prepareStatement(sqlProperties);
try {
statement.setLong(1, id);
ResultSet rs = statement.executeQuery();
while (rs.next()) {
String key = rs.getString(1);
String value = rs.getString(2);
event.setProperty(key, value);
}
} finally {
statement.close();
}
} } | public class class_name {
void getProperties(Connection connection, long id, LoggingEvent event)
throws SQLException {
PreparedStatement statement = connection.prepareStatement(sqlProperties);
try {
statement.setLong(1, id);
ResultSet rs = statement.executeQuery();
while (rs.next()) {
String key = rs.getString(1);
String value = rs.getString(2);
event.setProperty(key, value); // depends on control dependency: [while], data = [none]
}
} finally {
statement.close();
}
} } |
public class class_name {
private static int isTashkeelOnTatweelChar(char ch){
if (ch >= 0xfe70 && ch <= 0xfe7f && ch != NEW_TAIL_CHAR && ch != 0xFE75 && ch != SHADDA_TATWEEL_CHAR)
{
return tashkeelMedial [ch - 0xFE70];
} else if( (ch >= 0xfcf2 && ch <= 0xfcf4) || (ch == SHADDA_TATWEEL_CHAR)) {
return 2;
} else {
return 0;
}
} } | public class class_name {
private static int isTashkeelOnTatweelChar(char ch){
if (ch >= 0xfe70 && ch <= 0xfe7f && ch != NEW_TAIL_CHAR && ch != 0xFE75 && ch != SHADDA_TATWEEL_CHAR)
{
return tashkeelMedial [ch - 0xFE70]; // depends on control dependency: [if], data = [none]
} else if( (ch >= 0xfcf2 && ch <= 0xfcf4) || (ch == SHADDA_TATWEEL_CHAR)) {
return 2; // depends on control dependency: [if], data = [none]
} else {
return 0; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
@UiThread
public void expandParentRange(int startParentPosition, int parentCount) {
int endParentPosition = startParentPosition + parentCount;
for (int i = startParentPosition; i < endParentPosition; i++) {
expandParent(i);
}
} } | public class class_name {
@UiThread
public void expandParentRange(int startParentPosition, int parentCount) {
int endParentPosition = startParentPosition + parentCount;
for (int i = startParentPosition; i < endParentPosition; i++) {
expandParent(i); // depends on control dependency: [for], data = [i]
}
} } |
public class class_name {
private String fixPortletPath(HttpServletRequest request, IPortalUrlBuilder urlBuilder) {
String path = urlBuilder.getUrlString();
String context = request.getContextPath();
if (StringUtils.isBlank(context)) {
context = "/";
}
if (!path.startsWith(context + "/f/")) {
return path.replaceFirst(context, context + "/f/" + loginPortletFolderName);
}
return path;
} } | public class class_name {
private String fixPortletPath(HttpServletRequest request, IPortalUrlBuilder urlBuilder) {
String path = urlBuilder.getUrlString();
String context = request.getContextPath();
if (StringUtils.isBlank(context)) {
context = "/"; // depends on control dependency: [if], data = [none]
}
if (!path.startsWith(context + "/f/")) {
return path.replaceFirst(context, context + "/f/" + loginPortletFolderName); // depends on control dependency: [if], data = [none]
}
return path;
} } |
public class class_name {
public EClass getIfcLaborResource() {
if (ifcLaborResourceEClass == null) {
ifcLaborResourceEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc2x3tc1Package.eNS_URI)
.getEClassifiers().get(286);
}
return ifcLaborResourceEClass;
} } | public class class_name {
public EClass getIfcLaborResource() {
if (ifcLaborResourceEClass == null) {
ifcLaborResourceEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc2x3tc1Package.eNS_URI)
.getEClassifiers().get(286);
// depends on control dependency: [if], data = [none]
}
return ifcLaborResourceEClass;
} } |
public class class_name {
Number numberFor(Number source, Class<?> destinationType) {
if (destinationType.equals(source.getClass()))
return source;
if (destinationType.equals(Byte.class)) {
long longValue = source.longValue();
if (longValue > Byte.MAX_VALUE)
throw new Errors().errorTooLarge(source, destinationType).toMappingException();
if (longValue < Byte.MIN_VALUE)
throw new Errors().errorTooSmall(source, destinationType).toMappingException();
return Byte.valueOf(source.byteValue());
}
if (destinationType.equals(Short.class)) {
long longValue = source.longValue();
if (longValue > Short.MAX_VALUE)
throw new Errors().errorTooLarge(source, destinationType).toMappingException();
if (longValue < Short.MIN_VALUE)
throw new Errors().errorTooSmall(source, destinationType).toMappingException();
return Short.valueOf(source.shortValue());
}
if (destinationType.equals(Integer.class)) {
long longValue = source.longValue();
if (longValue > Integer.MAX_VALUE)
throw new Errors().errorTooLarge(source, destinationType).toMappingException();
if (longValue < Integer.MIN_VALUE)
throw new Errors().errorTooSmall(source, destinationType).toMappingException();
return Integer.valueOf(source.intValue());
}
if (destinationType.equals(Long.class))
return Long.valueOf(source.longValue());
if (destinationType.equals(Float.class)) {
if (source.doubleValue() > Float.MAX_VALUE)
throw new Errors().errorTooLarge(source, destinationType).toMappingException();
return Float.valueOf(source.floatValue());
}
if (destinationType.equals(Double.class))
return Double.valueOf(source.doubleValue());
if (destinationType.equals(BigDecimal.class)) {
if (source instanceof Float || source instanceof Double)
return new BigDecimal(source.toString());
else if (source instanceof BigInteger)
return new BigDecimal((BigInteger) source);
else
return BigDecimal.valueOf(source.longValue());
}
if (destinationType.equals(BigInteger.class)) {
if (source instanceof BigDecimal)
return ((BigDecimal) source).toBigInteger();
else
return BigInteger.valueOf(source.longValue());
}
throw new Errors().errorMapping(source, destinationType).toMappingException();
} } | public class class_name {
Number numberFor(Number source, Class<?> destinationType) {
if (destinationType.equals(source.getClass()))
return source;
if (destinationType.equals(Byte.class)) {
long longValue = source.longValue();
if (longValue > Byte.MAX_VALUE)
throw new Errors().errorTooLarge(source, destinationType).toMappingException();
if (longValue < Byte.MIN_VALUE)
throw new Errors().errorTooSmall(source, destinationType).toMappingException();
return Byte.valueOf(source.byteValue());
// depends on control dependency: [if], data = [none]
}
if (destinationType.equals(Short.class)) {
long longValue = source.longValue();
if (longValue > Short.MAX_VALUE)
throw new Errors().errorTooLarge(source, destinationType).toMappingException();
if (longValue < Short.MIN_VALUE)
throw new Errors().errorTooSmall(source, destinationType).toMappingException();
return Short.valueOf(source.shortValue());
// depends on control dependency: [if], data = [none]
}
if (destinationType.equals(Integer.class)) {
long longValue = source.longValue();
if (longValue > Integer.MAX_VALUE)
throw new Errors().errorTooLarge(source, destinationType).toMappingException();
if (longValue < Integer.MIN_VALUE)
throw new Errors().errorTooSmall(source, destinationType).toMappingException();
return Integer.valueOf(source.intValue());
// depends on control dependency: [if], data = [none]
}
if (destinationType.equals(Long.class))
return Long.valueOf(source.longValue());
if (destinationType.equals(Float.class)) {
if (source.doubleValue() > Float.MAX_VALUE)
throw new Errors().errorTooLarge(source, destinationType).toMappingException();
return Float.valueOf(source.floatValue());
// depends on control dependency: [if], data = [none]
}
if (destinationType.equals(Double.class))
return Double.valueOf(source.doubleValue());
if (destinationType.equals(BigDecimal.class)) {
if (source instanceof Float || source instanceof Double)
return new BigDecimal(source.toString());
else if (source instanceof BigInteger)
return new BigDecimal((BigInteger) source);
else
return BigDecimal.valueOf(source.longValue());
}
if (destinationType.equals(BigInteger.class)) {
if (source instanceof BigDecimal)
return ((BigDecimal) source).toBigInteger();
else
return BigInteger.valueOf(source.longValue());
}
throw new Errors().errorMapping(source, destinationType).toMappingException();
} } |
public class class_name {
public <R> Promise<R> zipPromise(final ListFunction<T, Promise<R>> fuc) {
return new Promise<>(resolver -> {
promises.then(promises1 -> {
final ArrayList<T> res = new ArrayList<T>();
for (int i = 0; i < promises1.length; i++) {
res.add(null);
}
final Boolean[] ended = new Boolean[promises1.length];
for (int i = 0; i < promises1.length; i++) {
final int finalI = i;
promises1[i].then(t -> {
res.set(finalI, t);
ended[finalI] = true;
for (int i1 = 0; i1 < promises1.length; i1++) {
if (ended[i1] == null || !ended[i1]) {
return;
}
}
fuc.apply(res)
.pipeTo(resolver);
});
promises1[i].failure(e -> resolver.error(e));
}
if (promises1.length == 0) {
fuc.apply(res)
.pipeTo(resolver);
}
});
promises.failure(e -> resolver.error(e));
});
} } | public class class_name {
public <R> Promise<R> zipPromise(final ListFunction<T, Promise<R>> fuc) {
return new Promise<>(resolver -> {
promises.then(promises1 -> {
final ArrayList<T> res = new ArrayList<T>();
for (int i = 0; i < promises1.length; i++) {
res.add(null);
}
final Boolean[] ended = new Boolean[promises1.length];
for (int i = 0; i < promises1.length; i++) {
final int finalI = i;
promises1[i].then(t -> {
res.set(finalI, t);
ended[finalI] = true;
for (int i1 = 0; i1 < promises1.length; i1++) {
if (ended[i1] == null || !ended[i1]) {
return; // depends on control dependency: [if], data = [none]
}
}
fuc.apply(res)
.pipeTo(resolver);
});
promises1[i].failure(e -> resolver.error(e));
}
if (promises1.length == 0) {
fuc.apply(res)
.pipeTo(resolver);
}
});
promises.failure(e -> resolver.error(e));
});
} } |
public class class_name {
public void setPolicyInputList(java.util.Collection<String> policyInputList) {
if (policyInputList == null) {
this.policyInputList = null;
return;
}
this.policyInputList = new com.amazonaws.internal.SdkInternalList<String>(policyInputList);
} } | public class class_name {
public void setPolicyInputList(java.util.Collection<String> policyInputList) {
if (policyInputList == null) {
this.policyInputList = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.policyInputList = new com.amazonaws.internal.SdkInternalList<String>(policyInputList);
} } |
public class class_name {
String getURI (String prefix)
{
if ("".equals(prefix)) {
return defaultNS;
} else if (prefixTable == null) {
return null;
} else {
return (String)prefixTable.get(prefix);
}
} } | public class class_name {
String getURI (String prefix)
{
if ("".equals(prefix)) {
return defaultNS; // depends on control dependency: [if], data = [none]
} else if (prefixTable == null) {
return null; // depends on control dependency: [if], data = [none]
} else {
return (String)prefixTable.get(prefix); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static <E extends Enum<E>> long getLongFlag(EnumSet<E> eSet)
{
long flag = 0;
for (Enum<E> en : eSet)
{
long ordinal = en.ordinal();
if (ordinal >= Long.SIZE)
{
throw new IllegalArgumentException(eSet+" contains too many enums for long");
}
flag |= 1 << ordinal;
}
return flag;
} } | public class class_name {
public static <E extends Enum<E>> long getLongFlag(EnumSet<E> eSet)
{
long flag = 0;
for (Enum<E> en : eSet)
{
long ordinal = en.ordinal();
if (ordinal >= Long.SIZE)
{
throw new IllegalArgumentException(eSet+" contains too many enums for long");
}
flag |= 1 << ordinal;
// depends on control dependency: [for], data = [none]
}
return flag;
} } |
public class class_name {
public void transition(RaftServer.Role role) {
checkThread();
checkNotNull(role);
if (this.role.role() == role) {
return;
}
log.info("Transitioning to {}", role);
// Close the old state.
try {
this.role.stop().get();
} catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("failed to close Raft state", e);
}
// Force state transitions to occur synchronously in order to prevent race conditions.
try {
this.role = createRole(role);
this.role.start().get();
} catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("failed to initialize Raft state", e);
}
roleChangeListeners.forEach(l -> l.accept(this.role.role()));
} } | public class class_name {
public void transition(RaftServer.Role role) {
checkThread();
checkNotNull(role);
if (this.role.role() == role) {
return; // depends on control dependency: [if], data = [none]
}
log.info("Transitioning to {}", role);
// Close the old state.
try {
this.role.stop().get(); // depends on control dependency: [try], data = [none]
} catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("failed to close Raft state", e);
} // depends on control dependency: [catch], data = [none]
// Force state transitions to occur synchronously in order to prevent race conditions.
try {
this.role = createRole(role); // depends on control dependency: [try], data = [none]
this.role.start().get(); // depends on control dependency: [try], data = [none]
} catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("failed to initialize Raft state", e);
} // depends on control dependency: [catch], data = [none]
roleChangeListeners.forEach(l -> l.accept(this.role.role()));
} } |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.