code stringlengths 130 281k | code_dependency stringlengths 182 306k |
|---|---|
public class class_name {
public static <I extends ScoreIter> double computeNDCG(Predicate<? super I> predicate, I iter) {
double sum = 0.;
int i = 0, positive = 0, tied = 0, totalpos = 0;
while(iter.valid()) {
// positive or negative match?
do {
if(predicate.test(iter)) {
++positive;
}
++tied;
++i;
iter.advance();
} // Loop while tied:
while(iter.valid() && iter.tiedToPrevious());
// We only support binary labeling, and can ignore negative weight.
if(positive > 0) {
sum += tied == 1 ? 1. / FastMath.log(i + 1) : //
DCGEvaluation.sumInvLog1p(i - tied + 1, i) * positive / (double) tied;
totalpos += positive;
}
positive = 0;
tied = 0;
}
// Optimum value:
double idcg = DCGEvaluation.sumInvLog1p(1, totalpos);
return sum / idcg; // log(2) base would disappear
} } | public class class_name {
public static <I extends ScoreIter> double computeNDCG(Predicate<? super I> predicate, I iter) {
double sum = 0.;
int i = 0, positive = 0, tied = 0, totalpos = 0;
while(iter.valid()) {
// positive or negative match?
do {
if(predicate.test(iter)) {
++positive; // depends on control dependency: [if], data = [none]
}
++tied;
++i;
iter.advance();
} // Loop while tied:
while(iter.valid() && iter.tiedToPrevious());
// We only support binary labeling, and can ignore negative weight.
if(positive > 0) {
sum += tied == 1 ? 1. / FastMath.log(i + 1) : //
DCGEvaluation.sumInvLog1p(i - tied + 1, i) * positive / (double) tied; // depends on control dependency: [if], data = [none]
totalpos += positive; // depends on control dependency: [if], data = [none]
}
positive = 0; // depends on control dependency: [while], data = [none]
tied = 0; // depends on control dependency: [while], data = [none]
}
// Optimum value:
double idcg = DCGEvaluation.sumInvLog1p(1, totalpos);
return sum / idcg; // log(2) base would disappear
} } |
public class class_name {
public java.util.List<Device> getDevices() {
if (devices == null) {
devices = new com.amazonaws.internal.SdkInternalList<Device>();
}
return devices;
} } | public class class_name {
public java.util.List<Device> getDevices() {
if (devices == null) {
devices = new com.amazonaws.internal.SdkInternalList<Device>(); // depends on control dependency: [if], data = [none]
}
return devices;
} } |
public class class_name {
@Override
protected void prepare(int flags) throws IOException {
SysUtil.mkdirOrThrow(soDirectory);
File lockFileName = new File(soDirectory, LOCK_FILE_NAME);
FileLocker lock = FileLocker.lock(lockFileName);
try {
Log.v(TAG, "locked dso store " + soDirectory);
if (refreshLocked(lock, flags, getDepsBlock())) {
lock = null; // Lock transferred to syncer thread
} else {
Log.i(TAG, "dso store is up-to-date: " + soDirectory);
}
} finally {
if (lock != null) {
Log.v(TAG, "releasing dso store lock for " + soDirectory);
lock.close();
} else {
Log.v(TAG, "not releasing dso store lock for "
+ soDirectory + " (syncer thread started)");
}
}
} } | public class class_name {
@Override
protected void prepare(int flags) throws IOException {
SysUtil.mkdirOrThrow(soDirectory);
File lockFileName = new File(soDirectory, LOCK_FILE_NAME);
FileLocker lock = FileLocker.lock(lockFileName);
try {
Log.v(TAG, "locked dso store " + soDirectory);
if (refreshLocked(lock, flags, getDepsBlock())) {
lock = null; // Lock transferred to syncer thread // depends on control dependency: [if], data = [none]
} else {
Log.i(TAG, "dso store is up-to-date: " + soDirectory); // depends on control dependency: [if], data = [none]
}
} finally {
if (lock != null) {
Log.v(TAG, "releasing dso store lock for " + soDirectory);
lock.close();
} else {
Log.v(TAG, "not releasing dso store lock for "
+ soDirectory + " (syncer thread started)");
}
}
} } |
public class class_name {
@Override
public final void bind(final Component _hostComponent)
{
Args.notNull(_hostComponent, "hostComponent");
if (this.component != null) {
throw new IllegalStateException("this kind of handler cannot be attached to "
+ "multiple components; it is already attached to component " + this.component
+ ", but component " + _hostComponent + " wants to be attached too");
}
this.component = _hostComponent;
this.component.setOutputMarkupId(true);
} } | public class class_name {
@Override
public final void bind(final Component _hostComponent)
{
Args.notNull(_hostComponent, "hostComponent");
if (this.component != null) {
throw new IllegalStateException("this kind of handler cannot be attached to "
+ "multiple components; it is already attached to component " + this.component
+ ", but component " + _hostComponent + " wants to be attached too"); // depends on control dependency: [if], data = [none]
}
this.component = _hostComponent;
this.component.setOutputMarkupId(true);
} } |
public class class_name {
public final EObject ruleXAdditiveExpression() throws RecognitionException {
EObject current = null;
EObject this_XMultiplicativeExpression_0 = null;
EObject lv_rightOperand_3_0 = null;
enterRule();
try {
// InternalSARL.g:13044:2: ( (this_XMultiplicativeExpression_0= ruleXMultiplicativeExpression ( ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) ) )* ) )
// InternalSARL.g:13045:2: (this_XMultiplicativeExpression_0= ruleXMultiplicativeExpression ( ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) ) )* )
{
// InternalSARL.g:13045:2: (this_XMultiplicativeExpression_0= ruleXMultiplicativeExpression ( ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) ) )* )
// InternalSARL.g:13046:3: this_XMultiplicativeExpression_0= ruleXMultiplicativeExpression ( ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) ) )*
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXAdditiveExpressionAccess().getXMultiplicativeExpressionParserRuleCall_0());
}
pushFollow(FOLLOW_123);
this_XMultiplicativeExpression_0=ruleXMultiplicativeExpression();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
current = this_XMultiplicativeExpression_0;
afterParserOrEnumRuleCall();
}
// InternalSARL.g:13054:3: ( ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) ) )*
loop312:
do {
int alt312=2;
int LA312_0 = input.LA(1);
if ( (LA312_0==75) ) {
int LA312_2 = input.LA(2);
if ( (synpred39_InternalSARL()) ) {
alt312=1;
}
}
else if ( (LA312_0==74) ) {
int LA312_3 = input.LA(2);
if ( (synpred39_InternalSARL()) ) {
alt312=1;
}
}
switch (alt312) {
case 1 :
// InternalSARL.g:13055:4: ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) )
{
// InternalSARL.g:13055:4: ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) )
// InternalSARL.g:13056:5: ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) )
{
// InternalSARL.g:13066:5: ( () ( ( ruleOpAdd ) ) )
// InternalSARL.g:13067:6: () ( ( ruleOpAdd ) )
{
// InternalSARL.g:13067:6: ()
// InternalSARL.g:13068:7:
{
if ( state.backtracking==0 ) {
current = forceCreateModelElementAndSet(
grammarAccess.getXAdditiveExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0(),
current);
}
}
// InternalSARL.g:13074:6: ( ( ruleOpAdd ) )
// InternalSARL.g:13075:7: ( ruleOpAdd )
{
// InternalSARL.g:13075:7: ( ruleOpAdd )
// InternalSARL.g:13076:8: ruleOpAdd
{
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElement(grammarAccess.getXAdditiveExpressionRule());
}
}
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXAdditiveExpressionAccess().getFeatureJvmIdentifiableElementCrossReference_1_0_0_1_0());
}
pushFollow(FOLLOW_45);
ruleOpAdd();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
afterParserOrEnumRuleCall();
}
}
}
}
}
// InternalSARL.g:13092:4: ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) )
// InternalSARL.g:13093:5: (lv_rightOperand_3_0= ruleXMultiplicativeExpression )
{
// InternalSARL.g:13093:5: (lv_rightOperand_3_0= ruleXMultiplicativeExpression )
// InternalSARL.g:13094:6: lv_rightOperand_3_0= ruleXMultiplicativeExpression
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXAdditiveExpressionAccess().getRightOperandXMultiplicativeExpressionParserRuleCall_1_1_0());
}
pushFollow(FOLLOW_123);
lv_rightOperand_3_0=ruleXMultiplicativeExpression();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElementForParent(grammarAccess.getXAdditiveExpressionRule());
}
set(
current,
"rightOperand",
lv_rightOperand_3_0,
"io.sarl.lang.SARL.XMultiplicativeExpression");
afterParserOrEnumRuleCall();
}
}
}
}
break;
default :
break loop312;
}
} while (true);
}
}
if ( state.backtracking==0 ) {
leaveRule();
}
}
catch (RecognitionException re) {
recover(input,re);
appendSkippedTokens();
}
finally {
}
return current;
} } | public class class_name {
public final EObject ruleXAdditiveExpression() throws RecognitionException {
EObject current = null;
EObject this_XMultiplicativeExpression_0 = null;
EObject lv_rightOperand_3_0 = null;
enterRule();
try {
// InternalSARL.g:13044:2: ( (this_XMultiplicativeExpression_0= ruleXMultiplicativeExpression ( ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) ) )* ) )
// InternalSARL.g:13045:2: (this_XMultiplicativeExpression_0= ruleXMultiplicativeExpression ( ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) ) )* )
{
// InternalSARL.g:13045:2: (this_XMultiplicativeExpression_0= ruleXMultiplicativeExpression ( ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) ) )* )
// InternalSARL.g:13046:3: this_XMultiplicativeExpression_0= ruleXMultiplicativeExpression ( ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) ) )*
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXAdditiveExpressionAccess().getXMultiplicativeExpressionParserRuleCall_0()); // depends on control dependency: [if], data = [none]
}
pushFollow(FOLLOW_123);
this_XMultiplicativeExpression_0=ruleXMultiplicativeExpression();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
current = this_XMultiplicativeExpression_0; // depends on control dependency: [if], data = [none]
afterParserOrEnumRuleCall(); // depends on control dependency: [if], data = [none]
}
// InternalSARL.g:13054:3: ( ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) ) )*
loop312:
do {
int alt312=2;
int LA312_0 = input.LA(1);
if ( (LA312_0==75) ) {
int LA312_2 = input.LA(2);
if ( (synpred39_InternalSARL()) ) {
alt312=1; // depends on control dependency: [if], data = [none]
}
}
else if ( (LA312_0==74) ) {
int LA312_3 = input.LA(2);
if ( (synpred39_InternalSARL()) ) {
alt312=1; // depends on control dependency: [if], data = [none]
}
}
switch (alt312) {
case 1 :
// InternalSARL.g:13055:4: ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) ) ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) )
{
// InternalSARL.g:13055:4: ( ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) ) )
// InternalSARL.g:13056:5: ( ( () ( ( ruleOpAdd ) ) ) )=> ( () ( ( ruleOpAdd ) ) )
{
// InternalSARL.g:13066:5: ( () ( ( ruleOpAdd ) ) )
// InternalSARL.g:13067:6: () ( ( ruleOpAdd ) )
{
// InternalSARL.g:13067:6: ()
// InternalSARL.g:13068:7:
{
if ( state.backtracking==0 ) {
current = forceCreateModelElementAndSet(
grammarAccess.getXAdditiveExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0(),
current); // depends on control dependency: [if], data = [none]
}
}
// InternalSARL.g:13074:6: ( ( ruleOpAdd ) )
// InternalSARL.g:13075:7: ( ruleOpAdd )
{
// InternalSARL.g:13075:7: ( ruleOpAdd )
// InternalSARL.g:13076:8: ruleOpAdd
{
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElement(grammarAccess.getXAdditiveExpressionRule()); // depends on control dependency: [if], data = [none]
}
}
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXAdditiveExpressionAccess().getFeatureJvmIdentifiableElementCrossReference_1_0_0_1_0()); // depends on control dependency: [if], data = [none]
}
pushFollow(FOLLOW_45);
ruleOpAdd();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
afterParserOrEnumRuleCall(); // depends on control dependency: [if], data = [none]
}
}
}
}
}
// InternalSARL.g:13092:4: ( (lv_rightOperand_3_0= ruleXMultiplicativeExpression ) )
// InternalSARL.g:13093:5: (lv_rightOperand_3_0= ruleXMultiplicativeExpression )
{
// InternalSARL.g:13093:5: (lv_rightOperand_3_0= ruleXMultiplicativeExpression )
// InternalSARL.g:13094:6: lv_rightOperand_3_0= ruleXMultiplicativeExpression
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXAdditiveExpressionAccess().getRightOperandXMultiplicativeExpressionParserRuleCall_1_1_0()); // depends on control dependency: [if], data = [none]
}
pushFollow(FOLLOW_123);
lv_rightOperand_3_0=ruleXMultiplicativeExpression();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElementForParent(grammarAccess.getXAdditiveExpressionRule()); // depends on control dependency: [if], data = [none]
}
set(
current,
"rightOperand",
lv_rightOperand_3_0,
"io.sarl.lang.SARL.XMultiplicativeExpression"); // depends on control dependency: [if], data = [none]
afterParserOrEnumRuleCall(); // depends on control dependency: [if], data = [none]
}
}
}
}
break;
default :
break loop312;
}
} while (true);
}
}
if ( state.backtracking==0 ) {
leaveRule(); // depends on control dependency: [if], data = [none]
}
}
catch (RecognitionException re) {
recover(input,re);
appendSkippedTokens();
}
finally {
}
return current;
} } |
public class class_name {
@MainThread
private void handleTasksExecution() {
if (isExecuting || executionQueue.isEmpty()) {
return; // Nothing to dispatch
}
try {
isExecuting = true;
handleTasksExecutionWrapped();
} finally {
isExecuting = false;
}
} } | public class class_name {
@MainThread
private void handleTasksExecution() {
if (isExecuting || executionQueue.isEmpty()) {
return; // Nothing to dispatch // depends on control dependency: [if], data = [none]
}
try {
isExecuting = true; // depends on control dependency: [try], data = [none]
handleTasksExecutionWrapped(); // depends on control dependency: [try], data = [none]
} finally {
isExecuting = false;
}
} } |
public class class_name {
public GraphQLDirective buildDirective(Directive directive, Set<GraphQLDirective> directiveDefinitions, DirectiveLocation directiveLocation) {
Optional<GraphQLDirective> directiveDefinition = directiveDefinitions.stream().filter(dd -> dd.getName().equals(directive.getName())).findFirst();
GraphQLDirective.Builder builder = GraphQLDirective.newDirective()
.name(directive.getName())
.description(buildDescription(directive, null))
.validLocations(directiveLocation);
List<GraphQLArgument> arguments = directive.getArguments().stream()
.map(arg -> buildDirectiveArgument(arg, directiveDefinition))
.collect(Collectors.toList());
if (directiveDefinition.isPresent()) {
arguments = transferMissingArguments(arguments, directiveDefinition.get());
}
arguments.forEach(builder::argument);
return builder.build();
} } | public class class_name {
public GraphQLDirective buildDirective(Directive directive, Set<GraphQLDirective> directiveDefinitions, DirectiveLocation directiveLocation) {
Optional<GraphQLDirective> directiveDefinition = directiveDefinitions.stream().filter(dd -> dd.getName().equals(directive.getName())).findFirst();
GraphQLDirective.Builder builder = GraphQLDirective.newDirective()
.name(directive.getName())
.description(buildDescription(directive, null))
.validLocations(directiveLocation);
List<GraphQLArgument> arguments = directive.getArguments().stream()
.map(arg -> buildDirectiveArgument(arg, directiveDefinition))
.collect(Collectors.toList());
if (directiveDefinition.isPresent()) {
arguments = transferMissingArguments(arguments, directiveDefinition.get()); // depends on control dependency: [if], data = [none]
}
arguments.forEach(builder::argument);
return builder.build();
} } |
public class class_name {
JSONObject toJson() {
JSONObject ret = new JSONObject();
ret.put("type",type.name());
if (targetConfig != null) {
ret.put("target",targetConfig.toJson());
}
return ret;
} } | public class class_name {
JSONObject toJson() {
JSONObject ret = new JSONObject();
ret.put("type",type.name());
if (targetConfig != null) {
ret.put("target",targetConfig.toJson()); // depends on control dependency: [if], data = [none]
}
return ret;
} } |
public class class_name {
private static Collection<AnnotationValue> getDirectAnnotation(AnnotatedObject m) {
Collection<AnnotationValue> result = getDirectObjectAnnotations().get(m);
if (result != null) {
return result;
}
if (m.getAnnotationDescriptors().isEmpty()) {
return Collections.<AnnotationValue> emptyList();
}
result = TypeQualifierResolver.resolveTypeQualifiers(m.getAnnotations());
if (result.size() == 0) {
result = Collections.<AnnotationValue> emptyList();
}
getDirectObjectAnnotations().put(m, result);
return result;
} } | public class class_name {
private static Collection<AnnotationValue> getDirectAnnotation(AnnotatedObject m) {
Collection<AnnotationValue> result = getDirectObjectAnnotations().get(m);
if (result != null) {
return result; // depends on control dependency: [if], data = [none]
}
if (m.getAnnotationDescriptors().isEmpty()) {
return Collections.<AnnotationValue> emptyList(); // depends on control dependency: [if], data = [none]
}
result = TypeQualifierResolver.resolveTypeQualifiers(m.getAnnotations());
if (result.size() == 0) {
result = Collections.<AnnotationValue> emptyList(); // depends on control dependency: [if], data = [none]
}
getDirectObjectAnnotations().put(m, result);
return result;
} } |
public class class_name {
private void initializeContentView() {
if (null != mContentView) {
mContentView.setClickable(true);
mContentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != mPopupWindow)
mPopupWindow.dismiss();
}
});
}
} } | public class class_name {
private void initializeContentView() {
if (null != mContentView) {
mContentView.setClickable(true); // depends on control dependency: [if], data = [none]
mContentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != mPopupWindow)
mPopupWindow.dismiss();
}
}); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public Tile getAbove() {
int y = tileY - 1;
if (y < 0) {
y = getMaxTileNumber(this.zoomLevel);
}
return new Tile(this.tileX, y, this.zoomLevel, this.tileSize);
} } | public class class_name {
public Tile getAbove() {
int y = tileY - 1;
if (y < 0) {
y = getMaxTileNumber(this.zoomLevel); // depends on control dependency: [if], data = [none]
}
return new Tile(this.tileX, y, this.zoomLevel, this.tileSize);
} } |
public class class_name {
void submit() {
try {
// Special user info attributes may have been set since the time the dialog was instantiated,
// and we don't want to overwrite them, so we read the user again.
m_user = m_context.getCms().readUser(m_user.getId());
m_form.submit(m_user, m_context.getCms(), new Runnable() {
public void run() {
try {
m_context.getCms().writeUser(m_user);
m_context.finish(Collections.<CmsUUID> emptyList());
m_context.updateUserInfo();
} catch (CmsException e) {
//
}
}
});
} catch (CmsException e) {
LOG.error("Unable to read user", e);
}
} } | public class class_name {
void submit() {
try {
// Special user info attributes may have been set since the time the dialog was instantiated,
// and we don't want to overwrite them, so we read the user again.
m_user = m_context.getCms().readUser(m_user.getId()); // depends on control dependency: [try], data = [none]
m_form.submit(m_user, m_context.getCms(), new Runnable() {
public void run() {
try {
m_context.getCms().writeUser(m_user); // depends on control dependency: [try], data = [none]
m_context.finish(Collections.<CmsUUID> emptyList()); // depends on control dependency: [try], data = [none]
m_context.updateUserInfo(); // depends on control dependency: [try], data = [none]
} catch (CmsException e) {
//
} // depends on control dependency: [catch], data = [none]
}
}); // depends on control dependency: [try], data = [none]
} catch (CmsException e) {
LOG.error("Unable to read user", e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public java.util.List<MetricDataResult> getMetricDataResults() {
if (metricDataResults == null) {
metricDataResults = new com.amazonaws.internal.SdkInternalList<MetricDataResult>();
}
return metricDataResults;
} } | public class class_name {
public java.util.List<MetricDataResult> getMetricDataResults() {
if (metricDataResults == null) {
metricDataResults = new com.amazonaws.internal.SdkInternalList<MetricDataResult>(); // depends on control dependency: [if], data = [none]
}
return metricDataResults;
} } |
public class class_name {
public final AntlrDatatypeRuleToken ruleMethodModifier() throws RecognitionException {
AntlrDatatypeRuleToken current = new AntlrDatatypeRuleToken();
Token kw=null;
enterRule();
try {
// InternalSARL.g:9800:2: ( (kw= 'def' | kw= 'override' ) )
// InternalSARL.g:9801:2: (kw= 'def' | kw= 'override' )
{
// InternalSARL.g:9801:2: (kw= 'def' | kw= 'override' )
int alt254=2;
int LA254_0 = input.LA(1);
if ( (LA254_0==90) ) {
alt254=1;
}
else if ( (LA254_0==91) ) {
alt254=2;
}
else {
if (state.backtracking>0) {state.failed=true; return current;}
NoViableAltException nvae =
new NoViableAltException("", 254, 0, input);
throw nvae;
}
switch (alt254) {
case 1 :
// InternalSARL.g:9802:3: kw= 'def'
{
kw=(Token)match(input,90,FOLLOW_2); if (state.failed) return current;
if ( state.backtracking==0 ) {
current.merge(kw);
newLeafNode(kw, grammarAccess.getMethodModifierAccess().getDefKeyword_0());
}
}
break;
case 2 :
// InternalSARL.g:9808:3: kw= 'override'
{
kw=(Token)match(input,91,FOLLOW_2); if (state.failed) return current;
if ( state.backtracking==0 ) {
current.merge(kw);
newLeafNode(kw, grammarAccess.getMethodModifierAccess().getOverrideKeyword_1());
}
}
break;
}
}
if ( state.backtracking==0 ) {
leaveRule();
}
}
catch (RecognitionException re) {
recover(input,re);
appendSkippedTokens();
}
finally {
}
return current;
} } | public class class_name {
public final AntlrDatatypeRuleToken ruleMethodModifier() throws RecognitionException {
AntlrDatatypeRuleToken current = new AntlrDatatypeRuleToken();
Token kw=null;
enterRule();
try {
// InternalSARL.g:9800:2: ( (kw= 'def' | kw= 'override' ) )
// InternalSARL.g:9801:2: (kw= 'def' | kw= 'override' )
{
// InternalSARL.g:9801:2: (kw= 'def' | kw= 'override' )
int alt254=2;
int LA254_0 = input.LA(1);
if ( (LA254_0==90) ) {
alt254=1; // depends on control dependency: [if], data = [none]
}
else if ( (LA254_0==91) ) {
alt254=2; // depends on control dependency: [if], data = [none]
}
else {
if (state.backtracking>0) {state.failed=true; return current;} // depends on control dependency: [if], data = [none] // depends on control dependency: [if], data = [none]
NoViableAltException nvae =
new NoViableAltException("", 254, 0, input);
throw nvae;
}
switch (alt254) {
case 1 :
// InternalSARL.g:9802:3: kw= 'def'
{
kw=(Token)match(input,90,FOLLOW_2); if (state.failed) return current;
if ( state.backtracking==0 ) {
current.merge(kw); // depends on control dependency: [if], data = [none]
newLeafNode(kw, grammarAccess.getMethodModifierAccess().getDefKeyword_0()); // depends on control dependency: [if], data = [none]
}
}
break;
case 2 :
// InternalSARL.g:9808:3: kw= 'override'
{
kw=(Token)match(input,91,FOLLOW_2); if (state.failed) return current;
if ( state.backtracking==0 ) {
current.merge(kw); // depends on control dependency: [if], data = [none]
newLeafNode(kw, grammarAccess.getMethodModifierAccess().getOverrideKeyword_1()); // depends on control dependency: [if], data = [none]
}
}
break;
}
}
if ( state.backtracking==0 ) {
leaveRule(); // depends on control dependency: [if], data = [none]
}
}
catch (RecognitionException re) {
recover(input,re);
appendSkippedTokens();
}
finally {
}
return current;
} } |
public class class_name {
@Override
public int read(char[] cbuf, int start, int len) throws IOException
{
// Let's first ensure there's enough room...
if (start < 0 || (start+len) > cbuf.length) {
reportBounds(cbuf, start, len);
}
// Already EOF?
if (mByteBuffer == null) {
return -1;
}
if (len < 1) {
return 0;
}
len += start;
int outPtr = start;
// Ok, first; do we have a surrogate from last round?
if (mSurrogate != NULL_CHAR) {
cbuf[outPtr++] = mSurrogate;
mSurrogate = NULL_CHAR;
// No need to load more, already got one char
} else {
/* Note: we'll try to avoid blocking as much as possible. As a
* result, we only need to get 4 bytes for a full char.
*/
int left = (mByteBufferEnd - mBytePtr);
if (left < 4) {
if (!loadMore(left)) { // (legal) EOF?
return -1;
}
}
}
byte[] buf = mByteBuffer;
main_loop:
while (outPtr < len) {
int ptr = mBytePtr;
int ch;
if (mBigEndian) {
ch = (buf[ptr] << 24) | ((buf[ptr+1] & 0xFF) << 16)
| ((buf[ptr+2] & 0xFF) << 8) | (buf[ptr+3] & 0xFF);
} else {
ch = (buf[ptr] & 0xFF) | ((buf[ptr+1] & 0xFF) << 8)
| ((buf[ptr+2] & 0xFF) << 16) | (buf[ptr+3] << 24);
}
mBytePtr += 4;
// Does it need to be split to surrogates?
// (also, we can and need to verify illegal chars)
if (ch >= 0x7F) {
if (ch <= 0x9F) {
if (mXml11) { // high-order ctrl char detection...
if (ch != 0x85) {
reportInvalid(ch, outPtr-start, "(can only be included via entity in xml 1.1)");
}
ch = CONVERT_NEL_TO;
}
} else if (ch >= 0xD800) {
// Illegal?
if (ch > XmlConsts.MAX_UNICODE_CHAR) {
reportInvalid(ch, outPtr-start,
"(above "+Integer.toHexString(XmlConsts.MAX_UNICODE_CHAR)+") ");
}
if (ch > 0xFFFF) { // need to split into surrogates?
ch -= 0x10000; // to normalize it starting with 0x0
cbuf[outPtr++] = (char) (0xD800 + (ch >> 10));
// hmmh. can this ever be 0? (not legal, at least?)
ch = (0xDC00 | (ch & 0x03FF));
// Room for second part?
if (outPtr >= len) { // nope
mSurrogate = (char) ch;
break main_loop;
}
} else { // in 16-bit range... just need validity checks
if (ch < 0xE000) {
reportInvalid(ch, outPtr-start, "(a surrogate char) ");
} else if (ch >= 0xFFFE) {
reportInvalid(ch, outPtr-start, "");
}
}
} else if (ch == 0x2028 && mXml11) { // LSEP
ch = CONVERT_LSEP_TO;
}
}
cbuf[outPtr++] = (char) ch;
if (mBytePtr >= mByteBufferEnd) {
break main_loop;
}
}
len = outPtr - start;
mCharCount += len;
return len;
} } | public class class_name {
@Override
public int read(char[] cbuf, int start, int len) throws IOException
{
// Let's first ensure there's enough room...
if (start < 0 || (start+len) > cbuf.length) {
reportBounds(cbuf, start, len);
}
// Already EOF?
if (mByteBuffer == null) {
return -1;
}
if (len < 1) {
return 0;
}
len += start;
int outPtr = start;
// Ok, first; do we have a surrogate from last round?
if (mSurrogate != NULL_CHAR) {
cbuf[outPtr++] = mSurrogate;
mSurrogate = NULL_CHAR;
// No need to load more, already got one char
} else {
/* Note: we'll try to avoid blocking as much as possible. As a
* result, we only need to get 4 bytes for a full char.
*/
int left = (mByteBufferEnd - mBytePtr);
if (left < 4) {
if (!loadMore(left)) { // (legal) EOF?
return -1; // depends on control dependency: [if], data = [none]
}
}
}
byte[] buf = mByteBuffer;
main_loop:
while (outPtr < len) {
int ptr = mBytePtr;
int ch;
if (mBigEndian) {
ch = (buf[ptr] << 24) | ((buf[ptr+1] & 0xFF) << 16)
| ((buf[ptr+2] & 0xFF) << 8) | (buf[ptr+3] & 0xFF);
} else {
ch = (buf[ptr] & 0xFF) | ((buf[ptr+1] & 0xFF) << 8)
| ((buf[ptr+2] & 0xFF) << 16) | (buf[ptr+3] << 24);
}
mBytePtr += 4;
// Does it need to be split to surrogates?
// (also, we can and need to verify illegal chars)
if (ch >= 0x7F) {
if (ch <= 0x9F) {
if (mXml11) { // high-order ctrl char detection...
if (ch != 0x85) {
reportInvalid(ch, outPtr-start, "(can only be included via entity in xml 1.1)");
}
ch = CONVERT_NEL_TO;
}
} else if (ch >= 0xD800) {
// Illegal?
if (ch > XmlConsts.MAX_UNICODE_CHAR) {
reportInvalid(ch, outPtr-start,
"(above "+Integer.toHexString(XmlConsts.MAX_UNICODE_CHAR)+") ");
}
if (ch > 0xFFFF) { // need to split into surrogates?
ch -= 0x10000; // to normalize it starting with 0x0
cbuf[outPtr++] = (char) (0xD800 + (ch >> 10));
// hmmh. can this ever be 0? (not legal, at least?)
ch = (0xDC00 | (ch & 0x03FF));
// Room for second part?
if (outPtr >= len) { // nope
mSurrogate = (char) ch;
break main_loop;
}
} else { // in 16-bit range... just need validity checks
if (ch < 0xE000) {
reportInvalid(ch, outPtr-start, "(a surrogate char) ");
} else if (ch >= 0xFFFE) {
reportInvalid(ch, outPtr-start, "");
}
}
} else if (ch == 0x2028 && mXml11) { // LSEP
ch = CONVERT_LSEP_TO;
}
}
cbuf[outPtr++] = (char) ch;
if (mBytePtr >= mByteBufferEnd) {
break main_loop;
}
}
len = outPtr - start;
mCharCount += len;
return len;
} } |
public class class_name {
@Override
public void visit(NodeVisitor v) {
if (v.visit(this)) {
if (expression != null) {
expression.visit(v);
}
if (statements != null) {
for (AstNode s : statements) {
s.visit(v);
}
}
}
} } | public class class_name {
@Override
public void visit(NodeVisitor v) {
if (v.visit(this)) {
if (expression != null) {
expression.visit(v); // depends on control dependency: [if], data = [none]
}
if (statements != null) {
for (AstNode s : statements) {
s.visit(v); // depends on control dependency: [for], data = [s]
}
}
}
} } |
public class class_name {
void onConnect() throws InterruptedException, IOException
{
if (state.get() != NodeState.Fresh) {
if (previousZKSessionStillActive()) {
LOG.info("ZooKeeper session re-established before timeout.");
return;
}
LOG.warn("Rejoined after session timeout. Forcing shutdown and clean startup.");
ensureCleanStartup();
}
LOG.info("Connected to Zookeeper (ID: {}).", myNodeID);
ZKUtils.ensureOrdasityPaths(zk, name, config.workUnitName, config.workUnitShortName);
joinCluster();
listener.onJoin(zk);
if (watchesRegistered.compareAndSet(false, true)) {
registerWatchers();
}
initialized.set(true);
initializedLatch.countDown();
setState(NodeState.Started);
claimer.requestClaim();
verifyIntegrity();
balancingPolicy.onConnect();
if (config.enableAutoRebalance) {
scheduleRebalancing();
}
} } | public class class_name {
void onConnect() throws InterruptedException, IOException
{
if (state.get() != NodeState.Fresh) {
if (previousZKSessionStillActive()) {
LOG.info("ZooKeeper session re-established before timeout."); // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
LOG.warn("Rejoined after session timeout. Forcing shutdown and clean startup.");
ensureCleanStartup();
}
LOG.info("Connected to Zookeeper (ID: {}).", myNodeID);
ZKUtils.ensureOrdasityPaths(zk, name, config.workUnitName, config.workUnitShortName);
joinCluster();
listener.onJoin(zk);
if (watchesRegistered.compareAndSet(false, true)) {
registerWatchers();
}
initialized.set(true);
initializedLatch.countDown();
setState(NodeState.Started);
claimer.requestClaim();
verifyIntegrity();
balancingPolicy.onConnect();
if (config.enableAutoRebalance) {
scheduleRebalancing();
}
} } |
public class class_name {
public void put(String key, Object value) {
// acquire write lock
writeLock.lock();
try {
if(METADATA_KEYS.contains(key)) {
VectorClock version = (VectorClock) get(key, null).get(0).getVersion();
put(key,
new Versioned<Object>(value, version.incremented(getNodeId(),
System.currentTimeMillis())));
} else {
throw new VoldemortException("Unhandled Key:" + key + " for MetadataStore put()");
}
} finally {
writeLock.unlock();
}
} } | public class class_name {
public void put(String key, Object value) {
// acquire write lock
writeLock.lock();
try {
if(METADATA_KEYS.contains(key)) {
VectorClock version = (VectorClock) get(key, null).get(0).getVersion();
put(key,
new Versioned<Object>(value, version.incremented(getNodeId(),
System.currentTimeMillis()))); // depends on control dependency: [if], data = [none]
} else {
throw new VoldemortException("Unhandled Key:" + key + " for MetadataStore put()");
}
} finally {
writeLock.unlock();
}
} } |
public class class_name {
public synchronized EvernoteClientFactory getEvernoteClientFactory() {
if (mFactoryThreadLocal == null) {
mFactoryThreadLocal = new ThreadLocal<>();
}
if (mEvernoteClientFactoryBuilder == null) {
mEvernoteClientFactoryBuilder = new EvernoteClientFactory.Builder(this);
}
EvernoteClientFactory factory = mFactoryThreadLocal.get();
if (factory == null) {
factory = mEvernoteClientFactoryBuilder.build();
mFactoryThreadLocal.set(factory);
}
return factory;
} } | public class class_name {
public synchronized EvernoteClientFactory getEvernoteClientFactory() {
if (mFactoryThreadLocal == null) {
mFactoryThreadLocal = new ThreadLocal<>(); // depends on control dependency: [if], data = [none]
}
if (mEvernoteClientFactoryBuilder == null) {
mEvernoteClientFactoryBuilder = new EvernoteClientFactory.Builder(this); // depends on control dependency: [if], data = [none]
}
EvernoteClientFactory factory = mFactoryThreadLocal.get();
if (factory == null) {
factory = mEvernoteClientFactoryBuilder.build(); // depends on control dependency: [if], data = [none]
mFactoryThreadLocal.set(factory); // depends on control dependency: [if], data = [(factory]
}
return factory;
} } |
public class class_name {
@Override
public boolean accept(final ConnectionSupplier supplier) {
if (supplier == null) {
return false;
}
String[] parts = supplier.getDatabaseName().split("-", 2);
String databaseName = parts[0];
if (!databaseName.startsWith(getDatabaseName())) {
return false;
}
String databaseVersion = parts[1];
try {
int majorVersion = Integer.parseInt(databaseVersion.substring(0, databaseVersion.indexOf(".")));
return isTargetVersion(majorVersion);
} catch (NumberFormatException e) {
return false;
}
} } | public class class_name {
@Override
public boolean accept(final ConnectionSupplier supplier) {
if (supplier == null) {
return false; // depends on control dependency: [if], data = [none]
}
String[] parts = supplier.getDatabaseName().split("-", 2);
String databaseName = parts[0];
if (!databaseName.startsWith(getDatabaseName())) {
return false; // depends on control dependency: [if], data = [none]
}
String databaseVersion = parts[1];
try {
int majorVersion = Integer.parseInt(databaseVersion.substring(0, databaseVersion.indexOf(".")));
return isTargetVersion(majorVersion); // depends on control dependency: [try], data = [none]
} catch (NumberFormatException e) {
return false;
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private static ServiceAccount getInstanceByVcapServices(String serviceName, String serviceInstanceName) {
Map<String, String> env = System.getenv();
String vcapServices = env.get("VCAP_SERVICES");
if (vcapServices == null) {
return null;
}
try {
JsonObject obj = new JsonParser().parse(vcapServices).getAsJsonObject();
// When service name is specified,
// this method returns only a matching entry
if (serviceName != null) {
JsonElement elem = obj.get(serviceName);
if (elem != null && elem.isJsonArray()) {
return parseToServiceAccount(elem.getAsJsonArray(), serviceInstanceName);
}
}
// Otherwise, lookup a valid entry with a name matching
// the default pattern GP_SERVICE_NAME_PATTERN.
for (Entry<String, JsonElement> entry : obj.entrySet()) {
String name = entry.getKey();
JsonElement elem = entry.getValue();
if (elem.isJsonArray() && GP_SERVICE_NAME_PATTERN.matcher(name).matches()) {
ServiceAccount account = parseToServiceAccount(elem.getAsJsonArray(), serviceInstanceName);
if (account != null) {
return account;
}
}
}
} catch (JsonParseException e) {
// Fall through - will return null
}
return null;
} } | public class class_name {
private static ServiceAccount getInstanceByVcapServices(String serviceName, String serviceInstanceName) {
Map<String, String> env = System.getenv();
String vcapServices = env.get("VCAP_SERVICES");
if (vcapServices == null) {
return null; // depends on control dependency: [if], data = [none]
}
try {
JsonObject obj = new JsonParser().parse(vcapServices).getAsJsonObject();
// When service name is specified,
// this method returns only a matching entry
if (serviceName != null) {
JsonElement elem = obj.get(serviceName);
if (elem != null && elem.isJsonArray()) {
return parseToServiceAccount(elem.getAsJsonArray(), serviceInstanceName); // depends on control dependency: [if], data = [(elem]
}
}
// Otherwise, lookup a valid entry with a name matching
// the default pattern GP_SERVICE_NAME_PATTERN.
for (Entry<String, JsonElement> entry : obj.entrySet()) {
String name = entry.getKey();
JsonElement elem = entry.getValue();
if (elem.isJsonArray() && GP_SERVICE_NAME_PATTERN.matcher(name).matches()) {
ServiceAccount account = parseToServiceAccount(elem.getAsJsonArray(), serviceInstanceName);
if (account != null) {
return account; // depends on control dependency: [if], data = [none]
}
}
}
} catch (JsonParseException e) {
// Fall through - will return null
} // depends on control dependency: [catch], data = [none]
return null;
} } |
public class class_name {
public static void main(String[] args) {
BasicConfigurator.configure(new ConsoleAppender(
new PatternLayout("%d [%-25t] %-5p: %m%n")));
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option help = parser.addBooleanOption('h', "help");
CmdLineParser.Option output = parser.addStringOption('o', "output");
CmdLineParser.Option iface = parser.addStringOption('i', "iface");
CmdLineParser.Option seedTime = parser.addIntegerOption('s', "seed");
CmdLineParser.Option maxUpload = parser.addDoubleOption('u', "max-upload");
CmdLineParser.Option maxDownload = parser.addDoubleOption('d', "max-download");
try {
parser.parse(args);
} catch (CmdLineParser.OptionException oe) {
System.err.println(oe.getMessage());
usage(System.err);
System.exit(1);
}
// Display help and exit if requested
if (Boolean.TRUE.equals((Boolean) parser.getOptionValue(help))) {
usage(System.out);
System.exit(0);
}
String outputValue = (String) parser.getOptionValue(output,
DEFAULT_OUTPUT_DIRECTORY);
String ifaceValue = (String) parser.getOptionValue(iface);
int seedTimeValue = (Integer) parser.getOptionValue(seedTime, -1);
String[] otherArgs = parser.getRemainingArgs();
if (otherArgs.length != 1) {
usage(System.err);
System.exit(1);
}
SimpleClient client = new SimpleClient();
try {
Inet4Address iPv4Address = getIPv4Address(ifaceValue);
File torrentFile = new File(otherArgs[0]);
File outputFile = new File(outputValue);
client.downloadTorrent(
torrentFile.getAbsolutePath(),
outputFile.getAbsolutePath(),
iPv4Address);
if (seedTimeValue > 0) {
Thread.sleep(seedTimeValue * 1000);
}
} catch (Exception e) {
logger.error("Fatal error: {}", e.getMessage(), e);
System.exit(2);
} finally {
client.stop();
}
} } | public class class_name {
public static void main(String[] args) {
BasicConfigurator.configure(new ConsoleAppender(
new PatternLayout("%d [%-25t] %-5p: %m%n")));
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option help = parser.addBooleanOption('h', "help");
CmdLineParser.Option output = parser.addStringOption('o', "output");
CmdLineParser.Option iface = parser.addStringOption('i', "iface");
CmdLineParser.Option seedTime = parser.addIntegerOption('s', "seed");
CmdLineParser.Option maxUpload = parser.addDoubleOption('u', "max-upload");
CmdLineParser.Option maxDownload = parser.addDoubleOption('d', "max-download");
try {
parser.parse(args); // depends on control dependency: [try], data = [none]
} catch (CmdLineParser.OptionException oe) {
System.err.println(oe.getMessage());
usage(System.err);
System.exit(1);
} // depends on control dependency: [catch], data = [none]
// Display help and exit if requested
if (Boolean.TRUE.equals((Boolean) parser.getOptionValue(help))) {
usage(System.out); // depends on control dependency: [if], data = [none]
System.exit(0); // depends on control dependency: [if], data = [none]
}
String outputValue = (String) parser.getOptionValue(output,
DEFAULT_OUTPUT_DIRECTORY);
String ifaceValue = (String) parser.getOptionValue(iface);
int seedTimeValue = (Integer) parser.getOptionValue(seedTime, -1);
String[] otherArgs = parser.getRemainingArgs();
if (otherArgs.length != 1) {
usage(System.err); // depends on control dependency: [if], data = [none]
System.exit(1); // depends on control dependency: [if], data = [1)]
}
SimpleClient client = new SimpleClient();
try {
Inet4Address iPv4Address = getIPv4Address(ifaceValue);
File torrentFile = new File(otherArgs[0]);
File outputFile = new File(outputValue);
client.downloadTorrent(
torrentFile.getAbsolutePath(),
outputFile.getAbsolutePath(),
iPv4Address);
if (seedTimeValue > 0) {
Thread.sleep(seedTimeValue * 1000); // depends on control dependency: [if], data = [(seedTimeValue]
}
} catch (Exception e) {
logger.error("Fatal error: {}", e.getMessage(), e);
System.exit(2);
} finally {
client.stop();
}
} } |
public class class_name {
public Observable<ServiceResponse<KeyPhraseBatchResult>> keyPhrasesWithServiceResponseAsync(List<MultiLanguageInput> documents) {
if (this.client.azureRegion() == null) {
throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null.");
}
Validator.validate(documents);
MultiLanguageBatchInput input = new MultiLanguageBatchInput();
input.withDocuments(documents);
String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion());
return service.keyPhrases(this.client.acceptLanguage(), input, parameterizedHost, this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyPhraseBatchResult>>>() {
@Override
public Observable<ServiceResponse<KeyPhraseBatchResult>> call(Response<ResponseBody> response) {
try {
ServiceResponse<KeyPhraseBatchResult> clientResponse = keyPhrasesDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
} } | public class class_name {
public Observable<ServiceResponse<KeyPhraseBatchResult>> keyPhrasesWithServiceResponseAsync(List<MultiLanguageInput> documents) {
if (this.client.azureRegion() == null) {
throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null.");
}
Validator.validate(documents);
MultiLanguageBatchInput input = new MultiLanguageBatchInput();
input.withDocuments(documents);
String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion());
return service.keyPhrases(this.client.acceptLanguage(), input, parameterizedHost, this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyPhraseBatchResult>>>() {
@Override
public Observable<ServiceResponse<KeyPhraseBatchResult>> call(Response<ResponseBody> response) {
try {
ServiceResponse<KeyPhraseBatchResult> clientResponse = keyPhrasesDelegate(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 {
protected void doFlush() {
long v;
synchronized (unFlushed) {
v = unFlushed.getCount();
}
for (Counter counter : counterMap.values()) {
counter.inc(v);
}
if (MetricUtils.metricAccurateCal) {
for (AsmMetric assocMetric : assocMetrics) {
assocMetric.updateDirectly(v);
}
}
this.unFlushed.dec(v);
} } | public class class_name {
protected void doFlush() {
long v;
synchronized (unFlushed) {
v = unFlushed.getCount();
}
for (Counter counter : counterMap.values()) {
counter.inc(v); // depends on control dependency: [for], data = [counter]
}
if (MetricUtils.metricAccurateCal) {
for (AsmMetric assocMetric : assocMetrics) {
assocMetric.updateDirectly(v); // depends on control dependency: [for], data = [assocMetric]
}
}
this.unFlushed.dec(v);
} } |
public class class_name {
public Map<String, List<String>> parse(final InputStream mapping) {
final Properties mappingProperties = new Properties();
try {
mappingProperties.load(mapping);
final Map<String, List<String>> serializedContent = new HashMap<>();
final Set<String> kinds = mappingProperties.stringPropertyNames();
for (String kind : kinds) {
final String filenames = mappingProperties.getProperty(kind);
final String[] filenameTypes = filenames.split(",");
final List<String> scannedFiletypes = new ArrayList<>();
for (final String filenameType : filenameTypes) {
scannedFiletypes.add(filenameType.trim());
}
serializedContent.put(kind, scannedFiletypes);
}
return serializedContent;
} catch (IOException e) {
throw new IllegalStateException(e);
}
} } | public class class_name {
public Map<String, List<String>> parse(final InputStream mapping) {
final Properties mappingProperties = new Properties();
try {
mappingProperties.load(mapping); // depends on control dependency: [try], data = [none]
final Map<String, List<String>> serializedContent = new HashMap<>();
final Set<String> kinds = mappingProperties.stringPropertyNames();
for (String kind : kinds) {
final String filenames = mappingProperties.getProperty(kind);
final String[] filenameTypes = filenames.split(",");
final List<String> scannedFiletypes = new ArrayList<>();
for (final String filenameType : filenameTypes) {
scannedFiletypes.add(filenameType.trim()); // depends on control dependency: [for], data = [filenameType]
}
serializedContent.put(kind, scannedFiletypes); // depends on control dependency: [for], data = [kind]
}
return serializedContent; // depends on control dependency: [try], data = [none]
} catch (IOException e) {
throw new IllegalStateException(e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public DateTimeFormatter withChronology(Chronology chrono) {
if (Jdk8Methods.equals(this.chrono, chrono)) {
return this;
}
return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone);
} } | public class class_name {
public DateTimeFormatter withChronology(Chronology chrono) {
if (Jdk8Methods.equals(this.chrono, chrono)) {
return this; // depends on control dependency: [if], data = [none]
}
return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone);
} } |
public class class_name {
public static double[] plus(final double[] v1, final double[] v2) {
assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
final double[] result = new double[v1.length];
for(int i = 0; i < result.length; i++) {
result[i] = v1[i] + v2[i];
}
return result;
} } | public class class_name {
public static double[] plus(final double[] v1, final double[] v2) {
assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
final double[] result = new double[v1.length];
for(int i = 0; i < result.length; i++) {
result[i] = v1[i] + v2[i]; // depends on control dependency: [for], data = [i]
}
return result;
} } |
public class class_name {
private void obtainStyledAttributes(@Nullable final AttributeSet attributeSet) {
TypedArray typedArray =
getContext().obtainStyledAttributes(attributeSet, R.styleable.FloatingActionButton);
try {
obtainSize(typedArray);
obtainColor(typedArray);
obtainActivatedColor(typedArray);
obtainPressedColor(typedArray);
obtainDisabledColor(typedArray);
obtainIcon(typedArray);
obtainVisibilityAnimationDuration(typedArray);
} finally {
typedArray.recycle();
}
} } | public class class_name {
private void obtainStyledAttributes(@Nullable final AttributeSet attributeSet) {
TypedArray typedArray =
getContext().obtainStyledAttributes(attributeSet, R.styleable.FloatingActionButton);
try {
obtainSize(typedArray); // depends on control dependency: [try], data = [none]
obtainColor(typedArray); // depends on control dependency: [try], data = [none]
obtainActivatedColor(typedArray); // depends on control dependency: [try], data = [none]
obtainPressedColor(typedArray); // depends on control dependency: [try], data = [none]
obtainDisabledColor(typedArray); // depends on control dependency: [try], data = [none]
obtainIcon(typedArray); // depends on control dependency: [try], data = [none]
obtainVisibilityAnimationDuration(typedArray); // depends on control dependency: [try], data = [none]
} finally {
typedArray.recycle();
}
} } |
public class class_name {
public OriginateResult[] dial(final NewChannelListener listener, final EndPoint localHandset,
final EndPoint targetEndPoint, final String dialContext, final CallerID callerID, final boolean hideCallerId,
Map<String, String> channelVarsToSet) throws PBXException
{
final PBX pbx = PBXFactory.getActivePBX();
try (final OriginateToExtension originate = new OriginateToExtension(listener))
{
this.startListener();
// First bring the operator's handset up and connect it to the
// 'njr-dial' extension where they can
// wait whilst we complete the second leg
final OriginateResult trcResult = originate.originate(localHandset, pbx.getExtensionAgi(), true,
((AsteriskPBX) pbx).getManagementContext(), callerID, null, hideCallerId, channelVarsToSet);
this.result[0] = trcResult;
if (trcResult.isSuccess() == true)
{
try
{
if (targetEndPoint instanceof HoldAtAgi)
{
if (trcResult.getChannel().waitForChannelToReachAgi(30, TimeUnit.SECONDS))
{
// call is now in agi
System.out.println("Call is in agi");
}
else
{
// call never reached agi
System.out.println("Call never reached agi");
}
}
else
{
// The call is now up, so connect it to
// the
// destination.
this._latch = new CountDownLatch(1);
trcResult.getChannel().setCurrentActivityAction(
new AgiChannelActivityDial(targetEndPoint.getFullyQualifiedName()));
this._latch.await(30, TimeUnit.SECONDS);
}
}
catch (final InterruptedException e)
{
// noop
}
}
return this.result;
}
finally
{
this.close();
}
} } | public class class_name {
public OriginateResult[] dial(final NewChannelListener listener, final EndPoint localHandset,
final EndPoint targetEndPoint, final String dialContext, final CallerID callerID, final boolean hideCallerId,
Map<String, String> channelVarsToSet) throws PBXException
{
final PBX pbx = PBXFactory.getActivePBX();
try (final OriginateToExtension originate = new OriginateToExtension(listener))
{
this.startListener();
// First bring the operator's handset up and connect it to the
// 'njr-dial' extension where they can
// wait whilst we complete the second leg
final OriginateResult trcResult = originate.originate(localHandset, pbx.getExtensionAgi(), true,
((AsteriskPBX) pbx).getManagementContext(), callerID, null, hideCallerId, channelVarsToSet);
this.result[0] = trcResult;
if (trcResult.isSuccess() == true)
{
try
{
if (targetEndPoint instanceof HoldAtAgi)
{
if (trcResult.getChannel().waitForChannelToReachAgi(30, TimeUnit.SECONDS))
{
// call is now in agi
System.out.println("Call is in agi");
// depends on control dependency: [if], data = [none]
}
else
{
// call never reached agi
System.out.println("Call never reached agi");
// depends on control dependency: [if], data = [none]
}
}
else
{
// The call is now up, so connect it to
// the
// destination.
this._latch = new CountDownLatch(1);
// depends on control dependency: [if], data = [none]
trcResult.getChannel().setCurrentActivityAction(
new AgiChannelActivityDial(targetEndPoint.getFullyQualifiedName()));
// depends on control dependency: [if], data = [none]
this._latch.await(30, TimeUnit.SECONDS);
// depends on control dependency: [if], data = [none]
}
}
catch (final InterruptedException e)
{
// noop
}
// depends on control dependency: [catch], data = [none]
}
return this.result;
}
finally
{
this.close();
}
} } |
public class class_name {
public FP64 extend(byte[] bytes, int start, int len) {
int end = start + len;
for (int i = start; i < end; i++) {
extend(bytes[i]);
}
return this;
} } | public class class_name {
public FP64 extend(byte[] bytes, int start, int len) {
int end = start + len;
for (int i = start; i < end; i++) {
extend(bytes[i]); // depends on control dependency: [for], data = [i]
}
return this;
} } |
public class class_name {
public AttachInstancesToLoadBalancerRequest withInstanceNames(String... instanceNames) {
if (this.instanceNames == null) {
setInstanceNames(new java.util.ArrayList<String>(instanceNames.length));
}
for (String ele : instanceNames) {
this.instanceNames.add(ele);
}
return this;
} } | public class class_name {
public AttachInstancesToLoadBalancerRequest withInstanceNames(String... instanceNames) {
if (this.instanceNames == null) {
setInstanceNames(new java.util.ArrayList<String>(instanceNames.length)); // depends on control dependency: [if], data = [none]
}
for (String ele : instanceNames) {
this.instanceNames.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public byte[] getPacketArray(boolean reUsable) throws IOException {
//***************************************************
//Read 4 byte header
//***************************************************
int remaining = 4;
int off = 0;
do {
int count = inputStream.read(header, off, remaining);
if (count < 0) {
throw new EOFException("unexpected end of stream, read " + off
+ " bytes from 4 (socket was closed by server)");
}
remaining -= count;
off += count;
} while (remaining > 0);
lastPacketLength = (header[0] & 0xff) + ((header[1] & 0xff) << 8) + ((header[2] & 0xff) << 16);
packetSeq = header[3];
//prepare array
byte[] rawBytes;
if (reUsable && lastPacketLength < REUSABLE_BUFFER_LENGTH) {
rawBytes = reusableArray;
} else {
rawBytes = new byte[lastPacketLength];
}
//***************************************************
//Read content
//***************************************************
remaining = lastPacketLength;
off = 0;
do {
int count = inputStream.read(rawBytes, off, remaining);
if (count < 0) {
throw new EOFException(
"unexpected end of stream, read " + (lastPacketLength - remaining) + " bytes from "
+ lastPacketLength
+ " (socket was closed by server)");
}
remaining -= count;
off += count;
} while (remaining > 0);
if (traceCache != null) {
traceCache.put(new TraceObject(false, NOT_COMPRESSED, Arrays.copyOfRange(header, 0, 4),
Arrays.copyOfRange(rawBytes, 0, off > 1000 ? 1000 : off)));
}
if (logger.isTraceEnabled()) {
logger.trace("read: {}{}",
serverThreadLog,
Utils.hexdump(maxQuerySizeToLog - 4, 0, lastPacketLength, header, rawBytes));
}
//***************************************************
//In case content length is big, content will be separate in many 16Mb packets
//***************************************************
if (lastPacketLength == MAX_PACKET_SIZE) {
int packetLength;
do {
remaining = 4;
off = 0;
do {
int count = inputStream.read(header, off, remaining);
if (count < 0) {
throw new EOFException("unexpected end of stream, read " + off + " bytes from 4");
}
remaining -= count;
off += count;
} while (remaining > 0);
packetLength = (header[0] & 0xff) + ((header[1] & 0xff) << 8) + ((header[2] & 0xff) << 16);
packetSeq = header[3];
int currentBufferLength = rawBytes.length;
byte[] newRawBytes = new byte[currentBufferLength + packetLength];
System.arraycopy(rawBytes, 0, newRawBytes, 0, currentBufferLength);
rawBytes = newRawBytes;
//***************************************************
//Read content
//***************************************************
remaining = packetLength;
off = currentBufferLength;
do {
int count = inputStream.read(rawBytes, off, remaining);
if (count < 0) {
throw new EOFException(
"unexpected end of stream, read " + (packetLength - remaining) + " bytes from "
+ packetLength);
}
remaining -= count;
off += count;
} while (remaining > 0);
if (traceCache != null) {
traceCache.put(new TraceObject(false, NOT_COMPRESSED, Arrays.copyOfRange(header, 0, 4),
Arrays.copyOfRange(rawBytes, 0, off > 1000 ? 1000 : off)));
}
if (logger.isTraceEnabled()) {
logger.trace("read: {}{}",
serverThreadLog,
Utils.hexdump(maxQuerySizeToLog - 4, currentBufferLength, packetLength, header,
rawBytes));
}
lastPacketLength += packetLength;
} while (packetLength == MAX_PACKET_SIZE);
}
return rawBytes;
} } | public class class_name {
public byte[] getPacketArray(boolean reUsable) throws IOException {
//***************************************************
//Read 4 byte header
//***************************************************
int remaining = 4;
int off = 0;
do {
int count = inputStream.read(header, off, remaining);
if (count < 0) {
throw new EOFException("unexpected end of stream, read " + off
+ " bytes from 4 (socket was closed by server)");
}
remaining -= count;
off += count; // depends on control dependency: [if], data = [none]
} while (remaining > 0);
lastPacketLength = (header[0] & 0xff) + ((header[1] & 0xff) << 8) + ((header[2] & 0xff) << 16);
packetSeq = header[3];
//prepare array
byte[] rawBytes;
if (reUsable && lastPacketLength < REUSABLE_BUFFER_LENGTH) {
rawBytes = reusableArray; // depends on control dependency: [if], data = [none]
} else {
rawBytes = new byte[lastPacketLength]; // depends on control dependency: [if], data = [none]
}
//***************************************************
//Read content
//***************************************************
remaining = lastPacketLength;
off = 0;
do {
int count = inputStream.read(rawBytes, off, remaining);
if (count < 0) {
throw new EOFException(
"unexpected end of stream, read " + (lastPacketLength - remaining) + " bytes from "
+ lastPacketLength
+ " (socket was closed by server)");
}
remaining -= count;
off += count; // depends on control dependency: [if], data = [none]
} while (remaining > 0);
if (traceCache != null) {
traceCache.put(new TraceObject(false, NOT_COMPRESSED, Arrays.copyOfRange(header, 0, 4),
Arrays.copyOfRange(rawBytes, 0, off > 1000 ? 1000 : off))); // depends on control dependency: [if], data = [none]
}
if (logger.isTraceEnabled()) {
logger.trace("read: {}{}",
serverThreadLog,
Utils.hexdump(maxQuerySizeToLog - 4, 0, lastPacketLength, header, rawBytes)); // depends on control dependency: [if], data = [none]
}
//***************************************************
//In case content length is big, content will be separate in many 16Mb packets
//***************************************************
if (lastPacketLength == MAX_PACKET_SIZE) {
int packetLength;
do {
remaining = 4;
off = 0;
do {
int count = inputStream.read(header, off, remaining);
if (count < 0) {
throw new EOFException("unexpected end of stream, read " + off + " bytes from 4");
}
remaining -= count;
off += count;
} while (remaining > 0);
packetLength = (header[0] & 0xff) + ((header[1] & 0xff) << 8) + ((header[2] & 0xff) << 16);
packetSeq = header[3];
int currentBufferLength = rawBytes.length;
byte[] newRawBytes = new byte[currentBufferLength + packetLength];
System.arraycopy(rawBytes, 0, newRawBytes, 0, currentBufferLength);
rawBytes = newRawBytes;
//***************************************************
//Read content
//***************************************************
remaining = packetLength;
off = currentBufferLength;
do {
int count = inputStream.read(rawBytes, off, remaining);
if (count < 0) {
throw new EOFException(
"unexpected end of stream, read " + (packetLength - remaining) + " bytes from "
+ packetLength);
}
remaining -= count;
off += count;
} while (remaining > 0);
if (traceCache != null) {
traceCache.put(new TraceObject(false, NOT_COMPRESSED, Arrays.copyOfRange(header, 0, 4),
Arrays.copyOfRange(rawBytes, 0, off > 1000 ? 1000 : off))); // depends on control dependency: [if], data = [none]
}
if (logger.isTraceEnabled()) {
logger.trace("read: {}{}",
serverThreadLog,
Utils.hexdump(maxQuerySizeToLog - 4, currentBufferLength, packetLength, header,
rawBytes)); // depends on control dependency: [if], data = [none]
}
lastPacketLength += packetLength;
} while (packetLength == MAX_PACKET_SIZE);
}
return rawBytes;
} } |
public class class_name {
public TextMatchBinding setText(
final Collection<String> text
)
{
if (text == null || text.size() == 0) {
clearText();
return this;
}
synchronized (text) {
for (String pattern : text) {
if (pattern == null || pattern.length() == 0) {
throw new IllegalArgumentException( "null element" );
}
}
clearText();
for (String pattern : text) {
addText( pattern );
}
}
return this;
} } | public class class_name {
public TextMatchBinding setText(
final Collection<String> text
)
{
if (text == null || text.size() == 0) {
clearText(); // depends on control dependency: [if], data = [none]
return this; // depends on control dependency: [if], data = [none]
}
synchronized (text) {
for (String pattern : text) {
if (pattern == null || pattern.length() == 0) {
throw new IllegalArgumentException( "null element" );
}
}
clearText();
for (String pattern : text) {
addText( pattern ); // depends on control dependency: [for], data = [pattern]
}
}
return this;
} } |
public class class_name {
private void addDateRange(ProjectCalendarHours hours, Date start, Date end)
{
if (start != null && end != null)
{
Calendar cal = DateHelper.popCalendar(end);
// If the time ends on midnight, the date should be the next day. Otherwise problems occur.
if (cal.get(Calendar.HOUR_OF_DAY) == 0 && cal.get(Calendar.MINUTE) == 0 && cal.get(Calendar.SECOND) == 0 && cal.get(Calendar.MILLISECOND) == 0)
{
cal.add(Calendar.DAY_OF_YEAR, 1);
}
end = cal.getTime();
DateHelper.pushCalendar(cal);
hours.addRange(new DateRange(start, end));
}
} } | public class class_name {
private void addDateRange(ProjectCalendarHours hours, Date start, Date end)
{
if (start != null && end != null)
{
Calendar cal = DateHelper.popCalendar(end);
// If the time ends on midnight, the date should be the next day. Otherwise problems occur.
if (cal.get(Calendar.HOUR_OF_DAY) == 0 && cal.get(Calendar.MINUTE) == 0 && cal.get(Calendar.SECOND) == 0 && cal.get(Calendar.MILLISECOND) == 0)
{
cal.add(Calendar.DAY_OF_YEAR, 1); // depends on control dependency: [if], data = [none]
}
end = cal.getTime(); // depends on control dependency: [if], data = [none]
DateHelper.pushCalendar(cal); // depends on control dependency: [if], data = [none]
hours.addRange(new DateRange(start, end)); // depends on control dependency: [if], data = [(start]
}
} } |
public class class_name {
public static SpanContextInformation forSpan(Span span) {
if (span != null) {
if (!spanContextMap.containsKey(span)) {
spanContextMap.putIfAbsent(span, new SpanContextInformation());
}
return spanContextMap.get(span);
}
return null;
} } | public class class_name {
public static SpanContextInformation forSpan(Span span) {
if (span != null) {
if (!spanContextMap.containsKey(span)) {
spanContextMap.putIfAbsent(span, new SpanContextInformation()); // depends on control dependency: [if], data = [none]
}
return spanContextMap.get(span); // depends on control dependency: [if], data = [(span]
}
return null;
} } |
public class class_name {
public static ParameterizedType toParameterizedType(Type type) {
if (type instanceof ParameterizedType) {
return (ParameterizedType) type;
} else if (type instanceof Class) {
return toParameterizedType(((Class<?>) type).getGenericSuperclass());
}
return null;
} } | public class class_name {
public static ParameterizedType toParameterizedType(Type type) {
if (type instanceof ParameterizedType) {
return (ParameterizedType) type;
// depends on control dependency: [if], data = [none]
} else if (type instanceof Class) {
return toParameterizedType(((Class<?>) type).getGenericSuperclass());
// depends on control dependency: [if], data = [none]
}
return null;
} } |
public class class_name {
public static Buffer readResourceToBuffer(@NotNull Class<?> clazz, @NotNull String resource) {
try {
Buffer buffer = Buffer.buffer(0);
try (InputStream in = clazz.getResourceAsStream(resource)) {
int read;
byte[] data = new byte[4096];
while ((read = in.read(data, 0, data.length)) != -1) {
if (read == data.length) {
buffer.appendBytes(data);
} else {
byte[] slice = new byte[read];
System.arraycopy(data, 0, slice, 0, slice.length);
buffer.appendBytes(slice);
}
}
}
return buffer;
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
} } | public class class_name {
public static Buffer readResourceToBuffer(@NotNull Class<?> clazz, @NotNull String resource) {
try {
Buffer buffer = Buffer.buffer(0);
try (InputStream in = clazz.getResourceAsStream(resource)) {
int read;
byte[] data = new byte[4096];
while ((read = in.read(data, 0, data.length)) != -1) {
if (read == data.length) {
buffer.appendBytes(data); // depends on control dependency: [if], data = [none]
} else {
byte[] slice = new byte[read];
System.arraycopy(data, 0, slice, 0, slice.length); // depends on control dependency: [if], data = [none]
buffer.appendBytes(slice); // depends on control dependency: [if], data = [none]
}
}
}
return buffer;
} catch (IOException ioe) {
throw new RuntimeException(ioe);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
protected void applyCachePolicy() {
// Run through all the active clients and gather status.
CacheStatus currentStatus = collectStatus();
if (currentStatus == null || currentStatus.getSize() == 0) {
// This indicates we have no clients or those clients have no data.
this.cacheSize.set(0);
return;
}
// Increment current generation (if needed).
boolean currentChanged = adjustCurrentGeneration(currentStatus);
// Increment oldest generation (if needed and if possible).
boolean oldestChanged = adjustOldestGeneration(currentStatus);
if (!currentChanged && !oldestChanged) {
// Nothing changed, nothing to do.
return;
}
// Notify clients that something changed (if any of the above got changed). Run in a loop, until either we can't
// adjust the oldest anymore or we are unable to trigger any changes to the clients.
long sizeReduction;
do {
sizeReduction = updateClients();
if (sizeReduction > 0) {
currentStatus = currentStatus.withUpdatedSize(-sizeReduction);
logCurrentStatus(currentStatus);
oldestChanged = adjustOldestGeneration(currentStatus);
}
} while (sizeReduction > 0 && oldestChanged);
this.cacheSize.set(currentStatus.getSize());
this.metrics.report(currentStatus.getSize(), currentStatus.getNewestGeneration() - currentStatus.getOldestGeneration());
} } | public class class_name {
protected void applyCachePolicy() {
// Run through all the active clients and gather status.
CacheStatus currentStatus = collectStatus();
if (currentStatus == null || currentStatus.getSize() == 0) {
// This indicates we have no clients or those clients have no data.
this.cacheSize.set(0); // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
// Increment current generation (if needed).
boolean currentChanged = adjustCurrentGeneration(currentStatus);
// Increment oldest generation (if needed and if possible).
boolean oldestChanged = adjustOldestGeneration(currentStatus);
if (!currentChanged && !oldestChanged) {
// Nothing changed, nothing to do.
return; // depends on control dependency: [if], data = [none]
}
// Notify clients that something changed (if any of the above got changed). Run in a loop, until either we can't
// adjust the oldest anymore or we are unable to trigger any changes to the clients.
long sizeReduction;
do {
sizeReduction = updateClients();
if (sizeReduction > 0) {
currentStatus = currentStatus.withUpdatedSize(-sizeReduction); // depends on control dependency: [if], data = [none]
logCurrentStatus(currentStatus); // depends on control dependency: [if], data = [none]
oldestChanged = adjustOldestGeneration(currentStatus); // depends on control dependency: [if], data = [none]
}
} while (sizeReduction > 0 && oldestChanged);
this.cacheSize.set(currentStatus.getSize());
this.metrics.report(currentStatus.getSize(), currentStatus.getNewestGeneration() - currentStatus.getOldestGeneration());
} } |
public class class_name {
public static Element drawLp(SVGPlot svgp, Projection2D proj, NumberVector mid, double radius, double p) {
final double[] v_mid = mid.toArray();
final long[] dims = proj.getVisibleDimensions2D();
double kappax = p > 1 ? Math.min(1.3, 4. * (2 * FastMath.pow(0.5, 1. / p) - 1) / 3.) : 0;
double kappay = p < 1 ? Math.min(1.3, 4. * (2 * (1 - FastMath.pow(0.5, 1. / p)) - 1) / 3.) : 0;
SVGPath path = new SVGPath();
for(int dim = BitsUtil.nextSetBit(dims, 0); dim >= 0; dim = BitsUtil.nextSetBit(dims, dim + 1)) {
v_mid[dim] += radius;
double[] pvp0 = proj.fastProjectDataToRenderSpace(v_mid);
v_mid[dim] -= radius * 2;
double[] pvm0 = proj.fastProjectDataToRenderSpace(v_mid);
v_mid[dim] += radius;
// delta vector
double[] tvd0 = new double[v_mid.length];
tvd0[dim] = radius;
double[] vd0 = proj.fastProjectRelativeDataToRenderSpace(tvd0);
for(int dim2 = BitsUtil.nextSetBit(dims, 0); dim2 >= 0; dim2 = BitsUtil.nextSetBit(dims, dim2 + 1)) {
if(dim < dim2) {
v_mid[dim2] += radius;
double[] pv0p = proj.fastProjectDataToRenderSpace(v_mid);
v_mid[dim2] -= radius * 2;
double[] pv0m = proj.fastProjectDataToRenderSpace(v_mid);
v_mid[dim2] += radius;
// delta vector
double[] tv0d = new double[v_mid.length];
tv0d[dim2] = radius;
double[] v0d = proj.fastProjectRelativeDataToRenderSpace(tv0d);
if(p > 1) {
// p > 1
// support points, p0 to 0p
final double s_pp1_x = pvp0[0] + v0d[0] * kappax;
final double s_pp1_y = pvp0[1] + v0d[1] * kappax;
final double s_pp2_x = pv0p[0] + vd0[0] * kappax;
final double s_pp2_y = pv0p[1] + vd0[1] * kappax;
// support points, 0p to m0
final double s_mp1_x = pv0p[0] - vd0[0] * kappax;
final double s_mp1_y = pv0p[1] - vd0[1] * kappax;
final double s_mp2_x = pvm0[0] + v0d[0] * kappax;
final double s_mp2_y = pvm0[1] + v0d[1] * kappax;
// support points, m0 to 0m
final double s_mm1_x = pvm0[0] - v0d[0] * kappax;
final double s_mm1_y = pvm0[1] - v0d[1] * kappax;
final double s_mm2_x = pv0m[0] - vd0[0] * kappax;
final double s_mm2_y = pv0m[1] - vd0[1] * kappax;
// support points, 0m to p0
final double s_pm1_x = pv0m[0] + vd0[0] * kappax;
final double s_pm1_y = pv0m[1] + vd0[1] * kappax;
final double s_pm2_x = pvp0[0] - v0d[0] * kappax;
final double s_pm2_y = pvp0[1] - v0d[1] * kappax;
path.moveTo(pvp0[0], pvp0[1]) //
.cubicTo(s_pp1_x, s_pp1_y, s_pp2_x, s_pp2_y, pv0p[0], pv0p[1]) //
.cubicTo(s_mp1_x, s_mp1_y, s_mp2_x, s_mp2_y, pvm0[0], pvm0[1]) //
.cubicTo(s_mm1_x, s_mm1_y, s_mm2_x, s_mm2_y, pv0m[0], pv0m[1]) //
.cubicTo(s_pm1_x, s_pm1_y, s_pm2_x, s_pm2_y, pvp0[0], pvp0[1]) //
.close();
}
else if(p < 1) {
// p < 1
// support points, p0 to 0p
final double s_vp0_x = pvp0[0] - vd0[0] * kappay;
final double s_vp0_y = pvp0[1] - vd0[1] * kappay;
final double s_v0p_x = pv0p[0] - v0d[0] * kappay;
final double s_v0p_y = pv0p[1] - v0d[1] * kappay;
final double s_vm0_x = pvm0[0] + vd0[0] * kappay;
final double s_vm0_y = pvm0[1] + vd0[1] * kappay;
final double s_v0m_x = pv0m[0] + v0d[0] * kappay;
final double s_v0m_y = pv0m[1] + v0d[1] * kappay;
// Draw the star
path.moveTo(pvp0[0], pvp0[1]) //
.cubicTo(s_vp0_x, s_vp0_y, s_v0p_x, s_v0p_y, pv0p[0], pv0p[1]) //
.cubicTo(s_v0p_x, s_v0p_y, s_vm0_x, s_vm0_y, pvm0[0], pvm0[1]) //
.cubicTo(s_vm0_x, s_vm0_y, s_v0m_x, s_v0m_y, pv0m[0], pv0m[1]) //
.cubicTo(s_v0m_x, s_v0m_y, s_vp0_x, s_vp0_y, pvp0[0], pvp0[1]) //
.close();
}
else {
// p == 1 - Manhattan
path.moveTo(pvp0[0], pvp0[1]) //
.lineTo(pv0p[0], pv0p[1]) //
.lineTo(pvm0[0], pvm0[1]) //
.lineTo(pv0m[0], pv0m[1]) //
.lineTo(pvp0[0], pvp0[1]) //
.close();
}
}
}
}
return path.makeElement(svgp);
} } | public class class_name {
public static Element drawLp(SVGPlot svgp, Projection2D proj, NumberVector mid, double radius, double p) {
final double[] v_mid = mid.toArray();
final long[] dims = proj.getVisibleDimensions2D();
double kappax = p > 1 ? Math.min(1.3, 4. * (2 * FastMath.pow(0.5, 1. / p) - 1) / 3.) : 0;
double kappay = p < 1 ? Math.min(1.3, 4. * (2 * (1 - FastMath.pow(0.5, 1. / p)) - 1) / 3.) : 0;
SVGPath path = new SVGPath();
for(int dim = BitsUtil.nextSetBit(dims, 0); dim >= 0; dim = BitsUtil.nextSetBit(dims, dim + 1)) {
v_mid[dim] += radius; // depends on control dependency: [for], data = [dim]
double[] pvp0 = proj.fastProjectDataToRenderSpace(v_mid);
v_mid[dim] -= radius * 2; // depends on control dependency: [for], data = [dim]
double[] pvm0 = proj.fastProjectDataToRenderSpace(v_mid);
v_mid[dim] += radius; // depends on control dependency: [for], data = [dim]
// delta vector
double[] tvd0 = new double[v_mid.length];
tvd0[dim] = radius; // depends on control dependency: [for], data = [dim]
double[] vd0 = proj.fastProjectRelativeDataToRenderSpace(tvd0);
for(int dim2 = BitsUtil.nextSetBit(dims, 0); dim2 >= 0; dim2 = BitsUtil.nextSetBit(dims, dim2 + 1)) {
if(dim < dim2) {
v_mid[dim2] += radius; // depends on control dependency: [if], data = [none]
double[] pv0p = proj.fastProjectDataToRenderSpace(v_mid);
v_mid[dim2] -= radius * 2; // depends on control dependency: [if], data = [none]
double[] pv0m = proj.fastProjectDataToRenderSpace(v_mid);
v_mid[dim2] += radius; // depends on control dependency: [if], data = [none]
// delta vector
double[] tv0d = new double[v_mid.length];
tv0d[dim2] = radius; // depends on control dependency: [if], data = [none]
double[] v0d = proj.fastProjectRelativeDataToRenderSpace(tv0d);
if(p > 1) {
// p > 1
// support points, p0 to 0p
final double s_pp1_x = pvp0[0] + v0d[0] * kappax;
final double s_pp1_y = pvp0[1] + v0d[1] * kappax;
final double s_pp2_x = pv0p[0] + vd0[0] * kappax;
final double s_pp2_y = pv0p[1] + vd0[1] * kappax;
// support points, 0p to m0
final double s_mp1_x = pv0p[0] - vd0[0] * kappax;
final double s_mp1_y = pv0p[1] - vd0[1] * kappax;
final double s_mp2_x = pvm0[0] + v0d[0] * kappax;
final double s_mp2_y = pvm0[1] + v0d[1] * kappax;
// support points, m0 to 0m
final double s_mm1_x = pvm0[0] - v0d[0] * kappax;
final double s_mm1_y = pvm0[1] - v0d[1] * kappax;
final double s_mm2_x = pv0m[0] - vd0[0] * kappax;
final double s_mm2_y = pv0m[1] - vd0[1] * kappax;
// support points, 0m to p0
final double s_pm1_x = pv0m[0] + vd0[0] * kappax;
final double s_pm1_y = pv0m[1] + vd0[1] * kappax;
final double s_pm2_x = pvp0[0] - v0d[0] * kappax;
final double s_pm2_y = pvp0[1] - v0d[1] * kappax;
path.moveTo(pvp0[0], pvp0[1]) //
.cubicTo(s_pp1_x, s_pp1_y, s_pp2_x, s_pp2_y, pv0p[0], pv0p[1]) //
.cubicTo(s_mp1_x, s_mp1_y, s_mp2_x, s_mp2_y, pvm0[0], pvm0[1]) //
.cubicTo(s_mm1_x, s_mm1_y, s_mm2_x, s_mm2_y, pv0m[0], pv0m[1]) //
.cubicTo(s_pm1_x, s_pm1_y, s_pm2_x, s_pm2_y, pvp0[0], pvp0[1]) //
.close(); // depends on control dependency: [if], data = [(p]
}
else if(p < 1) {
// p < 1
// support points, p0 to 0p
final double s_vp0_x = pvp0[0] - vd0[0] * kappay;
final double s_vp0_y = pvp0[1] - vd0[1] * kappay;
final double s_v0p_x = pv0p[0] - v0d[0] * kappay;
final double s_v0p_y = pv0p[1] - v0d[1] * kappay;
final double s_vm0_x = pvm0[0] + vd0[0] * kappay;
final double s_vm0_y = pvm0[1] + vd0[1] * kappay;
final double s_v0m_x = pv0m[0] + v0d[0] * kappay;
final double s_v0m_y = pv0m[1] + v0d[1] * kappay;
// Draw the star
path.moveTo(pvp0[0], pvp0[1]) //
.cubicTo(s_vp0_x, s_vp0_y, s_v0p_x, s_v0p_y, pv0p[0], pv0p[1]) //
.cubicTo(s_v0p_x, s_v0p_y, s_vm0_x, s_vm0_y, pvm0[0], pvm0[1]) //
.cubicTo(s_vm0_x, s_vm0_y, s_v0m_x, s_v0m_y, pv0m[0], pv0m[1]) //
.cubicTo(s_v0m_x, s_v0m_y, s_vp0_x, s_vp0_y, pvp0[0], pvp0[1]) //
.close(); // depends on control dependency: [if], data = [(p]
}
else {
// p == 1 - Manhattan
path.moveTo(pvp0[0], pvp0[1]) //
.lineTo(pv0p[0], pv0p[1]) //
.lineTo(pvm0[0], pvm0[1]) //
.lineTo(pv0m[0], pv0m[1]) //
.lineTo(pvp0[0], pvp0[1]) //
.close(); // depends on control dependency: [if], data = [(p]
}
}
}
}
return path.makeElement(svgp);
} } |
public class class_name {
public static TimeZone getStockTimeZone(String symbol) {
// First check if it's a known stock index
if(INDEX_TIMEZONES.containsKey(symbol)) {
return INDEX_TIMEZONES.get(symbol);
}
if(!symbol.contains(".")) {
return ExchangeTimeZone.get("");
}
String[] split = symbol.split("\\.");
return ExchangeTimeZone.get(split[split.length - 1]);
} } | public class class_name {
public static TimeZone getStockTimeZone(String symbol) {
// First check if it's a known stock index
if(INDEX_TIMEZONES.containsKey(symbol)) {
return INDEX_TIMEZONES.get(symbol); // depends on control dependency: [if], data = [none]
}
if(!symbol.contains(".")) {
return ExchangeTimeZone.get(""); // depends on control dependency: [if], data = [none]
}
String[] split = symbol.split("\\.");
return ExchangeTimeZone.get(split[split.length - 1]);
} } |
public class class_name {
public void addExtractor(String extractor) {
if (null == this.extractors) {
this.extractors = new ArrayList<String>();
}
this.extractors.add(extractor);
} } | public class class_name {
public void addExtractor(String extractor) {
if (null == this.extractors) {
this.extractors = new ArrayList<String>(); // depends on control dependency: [if], data = [none]
}
this.extractors.add(extractor);
} } |
public class class_name {
private WyalFile.Stmt and(WyalFile.Stmt lhs, WyalFile.Stmt rhs) {
if (lhs == null) {
return rhs;
} else if (rhs == null) {
return rhs;
} else {
return new WyalFile.Stmt.Block(lhs, rhs);
}
} } | public class class_name {
private WyalFile.Stmt and(WyalFile.Stmt lhs, WyalFile.Stmt rhs) {
if (lhs == null) {
return rhs; // depends on control dependency: [if], data = [none]
} else if (rhs == null) {
return rhs; // depends on control dependency: [if], data = [none]
} else {
return new WyalFile.Stmt.Block(lhs, rhs); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public synchronized void complete() {
if( logger.isInfoEnabled() ) {
logger.info("[" + this + "] Marking complete");
}
if( loaded ) {
return;
}
loaded = true;
lastTouch = System.currentTimeMillis();
if( waiting != null && waiting.isEmpty() ) {
waiting = null;
}
notifyAll();
} } | public class class_name {
public synchronized void complete() {
if( logger.isInfoEnabled() ) {
logger.info("[" + this + "] Marking complete"); // depends on control dependency: [if], data = [none]
}
if( loaded ) {
return; // depends on control dependency: [if], data = [none]
}
loaded = true;
lastTouch = System.currentTimeMillis();
if( waiting != null && waiting.isEmpty() ) {
waiting = null; // depends on control dependency: [if], data = [none]
}
notifyAll();
} } |
public class class_name {
public OutlierResult run(Relation<O> relation) {
final int k1 = k + 1; // Query size
final double perplexity = k / 3.;
KNNQuery<O> knnq = relation.getKNNQuery(getDistanceFunction(), k1);
final double logPerp = perplexity > 1. ? FastMath.log(perplexity) : .1;
double[] p = new double[k + 10];
ModifiableDoubleDBIDList dists = DBIDUtil.newDistanceDBIDList(k + 10);
DoubleDBIDListIter di = dists.iter();
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("ISOS scores", relation.size(), LOG) : null;
WritableDoubleDataStore scores = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB, 1.);
for(DBIDIter it = relation.iterDBIDs(); it.valid(); it.advance()) {
KNNList knns = knnq.getKNNForDBID(it, k1);
if(p.length < knns.size() + 1) {
p = new double[knns.size() + 10];
}
final DoubleDBIDListIter ki = knns.iter();
try {
double id = estimateID(it, ki, p);
adjustDistances(it, ki, knns.getKNNDistance(), id, dists);
// We now continue with the modified distances below.
// Compute affinities
SOS.computePi(it, di, p, perplexity, logPerp);
// Normalization factor:
double s = SOS.sumOfProbabilities(it, di, p);
if(s > 0.) {
nominateNeighbors(it, di, p, 1. / s, scores);
}
}
catch(ArithmeticException e) {
// ID estimation failed, supposedly constant values because of too many
// duplicate points, or too small k. Fall back to KNNSOS.
// Note: this looks almost identical to the above, but uses ki instead
// of the adjusted distances di!
// Compute affinities
SOS.computePi(it, ki, p, perplexity, logPerp);
// Normalization factor:
double s = SOS.sumOfProbabilities(it, ki, p);
if(s > 0.) {
nominateNeighbors(it, ki, p, 1. / s, scores);
}
}
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
DoubleMinMax minmax = transformScores(scores, relation.getDBIDs(), logPerp, phi);
DoubleRelation scoreres = new MaterializedDoubleRelation("Intrinsic Stoachastic Outlier Selection", "isos-outlier", scores, relation.getDBIDs());
OutlierScoreMeta meta = new ProbabilisticOutlierScore(minmax.getMin(), minmax.getMax(), 0.);
return new OutlierResult(meta, scoreres);
} } | public class class_name {
public OutlierResult run(Relation<O> relation) {
final int k1 = k + 1; // Query size
final double perplexity = k / 3.;
KNNQuery<O> knnq = relation.getKNNQuery(getDistanceFunction(), k1);
final double logPerp = perplexity > 1. ? FastMath.log(perplexity) : .1;
double[] p = new double[k + 10];
ModifiableDoubleDBIDList dists = DBIDUtil.newDistanceDBIDList(k + 10);
DoubleDBIDListIter di = dists.iter();
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("ISOS scores", relation.size(), LOG) : null;
WritableDoubleDataStore scores = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB, 1.);
for(DBIDIter it = relation.iterDBIDs(); it.valid(); it.advance()) {
KNNList knns = knnq.getKNNForDBID(it, k1);
if(p.length < knns.size() + 1) {
p = new double[knns.size() + 10]; // depends on control dependency: [if], data = [none]
}
final DoubleDBIDListIter ki = knns.iter();
try {
double id = estimateID(it, ki, p);
adjustDistances(it, ki, knns.getKNNDistance(), id, dists); // depends on control dependency: [try], data = [none]
// We now continue with the modified distances below.
// Compute affinities
SOS.computePi(it, di, p, perplexity, logPerp); // depends on control dependency: [try], data = [none]
// Normalization factor:
double s = SOS.sumOfProbabilities(it, di, p);
if(s > 0.) {
nominateNeighbors(it, di, p, 1. / s, scores); // depends on control dependency: [if], data = [none]
}
}
catch(ArithmeticException e) {
// ID estimation failed, supposedly constant values because of too many
// duplicate points, or too small k. Fall back to KNNSOS.
// Note: this looks almost identical to the above, but uses ki instead
// of the adjusted distances di!
// Compute affinities
SOS.computePi(it, ki, p, perplexity, logPerp);
// Normalization factor:
double s = SOS.sumOfProbabilities(it, ki, p);
if(s > 0.) {
nominateNeighbors(it, ki, p, 1. / s, scores); // depends on control dependency: [if], data = [none]
}
} // depends on control dependency: [catch], data = [none]
LOG.incrementProcessed(prog); // depends on control dependency: [for], data = [none]
}
LOG.ensureCompleted(prog);
DoubleMinMax minmax = transformScores(scores, relation.getDBIDs(), logPerp, phi);
DoubleRelation scoreres = new MaterializedDoubleRelation("Intrinsic Stoachastic Outlier Selection", "isos-outlier", scores, relation.getDBIDs());
OutlierScoreMeta meta = new ProbabilisticOutlierScore(minmax.getMin(), minmax.getMax(), 0.);
return new OutlierResult(meta, scoreres);
} } |
public class class_name {
public boolean stop() {
if (!this.isTailing.get()) {
LogWatchTailingManager.LOGGER.debug("Tailer not running, therefore not terminating.");
return false;
}
/*
* terminate tailer; we stop the scheduler and the task will therefore
* never be started again
*/
this.tailer.stop();
LogWatchTailingManager.LOGGER.info("Terminated tailing #{} for {}.",
this.numberOfTimesThatTailerWasStarted.get(), this.watch);
return true;
} } | public class class_name {
public boolean stop() {
if (!this.isTailing.get()) {
LogWatchTailingManager.LOGGER.debug("Tailer not running, therefore not terminating."); // depends on control dependency: [if], data = [none]
return false; // depends on control dependency: [if], data = [none]
}
/*
* terminate tailer; we stop the scheduler and the task will therefore
* never be started again
*/
this.tailer.stop();
LogWatchTailingManager.LOGGER.info("Terminated tailing #{} for {}.",
this.numberOfTimesThatTailerWasStarted.get(), this.watch);
return true;
} } |
public class class_name {
void collectObjectNames(Set set) {
for (int i = 0; i < nodes.length; i++) {
if (nodes[i] != null) {
nodes[i].collectObjectNames(set);
}
}
if (subQuery != null) {
if (subQuery.queryExpression != null) {
subQuery.queryExpression.collectObjectNames(set);
}
}
} } | public class class_name {
void collectObjectNames(Set set) {
for (int i = 0; i < nodes.length; i++) {
if (nodes[i] != null) {
nodes[i].collectObjectNames(set); // depends on control dependency: [if], data = [none]
}
}
if (subQuery != null) {
if (subQuery.queryExpression != null) {
subQuery.queryExpression.collectObjectNames(set); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public static ExpectedCondition<List<WebElement>> visibilityOfNestedElementsLocatedBy(
final By parent,
final By childLocator) {
return new ExpectedCondition<List<WebElement>>() {
@Override
public List<WebElement> apply(WebDriver driver) {
WebElement current = driver.findElement(parent);
List<WebElement> allChildren = current.findElements(childLocator);
// The original code only checked the first element. Fair enough.
if (!allChildren.isEmpty() && allChildren.get(0).isDisplayed()) {
return allChildren;
}
return null;
}
@Override
public String toString() {
return String.format("visibility of elements located by %s -> %s", parent, childLocator);
}
};
} } | public class class_name {
public static ExpectedCondition<List<WebElement>> visibilityOfNestedElementsLocatedBy(
final By parent,
final By childLocator) {
return new ExpectedCondition<List<WebElement>>() {
@Override
public List<WebElement> apply(WebDriver driver) {
WebElement current = driver.findElement(parent);
List<WebElement> allChildren = current.findElements(childLocator);
// The original code only checked the first element. Fair enough.
if (!allChildren.isEmpty() && allChildren.get(0).isDisplayed()) {
return allChildren; // depends on control dependency: [if], data = [none]
}
return null;
}
@Override
public String toString() {
return String.format("visibility of elements located by %s -> %s", parent, childLocator);
}
};
} } |
public class class_name {
@Override
public DoubleVector getCenterOfMass() {
final int dim = bounds.getDimensionality();
double[] mean = new double[dim];
for(int d = 0; d < dim; d++) {
mean[d] = (bounds.getMin(d) + bounds.getMax(d)) * .5;
}
return DoubleVector.wrap(mean);
} } | public class class_name {
@Override
public DoubleVector getCenterOfMass() {
final int dim = bounds.getDimensionality();
double[] mean = new double[dim];
for(int d = 0; d < dim; d++) {
mean[d] = (bounds.getMin(d) + bounds.getMax(d)) * .5; // depends on control dependency: [for], data = [d]
}
return DoubleVector.wrap(mean);
} } |
public class class_name {
protected void addCookies(final HttpRequest httpRequest) {
// prepare all cookies
List<Cookie> cookiesList = new ArrayList<>();
if (!cookies.isEmpty()) {
for (Map.Entry<String, Cookie> cookieEntry : cookies) {
cookiesList.add(cookieEntry.getValue());
}
httpRequest.cookies(cookiesList.toArray(new Cookie[0]));
}
} } | public class class_name {
protected void addCookies(final HttpRequest httpRequest) {
// prepare all cookies
List<Cookie> cookiesList = new ArrayList<>();
if (!cookies.isEmpty()) {
for (Map.Entry<String, Cookie> cookieEntry : cookies) {
cookiesList.add(cookieEntry.getValue()); // depends on control dependency: [for], data = [cookieEntry]
}
httpRequest.cookies(cookiesList.toArray(new Cookie[0])); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
String lookupName(ClassName className) {
// If the top level simple name is masked by a current type variable, use the canonical name.
String topLevelSimpleName = className.topLevelClassName().simpleName();
if (currentTypeVariables.contains(topLevelSimpleName)) {
return className.canonicalName;
}
// Find the shortest suffix of className that resolves to className. This uses both local type
// names (so `Entry` in `Map` refers to `Map.Entry`). Also uses imports.
boolean nameResolved = false;
for (ClassName c = className; c != null; c = c.enclosingClassName()) {
ClassName resolved = resolve(c.simpleName());
nameResolved = resolved != null;
if (resolved != null && Objects.equals(resolved.canonicalName, c.canonicalName)) {
int suffixOffset = c.simpleNames().size() - 1;
return join(".", className.simpleNames().subList(
suffixOffset, className.simpleNames().size()));
}
}
// If the name resolved but wasn't a match, we're stuck with the fully qualified name.
if (nameResolved) {
return className.canonicalName;
}
// If the class is in the same package, we're done.
if (Objects.equals(packageName, className.packageName())) {
referencedNames.add(topLevelSimpleName);
return join(".", className.simpleNames());
}
// We'll have to use the fully-qualified name. Mark the type as importable for a future pass.
if (!javadoc) {
importableType(className);
}
return className.canonicalName;
} } | public class class_name {
String lookupName(ClassName className) {
// If the top level simple name is masked by a current type variable, use the canonical name.
String topLevelSimpleName = className.topLevelClassName().simpleName();
if (currentTypeVariables.contains(topLevelSimpleName)) {
return className.canonicalName; // depends on control dependency: [if], data = [none]
}
// Find the shortest suffix of className that resolves to className. This uses both local type
// names (so `Entry` in `Map` refers to `Map.Entry`). Also uses imports.
boolean nameResolved = false;
for (ClassName c = className; c != null; c = c.enclosingClassName()) {
ClassName resolved = resolve(c.simpleName());
nameResolved = resolved != null; // depends on control dependency: [for], data = [none]
if (resolved != null && Objects.equals(resolved.canonicalName, c.canonicalName)) {
int suffixOffset = c.simpleNames().size() - 1;
return join(".", className.simpleNames().subList(
suffixOffset, className.simpleNames().size())); // depends on control dependency: [if], data = [none]
}
}
// If the name resolved but wasn't a match, we're stuck with the fully qualified name.
if (nameResolved) {
return className.canonicalName; // depends on control dependency: [if], data = [none]
}
// If the class is in the same package, we're done.
if (Objects.equals(packageName, className.packageName())) {
referencedNames.add(topLevelSimpleName); // depends on control dependency: [if], data = [none]
return join(".", className.simpleNames()); // depends on control dependency: [if], data = [none]
}
// We'll have to use the fully-qualified name. Mark the type as importable for a future pass.
if (!javadoc) {
importableType(className); // depends on control dependency: [if], data = [none]
}
return className.canonicalName;
} } |
public class class_name {
public static LocalDate adjustToFirstDayOfWeek(LocalDate date, DayOfWeek firstDayOfWeek) {
LocalDate newDate = date.with(DAY_OF_WEEK, firstDayOfWeek.getValue());
if (newDate.isAfter(date)) {
newDate = newDate.minusWeeks(1);
}
return newDate;
} } | public class class_name {
public static LocalDate adjustToFirstDayOfWeek(LocalDate date, DayOfWeek firstDayOfWeek) {
LocalDate newDate = date.with(DAY_OF_WEEK, firstDayOfWeek.getValue());
if (newDate.isAfter(date)) {
newDate = newDate.minusWeeks(1); // depends on control dependency: [if], data = [none]
}
return newDate;
} } |
public class class_name {
@Override
public EClass getIfcTextStyleForDefinedFont() {
if (ifcTextStyleForDefinedFontEClass == null) {
ifcTextStyleForDefinedFontEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(715);
}
return ifcTextStyleForDefinedFontEClass;
} } | public class class_name {
@Override
public EClass getIfcTextStyleForDefinedFont() {
if (ifcTextStyleForDefinedFontEClass == null) {
ifcTextStyleForDefinedFontEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI)
.getEClassifiers().get(715);
// depends on control dependency: [if], data = [none]
}
return ifcTextStyleForDefinedFontEClass;
} } |
public class class_name {
public void executeInstrumentation() throws IOException {
errors.clear();
// Iterate over all entries in the classes list
for (File f : this.classFiles) {
try {
if (!f.canRead() || !f.canWrite()) {
throw new IOException(f + " can not be replaced");
}
instrumentClassFile(f);
} catch (Exception e) {
e.printStackTrace();
errors.add(e);
}
}
// Iterate over all entries in the jar list
for (File f : this.jarFiles) {
try {
instrumentZipFile(f);
} catch (Exception e) {
e.printStackTrace();
errors.add(e);
}
}
// Chain the first exception and report the error count
if (!errors.isEmpty()) {
Throwable t = errors.get(0);
IOException ioe = new IOException(errors.size() + " errors occurred");
ioe.initCause(t);
throw ioe;
}
} } | public class class_name {
public void executeInstrumentation() throws IOException {
errors.clear();
// Iterate over all entries in the classes list
for (File f : this.classFiles) {
try {
if (!f.canRead() || !f.canWrite()) {
throw new IOException(f + " can not be replaced");
}
instrumentClassFile(f); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
e.printStackTrace();
errors.add(e);
} // depends on control dependency: [catch], data = [none]
}
// Iterate over all entries in the jar list
for (File f : this.jarFiles) {
try {
instrumentZipFile(f); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
e.printStackTrace();
errors.add(e);
} // depends on control dependency: [catch], data = [none]
}
// Chain the first exception and report the error count
if (!errors.isEmpty()) {
Throwable t = errors.get(0);
IOException ioe = new IOException(errors.size() + " errors occurred");
ioe.initCause(t);
throw ioe;
}
} } |
public class class_name {
public void setCustomLayer(final BufferedImage CUSTOM_LAYER) {
if (customLayer != null) {
customLayer.flush();
}
customLayer = CUSTOM_LAYER;
fireStateChanged();
} } | public class class_name {
public void setCustomLayer(final BufferedImage CUSTOM_LAYER) {
if (customLayer != null) {
customLayer.flush(); // depends on control dependency: [if], data = [none]
}
customLayer = CUSTOM_LAYER;
fireStateChanged();
} } |
public class class_name {
public void shutdown() throws Throwable
{
if (!started)
throw new IllegalStateException("Container not started");
if (shrinkwrapDeployments != null && !shrinkwrapDeployments.isEmpty())
{
List<File> copy = new ArrayList<File>(shrinkwrapDeployments);
for (File f : copy)
{
removeDeployment(f);
}
}
if (fullProfile)
{
undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "ds.xml");
undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "jca.xml");
undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "transaction.xml");
undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "stdio.xml");
undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "naming.xml");
}
kernel.shutdown();
started = false;
} } | public class class_name {
public void shutdown() throws Throwable
{
if (!started)
throw new IllegalStateException("Container not started");
if (shrinkwrapDeployments != null && !shrinkwrapDeployments.isEmpty())
{
List<File> copy = new ArrayList<File>(shrinkwrapDeployments);
for (File f : copy)
{
removeDeployment(f); // depends on control dependency: [for], data = [f]
}
}
if (fullProfile)
{
undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "ds.xml");
undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "jca.xml");
undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "transaction.xml");
undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "stdio.xml");
undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "naming.xml");
}
kernel.shutdown();
started = false;
} } |
public class class_name {
private void ensureElementFormatter(CmsResource resource, HttpServletRequest req) {
CmsJspStandardContextBean contextBean = CmsJspStandardContextBean.getInstance(req);
CmsContainerElementBean element = contextBean.getElement();
if (!resource.getStructureId().equals(element.getFormatterId())) {
element.setFormatterId(resource.getStructureId());
}
} } | public class class_name {
private void ensureElementFormatter(CmsResource resource, HttpServletRequest req) {
CmsJspStandardContextBean contextBean = CmsJspStandardContextBean.getInstance(req);
CmsContainerElementBean element = contextBean.getElement();
if (!resource.getStructureId().equals(element.getFormatterId())) {
element.setFormatterId(resource.getStructureId()); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private void authorizeClassicDbSecurityGroup(String groupName, String sourceCidr) throws CloudException, InternalException {
Map<String,String> parameters = getProvider().getStandardRdsParameters(getProvider().getContext(), AUTHORIZE_DB_SECURITY_GROUP_INGRESS);
parameters.put("DBSecurityGroupName", groupName);
parameters.put("CIDRIP", sourceCidr);
EC2Method method = new EC2Method(SERVICE_ID, getProvider(), parameters);
try {
method.invoke();
}
catch( EC2Exception e ) {
String code = e.getCode();
if( code != null && code.equals("AuthorizationAlreadyExists") ) {
return;
}
throw new CloudException(e);
}
} } | public class class_name {
private void authorizeClassicDbSecurityGroup(String groupName, String sourceCidr) throws CloudException, InternalException {
Map<String,String> parameters = getProvider().getStandardRdsParameters(getProvider().getContext(), AUTHORIZE_DB_SECURITY_GROUP_INGRESS);
parameters.put("DBSecurityGroupName", groupName);
parameters.put("CIDRIP", sourceCidr);
EC2Method method = new EC2Method(SERVICE_ID, getProvider(), parameters);
try {
method.invoke();
}
catch( EC2Exception e ) {
String code = e.getCode();
if( code != null && code.equals("AuthorizationAlreadyExists") ) {
return; // depends on control dependency: [if], data = [none]
}
throw new CloudException(e);
}
} } |
public class class_name {
public EventList getBaseEventList() {
if (baseList == null) {
// Construct on demand
Object[] data = getInitialData();
if (logger.isDebugEnabled()) {
logger.debug("Table data: got " + data.length + " entries");
}
// Construct the event list of all our data and layer on the sorting
EventList rawList = GlazedLists.eventList(Arrays.asList(data));
int initialSortColumn = getInitialSortColumn();
if (initialSortColumn >= 0) {
String sortProperty = getColumnPropertyNames()[initialSortColumn];
baseList = new SortedList(rawList, new PropertyComparator(
sortProperty, false, true));
} else {
baseList = new SortedList(rawList);
}
}
return baseList;
} } | public class class_name {
public EventList getBaseEventList() {
if (baseList == null) {
// Construct on demand
Object[] data = getInitialData();
if (logger.isDebugEnabled()) {
logger.debug("Table data: got " + data.length + " entries"); // depends on control dependency: [if], data = [none]
}
// Construct the event list of all our data and layer on the sorting
EventList rawList = GlazedLists.eventList(Arrays.asList(data));
int initialSortColumn = getInitialSortColumn();
if (initialSortColumn >= 0) {
String sortProperty = getColumnPropertyNames()[initialSortColumn];
baseList = new SortedList(rawList, new PropertyComparator(
sortProperty, false, true)); // depends on control dependency: [if], data = [none]
} else {
baseList = new SortedList(rawList); // depends on control dependency: [if], data = [none]
}
}
return baseList;
} } |
public class class_name {
public static ProjectionImpl convertWKTToProjection(WKTParser srp) {
if (!srp.isPlanarProjection()) {
return new ucar.unidata.geoloc.projection.LatLonProjection();
} else {
String projectionType = srp.getProjectionType();
double falseEasting = 0;
double falseNorthing = 0;
ProjectionImpl proj = null;
if (srp.hasParameter("False_Easting")) {
falseEasting = srp.getParameter("False_Easting");
}
if (srp.hasParameter("False_Northing")) {
falseNorthing = srp.getParameter("False_Northing");
}
if ((falseEasting != 0.0) || (falseNorthing != 0.0)) {
double scalef = 1.0;
if (srp.getProjUnitName() != null) {
try {
SimpleUnit unit =
SimpleUnit.factoryWithExceptions(
srp.getProjUnitName());
scalef = unit.convertTo(srp.getProjUnitValue(),
SimpleUnit.kmUnit);
} catch (Exception e) {
System.out.println(srp.getProjUnitValue() + " "
+ srp.getProjUnitName()
+ " not convertible to km");
}
}
falseEasting *= scalef;
falseNorthing *= scalef;
}
if (srp.getProjName().contains("UTM_Zone_"))
return processUTM(srp);
if ("Transverse_Mercator".equals(projectionType)) {
double lat0 = srp.getParameter("Latitude_Of_Origin");
double scale = srp.getParameter("Scale_Factor");
double tangentLon = srp.getParameter("Central_Meridian");
proj = new TransverseMercator(lat0, tangentLon, scale, falseEasting, falseNorthing);
} else if ("Lambert_Conformal_Conic".equals(projectionType)) {
double lon0 = srp.getParameter("Central_Meridian");
double par1 = srp.getParameter("Standard_Parallel_1");
double par2 = par1;
if (srp.hasParameter("Standard_Parallel_2")) {
par2 = srp.getParameter("Standard_Parallel_2");
}
double lat0 = srp.getParameter("Latitude_Of_Origin");
return new LambertConformal(lat0, lon0, par1, par2, falseEasting, falseNorthing);
} else if ("Albers".equals(projectionType)) {
double lon0 = srp.getParameter("Central_Meridian");
double par1 = srp.getParameter("Standard_Parallel_1");
double par2 = par1;
if (srp.hasParameter("Standard_Parallel_2")) {
par2 = srp.getParameter("Standard_Parallel_2");
}
double lat0 = srp.getParameter("Latitude_Of_Origin");
return new AlbersEqualArea(lat0, lon0, par1, par2, falseEasting, falseNorthing);
} else if ("Stereographic".equals(projectionType)) {
double lont = srp.getParameter("Central_Meridian");
double scale = srp.getParameter("Scale_Factor");
double latt = srp.getParameter("Latitude_Of_Origin");
return new Stereographic(latt, lont, scale, falseEasting, falseNorthing);
} else if ("Mercator".equals(projectionType)) {
double lat0 = srp.getParameter("Latitude_Of_Origin");
double lon0 = srp.getParameter("Central_Meridian");
proj = new Mercator(lon0, lat0, falseEasting, falseNorthing);
} else if ("Universal_Transverse_Mercator".equals(projectionType)) {
//throw new java.text.ParseException(
// "UTM adapter not implemented yet", 0);
}
return proj;
}
} } | public class class_name {
public static ProjectionImpl convertWKTToProjection(WKTParser srp) {
if (!srp.isPlanarProjection()) {
return new ucar.unidata.geoloc.projection.LatLonProjection();
// depends on control dependency: [if], data = [none]
} else {
String projectionType = srp.getProjectionType();
double falseEasting = 0;
double falseNorthing = 0;
ProjectionImpl proj = null;
if (srp.hasParameter("False_Easting")) {
falseEasting = srp.getParameter("False_Easting");
// depends on control dependency: [if], data = [none]
}
if (srp.hasParameter("False_Northing")) {
falseNorthing = srp.getParameter("False_Northing");
// depends on control dependency: [if], data = [none]
}
if ((falseEasting != 0.0) || (falseNorthing != 0.0)) {
double scalef = 1.0;
if (srp.getProjUnitName() != null) {
try {
SimpleUnit unit =
SimpleUnit.factoryWithExceptions(
srp.getProjUnitName());
scalef = unit.convertTo(srp.getProjUnitValue(),
SimpleUnit.kmUnit);
// depends on control dependency: [try], data = [none]
} catch (Exception e) {
System.out.println(srp.getProjUnitValue() + " "
+ srp.getProjUnitName()
+ " not convertible to km");
}
// depends on control dependency: [catch], data = [none]
}
falseEasting *= scalef;
// depends on control dependency: [if], data = [none]
falseNorthing *= scalef;
// depends on control dependency: [if], data = [none]
}
if (srp.getProjName().contains("UTM_Zone_"))
return processUTM(srp);
if ("Transverse_Mercator".equals(projectionType)) {
double lat0 = srp.getParameter("Latitude_Of_Origin");
double scale = srp.getParameter("Scale_Factor");
double tangentLon = srp.getParameter("Central_Meridian");
proj = new TransverseMercator(lat0, tangentLon, scale, falseEasting, falseNorthing);
// depends on control dependency: [if], data = [none]
} else if ("Lambert_Conformal_Conic".equals(projectionType)) {
double lon0 = srp.getParameter("Central_Meridian");
double par1 = srp.getParameter("Standard_Parallel_1");
double par2 = par1;
if (srp.hasParameter("Standard_Parallel_2")) {
par2 = srp.getParameter("Standard_Parallel_2");
// depends on control dependency: [if], data = [none]
}
double lat0 = srp.getParameter("Latitude_Of_Origin");
return new LambertConformal(lat0, lon0, par1, par2, falseEasting, falseNorthing);
// depends on control dependency: [if], data = [none]
} else if ("Albers".equals(projectionType)) {
double lon0 = srp.getParameter("Central_Meridian");
double par1 = srp.getParameter("Standard_Parallel_1");
double par2 = par1;
if (srp.hasParameter("Standard_Parallel_2")) {
par2 = srp.getParameter("Standard_Parallel_2");
// depends on control dependency: [if], data = [none]
}
double lat0 = srp.getParameter("Latitude_Of_Origin");
return new AlbersEqualArea(lat0, lon0, par1, par2, falseEasting, falseNorthing);
// depends on control dependency: [if], data = [none]
} else if ("Stereographic".equals(projectionType)) {
double lont = srp.getParameter("Central_Meridian");
double scale = srp.getParameter("Scale_Factor");
double latt = srp.getParameter("Latitude_Of_Origin");
return new Stereographic(latt, lont, scale, falseEasting, falseNorthing);
// depends on control dependency: [if], data = [none]
} else if ("Mercator".equals(projectionType)) {
double lat0 = srp.getParameter("Latitude_Of_Origin");
double lon0 = srp.getParameter("Central_Meridian");
proj = new Mercator(lon0, lat0, falseEasting, falseNorthing);
// depends on control dependency: [if], data = [none]
} else if ("Universal_Transverse_Mercator".equals(projectionType)) {
//throw new java.text.ParseException(
// "UTM adapter not implemented yet", 0);
}
return proj;
// depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private static void mutateInstructionConstant(Program program, LGP manager, RandEngine randEngine)
{
Instruction selected_instruction = null;
for (Instruction instruction : program.getInstructions())
{
if (!instruction.isStructuralIntron() && (instruction.getOperand1().isConstant() || instruction.getOperand2().isConstant()))
{
if (selected_instruction == null)
{
selected_instruction = instruction;
}
else if (randEngine.uniform() < 0.5)
{
selected_instruction = instruction;
}
}
}
if (selected_instruction != null)
{
InstructionHelper.mutateConstant(selected_instruction, randEngine, manager.getMicroMutateConstantStandardDeviation());
}
} } | public class class_name {
private static void mutateInstructionConstant(Program program, LGP manager, RandEngine randEngine)
{
Instruction selected_instruction = null;
for (Instruction instruction : program.getInstructions())
{
if (!instruction.isStructuralIntron() && (instruction.getOperand1().isConstant() || instruction.getOperand2().isConstant()))
{
if (selected_instruction == null)
{
selected_instruction = instruction; // depends on control dependency: [if], data = [none]
}
else if (randEngine.uniform() < 0.5)
{
selected_instruction = instruction; // depends on control dependency: [if], data = [none]
}
}
}
if (selected_instruction != null)
{
InstructionHelper.mutateConstant(selected_instruction, randEngine, manager.getMicroMutateConstantStandardDeviation()); // depends on control dependency: [if], data = [(selected_instruction]
}
} } |
public class class_name {
public void alarm(final Object alarmContext) {
final String methodName = "alarm()";
synchronized (this) {
if (!stopping && !this.htod.invalidationBuffer.isDiskClearInProgress()) {
this.htod.invalidationBuffer.invokeBackgroundInvalidation(HTODInvalidationBuffer.SCAN);
} else if (stopping) {
traceDebug(methodName, "cacheName=" + this.cacheName + " abort disk cleanup because of server is stopping.");
} else {
if (cleanupFrequency == 0) {
sleepTime = calculateSleepTime();
}
traceDebug(methodName, "cacheName=" + this.cacheName + " disk clear is in progress - skip disk scan and set alarm sleepTime="
+ sleepTime);
Scheduler.createNonDeferrable(sleepTime, alarmContext, new Runnable() {
@Override
public void run() {
alarm(alarmContext);
}
});
}
}
} } | public class class_name {
public void alarm(final Object alarmContext) {
final String methodName = "alarm()";
synchronized (this) {
if (!stopping && !this.htod.invalidationBuffer.isDiskClearInProgress()) {
this.htod.invalidationBuffer.invokeBackgroundInvalidation(HTODInvalidationBuffer.SCAN); // depends on control dependency: [if], data = [none]
} else if (stopping) {
traceDebug(methodName, "cacheName=" + this.cacheName + " abort disk cleanup because of server is stopping."); // depends on control dependency: [if], data = [none]
} else {
if (cleanupFrequency == 0) {
sleepTime = calculateSleepTime(); // depends on control dependency: [if], data = [none]
}
traceDebug(methodName, "cacheName=" + this.cacheName + " disk clear is in progress - skip disk scan and set alarm sleepTime="
+ sleepTime); // depends on control dependency: [if], data = [none]
Scheduler.createNonDeferrable(sleepTime, alarmContext, new Runnable() {
@Override
public void run() {
alarm(alarmContext);
}
}); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public boolean isCastOperatorLinkingEnabled(SarlCastedExpression cast) {
final LightweightTypeReference sourceType = getStackedResolvedTypes().getReturnType(cast.getTarget());
final LightweightTypeReference destinationType = getReferenceOwner().toLightweightTypeReference(cast.getType());
if (sourceType.isPrimitiveVoid() || destinationType.isPrimitiveVoid()) {
return false;
}
if (sourceType.isPrimitive() && destinationType.isPrimitive()) {
return false;
}
return !sourceType.isSubtypeOf(destinationType.getType());
} } | public class class_name {
public boolean isCastOperatorLinkingEnabled(SarlCastedExpression cast) {
final LightweightTypeReference sourceType = getStackedResolvedTypes().getReturnType(cast.getTarget());
final LightweightTypeReference destinationType = getReferenceOwner().toLightweightTypeReference(cast.getType());
if (sourceType.isPrimitiveVoid() || destinationType.isPrimitiveVoid()) {
return false; // depends on control dependency: [if], data = [none]
}
if (sourceType.isPrimitive() && destinationType.isPrimitive()) {
return false; // depends on control dependency: [if], data = [none]
}
return !sourceType.isSubtypeOf(destinationType.getType());
} } |
public class class_name {
public BaseJsonBo removeSubAttr(String attrName, String dPath) {
Lock lock = lockForWrite();
try {
JsonNode attr = cacheJsonObjs.get(attrName);
JacksonUtils.deleteValue(attr, dPath);
return (BaseJsonBo) setAttribute(attrName, SerializationUtils.toJsonString(attr),
false);
} finally {
lock.unlock();
}
} } | public class class_name {
public BaseJsonBo removeSubAttr(String attrName, String dPath) {
Lock lock = lockForWrite();
try {
JsonNode attr = cacheJsonObjs.get(attrName);
JacksonUtils.deleteValue(attr, dPath); // depends on control dependency: [try], data = [none]
return (BaseJsonBo) setAttribute(attrName, SerializationUtils.toJsonString(attr),
false); // depends on control dependency: [try], data = [none]
} finally {
lock.unlock();
}
} } |
public class class_name {
private boolean hasActivities() {
try {
for (ActivityContextHandle handle : sleeContainer
.getActivityContextFactory()
.getAllActivityContextsHandles()) {
if (handle.getActivityType() == ActivityType.RA) {
ResourceAdaptorActivityContextHandle raHandle = (ResourceAdaptorActivityContextHandle) handle;
if (raHandle.getResourceAdaptorEntity().equals(this)) {
logger.debug("**** AllActivityContextsHandles: "+sleeContainer
.getActivityContextFactory()
.getAllActivityContextsHandles());
if (logger.isDebugEnabled()) {
logger.debug("RA entity "+name+" has (at least) activity "+handle.getActivityHandle());
}
//return true;
logger.warn("WORKAROUND USAGE: ENDING RESOURCE ADAPTOR ACTIVITIES");
sleeContainer.getActivityContextFactory().WAremove("RA");
return false;
}
}
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
return false;
} } | public class class_name {
private boolean hasActivities() {
try {
for (ActivityContextHandle handle : sleeContainer
.getActivityContextFactory()
.getAllActivityContextsHandles()) {
if (handle.getActivityType() == ActivityType.RA) {
ResourceAdaptorActivityContextHandle raHandle = (ResourceAdaptorActivityContextHandle) handle;
if (raHandle.getResourceAdaptorEntity().equals(this)) {
logger.debug("**** AllActivityContextsHandles: "+sleeContainer
.getActivityContextFactory()
.getAllActivityContextsHandles());
// depends on control dependency: [if], data = [none]
if (logger.isDebugEnabled()) {
logger.debug("RA entity "+name+" has (at least) activity "+handle.getActivityHandle());
// depends on control dependency: [if], data = [none]
}
//return true;
logger.warn("WORKAROUND USAGE: ENDING RESOURCE ADAPTOR ACTIVITIES");
// depends on control dependency: [if], data = [none]
sleeContainer.getActivityContextFactory().WAremove("RA");
// depends on control dependency: [if], data = [none]
return false;
// depends on control dependency: [if], data = [none]
}
}
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
// depends on control dependency: [catch], data = [none]
return false;
} } |
public class class_name {
private void ensurePowerOfTwo(String parameter, int number) {
if (Integer.bitCount(number) > 1) {
if (log.isLoggable(Level.WARNING)) {
log.warning("Parameter '" + parameter + "' should be power of two but was " + number);
}
}
} } | public class class_name {
private void ensurePowerOfTwo(String parameter, int number) {
if (Integer.bitCount(number) > 1) {
if (log.isLoggable(Level.WARNING)) {
log.warning("Parameter '" + parameter + "' should be power of two but was " + number); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public <T> T fromDBObject(final Datastore datastore, final Class<T> entityClass, final DBObject dbObject, final EntityCache cache) {
if (!entityClass.isInterface() && !mapper.isMapped(entityClass)) {
throw new MappingException("Trying to map to an unmapped class: " + entityClass.getName());
}
try {
return mapper.fromDBObject(datastore, entityClass, dbObject, cache);
} catch (Exception e) {
throw new MappingException("Could not map entity from DBObject", e);
}
} } | public class class_name {
public <T> T fromDBObject(final Datastore datastore, final Class<T> entityClass, final DBObject dbObject, final EntityCache cache) {
if (!entityClass.isInterface() && !mapper.isMapped(entityClass)) {
throw new MappingException("Trying to map to an unmapped class: " + entityClass.getName());
}
try {
return mapper.fromDBObject(datastore, entityClass, dbObject, cache); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new MappingException("Could not map entity from DBObject", e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public static boolean foundFunctionInGroupHeader(ReportLayout layout, String groupName) {
List<Band> groupHeaderBands = layout.getGroupHeaderBands();
for (Band band : groupHeaderBands) {
if (band.getName().equals(ReportLayout.GROUP_HEADER_BAND_NAME_PREFIX + groupName)) {
return foundFunctionInBand(band);
}
}
return false;
} } | public class class_name {
public static boolean foundFunctionInGroupHeader(ReportLayout layout, String groupName) {
List<Band> groupHeaderBands = layout.getGroupHeaderBands();
for (Band band : groupHeaderBands) {
if (band.getName().equals(ReportLayout.GROUP_HEADER_BAND_NAME_PREFIX + groupName)) {
return foundFunctionInBand(band); // depends on control dependency: [if], data = [none]
}
}
return false;
} } |
public class class_name {
private void parseDateHeaderRange(Map<Object, Object> props) {
// @313642
Object value = props.get(HttpConfigConstants.PROPNAME_DATE_HEADER_RANGE);
if (null != value) {
try {
this.lDateHeaderRange = minLimit(convertLong(value), 0L);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: date header range is " + value);
}
} catch (NumberFormatException nfe) {
FFDCFilter.processException(nfe, getClass().getName() + ".parseDateHeaderRange", "1");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Invalid date header range; " + value);
}
}
}
} } | public class class_name {
private void parseDateHeaderRange(Map<Object, Object> props) {
// @313642
Object value = props.get(HttpConfigConstants.PROPNAME_DATE_HEADER_RANGE);
if (null != value) {
try {
this.lDateHeaderRange = minLimit(convertLong(value), 0L); // depends on control dependency: [try], data = [none]
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: date header range is " + value); // depends on control dependency: [if], data = [none]
}
} catch (NumberFormatException nfe) {
FFDCFilter.processException(nfe, getClass().getName() + ".parseDateHeaderRange", "1");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Invalid date header range; " + value); // depends on control dependency: [if], data = [none]
}
} // depends on control dependency: [catch], data = [none]
}
} } |
public class class_name {
@SuppressWarnings("unchecked")
public static <T> T castToType(final Class<T> type, final Object val) throws DevFailed {
T result;
if (val == null) {
result = null;
} else if (type.isAssignableFrom(val.getClass())) {
result = (T) val;
} else {
LOGGER.debug("converting {} to {}", val.getClass().getCanonicalName(), type.getCanonicalName());
// if input is not an array and we want to convert it to an array.
// Put
// the value in an array
Object array = val;
if (!val.getClass().isArray() && type.isArray()) {
array = Array.newInstance(val.getClass(), 1);
Array.set(array, 0, val);
}
final Transmorph transmorph = new Transmorph(creatConv());
try {
result = transmorph.convert(array, type);
} catch (final ConverterException e) {
LOGGER.error("convertion error", e);
throw DevFailedUtils.newDevFailed(e);
}
}
return result;
} } | public class class_name {
@SuppressWarnings("unchecked")
public static <T> T castToType(final Class<T> type, final Object val) throws DevFailed {
T result;
if (val == null) {
result = null;
} else if (type.isAssignableFrom(val.getClass())) {
result = (T) val;
} else {
LOGGER.debug("converting {} to {}", val.getClass().getCanonicalName(), type.getCanonicalName());
// if input is not an array and we want to convert it to an array.
// Put
// the value in an array
Object array = val;
if (!val.getClass().isArray() && type.isArray()) {
array = Array.newInstance(val.getClass(), 1); // depends on control dependency: [if], data = [none]
Array.set(array, 0, val); // depends on control dependency: [if], data = [none]
}
final Transmorph transmorph = new Transmorph(creatConv());
try {
result = transmorph.convert(array, type); // depends on control dependency: [try], data = [none]
} catch (final ConverterException e) {
LOGGER.error("convertion error", e);
throw DevFailedUtils.newDevFailed(e);
} // depends on control dependency: [catch], data = [none]
}
return result;
} } |
public class class_name {
private void initialize(Chunk chunk)
{
final String mName = "initialize";
if(logger.isLoggable(Level.FINER))
logger.entering(className, mName);
try
{
if (chunk.getSkipLimit() != null){
_skipLimit = Integer.parseInt(chunk.getSkipLimit());
if (_skipLimit < 0) {
throw new IllegalArgumentException("The skip-limit attribute on a chunk cannot be a negative value");
}
}
}
catch (NumberFormatException nfe)
{
throw new RuntimeException("NumberFormatException reading " + SKIP_COUNT, nfe);
}
// Read the include/exclude exceptions.
_skipIncludeExceptions = new HashSet<String>();
_skipExcludeExceptions = new HashSet<String>();
if (chunk.getSkippableExceptionClasses() != null) {
if (chunk.getSkippableExceptionClasses().getIncludeList() != null) {
List<ExceptionClassFilter.Include> includes = chunk.getSkippableExceptionClasses().getIncludeList();
for (ExceptionClassFilter.Include include : includes) {
_skipIncludeExceptions.add(include.getClazz().trim());
logger.finer("SKIPHANDLE: include: " + include.getClazz().trim());
}
if (_skipIncludeExceptions.size() == 0) {
logger.finer("SKIPHANDLE: include element not present");
}
}
}
if (chunk.getSkippableExceptionClasses() != null) {
if (chunk.getSkippableExceptionClasses().getExcludeList() != null) {
List<ExceptionClassFilter.Exclude> excludes = chunk.getSkippableExceptionClasses().getExcludeList();
for (ExceptionClassFilter.Exclude exclude : excludes) {
_skipExcludeExceptions.add(exclude.getClazz().trim());
logger.finer("SKIPHANDLE: exclude: " + exclude.getClazz().trim());
}
if (_skipExcludeExceptions.size() == 0) {
logger.finer("SKIPHANDLE: exclude element not present");
}
}
}
// Create the ExceptionMatcher Object
excMatcher = new ExceptionMatcher(_skipIncludeExceptions, _skipExcludeExceptions);
if (logger.isLoggable(Level.FINE))
logger.logp(Level.FINE, className, mName, "added include exception " + _skipIncludeExceptions
+ "; added exclude exception " + _skipExcludeExceptions);
if(logger.isLoggable(Level.FINER))
logger.exiting(className, mName, this.toString());
} } | public class class_name {
private void initialize(Chunk chunk)
{
final String mName = "initialize";
if(logger.isLoggable(Level.FINER))
logger.entering(className, mName);
try
{
if (chunk.getSkipLimit() != null){
_skipLimit = Integer.parseInt(chunk.getSkipLimit()); // depends on control dependency: [if], data = [(chunk.getSkipLimit()]
if (_skipLimit < 0) {
throw new IllegalArgumentException("The skip-limit attribute on a chunk cannot be a negative value");
}
}
}
catch (NumberFormatException nfe)
{
throw new RuntimeException("NumberFormatException reading " + SKIP_COUNT, nfe);
} // depends on control dependency: [catch], data = [none]
// Read the include/exclude exceptions.
_skipIncludeExceptions = new HashSet<String>();
_skipExcludeExceptions = new HashSet<String>();
if (chunk.getSkippableExceptionClasses() != null) {
if (chunk.getSkippableExceptionClasses().getIncludeList() != null) {
List<ExceptionClassFilter.Include> includes = chunk.getSkippableExceptionClasses().getIncludeList();
for (ExceptionClassFilter.Include include : includes) {
_skipIncludeExceptions.add(include.getClazz().trim()); // depends on control dependency: [for], data = [include]
logger.finer("SKIPHANDLE: include: " + include.getClazz().trim()); // depends on control dependency: [for], data = [include]
}
if (_skipIncludeExceptions.size() == 0) {
logger.finer("SKIPHANDLE: include element not present"); // depends on control dependency: [if], data = [none]
}
}
}
if (chunk.getSkippableExceptionClasses() != null) {
if (chunk.getSkippableExceptionClasses().getExcludeList() != null) {
List<ExceptionClassFilter.Exclude> excludes = chunk.getSkippableExceptionClasses().getExcludeList();
for (ExceptionClassFilter.Exclude exclude : excludes) {
_skipExcludeExceptions.add(exclude.getClazz().trim()); // depends on control dependency: [for], data = [exclude]
logger.finer("SKIPHANDLE: exclude: " + exclude.getClazz().trim()); // depends on control dependency: [for], data = [exclude]
}
if (_skipExcludeExceptions.size() == 0) {
logger.finer("SKIPHANDLE: exclude element not present"); // depends on control dependency: [if], data = [none]
}
}
}
// Create the ExceptionMatcher Object
excMatcher = new ExceptionMatcher(_skipIncludeExceptions, _skipExcludeExceptions);
if (logger.isLoggable(Level.FINE))
logger.logp(Level.FINE, className, mName, "added include exception " + _skipIncludeExceptions
+ "; added exclude exception " + _skipExcludeExceptions);
if(logger.isLoggable(Level.FINER))
logger.exiting(className, mName, this.toString());
} } |
public class class_name {
protected void removeLastFieldSeparator(final StringBuffer buffer) {
final int len = buffer.length();
final int sepLen = fieldSeparator.length();
if (len > 0 && sepLen > 0 && len >= sepLen) {
boolean match = true;
for (int i = 0; i < sepLen; i++) {
if (buffer.charAt(len - 1 - i) != fieldSeparator.charAt(sepLen - 1 - i)) {
match = false;
break;
}
}
if (match) {
buffer.setLength(len - sepLen);
}
}
} } | public class class_name {
protected void removeLastFieldSeparator(final StringBuffer buffer) {
final int len = buffer.length();
final int sepLen = fieldSeparator.length();
if (len > 0 && sepLen > 0 && len >= sepLen) {
boolean match = true;
for (int i = 0; i < sepLen; i++) {
if (buffer.charAt(len - 1 - i) != fieldSeparator.charAt(sepLen - 1 - i)) {
match = false; // depends on control dependency: [if], data = [none]
break;
}
}
if (match) {
buffer.setLength(len - sepLen); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public int compareTo(ReadableDuration other) {
long thisMillis = this.getMillis();
long otherMillis = other.getMillis();
// cannot do (thisMillis - otherMillis) as it can overflow
if (thisMillis < otherMillis) {
return -1;
}
if (thisMillis > otherMillis) {
return 1;
}
return 0;
} } | public class class_name {
public int compareTo(ReadableDuration other) {
long thisMillis = this.getMillis();
long otherMillis = other.getMillis();
// cannot do (thisMillis - otherMillis) as it can overflow
if (thisMillis < otherMillis) {
return -1; // depends on control dependency: [if], data = [none]
}
if (thisMillis > otherMillis) {
return 1; // depends on control dependency: [if], data = [none]
}
return 0;
} } |
public class class_name {
public static ArrayList<Word> toUntaggedList(String... words) {
ArrayList<Word> sent = new ArrayList<Word>();
for (String str : words) {
sent.add(new Word(str));
}
return sent;
} } | public class class_name {
public static ArrayList<Word> toUntaggedList(String... words) {
ArrayList<Word> sent = new ArrayList<Word>();
for (String str : words) {
sent.add(new Word(str));
// depends on control dependency: [for], data = [str]
}
return sent;
} } |
public class class_name {
public List<SecurityRoleType<WebAppDescriptor>> getAllSecurityRole()
{
List<SecurityRoleType<WebAppDescriptor>> list = new ArrayList<SecurityRoleType<WebAppDescriptor>>();
List<Node> nodeList = model.get("security-role");
for(Node node: nodeList)
{
SecurityRoleType<WebAppDescriptor> type = new SecurityRoleTypeImpl<WebAppDescriptor>(this, "security-role", model, node);
list.add(type);
}
return list;
} } | public class class_name {
public List<SecurityRoleType<WebAppDescriptor>> getAllSecurityRole()
{
List<SecurityRoleType<WebAppDescriptor>> list = new ArrayList<SecurityRoleType<WebAppDescriptor>>();
List<Node> nodeList = model.get("security-role");
for(Node node: nodeList)
{
SecurityRoleType<WebAppDescriptor> type = new SecurityRoleTypeImpl<WebAppDescriptor>(this, "security-role", model, node);
list.add(type); // depends on control dependency: [for], data = [none]
}
return list;
} } |
public class class_name {
@Override
public void dispose() {
if (this.disposed) {
return;
}
super.dispose();
// This call will block until all clients that still acquire access to the RocksDB instance have released it,
// so that we cannot release the native resources while clients are still working with it in parallel.
rocksDBResourceGuard.close();
// IMPORTANT: null reference to signal potential async checkpoint workers that the db was disposed, as
// working on the disposed object results in SEGFAULTS.
if (db != null) {
IOUtils.closeQuietly(writeBatchWrapper);
// Metric collection occurs on a background thread. When this method returns
// it is guaranteed that thr RocksDB reference has been invalidated
// and no more metric collection will be attempted against the database.
if (nativeMetricMonitor != null) {
nativeMetricMonitor.close();
}
List<ColumnFamilyOptions> columnFamilyOptions = new ArrayList<>(kvStateInformation.values().size());
// RocksDB's native memory management requires that *all* CFs (including default) are closed before the
// DB is closed. See:
// https://github.com/facebook/rocksdb/wiki/RocksJava-Basics#opening-a-database-with-column-families
// Start with default CF ...
RocksDBOperationUtils.addColumnFamilyOptionsToCloseLater(columnFamilyOptions, defaultColumnFamily);
IOUtils.closeQuietly(defaultColumnFamily);
// ... continue with the ones created by Flink...
for (RocksDbKvStateInfo kvStateInfo : kvStateInformation.values()) {
RocksDBOperationUtils.addColumnFamilyOptionsToCloseLater(columnFamilyOptions, kvStateInfo.columnFamilyHandle);
IOUtils.closeQuietly(kvStateInfo.columnFamilyHandle);
}
// ... and finally close the DB instance ...
IOUtils.closeQuietly(db);
columnFamilyOptions.forEach(IOUtils::closeQuietly);
IOUtils.closeQuietly(dbOptions);
IOUtils.closeQuietly(writeOptions);
ttlCompactFiltersManager.disposeAndClearRegisteredCompactionFactories();
kvStateInformation.clear();
cleanInstanceBasePath();
}
this.disposed = true;
} } | public class class_name {
@Override
public void dispose() {
if (this.disposed) {
return; // depends on control dependency: [if], data = [none]
}
super.dispose();
// This call will block until all clients that still acquire access to the RocksDB instance have released it,
// so that we cannot release the native resources while clients are still working with it in parallel.
rocksDBResourceGuard.close();
// IMPORTANT: null reference to signal potential async checkpoint workers that the db was disposed, as
// working on the disposed object results in SEGFAULTS.
if (db != null) {
IOUtils.closeQuietly(writeBatchWrapper); // depends on control dependency: [if], data = [none]
// Metric collection occurs on a background thread. When this method returns
// it is guaranteed that thr RocksDB reference has been invalidated
// and no more metric collection will be attempted against the database.
if (nativeMetricMonitor != null) {
nativeMetricMonitor.close(); // depends on control dependency: [if], data = [none]
}
List<ColumnFamilyOptions> columnFamilyOptions = new ArrayList<>(kvStateInformation.values().size());
// RocksDB's native memory management requires that *all* CFs (including default) are closed before the
// DB is closed. See:
// https://github.com/facebook/rocksdb/wiki/RocksJava-Basics#opening-a-database-with-column-families
// Start with default CF ...
RocksDBOperationUtils.addColumnFamilyOptionsToCloseLater(columnFamilyOptions, defaultColumnFamily); // depends on control dependency: [if], data = [none]
IOUtils.closeQuietly(defaultColumnFamily); // depends on control dependency: [if], data = [none]
// ... continue with the ones created by Flink...
for (RocksDbKvStateInfo kvStateInfo : kvStateInformation.values()) {
RocksDBOperationUtils.addColumnFamilyOptionsToCloseLater(columnFamilyOptions, kvStateInfo.columnFamilyHandle); // depends on control dependency: [for], data = [kvStateInfo]
IOUtils.closeQuietly(kvStateInfo.columnFamilyHandle); // depends on control dependency: [for], data = [kvStateInfo]
}
// ... and finally close the DB instance ...
IOUtils.closeQuietly(db); // depends on control dependency: [if], data = [(db]
columnFamilyOptions.forEach(IOUtils::closeQuietly); // depends on control dependency: [if], data = [none]
IOUtils.closeQuietly(dbOptions); // depends on control dependency: [if], data = [(db]
IOUtils.closeQuietly(writeOptions); // depends on control dependency: [if], data = [none]
ttlCompactFiltersManager.disposeAndClearRegisteredCompactionFactories(); // depends on control dependency: [if], data = [none]
kvStateInformation.clear(); // depends on control dependency: [if], data = [none]
cleanInstanceBasePath(); // depends on control dependency: [if], data = [none]
}
this.disposed = true;
} } |
public class class_name {
public boolean matches(long checkWidth, long checkHeight) {
if (checkWidth != 0 && checkWidth != getWidth()) {
return false;
}
if (checkHeight != 0 && checkHeight != getHeight()) {
return false;
}
return true;
} } | public class class_name {
public boolean matches(long checkWidth, long checkHeight) {
if (checkWidth != 0 && checkWidth != getWidth()) {
return false; // depends on control dependency: [if], data = [none]
}
if (checkHeight != 0 && checkHeight != getHeight()) {
return false; // depends on control dependency: [if], data = [none]
}
return true;
} } |
public class class_name {
public void closeRecorders() {
try {
this.ris.closeRecorder();
this.ros.closeRecorder();
} catch (IOException e) {
DevUtils.warnHandle(e, "Convert to runtime exception?");
}
} } | public class class_name {
public void closeRecorders() {
try {
this.ris.closeRecorder(); // depends on control dependency: [try], data = [none]
this.ros.closeRecorder(); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
DevUtils.warnHandle(e, "Convert to runtime exception?");
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
@Override
public boolean isKeyColumn(String columnName) {
for ( String keyColumName : getColumnNames() ) {
if ( keyColumName.equals( columnName ) ) {
return true;
}
}
return false;
} } | public class class_name {
@Override
public boolean isKeyColumn(String columnName) {
for ( String keyColumName : getColumnNames() ) {
if ( keyColumName.equals( columnName ) ) {
return true; // depends on control dependency: [if], data = [none]
}
}
return false;
} } |
public class class_name {
public static String formatJsonDate(Instant value) {
if (value == null) {
return null;
}
return JSON_DATETIME_FORMAT.format(value.atOffset(ZoneOffset.UTC));
} } | public class class_name {
public static String formatJsonDate(Instant value) {
if (value == null) {
return null; // depends on control dependency: [if], data = [none]
}
return JSON_DATETIME_FORMAT.format(value.atOffset(ZoneOffset.UTC));
} } |
public class class_name {
public JavaSrcTextBuffer printLinesWithIndent(final String text) {
final String[] splitted = text.split("\n", -1);
for (final String aSplitted : splitted) {
this.indent().println(aSplitted);
}
return this;
} } | public class class_name {
public JavaSrcTextBuffer printLinesWithIndent(final String text) {
final String[] splitted = text.split("\n", -1);
for (final String aSplitted : splitted) {
this.indent().println(aSplitted); // depends on control dependency: [for], data = [aSplitted]
}
return this;
} } |
public class class_name {
public static Expr.VariableAccess extractAssignedVariable(LVal lval) {
if (lval instanceof Expr.VariableAccess) {
return (Expr.VariableAccess) lval;
} else if (lval instanceof Expr.RecordAccess) {
Expr.RecordAccess e = (Expr.RecordAccess) lval;
return extractAssignedVariable((LVal) e.getOperand());
} else if (lval instanceof Expr.ArrayAccess) {
Expr.ArrayAccess e = (Expr.ArrayAccess) lval;
return extractAssignedVariable((LVal) e.getFirstOperand());
} else if (lval instanceof Expr.Dereference) {
return null;
} else {
syntaxError(lval, WyilFile.INVALID_LVAL_EXPRESSION);
return null; // dead code
}
} } | public class class_name {
public static Expr.VariableAccess extractAssignedVariable(LVal lval) {
if (lval instanceof Expr.VariableAccess) {
return (Expr.VariableAccess) lval; // depends on control dependency: [if], data = [none]
} else if (lval instanceof Expr.RecordAccess) {
Expr.RecordAccess e = (Expr.RecordAccess) lval;
return extractAssignedVariable((LVal) e.getOperand()); // depends on control dependency: [if], data = [none]
} else if (lval instanceof Expr.ArrayAccess) {
Expr.ArrayAccess e = (Expr.ArrayAccess) lval;
return extractAssignedVariable((LVal) e.getFirstOperand()); // depends on control dependency: [if], data = [none]
} else if (lval instanceof Expr.Dereference) {
return null; // depends on control dependency: [if], data = [none]
} else {
syntaxError(lval, WyilFile.INVALID_LVAL_EXPRESSION); // depends on control dependency: [if], data = [none]
return null; // dead code // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static <T> void quickSelect(List<? extends T> data, Comparator<? super T> comparator, int start, int end, int rank) {
while(true) {
// Optimization for small arrays
// This also ensures a minimum size below
if(start + SMALL > end) {
insertionSort(data, comparator, start, end);
return;
}
// Best of 5 pivot picking:
// Choose pivots by looking at five candidates.
final int len = end - start;
final int seventh = (len >> 3) + (len >> 6) + 1;
final int m3 = (start + end) >> 1; // middle
final int m2 = m3 - seventh;
final int m1 = m2 - seventh;
final int m4 = m3 + seventh;
final int m5 = m4 + seventh;
// Explicit (and optimal) sorting network for 5 elements
// See Knuth for details.
if(comparator.compare(data.get(m1), data.get(m2)) > 0) {
swap(data, m1, m2);
}
if(comparator.compare(data.get(m1), data.get(m3)) > 0) {
swap(data, m1, m3);
}
if(comparator.compare(data.get(m2), data.get(m3)) > 0) {
swap(data, m2, m3);
}
if(comparator.compare(data.get(m4), data.get(m5)) > 0) {
swap(data, m4, m5);
}
if(comparator.compare(data.get(m1), data.get(m4)) > 0) {
swap(data, m1, m4);
}
if(comparator.compare(data.get(m3), data.get(m4)) > 0) {
swap(data, m3, m4);
}
if(comparator.compare(data.get(m2), data.get(m5)) > 0) {
swap(data, m2, m5);
}
if(comparator.compare(data.get(m2), data.get(m3)) > 0) {
swap(data, m2, m3);
}
if(comparator.compare(data.get(m4), data.get(m5)) > 0) {
swap(data, m4, m5);
}
int best = bestPivot(rank, m1, m2, m3, m4, m5);
final T pivot = data.get(best);
// Move middle element out of the way, just before end
// (Since we already know that "end" is bigger)
swap(data, best, end - 1);
// Begin partitioning
int i = start, j = end - 2;
// This is classic quicksort stuff
while(true) {
while(i <= j && comparator.compare(data.get(i), pivot) <= 0) {
i++;
}
while(j >= i && comparator.compare(data.get(j), pivot) >= 0) {
j--;
}
if(i >= j) {
break;
}
swap(data, i, j);
}
// Move pivot (former middle element) back into the appropriate place
swap(data, i, end - 1);
// Skip duplicates to narrow down the search interval:
while(rank < i && comparator.compare(data.get(i - 1), pivot) == 0) {
--i;
}
while(rank > i && comparator.compare(data.get(i + 1), pivot) == 0) {
++i;
}
// In contrast to quicksort, we only need to recurse into the half we are
// interested in. Instead of recursion we now use iteration.
if(rank < i) {
end = i;
}
else if(rank > i) {
start = i + 1;
}
else {
break;
}
} // Loop until rank==i
} } | public class class_name {
public static <T> void quickSelect(List<? extends T> data, Comparator<? super T> comparator, int start, int end, int rank) {
while(true) {
// Optimization for small arrays
// This also ensures a minimum size below
if(start + SMALL > end) {
insertionSort(data, comparator, start, end); // depends on control dependency: [if], data = [end)]
return; // depends on control dependency: [if], data = [none]
}
// Best of 5 pivot picking:
// Choose pivots by looking at five candidates.
final int len = end - start;
final int seventh = (len >> 3) + (len >> 6) + 1;
final int m3 = (start + end) >> 1; // middle
final int m2 = m3 - seventh;
final int m1 = m2 - seventh;
final int m4 = m3 + seventh;
final int m5 = m4 + seventh;
// Explicit (and optimal) sorting network for 5 elements
// See Knuth for details.
if(comparator.compare(data.get(m1), data.get(m2)) > 0) {
swap(data, m1, m2); // depends on control dependency: [if], data = [none]
}
if(comparator.compare(data.get(m1), data.get(m3)) > 0) {
swap(data, m1, m3); // depends on control dependency: [if], data = [none]
}
if(comparator.compare(data.get(m2), data.get(m3)) > 0) {
swap(data, m2, m3); // depends on control dependency: [if], data = [none]
}
if(comparator.compare(data.get(m4), data.get(m5)) > 0) {
swap(data, m4, m5); // depends on control dependency: [if], data = [none]
}
if(comparator.compare(data.get(m1), data.get(m4)) > 0) {
swap(data, m1, m4); // depends on control dependency: [if], data = [none]
}
if(comparator.compare(data.get(m3), data.get(m4)) > 0) {
swap(data, m3, m4); // depends on control dependency: [if], data = [none]
}
if(comparator.compare(data.get(m2), data.get(m5)) > 0) {
swap(data, m2, m5); // depends on control dependency: [if], data = [none]
}
if(comparator.compare(data.get(m2), data.get(m3)) > 0) {
swap(data, m2, m3); // depends on control dependency: [if], data = [none]
}
if(comparator.compare(data.get(m4), data.get(m5)) > 0) {
swap(data, m4, m5); // depends on control dependency: [if], data = [none]
}
int best = bestPivot(rank, m1, m2, m3, m4, m5);
final T pivot = data.get(best);
// Move middle element out of the way, just before end
// (Since we already know that "end" is bigger)
swap(data, best, end - 1); // depends on control dependency: [while], data = [none]
// Begin partitioning
int i = start, j = end - 2;
// This is classic quicksort stuff
while(true) {
while(i <= j && comparator.compare(data.get(i), pivot) <= 0) {
i++; // depends on control dependency: [while], data = [none]
}
while(j >= i && comparator.compare(data.get(j), pivot) >= 0) {
j--; // depends on control dependency: [while], data = [none]
}
if(i >= j) {
break;
}
swap(data, i, j); // depends on control dependency: [while], data = [none]
}
// Move pivot (former middle element) back into the appropriate place
swap(data, i, end - 1); // depends on control dependency: [while], data = [none]
// Skip duplicates to narrow down the search interval:
while(rank < i && comparator.compare(data.get(i - 1), pivot) == 0) {
--i; // depends on control dependency: [while], data = [none]
}
while(rank > i && comparator.compare(data.get(i + 1), pivot) == 0) {
++i; // depends on control dependency: [while], data = [none]
}
// In contrast to quicksort, we only need to recurse into the half we are
// interested in. Instead of recursion we now use iteration.
if(rank < i) {
end = i; // depends on control dependency: [if], data = [none]
}
else if(rank > i) {
start = i + 1; // depends on control dependency: [if], data = [none]
}
else {
break;
}
} // Loop until rank==i
} } |
public class class_name {
public void sparsePrint(PrintStream stream) {
if (mSeries.isEmpty()) {
return;
}
long start = mSeries.firstKey();
stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano);
for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) {
stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue());
}
} } | public class class_name {
public void sparsePrint(PrintStream stream) {
if (mSeries.isEmpty()) {
return; // depends on control dependency: [if], data = [none]
}
long start = mSeries.firstKey();
stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano);
for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) {
stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue()); // depends on control dependency: [for], data = [entry]
}
} } |
public class class_name {
private Object getKey(CompositeType rowType, String key, String value) {
OpenType keyType = rowType.getType(key);
if (SimpleType.STRING == keyType) {
return value;
} else if (SimpleType.INTEGER == keyType) {
return Integer.parseInt(value);
} else if (SimpleType.LONG == keyType) {
return Long.parseLong(value);
} else if (SimpleType.SHORT == keyType) {
return Short.parseShort(value);
} else if (SimpleType.BYTE == keyType) {
return Byte.parseByte(value);
} else if (SimpleType.OBJECTNAME == keyType) {
try {
return new ObjectName(value);
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException("Can not convert " + value + " to an ObjectName",e);
}
} else {
throw new IllegalArgumentException("All keys must be a string, integer, long, short, byte or ObjectName type for accessing TabularData via a path. " +
"This is not the case for '"
+ key + "' which is of type " + keyType);
}
} } | public class class_name {
private Object getKey(CompositeType rowType, String key, String value) {
OpenType keyType = rowType.getType(key);
if (SimpleType.STRING == keyType) {
return value; // depends on control dependency: [if], data = [none]
} else if (SimpleType.INTEGER == keyType) {
return Integer.parseInt(value); // depends on control dependency: [if], data = [none]
} else if (SimpleType.LONG == keyType) {
return Long.parseLong(value); // depends on control dependency: [if], data = [none]
} else if (SimpleType.SHORT == keyType) {
return Short.parseShort(value); // depends on control dependency: [if], data = [none]
} else if (SimpleType.BYTE == keyType) {
return Byte.parseByte(value); // depends on control dependency: [if], data = [none]
} else if (SimpleType.OBJECTNAME == keyType) {
try {
return new ObjectName(value); // depends on control dependency: [try], data = [none]
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException("Can not convert " + value + " to an ObjectName",e);
} // depends on control dependency: [catch], data = [none]
} else {
throw new IllegalArgumentException("All keys must be a string, integer, long, short, byte or ObjectName type for accessing TabularData via a path. " +
"This is not the case for '"
+ key + "' which is of type " + keyType);
}
} } |
public class class_name {
public void shutdown()
{
try {
if (m_shutdownHook != null) {
synchronized (m_shutdownHook) {
if (m_shutdownHook != null) {
LOG.debug("Shutdown in progress...");
Runtime.getRuntime().removeShutdownHook( m_shutdownHook );
m_frameworkProcess = null;
m_shutdownHook.run();
m_shutdownHook = null;
LOG.info( "Platform has been shutdown." );
}
}
}
}
catch( IllegalStateException ignore )
{
// just ignore
}
} } | public class class_name {
public void shutdown()
{
try {
if (m_shutdownHook != null) {
synchronized (m_shutdownHook) { // depends on control dependency: [if], data = [(m_shutdownHook]
if (m_shutdownHook != null) {
LOG.debug("Shutdown in progress..."); // depends on control dependency: [if], data = [none]
Runtime.getRuntime().removeShutdownHook( m_shutdownHook ); // depends on control dependency: [if], data = [none]
m_frameworkProcess = null; // depends on control dependency: [if], data = [none]
m_shutdownHook.run(); // depends on control dependency: [if], data = [none]
m_shutdownHook = null; // depends on control dependency: [if], data = [none]
LOG.info( "Platform has been shutdown." ); // depends on control dependency: [if], data = [none]
}
}
}
}
catch( IllegalStateException ignore )
{
// just ignore
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public InterceptorBindingType<AssemblyDescriptorType<T>> getOrCreateInterceptorBinding()
{
List<Node> nodeList = childNode.get("interceptor-binding");
if (nodeList != null && nodeList.size() > 0)
{
return new InterceptorBindingTypeImpl<AssemblyDescriptorType<T>>(this, "interceptor-binding", childNode, nodeList.get(0));
}
return createInterceptorBinding();
} } | public class class_name {
public InterceptorBindingType<AssemblyDescriptorType<T>> getOrCreateInterceptorBinding()
{
List<Node> nodeList = childNode.get("interceptor-binding");
if (nodeList != null && nodeList.size() > 0)
{
return new InterceptorBindingTypeImpl<AssemblyDescriptorType<T>>(this, "interceptor-binding", childNode, nodeList.get(0)); // depends on control dependency: [if], data = [none]
}
return createInterceptorBinding();
} } |
public class class_name {
public void marshall(ListTagsRequest listTagsRequest, ProtocolMarshaller protocolMarshaller) {
if (listTagsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(listTagsRequest.getResourceArn(), RESOURCEARN_BINDING);
protocolMarshaller.marshall(listTagsRequest.getMaxResults(), MAXRESULTS_BINDING);
protocolMarshaller.marshall(listTagsRequest.getNextToken(), NEXTTOKEN_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(ListTagsRequest listTagsRequest, ProtocolMarshaller protocolMarshaller) {
if (listTagsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(listTagsRequest.getResourceArn(), RESOURCEARN_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(listTagsRequest.getMaxResults(), MAXRESULTS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(listTagsRequest.getNextToken(), NEXTTOKEN_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public List<ServerRedirect> getServerMappings() {
ArrayList<ServerRedirect> servers = new ArrayList<ServerRedirect>();
try {
JSONObject response = new JSONObject(doGet(BASE_SERVER, null));
JSONArray serverArray = response.getJSONArray("servers");
for (int i = 0; i < serverArray.length(); i++) {
JSONObject jsonServer = serverArray.getJSONObject(i);
ServerRedirect server = getServerRedirectFromJSON(jsonServer);
if (server != null) {
servers.add(server);
}
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return servers;
} } | public class class_name {
public List<ServerRedirect> getServerMappings() {
ArrayList<ServerRedirect> servers = new ArrayList<ServerRedirect>();
try {
JSONObject response = new JSONObject(doGet(BASE_SERVER, null));
JSONArray serverArray = response.getJSONArray("servers");
for (int i = 0; i < serverArray.length(); i++) {
JSONObject jsonServer = serverArray.getJSONObject(i);
ServerRedirect server = getServerRedirectFromJSON(jsonServer);
if (server != null) {
servers.add(server); // depends on control dependency: [if], data = [(server]
}
}
} catch (Exception e) {
e.printStackTrace();
return null;
} // depends on control dependency: [catch], data = [none]
return servers;
} } |
public class class_name {
public static boolean showUserPoolInfo(
String user,
Set<String> userFilterSet, PoolInfo poolInfo,
Set<String> poolGroupFilterSet, Set<PoolInfo> poolInfoFilterSet) {
boolean showUser = false;
if (userFilterSet.isEmpty() || userFilterSet.contains(user)) {
showUser = true;
}
return showUser &&
showPoolInfo(poolInfo, poolGroupFilterSet, poolInfoFilterSet);
} } | public class class_name {
public static boolean showUserPoolInfo(
String user,
Set<String> userFilterSet, PoolInfo poolInfo,
Set<String> poolGroupFilterSet, Set<PoolInfo> poolInfoFilterSet) {
boolean showUser = false;
if (userFilterSet.isEmpty() || userFilterSet.contains(user)) {
showUser = true; // depends on control dependency: [if], data = [none]
}
return showUser &&
showPoolInfo(poolInfo, poolGroupFilterSet, poolInfoFilterSet);
} } |
public class class_name {
public void marshall(CreateReplicationInstanceRequest createReplicationInstanceRequest, ProtocolMarshaller protocolMarshaller) {
if (createReplicationInstanceRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(createReplicationInstanceRequest.getReplicationInstanceIdentifier(), REPLICATIONINSTANCEIDENTIFIER_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getAllocatedStorage(), ALLOCATEDSTORAGE_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getReplicationInstanceClass(), REPLICATIONINSTANCECLASS_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getVpcSecurityGroupIds(), VPCSECURITYGROUPIDS_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getAvailabilityZone(), AVAILABILITYZONE_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getReplicationSubnetGroupIdentifier(), REPLICATIONSUBNETGROUPIDENTIFIER_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getPreferredMaintenanceWindow(), PREFERREDMAINTENANCEWINDOW_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getMultiAZ(), MULTIAZ_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getEngineVersion(), ENGINEVERSION_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getAutoMinorVersionUpgrade(), AUTOMINORVERSIONUPGRADE_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getTags(), TAGS_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getKmsKeyId(), KMSKEYID_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getPubliclyAccessible(), PUBLICLYACCESSIBLE_BINDING);
protocolMarshaller.marshall(createReplicationInstanceRequest.getDnsNameServers(), DNSNAMESERVERS_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(CreateReplicationInstanceRequest createReplicationInstanceRequest, ProtocolMarshaller protocolMarshaller) {
if (createReplicationInstanceRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(createReplicationInstanceRequest.getReplicationInstanceIdentifier(), REPLICATIONINSTANCEIDENTIFIER_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getAllocatedStorage(), ALLOCATEDSTORAGE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getReplicationInstanceClass(), REPLICATIONINSTANCECLASS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getVpcSecurityGroupIds(), VPCSECURITYGROUPIDS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getAvailabilityZone(), AVAILABILITYZONE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getReplicationSubnetGroupIdentifier(), REPLICATIONSUBNETGROUPIDENTIFIER_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getPreferredMaintenanceWindow(), PREFERREDMAINTENANCEWINDOW_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getMultiAZ(), MULTIAZ_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getEngineVersion(), ENGINEVERSION_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getAutoMinorVersionUpgrade(), AUTOMINORVERSIONUPGRADE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getTags(), TAGS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getKmsKeyId(), KMSKEYID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getPubliclyAccessible(), PUBLICLYACCESSIBLE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(createReplicationInstanceRequest.getDnsNameServers(), DNSNAMESERVERS_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private static String lookupStorageServiceByApp(RESTClient restClient, String applicationName) {
Utils.require(applicationName != null, "Missing application name");
if (applicationName != null) {
ApplicationDefinition appDef = Command.getAppDef(restClient, applicationName);
Utils.require(appDef != null, "Unknown application: %s", applicationName);
return appDef.getStorageService();
}
return null;
} } | public class class_name {
private static String lookupStorageServiceByApp(RESTClient restClient, String applicationName) {
Utils.require(applicationName != null, "Missing application name");
if (applicationName != null) {
ApplicationDefinition appDef = Command.getAppDef(restClient, applicationName);
Utils.require(appDef != null, "Unknown application: %s", applicationName); // depends on control dependency: [if], data = [none]
return appDef.getStorageService(); // depends on control dependency: [if], data = [none]
}
return null;
} } |
public class class_name {
@Override
public void initUpstream()
{
for (Entity entity : interaction.getParticipant())
{
addToUpstream(entity, getGraph());
}
for (Control control : interaction.getControlledOf())
{
addToUpstream(control, getGraph());
}
} } | public class class_name {
@Override
public void initUpstream()
{
for (Entity entity : interaction.getParticipant())
{
addToUpstream(entity, getGraph());
// depends on control dependency: [for], data = [entity]
}
for (Control control : interaction.getControlledOf())
{
addToUpstream(control, getGraph());
// depends on control dependency: [for], data = [control]
}
} } |
public class class_name {
public static List<WayDataBlock> encode(List<WayDataBlock> blocks, Encoding encoding) {
if (blocks == null) {
return null;
}
if (encoding == Encoding.NONE) {
return blocks;
}
List<WayDataBlock> results = new ArrayList<>();
for (WayDataBlock wayDataBlock : blocks) {
List<Integer> outer = mEncode(wayDataBlock.getOuterWay(), encoding);
List<List<Integer>> inner = null;
if (wayDataBlock.getInnerWays() != null) {
inner = new ArrayList<>();
for (List<Integer> list : wayDataBlock.getInnerWays()) {
inner.add(mEncode(list, encoding));
}
}
results.add(new WayDataBlock(outer, inner, encoding));
}
return results;
} } | public class class_name {
public static List<WayDataBlock> encode(List<WayDataBlock> blocks, Encoding encoding) {
if (blocks == null) {
return null; // depends on control dependency: [if], data = [none]
}
if (encoding == Encoding.NONE) {
return blocks; // depends on control dependency: [if], data = [none]
}
List<WayDataBlock> results = new ArrayList<>();
for (WayDataBlock wayDataBlock : blocks) {
List<Integer> outer = mEncode(wayDataBlock.getOuterWay(), encoding);
List<List<Integer>> inner = null;
if (wayDataBlock.getInnerWays() != null) {
inner = new ArrayList<>(); // depends on control dependency: [if], data = [none]
for (List<Integer> list : wayDataBlock.getInnerWays()) {
inner.add(mEncode(list, encoding)); // depends on control dependency: [for], data = [list]
}
}
results.add(new WayDataBlock(outer, inner, encoding)); // depends on control dependency: [for], data = [none]
}
return results;
} } |
public class class_name {
public static void print(Context context, long threshold) {
if (context == null) {
throw new IllegalArgumentException("Context argument cannot be null");
}
StatusManager sm = context.getStatusManager();
if (sm == null) {
ps.println("WARN: Context named \"" + context.getName()
+ "\" has no status manager");
} else {
print(sm, threshold);
}
} } | public class class_name {
public static void print(Context context, long threshold) {
if (context == null) {
throw new IllegalArgumentException("Context argument cannot be null");
}
StatusManager sm = context.getStatusManager();
if (sm == null) {
ps.println("WARN: Context named \"" + context.getName()
+ "\" has no status manager"); // depends on control dependency: [if], data = [none]
} else {
print(sm, threshold); // depends on control dependency: [if], data = [(sm]
}
} } |
public class class_name {
public boolean deletePassword(String account) {
int errorCode = deletePassword0(account.getBytes(UTF_8));
if (errorCode == OSSTATUS_SUCCESS) {
return true;
} else if (errorCode == OSSTATUS_NOT_FOUND) {
return false;
} else {
throw new JniException("Failed to delete password. Error code " + errorCode);
}
} } | public class class_name {
public boolean deletePassword(String account) {
int errorCode = deletePassword0(account.getBytes(UTF_8));
if (errorCode == OSSTATUS_SUCCESS) {
return true; // depends on control dependency: [if], data = [none]
} else if (errorCode == OSSTATUS_NOT_FOUND) {
return false; // depends on control dependency: [if], data = [none]
} else {
throw new JniException("Failed to delete password. Error code " + errorCode);
}
} } |
public class class_name {
protected String getRequestString(List<CmsResource> resources) {
String res = "?";
for (CmsResource resource : resources) {
res += "resources=" + resource.getStructureId().getStringValue() + "&";
}
return res.substring(0, res.length() - 1); //Remove last "&"
} } | public class class_name {
protected String getRequestString(List<CmsResource> resources) {
String res = "?";
for (CmsResource resource : resources) {
res += "resources=" + resource.getStructureId().getStringValue() + "&"; // depends on control dependency: [for], data = [resource]
}
return res.substring(0, res.length() - 1); //Remove last "&"
} } |
public class class_name {
public void addToolBarComponent(Component component) {
validateComponentNonNull(component);
if (component instanceof JButton) {
addButton((JButton) component);
} else if (component instanceof JToggleButton) {
addButton((JToggleButton) component);
} else {
getToolbar().add(component);
}
} } | public class class_name {
public void addToolBarComponent(Component component) {
validateComponentNonNull(component);
if (component instanceof JButton) {
addButton((JButton) component); // depends on control dependency: [if], data = [none]
} else if (component instanceof JToggleButton) {
addButton((JToggleButton) component); // depends on control dependency: [if], data = [none]
} else {
getToolbar().add(component); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void processEvent(EventObject event) {
if (event instanceof RequestEvent) {
processRequestEvent((RequestEvent) event);
} else {
LOG.error("invalid event type received: " + event.getClass().getName() + ": "
+ event.toString());
}
} } | public class class_name {
public void processEvent(EventObject event) {
if (event instanceof RequestEvent) {
processRequestEvent((RequestEvent) event); // depends on control dependency: [if], data = [none]
} else {
LOG.error("invalid event type received: " + event.getClass().getName() + ": "
+ event.toString()); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static int getLineNumber(Member member) {
if (!(member instanceof Method || member instanceof Constructor)) {
// We are not able to get this info for fields
return 0;
}
// BCEL is an optional dependency, if we cannot load it, simply return 0
if (!Reflections.isClassLoadable(BCEL_CLASS, WeldClassLoaderResourceLoader.INSTANCE)) {
return 0;
}
String classFile = member.getDeclaringClass().getName().replace('.', '/');
ClassLoaderResourceLoader classFileResourceLoader = new ClassLoaderResourceLoader(member.getDeclaringClass().getClassLoader());
InputStream in = null;
try {
URL classFileUrl = classFileResourceLoader.getResource(classFile + ".class");
if (classFileUrl == null) {
// The class file is not available
return 0;
}
in = classFileUrl.openStream();
ClassParser cp = new ClassParser(in, classFile);
JavaClass javaClass = cp.parse();
// First get all declared methods and constructors
// Note that in bytecode constructor is translated into a method
org.apache.bcel.classfile.Method[] methods = javaClass.getMethods();
org.apache.bcel.classfile.Method match = null;
String signature;
String name;
if (member instanceof Method) {
signature = DescriptorUtils.methodDescriptor((Method) member);
name = member.getName();
} else if (member instanceof Constructor) {
signature = DescriptorUtils.makeDescriptor((Constructor<?>) member);
name = INIT_METHOD_NAME;
} else {
return 0;
}
for (org.apache.bcel.classfile.Method method : methods) {
// Matching method must have the same name, modifiers and signature
if (method.getName().equals(name)
&& member.getModifiers() == method.getModifiers()
&& method.getSignature().equals(signature)) {
match = method;
}
}
if (match != null) {
// If a method is found, try to obtain the optional LineNumberTable attribute
LineNumberTable lineNumberTable = match.getLineNumberTable();
if (lineNumberTable != null) {
int line = lineNumberTable.getSourceLine(0);
return line == -1 ? 0 : line;
}
}
// No suitable method found
return 0;
} catch (Throwable t) {
return 0;
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
return 0;
}
}
}
} } | public class class_name {
public static int getLineNumber(Member member) {
if (!(member instanceof Method || member instanceof Constructor)) {
// We are not able to get this info for fields
return 0; // depends on control dependency: [if], data = [none]
}
// BCEL is an optional dependency, if we cannot load it, simply return 0
if (!Reflections.isClassLoadable(BCEL_CLASS, WeldClassLoaderResourceLoader.INSTANCE)) {
return 0; // depends on control dependency: [if], data = [none]
}
String classFile = member.getDeclaringClass().getName().replace('.', '/');
ClassLoaderResourceLoader classFileResourceLoader = new ClassLoaderResourceLoader(member.getDeclaringClass().getClassLoader());
InputStream in = null;
try {
URL classFileUrl = classFileResourceLoader.getResource(classFile + ".class");
if (classFileUrl == null) {
// The class file is not available
return 0; // depends on control dependency: [if], data = [none]
}
in = classFileUrl.openStream(); // depends on control dependency: [try], data = [none]
ClassParser cp = new ClassParser(in, classFile);
JavaClass javaClass = cp.parse();
// First get all declared methods and constructors
// Note that in bytecode constructor is translated into a method
org.apache.bcel.classfile.Method[] methods = javaClass.getMethods();
org.apache.bcel.classfile.Method match = null;
String signature;
String name;
if (member instanceof Method) {
signature = DescriptorUtils.methodDescriptor((Method) member); // depends on control dependency: [if], data = [none]
name = member.getName(); // depends on control dependency: [if], data = [none]
} else if (member instanceof Constructor) {
signature = DescriptorUtils.makeDescriptor((Constructor<?>) member); // depends on control dependency: [if], data = [none]
name = INIT_METHOD_NAME; // depends on control dependency: [if], data = [none]
} else {
return 0; // depends on control dependency: [if], data = [none]
}
for (org.apache.bcel.classfile.Method method : methods) {
// Matching method must have the same name, modifiers and signature
if (method.getName().equals(name)
&& member.getModifiers() == method.getModifiers()
&& method.getSignature().equals(signature)) {
match = method; // depends on control dependency: [if], data = [none]
}
}
if (match != null) {
// If a method is found, try to obtain the optional LineNumberTable attribute
LineNumberTable lineNumberTable = match.getLineNumberTable();
if (lineNumberTable != null) {
int line = lineNumberTable.getSourceLine(0);
return line == -1 ? 0 : line; // depends on control dependency: [if], data = [none]
}
}
// No suitable method found
return 0; // depends on control dependency: [try], data = [none]
} catch (Throwable t) {
return 0;
} finally { // depends on control dependency: [catch], data = [none]
if (in != null) {
try {
in.close(); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
return 0;
} // depends on control dependency: [catch], data = [none]
}
}
} } |
public class class_name {
private static X509Certificate getReqSigCert(Message message) {
List<WSHandlerResult> results =
CastUtils.cast((List<?>)
message.getExchange().getInMessage().get(WSHandlerConstants.RECV_RESULTS));
if (results == null) {
return null;
}
/*
* Scan the results for a matching actor. Use results only if the
* receiving Actor and the sending Actor match.
*/
for (WSHandlerResult rResult : results) {
List<WSSecurityEngineResult> wsSecEngineResults = rResult
.getResults();
/*
* Scan the results for the first Signature action. Use the
* certificate of this Signature to set the certificate for the
* encryption action :-).
*/
for (WSSecurityEngineResult wser : wsSecEngineResults) {
Integer actInt = (Integer) wser
.get(WSSecurityEngineResult.TAG_ACTION);
if (actInt.intValue() == WSConstants.SIGN) {
return (X509Certificate) wser
.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
}
}
}
return null;
} } | public class class_name {
private static X509Certificate getReqSigCert(Message message) {
List<WSHandlerResult> results =
CastUtils.cast((List<?>)
message.getExchange().getInMessage().get(WSHandlerConstants.RECV_RESULTS));
if (results == null) {
return null; // depends on control dependency: [if], data = [none]
}
/*
* Scan the results for a matching actor. Use results only if the
* receiving Actor and the sending Actor match.
*/
for (WSHandlerResult rResult : results) {
List<WSSecurityEngineResult> wsSecEngineResults = rResult
.getResults();
/*
* Scan the results for the first Signature action. Use the
* certificate of this Signature to set the certificate for the
* encryption action :-).
*/
for (WSSecurityEngineResult wser : wsSecEngineResults) {
Integer actInt = (Integer) wser
.get(WSSecurityEngineResult.TAG_ACTION);
if (actInt.intValue() == WSConstants.SIGN) {
return (X509Certificate) wser
.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE); // depends on control dependency: [if], data = [none]
}
}
}
return null;
} } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.