Showing the changes to java/pkg/sun/text/normalizer/Replaceable.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,123 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. | ||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| 4 | * | ||
| 5 | * This code is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms of the GNU General Public License version 2 only, as | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 10 | * | ||
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 14 | * version 2 for more details (a copy is included in the LICENSE file that | ||
| 15 | * accompanied this code). | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License version | ||
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, | ||
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | * | ||
| 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * questions. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | ******************************************************************************* | ||
| 28 | * (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved * | ||
| 29 | * * | ||
| 30 | * The original version of this source code and documentation is copyrighted * | ||
| 31 | * and owned by IBM, These materials are provided under terms of a License * | ||
| 32 | * Agreement between IBM and Sun. This technology is protected by multiple * | ||
| 33 | * US and International patents. This notice and attribution to IBM may not * | ||
| 34 | * to removed. * | ||
| 35 | ******************************************************************************* | ||
| 36 | */ | ||
| 37 | |||
| 38 | package sun.text.normalizer; | ||
| 39 | |||
| 40 | /** | ||
| 41 | * <code>Replaceable</code> is an interface representing a | ||
| 42 | * string of characters that supports the replacement of a range of | ||
| 43 | * itself with a new string of characters. It is used by APIs that | ||
| 44 | * change a piece of text while retaining metadata. Metadata is data | ||
| 45 | * other than the Unicode characters returned by char32At(). One | ||
| 46 | * example of metadata is style attributes; another is an edit | ||
| 47 | * history, marking each character with an author and revision number. | ||
| 48 | * | ||
| 49 | * <p>An implicit aspect of the <code>Replaceable</code> API is that | ||
| 50 | * during a replace operation, new characters take on the metadata of | ||
| 51 | * the old characters. For example, if the string "the <b>bold</b> | ||
| 52 | * font" has range (4, 8) replaced with "strong", then it becomes "the | ||
| 53 | * <b>strong</b> font". | ||
| 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 © 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 | } | ||