Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/text/normalizer/ReplaceableString.java
38830 views
/*1* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425/*26*******************************************************************************27* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *28* *29* The original version of this source code and documentation is copyrighted *30* and owned by IBM, These materials are provided under terms of a License *31* Agreement between IBM and Sun. This technology is protected by multiple *32* US and International patents. This notice and attribution to IBM may not *33* to removed. *34*******************************************************************************35*/3637package sun.text.normalizer;3839/**40* <code>ReplaceableString</code> is an adapter class that implements the41* <code>Replaceable</code> API around an ordinary <code>StringBuffer</code>.42*43* <p><em>Note:</em> This class does not support attributes and is not44* intended for general use. Most clients will need to implement45* {@link Replaceable} in their text representation class.46*47* <p>Copyright © IBM Corporation 1999. All rights reserved.48*49* @see Replaceable50* @author Alan Liu51* @stable ICU 2.052*/53public class ReplaceableString implements Replaceable {5455private StringBuffer buf;5657/**58* Construct a new object with the given initial contents.59* @param str initial contents60* @stable ICU 2.061*/62public ReplaceableString(String str) {63buf = new StringBuffer(str);64}6566//// for StringPrep67/**68* Construct a new object using <code>buf</code> for internal69* storage. The contents of <code>buf</code> at the time of70* construction are used as the initial contents. <em>Note!71* Modifications to <code>buf</code> will modify this object, and72* vice versa.</em>73* @param buf object to be used as internal storage74* @stable ICU 2.075*/76public ReplaceableString(StringBuffer buf) {77this.buf = buf;78}7980/**81* Return the number of characters contained in this object.82* <code>Replaceable</code> API.83* @stable ICU 2.084*/85public int length() {86return buf.length();87}8889/**90* Return the character at the given position in this object.91* <code>Replaceable</code> API.92* @param offset offset into the contents, from 0 to93* <code>length()</code> - 194* @stable ICU 2.095*/96public char charAt(int offset) {97return buf.charAt(offset);98}99100//// for StringPrep101/**102* Copies characters from this object into the destination103* character array. The first character to be copied is at index104* <code>srcStart</code>; the last character to be copied is at105* index <code>srcLimit-1</code> (thus the total number of106* characters to be copied is <code>srcLimit-srcStart</code>). The107* characters are copied into the subarray of <code>dst</code>108* starting at index <code>dstStart</code> and ending at index109* <code>dstStart + (srcLimit-srcStart) - 1</code>.110*111* @param srcStart the beginning index to copy, inclusive; <code>0112* <= start <= limit</code>.113* @param srcLimit the ending index to copy, exclusive;114* <code>start <= limit <= length()</code>.115* @param dst the destination array.116* @param dstStart the start offset in the destination array.117* @stable ICU 2.0118*/119public void getChars(int srcStart, int srcLimit, char dst[], int dstStart) {120Utility.getChars(buf, srcStart, srcLimit, dst, dstStart);121}122}123124125