< prev index next >

src/java.base/share/classes/sun/text/normalizer/Replaceable.java

Print this page




  54  *
  55  * <p><code>Replaceable</code> specifies ranges using a start
  56  * offset and a limit offset.  The range of characters thus specified
  57  * includes the characters at offset start..limit-1.  That is, the
  58  * start offset is inclusive, and the limit offset is exclusive.
  59  *
  60  * <p><code>Replaceable</code> also includes API to access characters
  61  * in the string: <code>length()</code>, <code>charAt()</code>,
  62  * <code>char32At()</code>, and <code>extractBetween()</code>.
  63  *
  64  * <p>For a subclass to support metadata, typical behavior of
  65  * <code>replace()</code> is the following:
  66  * <ul>
  67  *   <li>Set the metadata of the new text to the metadata of the first
  68  *   character replaced</li>
  69  *   <li>If no characters are replaced, use the metadata of the
  70  *   previous character</li>
  71  *   <li>If there is no previous character (i.e. start == 0), use the
  72  *   following character</li>
  73  *   <li>If there is no following character (i.e. the replaceable was
  74  *   empty), use default metadata<br>
  75  *   <li>If the code point U+FFFF is seen, it should be interpreted as
  76  *   a special marker having no metadata<li>
  77  *   </li>
  78  * </ul>
  79  * If this is not the behavior, the subclass should document any differences.
  80  *
  81  * <p>Copyright &copy; IBM Corporation 1999.  All rights reserved.
  82  *
  83  * @author Alan Liu
  84  * @stable ICU 2.0
  85  */
  86 public interface Replaceable {
  87     /**
  88      * Returns the number of 16-bit code units in the text.
  89      * @return number of 16-bit code units in text
  90      * @stable ICU 2.0
  91      */
  92     int length();
  93 
  94     /**
  95      * Returns the 16-bit code unit at the given offset into the text.
  96      * @param offset an integer between 0 and <code>length()</code>-1
  97      * inclusive
  98      * @return 16-bit code unit of text at given offset
  99      * @stable ICU 2.0
 100      */
 101     char charAt(int offset);
 102 
 103     //// for StringPrep
 104     /**
 105      * Copies characters from this object into the destination
 106      * character array.  The first character to be copied is at index
 107      * <code>srcStart</code>; the last character to be copied is at
 108      * index <code>srcLimit-1</code> (thus the total number of
 109      * characters to be copied is <code>srcLimit-srcStart</code>). The
 110      * characters are copied into the subarray of <code>dst</code>
 111      * starting at index <code>dstStart</code> and ending at index
 112      * <code>dstStart + (srcLimit-srcStart) - 1</code>.
 113      *
 114      * @param srcStart the beginning index to copy, inclusive; <code>0
 115      * <= start <= limit</code>.
 116      * @param srcLimit the ending index to copy, exclusive;
 117      * <code>start <= limit <= length()</code>.
 118      * @param dst the destination array.
 119      * @param dstStart the start offset in the destination array.
 120      * @stable ICU 2.0
 121      */
 122     void getChars(int srcStart, int srcLimit, char dst[], int dstStart);
 123 }


  54  *
  55  * <p><code>Replaceable</code> specifies ranges using a start
  56  * offset and a limit offset.  The range of characters thus specified
  57  * includes the characters at offset start..limit-1.  That is, the
  58  * start offset is inclusive, and the limit offset is exclusive.
  59  *
  60  * <p><code>Replaceable</code> also includes API to access characters
  61  * in the string: <code>length()</code>, <code>charAt()</code>,
  62  * <code>char32At()</code>, and <code>extractBetween()</code>.
  63  *
  64  * <p>For a subclass to support metadata, typical behavior of
  65  * <code>replace()</code> is the following:
  66  * <ul>
  67  *   <li>Set the metadata of the new text to the metadata of the first
  68  *   character replaced</li>
  69  *   <li>If no characters are replaced, use the metadata of the
  70  *   previous character</li>
  71  *   <li>If there is no previous character (i.e. start == 0), use the
  72  *   following character</li>
  73  *   <li>If there is no following character (i.e. the replaceable was
  74  *   empty), use default metadata</li>
  75  *   <li>If the code point U+FFFF is seen, it should be interpreted as
  76  *   a special marker having no metadata</li>

  77  * </ul>
  78  * If this is not the behavior, the subclass should document any differences.
  79  *
  80  * <p>Copyright &copy; IBM Corporation 1999.  All rights reserved.
  81  *
  82  * @author Alan Liu
  83  * @stable ICU 2.0
  84  */
  85 public interface Replaceable {
  86     /**
  87      * Returns the number of 16-bit code units in the text.
  88      * @return number of 16-bit code units in text
  89      * @stable ICU 2.0
  90      */
  91     int length();
  92 
  93     /**
  94      * Returns the 16-bit code unit at the given offset into the text.
  95      * @param offset an integer between 0 and <code>length()</code>-1
  96      * inclusive
  97      * @return 16-bit code unit of text at given offset
  98      * @stable ICU 2.0
  99      */
 100     char charAt(int offset);
 101 
 102     //// for StringPrep
 103     /**
 104      * Copies characters from this object into the destination
 105      * character array.  The first character to be copied is at index
 106      * <code>srcStart</code>; the last character to be copied is at
 107      * index <code>srcLimit-1</code> (thus the total number of
 108      * characters to be copied is <code>srcLimit-srcStart</code>). The
 109      * characters are copied into the subarray of <code>dst</code>
 110      * starting at index <code>dstStart</code> and ending at index
 111      * <code>dstStart + (srcLimit-srcStart) - 1</code>.
 112      *
 113      * @param srcStart the beginning index to copy, inclusive;
 114      *        {@code 0 <= start <= limit}.
 115      * @param srcLimit the ending index to copy, exclusive;
 116      *        {@code start <= limit <= length()}.
 117      * @param dst the destination array.
 118      * @param dstStart the start offset in the destination array.
 119      * @stable ICU 2.0
 120      */
 121     void getChars(int srcStart, int srcLimit, char dst[], int dstStart);
 122 }
< prev index next >