nus-yam/ex-repair huggingface dataset:
Program: 16519
Project: 16519
Buggy source:
/** 
 * Callback if a list item has been inserted. <p> Note: it won't be called if other kind of child is inserted. <p> When this method is called, the index is correct. <p> Default: invalidate if it is the paging mold and it affects the view of the active page.
 * @since 3.0.5
 */
protected void afterInsert(Component comp){
  if (comp instanceof Listitem && _model instanceof Selectable) {
    final Listitem item=(Listitem)comp;
    if (((Selectable)_model).getSelection().contains(_model.getElementAt(item.getIndex()))) {
      addItemToSelection(item);
    }
  }
  updateVisibleCount((Listitem)comp,false);
  checkInvalidateForMoved((Listitem)comp,false);
}

Fixed version (ground truth):
/** 
 * Callback if a list item has been inserted. <p> Note: it won't be called if other kind of child is inserted. <p> When this method is called, the index is correct. <p> Default: invalidate if it is the paging mold and it affects the view of the active page.
 * @since 3.0.5
 */
protected void afterInsert(Component comp){
  if (comp instanceof Listitem && _model instanceof Selectable && (isLoadingModel() || isSyncingModel())) {
    final Listitem item=(Listitem)comp;
    if (((Selectable)_model).getSelection().contains(_model.getElementAt(item.getIndex()))) {
      addItemToSelection(item);
    }
  }
  updateVisibleCount((Listitem)comp,false);
  checkInvalidateForMoved((Listitem)comp,false);
}
Program: 16521
Project: 16521
Buggy source:
/** 
 * Synchronizes the listbox to be consistent with the specified model.
 * @param min the lower index that a range of invalidated items
 * @param max the higher index that a range of invalidated items
 */
public void syncModel(int offset,int limit){
  int min=offset;
  int max=offset + limit - 1;
  final ListModel _model=_listbox.getModel();
  final int newsz=_model.getSize();
  final int oldsz=_listbox.getItemCount();
  final Paginal _pgi=_listbox.getPaginal();
  final boolean inPaging=inPagingMold();
  int newcnt=newsz - oldsz;
  int atg=_pgi != null ? _listbox.getActivePage() : 0;
  ListitemRenderer renderer=null;
  Component next=null;
  if (oldsz > 0) {
    if (min < 0)     min=0;
 else     if (min > oldsz - 1)     min=oldsz - 1;
    if (max < 0)     max=oldsz - 1;
 else     if (max > oldsz - 1)     max=oldsz - 1;
    if (min > max) {
      int t=min;
      min=max;
      max=t;
    }
    int cnt=max - min + 1;
    if (_model instanceof GroupsListModel) {
      newcnt+=cnt;
      if (newcnt > 50 && !inPaging)       _listbox.invalidate();
      Component comp=_listbox.getItemAtIndex(max);
      next=comp.getNextSibling();
      while (--cnt >= 0) {
        Component p=comp.getPreviousSibling();
        comp.detach();
        comp=p;
      }
    }
 else {
      int addcnt=0;
      Component item=_listbox.getItemAtIndex(min);
      while (--cnt >= 0) {
        next=item.getNextSibling();
        if (cnt < -newcnt) {
          item.detach();
        }
 else         if (((Listitem)item).isLoaded()) {
          if (renderer == null)           renderer=(ListitemRenderer)getRealRenderer();
          item.detach();
          _listbox.insertBefore(newUnloadedItem(renderer,min++),next);
          ++addcnt;
        }
        item=next;
      }
      if ((addcnt > 50 || addcnt + newcnt > 50) && !inPagingMold())       _listbox.invalidate();
    }
  }
 else {
    min=0;
  }
  for (; --newcnt >= 0; ++min) {
    if (renderer == null)     renderer=(ListitemRenderer)getRealRenderer();
    _listbox.insertBefore(newUnloadedItem(renderer,min),next);
  }
  if (_pgi != null) {
    if (atg >= _pgi.getPageCount())     atg=_pgi.getPageCount() - 1;
    _pgi.setActivePage(atg);
  }
}

Fixed version (ground truth):
/** 
 * Synchronizes the listbox to be consistent with the specified model.
 * @param min the lower index that a range of invalidated items
 * @param max the higher index that a range of invalidated items
 */
public void syncModel(int offset,int limit){
  _listbox.setAttribute(Listbox.SYNCING_MODEL,Boolean.TRUE);
  try {
    syncModel0(offset,limit);
  }
  finally {
    _listbox.setAttribute(Listbox.SYNCING_MODEL,null);
  }
}
Program: 16522
Project: 16522
Buggy source:
/** 
 * Organizes groups based sorted data. <p>There are three steps to re-group data:  {@link #sortDataInGroupOrder},   {@link #organizeGroup} and then{@link #sortGroupData}. <p>It is the second step of grouping. It creates group data based on the data sorted in the group order by  {@link #sortDataInGroupOrder}.
 * @param cmpr the comparator used to compare data in the group order.Notice that the comparator is never an instance of  {@link GroupComparator}. The implementation just uses   {@link Comparator#compare} to sortthe data.
 */
protected void organizeGroup(Comparator cmpr,int col){
  List group=new ArrayList();
  List gdata=null;
  Object last=null;
  Object curr=null;
  for (int i=0; i < _nativedata.length; i++) {
    curr=_nativedata[i];
    boolean hitn=false;
    boolean hita=false;
    if (last == null || cmpr.compare(last,curr) != 0) {
      hitn=true;
      gdata=new ArrayList();
      group.add(gdata);
    }
    gdata.add(curr);
    last=_nativedata[i];
  }
  List[] gd=new List[group.size()];
  group.toArray(gd);
  _data=new Object[gd.length][];
  _foots=new Object[_data.length];
  _heads=new Object[_data.length];
  for (int i=0; i < gd.length; i++) {
    gdata=(List)gd[i];
    _data[i]=new Object[gdata.size()];
    gdata.toArray(_data[i]);
    _heads[i]=createGroupHead(_data[i],i,col);
    _foots[i]=createGroupFoot(_data[i],i,col);
  }
}

Fixed version (ground truth):
/** 
 * Organizes groups based sorted data. <p>There are three steps to re-group data:  {@link #sortDataInGroupOrder},   {@link #organizeGroup} and then{@link #sortGroupData}. <p>It is the second step of grouping. It creates group data based on the data sorted in the group order by  {@link #sortDataInGroupOrder}.
 * @param cmpr the comparator used to compare data in the group order.Notice that the comparator is never an instance of  {@link GroupComparator}. The implementation just uses   {@link Comparator#compare} to sortthe data.
 * @param col column index
 */
