nus-yam/ex-repair huggingface dataset:
Program: 28575
Project: 28575
Buggy source:
/** 
 * Updates the Binding with new data. It uses a   {@link com.flipkart.layoutengine.binding.Binding}to get the associated   {@link android.view.View},   {@link com.flipkart.layoutengine.builder.LayoutBuilder}, and   {@link com.flipkart.layoutengine.parser.LayoutHandler} to update the value of the boundattribute with the new value fetched from the new data object passed.
 * @param binding The property name to update mapped to its{@link com.flipkart.layoutengine.binding.Binding}
 */
private void handleBinding(Binding binding){
  if (binding.hasRegEx()) {
    parserContext.getLayoutBuilder().handleAttribute(binding.getLayoutHandler(),parserContext,binding.getAttributeKey(),new JsonPrimitive(binding.getAttributeValue()),layout,this,parent,index);
  }
 else {
    JsonElement dataValue;
    try {
      dataValue=Utils.getElementFromData(binding.getBindingName(),parserContext.getDataContext().getDataProvider(),index);
    }
 catch (    JsonNullException|NoSuchDataPathException|InvalidDataPathException e) {
      Log.e(Utils.TAG_ERROR + "String_Node_Str",e.getMessage());
      if (getView() != null) {
        getView().setVisibility(View.GONE);
      }
      dataValue=new JsonPrimitive(ProteusConstants.DATA_NULL);
    }
    parserContext.getLayoutBuilder().handleAttribute(binding.getLayoutHandler(),parserContext,binding.getAttributeKey(),dataValue,layout,this,parent,index);
  }
}

Fixed version (ground truth):
/** 
 * Updates the Binding with new data. It uses a   {@link com.flipkart.layoutengine.binding.Binding}to get the associated   {@link android.view.View},   {@link com.flipkart.layoutengine.builder.LayoutBuilder}, and   {@link com.flipkart.layoutengine.parser.LayoutHandler} to update the value of the boundattribute with the new value fetched from the new data object passed.
 * @param binding The property name to update mapped to its{@link com.flipkart.layoutengine.binding.Binding}
 */
private void handleBinding(Binding binding){
  if (binding.hasRegEx()) {
    parserContext.getLayoutBuilder().handleAttribute(binding.getLayoutHandler(),parserContext,binding.getAttributeKey(),new JsonPrimitive(binding.getAttributeValue()),layout,this,parent,index);
  }
 else {
    JsonElement dataValue;
    try {
      dataValue=Utils.getElementFromData(binding.getBindingName(),parserContext.getDataContext().getDataProvider(),index);
      if (!Attributes.View.Visibility.getName().equals(binding.getAttributeKey()) && !Attributes.View.Invisibility.getName().equals(binding.getAttributeKey()) && this.getView() != null) {
        this.getView().setVisibility(0);
      }
    }
 catch (    JsonNullException|NoSuchDataPathException|InvalidDataPathException e) {
      Log.e(Utils.TAG_ERROR + "String_Node_Str",e.getMessage());
      if (getView() != null) {
        getView().setVisibility(View.GONE);
      }
      dataValue=new JsonPrimitive(ProteusConstants.DATA_NULL);
    }
    parserContext.getLayoutBuilder().handleAttribute(binding.getLayoutHandler(),parserContext,binding.getAttributeKey(),dataValue,layout,this,parent,index);
  }
}
Program: 28577
Project: 28577
Buggy source:
public HorizontalProgressBarParser(Parser wrappedParser){
  super(wrappedParser);
}

Fixed version (ground truth):
public HorizontalProgressBarParser(Parser<T> wrappedParser){
  super(HorizontalProgressBar.class,wrappedParser);
}
Program: 28578
Project: 28578
Buggy source:
@NonNull public static String getLayoutIdentifier(JsonObject layout){
  String value=Utils.getPropertyAsString(layout,ProteusConstants.ID);
  if (value != null) {
    return "String_Node_Str" + value + "String_Node_Str";
  }
  value=Utils.getPropertyAsString(layout,ProteusConstants.TAG);
  if (value != null) {
    return "String_Node_Str" + value + "String_Node_Str";
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
@NonNull public static String getLayoutIdentifier(JsonObject layout){
  String noLayoutId="String_Node_Str";
  if (layout == null) {
    return noLayoutId;
  }
  String value=Utils.getPropertyAsString(layout,ProteusConstants.ID);
  if (value != null) {
    return "String_Node_Str" + value + "String_Node_Str";
  }
  value=Utils.getPropertyAsString(layout,ProteusConstants.TAG);
  if (value != null) {
    return "String_Node_Str" + value + "String_Node_Str";
  }
  return noLayoutId;
}
Program: 28583
Project: 28583
Buggy source:
@Override public void handle(ParserContext parserContext,String attributeKey,String attributeValue,T view){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    view.setAllCaps(ParseHelper.parseBoolean(attributeValue));
  }
}

Fixed version (ground truth):
@Override public void handle(ParserContext parserContext,String attributeKey,String attributeValue,T view){
  view.setHint(attributeValue);
}
Program: 28584
Project: 28584
Buggy source:
public abstract void handle(ParserContext parserContext,String attributeKey,JsonElement attributeValue,E view,JsonObject layout);

Fixed version (ground truth):
/** 
 * @param parserContext
 * @param attributeKey
 * @param attributeValue
 * @param view
 * @param layout
 */
public abstract void handle(ParserContext parserContext,String attributeKey,JsonElement attributeValue,E view,JsonObject layout);
Program: 28585
Project: 28585
Buggy source:
public abstract void handle(ParserContext parserContext,String attributeKey,String attributeValue,E view);

Fixed version (ground truth):
/** 
 * @param parserContext
 * @param attributeKey
 * @param attributeValue
 * @param view
 */
public abstract void handle(ParserContext parserContext,String attributeKey,String attributeValue,E view);
Program: 28586
Project: 28586
Buggy source:
/** 
 * Updates the Binding with new data. It uses a   {@link com.flipkart.layoutengine.binding.Binding}to get the associated   {@link android.view.View},   {@link com.flipkart.layoutengine.builder.LayoutBuilder}, and   {@link com.flipkart.layoutengine.parser.LayoutHandler} to update the value of the boundattribute with the new value fetched from the new data object passed.
 * @param binding The property name to update mapped to its{@link com.flipkart.layoutengine.binding.Binding}
 */
private void handleBinding(Binding binding){
  if (binding.hasRegEx()) {
    parserContext.getLayoutBuilder().handleAttribute(binding.getLayoutHandler(),parserContext,binding.getAttributeKey(),new JsonPrimitive(binding.getAttributeValue()),layout,this,parent,index);
  }
 else {
    JsonElement dataValue;
    try {
      dataValue=Utils.getElementFromData(binding.getBindingName(),parserContext.getDataContext().getDataProvider(),index);
    }
 catch (    JsonNullException|NoSuchDataPathException|InvalidDataPathException e) {
      Log.e(TAG + "String_Node_Str",e.getMessage());
      if (getView() != null) {
        getView().setVisibility(View.GONE);
      }
      return;
    }
    parserContext.getLayoutBuilder().handleAttribute(binding.getLayoutHandler(),parserContext,binding.getAttributeKey(),dataValue,layout,this,parent,index);
  }
}

Fixed version (ground truth):
/** 
 * Updates the Binding with new data. It uses a   {@link com.flipkart.layoutengine.binding.Binding}to get the associated   {@link android.view.View},   {@link com.flipkart.layoutengine.builder.LayoutBuilder}, and   {@link com.flipkart.layoutengine.parser.LayoutHandler} to update the value of the boundattribute with the new value fetched from the new data object passed.
 * @param binding The property name to update mapped to its{@link com.flipkart.layoutengine.binding.Binding}
 */
private void handleBinding(Binding binding){
  if (binding.hasRegEx()) {
    parserContext.getLayoutBuilder().handleAttribute(binding.getLayoutHandler(),parserContext,binding.getAttributeKey(),new JsonPrimitive(binding.getAttributeValue()),layout,this,parent,index);
  }
 else {
    JsonElement dataValue;
    try {
      dataValue=Utils.getElementFromData(binding.getBindingName(),parserContext.getDataContext().getDataProvider(),index);
    }
 catch (    JsonNullException|NoSuchDataPathException|InvalidDataPathException e) {
      Log.e(TAG + "String_Node_Str",e.getMessage());
      if (getView() != null) {
        getView().setVisibility(View.GONE);
      }
      dataValue=new JsonPrimitive(ProteusConstants.DATA_NULL);
    }
    parserContext.getLayoutBuilder().handleAttribute(binding.getLayoutHandler(),parserContext,binding.getAttributeKey(),dataValue,layout,this,parent,index);
  }
}
Program: 28587
Project: 28587
Buggy source:
public static DataContext updateDataContext(DataContext dataContext,JsonProvider dataProvider,JsonObject scope,int childIndex){
  JsonObject reverseScope=new JsonObject();
  JsonObject newData=new JsonObject();
  JsonObject data=dataProvider.getData().getAsJsonObject();
  if (data == null) {
    data=new JsonObject();
  }
  for (  Map.Entry<String,JsonElement> entry : scope.entrySet()) {
    String key=entry.getKey();
    if (entry.getValue().isJsonPrimitive()) {
      JsonElement element;
      String value=entry.getValue().getAsString();
      try {
        element=Utils.getElementFromData(value,dataProvider,childIndex);
      }
 catch (      JsonNullException|NoSuchDataPathException|InvalidDataPathException e) {
        Log.e(TAG + "String_Node_Str","String_Node_Str" + value + "String_Node_Str"+ key+ "String_Node_Str"+ e.getMessage());
        element=new JsonObject();
      }
      newData.add(key,element);
      String unAliasedValue=value.replace(ProteusConstants.CHILD_INDEX_REFERENCE,String.valueOf(childIndex));
      reverseScope.add(unAliasedValue,new JsonPrimitive(key));
    }
 else {
      newData.add(key,entry.getValue());
    }
  }
  Utils.addElements(newData,data,false);
  if (dataContext.getDataProvider() == null) {
    dataContext.setDataProvider(new JsonProvider(newData));
  }
 else {
    dataContext.getDataProvider().setData(newData);
  }
  dataContext.setScope(scope);
  dataContext.setReverseScope(reverseScope);
  dataContext.setIndex(childIndex);
  return dataContext;
}

Fixed version (ground truth):
public static DataContext updateDataContext(DataContext dataContext,JsonProvider dataProvider,JsonObject scope,int childIndex){
  JsonObject reverseScope=new JsonObject();
  JsonObject newData=new JsonObject();
  JsonObject data=dataProvider.getData().getAsJsonObject();
  if (data == null) {
    data=new JsonObject();
  }
  for (  Map.Entry<String,JsonElement> entry : scope.entrySet()) {
    String key=entry.getKey();
    String value=entry.getValue().getAsString();
    JsonElement element;
    try {
      element=Utils.getElementFromData(value,dataProvider,childIndex);
    }
 catch (    JsonNullException|NoSuchDataPathException|InvalidDataPathException e) {
      Log.e(TAG + "String_Node_Str","String_Node_Str" + key + "String_Node_Str"+ value+ "String_Node_Str"+ e.getMessage());
      element=entry.getValue();
    }
    newData.add(key,element);
    String unAliasedValue=value.replace(ProteusConstants.CHILD_INDEX_REFERENCE,String.valueOf(childIndex));
    reverseScope.add(unAliasedValue,new JsonPrimitive(key));
  }
  Utils.addElements(newData,data,false);
  if (dataContext.getDataProvider() == null) {
    dataContext.setDataProvider(new JsonProvider(newData));
  }
 else {
    dataContext.getDataProvider().setData(newData);
  }
  dataContext.setScope(scope);
  dataContext.setReverseScope(reverseScope);
  dataContext.setIndex(childIndex);
  return dataContext;
}
Program: 28588
Project: 28588
Buggy source:
@Override public void replaceView(ProteusView proteusView){
  if (proteusView instanceof DataProteusView) {
    DataProteusView dataProteusView=(DataProteusView)proteusView;
    this.bindings=dataProteusView.getBindings();
    this.childLayout=dataProteusView.getChildLayout();
    this.dataPathForChildren=dataProteusView.getDataPathForChildren();
    this.parserContext=dataProteusView.getParserContext();
  }
  super.replaceView(proteusView);
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView view){
  if (view instanceof DataProteusView) {
    DataProteusView dataProteusView=(DataProteusView)view;
    this.bindings=dataProteusView.getBindings();
  }
  super.replaceView(view);
}
Program: 28589
Project: 28589
Buggy source:
@Override public void replaceView(ProteusView proteusView){
  this.children=proteusView.getChildren();
  this.layout=proteusView.getLayout();
  this.styles=proteusView.getStyles();
  ViewGroup parent=(ViewGroup)this.view.getParent();
  if (parent != null && proteusView.getView() != null) {
    int index=parent.indexOfChild(this.view);
    if (proteusView.getView().getParent() != null) {
      ((ViewGroup)proteusView.getView().getParent()).removeView(proteusView.getView());
    }
    parent.removeView(this.view);
    parent.addView(proteusView.getView(),index);
  }
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView view){
  this.children=view.getChildren();
  ViewGroup parent=(ViewGroup)this.view.getParent();
  if (parent != null) {
    int index=parent.indexOfChild(this.view);
    parent.removeView(this.view);
    parent.addView(view.getView(),index);
  }
}
Program: 28591
Project: 28591
Buggy source:
/** 
 * This is a base implementation which calls addChild() on the parent.
 * @param parent   The view group into which the child will be added.
 * @param children The List of child views which have to be added.
 */
@Override public void addChildren(ParserContext parserContext,ProteusView parent,List<ProteusView> children,JsonObject viewLayout){
  for (  ProteusView child : children) {
    parent.addChild(child);
  }
}

Fixed version (ground truth):
/** 
 * This is a base implementation which calls addView() on the parent.
 * @param parent   The view group into which the child will be added.
 * @param children The List of child views which have to be added.
 */
@Override public void addChildren(ParserContext parserContext,ProteusView parent,List<ProteusView> children,JsonObject viewLayout){
  for (  ProteusView child : children) {
    parent.addView(child);
  }
}
Program: 28592
Project: 28592
Buggy source:
private void updateChildrenFromData(){
  JsonArray childrenDataArray=new JsonArray();
  try {
    childrenDataArray=Utils.getElementFromData(dataPathForChildren,parserContext.getDataContext().getDataProvider(),index).getAsJsonArray();
  }
 catch (  JsonNullException|NoSuchDataPathException|InvalidDataPathException|IllegalStateException e) {
    Log.e(TAG + "String_Node_Str",e.getMessage());
  }
  if (children.size() > childrenDataArray.size()) {
    while (children.size() > childrenDataArray.size()) {
      ProteusView proteusView=children.remove(children.size() - 1);
      proteusView.removeView();
    }
  }
  JsonObject data=parserContext.getDataContext().getDataProvider().getData().getAsJsonObject();
  for (int index=0; index < childrenDataArray.size(); index++) {
    if (index < children.size()) {
      children.get(index).updateData(data);
    }
 else {
      if (childLayout != null) {
        DataProteusView proteusView=(DataProteusView)parserContext.getLayoutBuilder().build(view,childLayout,data,index,styles);
        addChild(proteusView);
      }
    }
  }
}

Fixed version (ground truth):
private void updateChildrenFromData(){
  JsonArray childrenDataArray=new JsonArray();
  try {
    childrenDataArray=Utils.getElementFromData(dataPathForChildren,parserContext.getDataContext().getDataProvider(),index).getAsJsonArray();
  }
 catch (  JsonNullException|NoSuchDataPathException|InvalidDataPathException|IllegalStateException e) {
    Log.e(TAG + "String_Node_Str",e.getMessage());
  }
  if (children.size() > childrenDataArray.size()) {
    while (children.size() > childrenDataArray.size()) {
      ProteusView proteusView=children.remove(children.size() - 1);
      unsetParent(proteusView.getView());
      proteusView.destroy();
    }
  }
  JsonObject data=parserContext.getDataContext().getDataProvider().getData().getAsJsonObject();
  for (int index=0; index < childrenDataArray.size(); index++) {
    if (index < children.size()) {
      children.get(index).updateData(data);
    }
 else {
      if (childLayout != null) {
        DataProteusView child=(DataProteusView)parserContext.getLayoutBuilder().build(view,childLayout,data,index,styles);
        addView(child);
      }
    }
  }
}
Program: 28593
Project: 28593
Buggy source:
@Override public void replaceView(ProteusView view){
  if (view instanceof DataProteusView) {
    DataProteusView dataProteusView=(DataProteusView)view;
    this.bindings=dataProteusView.getBindings();
  }
  super.replaceView(view);
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView view){
  super.replaceView(view);
  if (view instanceof DataProteusView) {
    DataProteusView dataProteusView=(DataProteusView)view;
    this.bindings=dataProteusView.getBindings();
    this.parserContext=dataProteusView.getParserContext();
    this.childLayout=dataProteusView.getChildLayout();
    this.dataPathForChildren=dataProteusView.getDataPathForChildren();
  }
}
Program: 28594
Project: 28594
Buggy source:
void setStyles(Styles styles);

Fixed version (ground truth):
/** 
 * Returns the   {@link Styles} used in this {@link ProteusView}
 * @param styles Returns the {@link Styles} used in this {@link ProteusView}
 */
void setStyles(Styles styles);
Program: 28595
Project: 28595
Buggy source:
/** 
 * @return the list of children.
 */
ArrayList<ProteusView> getChildren();

Fixed version (ground truth):
/** 
 * @return the list of children.
 */
List<ProteusView> getChildren();
Program: 28596
Project: 28596
Buggy source:
void removeView();

Fixed version (ground truth):
/** 
 * Removes the child view at the specified location from this   {@code ProteusView}.
 * @param childIndex the index of the object to remove.
 * @return the removed object.
 */
@Nullable ProteusView removeView(int childIndex);
Program: 28597
Project: 28597
Buggy source:
JsonObject getLayout();

Fixed version (ground truth):
/** 
 * Returns the layout used to build this   {@link ProteusView}
 * @return Returns the layout used to build this {@link ProteusView}
 */
@Nullable JsonObject getLayout();
Program: 28598
Project: 28598
Buggy source:
/** 
 * Updates the data associated with view wrapped by the   {@link ProteusView}with new   {@link org.json.JSONObject} object.
 * @param data new {@link org.json.JSONObject} object which will used to update the view.
 * @return reference to the updated view {@link android.view.View} wrapped by the{@link ProteusView}
 */
View updateData(JsonObject data);

Fixed version (ground truth):
/** 
 * Updates the data associated with view wrapped by the   {@link ProteusView}with new   {@link JsonObject} object.
 * @param data new {@link JsonObject} object which will used to update the view.
 * @return reference to the updated view {@link android.view.View} wrapped by the{@link ProteusView}
 */
View updateData(JsonObject data);
Program: 28599
Project: 28599
Buggy source:
Styles getStyles();

Fixed version (ground truth):
/** 
 * Returns the current   {@link Styles} used in this {@link ProteusView}
 * @return Returns the current {@link Styles} used in this {@link ProteusView}
 */
Styles getStyles();
Program: 28600
Project: 28600
Buggy source:
/** 
 * @return reference to the view {@link android.view.View} wrapped by the {@link ProteusView}
 */
View getView();

Fixed version (ground truth):
/** 
 * @return the view {@link android.view.View} wrapped by the {@link ProteusView}
 */
View getView();
Program: 28601
Project: 28601
Buggy source:
/** 
 * Replace the   {@link View},   {@link com.flipkart.layoutengine.binding.Binding} and childrenassociated to this  {@link ProteusView}.
 * @param view The {@link ProteusView} to use for the replacement
 */
void replaceView(ProteusView view);

Fixed version (ground truth):
/** 
 * Replaces the   {@link ProteusView} in the hierarchy.
 * @param view The {@link ProteusView} to use for the replacement
 */
void replaceView(ProteusView view);
Program: 28602
Project: 28602
Buggy source:
@Override public ArrayList<ProteusView> getChildren(){
  return this.children;
}

Fixed version (ground truth):
@Override public List<ProteusView> getChildren(){
  return this.children;
}
Program: 28603
Project: 28603
Buggy source:
@Override public void removeView(){
  if (getParent() != null && getParent().getView() != null && view != null) {
    ((ViewGroup)getParent().getView()).removeView(view);
  }
}

Fixed version (ground truth):
@Override public ProteusView removeView(int childIndex){
  if (childIndex < children.size()) {
    ProteusView proteusView=getChildren().remove(childIndex);
    unsetParent(proteusView.getView());
    return proteusView;
  }
  return null;
}
Program: 28604
Project: 28604
Buggy source:
@Override public void replaceView(ProteusView view){
  this.children=view.getChildren();
  ViewGroup parent=(ViewGroup)this.view.getParent();
  if (parent != null) {
    int index=parent.indexOfChild(this.view);
    parent.removeView(this.view);
    parent.addView(view.getView(),index);
  }
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView view){
  this.children=view.getChildren();
  this.layout=view.getLayout();
  this.styles=view.getStyles();
  ViewGroup parent=(ViewGroup)this.view.getParent();
  if (parent != null) {
    int index=parent.indexOfChild(this.view);
    parent.removeView(this.view);
    unsetParent(view.getView());
    parent.addView(view.getView(),index);
  }
}
Program: 28605
Project: 28605
Buggy source:
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || parent.getView() == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
    parent.addView(child,index);
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    if (parentViewGroup == null) {
      return;
    }
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
    parent.getChildren().add(child);
  }
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || parent.getView() == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
  }
  parent.addView(child,index);
}
Program: 28606
Project: 28606
Buggy source:
public static DataContext updateDataContext(DataContext dataContext,JsonProvider dataProvider,JsonObject scope,int childIndex){
  JsonObject reverseScope=new JsonObject();
  JsonObject newData=new JsonObject();
  JsonObject data=dataProvider.getData().getAsJsonObject();
  if (data == null) {
    data=new JsonObject();
  }
  for (  Map.Entry<String,JsonElement> entry : scope.entrySet()) {
    String key=entry.getKey();
    String value=entry.getValue().getAsString();
    JsonElement element;
    try {
      element=Utils.getElementFromData(value,dataProvider,childIndex);
    }
 catch (    JsonNullException|NoSuchDataPathException|InvalidDataPathException e) {
      Log.e(TAG + "String_Node_Str","String_Node_Str" + key + "String_Node_Str"+ value+ "String_Node_Str"+ e.getMessage());
      element=entry.getValue();
    }
    newData.add(key,element);
    String unAliasedValue=value.replace(ProteusConstants.CHILD_INDEX_REFERENCE,String.valueOf(childIndex));
    reverseScope.add(unAliasedValue,new JsonPrimitive(key));
  }
  Utils.addElements(newData,data,false);
  if (dataContext.getDataProvider() == null) {
    dataContext.setDataProvider(new JsonProvider(newData));
  }
 else {
    dataContext.getDataProvider().setData(newData);
  }
  dataContext.setScope(scope);
  dataContext.setReverseScope(reverseScope);
  dataContext.setIndex(childIndex);
  return dataContext;
}

Fixed version (ground truth):
public static DataContext updateDataContext(DataContext dataContext,JsonProvider dataProvider,JsonObject scope,int childIndex){
  JsonObject reverseScope=new JsonObject();
  JsonObject newData=new JsonObject();
  JsonObject data=dataProvider.getData().getAsJsonObject();
  if (data == null) {
    data=new JsonObject();
  }
  for (  Map.Entry<String,JsonElement> entry : scope.entrySet()) {
    String key=entry.getKey();
    if (entry.getValue().isJsonPrimitive()) {
      JsonElement element;
      String value=entry.getValue().getAsString();
      try {
        element=Utils.getElementFromData(value,dataProvider,childIndex);
      }
 catch (      JsonNullException|NoSuchDataPathException|InvalidDataPathException e) {
        Log.e(TAG + "String_Node_Str","String_Node_Str" + value + "String_Node_Str"+ key+ "String_Node_Str"+ e.getMessage());
        element=new JsonObject();
      }
      newData.add(key,element);
      String unAliasedValue=value.replace(ProteusConstants.CHILD_INDEX_REFERENCE,String.valueOf(childIndex));
      reverseScope.add(unAliasedValue,new JsonPrimitive(key));
    }
 else {
      newData.add(key,entry.getValue());
    }
  }
  Utils.addElements(newData,data,false);
  if (dataContext.getDataProvider() == null) {
    dataContext.setDataProvider(new JsonProvider(newData));
  }
 else {
    dataContext.getDataProvider().setData(newData);
  }
  dataContext.setScope(scope);
  dataContext.setReverseScope(reverseScope);
  dataContext.setIndex(childIndex);
  return dataContext;
}
Program: 28607
Project: 28607
Buggy source:
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || parent.getView() == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
  }
  parent.addView(child,index);
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
  }
  parent.addView(child,index);
}
Program: 28608
Project: 28608
Buggy source:
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
  }
  parent.addView(child,index);
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (parent != null) {
    if (child.getView().getParent() != null) {
      ((ViewGroup)child.getView().getParent()).removeView(child.getView());
    }
    parent.removeView(index).destroy();
    parent.addView(child,index);
  }
}
Program: 28609
Project: 28609
Buggy source:
@Override public void replaceView(ProteusView child){
  if (child.getView() == null) {
    return;
  }
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent != null && parent.getView() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
    parent.addView(child,index);
  }
 else {
    ViewGroup parentView=(ViewGroup)this.view.getParent();
    if (parentView == null) {
      return;
    }
    int index=parentView.indexOfChild(this.view);
    parentView.removeView(this.view);
    parentView.addView(child.getView(),index);
    parent.getChildren().add(child);
  }
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || parent.getView() == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
    parent.addView(child,index);
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    if (parentViewGroup == null) {
      return;
    }
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
    parent.getChildren().add(child);
  }
}
Program: 28610
Project: 28610
Buggy source:
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || parent.getView() == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
  }
  parent.addView(child,index);
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || parent.getView() == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
    parent.addView(child,index);
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    if (parentViewGroup == null) {
      return;
    }
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
    parent.getChildren().add(child);
  }
}
Program: 28611
Project: 28611
Buggy source:
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
  }
  parent.addView(child,index);
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || parent.getView() == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
  }
  parent.addView(child,index);
}
Program: 28612
Project: 28612
Buggy source:
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (parent != null) {
    if (child.getView().getParent() != null) {
      ((ViewGroup)child.getView().getParent()).removeView(child.getView());
    }
    parent.removeView(index).destroy();
    parent.addView(child,index);
  }
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
  }
  parent.addView(child,index);
}
Program: 28614
Project: 28614
Buggy source:
@Override public void replaceView(ProteusView child){
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent == null || parent.getView() == null || child.getView() == null) {
    return;
  }
  if (parent.getChildren() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
    parent.addView(child,index);
  }
 else {
    ViewGroup parentViewGroup=(ViewGroup)this.view.getParent();
    if (parentViewGroup == null) {
      return;
    }
    int index=parentViewGroup.indexOfChild(this.view);
    parentViewGroup.removeView(this.view);
    parentViewGroup.addView(child.getView(),index);
    parent.getChildren().add(child);
  }
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView child){
  if (child.getView() == null) {
    return;
  }
  if (child.getView().getParent() != null) {
    ((ViewGroup)child.getView().getParent()).removeView(child.getView());
  }
  if (parent != null && parent.getView() != null && index < parent.getChildren().size()) {
    parent.removeView(index).destroy();
    parent.addView(child,index);
  }
 else {
    ViewGroup parentView=(ViewGroup)this.view.getParent();
    if (parentView == null) {
      return;
    }
    int index=parentView.indexOfChild(this.view);
    parentView.removeView(this.view);
    parentView.addView(child.getView(),index);
    parent.getChildren().add(child);
  }
  this.children=child.getChildren();
  this.layout=child.getLayout();
  this.styles=child.getStyles();
}
Program: 28616
Project: 28616
Buggy source:
@Override protected void prepareHandlers(Context context){
  super.prepareHandlers(context);
  addHandler(Attributes.HorizontalScrollView.FillViewPort,new StringAttributeProcessor<T>(){
    @Override public void handle(    ParserContext parserContext,    String attributeKey,    String attributeValue,    T view){
      boolean fillViewPort=ParseHelper.parseBoolean(attributeValue);
      view.setFillViewport(fillViewPort);
    }
  }
);
}

