Appendable.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* Appendable.java -- Something to which characters can be appended
  2. Copyright (C) 2004 Free Software Foundation
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.lang;
  32. import java.io.IOException;
  33. /**
  34. * <p>
  35. * An <code>Appendable</code> object is one to which a sequence of Unicode
  36. * characters can be added. The appended characters must be valid Unicode
  37. * characters, and may include supplementary characters, composed of multiple
  38. * 16-bit <code>char</code> values.
  39. * </p>
  40. * <p>
  41. * The behaviour of the <code>Appendable</code> object is heavily dependent
  42. * on the particular implementation being used. Some implementations may be
  43. * thread-safe, while others may not. Likewise, some implementing classes
  44. * may produce errors which aren't propogated to the invoking class, due
  45. * to differences in the error handling used.
  46. * </p>
  47. * <p>
  48. * <strong>Note</strong>: implementation of this interface is required for
  49. * any class that wishes to receive data from a <code>Formatter</code>
  50. * instance.
  51. * </p>
  52. *
  53. * @author Tom Tromey (tromey@redhat.com)
  54. * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  55. * @since 1.5
  56. */
  57. public interface Appendable
  58. {
  59. /**
  60. * Appends the Unicode character, c, to this <code>Appendable</code>
  61. * object.
  62. *
  63. * @param c the character to append.
  64. * @return a reference to this object.
  65. * @throws IOException if an I/O error occurs.
  66. */
  67. Appendable append(char c)
  68. throws IOException;
  69. /**
  70. * Appends the specified sequence of Unicode characters to this
  71. * <code>Appendable</code> object. The entire sequence may not
  72. * be appended, if constrained by the underlying implementation.
  73. * For example, a buffer may reach its size limit before the entire
  74. * sequence is appended.
  75. *
  76. * @param seq the character sequence to append. If seq is null,
  77. * then the string "null" (the string representation of null)
  78. * is appended.
  79. * @return a reference to this object.
  80. * @throws IOException if an I/O error occurs.
  81. */
  82. Appendable append(CharSequence seq)
  83. throws IOException;
  84. /**
  85. * Appends the specified subsequence of Unicode characters to this
  86. * <code>Appendable</code> object, starting and ending at the specified
  87. * positions within the sequence. The entire sequence may not
  88. * be appended, if constrained by the underlying implementation.
  89. * For example, a buffer may reach its size limit before the entire
  90. * sequence is appended. The behaviour of this method matches the
  91. * behaviour of <code>append(seq.subSequence(start,end))</code> when
  92. * the sequence is not null.
  93. *
  94. * @param seq the character sequence to append. If seq is null,
  95. * then the string "null" (the string representation of null)
  96. * is appended.
  97. * @param start the index of the first Unicode character to use from
  98. * the sequence.
  99. * @param end the index of the last Unicode character to use from the
  100. * sequence.
  101. * @return a reference to this object.
  102. * @throws IOException if an I/O error occurs.
  103. * @throws IndexOutOfBoundsException if either of the indices are negative,
  104. * the start index occurs after the end index, or the end index is
  105. * beyond the end of the sequence.
  106. */
  107. Appendable append(CharSequence seq, int start, int end)
  108. throws IOException;
  109. }