CharSeq.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2001, 2005 Per M.A. Bothner and Brainfood Inc.
  2. // This is free software; for terms and warranty disclaimer see ./COPYING.
  3. package gnu.lists;
  4. import gnu.text.Char;
  5. /** A sequence where each element is a character (Unicode code point).
  6. */
  7. public interface CharSeq
  8. extends CharSequence, Sequence<Char>, Consumable
  9. {
  10. /** Get length of string, in code units (not characters).
  11. * In contract, size() returns the number of 16-bit code points. */
  12. public int length();
  13. /** The index is in terms of code units. */
  14. public char charAt(int index);
  15. /** Copy characters into a destination buffer.
  16. * Same interface as java.lang.String's getChars.
  17. * @param srcBegin source start position, in 16-bit code units.
  18. * @param srcEnd source end position, in 16-bit code units.
  19. * @param dst destination
  20. * @param dstBegin index (in code units) in dst array
  21. */
  22. public void getChars (int srcBegin, int srcEnd, char[] dst, int dstBegin);
  23. public void setCharAt(int index, char ch);
  24. public void setCharacterAt(int index, int ch);
  25. /** Append a specified subsequence to an <code>Appendable</code>.
  26. * An allowable implementation is:
  27. * <code>dest.append(this, start, start+count)</code>.
  28. * Hence implementors of <code>Appendable</code> should avoid calling
  29. * <code>writeTo</code> - though they can call <code>getChars</code>.
  30. */
  31. public void writeTo(int start, int count, Appendable dest)
  32. throws java.io.IOException;
  33. public void writeTo(Appendable dest)
  34. throws java.io.IOException;
  35. public String toString();
  36. }