2 * Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
29 * An Annotation object is used as a wrapper for a text attribute value if
30 * the attribute has annotation characteristics. These characteristics are:
32 * <li>The text range that the attribute is applied to is critical to the
33 * semantics of the range. That means, the attribute cannot be applied to subranges
34 * of the text range that it applies to, and, if two adjacent text ranges have
35 * the same value for this attribute, the attribute still cannot be applied to
36 * the combined range as a whole with this value.
37 * <li>The attribute or its value usually do no longer apply if the underlying text is
41 * An example is grammatical information attached to a sentence:
42 * For the previous sentence, you can say that "an example"
43 * is the subject, but you cannot say the same about "an", "example", or "exam".
44 * When the text is changed, the grammatical information typically becomes invalid.
45 * Another example is Japanese reading information (yomi).
48 * Wrapping the attribute value into an Annotation object guarantees that
49 * adjacent text runs don't get merged even if the attribute values are equal,
50 * and indicates to text containers that the attribute should be discarded if
51 * the underlying text is modified.
53 * @see AttributedCharacterIterator
57 public class Annotation {
60 * Constructs an annotation record with the given value, which
62 * @param value The value of the attribute
64 public Annotation(Object value) {
69 * Returns the value of the attribute, which may be null.
71 public Object getValue() {
76 * Returns the String representation of this Annotation.
78 public String toString() {
79 return getClass().getName() + "[value=" + value + "]";