Stay organized with collections
Save and categorize content based on your preferences.
Annotation
public
class
Annotation
extends Object
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.
Summary
Public constructors |
Annotation(Object value)
Constructs an annotation record with the given value, which
may be null.
|
Public methods |
Object
|
getValue()
Returns the value of the attribute, which may be null.
|
String
|
toString()
Returns the String representation of this Annotation.
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
Public constructors
Annotation
public Annotation (Object value)
Constructs an annotation record with the given value, which
may be null.
Parameters |
value |
Object : the value of the attribute |
Public methods
getValue
public Object getValue ()
Returns the value of the attribute, which may be null.
Returns |
Object |
the value of the attribute |
toString
public String toString ()
Returns the String representation of this Annotation.
Returns |
String |
the String representation of this Annotation |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# Annotation\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Ctors](#pubctors) \\| [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nAnnotation\n==========\n\n\n`\npublic\n\n\nclass\nAnnotation\n`\n\n\n`\n\nextends `[Object](/reference/java/lang/Object)`\n\n\n`\n\n`\n\n\n`\n\n|---|----------------------|\n| [java.lang.Object](/reference/java/lang/Object) ||\n| ↳ | java.text.Annotation |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\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**See also:**\n\n- [AttributedCharacterIterator](/reference/java/text/AttributedCharacterIterator)\n\nSummary\n-------\n\n| ### Public constructors ||\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[Annotation](/reference/java/text/Annotation#Annotation(java.lang.Object))`(`[Object](/reference/java/lang/Object)` value) ` Constructs an annotation record with the given value, which may be null. |\n\n| ### Public methods ||\n|------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|\n| ` `[Object](/reference/java/lang/Object) | ` `[getValue](/reference/java/text/Annotation#getValue())`() ` Returns the value of the attribute, which may be null. |\n| ` `[String](/reference/java/lang/String) | ` `[toString](/reference/java/text/Annotation#toString())`() ` Returns the String representation of this Annotation. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` `[java.lang.Object](/reference/java/lang/Object)` ` |---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](/reference/java/lang/Object) | ` `[clone](/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object. | | ` boolean` | ` `[equals](/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` obj) ` Indicates whether some other object is \"equal to\" this one. | | ` void` | ` `[finalize](/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final `[Class](/reference/java/lang/Class)`\u003c?\u003e` | ` `[getClass](/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this `Object`. | | ` int` | ` `[hashCode](/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object. | | ` final void` | ` `[notify](/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` `[notifyAll](/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor. | | ` `[String](/reference/java/lang/String) | ` `[toString](/reference/java/lang/Object#toString())`() ` Returns a string representation of the object. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||\n\nPublic constructors\n-------------------\n\n### Annotation\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic Annotation (Object value)\n```\n\nConstructs an annotation record with the given value, which\nmay be null.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|---------------------------------------------|\n| `value` | `Object`: the value of the attribute \u003cbr /\u003e |\n\nPublic methods\n--------------\n\n### getValue\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic Object getValue ()\n```\n\nReturns the value of the attribute, which may be null.\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------------------------|-----------------------------------|\n| [Object](/reference/java/lang/Object) | the value of the attribute \u003cbr /\u003e |\n\n### toString\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic String toString ()\n```\n\nReturns the String representation of this Annotation.\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------------------------|---------------------------------------------------------|\n| [String](/reference/java/lang/String) | the `String` representation of this `Annotation` \u003cbr /\u003e |"]]