code: private String[] halfMatchI(String longtext, String shorttext, int i) {
          // Start with a 1/4 length substring at position i as a seed.
          String seed = longtext.substring(i, i + longtext.length() / 4);
          int j = -1;
          String best_common = "";
          String best_longtext_a = "", best_longtext_b = "";
          String best_shorttext_a = "", best_shorttext_b = "";
          while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
              int prefixLength = commonPrefix(longtext.substring(i),
                                              shorttext.substring(j));
              int suffixLength = commonSuffix(longtext.substring(0, i),
                                              shorttext.substring(0, j));
              if (best_common.length() < suffixLength + prefixLength) {
                  best_common = shorttext.substring(j - suffixLength, j)
                                + shorttext.substring(j, j + prefixLength);
                  best_longtext_a = longtext.substring(0, i - suffixLength);
                  best_longtext_b = longtext.substring(i + prefixLength);
                  best_shorttext_a = shorttext.substring(0, j - suffixLength);
                  best_shorttext_b = shorttext.substring(j + prefixLength);
              }
          }
          if (best_common.length() * 2 >= longtext.length()) {
              return new String[]{best_longtext_a, best_longtext_b,
                      best_shorttext_a, best_shorttext_b, best_common};
          } else {
              return null;
          }
      }
docs: Does a substring of shorttext exist within longtext such that the
  substring is at least half the length of longtext?
  @param longtext Longer string.
  @param shorttext Shorter string.
  @param i Start index of quarter length substring within longtext.
  @return Five element String array, containing the prefix of longtext, the
  suffix of longtext, the prefix of shorttext, the suffix of shorttext
  and the common middle.  Or null if there was no match.