protected void organizeGroup(Comparator cmpr,int col){
  List group=new ArrayList();
  List gdata=null;
  Object last=null;
  Object curr=null;
  for (int i=0; i < _nativedata.length; i++) {
    curr=_nativedata[i];
    boolean hitn=false;
    boolean hita=false;
    if (last == null || cmpr.compare(last,curr) != 0) {
      hitn=true;
      gdata=new ArrayList();
      group.add(gdata);
    }
    gdata.add(curr);
    last=_nativedata[i];
  }
  List[] gd=new List[group.size()];
  group.toArray(gd);
  _data=new Object[gd.length][];
  _foots=new Object[_data.length];
  _heads=new Object[_data.length];
  _closes=new boolean[_data.length];
  for (int i=0; i < gd.length; i++) {
    gdata=(List)gd[i];
    _data[i]=new Object[gdata.size()];
    gdata.toArray(_data[i]);
    _heads[i]=createGroupHead(_data[i],i,col);
    _foots[i]=createGroupFoot(_data[i],i,col);
    _closes[i]=createGroupClose(_data[i],i,col);
  }
}
Program: 16523
Project: 16523
Buggy source:
public void group(final Comparator cmpr,boolean ascending,int col){
  Comparator cmprx;
  if (cmpr instanceof GroupComparator) {
    cmprx=new Comparator(){
      public int compare(      Object o1,      Object o2){
        return ((GroupComparator)cmpr).compareGroup(o1,o2);
      }
    }
;
  }
 else {
    cmprx=cmpr;
  }
  sortDataInGroupOrder(cmprx,ascending,col);
  organizeGroup(cmprx,col);
  if (cmprx != cmpr)   sortAllGroupData(cmpr,ascending,col);
  fireEvent(GroupsDataEvent.GROUPS_CHANGED,-1,-1,-1);
}

Fixed version (ground truth):
public void group(final Comparator cmpr,boolean ascending,int col){
  Comparator cmprx;
  if (cmpr instanceof GroupComparator) {
    cmprx=new Comparator(){
      public int compare(      Object o1,      Object o2){
        return ((GroupComparator)cmpr).compareGroup(o1,o2);
      }
    }
;
  }
 else {
    cmprx=cmpr;
  }
  sortDataInGroupOrder(cmprx,ascending,col);
  organizeGroup(cmprx,col);
  if (cmprx != cmpr)   sortAllGroupData(cmpr,ascending,col);
  fireEvent(GroupsDataEvent.GROUPS_RESET,-1,-1,-1);
}
Program: 16524
Project: 16524
Buggy source:
/** 
 * Handles a private event, onInitRender. It is used only for implementation, and you rarely need to invoke it explicitly.
 */
public void onInitRender(){
  removeAttribute(ATTR_ON_INIT_RENDER_POSTED);
  final Renderer renderer=new Renderer();
  try {
    int pgsz, ofs;
    if (inPagingMold()) {
      pgsz=_pgi.getPageSize();
      ofs=_pgi.getActivePage() * pgsz;
    }
 else {
      pgsz=getDataLoader().getLimit();
      ofs=getDataLoader().getOffset();
    }
    final int cnt=_rows.getChildren().size();
    if (ofs >= cnt) {
      ofs=cnt - pgsz;
      if (ofs < 0)       ofs=0;
    }
    int j=0;
    for (Iterator it=_rows.getChildren().listIterator(ofs); j < pgsz && it.hasNext(); ++j)     renderer.render((Row)it.next());
  }
 catch (  Throwable ex) {
    renderer.doCatch(ex);
  }
 finally {
    renderer.doFinally();
  }
}

Fixed version (ground truth):
/** 
 * Handles a private event, onInitRender. It is used only for implementation, and you rarely need to invoke it explicitly.
 */
public void onInitRender(){
  removeAttribute(ATTR_ON_INIT_RENDER_POSTED);
  final Renderer renderer=new Renderer();
  try {
    int pgsz, ofs;
    if (inPagingMold()) {
      pgsz=_pgi.getPageSize();
      ofs=_pgi.getActivePage() * pgsz;
    }
 else {
      pgsz=getDataLoader().getLimit();
      ofs=getDataLoader().getOffset();
    }
    final int cnt=_rows.getChildren().size();
    if (ofs >= cnt) {
      ofs=cnt - pgsz;
      if (ofs < 0)       ofs=0;
    }
    int j=0;
    int realOfs=ofs - getDataLoader().getOffset();
    if (realOfs < 0)     realOfs=0;
    boolean open=true;
    for (Iterator it=_rows.getChildren().listIterator(realOfs); j < pgsz && it.hasNext(); ) {
      final Row row=(Row)(Row)it.next();
      if (row.isVisible() && (open || row instanceof Groupfoot || row instanceof Group)) {
        renderer.render(row);
        ++j;
      }
      if (row instanceof Group)       open=((Group)row).isOpen();
    }
  }
 catch (  Throwable ex) {
    renderer.doCatch(ex);
  }
 finally {
    renderer.doFinally();
  }
}
Program: 16525
Project: 16525
Buggy source:
private void init(){
  _heads=new AbstractCollection(){
    public int size(){
      int sz=getChildren().size();
      if (_rows != null)       --sz;
      if (_foot != null)       --sz;
      if (_paging != null)       --sz;
      if (_frozen != null)       --sz;
      return sz;
    }
    public Iterator iterator(){
      return new Iter();
    }
  }
;
  this.addEventListener("String_Node_Str",_gridInitListener=new EventListener(){
    public void onEvent(    Event event) throws Exception {
      if (_gridInitListener != null) {
        Grid.this.removeEventListener("String_Node_Str",_gridInitListener);
        _gridInitListener=null;
      }
      final DataLoader loader=getDataLoader();
      Paginal pgi=getPaginal();
      if (pgi != null)       pgi.setTotalSize(loader.getTotalSize());
    }
  }
);
  Events.postEvent(new Event("String_Node_Str",this));
}

