emul/mini/src/main/java/java/lang/Appendable.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 23 Jan 2013 20:39:23 +0100
branchemul
changeset 554 05224402145d
parent 59 emul/src/main/java/java/lang/Appendable.java@d8e812b1ee1f
permissions -rw-r--r--
First attempt to separate 'mini' profile from the rest of JDK APIs
jaroslav@59
     1
/*
jaroslav@59
     2
 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
jaroslav@59
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@59
     4
 *
jaroslav@59
     5
 * This code is free software; you can redistribute it and/or modify it
jaroslav@59
     6
 * under the terms of the GNU General Public License version 2 only, as
jaroslav@59
     7
 * published by the Free Software Foundation.  Oracle designates this
jaroslav@59
     8
 * particular file as subject to the "Classpath" exception as provided
jaroslav@59
     9
 * by Oracle in the LICENSE file that accompanied this code.
jaroslav@59
    10
 *
jaroslav@59
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@59
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@59
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
jaroslav@59
    14
 * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@59
    15
 * accompanied this code).
jaroslav@59
    16
 *
jaroslav@59
    17
 * You should have received a copy of the GNU General Public License version
jaroslav@59
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@59
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@59
    20
 *
jaroslav@59
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@59
    22
 * or visit www.oracle.com if you need additional information or have any
jaroslav@59
    23
 * questions.
jaroslav@59
    24
 */
jaroslav@59
    25
jaroslav@59
    26
package java.lang;
jaroslav@59
    27
jaroslav@59
    28
import java.io.IOException;
jaroslav@59
    29
jaroslav@59
    30
/**
jaroslav@59
    31
 * An object to which <tt>char</tt> sequences and values can be appended.  The
jaroslav@59
    32
 * <tt>Appendable</tt> interface must be implemented by any class whose
jaroslav@59
    33
 * instances are intended to receive formatted output from a {@link
jaroslav@59
    34
 * java.util.Formatter}.
jaroslav@59
    35
 *
jaroslav@59
    36
 * <p> The characters to be appended should be valid Unicode characters as
jaroslav@59
    37
 * described in <a href="Character.html#unicode">Unicode Character
jaroslav@59
    38
 * Representation</a>.  Note that supplementary characters may be composed of
jaroslav@59
    39
 * multiple 16-bit <tt>char</tt> values.
jaroslav@59
    40
 *
jaroslav@59
    41
 * <p> Appendables are not necessarily safe for multithreaded access.  Thread
jaroslav@59
    42
 * safety is the responsibility of classes that extend and implement this
jaroslav@59
    43
 * interface.
jaroslav@59
    44
 *
jaroslav@59
    45
 * <p> Since this interface may be implemented by existing classes
jaroslav@59
    46
 * with different styles of error handling there is no guarantee that
jaroslav@59
    47
 * errors will be propagated to the invoker.
jaroslav@59
    48
 *
jaroslav@59
    49
 * @since 1.5
jaroslav@59
    50
 */
jaroslav@59
    51
public interface Appendable {
jaroslav@59
    52
jaroslav@59
    53
    /**
jaroslav@59
    54
     * Appends the specified character sequence to this <tt>Appendable</tt>.
jaroslav@59
    55
     *
jaroslav@59
    56
     * <p> Depending on which class implements the character sequence
jaroslav@59
    57
     * <tt>csq</tt>, the entire sequence may not be appended.  For
jaroslav@59
    58
     * instance, if <tt>csq</tt> is a {@link java.nio.CharBuffer} then
jaroslav@59
    59
     * the subsequence to append is defined by the buffer's position and limit.
jaroslav@59
    60
     *
jaroslav@59
    61
     * @param  csq
jaroslav@59
    62
     *         The character sequence to append.  If <tt>csq</tt> is
jaroslav@59
    63
     *         <tt>null</tt>, then the four characters <tt>"null"</tt> are
jaroslav@59
    64
     *         appended to this Appendable.
jaroslav@59
    65
     *
jaroslav@59
    66
     * @return  A reference to this <tt>Appendable</tt>
jaroslav@59
    67
     *
jaroslav@59
    68
     * @throws  IOException
jaroslav@59
    69
     *          If an I/O error occurs
jaroslav@59
    70
     */
jaroslav@59
    71
    Appendable append(CharSequence csq) throws IOException;
jaroslav@59
    72
jaroslav@59
    73
    /**
jaroslav@59
    74
     * Appends a subsequence of the specified character sequence to this
jaroslav@59
    75
     * <tt>Appendable</tt>.
jaroslav@59
    76
     *
jaroslav@59
    77
     * <p> An invocation of this method of the form <tt>out.append(csq, start,
jaroslav@59
    78
     * end)</tt> when <tt>csq</tt> is not <tt>null</tt>, behaves in
jaroslav@59
    79
     * exactly the same way as the invocation
jaroslav@59
    80
     *
jaroslav@59
    81
     * <pre>
jaroslav@59
    82
     *     out.append(csq.subSequence(start, end)) </pre>
jaroslav@59
    83
     *
jaroslav@59
    84
     * @param  csq
jaroslav@59
    85
     *         The character sequence from which a subsequence will be
jaroslav@59
    86
     *         appended.  If <tt>csq</tt> is <tt>null</tt>, then characters
jaroslav@59
    87
     *         will be appended as if <tt>csq</tt> contained the four
jaroslav@59
    88
     *         characters <tt>"null"</tt>.
jaroslav@59
    89
     *
jaroslav@59
    90
     * @param  start
jaroslav@59
    91
     *         The index of the first character in the subsequence
jaroslav@59
    92
     *
jaroslav@59
    93
     * @param  end
jaroslav@59
    94
     *         The index of the character following the last character in the
jaroslav@59
    95
     *         subsequence
jaroslav@59
    96
     *
jaroslav@59
    97
     * @return  A reference to this <tt>Appendable</tt>
jaroslav@59
    98
     *
jaroslav@59
    99
     * @throws  IndexOutOfBoundsException
jaroslav@59
   100
     *          If <tt>start</tt> or <tt>end</tt> are negative, <tt>start</tt>
jaroslav@59
   101
     *          is greater than <tt>end</tt>, or <tt>end</tt> is greater than
jaroslav@59
   102
     *          <tt>csq.length()</tt>
jaroslav@59
   103
     *
jaroslav@59
   104
     * @throws  IOException
jaroslav@59
   105
     *          If an I/O error occurs
jaroslav@59
   106
     */
jaroslav@59
   107
    Appendable append(CharSequence csq, int start, int end) throws IOException;
jaroslav@59
   108
jaroslav@59
   109
    /**
jaroslav@59
   110
     * Appends the specified character to this <tt>Appendable</tt>.
jaroslav@59
   111
     *
jaroslav@59
   112
     * @param  c
jaroslav@59
   113
     *         The character to append
jaroslav@59
   114
     *
jaroslav@59
   115
     * @return  A reference to this <tt>Appendable</tt>
jaroslav@59
   116
     *
jaroslav@59
   117
     * @throws  IOException
jaroslav@59
   118
     *          If an I/O error occurs
jaroslav@59
   119
     */
jaroslav@59
   120
    Appendable append(char c) throws IOException;
jaroslav@59
   121
}