Path: blob/master/src/java.base/share/classes/java/text/Annotation.java
41152 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.text;2627/**28* An Annotation object is used as a wrapper for a text attribute value if29* the attribute has annotation characteristics. These characteristics are:30* <ul>31* <li>The text range that the attribute is applied to is critical to the32* semantics of the range. That means, the attribute cannot be applied to subranges33* of the text range that it applies to, and, if two adjacent text ranges have34* the same value for this attribute, the attribute still cannot be applied to35* the combined range as a whole with this value.36* <li>The attribute or its value usually do no longer apply if the underlying text is37* changed.38* </ul>39*40* An example is grammatical information attached to a sentence:41* For the previous sentence, you can say that "an example"42* is the subject, but you cannot say the same about "an", "example", or "exam".43* When the text is changed, the grammatical information typically becomes invalid.44* Another example is Japanese reading information (yomi).45*46* <p>47* Wrapping the attribute value into an Annotation object guarantees that48* adjacent text runs don't get merged even if the attribute values are equal,49* and indicates to text containers that the attribute should be discarded if50* the underlying text is modified.51*52* @see AttributedCharacterIterator53* @since 1.254*/5556public class Annotation {5758/**59* Constructs an annotation record with the given value, which60* may be null.61*62* @param value the value of the attribute63*/64public Annotation(Object value) {65this.value = value;66}6768/**69* Returns the value of the attribute, which may be null.70*71* @return the value of the attribute72*/73public Object getValue() {74return value;75}7677/**78* Returns the String representation of this Annotation.79*80* @return the {@code String} representation of this {@code Annotation}81*/82public String toString() {83return getClass().getName() + "[value=" + value + "]";84}8586private Object value;8788};899091