|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.richtext.styledtext.MConstText
MConstText is a base class for text with multiple character and
paragraph styles. The text is a sequence of Unicode characters,
represented by char
. Character and paragraph
styles are represented by the AttributeMap
class.
Characters in the text are accessed with an integer index using the
at
method.
Valid indices are between 0 and (length-1), where length is the number
of characters in the text. Additionally, the
characters in the text may be accessed through a
java.text.CharacterIterator
.
Every character in the text has a character style associated with it,
represented by the AttributeMap
class. The character
style for a particular character can be obtained using the
characterStyleAt
method.
Each character in the text is contained in a paragraph. A paragraph
is a range of text including and terminated by a
paragraph separator (either \n
or U+2029
).
Every
paragraph has a paragraph style associated with it, represented
by the AttributeMap
class. Paragraph boundaries and
styles can be obtained from the MConstText.
This class does not have methods for modifying the text or styles. However, subclasses may add this capability, so it is not safe to assume that an MConstText instance is immutable. In particular, the MText class adds modification protocol to this class. Clients can detect whether an MConstText has changed by keeping track of its timestamp.
A DataFlavor for clipboard content is defined in this class. Using this DataFlavor insures that all clients will recognize MConstText content on the clipboard.
MText
,
AttributeMap
,
CharacterIterator
,
DataFlavor
Field Summary | |
static java.awt.datatransfer.DataFlavor |
styledTextFlavor
The DataFlavor for MConstText clipboard content. |
Constructor Summary | |
protected |
MConstText()
|
Method Summary | |
abstract char |
at(int pos)
Return the character at offset pos . |
abstract AttributeMap |
characterStyleAt(int pos)
Return the style applied to the character at offset pos . |
abstract int |
characterStyleLimit(int pos)
Return the index after the last character in the character style run containing pos. |
abstract int |
characterStyleStart(int pos)
Return the index of the first character in the character style run containing pos. |
java.text.CharacterIterator |
createCharacterIterator()
Create a java.text.CharacterIterator over all
of the characters in the text. |
abstract java.text.CharacterIterator |
createCharacterIterator(int start,
int limit)
Create a java.text.CharacterIterator over the
given range of characters in the text. |
abstract int |
damagedRangeLimit()
Return the limit of the damaged range. |
abstract int |
damagedRangeStart()
Return the start of the damaged range. |
boolean |
equals(MConstText rhs)
Compare this to another MConstText for equality. |
boolean |
equals(java.lang.Object rhs)
Compare this to another Object for equality. |
abstract MConstText |
extract(int start,
int limit)
Create an MConstText containing the characters and styles in the range [ start , limit ). |
abstract 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 . |
abstract int |
getTimeStamp()
Return the current time stamp. |
int |
hashCode()
Return the hashCode for this MConstText. |
abstract int |
length()
Return the length of the MConstText object. |
abstract int |
paragraphLimit(int pos)
Return the limit of the paragraph containing the character at offset pos . |
abstract int |
paragraphStart(int pos)
Return the start of the paragraph containing the character at offset pos . |
abstract AttributeMap |
paragraphStyleAt(int pos)
Return the paragraph style applied to the paragraph containing offset pos . |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.awt.datatransfer.DataFlavor styledTextFlavor
Constructor Detail |
protected MConstText()
Method Detail |
public abstract char at(int pos)
pos
.pos
- a valid offset into the textpos
public abstract void extractChars(int start, int limit, char[] dst, int dstStart)
start
, limit
)
into the array dst
, beginning at dstStart
.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 abstract MConstText extract(int start, int limit)
start
, limit
).start
- offset of first character in the new textlimit
- offset immediately after the last character in the new textpublic java.text.CharacterIterator createCharacterIterator()
java.text.CharacterIterator
over all
of the characters in the text. Default implementation calls
createCharacterIterator(0, length())
java.text.CharacterIterator
over all
of the characters in the textpublic abstract java.text.CharacterIterator createCharacterIterator(int start, int limit)
java.text.CharacterIterator
over the
given range of characters in the text.start
- the first index in the iteration rangelimit
- the index after the last character in the iteration rangejava.text.CharacterIterator
over the
given rangepublic abstract int length()
public abstract int characterStyleStart(int pos)
pos
public abstract int characterStyleLimit(int pos)
pos
public abstract AttributeMap characterStyleAt(int pos)
pos
.pos
- a valid offset into the textpos
public abstract int paragraphStart(int pos)
pos
.pos
- a valid offset into the textpos
public abstract int paragraphLimit(int pos)
pos
.pos
- a valid offset into the textpos
public abstract AttributeMap paragraphStyleAt(int pos)
pos
.pos
- a valid offset into the textpos
public abstract int getTimeStamp()
public abstract int damagedRangeStart()
damagedRangeLimit()
,
MText.resetDamagedRange()
public abstract int damagedRangeLimit()
damagedRangeStart()
,
MText.resetDamagedRange()
public final boolean equals(java.lang.Object rhs)
equals
in class java.lang.Object
rhs
- Object to compare torhs
public boolean equals(MConstText rhs)
rhs
- Object to compare torhs
public final int hashCode()
whereat(0) + at(length/2)*31^1 + at(length-1)*31^2 + characterStyleAt(0).hashCode()*31^3 + paragraphStyleAt(length-1).hashCode()*31^4
^
is exponentiation (not bitwise XOR).hashCode
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |