Stay organized with collections
Save and categorize content based on your preferences.
Annotation
open class Annotation
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 |
Constructs an annotation record with the given value, which may be null.
|
Public methods |
open Any! |
Returns the value of the attribute, which may be null.
|
open String |
Returns the String representation of this Annotation.
|
Public constructors
Annotation
Annotation(value: Any!)
Constructs an annotation record with the given value, which may be null.
Parameters |
value |
Any!: the value of the attribute |
Public methods
getValue
open fun getValue(): Any!
Returns the value of the attribute, which may be null.
Return |
Any! |
the value of the attribute |
toString
open fun toString(): String
Returns the String representation of this Annotation.
Return |
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nAnnotation\n==========\n\n```\nopen class Annotation\n```\n\n|---|---------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [java.text.Annotation](#) |\n\nAn Annotation object is used as a wrapper for a text attribute value if the 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\u003cbr /\u003e\n\nWrapping 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.\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Annotation](#Annotation(kotlin.Any))`(`value:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Constructs an annotation record with the given value, which may be null. |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|\n| open [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | [getValue](#getValue())`()` Returns the value of the attribute, which may be null. |\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](#toString())`()` Returns the String representation of this Annotation. |\n\nPublic constructors\n-------------------\n\n### Annotation\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nAnnotation(value: Any!)\n```\n\nConstructs an annotation record with the given value, which may be null.\n\n| Parameters ||\n|---------|---------------------------------------------------------------------------------------------------------|\n| `value` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!: the value of the attribute |\n\nPublic methods\n--------------\n\n### getValue\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getValue(): Any!\n```\n\nReturns the value of the attribute, which may be null.\n\n| Return ||\n|-----------------------------------------------------------------------------|----------------------------|\n| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the value of the attribute |\n\n### toString\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun toString(): String\n```\n\nReturns the String representation of this Annotation.\n\n| Return ||\n|----------------------------------------------------------------------------------|--------------------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | the `String` representation of this `Annotation` |"]]