code: private boolean checkCDataEnd(char[] outBuf, int outPtr)
          throws XMLStreamException
      {
          int bracketCount = 0;
          char c;
          do {
              ++bracketCount;
              c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++]
                  : getNextCharFromCurrent(SUFFIX_IN_CDATA);
          } while (c == ']');
  
          boolean match = (bracketCount >= 2 && c == '>');
          if (match) {
              bracketCount -= 2;
          }
          while (bracketCount > 0) {
              --bracketCount;
              outBuf[outPtr++] = ']';
              if (outPtr >= outBuf.length) {
                  /* Can't really easily return, even if we have enough
                   * stuff here, since we've more than one char...
                   */
                  outBuf = mTextBuffer.finishCurrentSegment();
                  outPtr = 0;
              }
          }
          mTextBuffer.setCurrentLength(outPtr);
          // Match? Can break, then:
          if (match) {
              return true;
          }
          // No match, need to push the last char back and admit defeat...
          --mInputPtr;
          return false;
      }
docs: Method that will check, given the starting ']', whether there is
  ending ']]>' (including optional extra ']'s); if so, will updated
  output buffer with extra ]s, if not, will make sure input and output
  are positioned for further checking.
  
  @return True, if we hit the end marker; false if not.