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