nus-yam/ex-repair huggingface dataset:
Program: 57037
Project: 57037
Buggy source:
/** 
 * Generates the HTML code for this component. 
 */
@Override public void encodeBegin(FacesContext context,UIComponent component) throws IOException {
  SelectOneMenu menu=(SelectOneMenu)component;
  if (!menu.isRendered()) {
    return;
  }
  ResponseWriter rw=context.getResponseWriter();
  String clientId=menu.getClientId(context);
  rw.startElement("String_Node_Str",menu);
  rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  addLabel(rw,clientId,menu);
  UIComponent prependingAddOnFacet=menu.getFacet(C.PREPEND);
  if ((prependingAddOnFacet != null)) {
    R.addClass2FacetComponent(prependingAddOnFacet,"String_Node_Str",ADDON);
  }
  UIComponent appendingAddOnFacet=menu.getFacet(C.APPEND);
  if ((appendingAddOnFacet != null)) {
    R.addClass2FacetComponent(appendingAddOnFacet,"String_Node_Str",ADDON);
  }
  final boolean hasAddon=startInputGroupForAddOn(rw,(prependingAddOnFacet != null),(appendingAddOnFacet != null),menu);
  int span=startColSpanDiv(rw,menu);
  addPrependingAddOnToInputGroup(context,rw,prependingAddOnFacet,(prependingAddOnFacet != null),menu);
  renderSelectTag(context,rw,clientId,menu);
  addAppendingAddOnToInputGroup(context,rw,appendingAddOnFacet,(appendingAddOnFacet != null),menu);
  closeInputGroupForAddOn(rw,hasAddon);
  closeColSpanDiv(rw,span);
  rw.endElement("String_Node_Str");
  Tooltip.activateTooltips(context,menu);
}

Fixed version (ground truth):
/** 
 * Generates the HTML code for this component. 
 */
@Override public void encodeBegin(FacesContext context,UIComponent component) throws IOException {
  SelectOneMenu menu=(SelectOneMenu)component;
  if (!menu.isRendered()) {
    return;
  }
  ResponseWriter rw=context.getResponseWriter();
  String clientId=menu.getClientId(context);
  rw.startElement("String_Node_Str",menu);
  rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  writeAttribute(rw,"String_Node_Str",menu.getDir(),"String_Node_Str");
  addLabel(rw,clientId,menu);
  UIComponent prependingAddOnFacet=menu.getFacet(C.PREPEND);
  if ((prependingAddOnFacet != null)) {
    R.addClass2FacetComponent(prependingAddOnFacet,"String_Node_Str",ADDON);
  }
  UIComponent appendingAddOnFacet=menu.getFacet(C.APPEND);
  if ((appendingAddOnFacet != null)) {
    R.addClass2FacetComponent(appendingAddOnFacet,"String_Node_Str",ADDON);
  }
  final boolean hasAddon=startInputGroupForAddOn(rw,(prependingAddOnFacet != null),(appendingAddOnFacet != null),menu);
  int span=startColSpanDiv(rw,menu);
  addPrependingAddOnToInputGroup(context,rw,prependingAddOnFacet,(prependingAddOnFacet != null),menu);
  renderSelectTag(context,rw,clientId,menu);
  addAppendingAddOnToInputGroup(context,rw,appendingAddOnFacet,(appendingAddOnFacet != null),menu);
  closeInputGroupForAddOn(rw,hasAddon);
  closeColSpanDiv(rw,span);
  rw.endElement("String_Node_Str");
  Tooltip.activateTooltips(context,menu);
}
Program: 57038
Project: 57038
Buggy source:
@Override public void encodeBegin(FacesContext context,UIComponent component) throws IOException {
  ResponseWriter rw=context.getResponseWriter();
  String clientId=component.getClientId();
  Switch _switch=(Switch)component;
  rw.startElement("String_Node_Str",_switch);
  rw.writeAttribute("String_Node_Str",clientId,"String_Node_Str");
  renderInputTagAttributes(rw,clientId,_switch);
  AJAXRenderer.generateBootsFacesAJAXAndJavaScript(FacesContext.getCurrentInstance(),_switch,rw);
  renderInputTagValue(context,rw,_switch);
  rw.endElement("String_Node_Str");
  clientId=clientId.replace("String_Node_Str","String_Node_Str");
  rw.append("String_Node_Str");
  rw.append("String_Node_Str" + clientId + "String_Node_Str");
  rw.append("String_Node_Str");
}

Fixed version (ground truth):
@Override public void encodeBegin(FacesContext context,UIComponent component) throws IOException {
  ResponseWriter rw=context.getResponseWriter();
  String clientId=component.getClientId();
  super.encodeBegin(context,component);
  clientId=clientId.replace("String_Node_Str","String_Node_Str");
  rw.append("String_Node_Str");
  rw.append("String_Node_Str" + clientId + "String_Node_Str");
  rw.append("String_Node_Str");
}
Program: 57040
Project: 57040
Buggy source:
/** 
 * HTML snippet of the container holding both the button as well as the dropdown. Default: <div class='btn-group' style='display:block' />. Note that the original definition of the widget doesn't use the style definition. We've added it to fix a rendering bug. <P> Usually this method is called internally by the JSF engine.
 */
public void setButtonContainer(String _buttonContainer){
  getStateHelper().put(PropertyKeys.buttonContainer,_buttonContainer);
}

Fixed version (ground truth):
/** 
 * HTML snippet of the container holding both the button as well as the dropdown. Default: <div class='btn-group' style='display:block'></div>. Note that the original definition of the widget doesn't use the style definition. We've added it to fix a rendering bug. <P> Usually this method is called internally by the JSF engine.
 */
public void setButtonContainer(String _buttonContainer){
  getStateHelper().put(PropertyKeys.buttonContainer,_buttonContainer);
}
Program: 57041
Project: 57041
Buggy source:
/** 
 * HTML snippet of the container holding both the button as well as the dropdown. Default: <div class='btn-group' style='display:block' />. Note that the original definition of the widget doesn't use the style definition. We've added it to fix a rendering bug. <P>
 * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
 */
