home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / text / Annotation.java next >
Encoding:
Java Source  |  1999-05-28  |  2.3 KB  |  72 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)Annotation.java    1.7 98/07/07
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.text;
  16.  
  17. /**
  18. * An Annotation object is used as a wrapper for a text attribute value if
  19. * the attribute has annotation characteristics. These characteristics are:
  20. * <ul>
  21. * <li>The text range that the attribute is applied to is critical to the
  22. * semantics of the range. That means, the attribute cannot be applied to subranges
  23. * of the text range that it applies to, and, if two adjacent text ranges have
  24. * the same value for this attribute, the attribute still cannot be applied to
  25. * the combined range as a whole with this value.
  26. * <li>The attribute or its value usually do no longer apply if the underlying text is
  27. * changed.
  28. * </ul>
  29. *
  30. * An example is grammatical information attached to a sentence:
  31. * For the previous sentence, you can say that "an example"
  32. * is the subject, but you cannot say the same about "an", "example", or "exam".
  33. * When the text is changed, the grammatical information typically becomes invalid.
  34. * Another example is Japanese reading information (yomi).
  35. *
  36. * <p>
  37. * Wrapping the attribute value into an Annotation object guarantees that
  38. * adjacent text runs don't get merged even if the attribute values are equal,
  39. * and indicates to text containers that the attribute should be discarded if
  40. * the underlying text is modified.
  41. *
  42. * @see AttributedCharacterIterator
  43. */
  44.  
  45. public class Annotation {
  46.  
  47.     /**
  48.      * Constructs an annotation record with the given value.
  49.      * @param value The value of the attribute
  50.      */
  51.     public Annotation(Object value) {
  52.         this.value = value;
  53.     }
  54.  
  55.     /**
  56.      * Returns the value of the attribute.
  57.      */
  58.     public Object getValue() {
  59.         return value;
  60.     }
  61.  
  62.     /**
  63.      * Returns the String representation of this Annotation.
  64.      */
  65.     public String toString() {
  66.     return getClass().getName() + "[value=" + value + "]";
  67.     }
  68.  
  69.     private Object value;
  70.  
  71. };
  72.