1. /*
  2. * @(#)Annotation.java 1.10 01/11/29
  3. *
  4. * Copyright 2002 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. */
  35. public class Annotation {
  36. /**
  37. * Constructs an annotation record with the given value, which
  38. * may be null.
  39. * @param value The value of the attribute
  40. */
  41. public Annotation(Object value) {
  42. this.value = value;
  43. }
  44. /**
  45. * Returns the value of the attribute, which may be null.
  46. */
  47. public Object getValue() {
  48. return value;
  49. }
  50. /**
  51. * Returns the String representation of this Annotation.
  52. */
  53. public String toString() {
  54. return getClass().getName() + "[value=" + value + "]";
  55. }
  56. private Object value;
  57. };