1. /*
  2. * @(#)Annotation.java 1.15 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.text;
  8. /**
  9. * An Annotation object is used as a wrapper for a text attribute value if
  10. * the attribute has annotation characteristics. These characteristics are:
  11. * <ul>
  12. * <li>The text range that the attribute is applied to is critical to the
  13. * semantics of the range. That means, the attribute cannot be applied to subranges
  14. * of the text range that it applies to, and, if two adjacent text ranges have
  15. * the same value for this attribute, the attribute still cannot be applied to
  16. * the combined range as a whole with this value.
  17. * <li>The attribute or its value usually do no longer apply if the underlying text is
  18. * changed.
  19. * </ul>
  20. *
  21. * An example is grammatical information attached to a sentence:
  22. * For the previous sentence, you can say that "an example"
  23. * is the subject, but you cannot say the same about "an", "example", or "exam".
  24. * When the text is changed, the grammatical information typically becomes invalid.
  25. * Another example is Japanese reading information (yomi).
  26. *
  27. * <p>
  28. * Wrapping the attribute value into an Annotation object guarantees that
  29. * adjacent text runs don't get merged even if the attribute values are equal,
  30. * and indicates to text containers that the attribute should be discarded if
  31. * the underlying text is modified.
  32. *
  33. * @see AttributedCharacterIterator
  34. * @since 1.2
  35. */
  36. public class Annotation {
  37. /**
  38. * Constructs an annotation record with the given value, which
  39. * may be null.
  40. * @param value The value of the attribute
  41. */
  42. public Annotation(Object value) {
  43. this.value = value;
  44. }
  45. /**
  46. * Returns the value of the attribute, which may be null.
  47. */
  48. public Object getValue() {
  49. return value;
  50. }
  51. /**
  52. * Returns the String representation of this Annotation.
  53. */
  54. public String toString() {
  55. return getClass().getName() + "[value=" + value + "]";
  56. }
  57. private Object value;
  58. };