Fixed version (ground truth):
private void init(){
  _heads=new AbstractCollection(){
    public int size(){
      int sz=getChildren().size();
      if (_rows != null)       --sz;
      if (_foot != null)       --sz;
      if (_paging != null)       --sz;
      if (_frozen != null)       --sz;
      return sz;
    }
    public Iterator iterator(){
      return new Iter();
    }
  }
;
  this.addEventListener("String_Node_Str",_gridInitListener=new EventListener(){
    public void onEvent(    Event event) throws Exception {
      if (_gridInitListener != null) {
        Grid.this.removeEventListener("String_Node_Str",_gridInitListener);
        _gridInitListener=null;
      }
      if (_dataLoader != null) {
        final boolean rod=evalRod();
        if (_rod != rod) {
          if (_model != null) {
            getRows().getChildren().clear();
            _dataLoader=null;
            setModel(_model);
          }
 else {
            _dataLoader=null;
          }
        }
      }
      final DataLoader loader=getDataLoader();
      Paginal pgi=getPaginal();
      if (pgi != null)       pgi.setTotalSize(loader.getTotalSize());
    }
  }
);
  Events.postEvent(new Event("String_Node_Str",this));
}
Program: 16526
Project: 16526
Buggy source:
DataLoader getDataLoader(){
  if (_dataLoader == null) {
    final String loadercls=(String)getAttribute("String_Node_Str");
    try {
      _dataLoader=loadercls != null ? (DataLoader)Classes.forNameByThread(loadercls).newInstance() : new GridDataLoader();
    }
 catch (    Exception e) {
      throw UiException.Aide.wrap(e);
    }
    _dataLoader.init(this);
  }
  return _dataLoader;
}

Fixed version (ground truth):
DataLoader getDataLoader(){
  if (_dataLoader == null) {
    _rod=evalRod();
    final String loadercls=(String)getAttribute("String_Node_Str");
    try {
      _dataLoader=_rod && loadercls != null ? (DataLoader)Classes.forNameByThread(loadercls).newInstance() : new GridDataLoader();
    }
 catch (    Exception e) {
      throw UiException.Aide.wrap(e);
    }
    _dataLoader.init(this);
  }
  return _dataLoader;
}
Program: 16527
Project: 16527
Buggy source:
public void setMold(String mold){
  final String old=getMold();
  if (!Objects.equals(old,mold)) {
    super.setMold(mold);
    if ("String_Node_Str".equals(old)) {
      if (_paging != null) {
        removePagingListener(_paging);
        _paging.detach();
      }
 else       if (_pgi != null) {
        removePagingListener(_pgi);
      }
      invalidate();
    }
 else     if (inPagingMold()) {
      if (_pgi != null)       addPagingListener(_pgi);
 else       newInternalPaging();
      invalidate();
    }
  }
}

Fixed version (ground truth):
public void setMold(String mold){
  final String old=getMold();
  if (!Objects.equals(old,mold)) {
    super.setMold(mold);
    if ("String_Node_Str".equals(old)) {
      if (_paging != null) {
        removePagingListener(_paging);
        _paging.detach();
      }
 else       if (_pgi != null) {
        removePagingListener(_pgi);
      }
      if (getModel() != null) {
        getDataLoader().syncModel(0,40);
        postOnInitRender();
      }
      invalidate();
    }
 else     if (inPagingMold()) {
      if (_pgi != null)       addPagingListener(_pgi);
 else       newInternalPaging();
      _topPad=0;
      _currentTop=0;
      _currentLeft=0;
      Events.postEvent(new PagingEvent("String_Node_Str",(Component)_pgi,_pgi.getActivePage()));
      invalidate();
    }
  }
}
Program: 16528
Project: 16528
Buggy source:
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
  super.renderProperties(renderer);
  render(renderer,"String_Node_Str",_scOddRow);
  if (isSizedByContent())   renderer.render("String_Node_Str",true);
  render(renderer,"String_Node_Str",_vflex);
  if (_model != null)   render(renderer,"String_Node_Str",true);
  if (!"String_Node_Str".equals(_pagingPosition))   render(renderer,"String_Node_Str",_pagingPosition);
  if (!"String_Node_Str".equals(_innerWidth))   render(renderer,"String_Node_Str",_innerWidth);
  if (_currentTop != 0)   renderer.render("String_Node_Str",_currentTop);
  if (_currentLeft != 0)   renderer.render("String_Node_Str",_currentLeft);
  if (_topPad != 0)   renderer.render("String_Node_Str",_topPad);
  render(renderer,"String_Node_Str",new Integer(getDataLoader().getTotalSize()));
  render(renderer,"String_Node_Str",new Integer(getDataLoader().getOffset()));
}

Fixed version (ground truth):
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
  super.renderProperties(renderer);
  render(renderer,"String_Node_Str",_scOddRow);
  if (isSizedByContent())   renderer.render("String_Node_Str",true);
  render(renderer,"String_Node_Str",_vflex);
  if (_model != null)   render(renderer,"String_Node_Str",true);
  if (!"String_Node_Str".equals(_pagingPosition))   render(renderer,"String_Node_Str",_pagingPosition);
  if (!"String_Node_Str".equals(_innerWidth))   render(renderer,"String_Node_Str",_innerWidth);
  if (_currentTop != 0)   renderer.render("String_Node_Str",_currentTop);
  if (_currentLeft != 0)   renderer.render("String_Node_Str",_currentLeft);
  renderer.render("String_Node_Str",_topPad);
  renderer.render("String_Node_Str",getDataLoader().getTotalSize());
  renderer.render("String_Node_Str",getDataLoader().getOffset());
  if (_rod) {
    renderer.render("String_Node_Str",true);
  }
}
Program: 16530
Project: 16530
Buggy source:
/** 
 * Returns the number of visible descendant   {@link Row}.
 * @since 3.5.1
 */
public int getVisibleItemCount(){
  int count=getItemCount();
  int visibleCount=0;
  Row row=(Row)getNextSibling();
  while (count-- > 0) {
    if (row.isVisible())     visibleCount++;
    row=(Row)row.getNextSibling();
  }
  return visibleCount;
}

Fixed version (ground truth):
/** 
 * Returns the number of visible descendant   {@link Row}.
 * @since 3.5.1
 */
public int getVisibleItemCount(){
  int count=getItemCount();
  int visibleCount=0;
  Row row=(Row)getNextSibling();
  while (count-- > 0 && row != null) {
    if (row.isVisible())     visibleCount++;
    row=(Row)row.getNextSibling();
  }
  return visibleCount;
}
Program: 16531
Project: 16531
Buggy source:
/** 
 * Processes an AU request. <p>Default: in addition to what are handled by   {@link XulElement#service}, it also handles onOpen.
 * @since 5.0.0
 */
