Exemplo n.º 1
0
  /**
   * Flushes any buffered but not yet written characters. Subclasses which override this method
   * should call this method <em>before</em> flushing any of their own buffers.
   */
  public void flush() throws IOException {
    super.flush();

    if (state == S_text && currentCharacters.length() > 0) {
      handleText(currentCharacters.toString());
      currentCharacters = new StringBuffer();
    }
  }
Exemplo n.º 2
0
  /**
   * Closes the parser. Currently, this simply does a <code>flush()</code>, followed by some minimal
   * consistency checks.
   */
  public void close() throws IOException {
    flush();

    if (state != S_text || level > 0) {
      warning("Truncated RTF file.");

      /* TODO: any sane way to handle termination in a non-S_text state? */
      /* probably not */

      /* this will cause subclasses to behave more reasonably
      some of the time */
      while (level > 0) {
        endgroup();
        level--;
      }
    }

    super.close();
  }