Fixed version (ground truth):
@Override protected void prepareHandlers(Context context){
  super.prepareHandlers(context);
  addHandler(Attributes.HorizontalScrollView.FillViewPort,new StringAttributeProcessor<T>(){
    @Override public void handle(    ParserContext parserContext,    String attributeKey,    String attributeValue,    T view){
      boolean fillViewPort=ParseHelper.parseBoolean(attributeValue);
      view.setFillViewport(fillViewPort);
    }
  }
);
  addHandler(Attributes.ScrollView.Scrollbars,new StringAttributeProcessor<T>(){
    @Override public void handle(    ParserContext parserContext,    String attributeKey,    String attributeValue,    T view){
      if ("String_Node_Str".equals(attributeValue)) {
        view.setHorizontalScrollBarEnabled(false);
        view.setVerticalScrollBarEnabled(false);
      }
 else       if ("String_Node_Str".equals(attributeValue)) {
        view.setHorizontalScrollBarEnabled(true);
        view.setVerticalScrollBarEnabled(false);
      }
 else       if ("String_Node_Str".equals(attributeValue)) {
        view.setHorizontalScrollBarEnabled(false);
        view.setVerticalScrollBarEnabled(true);
      }
 else {
        view.setHorizontalScrollBarEnabled(false);
        view.setVerticalScrollBarEnabled(false);
      }
    }
  }
);
}
Program: 28617
Project: 28617
Buggy source:
@Override public void handle(ParserContext parserContext,String attributeKey,String attributeValue,T view){
  boolean fillViewPort=ParseHelper.parseBoolean(attributeValue);
  view.setFillViewport(fillViewPort);
}

Fixed version (ground truth):
@Override public void handle(ParserContext parserContext,String attributeKey,String attributeValue,T view){
  if ("String_Node_Str".equals(attributeValue)) {
    view.setHorizontalScrollBarEnabled(false);
    view.setVerticalScrollBarEnabled(false);
  }
 else   if ("String_Node_Str".equals(attributeValue)) {
    view.setHorizontalScrollBarEnabled(true);
    view.setVerticalScrollBarEnabled(false);
  }
 else   if ("String_Node_Str".equals(attributeValue)) {
    view.setHorizontalScrollBarEnabled(false);
    view.setVerticalScrollBarEnabled(true);
  }
 else {
    view.setHorizontalScrollBarEnabled(false);
    view.setVerticalScrollBarEnabled(false);
  }
}
Program: 28618
Project: 28618
Buggy source:
@Override public void replaceView(ProteusView view){
  if (view instanceof DataProteusView) {
    DataProteusView dataProteusView=(DataProteusView)view;
    this.bindings=dataProteusView.getBindings();
  }
  super.replaceView(view);
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView proteusView){
  if (proteusView instanceof DataProteusView) {
    DataProteusView dataProteusView=(DataProteusView)proteusView;
    this.bindings=dataProteusView.getBindings();
    this.childLayout=dataProteusView.getChildLayout();
    this.dataPathForChildren=dataProteusView.getDataPathForChildren();
    this.parserContext=dataProteusView.getParserContext();
  }
  super.replaceView(proteusView);
}
Program: 28619
Project: 28619
Buggy source:
@Override public void replaceView(ProteusView view){
  this.children=view.getChildren();
  ViewGroup parent=(ViewGroup)this.view.getParent();
  if (parent != null) {
    int index=parent.indexOfChild(this.view);
    parent.removeView(this.view);
    parent.addView(view.getView(),index);
  }
}

Fixed version (ground truth):
@Override public void replaceView(ProteusView proteusView){
  this.children=proteusView.getChildren();
  this.layout=proteusView.getLayout();
  this.styles=proteusView.getStyles();
  ViewGroup parent=(ViewGroup)this.view.getParent();
  if (parent != null && proteusView.getView() != null) {
    int index=parent.indexOfChild(this.view);
    if (proteusView.getView().getParent() != null) {
      ((ViewGroup)proteusView.getView().getParent()).removeView(proteusView.getView());
    }
    parent.removeView(this.view);
    parent.addView(proteusView.getView(),index);
  }
}
Program: 28621
Project: 28621
Buggy source:
public static int parseVisibility(JsonElement element){
  String attributeValue;
  int returnValue;
  if (element.isJsonPrimitive()) {
    if (!element.getAsString().equals("String_Node_Str") && !element.getAsString().equals("String_Node_Str")) {
      attributeValue="String_Node_Str";
    }
 else {
      attributeValue="String_Node_Str";
    }
  }
 else   if (element.isJsonNull()) {
    attributeValue="String_Node_Str";
  }
 else {
    attributeValue="String_Node_Str";
  }
  if ("String_Node_Str".equals(attributeValue)) {
    returnValue=View.VISIBLE;
  }
 else   if ("String_Node_Str".equals(attributeValue)) {
    returnValue=View.INVISIBLE;
  }
 else   if ("String_Node_Str".equals(attributeValue)) {
    returnValue=View.GONE;
  }
 else   if ("String_Node_Str".equals(attributeValue)) {
    returnValue=View.VISIBLE;
  }
 else   if ("String_Node_Str".equals(attributeValue)) {
    returnValue=View.GONE;
  }
 else {
    returnValue=View.VISIBLE;
  }
  return returnValue;
}

Fixed version (ground truth):
public static int parseVisibility(JsonElement element){
  String attributeValue;
  int returnValue;
  if (element.isJsonPrimitive()) {
    if (!element.getAsString().equals("String_Node_Str") && !element.getAsString().equals("String_Node_Str") && !element.getAsString().equals(ProteusConstants.DATA_NULL)) {
      attributeValue=element.getAsString();
    }
 else {
      attributeValue="String_Node_Str";
    }
  }
 else   if (element.isJsonNull()) {
    attributeValue="String_Node_Str";
  }
 else {
    attributeValue="String_Node_Str";
  }
  if ("String_Node_Str".equals(attributeValue)) {
    returnValue=View.VISIBLE;
  }
 else   if ("String_Node_Str".equals(attributeValue)) {
    returnValue=View.INVISIBLE;
  }
 else   if ("String_Node_Str".equals(attributeValue)) {
    returnValue=View.GONE;
  }
 else   if ("String_Node_Str".equals(attributeValue)) {
    returnValue=View.VISIBLE;
  }
 else   if ("String_Node_Str".equals(attributeValue)) {
    returnValue=View.GONE;
  }
 else {
    returnValue=View.VISIBLE;
  }
  return returnValue;
}
Program: 28622
Project: 28622
Buggy source:
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) private void init(final String url,boolean loadImmediately){
  final CountDownLatch lock;
  if (view == null) {
    loadImmediately=true;
  }
  if (loadImmediately) {
    startSyncLoad(url,view);
  }
 else {
    lock=null;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
      startAsyncLoad(url,view);
    }
 else {
      view.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener(){
        @Override public void onViewAttachedToWindow(        final View view){
          startAsyncLoad(url,view);
        }
        @Override public void onViewDetachedFromWindow(        View view){
          cancelLoad();
        }
      }
);
    }
  }
}

Fixed version (ground truth):
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) private void init(final String url,boolean loadImmediately){
  final CountDownLatch lock;
  if (view == null) {
    loadImmediately=true;
  }
  if (loadImmediately) {
    startSyncLoad(url,view);
  }
 else {
    lock=null;
    startAsyncLoad(url,view);
  }
}
Program: 28623
Project: 28623
Buggy source:
@Override protected void prepareHandlers(final Context context){
  super.prepareHandlers(context);
  addHandler(Attributes.ProgressBar.Max,new StringAttributeProcessor<T>(){
    @Override public void handle(    ParserContext parserContext,    String attributeKey,    String attributeValue,    T view){
      view.setMax((int)Double.parseDouble(attributeValue));
    }
  }
);
  addHandler(Attributes.ProgressBar.Progress,new StringAttributeProcessor<T>(){
    @Override public void handle(    ParserContext parserContext,    String attributeKey,    String attributeValue,    T view){
      view.setProgress((int)Double.parseDouble(attributeValue));
    }
  }
);
  addHandler(Attributes.ProgressBar.ProgressTint,new JsonDataProcessor<T>(){
    @Override public void handle(    ParserContext parserContext,    String attributeKey,    JsonElement attributeValue,    T view,    JsonObject layout){
      if (!attributeValue.isJsonObject() || attributeValue.isJsonNull()) {
        return;
      }
      JsonObject data=attributeValue.getAsJsonObject();
      int background=Color.TRANSPARENT;
      int progress=Color.TRANSPARENT;
      String value=Utils.getPropertyAsString(data,"String_Node_Str");
      if (value != null) {
        background=ParseHelper.parseColor(value);
      }
      value=Utils.getPropertyAsString(data,"String_Node_Str");
      if (value != null) {
        progress=ParseHelper.parseColor(value);
      }
      view.setProgressDrawable(getLayerDrawable(progress,background));
    }
  }
);
}

Fixed version (ground truth):
@Override protected void prepareHandlers(final Context context){
  super.prepareHandlers(context);
  addHandler(Attributes.ProgressBar.Max,new StringAttributeProcessor<T>(){
    @Override public void handle(    ParserContext parserContext,    String attributeKey,    String attributeValue,    T view){
      view.setMax((int)ParseHelper.parseDouble(attributeValue));
    }
  }
);
  addHandler(Attributes.ProgressBar.Progress,new StringAttributeProcessor<T>(){
    @Override public void handle(    ParserContext parserContext,    String attributeKey,    String attributeValue,    T view){
      view.setProgress((int)ParseHelper.parseDouble(attributeValue));
    }
  }
);
  addHandler(Attributes.ProgressBar.ProgressTint,new JsonDataProcessor<T>(){
    @Override public void handle(    ParserContext parserContext,    String attributeKey,    JsonElement attributeValue,    T view,    JsonObject layout){
      if (!attributeValue.isJsonObject() || attributeValue.isJsonNull()) {
        return;
      }
      JsonObject data=attributeValue.getAsJsonObject();
      int background=Color.TRANSPARENT;
      int progress=Color.TRANSPARENT;
      String value=Utils.getPropertyAsString(data,"String_Node_Str");
      if (value != null) {
        background=ParseHelper.parseColor(value);
      }
      value=Utils.getPropertyAsString(data,"String_Node_Str");
      if (value != null) {
        progress=ParseHelper.parseColor(value);
      }
      view.setProgressDrawable(getLayerDrawable(progress,background));
    }
  }
);
}
Program: 28624
Project: 28624
Buggy source:
@Override public Adapter onAdapterRequired(ParserContext parserContext,ProteusView<View> parent,List<ProteusView> children,JsonObject viewLayout){
  return null;
}

Fixed version (ground truth):
@Override public Adapter onAdapterRequired(ParserContext parserContext,ProteusView parent,List<ProteusView> children,JsonObject viewLayout){
  return null;
}
Program: 28625
Project: 28625
Buggy source:
@Override public PagerAdapter onPagerAdapterRequired(ParserContext parserContext,ProteusView<View> parent,List<ProteusView> children,JsonObject viewLayout){
  return null;
}

Fixed version (ground truth):
@Override public PagerAdapter onPagerAdapterRequired(ParserContext parserContext,ProteusView parent,List<ProteusView> children,JsonObject viewLayout){
  return null;
}