/** * Creates a new filtered formatter which will send its output to the given stream or buffer. * * @param out the underlying character output stream or buffer. */ AppendableWriter(final Appendable out) { super(getLock(out)); this.out = out; }
/** * Returns a view of the given {@code Appendable} as a {@code Writer}. * If the given argument is already a {@code Writer} instance, then it is returned unchanged. * Otherwise if the argument is non-null, then it is wrapped in an adapter. * Any write operations performed on the returned writer will be forwarded * to the given {@code Appendable}. * * @param out the output stream, writer or buffer to view as a {@link Writer}, or {@code null}. * @return a view of this {@code Appendable} as a writer, or {@code null} if the given argument was null. */ public static Writer asWriter(final Appendable out) { if (out == null || out instanceof Writer) { return (Writer) out; } return new AppendableWriter(out); } }
/** * Returns a view of the given {@code Appendable} as a {@code Writer}. * If the given argument is already a {@code Writer} instance, then it is returned unchanged. * Otherwise if the argument is non-null, then it is wrapped in an adapter. * Any write operations performed on the returned writer will be forwarded * to the given {@code Appendable}. * * @param out the output stream, writer or buffer to view as a {@link Writer}, or {@code null}. * @return a view of this {@code Appendable} as a writer, or {@code null} if the given argument was null. */ public static Writer asWriter(final Appendable out) { if (out == null || out instanceof Writer) { return (Writer) out; } return new AppendableWriter(out); } }
/** * Creates a new filtered formatter which will send its output to the given stream or buffer. * * @param out the underlying character output stream or buffer. */ AppendableWriter(final Appendable out) { super(getLock(out)); this.out = out; }