|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.richtext.styledtext.MConstText | +--com.ibm.richtext.styledtext.MText | +--com.ibm.richtext.styledtext.StyledText
This class is an implementation of MText, a modifyable, styled text storage model. Additionally, it supports persistance through the Externalizable interface.
MText
, Serialized FormFields inherited from class com.ibm.richtext.styledtext.MConstText |
styledTextFlavor |
Constructor Summary | |
StyledText()
Create an empty text object. |
|
StyledText(int capacity)
Create an empty text object ready to hold at least capacity chars. |
|
StyledText(MConstText source)
Create a text object from the given source. |
|
StyledText(MConstText source,
int srcStart,
int srcLimit)
Create a text object from a subrange of the given source. |
|
StyledText(java.lang.String string,
AttributeMap initialStyle)
Create a text object with the characters in the string, in the given style. |
Method Summary | |
void |
append(MConstText srcText)
Append the contents of srcText (both characters and styles) to the
end of this MText. |
char |
at(int pos)
Return the character at offset pos . |
AttributeMap |
characterStyleAt(int pos)
Return the style applied to the character at offset pos . |
int |
characterStyleLimit(int pos)
Return the index after the last character in the character style run containing pos. |
int |
characterStyleStart(int pos)
Return the index of the first character in the character style run containing pos. |
void |
compress()
Minimize the amount of memory used by the MText object. |
java.text.CharacterIterator |
createCharacterIterator(int start,
int limit)
Create a CharacterIterator over the range [start , limit ). |
int |
damagedRangeLimit()
Return the limit of the damaged range. |
int |
damagedRangeStart()
Return the start of the damaged range. |
MConstText |
extract(int start,
int limit)
Create an MConstText containing the characters and styles in the range [ start , limit ). |
void |
extractChars(int start,
int limit,
char[] dst,
int dstStart)
Copy the characters in the range [ start , limit )
into the array dst , beginning at dstStart . |
MText |
extractWritable(int start,
int limit)
Create an MText containing the characters and styles in the range [ start , limit ). |
int |
getTimeStamp()
Return the current time stamp. |
void |
insert(int pos,
MConstText srcText)
Insert the contents of srcText (both characters and styles) into this
MText at the position specified by pos . |
int |
length()
Return the length of the MConstText object. |
void |
modifyCharacterStyles(int start,
int limit,
StyleModifier modifier)
Invoke the given modifier on all character styles from start to limit. |
void |
modifyParagraphStyles(int start,
int limit,
StyleModifier modifier)
Invoke the given modifier on all paragraph styles in paragraphs containing characters in the range [start, limit). |
int |
paragraphLimit(int pos)
Return the limit of the paragraph containing the character at offset pos . |
int |
paragraphStart(int pos)
Return the start of the paragraph containing the character at offset pos . |
AttributeMap |
paragraphStyleAt(int pos)
Return the paragraph style applied to the paragraph containing offset pos . |
void |
readExternal(java.io.ObjectInput in)
|
void |
remove()
Delete all characters and styles. |
void |
remove(int start,
int limit)
Delete the specified range of characters (and styles). |
void |
removeCharacterStyles()
Set the style of all characters in the MText object to AttributeMap.EMPTY_ATTRIBUTE_MAP . |
void |
replace(int start,
int limit,
char[] srcChars,
int srcStart,
int srcLimit,
AttributeMap charsStyle)
Replace the characters in the range [ start , limit ) with the characters
in srcChars in the range [srcStart , srcLimit ). |
void |
replace(int start,
int limit,
char srcChar,
AttributeMap charStyle)
Replace the characters in the range [ start , limit ) with the character srcChar . |
void |
replace(int start,
int limit,
MConstText text)
Replace the characters and styles in the range [ start , limit ) with the characters
and styles in srcText . |
void |
replace(int start,
int limit,
MConstText text,
int srcStart,
int srcLimit)
Replace the characters and styles in the range [ start , limit ) with the characters
and styles in srcText in the range [srcStart , srcLimit ). |
void |
replaceAll(MConstText srcText)
Replace the entire contents of this MText (both characters and styles) with the contents of srcText . |
void |
resetDamagedRange()
Reset the damaged range to an empty interval, and begin accumulating the damaged range. |
java.lang.String |
toString()
|
void |
writeExternal(java.io.ObjectOutput out)
|
Methods inherited from class com.ibm.richtext.styledtext.MConstText |
createCharacterIterator, equals, equals, hashCode |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public StyledText()
public StyledText(int capacity)
capacity
- the minimum capacity of the internal text bufferpublic StyledText(java.lang.String string, AttributeMap initialStyle)
string
- the initial contentsinitialStyle
- the style of the initial textpublic StyledText(MConstText source)
source
- the text to copypublic StyledText(MConstText source, int srcStart, int srcLimit)
source
- the text to copy fromsrcStart
- the index of the first character to copysrcLimit
- the index after the last character to copyMethod Detail |
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
public char at(int pos)
pos
.at
in class MConstText
pos
- a valid offset into the textpos
public void extractChars(int start, int limit, char[] dst, int dstStart)
start
, limit
)
into the array dst
, beginning at dstStart
.extractChars
in class MConstText
start
- offset of first character which will be copied into the arraylimit
- offset immediately after the last character which will be copied into the arraydst
- array in which to copy characters. The length of dst
must be at least
(dstStart + limit - start
).public MConstText extract(int start, int limit)
start
, limit
).extract
in class MConstText
start
- offset of first character in the new textlimit
- offset immediately after the last character in the new textpublic MText extractWritable(int start, int limit)
start
, limit
).extractWritable
in class MText
start
- offset of first character in the new textlimit
- offset immediately after the last character in the new textpublic int length()
length
in class MConstText
public java.text.CharacterIterator createCharacterIterator(int start, int limit)
CharacterIterator
over the range [start
, limit
).createCharacterIterator
in class MConstText
start
- the beginning of the iterator's rangelimit
- the limit of the iterator's rangeCharacterIterator
over the specified rangeCharacterIterator
public int characterStyleStart(int pos)
characterStyleStart
in class MConstText
pos
public int characterStyleLimit(int pos)
characterStyleLimit
in class MConstText
pos
public AttributeMap characterStyleAt(int pos)
pos
.characterStyleAt
in class MConstText
pos
- a valid offset into the textpos
public int paragraphStart(int pos)
pos
.paragraphStart
in class MConstText
pos
- a valid offset into the textpos
public int paragraphLimit(int pos)
pos
.paragraphLimit
in class MConstText
pos
- a valid offset into the textpos
public AttributeMap paragraphStyleAt(int pos)
pos
.paragraphStyleAt
in class MConstText
pos
- a valid offset into the textpos
public int getTimeStamp()
getTimeStamp
in class MConstText
public void replace(int start, int limit, MConstText text, int srcStart, int srcLimit)
start
, limit
) with the characters
and styles in srcText
in the range [srcStart
, srcLimit
). srcText
is not
modified.replace
in class MText
start
- the offset at which the replace operation beginslimit
- the offset at which the replace operation ends. The character and style at
limit
is not modified.srcText
- the source for the new characters and stylessrcStart
- the offset into srcText
where new characters and styles will be obtainedsrcLimit
- the offset into srcText
where the new characters and styles endpublic void replace(int start, int limit, MConstText text)
start
, limit
) with the characters
and styles in srcText
. srcText
is not
modified.replace
in class MText
start
- the offset at which the replace operation beginslimit
- the offset at which the replace operation ends. The character and style at
limit
is not modified.srcText
- the source for the new characters and stylespublic void replace(int start, int limit, char[] srcChars, int srcStart, int srcLimit, AttributeMap charsStyle)
start
, limit
) with the characters
in srcChars
in the range [srcStart
, srcLimit
). New characters take on the style
charsStyle
.
srcChars
is not modified.replace
in class MText
start
- the offset at which the replace operation beginslimit
- the offset at which the replace operation ends. The character at
limit
is not modified.srcChars
- the source for the new characterssrcStart
- the offset into srcChars
where new characters will be obtainedsrcLimit
- the offset into srcChars
where the new characters endcharsStyle
- the style of the new characterspublic void replace(int start, int limit, char srcChar, AttributeMap charStyle)
start
, limit
) with the character srcChar
.
The new character takes on the style charStyle
replace
in class MText
start
- the offset at which the replace operation beginslimit
- the offset at which the replace operation ends. The character at
limit
is not modified.srcChar
- the new charactercharsStyle
- the style of the new characterpublic void replaceAll(MConstText srcText)
srcText
.replaceAll
in class MText
srcText
- the source for the new characters and stylespublic void insert(int pos, MConstText srcText)
srcText
(both characters and styles) into this
MText at the position specified by pos
.insert
in class MText
pos
- The character offset where the new text is to be inserted.srcText
- The text to insert.public void append(MConstText srcText)
srcText
(both characters and styles) to the
end of this MText.append
in class MText
srcText
- The text to append.public void remove(int start, int limit)
remove
in class MText
start
- Offset of the first character to delete.limit
- Offset of the first character after the range to delete.public void remove()
remove
in class MText
public void compress()
compress
in class MText
public void removeCharacterStyles()
AttributeMap.EMPTY_ATTRIBUTE_MAP
.removeCharacterStyles
in class MText
public void modifyCharacterStyles(int start, int limit, StyleModifier modifier)
modifyCharacterStyles
in class MText
modifier
- the modifier to apply to the range.start
- the start of the range of text to modify.limit
- the limit of the range of text to modify.public void modifyParagraphStyles(int start, int limit, StyleModifier modifier)
modifyParagraphStyles
in class MText
modifier
- the modifier to apply to the range.start
- the start of the range of text to modify.limit
- the limit of the range of text to modify.public void resetDamagedRange()
resetDamagedRange
in class MText
damagedRangeStart()
,
damagedRangeLimit()
public int damagedRangeStart()
Integer.MAX_VALUE
and the limit is
Integer.MIN_VALUE
, then the damaged range
is empty.damagedRangeStart
in class MConstText
damagedRangeLimit()
,
resetDamagedRange()
public int damagedRangeLimit()
Integer.MAX_VALUE
and the limit is
Integer.MIN_VALUE
, then the damaged range
is empty.damagedRangeLimit
in class MConstText
damagedRangeStart()
,
resetDamagedRange()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |