|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
AnnotatedString
is an interface for annotating strings
and working on them. It merges the functionality of
java.text.AttributedCharacterIterator and
java.text.AttributedString.
An AnnotatedString
allows iteration through both text
and related annotation information. An annotation is a key/value
pair, identified by the key. No two annotations on a given character
can have the same key.
A run with respect to an annotation is a maximum text range for
which:
- the annotation is undefined or null for the entire range, or
- the annotation value is defined and has the same non-null value
for the entire range
Field Summary |
Fields inherited from interface java.text.CharacterIterator |
DONE |
Method Summary | |
void |
annotate(java.lang.String key,
java.lang.Object value,
int beginIndex,
int endIndex)
Adds an annotation to a subrange of the string. |
char |
charAt(int charIndex)
Returns the character from the specified position without changing the index. |
int |
findNextAnnotation(java.lang.String key)
Returns the index of the first character annotated with the given annotation key following the run containing the current character with respect to the given annotation key. |
java.lang.Object |
getAnnotation(java.lang.String key)
Returns the annotation value of the string at the current index for a given annotation key. |
int |
getRunLimit(java.lang.String key)
Returns the index of the first character following the run with respect to the given annotation key containing the current character. |
int |
getRunStart(java.lang.String key)
Returns the index of the first character of the run with respect to the given annotation key containing the current character. |
java.lang.String |
substring(int beginIndex,
int endIndex)
Returns the substring between the specified indices. |
java.lang.String |
toString()
Returns the surface string of the annotated string. |
java.lang.String |
toString(java.lang.String key)
Returns a string representation of the annotated string with the annotation for the given attribute key. |
Methods inherited from interface java.text.CharacterIterator |
clone, current, first, getBeginIndex, getEndIndex, getIndex, last, next, previous, setIndex |
Method Detail |
public int getRunStart(java.lang.String key)
key
- String
with an annotation key
int
with the indexpublic int getRunLimit(java.lang.String key)
key
- String
with an attribute key
int
with the indexpublic void annotate(java.lang.String key, java.lang.Object value, int beginIndex, int endIndex)
key
- a String
with the annotation keyvalue
- a Object
with the annotation valuebeginIndex
- an int
with the index of the first
character of the rangeendIndex
- an int
with the index of the
character following the last character of the range
java.lang.IllegalArgumentException
- if beginIndex is less then 0,
endIndex is greater than the length of the string, or beginIndex
and endIndex together don't define a non-empty subrange of the
stringpublic java.lang.Object getAnnotation(java.lang.String key)
key
- a String
with the annotation key
Object
with the annotation value or
null
if there is no annotation with the given key at
that positionpublic int findNextAnnotation(java.lang.String key)
key
- a String
with the annotation key
int
with the indexpublic java.lang.String substring(int beginIndex, int endIndex)
beginIndex
- an int
with the index of the first
character of the rangeendIndex
- an int
with the index of the
character following the last character of the range
String
with the substring
java.lang.IllegalArgumentException
- if beginIndex is less then 0,
endIndex is greater than the length of the string, or beginIndex
and endIndex together don't define a non-empty subrange of the
stringpublic char charAt(int charIndex)
charIndex
- the index within the text; valid values range from
getBeginIndex() to getEndIndex(); an IllegalArgumentException is thrown
if an invalid value is supplied
public java.lang.String toString(java.lang.String key)
key
- String
with an attribute key
String
public java.lang.String toString()
String
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |