001 /* Appendable.java -- Something to which characters can be appended 002 Copyright (C) 2004 Free Software Foundation 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 package java.lang; 039 040 import java.io.IOException; 041 042 /** 043 * <p> 044 * An <code>Appendable</code> object is one to which a sequence of Unicode 045 * characters can be added. The appended characters must be valid Unicode 046 * characters, and may include supplementary characters, composed of multiple 047 * 16-bit <code>char</code> values. 048 * </p> 049 * <p> 050 * The behaviour of the <code>Appendable</code> object is heavily dependent 051 * on the particular implementation being used. Some implementations may be 052 * thread-safe, while others may not. Likewise, some implementing classes 053 * may produce errors which aren't propogated to the invoking class, due 054 * to differences in the error handling used. 055 * </p> 056 * <p> 057 * <strong>Note</strong>: implementation of this interface is required for 058 * any class that wishes to receive data from a <code>Formatter</code> 059 * instance. 060 * </p> 061 * 062 * @author Tom Tromey (tromey@redhat.com) 063 * @author Andrew John Hughes (gnu_andrew@member.fsf.org) 064 * @since 1.5 065 */ 066 public interface Appendable 067 { 068 069 /** 070 * Appends the Unicode character, c, to this <code>Appendable</code> 071 * object. 072 * 073 * @param c the character to append. 074 * @return a reference to this object. 075 * @throws IOException if an I/O error occurs. 076 */ 077 Appendable append(char c) 078 throws IOException; 079 080 /** 081 * Appends the specified sequence of Unicode characters to this 082 * <code>Appendable</code> object. The entire sequence may not 083 * be appended, if constrained by the underlying implementation. 084 * For example, a buffer may reach its size limit before the entire 085 * sequence is appended. 086 * 087 * @param seq the character sequence to append. If seq is null, 088 * then the string "null" (the string representation of null) 089 * is appended. 090 * @return a reference to this object. 091 * @throws IOException if an I/O error occurs. 092 */ 093 Appendable append(CharSequence seq) 094 throws IOException; 095 096 /** 097 * Appends the specified subsequence of Unicode characters to this 098 * <code>Appendable</code> object, starting and ending at the specified 099 * positions within the sequence. The entire sequence may not 100 * be appended, if constrained by the underlying implementation. 101 * For example, a buffer may reach its size limit before the entire 102 * sequence is appended. The behaviour of this method matches the 103 * behaviour of <code>append(seq.subSequence(start,end))</code> when 104 * the sequence is not null. 105 * 106 * @param seq the character sequence to append. If seq is null, 107 * then the string "null" (the string representation of null) 108 * is appended. 109 * @param start the index of the first Unicode character to use from 110 * the sequence. 111 * @param end the index of the last Unicode character to use from the 112 * sequence. 113 * @return a reference to this object. 114 * @throws IOException if an I/O error occurs. 115 * @throws IndexOutOfBoundsException if either of the indices are negative, 116 * the start index occurs after the end index, or the end index is 117 * beyond the end of the sequence. 118 */ 119 Appendable append(CharSequence seq, int start, int end) 120 throws IOException; 121 122 }