Top Description Fields Constructors Methods
com.ibm.icu.text

public Class ReplaceableString

extends Object
implements Replaceable
Class Inheritance
All Implemented Interfaces
com.ibm.icu.text.Replaceable

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.

Author
Alan Liu
ICU Status
Stable since ICU 2.0.
See Also
Replaceable

Field Summary

Modifier and TypeField and Description
private StringBuffer

Constructor Summary

AccessConstructor and Description
public
ReplaceableString(String
initial contents
str
)

Construct a new object with the given initial contents.

public
ReplaceableString(StringBuffer
object to be used as internal storage
buf
)

Construct a new object using buf for internal storage.

public
ReplaceableString()

Construct a new empty object.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

32-bit code point of text at given offset
char32At
(int
an integer between 0 and length()-1 inclusive
offset
)

Implements com.ibm.icu.text.Replaceable.char32At.

Return the 32-bit code point at the given 16-bit offset into the text.
public char
charAt(int
offset into the contents, from 0 to length() - 1
offset
)

Implements com.ibm.icu.text.Replaceable.charAt.

Return the character at the given position in this object.
public void
copy(int
the beginning index, inclusive; 0 <= start <= limit.
start
,
int
the ending index, exclusive; start <= limit <= length().
limit
,
int
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.
dest
)

Implements com.ibm.icu.text.Replaceable.copy.

Copy a substring of this object, retaining attribute (out-of-band) information.
public void
getChars(int
the beginning index to copy, inclusive; 0 <= start <= limit.
srcStart
,
int
the ending index to copy, exclusive; start <= limit <= length().
srcLimit
,
char[]
the destination array.
dst
,
int
the start offset in the destination array.
dstStart
)

Implements com.ibm.icu.text.Replaceable.getChars.

Copies characters from this object into the destination character array.
public boolean
hasMetaData()

Implements com.ibm.icu.text.Replaceable.hasMetaData.

Implements Replaceable
public int
length()

Implements com.ibm.icu.text.Replaceable.length.

Return the number of characters contained in this object.
public void
replace(int
the beginning index, inclusive; 0 <= start <= limit.
start
,
int
the ending index, exclusive; start <= limit <= length().
limit
,
String
new text to replace characters start to limit - 1
text
)

Implements com.ibm.icu.text.Replaceable.replace.

Replace zero or more characters with new characters.
public void
replace(int
the beginning index, inclusive; 0 <= start <= limit.
start
,
int
the ending index, exclusive; start <= limit <= length().
limit
,
char[]
the text to replace characters start to limit - 1
chars
,
int
the beginning index into chars, inclusive; 0 <= start <= limit.
charsStart
,
int
the number of characters of chars.
charsLen
)

Implements com.ibm.icu.text.Replaceable.replace.

Replace a substring of this object with the given text.
public String
substring(int start, int limit)

Return a substring of the given string.

public String

Returns:

string contents of this object
toString
()

Overrides java.lang.Object.toString.

Return the contents of this object as a String.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bufback to summary
private StringBuffer buf

Constructor Detail

ReplaceableStringback to summary
public ReplaceableString(String str)

Construct a new object with the given initial contents.

Parameters
str:String

initial contents

ICU Status
Stable since ICU 2.0.
ReplaceableStringback to summary
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.

Parameters
buf:StringBuffer

object to be used as internal storage

ICU Status
Stable since ICU 2.0.
ReplaceableStringback to summary
public ReplaceableString()

Construct a new empty object.

ICU Status
Stable since ICU 2.0.

Method Detail

char32Atback to summary
public int char32At(int offset)

Implements com.ibm.icu.text.Replaceable.char32At.

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.

Parameters
offset:int

an integer between 0 and length()-1 inclusive

Returns:int

32-bit code point of text at given offset

Annotations
@Override
ICU Status
Stable since ICU 2.0.
charAtback to summary
public char charAt(int offset)

Implements com.ibm.icu.text.Replaceable.charAt.

Return the character at the given position in this object. Replaceable API.

Parameters
offset:int

offset into the contents, from 0 to length() - 1

Returns:char

Doc from com.ibm.icu.text.Replaceable.charAt.

16-bit code unit of text at given offset

Annotations
@Override
ICU Status
Stable since ICU 2.0.
copyback to summary
public void copy(int start, int limit, int dest)

Implements com.ibm.icu.text.Replaceable.copy.

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.

Parameters
start:int

the beginning index, inclusive; 0 <= start <= limit.

limit:int

the ending index, exclusive; start <= limit <= length().

dest:int

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.

Annotations
@Override
ICU Status
Stable since ICU 2.0.
getCharsback to summary
public void getChars(int srcStart, int srcLimit, char[] dst, int dstStart)

Implements com.ibm.icu.text.Replaceable.getChars.

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.

Parameters
srcStart:int

the beginning index to copy, inclusive; 0 <= start <= limit.

srcLimit:int

the ending index to copy, exclusive; start <= limit <= length().

dst:char[]

the destination array.

dstStart:int

the start offset in the destination array.

Annotations
@Override
ICU Status
Stable since ICU 2.0.
hasMetaDataback to summary
public boolean hasMetaData()

Implements com.ibm.icu.text.Replaceable.hasMetaData.

Implements Replaceable

Returns:boolean

Doc from com.ibm.icu.text.Replaceable.hasMetaData.

true if this object contains metadata

Annotations
@Override
ICU Status
Stable since ICU 2.0.
lengthback to summary
public int length()

Implements com.ibm.icu.text.Replaceable.length.

Return the number of characters contained in this object. Replaceable API.

Returns:int

Doc from com.ibm.icu.text.Replaceable.length.

number of 16-bit code units in text

Annotations
@Override
ICU Status
Stable since ICU 2.0.
replaceback to summary
public void replace(int start, int limit, String text)

Implements com.ibm.icu.text.Replaceable.replace.

Replace zero or more characters with new characters. Replaceable API.

Parameters
start:int

the beginning index, inclusive; 0 <= start <= limit.

limit:int

the ending index, exclusive; start <= limit <= length().

text:String

new text to replace characters start to limit - 1

Annotations
@Override
ICU Status
Stable since ICU 2.0.
replaceback to summary
public void replace(int start, int limit, char[] chars, int charsStart, int charsLen)

Implements com.ibm.icu.text.Replaceable.replace.

Replace a substring of this object with the given text.

Parameters
start:int

the beginning index, inclusive; 0 <= start <= limit.

limit:int

the ending index, exclusive; start <= limit <= length().

chars:char[]

the text to replace characters start to limit - 1

charsStart:int

the beginning index into chars, inclusive; 0 <= start <= limit.

charsLen:int

the number of characters of chars.

Annotations
@Override
ICU Status
Stable since ICU 2.0.
substringback to summary
public String substring(int start, int limit)

Return a substring of the given string.

ICU Status
Stable since ICU 2.0.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return the contents of this object as a String.

Returns:String

string contents of this object

Annotations
@Override
ICU Status
Stable since ICU 2.0.