nus-yam/ex-repair huggingface dataset:
Program: 87773
Project: 87773
Buggy source:
/** 
 * Apply an auto-caps mode to a string. This intentionally does NOT apply manual caps mode. It only changes the capitalization if the mode is one of the auto-caps modes.
 * @param s The string to capitalize.
 * @param capitalizeMode The mode in which to capitalize.
 * @param locale The locale for capitalizing.
 * @return The capitalized string.
 */
public static String applyAutoCapsMode(final String s,final int capitalizeMode,final Locale locale){
  if (WordComposer.CAPS_MODE_AUTO_SHIFT_LOCKED == capitalizeMode) {
    return s.toUpperCase(locale);
  }
 else   if (WordComposer.CAPS_MODE_AUTO_SHIFTED == capitalizeMode) {
    return StringUtils.toTitleCase(s,locale);
  }
 else {
    return s;
  }
}

Fixed version (ground truth):
/** 
 * Apply an auto-caps mode to a string. This intentionally does NOT apply manual caps mode. It only changes the capitalization if the mode is one of the auto-caps modes.
 * @param s The string to capitalize.
 * @param capitalizeMode The mode in which to capitalize.
 * @param locale The locale for capitalizing.
 * @return The capitalized string.
 */
public static String applyAutoCapsMode(final String s,final int capitalizeMode,final Locale locale){
  if (WordComposer.CAPS_MODE_AUTO_SHIFT_LOCKED == capitalizeMode) {
    return s.toUpperCase(locale);
  }
 else   if (WordComposer.CAPS_MODE_AUTO_SHIFTED == capitalizeMode) {
    return StringUtils.capitalizeFirstCodePoint(s,locale);
  }
 else {
    return s;
  }
}
Program: 87774
Project: 87774
Buggy source:
private static String getSubtypeDisplayNameInternal(final InputMethodSubtype subtype,final Locale displayLocale){
  final String replacementString=getReplacementString(subtype,displayLocale);
  final int nameResId=subtype.getNameResId();
  final RunInLocale<String> getSubtypeName=new RunInLocale<String>(){
    @Override protected String job(    final Resources res){
      try {
        return res.getString(nameResId,replacementString);
      }
 catch (      Resources.NotFoundException e) {
        Log.w(TAG,"String_Node_Str" + subtype.getMode() + "String_Node_Str"+ subtype.getNameResId()+ "String_Node_Str"+ subtype.getLocale()+ "String_Node_Str"+ subtype.getExtraValue()+ "String_Node_Str"+ Utils.getStackTrace());
        return "String_Node_Str";
      }
    }
  }
;
  return StringUtils.capitalizeFirstCharacter(getSubtypeName.runInLocale(sResources,displayLocale),displayLocale);
}

Fixed version (ground truth):
private static String getSubtypeDisplayNameInternal(final InputMethodSubtype subtype,final Locale displayLocale){
  final String replacementString=getReplacementString(subtype,displayLocale);
  final int nameResId=subtype.getNameResId();
  final RunInLocale<String> getSubtypeName=new RunInLocale<String>(){
    @Override protected String job(    final Resources res){
      try {
        return res.getString(nameResId,replacementString);
      }
 catch (      Resources.NotFoundException e) {
        Log.w(TAG,"String_Node_Str" + subtype.getMode() + "String_Node_Str"+ subtype.getNameResId()+ "String_Node_Str"+ subtype.getLocale()+ "String_Node_Str"+ subtype.getExtraValue()+ "String_Node_Str"+ Utils.getStackTrace());
        return "String_Node_Str";
      }
    }
  }
;
  return StringUtils.capitalizeFirstCodePoint(getSubtypeName.runInLocale(sResources,displayLocale),displayLocale);
}
Program: 87775
Project: 87775
Buggy source:
private static String getSubtypeLocaleDisplayNameInternal(final String localeString,final Locale displayLocale){
  final Integer exceptionalNameResId=sExceptionalLocaleToNameIdsMap.get(localeString);
  final String displayName;
  if (exceptionalNameResId != null) {
    final RunInLocale<String> getExceptionalName=new RunInLocale<String>(){
      @Override protected String job(      final Resources res){
        return res.getString(exceptionalNameResId);
      }
    }
;
    displayName=getExceptionalName.runInLocale(sResources,displayLocale);
  }
 else   if (NO_LANGUAGE.equals(localeString)) {
    return sResources.getString(R.string.subtype_no_language);
  }
 else {
    final Locale locale=LocaleUtils.constructLocaleFromString(localeString);
    displayName=locale.getDisplayName(displayLocale);
  }
  return StringUtils.capitalizeFirstCharacter(displayName,displayLocale);
}

Fixed version (ground truth):
private static String getSubtypeLocaleDisplayNameInternal(final String localeString,final Locale displayLocale){
  final Integer exceptionalNameResId=sExceptionalLocaleToNameIdsMap.get(localeString);
  final String displayName;
  if (exceptionalNameResId != null) {
    final RunInLocale<String> getExceptionalName=new RunInLocale<String>(){
      @Override protected String job(      final Resources res){
        return res.getString(exceptionalNameResId);
      }
    }
;
    displayName=getExceptionalName.runInLocale(sResources,displayLocale);
  }
 else   if (NO_LANGUAGE.equals(localeString)) {
    return sResources.getString(R.string.subtype_no_language);
  }
 else {
    final Locale locale=LocaleUtils.constructLocaleFromString(localeString);
    displayName=locale.getDisplayName(displayLocale);
  }
  return StringUtils.capitalizeFirstCodePoint(displayName,displayLocale);
}
Program: 87776
Project: 87776
Buggy source:
private static SuggestedWordInfo getTransformedSuggestedWordInfo(final SuggestedWordInfo wordInfo,final Locale locale,final boolean isAllUpperCase,final boolean isFirstCharCapitalized,final int trailingSingleQuotesCount){
  final StringBuilder sb=new StringBuilder(wordInfo.mWord.length());
  if (isAllUpperCase) {
    sb.append(wordInfo.mWord.toUpperCase(locale));
  }
 else   if (isFirstCharCapitalized) {
    sb.append(StringUtils.toTitleCase(wordInfo.mWord,locale));
  }
 else {
    sb.append(wordInfo.mWord);
  }
  for (int i=trailingSingleQuotesCount - 1; i >= 0; --i) {
    sb.appendCodePoint(Constants.CODE_SINGLE_QUOTE);
  }
  return new SuggestedWordInfo(sb.toString(),wordInfo.mScore,wordInfo.mKind,wordInfo.mSourceDict);
}

Fixed version (ground truth):
private static SuggestedWordInfo getTransformedSuggestedWordInfo(final SuggestedWordInfo wordInfo,final Locale locale,final boolean isAllUpperCase,final boolean isFirstCharCapitalized,final int trailingSingleQuotesCount){
  final StringBuilder sb=new StringBuilder(wordInfo.mWord.length());
  if (isAllUpperCase) {
    sb.append(wordInfo.mWord.toUpperCase(locale));
  }
 else   if (isFirstCharCapitalized) {
    sb.append(StringUtils.capitalizeFirstCodePoint(wordInfo.mWord,locale));
  }
 else {
    sb.append(wordInfo.mWord);
  }
  for (int i=trailingSingleQuotesCount - 1; i >= 0; --i) {
    sb.appendCodePoint(Constants.CODE_SINGLE_QUOTE);
  }
  return new SuggestedWordInfo(sb.toString(),wordInfo.mScore,wordInfo.mKind,wordInfo.mSourceDict);
}
Program: 87778
Project: 87778
Buggy source:
/** 
 * Helper method to test valid capitalizations of a word. If the "text" is lower-case, we test only the exact string. If the "Text" is capitalized, we test the exact string "Text" and the lower-cased version of it "text". If the "TEXT" is fully upper case, we test the exact string "TEXT", the lower-cased version of it "text" and the capitalized version of it "Text".
 */
private boolean isInDictForAnyCapitalization(final Dictionary dict,final String text,final int capitalizeType){
  if (dict.isValidWord(text))   return true;
  if (StringUtils.CAPITALIZE_NONE == capitalizeType)   return false;
  final String lowerCaseText=text.toLowerCase(mLocale);
  if (dict.isValidWord(lowerCaseText))   return true;
  if (StringUtils.CAPITALIZE_FIRST == capitalizeType)   return false;
  return dict.isValidWord(StringUtils.toTitleCase(lowerCaseText,mLocale));
}

Fixed version (ground truth):
/** 
 * Helper method to test valid capitalizations of a word. If the "text" is lower-case, we test only the exact string. If the "Text" is capitalized, we test the exact string "Text" and the lower-cased version of it "text". If the "TEXT" is fully upper case, we test the exact string "TEXT", the lower-cased version of it "text" and the capitalized version of it "Text".
 */
private boolean isInDictForAnyCapitalization(final Dictionary dict,final String text,final int capitalizeType){
  if (dict.isValidWord(text))   return true;
  if (StringUtils.CAPITALIZE_NONE == capitalizeType)   return false;
  final String lowerCaseText=text.toLowerCase(mLocale);
  if (dict.isValidWord(lowerCaseText))   return true;
  if (StringUtils.CAPITALIZE_FIRST == capitalizeType)   return false;
  return dict.isValidWord(StringUtils.capitalizeFirstAndDowncaseRest(lowerCaseText,mLocale));
}
Program: 87779
Project: 87779
Buggy source:
public void testAllShortDisplayName(){
  for (  final InputMethodSubtype subtype : mSubtypesList) {
    final String subtypeName=SubtypeLocale.getSubtypeDisplayName(subtype);
    final Locale locale=SubtypeLocale.getSubtypeLocale(subtype);
    final String spacebarText=MainKeyboardView.getShortDisplayName(subtype);
    final String languageCode=StringUtils.capitalizeFirstCharacter(locale.getLanguage(),locale);
    if (SubtypeLocale.isNoLanguage(subtype)) {
      assertEquals(subtypeName,"String_Node_Str",spacebarText);
    }
 else {
      assertEquals(subtypeName,languageCode,spacebarText);
    }
  }
}

Fixed version (ground truth):
public void testAllShortDisplayName(){
  for (  final InputMethodSubtype subtype : mSubtypesList) {
    final String subtypeName=SubtypeLocale.getSubtypeDisplayName(subtype);
    final Locale locale=SubtypeLocale.getSubtypeLocale(subtype);
    final String spacebarText=MainKeyboardView.getShortDisplayName(subtype);
    final String languageCode=StringUtils.capitalizeFirstCodePoint(locale.getLanguage(),locale);
    if (SubtypeLocale.isNoLanguage(subtype)) {
      assertEquals(subtypeName,"String_Node_Str",spacebarText);
    }
 else {
      assertEquals(subtypeName,languageCode,spacebarText);
    }
  }
}
Program: 87780
Project: 87780
Buggy source:
public static int getCapitalizationType(final String text){
  if (!Character.isUpperCase(text.codePointAt(0)))   return CAPITALIZE_NONE;
  final int len=text.length();
  int capsCount=1;
  int letterCount=1;
  for (int i=1; i < len; i=text.offsetByCodePoints(i,1)) {
    if (1 != capsCount && letterCount != capsCount)     break;
    final int codePoint=text.codePointAt(i);
    if (Character.isUpperCase(codePoint)) {
      ++capsCount;
      ++letterCount;
    }
 else     if (Character.isLetter(codePoint)) {
      ++letterCount;
    }
  }
  if (1 == capsCount)   return CAPITALIZE_FIRST;
  return (letterCount == capsCount ? CAPITALIZE_ALL : CAPITALIZE_NONE);
}

Fixed version (ground truth):
public static int getCapitalizationType(final String text){
  final int len=text.length();
  int index=0;
  for (; index < len; index=text.offsetByCodePoints(index,1)) {
    if (Character.isLetter(text.codePointAt(index))) {
      break;
    }
  }
  if (index == len)   return CAPITALIZE_NONE;
  if (!Character.isUpperCase(text.codePointAt(index))) {
    return CAPITALIZE_NONE;
  }
  int capsCount=1;
  int letterCount=1;
  for (index=text.offsetByCodePoints(index,1); index < len; index=text.offsetByCodePoints(index,1)) {
    if (1 != capsCount && letterCount != capsCount)     break;
    final int codePoint=text.codePointAt(index);
    if (Character.isUpperCase(codePoint)) {
      ++capsCount;
      ++letterCount;
    }
 else     if (Character.isLetter(codePoint)) {
      ++letterCount;
    }
  }
  if (1 == capsCount)   return CAPITALIZE_FIRST;
  return (letterCount == capsCount ? CAPITALIZE_ALL : CAPITALIZE_NONE);
}
Program: 87781
Project: 87781
Buggy source:
public static String toTitleCase(final String s,final Locale locale){
  if (s.length() <= 1) {
    return s;
  }
  return s.toUpperCase(locale).charAt(0) + s.substring(1);
}

Fixed version (ground truth):
public static String toTitleCase(final String s,final Locale locale){
  if (s.length() <= 1) {
    return s;
  }
  final int cutoff=s.offsetByCodePoints(0,1);
  return s.substring(0,cutoff).toUpperCase(locale) + s.substring(cutoff).toLowerCase(locale);
}
Program: 87782
Project: 87782
Buggy source:
@Override public Word next(){
  Position currentPos=mPositions.getLast();
  mCurrentString.setLength(mCurrentString.length() - currentPos.length);
  do {
    if (currentPos.pos.hasNext()) {
      final CharGroup currentGroup=currentPos.pos.next();
      currentPos.length=currentGroup.mChars.length;
      for (      int i : currentGroup.mChars)       mCurrentString.append(Character.toChars(i));
      if (null != currentGroup.mChildren) {
        currentPos=new Position(currentGroup.mChildren.mData);
        mPositions.addLast(currentPos);
      }
      if (currentGroup.mFrequency >= 0)       return new Word(mCurrentString.toString(),currentGroup.mFrequency,currentGroup.mShortcutTargets,currentGroup.mBigrams,currentGroup.mIsNotAWord,currentGroup.mIsBlacklistEntry);
    }
 else {
      mPositions.removeLast();
      currentPos=mPositions.getLast();
      mCurrentString.setLength(mCurrentString.length() - mPositions.getLast().length);
    }
  }
 while (true);
}

Fixed version (ground truth):
@Override public Word next(){
  Position currentPos=mPositions.getLast();
  mCurrentString.setLength(currentPos.length);
  do {
    if (currentPos.pos.hasNext()) {
      final CharGroup currentGroup=currentPos.pos.next();
      currentPos.length=mCurrentString.length();
      for (      int i : currentGroup.mChars)       mCurrentString.append(Character.toChars(i));
      if (null != currentGroup.mChildren) {
        currentPos=new Position(currentGroup.mChildren.mData);
        mPositions.addLast(currentPos);
      }
      if (currentGroup.mFrequency >= 0)       return new Word(mCurrentString.toString(),currentGroup.mFrequency,currentGroup.mShortcutTargets,currentGroup.mBigrams,currentGroup.mIsNotAWord,currentGroup.mIsBlacklistEntry);
    }
 else {
      mPositions.removeLast();
      currentPos=mPositions.getLast();
      mCurrentString.setLength(mPositions.getLast().length);
    }
  }
 while (true);
}
Program: 87783
Project: 87783
Buggy source:
/** 
 * Helper method to find a word in a given branch.
 */
@SuppressWarnings("String_Node_Str") public static CharGroup findWordInTree(Node node,final String s){
  int index=0;
  final StringBuilder checker=DBG ? new StringBuilder() : null;
  CharGroup currentGroup;
  final int codePointCountInS=s.codePointCount(0,s.length());
  do {
    int indexOfGroup=findIndexOfChar(node,s.codePointAt(index));
    if (CHARACTER_NOT_FOUND == indexOfGroup)     return null;
    currentGroup=node.mData.get(indexOfGroup);
    if (s.length() - index < currentGroup.mChars.length)     return null;
    int newIndex=index;
    while (newIndex < s.length() && newIndex - index < currentGroup.mChars.length) {
      if (currentGroup.mChars[newIndex - index] != s.codePointAt(newIndex))       return null;
      newIndex++;
    }
    index=newIndex;
    if (DBG)     checker.append(new String(currentGroup.mChars,0,currentGroup.mChars.length));
    if (index < codePointCountInS) {
      node=currentGroup.mChildren;
    }
  }
 while (null != node && index < codePointCountInS);
  if (index < codePointCountInS)   return null;
  if (!currentGroup.isTerminal())   return null;
  if (DBG && !s.equals(checker.toString()))   return null;
  return currentGroup;
}

Fixed version (ground truth):
/** 
 * Helper method to find a word in a given branch.
 */
@SuppressWarnings("String_Node_Str") public static CharGroup findWordInTree(Node node,final String string){
  int index=0;
  final StringBuilder checker=DBG ? new StringBuilder() : null;
  final int[] codePoints=getCodePoints(string);
  CharGroup currentGroup;
  do {
    int indexOfGroup=findIndexOfChar(node,codePoints[index]);
    if (CHARACTER_NOT_FOUND == indexOfGroup)     return null;
    currentGroup=node.mData.get(indexOfGroup);
    if (codePoints.length - index < currentGroup.mChars.length)     return null;
    int newIndex=index;
    while (newIndex < codePoints.length && newIndex - index < currentGroup.mChars.length) {
      if (currentGroup.mChars[newIndex - index] != codePoints[newIndex])       return null;
      newIndex++;
    }
    index=newIndex;
    if (DBG)     checker.append(new String(currentGroup.mChars,0,currentGroup.mChars.length));
    if (index < codePoints.length) {
      node=currentGroup.mChildren;
    }
  }
 while (null != node && index < codePoints.length);
  if (index < codePoints.length)   return null;
  if (!currentGroup.isTerminal())   return null;
  if (DBG && !codePoints.equals(checker.toString()))   return null;
  return currentGroup;
}
Program: 87784
Project: 87784
Buggy source:
public void testGetTerminalPosition(){
  File file=null;
  try {
    file=File.createTempFile("String_Node_Str","String_Node_Str",getContext().getCacheDir());
  }
 catch (  IOException e) {
  }
  assertNotNull(file);
  final FusionDictionary dict=new FusionDictionary(new Node(),new FusionDictionary.DictionaryOptions(new HashMap<String,String>(),false,false));
  addUnigrams(sWords.size(),dict,sWords,null);
  timeWritingDictToFile(file,dict,VERSION3_WITH_DYNAMIC_UPDATE);
  final FusionDictionaryBufferInterface buffer=getBuffer(file,USE_BYTE_ARRAY);
  try {
    final String longWord="String_Node_Str";
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,longWord));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,null));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,"String_Node_Str"));
  }
 catch (  IOException e) {
  }
catch (  UnsupportedFormatException e) {
  }
  long sum=0;
  for (int i=0; i < sWords.size(); ++i) {
    final long time=runGetTerminalPosition(buffer,sWords.get(i),i,true);
    sum+=time == -1 ? 0 : time;
  }
  Log.d(TAG,"String_Node_Str" + (((double)sum) / sWords.size() / 1000000));
  final Random random=new Random((int)System.currentTimeMillis());
  for (int i=0; i < 1000; ++i) {
    final String word=generateWord(random.nextInt());
    if (sWords.indexOf(word) != -1)     continue;
    runGetTerminalPosition(buffer,word,i,false);
  }
}

Fixed version (ground truth):
public void testGetTerminalPosition(){
  File file=null;
  try {
    file=File.createTempFile("String_Node_Str","String_Node_Str",getContext().getCacheDir());
  }
 catch (  IOException e) {
  }
  assertNotNull(file);
  final FusionDictionary dict=new FusionDictionary(new Node(),new FusionDictionary.DictionaryOptions(new HashMap<String,String>(),false,false));
  addUnigrams(sWords.size(),dict,sWords,null);
  timeWritingDictToFile(file,dict,VERSION3_WITH_DYNAMIC_UPDATE);
  final FusionDictionaryBufferInterface buffer=getBuffer(file,USE_BYTE_ARRAY);
  try {
    final String longWord="String_Node_Str";
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,longWord));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,null));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,"String_Node_Str"));
  }
 catch (  IOException e) {
  }
catch (  UnsupportedFormatException e) {
  }
  long sum=0;
  for (int i=0; i < sWords.size(); ++i) {
    final long time=runGetTerminalPosition(buffer,sWords.get(i),i,true);
    sum+=time == -1 ? 0 : time;
  }
  Log.d(TAG,"String_Node_Str" + (((double)sum) / sWords.size() / 1000000));
  final Random random=new Random((int)System.currentTimeMillis());
  for (int i=0; i < 1000; ++i) {
    final String word=generateWord(random);
    if (sWords.indexOf(word) != -1)     continue;
    runGetTerminalPosition(buffer,word,i,false);
  }
}
Program: 87785
Project: 87785
Buggy source:
public BinaryDictIOTests(){
  super();
  final Random random=new Random(123456);
  sWords.clear();
  generateWords(MAX_UNIGRAMS,random);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  for (int i=1; i < sWords.size(); ++i) {
    sStarBigrams.get(0).add(i);
  }
}

Fixed version (ground truth):
public BinaryDictIOTests(){
  super();
  final long time=System.currentTimeMillis();
  Log.e(TAG,"String_Node_Str" + time);
  final Random random=new Random(time);
  sWords.clear();
  generateWords(MAX_UNIGRAMS,random);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  for (int i=1; i < sWords.size(); ++i) {
    sStarBigrams.get(0).add(i);
  }
}
Program: 87786
Project: 87786
Buggy source:
/** 
 * Generates a random word.
 */
private String generateWord(final int value){
  final int lengthOfChars=CHARACTERS.length;
  StringBuilder builder=new StringBuilder("String_Node_Str");
  long lvalue=Math.abs((long)value);
  while (lvalue > 0) {
    builder.append(CHARACTERS[(int)(lvalue % lengthOfChars)]);
    lvalue/=lengthOfChars;
  }
  return builder.toString();
}

Fixed version (ground truth):
/** 
 * Generates a random word.
 */
private String generateWord(final Random random){
  StringBuilder builder=new StringBuilder("String_Node_Str");
  int count=random.nextInt() % 30;
  while (count > 0) {
    final long r=Math.abs(random.nextInt());
    if (r < 0)     continue;
    builder.appendCodePoint((int)(20 + r % (0x10FFFF - 20)));
    --count;
  }
  return builder.toString();
}
Program: 87787
Project: 87787
Buggy source:
private void generateWords(final int number,final Random random){
  final Set<String> wordSet=CollectionUtils.newHashSet();
  while (wordSet.size() < number) {
    wordSet.add(generateWord(random.nextInt()));
  }
  sWords.addAll(wordSet);
}

Fixed version (ground truth):
private void generateWords(final int number,final Random random){
  final Set<String> wordSet=CollectionUtils.newHashSet();
  while (wordSet.size() < number) {
    wordSet.add(generateWord(random));
  }
  sWords.addAll(wordSet);
}
Program: 87788
Project: 87788
Buggy source:
@Override public Word next(){
  Position currentPos=mPositions.getLast();
  mCurrentString.setLength(mCurrentString.length() - currentPos.length);
  do {
    if (currentPos.pos.hasNext()) {
      final CharGroup currentGroup=currentPos.pos.next();
      currentPos.length=currentGroup.mChars.length;
      for (      int i : currentGroup.mChars)       mCurrentString.append(Character.toChars(i));
      if (null != currentGroup.mChildren) {
        currentPos=new Position(currentGroup.mChildren.mData);
        mPositions.addLast(currentPos);
      }
      if (currentGroup.mFrequency >= 0)       return new Word(mCurrentString.toString(),currentGroup.mFrequency,currentGroup.mShortcutTargets,currentGroup.mBigrams,currentGroup.mIsNotAWord,currentGroup.mIsBlacklistEntry);
    }
 else {
      mPositions.removeLast();
      currentPos=mPositions.getLast();
      mCurrentString.setLength(mCurrentString.length() - mPositions.getLast().length);
    }
  }
 while (true);
}

