CharSequence.hx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package java.lang;
  2. /*
  3. * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
  4. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5. *
  6. * This code is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 only, as
  8. * published by the Free Software Foundation. Oracle designates this
  9. * particular file as subject to the "Classpath" exception as provided
  10. * by Oracle in the LICENSE file that accompanied this code.
  11. *
  12. * This code is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  15. * version 2 for more details (a copy is included in the LICENSE file that
  16. * accompanied this code).
  17. *
  18. * You should have received a copy of the GNU General Public License version
  19. * 2 along with this work; if not, write to the Free Software Foundation,
  20. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21. *
  22. * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  23. * or visit www.oracle.com if you need additional information or have any
  24. * questions.
  25. */
  26. /**
  27. * A <tt>CharSequence</tt> is a readable sequence of <code>char</code> values. This
  28. * interface provides uniform, read-only access to many different kinds of
  29. * <code>char</code> sequences.
  30. * A <code>char</code> value represents a character in the <i>Basic
  31. * Multilingual Plane (BMP)</i> or a surrogate. Refer to <a
  32. * href="Character.html#unicode">Unicode Character Representation</a> for details.
  33. *
  34. * <p> This interface does not refine the general contracts of the {@link
  35. * java.lang.Object#equals(java.lang.Object) equals} and {@link
  36. * java.lang.Object#hashCode() hashCode} methods. The result of comparing two
  37. * objects that implement <tt>CharSequence</tt> is therefore, in general,
  38. * undefined. Each object may be implemented by a different class, and there
  39. * is no guarantee that each class will be capable of testing its instances
  40. * for equality with those of the other. It is therefore inappropriate to use
  41. * arbitrary <tt>CharSequence</tt> instances as elements in a set or as keys in
  42. * a map. </p>
  43. *
  44. * @author Mike McCloskey
  45. * @since 1.4
  46. * @spec JSR-51
  47. */
  48. @:require(java4) extern interface CharSequence
  49. {
  50. /**
  51. * Returns the length of this character sequence. The length is the number
  52. * of 16-bit <code>char</code>s in the sequence.</p>
  53. *
  54. * @return the number of <code>char</code>s in this sequence
  55. */
  56. @:overload public function length() : Int;
  57. /**
  58. * Returns the <code>char</code> value at the specified index. An index ranges from zero
  59. * to <tt>length() - 1</tt>. The first <code>char</code> value of the sequence is at
  60. * index zero, the next at index one, and so on, as for array
  61. * indexing. </p>
  62. *
  63. * <p>If the <code>char</code> value specified by the index is a
  64. * <a href="{@docRoot}/java/lang/Character.html#unicode">surrogate</a>, the surrogate
  65. * value is returned.
  66. *
  67. * @param index the index of the <code>char</code> value to be returned
  68. *
  69. * @return the specified <code>char</code> value
  70. *
  71. * @throws IndexOutOfBoundsException
  72. * if the <tt>index</tt> argument is negative or not less than
  73. * <tt>length()</tt>
  74. */
  75. @:overload public function charAt(index : Int) : java.StdTypes.Char16;
  76. /**
  77. * Returns a new <code>CharSequence</code> that is a subsequence of this sequence.
  78. * The subsequence starts with the <code>char</code> value at the specified index and
  79. * ends with the <code>char</code> value at index <tt>end - 1</tt>. The length
  80. * (in <code>char</code>s) of the
  81. * returned sequence is <tt>end - start</tt>, so if <tt>start == end</tt>
  82. * then an empty sequence is returned. </p>
  83. *
  84. * @param start the start index, inclusive
  85. * @param end the end index, exclusive
  86. *
  87. * @return the specified subsequence
  88. *
  89. * @throws IndexOutOfBoundsException
  90. * if <tt>start</tt> or <tt>end</tt> are negative,
  91. * if <tt>end</tt> is greater than <tt>length()</tt>,
  92. * or if <tt>start</tt> is greater than <tt>end</tt>
  93. */
  94. @:overload public function subSequence(start : Int, end : Int) : CharSequence;
  95. /**
  96. * Returns a string containing the characters in this sequence in the same
  97. * order as this sequence. The length of the string will be the length of
  98. * this sequence. </p>
  99. *
  100. * @return a string consisting of exactly this sequence of characters
  101. */
  102. @:overload public function toString() : String;
  103. }