|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.dfki.lt.tools.tokenizer.annotate.FastAnnotatedString
FastAnnotatedString
is a fast implementation of
the AnnotatedString
interface. It reserves an array of
objects and an array of booleans for each newly introduced
annotation key. This provides fast access at the cost of memory. So
only introduce new annotation keys if neccessary.
Field Summary |
Fields inherited from interface java.text.CharacterIterator |
DONE |
Constructor Summary | |
FastAnnotatedString(java.lang.String anInputText)
This create a new instance of FastAnnotatedString
for a text in inputString . |
Method Summary | |
void |
annotate(java.lang.String key,
java.lang.Object value,
int aBeginIndex,
int anEndIndex)
Adds an annotation to a subrange of the string. |
char |
charAt(int charIndex)
This returns the character from the specified position without changing the index. |
java.lang.Object |
clone()
This create a copy of this object. |
char |
current()
This gets the character at the current position (as returned by getIndex()). |
int |
findNextAnnotation(java.lang.String key)
This 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. |
char |
first()
This sets the position to getBeginIndex() and returns the character at that position. |
java.lang.Object |
getAnnotation(java.lang.String key)
This returns the annotation value of the string at the current index for a given key. |
int |
getBeginIndex()
This returns the start index of the text. |
int |
getEndIndex()
This returns the end index of the text. |
int |
getIndex()
This returns the current index. |
int |
getRunLimit(java.lang.String key)
This 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)
This returns the index of the first character of the run with respect to the given annotation key containing the current character. |
char |
last()
This sets the position to getEndIndex()-1 (getEndIndex() if the text is empty) and returns the character at that position |
char |
next()
This increments the index by one and returns the character at the new index. |
char |
previous()
This decrements the index by one and returns the character at the new index. |
char |
setIndex(int anIndex)
This sets the position to the specified position in the text and returns that character. |
java.lang.String |
substring(int aBeginIndex,
int anEndIndex)
This returns the substring between the specified indices. |
java.lang.String |
toString()
This returns the surface string of the annotated string. |
java.lang.String |
toString(java.lang.String key)
This returns a string representation of the annotated string with the annotation for the given attribute key. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public FastAnnotatedString(java.lang.String anInputText)
FastAnnotatedString
for a text in inputString
.
anInputText
- a String
with the text to
annotateMethod Detail |
public char first()
first
in interface java.text.CharacterIterator
public char last()
last
in interface java.text.CharacterIterator
public char current()
current
in interface java.text.CharacterIterator
public char next()
next
in interface java.text.CharacterIterator
public char previous()
previous
in interface java.text.CharacterIterator
public int getBeginIndex()
getBeginIndex
in interface java.text.CharacterIterator
public int getEndIndex()
getEndIndex
in interface java.text.CharacterIterator
public int getIndex()
getIndex
in interface java.text.CharacterIterator
public char setIndex(int anIndex)
setIndex
in interface java.text.CharacterIterator
anIndex
- 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.Object clone()
clone
in interface java.text.CharacterIterator
public char charAt(int charIndex)
charAt
in interface AnnotatedString
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 substring(int aBeginIndex, int anEndIndex)
substring
in interface AnnotatedString
aBeginIndex
- an int
with the index of the first
character of the rangeanEndIndex
- an int
with the index of the
character following the last character of the range
String
with the substring
java.lang.IllegalArgumentException
- if aBeginIndex is less then 0,
anEndIndex is greater than the length of the string, or aBeginIndex
and anEndIndex together don't define a non-empty subrange of the
stringpublic void annotate(java.lang.String key, java.lang.Object value, int aBeginIndex, int anEndIndex)
annotate
in interface AnnotatedString
key
- a String
with the annotation keyvalue
- a Object
with the annotation valueaBeginIndex
- an int
with the index of the first
character of the rangeanEndIndex
- an int
with the index of the
character following the last character of the range
java.lang.IllegalArgumentException
- if aBeginIndex is less then 0,
anEndIndex is greater than the length of the string, or aBeginIndex
and anEndIndex together don't define a non-empty subrange of the
stringpublic java.lang.Object getAnnotation(java.lang.String key)
getAnnotation
in interface AnnotatedString
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 getRunStart(java.lang.String key)
getRunStart
in interface AnnotatedString
key
- String
with an annotation key
int
with the indexpublic int getRunLimit(java.lang.String key)
getRunLimit
in interface AnnotatedString
key
- String
with an attribute key
int
with the indexpublic int findNextAnnotation(java.lang.String key)
findNextAnnotation
in interface AnnotatedString
key
- a String
with the annotation key
int
with the indexpublic java.lang.String toString(java.lang.String key)
toString
in interface AnnotatedString
key
- String
with an attribute key
String
public java.lang.String toString()
toString
in interface AnnotatedString
String
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |