/** * Returns the content of this {@code TableAppender} as a string if possible. * * <ul> * <li>If this {@code TableAppender} has been created without explicit {@link Appendable}, * then this method always returns the current table content formatted as a string.</li> * <li>Otherwise, if {@link #out} implements {@link CharSequence} or is directly or * indirectly a wrapper around a {@code CharSequence}, returns its {@code toString()} * representation. The string will contain this table content only if {@link #flush()} * has been invoked prior this {@code toString()} method.</li> * <li>Otherwise returns the localized <cite>"Unavailable content"</cite> string.</li> * </ul> */ @Override public String toString() { if (ownOut) { ((StringBuilder) out).setLength(0); try { writeTable(); } catch (IOException e) { // Should never happen because we are writing in a StringBuilder. throw new AssertionError(e); } } return super.toString(); }
/** * Returns the content of this {@code TableAppender} as a string if possible. * * <ul> * <li>If this {@code TableAppender} has been created without explicit {@link Appendable}, * then this method always returns the current table content formatted as a string.</li> * <li>Otherwise, if {@link #out} implements {@link CharSequence} or is directly or * indirectly a wrapper around a {@code CharSequence}, returns its {@code toString()} * representation. The string will contain this table content only if {@link #flush()} * has been invoked prior this {@code toString()} method.</li> * <li>Otherwise returns the localized <cite>"Unavailable content"</cite> string.</li> * </ul> */ @Override public String toString() { if (ownOut) { ((StringBuilder) out).setLength(0); try { writeTable(); } catch (IOException e) { // Should never happen because we are writing in a StringBuilder. throw new UncheckedIOException(e); } } return super.toString(); }