code: public int indexOf(final String str, int startIndex) {
          startIndex = (startIndex < 0 ? 0 : startIndex);
          if (str == null || startIndex >= size) {
              return -1;
          }
          final int strLen = str.length();
          if (strLen == 1) {
              return indexOf(str.charAt(0), startIndex);
          }
          if (strLen == 0) {
              return startIndex;
          }
          if (strLen > size) {
              return -1;
          }
          final char[] thisBuf = buffer;
          final int len = size - strLen + 1;
          outer:
          for (int i = startIndex; i < len; i++) {
              for (int j = 0; j < strLen; j++) {
                  if (str.charAt(j) != thisBuf[i + j]) {
                      continue outer;
                  }
              }
              return i;
          }
          return -1;
      }
docs: Searches the string builder to find the first reference to the specified
  string starting searching from the given index.
  <p>
  Note that a null input string will return -1, whereas the JDK throws an exception.
  
  @param str  the string to find, null returns -1
  @param startIndex  the index to start at, invalid index rounded to edge
  @return the first index of the string, or -1 if not found