001: /*
002: * Portions Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: /*
027: *******************************************************************************
028: * (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
029: * *
030: * The original version of this source code and documentation is copyrighted *
031: * and owned by IBM, These materials are provided under terms of a License *
032: * Agreement between IBM and Sun. This technology is protected by multiple *
033: * US and International patents. This notice and attribution to IBM may not *
034: * to removed. *
035: *******************************************************************************
036: */
037:
038: package sun.text.normalizer;
039:
040: /**
041: * <code>Replaceable</code> is an interface representing a
042: * string of characters that supports the replacement of a range of
043: * itself with a new string of characters. It is used by APIs that
044: * change a piece of text while retaining metadata. Metadata is data
045: * other than the Unicode characters returned by char32At(). One
046: * example of metadata is style attributes; another is an edit
047: * history, marking each character with an author and revision number.
048: *
049: * <p>An implicit aspect of the <code>Replaceable</code> API is that
050: * during a replace operation, new characters take on the metadata of
051: * the old characters. For example, if the string "the <b>bold</b>
052: * font" has range (4, 8) replaced with "strong", then it becomes "the
053: * <b>strong</b> font".
054: *
055: * <p><code>Replaceable</code> specifies ranges using a start
056: * offset and a limit offset. The range of characters thus specified
057: * includes the characters at offset start..limit-1. That is, the
058: * start offset is inclusive, and the limit offset is exclusive.
059: *
060: * <p><code>Replaceable</code> also includes API to access characters
061: * in the string: <code>length()</code>, <code>charAt()</code>,
062: * <code>char32At()</code>, and <code>extractBetween()</code>.
063: *
064: * <p>For a subclass to support metadata, typical behavior of
065: * <code>replace()</code> is the following:
066: * <ul>
067: * <li>Set the metadata of the new text to the metadata of the first
068: * character replaced</li>
069: * <li>If no characters are replaced, use the metadata of the
070: * previous character</li>
071: * <li>If there is no previous character (i.e. start == 0), use the
072: * following character</li>
073: * <li>If there is no following character (i.e. the replaceable was
074: * empty), use default metadata<br>
075: * <li>If the code point U+FFFF is seen, it should be interpreted as
076: * a special marker having no metadata<li>
077: * </li>
078: * </ul>
079: * If this is not the behavior, the subclass should document any differences.
080: *
081: * <p>Copyright © IBM Corporation 1999. All rights reserved.
082: *
083: * @author Alan Liu
084: * @stable ICU 2.0
085: */
086: public interface Replaceable {
087: /**
088: * Returns the number of 16-bit code units in the text.
089: * @return number of 16-bit code units in text
090: * @stable ICU 2.0
091: */
092: int length();
093:
094: /**
095: * Returns the 16-bit code unit at the given offset into the text.
096: * @param offset an integer between 0 and <code>length()</code>-1
097: * inclusive
098: * @return 16-bit code unit of text at given offset
099: * @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: }
|