public void service(org.zkoss.zk.au.AuRequest request,boolean everError){
  final String cmd=request.getCommand();
  if (cmd.equals(Events.ON_OPEN)) {
    OpenEvent evt=OpenEvent.getOpenEvent(request);
    _open=evt.isOpen();
    final Rows rows=(Rows)getParent();
    if (rows != null)     rows.addVisibleItemCount(_open ? getVisibleItemCount() : -getVisibleItemCount());
    Events.postEvent(evt);
  }
 else   super.service(request,everError);
}

Fixed version (ground truth):
/** 
 * Processes an AU request. <p>Default: in addition to what are handled by   {@link XulElement#service}, it also handles onOpen.
 * @since 5.0.0
 */
public void service(org.zkoss.zk.au.AuRequest request,boolean everError){
  final String cmd=request.getCommand();
  if (cmd.equals(Events.ON_OPEN)) {
    OpenEvent evt=OpenEvent.getOpenEvent(request);
    _open=evt.isOpen();
    final Rows rows=(Rows)getParent();
    if (rows != null) {
      rows.addVisibleItemCount(_open ? getVisibleItemCount() : -getVisibleItemCount());
      final Grid grid=getGrid();
      if (grid != null) {
        final ListModel model=grid.getModel();
        if (model instanceof GroupsListModel) {
          ((GroupsListModel)model).getGroupsModel().setClose(rows.getGroupIndex(getIndex()),!_open);
        }
      }
    }
    Events.postEvent(evt);
  }
 else   super.service(request,everError);
}
Program: 16532
Project: 16532
Buggy source:
/** 
 * Returns the index of the specified row. The current implementation is stupid, so not public it yet.
 */
int getIndex(){
  int j=0;
  for (Iterator it=getParent().getChildren().iterator(); it.hasNext(); ++j) {
    if (it.next() == this)     break;
  }
  return j;
}

Fixed version (ground truth):
/** 
 * Returns the index of the specified row. The current implementation is stupid, so not public it yet.
 */
int getIndex(){
  int j=0;
  if (_index < 0) {
    for (Iterator it=getParent().getChildren().iterator(); it.hasNext(); ++j) {
      if (it.next() == this)       break;
    }
    final Grid grid=getGrid();
    final int offset=grid != null && grid.getModel() != null ? grid.getDataLoader().getOffset() : 0;
    j+=(offset < 0 ? 0 : offset);
  }
 else {
    j=_index;
  }
  return j;
}
Program: 16533
Project: 16533
Buggy source:
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
  super.renderProperties(renderer);
  render(renderer,"String_Node_Str",_align);
  render(renderer,"String_Node_Str",_valign);
  render(renderer,"String_Node_Str",_nowrap);
  render(renderer,"String_Node_Str",_spans);
  render(renderer,"String_Node_Str",_loaded);
}

Fixed version (ground truth):
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
  super.renderProperties(renderer);
  render(renderer,"String_Node_Str",_align);
  render(renderer,"String_Node_Str",_valign);
  render(renderer,"String_Node_Str",_nowrap);
  render(renderer,"String_Node_Str",_spans);
  render(renderer,"String_Node_Str",_loaded);
  if (_index >= 0)   renderer.render("String_Node_Str",_index);
}
Program: 16534
Project: 16534
Buggy source:
public Object getElementAt(int v){
  String value="String_Node_Str" + (_asc ? v : _size - v);
  return value;
}

Fixed version (ground truth):
public Object getElementAt(int v){
  String value="String_Node_Str" + (_asc ? v : _size - v - 1);
  return value;
}
Program: 16535
Project: 16535
Buggy source:
/** 
 * Deselects all of the currently selected items and selects the item with the given index.
 */
public void setSelectedIndex(int jsel){
  if (jsel >= _items.size())   throw new UiException("String_Node_Str" + jsel + "String_Node_Str"+ _items.size());
  if (jsel < -1)   jsel=-1;
  if (jsel < 0) {
    clearSelection();
  }
 else   if (jsel != _jsel || (_multiple && _selItems.size() > 1)) {
    for (Iterator it=_selItems.iterator(); it.hasNext(); ) {
      final Listitem item=(Listitem)it.next();
      item.setSelectedDirectly(false);
    }
    _selItems.clear();
    _jsel=jsel;
    final Listitem item=getItemAtIndex(_jsel);
    item.setSelectedDirectly(true);
    _selItems.add(item);
    if (inSelectMold())     smartUpdate("String_Node_Str",Integer.toString(_jsel));
 else     smartUpdate("String_Node_Str",item.getUuid());
  }
  if (_jsel >= 0 && inPagingMold()) {
    final Listitem item=getItemAtIndex(_jsel);
    int size=0;
    for (Iterator it=new VisibleChildrenIterator(true); it.hasNext(); size++)     if (item.equals(it.next()))     break;
    final int pg=size / getPageSize();
    if (pg != getActivePage())     setActivePage(pg);
  }
}

Fixed version (ground truth):
/** 
 * Deselects all of the currently selected items and selects the item with the given index.
 */
public void setSelectedIndex(int jsel){
  if (jsel >= _items.size())   throw new UiException("String_Node_Str" + jsel + "String_Node_Str"+ _items.size());
  if (jsel < -1)   jsel=-1;
  if (jsel < 0) {
    clearSelection();
  }
 else   if (jsel != _jsel || (_multiple && _selItems.size() > 1)) {
    for (Iterator it=_selItems.iterator(); it.hasNext(); ) {
      final Listitem item=(Listitem)it.next();
      item.setSelectedDirectly(false);
    }
    _selItems.clear();
    _jsel=jsel;
    final Listitem item=getItemAtIndex(_jsel);
    item.setSelectedDirectly(true);
    _selItems.add(item);
    if (inSelectMold()) {
      int i=0, j=0;
      for (Iterator it=getItems().iterator(); i < _jsel; i++)       if (!((Component)it.next()).isVisible())       j++;
      smartUpdate("String_Node_Str",_jsel - j);
    }
 else     smartUpdate("String_Node_Str",item.getUuid());
  }
  if (_jsel >= 0 && inPagingMold()) {
    final Listitem item=getItemAtIndex(_jsel);
    int size=0;
    for (Iterator it=new VisibleChildrenIterator(true); it.hasNext(); size++)     if (item.equals(it.next()))     break;
    final int pg=size / getPageSize();
    if (pg != getActivePage())     setActivePage(pg);
  }
}
Program: 16536
Project: 16536
Buggy source:
/** 
 * Deselects all of the currently selected items and selects the item with the given index.
 */
public void setSelectedIndex(int jsel){
  if (jsel >= _items.size())   throw new UiException("String_Node_Str" + jsel + "String_Node_Str"+ _items.size());
  if (jsel < -1)   jsel=-1;
  if (jsel < 0) {
    clearSelection();
  }
 else   if (jsel != _jsel || (_multiple && _selItems.size() > 1)) {
    for (Iterator it=_selItems.iterator(); it.hasNext(); ) {
      final Listitem item=(Listitem)it.next();
      item.setSelectedDirectly(false);
    }
    _selItems.clear();
    _jsel=jsel;
    final Listitem item=getItemAtIndex(_jsel);
    item.setSelectedDirectly(true);
    _selItems.add(item);
    if (inSelectMold())     smartUpdate("String_Node_Str",_jsel);
 else     smartUpdate("String_Node_Str",item.getUuid());
  }
  if (_jsel >= 0 && inPagingMold()) {
    final Listitem item=getItemAtIndex(_jsel);
    int size=0;
    for (Iterator it=new VisibleChildrenIterator(true); it.hasNext(); size++)     if (item.equals(it.next()))     break;
    final int pg=size / getPageSize();
    if (pg != getActivePage())     setActivePage(pg);
  }
}

Fixed version (ground truth):
/** 
 * Deselects all of the currently selected items and selects the item with the given index.
 */
public void setSelectedIndex(int jsel){
  if (jsel >= _items.size())   throw new UiException("String_Node_Str" + jsel + "String_Node_Str"+ _items.size());
  if (jsel < -1)   jsel=-1;
  if (jsel < 0) {
    clearSelection();
  }
 else   if (jsel != _jsel || (_multiple && _selItems.size() > 1)) {
    for (Iterator it=_selItems.iterator(); it.hasNext(); ) {
      final Listitem item=(Listitem)it.next();
      item.setSelectedDirectly(false);
    }
    _selItems.clear();
    _jsel=jsel;
    final Listitem item=getItemAtIndex(_jsel);
    item.setSelectedDirectly(true);
    _selItems.add(item);
    if (inSelectMold()) {
      int i=0, j=0;
      for (Iterator it=getItems().iterator(); i < _jsel; i++)       if (!((Component)it.next()).isVisible())       j++;
      smartUpdate("String_Node_Str",_jsel - j);
    }
 else     smartUpdate("String_Node_Str",item.getUuid());
  }
  if (_jsel >= 0 && inPagingMold()) {
    final Listitem item=getItemAtIndex(_jsel);
    int size=0;
    for (Iterator it=new VisibleChildrenIterator(true); it.hasNext(); size++)     if (item.equals(it.next()))     break;
    final int pg=size / getPageSize();
    if (pg != getActivePage())     setActivePage(pg);
  }
}
Program: 16538
Project: 16538
Buggy source:
public Desktop getDesktopIfAny(String desktopId){
synchronized (_desktops) {
    return (Desktop)_desktops.get(desktopId);
  }
}

Fixed version (ground truth):
public Desktop getDesktopIfAny(String desktopId){
synchronized (_desktops) {
    final boolean old=_desktops.disableExpunge(true);
    try {
      return (Desktop)_desktops.get(desktopId);
    }
  finally {
      _desktops.disableExpunge(old);
    }
  }
}
Program: 16539
Project: 16539
Buggy source:
/** 
 * Invokes   {@link DesktopCtrl#sessionWillPassivate} for eachdesktops it cached.
 */
public void sessionWillPassivate(Session sess){
synchronized (_desktops) {
    for (Iterator it=_desktops.values().iterator(); it.hasNext(); )     ((DesktopCtrl)it.next()).sessionWillPassivate(sess);
  }
}

Fixed version (ground truth):
/** 
 * Invokes   {@link DesktopCtrl#sessionWillPassivate} for eachdesktops it cached.
 */
public void sessionWillPassivate(Session sess){
synchronized (_desktops) {
    final boolean old=_desktops.disableExpunge(true);
    try {
      for (Iterator it=_desktops.values().iterator(); it.hasNext(); )       ((DesktopCtrl)it.next()).sessionWillPassivate(sess);
    }
  finally {
      _desktops.disableExpunge(old);
    }
  }
}
Program: 16540
Project: 16540
Buggy source:
public void stop(){
synchronized (_desktops) {
    if (log.debugable())     log.debug("String_Node_Str" + _desktops);
    for (Iterator it=new ArrayList(_desktops.values()).iterator(); it.hasNext(); ) {
      desktopDestroyed((Desktop)it.next());
    }
    _desktops.clear();
  }
}

Fixed version (ground truth):
public void stop(){
synchronized (_desktops) {
    if (log.debugable())     log.debug("String_Node_Str" + _desktops);
    final boolean old=_desktops.disableExpunge(true);
    try {
      for (Iterator it=new ArrayList(_desktops.values()).iterator(); it.hasNext(); ) {
        desktopDestroyed((Desktop)it.next());
      }
      _desktops.clear();
    }
  finally {
      _desktops.disableExpunge(old);
    }
  }
}
Program: 16541
Project: 16541
Buggy source:
protected boolean shallExpunge(){
  return super.shallExpunge() || sizeWithoutExpunge() > (getMaxSize() << 2);
}

Fixed version (ground truth):
protected boolean shallExpunge(){
  return !_expungeDisabled && (super.shallExpunge() || sizeWithoutExpunge() > (getMaxSize() << 2));
}
Program: 16542
Project: 16542
Buggy source:
/** 
 * Invokes   {@link DesktopCtrl#sessionDidActivate} for eachdesktops it cached.
 */
public void sessionDidActivate(Session sess){
synchronized (_desktops) {
    for (Iterator it=_desktops.values().iterator(); it.hasNext(); )     ((DesktopCtrl)it.next()).sessionDidActivate(sess);
  }
}

Fixed version (ground truth):
/** 
 * Invokes   {@link DesktopCtrl#sessionDidActivate} for eachdesktops it cached.
 */
public void sessionDidActivate(Session sess){
synchronized (_desktops) {
    final boolean old=_desktops.disableExpunge(true);
    try {
      for (Iterator it=_desktops.values().iterator(); it.hasNext(); )       ((DesktopCtrl)it.next()).sessionDidActivate(sess);
    }
  finally {
      _desktops.disableExpunge(old);
    }
  }
}
Program: 16544
Project: 16544
Buggy source:
private void setupStatus(){
  final Scope scope=_comp != null ? (Scope)_comp : _page;
  _oldEach=scope.getAttribute("String_Node_Str",true);
  _status=new Status(scope.getAttribute("String_Node_Str",true));
  scope.setAttribute("String_Node_Str",_status);
}

Fixed version (ground truth):
private void setupStatus(){
  final Scope scope=getScope();
  _oldEach=scope.getAttribute("String_Node_Str",false);
  _status=new Status(scope.getAttribute("String_Node_Str",false));
  scope.setAttribute("String_Node_Str",_status);
}
Program: 16545
Project: 16545
Buggy source:
private void restoreStatus(){
  final Scope scope=_comp != null ? (Scope)_comp : _page;
  if (_status.previous != null)   scope.setAttribute("String_Node_Str",_status.previous);
 else   scope.removeAttribute("String_Node_Str");
  if (_oldEach != null)   scope.setAttribute("String_Node_Str",_oldEach);
 else   scope.removeAttribute("String_Node_Str");
  _it=null;
  _status=null;
}

Fixed version (ground truth):
private void restoreStatus(){
  final Scope scope=getScope();
  if (_status.previous != null)   scope.setAttribute("String_Node_Str",_status.previous);
 else   scope.removeAttribute("String_Node_Str");
  if (_oldEach != null)   scope.setAttribute("String_Node_Str",_oldEach);
 else   scope.removeAttribute("String_Node_Str");
  _it=null;
  _status=null;
}
Program: 16546
Project: 16546
Buggy source:
/** 
 * A forward event is used for component level only.
 * @since 5.0.0
 */
public void onSend(ForwardEvent evt){
  _result.push(((UploadEvent)evt.getOrigin()).getMedia());
}

Fixed version (ground truth):
/** 
 * A forward event is used for component level only.
 * @since 5.0.0
 */
public void onSend(ForwardEvent evt){
  _result.add(((UploadEvent)evt.getOrigin()).getMedia());
}
Program: 16548
Project: 16548
Buggy source:
/** 
 * Converts an AU request to an error event.
 * @since 5.0.0
 */
public static final ErrorEvent getErrorEvent(AuRequest request){
  final Component comp=request.getComponent();
  if (comp == null)   throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED,request);
  final Map data=request.getData();
  if (data == null)   throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA,new Object[]{data,request});
  return new ErrorEvent(request.getCommand(),comp,(String)data.get("String_Node_Str"),(String)data.get("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Converts an AU request to an error event.
 * @since 5.0.0
 */
public static final ErrorEvent getErrorEvent(AuRequest request){
  final Component comp=request.getComponent();
  if (comp == null)   throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED,request);
  final Map data=request.getData();
  if (data == null)   throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA,new Object[]{data,request});
  return new ErrorEvent(request.getCommand(),comp,String.valueOf(data.get("String_Node_Str")),String.valueOf(data.get("String_Node_Str")));
}
Program: 16549
Project: 16549
Buggy source:
/** 
 * Remove the DialModelScale of the specified index.
 * @param index
 */
public void removeScale(DialModelScale entry){
  _series.remove(entry);
  fireEvent(ChartDataEvent.REMOVED,null,null);
}

Fixed version (ground truth):
/** 
 * Remove the specified DialModelScale from this DialModel.
 * @param scale
 */
public void removeScale(DialModelScale scale){
  _series.remove(scale);
  fireEvent(ChartDataEvent.REMOVED,null,null);
}
Program: 16550
Project: 16550
Buggy source:
/** 
 * Get value of the specified index.
 * @param series the series
 * @param category the category.
 */
public double getValue(int index){
  return getScale(index).getValue();
}

Fixed version (ground truth):
/** 
 * Get value of the scale per the specified index.
 * @param index the scale index.
 */
public double getValue(int index){
  return getScale(index).getValue();
}
Program: 16551
Project: 16551
Buggy source:
/** 
 * Sets the radius percentage(0 ~ 1) of the meter's cap; default to 0.07.
 * @return the radius percentage(0 ~ 1) of the meter's cap.
 */
public void setCapRadius(double radius){
  _capRadius=radius;
}

Fixed version (ground truth):
/** 
 * Sets the radius percentage(0 ~ 1) of the meter's cap; default to 0.07.
 * @param radius the radius percentage(0 ~ 1) of the meter's cap.
 */
public void setCapRadius(double radius){
  _capRadius=radius;
}
Program: 16552
Project: 16552
Buggy source:
/** 
 * add or update the value of a specified index.
 * @param index the index of the Scale
 * @param value the value
 */
public void setValue(int index,double value){
  getScale(index).setValue(value);
}

Fixed version (ground truth):
/** 
 * add or update the value of a specified scale index.
 * @param index the index of the Scale
 * @param value the value
 */
public void setValue(int index,double value){
  getScale(index).setValue(value);
}
Program: 16553
Project: 16553
Buggy source:
/** 
 * Sets the outer radius percentage(0 ~ 1) of the dial range; default to 0.8.
 * @param the outer radius percentage(0 ~ 1) of the dial range; default to 0.8.
 */
public void setOuterRadius(double radius){
  _outerRadius=radius;
}

Fixed version (ground truth):
/** 
 * Sets the outer radius percentage(0 ~ 1) of the dial range; default to 0.8.
 * @param radius the outer radius percentage(0 ~ 1) of the dial range; default to 0.8.
 */
public void setOuterRadius(double radius){
  _outerRadius=radius;
}
Program: 16554
Project: 16554
Buggy source:
/** 
 * Sets the inner radius percentage(0 ~ 1) of the dial range; default to 0.7.
 * @param the inner radius percentage(0 ~ 1) of the dial range; default to 0.7.
 */
public void setInnerRadius(double radius){
  _innerRadius=radius;
}

Fixed version (ground truth):
/** 
 * Sets the inner radius percentage(0 ~ 1) of the dial range; default to 0.7.
 * @param radius the inner radius percentage(0 ~ 1) of the dial range; default to 0.7.
 */
public void setInnerRadius(double radius){
  _innerRadius=radius;
}
Program: 16555
Project: 16555
Buggy source:
/** 
 * Sets the radius percentage(0 ~ 1) of the scale's needle; default to 0.9.
 * @return the radius percentage(0 ~ 1) of the scale's needle; default to 0.9.
 */
