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."],[[["\u003cp\u003eThe \u003ccode\u003eAnnotation\u003c/code\u003e class is a wrapper for text attribute values with annotation characteristics, ensuring the attribute's critical tie to its text range.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eAnnotation\u003c/code\u003e objects prevent accidental merging of adjacent text runs with the same attribute value, even when text is modified.\u003c/p\u003e\n"],["\u003cp\u003eThe class provides methods to construct an \u003ccode\u003eAnnotation\u003c/code\u003e with a specified value, retrieve the attribute's value, and obtain a string representation of the \u003ccode\u003eAnnotation\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Annotation\n\npublic class **Annotation** extends [Object](../../../reference/java/lang/Object.html) \nAn Annotation object is used as a wrapper for a text attribute value if\nthe attribute has annotation characteristics. These characteristics are:\n\n- 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.\n- The attribute or its value usually do no longer apply if the underlying text is changed.\n\nAn 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).\n\n\nWrapping the attribute value into an Annotation object guarantees that\nadjacent text runs don't get merged even if the attribute values are equal,\nand indicates to text containers that the attribute should be discarded if\nthe underlying text is modified. \n\n##### See Also\n\n- [AttributedCharacterIterator](../../../reference/java/text/AttributedCharacterIterator.html) \n\n### Public Constructor Summary\n\n|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [Annotation](../../../reference/java/text/Annotation.html#Annotation(java.lang.Object))([Object](../../../reference/java/lang/Object.html) value) Constructs an annotation record with the given value, which may be null. |\n\n### Public Method Summary\n\n|----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [Object](../../../reference/java/lang/Object.html) | [getValue](../../../reference/java/text/Annotation.html#getValue())() Returns the value of the attribute, which may be null. |\n| [String](../../../reference/java/lang/String.html) | [toString](../../../reference/java/text/Annotation.html#toString())() Returns the String representation of this Annotation. |\n\n### Inherited Method Summary\n\nFrom class [java.lang.Object](../../../reference/java/lang/Object.html) \n\n|-------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Object](../../../reference/java/lang/Object.html) | [clone](../../../reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |\n| boolean | [equals](../../../reference/java/lang/Object.html#equals(java.lang.Object))([Object](../../../reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |\n| void | [finalize](../../../reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |\n| final [Class](../../../reference/java/lang/Class.html)\\\u003c?\\\u003e | [getClass](../../../reference/java/lang/Object.html#getClass())() Returns the unique instance of [Class](../../../reference/java/lang/Class.html) that represents this object's class. |\n| int | [hashCode](../../../reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |\n| final void | [notify](../../../reference/java/lang/Object.html#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. |\n| final void | [notifyAll](../../../reference/java/lang/Object.html#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. |\n| [String](../../../reference/java/lang/String.html) | [toString](../../../reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |\n| final void | [wait](../../../reference/java/lang/Object.html#wait(long,%20int))(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. |\n| final void | [wait](../../../reference/java/lang/Object.html#wait(long))(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. |\n| final void | [wait](../../../reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |\n\nPublic Constructors\n-------------------\n\n#### public\n**Annotation**\n([Object](../../../reference/java/lang/Object.html) value)\n\nConstructs an annotation record with the given value, which\nmay be null. \n\n##### Parameters\n\n| value | the value of the attribute |\n|-------|----------------------------|\n\nPublic Methods\n--------------\n\n#### public [Object](../../../reference/java/lang/Object.html)\n**getValue**\n()\n\nReturns the value of the attribute, which may be null. \n\n##### Returns\n\n- the value of the attribute \n\n#### public [String](../../../reference/java/lang/String.html)\n**toString**\n()\n\nReturns the String representation of this Annotation. \n\n##### Returns\n\n- the `String` representation of this `Annotation`"]]