public String getButtonContainer(){
  String value=(String)getStateHelper().eval(PropertyKeys.buttonContainer);
  return value;
}

Fixed version (ground truth):
/** 
 * HTML snippet of the container holding both the button as well as the dropdown. Default: <div class='btn-group' style='display:block'></div>. Note that the original definition of the widget doesn't use the style definition. We've added it to fix a rendering bug. <P>
 * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
 */
public String getButtonContainer(){
  String value=(String)getStateHelper().eval(PropertyKeys.buttonContainer);
  return value;
}
Program: 57043
Project: 57043
Buggy source:
/** 
 * Renders the start of the input tag. This method is protected in order to allow third-party frameworks to derive from it.
 * @param rw the response writer
 * @param selectBooleanCheckbox the component to render
 * @throws IOException may be thrown by the response writer
 */
protected void renderInputTagHelper(ResponseWriter rw,FacesContext context,SelectBooleanCheckbox selectBooleanCheckbox,String clientId) throws IOException {
  rw.startElement("String_Node_Str",selectBooleanCheckbox);
  rw.writeAttribute("String_Node_Str",clientId + "String_Node_Str",null);
  rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  rw.endElement("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Renders the start of the input tag. This method is protected in order to allow third-party frameworks to derive from it.
 * @param rw the response writer
 * @param selectBooleanCheckbox the component to render
 * @throws IOException may be thrown by the response writer
 */
protected void renderInputTagHelper(ResponseWriter rw,FacesContext context,SelectBooleanCheckbox selectBooleanCheckbox,String clientId) throws IOException {
  rw.startElement("String_Node_Str",selectBooleanCheckbox);
  rw.writeAttribute("String_Node_Str",clientId + "String_Node_Str",null);
  rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  rw.endElement("String_Node_Str");
}
Program: 57044
Project: 57044
Buggy source:
private static StringBuilder generateAJAXCall(FacesContext context,IAJAXComponent component,String event){
  String complete=component.getOncomplete();
  StringBuilder cJS=new StringBuilder(150);
  String update=component.getUpdate();
  if (null == update) {
    update="String_Node_Str";
  }
  update=ExpressionResolver.getComponentIDs(context,(UIComponent)component,update);
  String process=component.getProcess();
  if (null == process) {
    if (component.getClass().getName().contains("String_Node_Str")) {
      process="String_Node_Str";
    }
 else {
      process="String_Node_Str";
    }
  }
  process=ExpressionResolver.getComponentIDs(context,(UIComponent)component,process);
  cJS.append("String_Node_Str").append("String_Node_Str" + update + "String_Node_Str").append("String_Node_Str").append(process).append("String_Node_Str");
  if (complete != null) {
    cJS.append("String_Node_Str" + complete + "String_Node_Str");
  }
 else   cJS.append("String_Node_Str");
  if (event != null) {
    cJS.append("String_Node_Str" + event + "String_Node_Str");
  }
  cJS.append("String_Node_Str");
  return cJS;
}

Fixed version (ground truth):
private static StringBuilder generateAJAXCall(FacesContext context,IAJAXComponent component,String event){
  String complete=component.getOncomplete();
  StringBuilder cJS=new StringBuilder(150);
  String update=component.getUpdate();
  if (null == update) {
    update="String_Node_Str";
  }
  update=ExpressionResolver.getComponentIDs(context,(UIComponent)component,update);
  String process=component.getProcess();
  if (null == process) {
    if (component.getClass().getName().contains("String_Node_Str")) {
      process="String_Node_Str";
    }
 else {
      process="String_Node_Str";
    }
  }
  process=ExpressionResolver.getComponentIDs(context,(UIComponent)component,process);
  cJS.append("String_Node_Str").append("String_Node_Str" + update + "String_Node_Str").append("String_Node_Str").append(process).append("String_Node_Str");
  if (complete != null) {
    cJS.append("String_Node_Str" + complete + "String_Node_Str");
  }
 else   cJS.append("String_Node_Str");
  if ((event != null) && (event.length() > 0)) {
    cJS.append("String_Node_Str" + event + "String_Node_Str");
  }
  cJS.append("String_Node_Str");
  return cJS;
}
Program: 57047
Project: 57047
Buggy source:
/** 
 * This methods receives and processes input made by the user. More specifically, it ckecks whether the user has interacted with the current b:selectBooleanCheckbox. The default implementation simply stores the input value in the list of submitted values. If the validation checks are passed, the values in the <code>submittedValues</code> list are store in the backend bean.
 * @param context the FacesContext.
 * @param component the current b:selectBooleanCheckbox.
 */
@Override public void decode(FacesContext context,UIComponent component){
  SelectBooleanCheckbox selectBooleanCheckbox=(SelectBooleanCheckbox)component;
  if (selectBooleanCheckbox.isDisabled() || selectBooleanCheckbox.isReadonly()) {
    return;
  }
  decodeBehaviors(context,selectBooleanCheckbox);
  String clientId=selectBooleanCheckbox.getClientId(context);
  String submittedValue=(String)context.getExternalContext().getRequestParameterMap().get(clientId);
  if (submittedValue != null) {
    selectBooleanCheckbox.setSubmittedValue("String_Node_Str".equals(submittedValue));
  }
  new AJAXRenderer().decode(context,component);
}

Fixed version (ground truth):
/** 
 * This methods receives and processes input made by the user. More specifically, it ckecks whether the user has interacted with the current b:selectBooleanCheckbox. The default implementation simply stores the input value in the list of submitted values. If the validation checks are passed, the values in the <code>submittedValues</code> list are store in the backend bean.
 * @param context the FacesContext.
 * @param component the current b:selectBooleanCheckbox.
 */
@Override public void decode(FacesContext context,UIComponent component){
  SelectBooleanCheckbox selectBooleanCheckbox=(SelectBooleanCheckbox)component;
  if (selectBooleanCheckbox.isDisabled() || selectBooleanCheckbox.isReadonly()) {
    return;
  }
  decodeBehaviors(context,selectBooleanCheckbox);
  String clientId=selectBooleanCheckbox.getClientId(context);
  String submittedValue=(String)context.getExternalContext().getRequestParameterMap().get(clientId);
  String event=(String)context.getExternalContext().getRequestParameterMap().get("String_Node_Str");
  if (submittedValue != null) {
    selectBooleanCheckbox.setSubmittedValue("String_Node_Str".equals(submittedValue));
    if (clientId.contains("String_Node_Str"))     System.out.println(event + "String_Node_Str" + "String_Node_Str".equals(submittedValue));
  }
 else   if (context.getExternalContext().getRequestParameterMap().containsKey(clientId + "String_Node_Str")) {
    selectBooleanCheckbox.setSubmittedValue(false);
    if (clientId.contains("String_Node_Str"))     System.out.println(event + "String_Node_Str" + "String_Node_Str");
  }
  new AJAXRenderer().decode(context,component);
}
Program: 57048
Project: 57048
Buggy source:
public static String determineQualifiedId(UIComponent component){
  String qualifiedId="String_Node_Str";
  if (component instanceof NamingContainer)   qualifiedId=component.getId();
  while (component != null && (!(component instanceof UIViewRoot)) && (!(component instanceof UIForm))) {
    component=component.getParent();
    if (component instanceof NamingContainer)     qualifiedId=component.getId() + "String_Node_Str" + qualifiedId;
  }
  return "String_Node_Str" + qualifiedId;
}

Fixed version (ground truth):
public static String determineQualifiedId(UIComponent component){
  String qualifiedId="String_Node_Str";
  if (component instanceof NamingContainer)   return "String_Node_Str";
  while (component != null && (!(component instanceof UIViewRoot)) && (!(component instanceof NamingContainer))) {
    component=component.getParent();
    if (component instanceof NamingContainer)     qualifiedId=component.getId() + "String_Node_Str" + qualifiedId;
  }
  return "String_Node_Str" + qualifiedId;
}
Program: 57049
Project: 57049
Buggy source:
public List<UIComponent> resolve(UIComponent component,List<UIComponent> parentComponents,String currentId,String originalExpression,String[] parameters){
  List<UIComponent> result=new ArrayList<UIComponent>();
  for (  UIComponent parent : parentComponents) {
    while ((!(parent instanceof UIViewRoot)) && (!(parent instanceof NamingContainer))) {
      parent=parent.getParent();
    }
    String parentId=ExpressionResolverUtilities.determineQualifiedId(parent);
    String childId;
    if (parentId.endsWith("String_Node_Str"))     childId=parentId + currentId;
 else     childId=parentId + "String_Node_Str" + currentId;
    UIComponent c=component.findComponent(childId);
    if (null != c) {
      result.add(c);
    }
  }
  if (result.size() > 0) {
    return result;
  }
  throw new FacesException("String_Node_Str" + currentId + "String_Node_Str"+ originalExpression);
}

Fixed version (ground truth):
public List<UIComponent> resolve(UIComponent component,List<UIComponent> parentComponents,String currentId,String originalExpression,String[] parameters){
  List<UIComponent> result=new ArrayList<UIComponent>();
  for (  UIComponent parent : parentComponents) {
    while ((!(parent instanceof UIViewRoot)) && (!(parent instanceof NamingContainer))) {
      parent=parent.getParent();
    }
    String parentId=ExpressionResolverUtilities.determineQualifiedId(parent);
    String childId;
    if (parentId.length() == 0)     childId=currentId;
 else     if (parentId.endsWith("String_Node_Str"))     childId=parentId + currentId;
 else     childId=parentId + "String_Node_Str" + currentId;
    UIComponent c=component.findComponent(childId);
    if (null == c) {
      c=component.findComponent("String_Node_Str" + childId);
    }
    if (null != c) {
      result.add(c);
    }
  }
  if (result.size() > 0) {
    return result;
  }
  throw new FacesException("String_Node_Str" + currentId + "String_Node_Str"+ originalExpression);
}
Program: 57051
Project: 57051
Buggy source:
@Override public void encodeBegin(FacesContext context,UIComponent component) throws IOException {
  if (!component.isRendered()) {
    return;
  }
  CommandButton commandButton=(CommandButton)component;
  ResponseWriter rw=context.getResponseWriter();
  String CID=component.getClientId(context);
  String type=commandButton.getType();
  if (null == type)   type="String_Node_Str";
  String style=commandButton.getStyle();
  rw.startElement("String_Node_Str",component);
  rw.writeAttribute("String_Node_Str",type,null);
  rw.writeAttribute("String_Node_Str",CID,"String_Node_Str");
  rw.writeAttribute("String_Node_Str",CID,"String_Node_Str");
  Tooltip.generateTooltip(context,commandButton,rw);
  writeAttribute(rw,H.STYLE,style,H.STYLE);
  rw.writeAttribute("String_Node_Str",getStyleClasses(commandButton),"String_Node_Str");
  String title=commandButton.getTitle();
  if (title != null && title.length() > 0) {
    rw.writeAttribute(H.TITLE,title,H.TITLE);
  }
  if (commandButton.isDisabled()) {
    rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  }
  if (!type.equals("String_Node_Str") && !type.equals("String_Node_Str")) {
    String formId=R.findComponentFormId(context,component);
    if (formId == null) {
      throw new FacesException("String_Node_Str" + CID + "String_Node_Str");
    }
  }
  AJAXRenderer.generateJavaScriptHandlers(context,commandButton,rw,CID,type);
  R.encodeHTML4DHTMLAttrs(rw,commandButton.getAttributes(),A.ALLBUTTON_ATTRS);
}

Fixed version (ground truth):
@Override public void encodeBegin(FacesContext context,UIComponent component) throws IOException {
  if (!component.isRendered()) {
    return;
  }
  CommandButton commandButton=(CommandButton)component;
  ResponseWriter rw=context.getResponseWriter();
  String CID=component.getClientId(context);
  String type=commandButton.getType();
  if (null == type)   type="String_Node_Str";
  String style=commandButton.getStyle();
  rw.startElement("String_Node_Str",component);
  rw.writeAttribute("String_Node_Str",type,null);
  rw.writeAttribute("String_Node_Str",CID,"String_Node_Str");
  rw.writeAttribute("String_Node_Str",CID,"String_Node_Str");
  Tooltip.generateTooltip(context,commandButton,rw);
  writeAttribute(rw,H.STYLE,style,H.STYLE);
  rw.writeAttribute("String_Node_Str",getStyleClasses(commandButton),"String_Node_Str");
  String title=commandButton.getTitle();
  if (title != null && title.length() > 0) {
    rw.writeAttribute(H.TITLE,title,H.TITLE);
  }
  if (commandButton.isDisabled()) {
    rw.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  }
  if (!type.equals("String_Node_Str") && !type.equals("String_Node_Str")) {
    String formId=R.findComponentFormId(context,component);
    if (formId == null) {
      throw new FacesException("String_Node_Str" + CID + "String_Node_Str");
    }
  }
  AJAXRenderer.generateBootsFacesAJAXAndJavaScriptForCommandButtons(context,commandButton,rw);
  R.encodeHTML4DHTMLAttrs(rw,commandButton.getAttributes(),A.ALLBUTTON_ATTRS);
}
Program: 57053
Project: 57053
Buggy source:
/** 
 * This methods receives and processes input made by the user. More specifically, it ckecks whether the user has interacted with the current b:panel. The default implementation simply stores the input value in the list of submitted values. If the validation checks are passed, the values in the <code>submittedValues</code> list are store in the backend bean.
 * @param context the FacesContext.
 * @param component the current b:panel.
 */
@Override public void decode(FacesContext context,UIComponent component){
  Panel panel=(Panel)component;
  decodeBehaviors(context,panel);
  String clientId=panel.getClientId(context);
  String collapseStateId=clientId.replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
  String submittedValue=(String)context.getExternalContext().getRequestParameterMap().get(collapseStateId);
  if (submittedValue != null) {
    panel.setCollapsed(Boolean.valueOf(submittedValue));
  }
}

Fixed version (ground truth):
/** 
 * This methods receives and processes input made by the user. More specifically, it ckecks whether the user has interacted with the current b:panel. The default implementation simply stores the input value in the list of submitted values. If the validation checks are passed, the values in the <code>submittedValues</code> list are store in the backend bean.
 * @param context the FacesContext.
 * @param component the current b:panel.
 */
@Override public void decode(FacesContext context,UIComponent component){
  Panel panel=(Panel)component;
  decodeBehaviors(context,panel);
  String clientId=panel.getClientId(context);
  String collapseStateId=clientId.replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
  String submittedValue=(String)context.getExternalContext().getRequestParameterMap().get(collapseStateId);
  if (submittedValue != null) {
    if (Boolean.valueOf(submittedValue) != panel.isCollapsed())     panel.setCollapsed(Boolean.valueOf(submittedValue));
  }
}
Program: 57055
Project: 57055
Buggy source:
private void addResourceIfNecessary(UIViewRoot root,FacesContext context,UIOutput output){
  for (  UIComponent c : root.getComponentResources(context,"String_Node_Str")) {
    String library=(String)c.getAttributes().get("String_Node_Str");
    String name=(String)c.getAttributes().get("String_Node_Str");
    if (library != null && library.equals(output.getAttributes().get("String_Node_Str"))) {
      if (name != null && name.equals(output.getAttributes().get("String_Node_Str"))) {
        return;
      }
    }
  }
  root.addComponentResource(context,output,"String_Node_Str");
}

Fixed version (ground truth):
private void addResourceIfNecessary(UIViewRoot root,FacesContext context,UIOutput output){
  for (  UIComponent c : root.getComponentResources(context,"String_Node_Str")) {
    String library=(String)c.getAttributes().get("String_Node_Str");
    String name=(String)c.getAttributes().get("String_Node_Str");
    if (library != null && library.equals(output.getAttributes().get("String_Node_Str"))) {
      if (name != null && library.equals(output.getAttributes().get("String_Node_Str"))) {
        return;
      }
    }
  }
  root.addComponentResource(context,output,"String_Node_Str");
}
Program: 57056
Project: 57056
Buggy source:
private void addResourceIfNecessary(UIViewRoot root,FacesContext context,UIOutput output){
  for (  UIComponent c : root.getComponentResources(context,"String_Node_Str")) {
    String library=(String)c.getAttributes().get("String_Node_Str");
    String name=(String)c.getAttributes().get("String_Node_Str");
    if (library != null && library.equals(output.getAttributes().get("String_Node_Str"))) {
      if (name != null && library.equals(output.getAttributes().get("String_Node_Str"))) {
        return;
      }
    }
  }
  root.addComponentResource(context,output,"String_Node_Str");
}

Fixed version (ground truth):
private void addResourceIfNecessary(UIViewRoot root,FacesContext context,UIOutput output){
  for (  UIComponent c : root.getComponentResources(context,"String_Node_Str")) {
    String library=(String)c.getAttributes().get("String_Node_Str");
    String name=(String)c.getAttributes().get("String_Node_Str");
    if (library != null && library.equals(output.getAttributes().get("String_Node_Str"))) {
      if (name != null && name.equals(output.getAttributes().get("String_Node_Str"))) {
        return;
      }
    }
  }
  root.addComponentResource(context,output,"String_Node_Str");
}
Program: 57061
Project: 57061
Buggy source:
/** 
 * Renders the button. <br> General layout of the generated HTML code:<br> &lt;button class="btn btn-large" href="#">&lt;i class="icon-star">&lt;/i> Star&lt;/button>
 * @param context the current FacesContext
 * @throws IOException thrown if something's wrong with the ResponseWriter
 */
@Override public void encodeEnd(FacesContext context) throws IOException {
  encodeHTML(context,getAttributes());
}

Fixed version (ground truth):
/** 
 * Renders the button. <br> General layout of the generated HTML code:<br> &lt;button class="btn btn-large" href="#"%gt;&lt;i class="icon-star"&gt;&lt;/i&gt; Star&lt;/button&gt;
 * @param context the current FacesContext
 * @throws IOException thrown if something's wrong with the ResponseWriter
 */
@Override public void encodeEnd(FacesContext context) throws IOException {
  encodeHTML(context,getAttributes());
}
Program: 57062
Project: 57062
Buggy source:
/** 
 * <p>Returns the <code>label</code> property from the specified component.</p> Simplified and adapted version of the implementation of Mojarra 2.2.8-b02 (see MessageFactory).
 * @param context   - the <code>FacesContext</code> for the current request
 * @param component - the component of interest
 * @return the label, if any, of the component
 */
public String getLabel(FacesContext context){
  Object o=getAttributes().get("String_Node_Str");
  if (o == null || (o instanceof String && ((String)o).length() == 0)) {
    ValueExpression vex=getValueExpression("String_Node_Str");
    if (null != vex)     return (String)vex.getValue(context.getELContext());
  }
  return (String)getClientId(context);
}

Fixed version (ground truth):
/** 
 * <p>Returns the <code>label</code> property from the specified component.</p> Simplified and adapted version of the implementation of Mojarra 2.2.8-b02 (see MessageFactory).
 * @param context   - the <code>FacesContext</code> for the current request
 * @return the label, if any, of the component
 */
public String getLabel(FacesContext context){
  Object o=getAttributes().get("String_Node_Str");
  if (o == null || (o instanceof String && ((String)o).length() == 0)) {
    ValueExpression vex=getValueExpression("String_Node_Str");
    if (null != vex)     return (String)vex.getValue(context.getELContext());
  }
  return (String)getClientId(context);
}
Program: 57064
Project: 57064
Buggy source:
/** 
 * Generates the HTML of the tabs.
 * @param context the current FacesContext
 * @param writer the response writer
 * @param children the tabs
 * @throws IOException only thrown if something's wrong with the response writer
 */
private static void encodeTabs(FacesContext context,ResponseWriter writer,List<UIComponent> children,Map<String,Object> attributes,int currentlyActiveIndex) throws IOException {
  if (null != children) {
    int activeIndex=determineActiveIndex(attributes,currentlyActiveIndex);
    for (int index=0; index < children.size(); index++) {
      encodeTab(context,writer,children.get(index),index == activeIndex);
    }
  }
}

Fixed version (ground truth):
/** 
 * Generates the HTML of the tabs.
 * @param context the current FacesContext
 * @param writer the response writer
 * @param children the tabs
 * @throws IOException only thrown if something's wrong with the response writer
 */
private static void encodeTabs(FacesContext context,ResponseWriter writer,List<UIComponent> children,Map<String,Object> attributes,int currentlyActiveIndex,String hiddenInputFieldID) throws IOException {
  if (null != children) {
    int activeIndex=determineActiveIndex(attributes,currentlyActiveIndex);
    for (int index=0; index < children.size(); index++) {
      encodeTab(context,writer,children.get(index),index == activeIndex,hiddenInputFieldID,index);
    }
  }
}
Program: 57065
Project: 57065
Buggy source:
/** 
 * Generate the clickable entity of the tab.
 * @param writer the response writer
 * @param tab the tab to be rendered.
 * @param tabAttributes the attribute list of the tab.
 * @throws IOException only thrown if something's wrong with the response writer
 */
private static void encodeTabAnchorTag(ResponseWriter writer,UIComponent tab,Map<String,Object> tabAttributes) throws IOException {
  writer.startElement(A,tab);
  writer.writeAttribute(ROLE,"String_Node_Str",ROLE);
  writer.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  writer.writeAttribute(HREF,"String_Node_Str" + tab.getClientId().replace("String_Node_Str","String_Node_Str"),HREF);
  R.encodeHTML4DHTMLAttrs(writer,tabAttributes,TAB_ATTRS);
  writer.writeText(tabAttributes.get("String_Node_Str"),null);
  writer.endElement(A);
}

Fixed version (ground truth):
/** 
 * Generate the clickable entity of the tab.
 * @param writer the response writer
 * @param tab the tab to be rendered.
 * @param tabAttributes the attribute list of the tab.
 * @throws IOException only thrown if something's wrong with the response writer
 */
private static void encodeTabAnchorTag(ResponseWriter writer,UIComponent tab,Map<String,Object> tabAttributes,String hiddenInputFieldID,int tabindex) throws IOException {
  writer.startElement(A,tab);
  writer.writeAttribute(ROLE,"String_Node_Str",ROLE);
  writer.writeAttribute("String_Node_Str","String_Node_Str","String_Node_Str");
  writer.writeAttribute(HREF,"String_Node_Str" + tab.getClientId().replace("String_Node_Str","String_Node_Str"),HREF);
  String onclick="String_Node_Str" + hiddenInputFieldID + "String_Node_Str"+ String.valueOf(tabindex)+ "String_Node_Str";
  String userClick=(String)tabAttributes.get("String_Node_Str");
  if (null != userClick && userClick.trim().length() > 0) {
    onclick+=userClick;
  }
  writer.writeAttribute("String_Node_Str",onclick,"String_Node_Str");
  R.encodeHTML4DHTMLAttrs(writer,tabAttributes,TAB_ATTRS);
  writer.writeText(tabAttributes.get("String_Node_Str"),null);
  writer.endElement(A);
}
Program: 57066
Project: 57066
Buggy source:
/** 
 * Generate an individual tab. Basically, that's &lt;li role="presentation" class="active"&gt&lt;a href="#{clientID}" role="tab" data-toggle="tab"&lt; {{title}} &gt;/a&gt;
 * @param context the current FacesContext
 * @param writer the response writer
 * @param tab the tab to be rendered.
 * @param isActive is the current tab active?
 * @throws IOException only thrown if something's wrong with the response writer
 */
private static void encodeTab(FacesContext context,ResponseWriter writer,UIComponent tab,boolean isActive) throws IOException {
  writer.startElement(LI,tab);
  writer.writeAttribute(ROLE,"String_Node_Str",ROLE);
  Map<String,Object> tabAttributes=tab.getAttributes();
  String classes=isActive ? ACTIVE : "String_Node_Str";
  if (tabAttributes.containsKey(STYLECLASS)) {
    classes+="String_Node_Str";
    classes+=tabAttributes.get(STYLECLASS);
  }
  if (classes.length() > 0)   writer.writeAttribute(CLASS,classes,CLASS);
  encodeTabAnchorTag(writer,tab,tabAttributes);
  writer.endElement(LI);
}

Fixed version (ground truth):
/** 
 * Generate an individual tab. Basically, that's &lt;li role="presentation" class="active"&gt&lt;a href="#{clientID}" role="tab" data-toggle="tab"&lt; {{title}} &gt;/a&gt;
 * @param context the current FacesContext
 * @param writer the response writer
 * @param tab the tab to be rendered.
 * @param isActive is the current tab active?
 * @throws IOException only thrown if something's wrong with the response writer
 */
private static void encodeTab(FacesContext context,ResponseWriter writer,UIComponent tab,boolean isActive,String hiddenInputFieldID,int tabIndex) throws IOException {
  writer.startElement(LI,tab);
  writer.writeAttribute(ROLE,"String_Node_Str",ROLE);
  Map<String,Object> tabAttributes=tab.getAttributes();
  String classes=isActive ? ACTIVE : "String_Node_Str";
  if (tabAttributes.containsKey(STYLECLASS)) {
    classes+="String_Node_Str";
    classes+=tabAttributes.get(STYLECLASS);
  }
  if (classes.length() > 0)   writer.writeAttribute(CLASS,classes,CLASS);
  encodeTabAnchorTag(writer,tab,tabAttributes,hiddenInputFieldID,tabIndex);
  writer.endElement(LI);
}
Program: 57067
Project: 57067
Buggy source:
/** 
 * Generates the HTML code for the entire TabStrip.
 * @param context the current FacesContext
 * @throws IOException only thrown if something's wrong with the response writer
 */
@Override public void encodeBegin(FacesContext context) throws IOException {
  ResponseWriter writer=context.getResponseWriter();
  Map<String,Object> attributes=getAttributes();
  String clientId=getClientId(context);
  writer.startElement("String_Node_Str",this);
  writer.writeAttribute("String_Node_Str","String_Node_Str",null);
  writer.writeAttribute("String_Node_Str",clientId + "String_Node_Str","String_Node_Str");
  writer.writeAttribute("String_Node_Str",determineActiveIndex(attributes,currentlyActiveIndex),"String_Node_Str");
  writer.endElement("String_Node_Str");
  writer.startElement(UL,this);
  writer.writeAttribute(ID,clientId,ID);
  String classes="String_Node_Str";
  if (attributes.containsKey(STYLECLASS)) {
    classes+="String_Node_Str";
    classes+=attributes.get(STYLECLASS);
  }
  writer.writeAttribute(CLASS,classes,CLASS);
  String role="String_Node_Str";
  R.encodeHTML4DHTMLAttrs(writer,attributes,TAB_VIEW_ATTRS);
  if (attributes.containsKey(ROLE)) {
    role=(String)attributes.get(ROLE);
  }
  writer.writeAttribute(ROLE,role,ROLE);
  encodeTabs(context,writer,getChildren(),attributes,currentlyActiveIndex);
  writer.endElement("String_Node_Str");
  encodeTabContentPanes(context,writer,this,attributes,currentlyActiveIndex);
}

Fixed version (ground truth):
/** 
 * Generates the HTML code for the entire TabStrip.
 * @param context the current FacesContext
 * @throws IOException only thrown if something's wrong with the response writer
 */
@Override public void encodeBegin(FacesContext context) throws IOException {
  ResponseWriter writer=context.getResponseWriter();
  Map<String,Object> attributes=getAttributes();
  String clientId=getClientId(context);
  writer.startElement("String_Node_Str",this);
  writer.writeAttribute("String_Node_Str","String_Node_Str",null);
  final String hiddenInputFieldID=clientId + "String_Node_Str";
  writer.writeAttribute("String_Node_Str",hiddenInputFieldID,"String_Node_Str");
  writer.writeAttribute("String_Node_Str",hiddenInputFieldID,"String_Node_Str");
  writer.writeAttribute("String_Node_Str",determineActiveIndex(attributes,currentlyActiveIndex),"String_Node_Str");
  writer.endElement("String_Node_Str");
  writer.startElement(UL,this);
  writer.writeAttribute(ID,clientId,ID);
  String classes="String_Node_Str";
  if (attributes.containsKey(STYLECLASS)) {
    classes+="String_Node_Str";
    classes+=attributes.get(STYLECLASS);
  }
  writer.writeAttribute(CLASS,classes,CLASS);
  String role="String_Node_Str";
  R.encodeHTML4DHTMLAttrs(writer,attributes,TAB_VIEW_ATTRS);
  if (attributes.containsKey(ROLE)) {
    role=(String)attributes.get(ROLE);
  }
  writer.writeAttribute(ROLE,role,ROLE);
  encodeTabs(context,writer,getChildren(),attributes,currentlyActiveIndex,hiddenInputFieldID);
  writer.endElement("String_Node_Str");
  encodeTabContentPanes(context,writer,this,attributes,currentlyActiveIndex);
}
Program: 57068
Project: 57068
Buggy source:
/** 
 * Generate an individual tab. Basically, that's &lt;li role="presentation" class="active"&gt&lt;a href="#{clientID}" role="tab" data-toggle="tab"&lt; {{title}} &gt;/a&gt;
 * @param context the current FacesContext
 * @param writer the response writer
 * @param tab the tab to be rendered.
 * @param isActive is the current tab active?
 * @throws IOException only thrown if something's wrong with the response writer
 */
private static void encodeTab(FacesContext context,ResponseWriter writer,UIComponent tab,boolean isActive) throws IOException {
  writer.startElement(LI,tab);
  writer.writeAttribute(ROLE,"String_Node_Str",ROLE);
  Map<String,Object> tabAttributes=tab.getAttributes();
  String classes=isActive ? ACTIVE : "String_Node_Str";
  if (tabAttributes.containsKey(STYLECLASS)) {
    classes+="String_Node_Str";
    classes+=tabAttributes.get(STYLECLASS);
  }
  writer.writeAttribute(CLASS,classes,CLASS);
  encodeTabAnchorTag(writer,tab,tabAttributes);
  writer.endElement(LI);
}

Fixed version (ground truth):
/** 
 * Generate an individual tab. Basically, that's &lt;li role="presentation" class="active"&gt&lt;a href="#{clientID}" role="tab" data-toggle="tab"&lt; {{title}} &gt;/a&gt;
 * @param context the current FacesContext
 * @param writer the response writer
 * @param tab the tab to be rendered.
 * @param isActive is the current tab active?
 * @throws IOException only thrown if something's wrong with the response writer
 */
private static void encodeTab(FacesContext context,ResponseWriter writer,UIComponent tab,boolean isActive) throws IOException {
  writer.startElement(LI,tab);
  writer.writeAttribute(ROLE,"String_Node_Str",ROLE);
  Map<String,Object> tabAttributes=tab.getAttributes();
  String classes=isActive ? ACTIVE : "String_Node_Str";
  if (tabAttributes.containsKey(STYLECLASS)) {
    classes+="String_Node_Str";
    classes+=tabAttributes.get(STYLECLASS);
  }
  if (classes.length() > 0)   writer.writeAttribute(CLASS,classes,CLASS);
  encodeTabAnchorTag(writer,tab,tabAttributes);
  writer.endElement(LI);
}
Program: 57069
Project: 57069
Buggy source:
/** 
 * Merge the column span information and the optional columnClasses attribute.
 * @param colSpans the integer array returned by getColSpans().
 * @return null or an array of String consisting of the CSS classes.
 */
protected String[] getColumnClasses(int[] colSpans){
  String columnsCSV=getColumnClasses();
  String[] columnClasses;
  if (null == columnsCSV)   columnClasses=null;
 else {
    columnClasses=columnsCSV.split("String_Node_Str");
    if (columnClasses.length > colSpans.length) {
      throw new FacesException("String_Node_Str");
    }
  }
  String[] result=new String[colSpans.length];
  for (int i=0; i < colSpans.length; i++) {
    if (columnClasses == null) {
      result[i]="String_Node_Str" + colSpans[i];
    }
 else {
      String current=columnClasses[i % columnClasses.length];
      if (current.contains("String_Node_Str")) {
        result[i]=current;
      }
 else {
        result[i]="String_Node_Str" + colSpans[i] + "String_Node_Str"+ current;
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Merge the column span information and the optional columnClasses attribute.
 * @param colSpans the integer array returned by getColSpans().
 * @return null or an array of String consisting of the CSS classes.
 */
protected String[] getColumnClasses(int[] colSpans){
  String columnsCSV=getColumnClasses();
  String[] columnClasses;
  if (null == columnsCSV)   columnClasses=null;
 else {
    columnClasses=columnsCSV.split("String_Node_Str");
    if (columnClasses.length > colSpans.length) {
      throw new FacesException("String_Node_Str");
    }
  }
  String size=getSize();
  if (null == size || size.equals("String_Node_Str"))   size="String_Node_Str";
  String[] result=new String[colSpans.length];
  for (int i=0; i < colSpans.length; i++) {
    if (columnClasses == null) {
      result[i]="String_Node_Str" + size + "String_Node_Str"+ colSpans[i];
    }
 else {
      String current=columnClasses[i % columnClasses.length];
      if (current.contains("String_Node_Str")) {
        result[i]=current;
      }
 else {
        result[i]="String_Node_Str" + size + "String_Node_Str"+ colSpans[i]+ "String_Node_Str"+ current;
      }
    }
  }
  return result;
}
Program: 57070
Project: 57070
Buggy source:
@Override public void decode(FacesContext context){
  String subVal=(String)context.getExternalContext().getRequestParameterMap().get(getClientId(context));
  if (subVal != null) {
    this.setSubmittedValue(subVal);
    this.setValid(true);
  }
}

Fixed version (ground truth):
@Override public void decode(FacesContext context){
  InputText inputText=(InputText)this;
  if (inputText.isDisabled() || inputText.isReadonly()) {
    return;
  }
  decodeBehaviors(context,inputText);
  String clientId=inputText.getClientId(context);
  String submittedValue=(String)context.getExternalContext().getRequestParameterMap().get(clientId);
  if (submittedValue != null) {
    inputText.setSubmittedValue(submittedValue);
  }
}
Program: 57072
Project: 57072
Buggy source:
/** 
 * Encodes component attributes (HTML 4 + DHTML)
 * @param rw ResponseWriter instance
 * @param attrs
 * @param alist
 * @throws IOException 
 */
public static void encodeHTML4DHTMLAttrs(ResponseWriter rw,Map<String,Object> attrs,String[] alist) throws IOException {
  for (  String a : alist) {
    if (attrs.get(a) != null) {
      String val=A.asString(attrs.get(a));
      if (val != null && val.length() > 0) {
        rw.writeAttribute(a,val,a);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Encodes component attributes (HTML 4 + DHTML)
 * @param rw ResponseWriter instance
 * @param attrs
 * @param alist
 * @throws IOException 
 */
public static void encodeHTML4DHTMLAttrs(ResponseWriter rw,Map<String,Object> attrs,String[] alist) throws IOException {
  for (  String a : alist) {
    if (attrs.containsKey(a)) {
      if (attrs.get(a) != null) {
        String val=A.asString(attrs.get(a));
        if (val != null && val.length() > 0) {
          rw.writeAttribute(a,val,a);
        }
      }
    }
  }
}
Program: 57074
Project: 57074
Buggy source:
/** 
 * Returns the complementary error function. <p>erfc(x) = 2/&radic;&pi; <sub>x</sub>&int;<sup>&infin;</sup> e<sup>-t<sup>2</sup></sup>dt <br> = 1 -   {@link #erf(double) erf(x)} </p><p>This implementation computes erfc(x) using the {@link Gamma#regularizedGammaQ(double,double,double,int) regularized gamma function}, following <a href="http://mathworld.wolfram.com/Erf.html"> Erf</a>, equation (3).</p> <p>The value returned is always between 0 and 2 (inclusive). If   {@code abs(x) > 40}, then   {@code erf(x)} is indistinguishable fromeither 0 or 2 as a double, so the appropriate extreme value is returned. </p>
 * @param x the value
 * @return the complementary error function erfc(x)
 * @throws org.apache.commons.math4.exception.MaxCountExceededException if the algorithm fails to converge.
 * @see Gamma#regularizedGammaQ(double,double,double,int)
 * @since 2.2
 */
public static double erfc(double x){
  if (FastMath.abs(x) > 40) {
    return x > 0 ? 0 : 2;
  }
  final double ret=Gamma.regularizedGammaQ(0.5,x * x,1.0e-15,10000);
  return x < 0 ? 2 - ret : ret;
}

Fixed version (ground truth):
/** 
 * Returns the complementary error function. <p>erfc(x) = 2/&radic;&pi; <sub>x</sub>&int;<sup>&infin;</sup> e<sup>-t<span style="position: relative; top: -.5em">2</span></sup>dt <br> = 1 -   {@link #erf(double) erf(x)} </p><p>This implementation computes erfc(x) using the {@link Gamma#regularizedGammaQ(double,double,double,int) regularized gamma function}, following <a href="http://mathworld.wolfram.com/Erf.html"> Erf</a>, equation (3).</p> <p>The value returned is always between 0 and 2 (inclusive). If   {@code abs(x) > 40}, then   {@code erf(x)} is indistinguishable fromeither 0 or 2 as a double, so the appropriate extreme value is returned. </p>
 * @param x the value
 * @return the complementary error function erfc(x)
 * @throws org.apache.commons.math4.exception.MaxCountExceededException if the algorithm fails to converge.
 * @see Gamma#regularizedGammaQ(double,double,double,int)
 * @since 2.2
 */
public static double erfc(double x){
  if (FastMath.abs(x) > 40) {
    return x > 0 ? 0 : 2;
  }
  final double ret=Gamma.regularizedGammaQ(0.5,x * x,1.0e-15,10000);
  return x < 0 ? 2 - ret : ret;
}
Program: 57075
Project: 57075
Buggy source:
/** 
 * Returns the next pseudorandom, uniformly distributed <code>long</code> value from this random number generator's sequence.  All 2<font size="-1"><sup>64</sup></font> possible   {@code long} valuesshould be produced with (approximately) equal probability.
 * @return  the next pseudorandom, uniformly distributed <code>long</code>value from this random number generator's sequence
 */
long nextLong();

Fixed version (ground truth):
/** 
 * Returns the next pseudorandom, uniformly distributed <code>long</code> value from this random number generator's sequence.  All 2<sup style="font-size: smaller">64</sup> possible   {@code long} valuesshould be produced with (approximately) equal probability.
 * @return  the next pseudorandom, uniformly distributed <code>long</code>value from this random number generator's sequence
 */
long nextLong();
Program: 57077
Project: 57077
Buggy source:
/** 
 * Compute the <i>distance</i> between two rotations. <p>The <i>distance</i> is intended here as a way to check if two rotations are almost similar (i.e. they transform vectors the same way) or very different. It is mathematically defined as the angle of the rotation r that prepended to one of the rotations gives the other one:</p> <pre> r<sub>1</sub>(r) = r<sub>2</sub> </pre> <p>This distance is an angle between 0 and &pi;. Its value is the smallest possible upper bound of the angle in radians between r<sub>1</sub>(v) and r<sub>2</sub>(v) for all possible vectors v. This upper bound is reached for some v. The distance is equal to 0 if and only if the two rotations are identical.</p> <p>Comparing two rotations should always be done using this value rather than for example comparing the components of the quaternions. It is much more stable, and has a geometric meaning. Also comparing quaternions components is error prone since for example quaternions (0.36, 0.48, -0.48, -0.64) and (-0.36, -0.48, 0.48, 0.64) represent exactly the same rotation despite their components are different (they are exact opposites).</p>
 * @param r1 first rotation
 * @param r2 second rotation
 * @param < T > the type of the field elements
 * @return <i>distance</i> between r1 and r2
 */
public static <T extends RealFieldElement<T>>T distance(final FieldRotation<T> r1,final FieldRotation<T> r2){
  return r1.composeInverseInternal(r2).getAngle();
}

Fixed version (ground truth):
/** 
 * Compute the <i>distance</i> between two rotations. <p>The <i>distance</i> is intended here as a way to check if two rotations are almost similar (i.e. they transform vectors the same way) or very different. It is mathematically defined as the angle of the rotation r that prepended to one of the rotations gives the other one:</p> <div style="white-space: pre"><code> r<sub>1</sub>(r) = r<sub>2</sub> </code></div> <p>This distance is an angle between 0 and &pi;. Its value is the smallest possible upper bound of the angle in radians between r<sub>1</sub>(v) and r<sub>2</sub>(v) for all possible vectors v. This upper bound is reached for some v. The distance is equal to 0 if and only if the two rotations are identical.</p> <p>Comparing two rotations should always be done using this value rather than for example comparing the components of the quaternions. It is much more stable, and has a geometric meaning. Also comparing quaternions components is error prone since for example quaternions (0.36, 0.48, -0.48, -0.64) and (-0.36, -0.48, 0.48, 0.64) represent exactly the same rotation despite their components are different (they are exact opposites).</p>
 * @param r1 first rotation
 * @param r2 second rotation
 * @param < T > the type of the field elements
 * @return <i>distance</i> between r1 and r2
 */
public static <T extends RealFieldElement<T>>T distance(final FieldRotation<T> r1,final FieldRotation<T> r2){
  return r1.composeInverseInternal(r2).getAngle();
}