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