1 7 package com.ibm.icu.text; 8 9 import com.ibm.icu.impl.Utility; 10 11 25 public class ReplaceableString implements Replaceable { 26 private StringBuffer buf; 27 28 private static final String COPYRIGHT = 29 "\u00A9 IBM Corporation 1999. All rights reserved."; 30 31 36 public ReplaceableString(String str) { 37 buf = new StringBuffer (str); 38 } 39 40 49 public ReplaceableString(StringBuffer buf) { 50 this.buf = buf; 51 } 52 53 57 public ReplaceableString() { 58 buf = new StringBuffer (); 59 } 60 61 66 public String toString() { 67 return buf.toString(); 68 } 69 70 74 public String substring(int start, int limit) { 75 return buf.substring(start, limit); 76 } 77 78 83 public int length() { 84 return buf.length(); 85 } 86 87 94 public char charAt(int offset) { 95 return buf.charAt(offset); 96 } 97 98 109 public int char32At(int offset) { 110 return UTF16.charAt(buf, offset); 111 } 112 113 131 public void getChars(int srcStart, int srcLimit, char dst[], int dstStart) { 132 Utility.getChars(buf, srcStart, srcLimit, dst, dstStart); 133 } 134 135 146 public void replace(int start, int limit, String text) { 147 buf.replace(start, limit, text); 148 } 149 150 163 public void replace(int start, int limit, char[] chars, 164 int charsStart, int charsLen) { 165 buf.delete(start, limit); 166 buf.insert(start, chars, charsStart, charsLen); 167 } 168 169 184 public void copy(int start, int limit, int dest) { 185 if (start == limit && start >= 0 && start <= buf.length()) { 186 return; 187 } 188 char[] text = new char[limit - start]; 189 getChars(start, limit, text, 0); 190 replace(dest, dest, text, 0, limit - start); 191 } 192 193 197 public boolean hasMetaData() { 198 return false; 199 } 200 } 201 | Popular Tags |