code: static int binarySearch(final char[][] values,
                              final String text, final int start, final int end) {
  
          int low = 0;
          int high = values.length - 1;
  
          int partialIndex = Integer.MIN_VALUE;
          int partialValue = Integer.MIN_VALUE;
  
          while (low <= high) {
  
              final int mid = (low + high) >>> 1;
              final char[] midVal = values[mid];
  
              final int cmp = compare(midVal, text, start, end);
  
              if (cmp == -1) {
                  low = mid + 1;
              } else if (cmp == 1) {
                  high = mid - 1;
              } else if (cmp < -10) {
                  // Partial match
                  low = mid + 1;
                  if (partialIndex == Integer.MIN_VALUE || partialValue < cmp) {
                      partialIndex = mid;
                      partialValue = cmp; // partial will always be negative, and -10. We look for the smallest partial
                  }
              } else {
                  // Found!!
                  return mid;
              }
  
          }
  
          if (partialIndex != Integer.MIN_VALUE) {
              // We have a partial result. We return the closest result index as negative + (-10)
              return (-1) * (partialIndex + 10);
          }
  
          return Integer.MIN_VALUE; // Not found!
  
      }
docs: /*
  These two methods (two versions: for String and for char[]) are used during unescape at the
  {@link HtmlEscapeUtil} class in order to quickly find the NCR corresponding to a preselected fragment
  of text (if there is such NCR).
  
  Note this operation supports partial matching (based on the above 'compare(...)' methods). That way,
  if an exact match is not found but a partial match exists, the partial match will be returned.