Fixed version (ground truth):
@Override public Word next(){
  Position currentPos=mPositions.getLast();
  mCurrentString.setLength(currentPos.length);
  do {
    if (currentPos.pos.hasNext()) {
      final CharGroup currentGroup=currentPos.pos.next();
      currentPos.length=mCurrentString.length();
      for (      int i : currentGroup.mChars)       mCurrentString.append(Character.toChars(i));
      if (null != currentGroup.mChildren) {
        currentPos=new Position(currentGroup.mChildren.mData);
        mPositions.addLast(currentPos);
      }
      if (currentGroup.mFrequency >= 0)       return new Word(mCurrentString.toString(),currentGroup.mFrequency,currentGroup.mShortcutTargets,currentGroup.mBigrams,currentGroup.mIsNotAWord,currentGroup.mIsBlacklistEntry);
    }
 else {
      mPositions.removeLast();
      currentPos=mPositions.getLast();
      mCurrentString.setLength(mPositions.getLast().length);
    }
  }
 while (true);
}
Program: 87789
Project: 87789
Buggy source:
/** 
 * Helper method to find a word in a given branch.
 */
@SuppressWarnings("String_Node_Str") public static CharGroup findWordInTree(Node node,final String s){
  int index=0;
  final StringBuilder checker=DBG ? new StringBuilder() : null;
  CharGroup currentGroup;
  final int codePointCountInS=s.codePointCount(0,s.length());
  do {
    int indexOfGroup=findIndexOfChar(node,s.codePointAt(index));
    if (CHARACTER_NOT_FOUND == indexOfGroup)     return null;
    currentGroup=node.mData.get(indexOfGroup);
    if (s.length() - index < currentGroup.mChars.length)     return null;
    int newIndex=index;
    while (newIndex < s.length() && newIndex - index < currentGroup.mChars.length) {
      if (currentGroup.mChars[newIndex - index] != s.codePointAt(newIndex))       return null;
      newIndex++;
    }
    index=newIndex;
    if (DBG)     checker.append(new String(currentGroup.mChars,0,currentGroup.mChars.length));
    if (index < codePointCountInS) {
      node=currentGroup.mChildren;
    }
  }
 while (null != node && index < codePointCountInS);
  if (index < codePointCountInS)   return null;
  if (!currentGroup.isTerminal())   return null;
  if (DBG && !s.equals(checker.toString()))   return null;
  return currentGroup;
}

Fixed version (ground truth):
/** 
 * Helper method to find a word in a given branch.
 */
@SuppressWarnings("String_Node_Str") public static CharGroup findWordInTree(Node node,final String string){
  int index=0;
  final StringBuilder checker=DBG ? new StringBuilder() : null;
  final int[] codePoints=getCodePoints(string);
  CharGroup currentGroup;
  do {
    int indexOfGroup=findIndexOfChar(node,codePoints[index]);
    if (CHARACTER_NOT_FOUND == indexOfGroup)     return null;
    currentGroup=node.mData.get(indexOfGroup);
    if (codePoints.length - index < currentGroup.mChars.length)     return null;
    int newIndex=index;
    while (newIndex < codePoints.length && newIndex - index < currentGroup.mChars.length) {
      if (currentGroup.mChars[newIndex - index] != codePoints[newIndex])       return null;
      newIndex++;
    }
    index=newIndex;
    if (DBG)     checker.append(new String(currentGroup.mChars,0,currentGroup.mChars.length));
    if (index < codePoints.length) {
      node=currentGroup.mChildren;
    }
  }
 while (null != node && index < codePoints.length);
  if (index < codePoints.length)   return null;
  if (!currentGroup.isTerminal())   return null;
  if (DBG && !codePoints.equals(checker.toString()))   return null;
  return currentGroup;
}
Program: 87790
Project: 87790
Buggy source:
public void testGetTerminalPosition(){
  File file=null;
  try {
    file=File.createTempFile("String_Node_Str","String_Node_Str",getContext().getCacheDir());
  }
 catch (  IOException e) {
  }
  assertNotNull(file);
  final FusionDictionary dict=new FusionDictionary(new Node(),new FusionDictionary.DictionaryOptions(new HashMap<String,String>(),false,false));
  addUnigrams(sWords.size(),dict,sWords,null);
  timeWritingDictToFile(file,dict,VERSION3_WITH_DYNAMIC_UPDATE);
  final FusionDictionaryBufferInterface buffer=getBuffer(file,USE_BYTE_ARRAY);
  try {
    final String longWord="String_Node_Str";
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,longWord));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,null));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,"String_Node_Str"));
  }
 catch (  IOException e) {
  }
catch (  UnsupportedFormatException e) {
  }
  long sum=0;
  for (int i=0; i < sWords.size(); ++i) {
    final long time=runGetTerminalPosition(buffer,sWords.get(i),i,true);
    sum+=time == -1 ? 0 : time;
  }
  Log.d(TAG,"String_Node_Str" + (((double)sum) / sWords.size() / 1000000));
  final Random random=new Random((int)System.currentTimeMillis());
  for (int i=0; i < 1000; ++i) {
    final String word=generateWord(random.nextInt());
    if (sWords.indexOf(word) != -1)     continue;
    runGetTerminalPosition(buffer,word,i,false);
  }
}

Fixed version (ground truth):
public void testGetTerminalPosition(){
  File file=null;
  try {
    file=File.createTempFile("String_Node_Str","String_Node_Str",getContext().getCacheDir());
  }
 catch (  IOException e) {
  }
  assertNotNull(file);
  final FusionDictionary dict=new FusionDictionary(new Node(),new FusionDictionary.DictionaryOptions(new HashMap<String,String>(),false,false));
  addUnigrams(sWords.size(),dict,sWords,null);
  timeWritingDictToFile(file,dict,VERSION3_WITH_DYNAMIC_UPDATE);
  final FusionDictionaryBufferInterface buffer=getBuffer(file,USE_BYTE_ARRAY);
  try {
    final String longWord="String_Node_Str";
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,longWord));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,null));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,"String_Node_Str"));
  }
 catch (  IOException e) {
  }
catch (  UnsupportedFormatException e) {
  }
  long sum=0;
  for (int i=0; i < sWords.size(); ++i) {
    final long time=runGetTerminalPosition(buffer,sWords.get(i),i,true);
    sum+=time == -1 ? 0 : time;
  }
  Log.d(TAG,"String_Node_Str" + (((double)sum) / sWords.size() / 1000000));
  final Random random=new Random((int)System.currentTimeMillis());
  for (int i=0; i < 1000; ++i) {
    final String word=generateWord(random);
    if (sWords.indexOf(word) != -1)     continue;
    runGetTerminalPosition(buffer,word,i,false);
  }
}
Program: 87791
Project: 87791
Buggy source:
public BinaryDictIOTests(){
  super();
  final Random random=new Random(123456);
  sWords.clear();
  generateWords(MAX_UNIGRAMS,random);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  for (int i=1; i < sWords.size(); ++i) {
    sStarBigrams.get(0).add(i);
  }
}

Fixed version (ground truth):
public BinaryDictIOTests(){
  super();
  final long time=System.currentTimeMillis();
  Log.e(TAG,"String_Node_Str" + time);
  final Random random=new Random(time);
  sWords.clear();
  generateWords(MAX_UNIGRAMS,random);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  for (int i=1; i < sWords.size(); ++i) {
    sStarBigrams.get(0).add(i);
  }
}
Program: 87792
Project: 87792
Buggy source:
/** 
 * Generates a random word.
 */
private String generateWord(final int value){
  final int lengthOfChars=CHARACTERS.length;
  StringBuilder builder=new StringBuilder("String_Node_Str");
  long lvalue=Math.abs((long)value);
  while (lvalue > 0) {
    builder.append(CHARACTERS[(int)(lvalue % lengthOfChars)]);
    lvalue/=lengthOfChars;
  }
  return builder.toString();
}

Fixed version (ground truth):
/** 
 * Generates a random word.
 */
private String generateWord(final Random random){
  StringBuilder builder=new StringBuilder("String_Node_Str");
  int count=random.nextInt() % 30;
  while (count > 0) {
    final long r=Math.abs(random.nextInt());
    if (r < 0)     continue;
    builder.appendCodePoint((int)(20 + r % (0x10FFFF - 20)));
    --count;
  }
  return builder.toString();
}
Program: 87793
Project: 87793
Buggy source:
private void generateWords(final int number,final Random random){
  final Set<String> wordSet=CollectionUtils.newHashSet();
  while (wordSet.size() < number) {
    wordSet.add(generateWord(random.nextInt()));
  }
  sWords.addAll(wordSet);
}

Fixed version (ground truth):
private void generateWords(final int number,final Random random){
  final Set<String> wordSet=CollectionUtils.newHashSet();
  while (wordSet.size() < number) {
    wordSet.add(generateWord(random));
  }
  sWords.addAll(wordSet);
}
Program: 87794
Project: 87794
Buggy source:
@Override public Word next(){
  Position currentPos=mPositions.getLast();
  mCurrentString.setLength(mCurrentString.length() - currentPos.length);
  do {
    if (currentPos.pos.hasNext()) {
      final CharGroup currentGroup=currentPos.pos.next();
      currentPos.length=currentGroup.mChars.length;
      for (      int i : currentGroup.mChars)       mCurrentString.append(Character.toChars(i));
      if (null != currentGroup.mChildren) {
        currentPos=new Position(currentGroup.mChildren.mData);
        mPositions.addLast(currentPos);
      }
      if (currentGroup.mFrequency >= 0)       return new Word(mCurrentString.toString(),currentGroup.mFrequency,currentGroup.mShortcutTargets,currentGroup.mBigrams,currentGroup.mIsNotAWord,currentGroup.mIsBlacklistEntry);
    }
 else {
      mPositions.removeLast();
      currentPos=mPositions.getLast();
      mCurrentString.setLength(mCurrentString.length() - mPositions.getLast().length);
    }
  }
 while (true);
}

Fixed version (ground truth):
@Override public Word next(){
  Position currentPos=mPositions.getLast();
  mCurrentString.setLength(currentPos.length);
  do {
    if (currentPos.pos.hasNext()) {
      final CharGroup currentGroup=currentPos.pos.next();
      currentPos.length=mCurrentString.length();
      for (      int i : currentGroup.mChars)       mCurrentString.append(Character.toChars(i));
      if (null != currentGroup.mChildren) {
        currentPos=new Position(currentGroup.mChildren.mData);
        mPositions.addLast(currentPos);
      }
      if (currentGroup.mFrequency >= 0)       return new Word(mCurrentString.toString(),currentGroup.mFrequency,currentGroup.mShortcutTargets,currentGroup.mBigrams,currentGroup.mIsNotAWord,currentGroup.mIsBlacklistEntry);
    }
 else {
      mPositions.removeLast();
      currentPos=mPositions.getLast();
      mCurrentString.setLength(mPositions.getLast().length);
    }
  }
 while (true);
}
Program: 87795
Project: 87795
Buggy source:
/** 
 * Helper method to find a word in a given branch.
 */
@SuppressWarnings("String_Node_Str") public static CharGroup findWordInTree(Node node,final String s){
  int index=0;
  final StringBuilder checker=DBG ? new StringBuilder() : null;
  CharGroup currentGroup;
  final int codePointCountInS=s.codePointCount(0,s.length());
  do {
    int indexOfGroup=findIndexOfChar(node,s.codePointAt(index));
    if (CHARACTER_NOT_FOUND == indexOfGroup)     return null;
    currentGroup=node.mData.get(indexOfGroup);
    if (s.length() - index < currentGroup.mChars.length)     return null;
    int newIndex=index;
    while (newIndex < s.length() && newIndex - index < currentGroup.mChars.length) {
      if (currentGroup.mChars[newIndex - index] != s.codePointAt(newIndex))       return null;
      newIndex++;
    }
    index=newIndex;
    if (DBG)     checker.append(new String(currentGroup.mChars,0,currentGroup.mChars.length));
    if (index < codePointCountInS) {
      node=currentGroup.mChildren;
    }
  }
 while (null != node && index < codePointCountInS);
  if (index < codePointCountInS)   return null;
  if (!currentGroup.isTerminal())   return null;
  if (DBG && !s.equals(checker.toString()))   return null;
  return currentGroup;
}

Fixed version (ground truth):
/** 
 * Helper method to find a word in a given branch.
 */
@SuppressWarnings("String_Node_Str") public static CharGroup findWordInTree(Node node,final String string){
  int index=0;
  final StringBuilder checker=DBG ? new StringBuilder() : null;
  final int[] codePoints=getCodePoints(string);
  CharGroup currentGroup;
  do {
    int indexOfGroup=findIndexOfChar(node,codePoints[index]);
    if (CHARACTER_NOT_FOUND == indexOfGroup)     return null;
    currentGroup=node.mData.get(indexOfGroup);
    if (codePoints.length - index < currentGroup.mChars.length)     return null;
    int newIndex=index;
    while (newIndex < codePoints.length && newIndex - index < currentGroup.mChars.length) {
      if (currentGroup.mChars[newIndex - index] != codePoints[newIndex])       return null;
      newIndex++;
    }
    index=newIndex;
    if (DBG)     checker.append(new String(currentGroup.mChars,0,currentGroup.mChars.length));
    if (index < codePoints.length) {
      node=currentGroup.mChildren;
    }
  }
 while (null != node && index < codePoints.length);
  if (index < codePoints.length)   return null;
  if (!currentGroup.isTerminal())   return null;
  if (DBG && !codePoints.equals(checker.toString()))   return null;
  return currentGroup;
}
Program: 87796
Project: 87796
Buggy source:
public void testGetTerminalPosition(){
  File file=null;
  try {
    file=File.createTempFile("String_Node_Str","String_Node_Str",getContext().getCacheDir());
  }
 catch (  IOException e) {
  }
  assertNotNull(file);
  final FusionDictionary dict=new FusionDictionary(new Node(),new FusionDictionary.DictionaryOptions(new HashMap<String,String>(),false,false));
  addUnigrams(sWords.size(),dict,sWords,null);
  timeWritingDictToFile(file,dict,VERSION3_WITH_DYNAMIC_UPDATE);
  final FusionDictionaryBufferInterface buffer=getBuffer(file,USE_BYTE_ARRAY);
  try {
    final String longWord="String_Node_Str";
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,longWord));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,null));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,"String_Node_Str"));
  }
 catch (  IOException e) {
  }
catch (  UnsupportedFormatException e) {
  }
  long sum=0;
  for (int i=0; i < sWords.size(); ++i) {
    final long time=runGetTerminalPosition(buffer,sWords.get(i),i,true);
    sum+=time == -1 ? 0 : time;
  }
  Log.d(TAG,"String_Node_Str" + (((double)sum) / sWords.size() / 1000000));
  final Random random=new Random((int)System.currentTimeMillis());
  for (int i=0; i < 1000; ++i) {
    final String word=generateWord(random.nextInt());
    if (sWords.indexOf(word) != -1)     continue;
    runGetTerminalPosition(buffer,word,i,false);
  }
}

Fixed version (ground truth):
public void testGetTerminalPosition(){
  File file=null;
  try {
    file=File.createTempFile("String_Node_Str","String_Node_Str",getContext().getCacheDir());
  }
 catch (  IOException e) {
  }
  assertNotNull(file);
  final FusionDictionary dict=new FusionDictionary(new Node(),new FusionDictionary.DictionaryOptions(new HashMap<String,String>(),false,false));
  addUnigrams(sWords.size(),dict,sWords,null);
  timeWritingDictToFile(file,dict,VERSION3_WITH_DYNAMIC_UPDATE);
  final FusionDictionaryBufferInterface buffer=getBuffer(file,USE_BYTE_ARRAY);
  try {
    final String longWord="String_Node_Str";
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,longWord));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,null));
    assertEquals(FormatSpec.NOT_VALID_WORD,BinaryDictIOUtils.getTerminalPosition(buffer,"String_Node_Str"));
  }
 catch (  IOException e) {
  }
catch (  UnsupportedFormatException e) {
  }
  long sum=0;
  for (int i=0; i < sWords.size(); ++i) {
    final long time=runGetTerminalPosition(buffer,sWords.get(i),i,true);
    sum+=time == -1 ? 0 : time;
  }
  Log.d(TAG,"String_Node_Str" + (((double)sum) / sWords.size() / 1000000));
  final Random random=new Random((int)System.currentTimeMillis());
  for (int i=0; i < 1000; ++i) {
    final String word=generateWord(random);
    if (sWords.indexOf(word) != -1)     continue;
    runGetTerminalPosition(buffer,word,i,false);
  }
}
Program: 87797
Project: 87797
Buggy source:
public BinaryDictIOTests(){
  super();
  final Random random=new Random(123456);
  sWords.clear();
  generateWords(MAX_UNIGRAMS,random);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  for (int i=1; i < sWords.size(); ++i) {
    sStarBigrams.get(0).add(i);
  }
}

Fixed version (ground truth):
public BinaryDictIOTests(){
  super();
  final long time=System.currentTimeMillis();
  Log.e(TAG,"String_Node_Str" + time);
  final Random random=new Random(time);
  sWords.clear();
  generateWords(MAX_UNIGRAMS,random);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  for (int i=1; i < sWords.size(); ++i) {
    sStarBigrams.get(0).add(i);
  }
}
Program: 87798
Project: 87798
Buggy source:
/** 
 * Generates a random word.
 */
private String generateWord(final int value){
  final int lengthOfChars=CHARACTERS.length;
  StringBuilder builder=new StringBuilder("String_Node_Str");
  long lvalue=Math.abs((long)value);
  while (lvalue > 0) {
    builder.append(CHARACTERS[(int)(lvalue % lengthOfChars)]);
    lvalue/=lengthOfChars;
  }
  return builder.toString();
}

Fixed version (ground truth):
/** 
 * Generates a random word.
 */
private String generateWord(final Random random){
  StringBuilder builder=new StringBuilder("String_Node_Str");
  int count=random.nextInt() % 30;
  while (count > 0) {
    final long r=Math.abs(random.nextInt());
    if (r < 0)     continue;
    builder.appendCodePoint((int)(20 + r % (0x10FFFF - 20)));
    --count;
  }
  return builder.toString();
}
Program: 87799
Project: 87799
Buggy source:
private void generateWords(final int number,final Random random){
  final Set<String> wordSet=CollectionUtils.newHashSet();
  while (wordSet.size() < number) {
    wordSet.add(generateWord(random.nextInt()));
  }
  sWords.addAll(wordSet);
}

Fixed version (ground truth):
private void generateWords(final int number,final Random random){
  final Set<String> wordSet=CollectionUtils.newHashSet();
  while (wordSet.size() < number) {
    wordSet.add(generateWord(random));
  }
  sWords.addAll(wordSet);
}
Program: 87800
Project: 87800
Buggy source:
@Override public Word next(){
  Position currentPos=mPositions.getLast();
  mCurrentString.setLength(mCurrentString.length() - currentPos.length);
  do {
    if (currentPos.pos.hasNext()) {
      final CharGroup currentGroup=currentPos.pos.next();
      currentPos.length=currentGroup.mChars.length;
      for (      int i : currentGroup.mChars)       mCurrentString.append(Character.toChars(i));
      if (null != currentGroup.mChildren) {
        currentPos=new Position(currentGroup.mChildren.mData);
        mPositions.addLast(currentPos);
      }
      if (currentGroup.mFrequency >= 0)       return new Word(mCurrentString.toString(),currentGroup.mFrequency,currentGroup.mShortcutTargets,currentGroup.mBigrams,currentGroup.mIsNotAWord,currentGroup.mIsBlacklistEntry);
    }
 else {
      mPositions.removeLast();
      currentPos=mPositions.getLast();
      mCurrentString.setLength(mCurrentString.length() - mPositions.getLast().length);
    }
  }
 while (true);
}

Fixed version (ground truth):
@Override public Word next(){
  Position currentPos=mPositions.getLast();
  mCurrentString.setLength(currentPos.length);
  do {
    if (currentPos.pos.hasNext()) {
      final CharGroup currentGroup=currentPos.pos.next();
      currentPos.length=mCurrentString.length();
      for (      int i : currentGroup.mChars)       mCurrentString.append(Character.toChars(i));
      if (null != currentGroup.mChildren) {
        currentPos=new Position(currentGroup.mChildren.mData);
        mPositions.addLast(currentPos);
      }
      if (currentGroup.mFrequency >= 0)       return new Word(mCurrentString.toString(),currentGroup.mFrequency,currentGroup.mShortcutTargets,currentGroup.mBigrams,currentGroup.mIsNotAWord,currentGroup.mIsBlacklistEntry);
    }
 else {
      mPositions.removeLast();
      currentPos=mPositions.getLast();
      mCurrentString.setLength(mPositions.getLast().length);
    }
  }
 while (true);
}
Program: 87801
Project: 87801
Buggy source:
/** 
 * Helper method to find a word in a given branch.
 */
@SuppressWarnings("String_Node_Str") public static CharGroup findWordInTree(Node node,final String s){
  int index=0;
  final StringBuilder checker=DBG ? new StringBuilder() : null;
  CharGroup currentGroup;
  final int codePointCountInS=s.codePointCount(0,s.length());
  do {
    int indexOfGroup=findIndexOfChar(node,s.codePointAt(index));
    if (CHARACTER_NOT_FOUND == indexOfGroup)     return null;
    currentGroup=node.mData.get(indexOfGroup);
    if (s.length() - index < currentGroup.mChars.length)     return null;
    int newIndex=index;
    while (newIndex < s.length() && newIndex - index < currentGroup.mChars.length) {
      if (currentGroup.mChars[newIndex - index] != s.codePointAt(newIndex))       return null;
      newIndex++;
    }
    index=newIndex;
    if (DBG)     checker.append(new String(currentGroup.mChars,0,currentGroup.mChars.length));
    if (index < codePointCountInS) {
      node=currentGroup.mChildren;
    }
  }
 while (null != node && index < codePointCountInS);
  if (index < codePointCountInS)   return null;
  if (!currentGroup.isTerminal())   return null;
  if (DBG && !s.equals(checker.toString()))   return null;
  return currentGroup;
}

Fixed version (ground truth):
/** 
 * Helper method to find a word in a given branch.
 */
@SuppressWarnings("String_Node_Str") public static CharGroup findWordInTree(Node node,final String string){
  int index=0;
  final StringBuilder checker=DBG ? new StringBuilder() : null;
  final int[] codePoints=getCodePoints(string);
  CharGroup currentGroup;
  do {
    int indexOfGroup=findIndexOfChar(node,codePoints[index]);
    if (CHARACTER_NOT_FOUND == indexOfGroup)     return null;
    currentGroup=node.mData.get(indexOfGroup);
    if (codePoints.length - index < currentGroup.mChars.length)     return null;
    int newIndex=index;
    while (newIndex < codePoints.length && newIndex - index < currentGroup.mChars.length) {
      if (currentGroup.mChars[newIndex - index] != codePoints[newIndex])       return null;
      newIndex++;
    }
    index=newIndex;
    if (DBG)     checker.append(new String(currentGroup.mChars,0,currentGroup.mChars.length));
    if (index < codePoints.length) {
      node=currentGroup.mChildren;
    }
  }
 while (null != node && index < codePoints.length);
  if (index < codePoints.length)   return null;
  if (!currentGroup.isTerminal())   return null;
  if (DBG && !codePoints.equals(checker.toString()))   return null;
  return currentGroup;
}