01: /*
02: * @(#)Annotation.java 1.17 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package java.text;
29:
30: /**
31: * An Annotation object is used as a wrapper for a text attribute value if
32: * the attribute has annotation characteristics. These characteristics are:
33: * <ul>
34: * <li>The text range that the attribute is applied to is critical to the
35: * semantics of the range. That means, the attribute cannot be applied to subranges
36: * of the text range that it applies to, and, if two adjacent text ranges have
37: * the same value for this attribute, the attribute still cannot be applied to
38: * the combined range as a whole with this value.
39: * <li>The attribute or its value usually do no longer apply if the underlying text is
40: * changed.
41: * </ul>
42: *
43: * An example is grammatical information attached to a sentence:
44: * For the previous sentence, you can say that "an example"
45: * is the subject, but you cannot say the same about "an", "example", or "exam".
46: * When the text is changed, the grammatical information typically becomes invalid.
47: * Another example is Japanese reading information (yomi).
48: *
49: * <p>
50: * Wrapping the attribute value into an Annotation object guarantees that
51: * adjacent text runs don't get merged even if the attribute values are equal,
52: * and indicates to text containers that the attribute should be discarded if
53: * the underlying text is modified.
54: *
55: * @see AttributedCharacterIterator
56: */
57:
58: public class Annotation {
59:
60: /**
61: * Constructs an annotation record with the given value, which
62: * may be null.
63: * @param value The value of the attribute
64: */
65: public Annotation(Object value) {
66: this .value = value;
67: }
68:
69: /**
70: * Returns the value of the attribute, which may be null.
71: */
72: public Object getValue() {
73: return value;
74: }
75:
76: /**
77: * Returns the String representation of this Annotation.
78: */
79: public String toString() {
80: return getClass().getName() + "[value=" + value + "]";
81: }
82:
83: private Object value;
84:
85: };
|