com.ibm.icu.text
Class ReplaceableString
- Replaceable
public class ReplaceableString
ReplaceableString
is an adapter class that implements the
Replaceable
API around an ordinary
StringBuffer
.
Note: This class does not support attributes and is not
intended for general use. Most clients will need to implement
Replaceable
in their text representation class.
Copyright © IBM Corporation 1999. All rights reserved.
int | char32At(int offset) - Return the 32-bit code point at the given 16-bit offset into
the text.
|
char | charAt(int offset) - Return the character at the given position in this object.
|
void | copy(int start, int limit, int dest) - Copy a substring of this object, retaining attribute (out-of-band)
information.
|
void | getChars(int srcStart, int srcLimit, dst[] , int dstStart) - Copies characters from this object into the destination
character array.
|
boolean | hasMetaData() - Implements Replaceable
|
int | length() - Return the number of characters contained in this object.
|
void | replace(int start, int limit, String text) - Replace zero or more characters with new characters.
|
void | replace(int start, int limit, char[] chars, int charsStart, int charsLen) - Replace a substring of this object with the given text.
|
String | substring(int start, int limit) - Return a substring of the given string.
|
String | toString() - Return the contents of this object as a
String .
|
ReplaceableString
public ReplaceableString()
Construct a new empty object.
ReplaceableString
public ReplaceableString(String str)
Construct a new object with the given initial contents.
ReplaceableString
public ReplaceableString(StringBuffer buf)
Construct a new object using buf
for internal
storage. The contents of buf
at the time of
construction are used as the initial contents. Note!
Modifications to buf
will modify this object, and
vice versa.
buf
- object to be used as internal storage
char32At
public int char32At(int offset)
Return the 32-bit code point at the given 16-bit offset into
the text. This assumes the text is stored as 16-bit code units
with surrogate pairs intermixed. If the offset of a leading or
trailing code unit of a surrogate pair is given, return the
code point of the surrogate pair.
- char32At in interface Replaceable
offset
- an integer between 0 and length()
-1
inclusive
- 32-bit code point of text at given offset
charAt
public char charAt(int offset)
Return the character at the given position in this object.
Replaceable
API.
- charAt in interface Replaceable
offset
- offset into the contents, from 0 to
length()
- 1
copy
public void copy(int start,
int limit,
int dest)
Copy a substring of this object, retaining attribute (out-of-band)
information. This method is used to duplicate or reorder substrings.
The destination index must not overlap the source range.
- copy in interface Replaceable
start
- the beginning index, inclusive; 0 <= start <=
limit
.limit
- the ending index, exclusive; start <= limit <=
length()
.dest
- the destination index. The characters from
start..limit-1
will be copied to dest
.
Implementations of this method may assume that dest <= start ||
dest >= limit
.
getChars
public void getChars(int srcStart,
int srcLimit,
dst[] ,
int dstStart)
Copies characters from this object into the destination
character array. The first character to be copied is at index
srcStart
; the last character to be copied is at
index srcLimit-1
(thus the total number of
characters to be copied is srcLimit-srcStart
). The
characters are copied into the subarray of dst
starting at index dstStart
and ending at index
dstStart + (srcLimit-srcStart) - 1
.
- getChars in interface Replaceable
srcStart
- the beginning index to copy, inclusive; 0
<= start <= limit
.srcLimit
- the ending index to copy, exclusive;
start <= limit <= length()
.dstStart
- the start offset in the destination array.
length
public int length()
Return the number of characters contained in this object.
Replaceable
API.
- length in interface Replaceable
replace
public void replace(int start,
int limit,
String text)
Replace zero or more characters with new characters.
Replaceable
API.
- replace in interface Replaceable
start
- the beginning index, inclusive; 0 <= start
<= limit
.limit
- the ending index, exclusive; start <= limit
<= length()
.text
- new text to replace characters start
to
limit - 1
replace
public void replace(int start,
int limit,
char[] chars,
int charsStart,
int charsLen)
Replace a substring of this object with the given text.
- replace in interface Replaceable
start
- the beginning index, inclusive; 0 <= start
<= limit
.limit
- the ending index, exclusive; start <= limit
<= length()
.chars
- the text to replace characters start
to limit - 1
charsStart
- the beginning index into chars
,
inclusive; 0 <= start <= limit
.charsLen
- the number of characters of chars
.
substring
public String substring(int start,
int limit)
Return a substring of the given string.
toString
public String toString()
Return the contents of this object as a String
.
- string contents of this object
Copyright (c) 2006 IBM Corporation and others.