Annotation
Stay organized with collections
Save and categorize content based on your preferences.
An Annotation object is used as a wrapper for a text attribute value if
the attribute has annotation characteristics. These characteristics are:
- The text range that the attribute is applied to is critical to the
semantics of the range. That means, the attribute cannot be applied to subranges
of the text range that it applies to, and, if two adjacent text ranges have
the same value for this attribute, the attribute still cannot be applied to
the combined range as a whole with this value.
- The attribute or its value usually do no longer apply if the underlying text is
changed.
An example is grammatical information attached to a sentence:
For the previous sentence, you can say that "an example"
is the subject, but you cannot say the same about "an", "example", or "exam".
When the text is changed, the grammatical information typically becomes invalid.
Another example is Japanese reading information (yomi).
Wrapping the attribute value into an Annotation object guarantees that
adjacent text runs don't get merged even if the attribute values are equal,
and indicates to text containers that the attribute should be discarded if
the underlying text is modified.
Public Constructor Summary
|
Annotation( Object value)
Constructs an annotation record with the given value, which
may be null.
|
Public Method Summary
Object
|
getValue()
Returns the value of the attribute, which may be null.
|
String
|
toString()
Returns the String representation of this Annotation.
|
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals( Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long timeout, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long timeout)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
Public Constructors
public
Annotation
(Object value)
Constructs an annotation record with the given value, which
may be null.
Parameters
value |
the value of the attribute
|
Public Methods
public
Object
getValue
()
Returns the value of the attribute, which may be null.
Returns
- the value of the attribute
public
String
toString
()
Returns the String representation of this Annotation.
Returns
- the
String
representation of this Annotation
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["The `Annotation` class is a wrapper for text attribute values with annotation characteristics, ensuring the attribute's critical tie to its text range."],["`Annotation` objects prevent accidental merging of adjacent text runs with the same attribute value, even when text is modified."],["The class provides methods to construct an `Annotation` with a specified value, retrieve the attribute's value, and obtain a string representation of the `Annotation`."]]],[]]