public void setNeedleRadius(double radius){
  if (_needleRadius != radius) {
    _needleRadius=radius;
    fireEvent(ChartDataEvent.CHANGED);
  }
}

Fixed version (ground truth):
/** 
 * Sets the radius percentage(0 ~ 1) of the scale's needle; default to 0.9.
 * @param radius the radius percentage(0 ~ 1) of the scale's needle; default to 0.9.
 */
public void setNeedleRadius(double radius){
  if (_needleRadius != radius) {
    _needleRadius=radius;
    fireEvent(ChartDataEvent.CHANGED);
  }
}
Program: 16556
Project: 16556
Buggy source:
/** 
 * Sets the needle type of this scale ("pointer" or "pin")
 * @param the needle type of this scale ("pointer" or "pin")
 */
public void setNeedleType(String type){
  if (_needleType != type) {
    _needleType=type;
    fireEvent(ChartDataEvent.CHANGED);
  }
}

Fixed version (ground truth):
/** 
 * Sets the needle type of this scale ("pointer" or "pin")
 * @param type the needle type of this scale ("pointer" or "pin")
 */
public void setNeedleType(String type){
  if (_needleType != type) {
    _needleType=type;
    fireEvent(ChartDataEvent.CHANGED);
  }
}
Program: 16557
Project: 16557
Buggy source:
/** 
 * returns the number of minor ticks between major tick.
 * @return
 */
public int getMinorTickCount(){
  return _minorTickCount;
}

Fixed version (ground truth):
/** 
 * returns the number of minor ticks between major tick.
 * @return the number of minor ticks between major tick.
 */
public int getMinorTickCount(){
  return _minorTickCount;
}
Program: 16558
Project: 16558
Buggy source:
/** 
 * Remove the DialModelScale of the specified index.
 * @param index
 */
public void removeScale(DialModelScale entry){
  _series.remove(entry);
  fireEvent(ChartDataEvent.REMOVED,null,null);
}

Fixed version (ground truth):
/** 
 * Remove the specified DialModelScale from this DialModel.
 * @param scale
 */
public void removeScale(DialModelScale scale){
  _series.remove(scale);
  fireEvent(ChartDataEvent.REMOVED,null,null);
}
Program: 16559
Project: 16559
Buggy source:
/** 
 * Get value of the specified index.
 * @param series the series
 * @param category the category.
 */
public double getValue(int index){
  return getScale(index).getValue();
}

Fixed version (ground truth):
/** 
 * Get value of the scale per the specified index.
 * @param index the scale index.
 */
public double getValue(int index){
  return getScale(index).getValue();
}
Program: 16560
Project: 16560
Buggy source:
/** 
 * Sets the radius percentage(0 ~ 1) of the meter's cap; default to 0.07.
 * @return the radius percentage(0 ~ 1) of the meter's cap.
 */
public void setCapRadius(double radius){
  _capRadius=radius;
}

Fixed version (ground truth):
/** 
 * Sets the radius percentage(0 ~ 1) of the meter's cap; default to 0.07.
 * @param radius the radius percentage(0 ~ 1) of the meter's cap.
 */
public void setCapRadius(double radius){
  _capRadius=radius;
}
Program: 16561
Project: 16561
Buggy source:
/** 
 * add or update the value of a specified index.
 * @param index the index of the Scale
 * @param value the value
 */
public void setValue(int index,double value){
  getScale(index).setValue(value);
}

Fixed version (ground truth):
/** 
 * add or update the value of a specified scale index.
 * @param index the index of the Scale
 * @param value the value
 */
public void setValue(int index,double value){
  getScale(index).setValue(value);
}
Program: 16562
Project: 16562
Buggy source:
/** 
 * Sets the outer radius percentage(0 ~ 1) of the dial range; default to 0.8.
 * @param the outer radius percentage(0 ~ 1) of the dial range; default to 0.8.
 */
public void setOuterRadius(double radius){
  _outerRadius=radius;
}

Fixed version (ground truth):
/** 
 * Sets the outer radius percentage(0 ~ 1) of the dial range; default to 0.8.
 * @param radius the outer radius percentage(0 ~ 1) of the dial range; default to 0.8.
 */
public void setOuterRadius(double radius){
  _outerRadius=radius;
}
Program: 16563
Project: 16563
Buggy source:
/** 
 * Sets the inner radius percentage(0 ~ 1) of the dial range; default to 0.7.
 * @param the inner radius percentage(0 ~ 1) of the dial range; default to 0.7.
 */
public void setInnerRadius(double radius){
  _innerRadius=radius;
}

Fixed version (ground truth):
/** 
 * Sets the inner radius percentage(0 ~ 1) of the dial range; default to 0.7.
 * @param radius the inner radius percentage(0 ~ 1) of the dial range; default to 0.7.
 */
public void setInnerRadius(double radius){
  _innerRadius=radius;
}
Program: 16564
Project: 16564
Buggy source:
/** 
 * Sets the radius percentage(0 ~ 1) of the scale's needle; default to 0.9.
 * @return the radius percentage(0 ~ 1) of the scale's needle; default to 0.9.
 */
public void setNeedleRadius(double radius){
  if (_needleRadius != radius) {
    _needleRadius=radius;
    fireEvent(ChartDataEvent.CHANGED);
  }
}

Fixed version (ground truth):
/** 
 * Sets the radius percentage(0 ~ 1) of the scale's needle; default to 0.9.
 * @param radius the radius percentage(0 ~ 1) of the scale's needle; default to 0.9.
 */
public void setNeedleRadius(double radius){
  if (_needleRadius != radius) {
    _needleRadius=radius;
    fireEvent(ChartDataEvent.CHANGED);
  }
}
Program: 16565
Project: 16565
Buggy source:
/** 
 * Sets the needle type of this scale ("pointer" or "pin")
 * @param the needle type of this scale ("pointer" or "pin")
 */
public void setNeedleType(String type){
  if (_needleType != type) {
    _needleType=type;
    fireEvent(ChartDataEvent.CHANGED);
  }
}

Fixed version (ground truth):
/** 
 * Sets the needle type of this scale ("pointer" or "pin")
 * @param type the needle type of this scale ("pointer" or "pin")
 */
public void setNeedleType(String type){
  if (_needleType != type) {
    _needleType=type;
    fireEvent(ChartDataEvent.CHANGED);
  }
}
Program: 16566
Project: 16566
Buggy source:
/** 
 * returns the number of minor ticks between major tick.
 * @return
 */
public int getMinorTickCount(){
  return _minorTickCount;
}

Fixed version (ground truth):
/** 
 * returns the number of minor ticks between major tick.
 * @return the number of minor ticks between major tick.
 */
public int getMinorTickCount(){
  return _minorTickCount;
}
Program: 16567
Project: 16567
Buggy source:
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
  super.renderProperties(renderer);
  render(renderer,"String_Node_Str",isSelected());
  render(renderer,"String_Node_Str",isDisabled());
  if (!isCheckable())   renderer.render("String_Node_Str",false);
}

Fixed version (ground truth):
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
  super.renderProperties(renderer);
  render(renderer,"String_Node_Str",isSelected());
  render(renderer,"String_Node_Str",isDisabled());
  render(renderer,"String_Node_Str",_loaded);
  if (!isCheckable())   renderer.render("String_Node_Str",false);
}
Program: 16568
Project: 16568
Buggy source:
private Listitem getVisibleRow(Listitem item){
  if (item instanceof Listgroup) {
    final Listgroup g=(Listgroup)item;
    if (!g.isOpen()) {
      for (int j=0, len=g.getItemCount(); j < len && _it.hasNext(); j++)       _it.next();
    }
  }
  while (!item.isVisible())   item=(Listitem)_it.next();
  return item;
}

Fixed version (ground truth):
private Listitem getVisibleRow(Listitem item){
  if (item instanceof Listgroup) {
    final Listgroup g=(Listgroup)item;
    if (!g.isOpen()) {
      for (int j=0, len=g.getItemCount(); j < len && _it.hasNext(); j++)       _it.next();
    }
  }
  while (!item.isVisible() && _it.hasNext())   item=(Listitem)_it.next();
  return item;
}
Program: 16569
Project: 16569
Buggy source:
private Row getVisibleRow(Row row){
  if (row instanceof Group) {
    final Group g=(Group)row;
    if (!g.isOpen()) {
      for (int j=0, len=g.getItemCount(); j < len && _it.hasNext(); j++)       _it.next();
    }
  }
  while (!row.isVisible())   row=(Row)_it.next();
  return row;
}

Fixed version (ground truth):
private Row getVisibleRow(Row row){
  if (row instanceof Group) {
    final Group g=(Group)row;
    if (!g.isOpen()) {
      for (int j=0, len=g.getItemCount(); j < len && _it.hasNext(); j++)       _it.next();
    }
  }
  while (!row.isVisible() && _it.hasNext())   row=(Row)_it.next();
  return row;
}
Program: 16570
Project: 16570
Buggy source:
public boolean setVisible(boolean visible){
  if (isVisible() != visible && _treerow != null)   _treerow.smartUpdate("String_Node_Str",visible);
  int count=isOpen() && _treechildren != null ? _treechildren.getVisibleItemCount() + 1 : 1;
  boolean result=super.setVisible(visible);
  if (isVisible()) {
    addVisibleItemCount(count,false);
  }
 else {
    addVisibleItemCount(-count,true);
  }
  return result;
}

Fixed version (ground truth):
public boolean setVisible(boolean visible){
  if (isVisible() != visible) {
    if (isVisible() != visible && _treerow != null)     _treerow.smartUpdate("String_Node_Str",visible);
    int count=isOpen() && _treechildren != null ? _treechildren.getVisibleItemCount() + 1 : 1;
    boolean result=super.setVisible(visible);
    if (isVisible()) {
      addVisibleItemCount(count,false);
    }
 else {
      addVisibleItemCount(-count,true);
    }
    return result;
  }
  return visible;
}
Program: 16571
Project: 16571
Buggy source:
/** 
 * @deprecated As of release 5.0.0, use {@link #escape(StringBuffer,CharSequence,String)}instead.
 */
public static final StringBuffer appendEscape(StringBuffer sb,String s,String specials){
  return escape(sb,(CharSequence)s,specials);
}

Fixed version (ground truth):
/** 
 * @deprecated As of release 5.0.0, use {@link #escape(StringBuffer,CharSequence,String)}instead.
 */
public static final StringBuffer appendEscape(StringBuffer sb,String src,String specials){
  return escape(sb,(CharSequence)src,specials);
}
Program: 16572
Project: 16572
Buggy source:
/** 
 * Escapes (aka. quote) the special characters with backslash and appends it the specified string buffer.
 * @param dst the destination buffer to append to.
 * @param src the source to escape from.
 * @since 5.0.0
 */
public static final StringBuffer escape(StringBuffer dst,CharSequence src,String specials){
  if (src == null)   return dst;
  for (int j=0, len=src.length(); ; ) {
    int k=j;
    for (; k < len && specials.indexOf(src.charAt(k)) < 0; ++k)     ;
    if (k >= len)     return dst.append(src.subSequence(j,src.length()));
    char cc=src.charAt(k);
switch (cc) {
case '\n':
      cc='n';
    break;
case '\t':
  cc='t';
break;
case '\r':
cc='r';
break;
case '\f':
cc='f';
break;
}
dst.append(src.subSequence(j,k)).append('\\').append(cc);
j=k + 1;
}
}

Fixed version (ground truth):
/** 
 * Escapes (aka. quote) the special characters with backslash and appends it the specified string buffer.
 * @param dst the destination buffer to append to.
 * @param src the source to escape from.
 * @param specials a string of characters that shall be escaped/quotedTo escape a string in JavaScript code snippet, you can use  {@link #ESCAPE_JAVASCRIPT}.
 * @since 5.0.0
 */
public static final StringBuffer escape(StringBuffer dst,CharSequence src,String specials){
  if (src == null)   return dst;
  for (int j=0, j2=0, len=src.length(); ; ) {
    int k=j2;
    for (; k < len && specials.indexOf(src.charAt(k)) < 0; ++k)     ;
    if (k >= len)     return dst.append(src.subSequence(j,src.length()));
    char cc=src.charAt(k);
switch (cc) {
case '\n':
      cc='n';
    break;
case '\t':
  cc='t';
break;
case '\r':
cc='r';
break;
case '\f':
cc='f';
break;
case '/':
if (specials == ESCAPE_JAVASCRIPT && (k <= 0 || src.charAt(k - 1) != '<' || k + 8 > len || !"String_Node_Str".equalsIgnoreCase(src.subSequence(k + 1,k + 8).toString()))) {
j2=k + 1;
continue;
}
}
dst.append(src.subSequence(j,k)).append('\\').append(cc);
j2=j=k + 1;
}
}