2 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
28 import java.io.IOException;
31 * An object to which <tt>char</tt> sequences and values can be appended. The
32 * <tt>Appendable</tt> interface must be implemented by any class whose
33 * instances are intended to receive formatted output from a {@link
34 * java.util.Formatter}.
36 * <p> The characters to be appended should be valid Unicode characters as
37 * described in <a href="Character.html#unicode">Unicode Character
38 * Representation</a>. Note that supplementary characters may be composed of
39 * multiple 16-bit <tt>char</tt> values.
41 * <p> Appendables are not necessarily safe for multithreaded access. Thread
42 * safety is the responsibility of classes that extend and implement this
45 * <p> Since this interface may be implemented by existing classes
46 * with different styles of error handling there is no guarantee that
47 * errors will be propagated to the invoker.
51 public interface Appendable {
54 * Appends the specified character sequence to this <tt>Appendable</tt>.
56 * <p> Depending on which class implements the character sequence
57 * <tt>csq</tt>, the entire sequence may not be appended. For
58 * instance, if <tt>csq</tt> is a {@link java.nio.CharBuffer} then
59 * the subsequence to append is defined by the buffer's position and limit.
62 * The character sequence to append. If <tt>csq</tt> is
63 * <tt>null</tt>, then the four characters <tt>"null"</tt> are
64 * appended to this Appendable.
66 * @return A reference to this <tt>Appendable</tt>
69 * If an I/O error occurs
71 Appendable append(CharSequence csq) throws IOException;
74 * Appends a subsequence of the specified character sequence to this
75 * <tt>Appendable</tt>.
77 * <p> An invocation of this method of the form <tt>out.append(csq, start,
78 * end)</tt> when <tt>csq</tt> is not <tt>null</tt>, behaves in
79 * exactly the same way as the invocation
82 * out.append(csq.subSequence(start, end)) </pre>
85 * The character sequence from which a subsequence will be
86 * appended. If <tt>csq</tt> is <tt>null</tt>, then characters
87 * will be appended as if <tt>csq</tt> contained the four
88 * characters <tt>"null"</tt>.
91 * The index of the first character in the subsequence
94 * The index of the character following the last character in the
97 * @return A reference to this <tt>Appendable</tt>
99 * @throws IndexOutOfBoundsException
100 * If <tt>start</tt> or <tt>end</tt> are negative, <tt>start</tt>
101 * is greater than <tt>end</tt>, or <tt>end</tt> is greater than
102 * <tt>csq.length()</tt>
104 * @throws IOException
105 * If an I/O error occurs
107 Appendable append(CharSequence csq, int start, int end) throws IOException;
110 * Appends the specified character to this <tt>Appendable</tt>.
113 * The character to append
115 * @return A reference to this <tt>Appendable</tt>
117 * @throws IOException
118 * If an I/O error occurs
120 Appendable append(char c) throws IOException;