Annotation.java revision cec4dd4b1d33f78997603d0f89c0d0e56e64dbcd
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package java.text;
19
20/**
21 * Wrapper for a text attribute value which represents an annotation. An
22 * annotation has two special aspects:
23 * <ol>
24 * <li>it is connected to a range of main text; if this range or the main text
25 * is changed then the annotation becomes invalid,</li>
26 * <li>it can not be joined with adjacent annotations even if the text attribute
27 * value is the same.</li>
28 * </ol>
29 * <p>
30 * By wrapping text attribute values into an {@code Annotation}, these aspects
31 * will be taken into account when handling annotation text and the
32 * corresponding main text.
33 * <p>
34 * Note: There is no semantic connection between this annotation class and the
35 * {@code java.lang.annotation} package.
36 */
37public class Annotation {
38
39    private Object value;
40
41    /**
42     * Constructs a new {@code Annotation}.
43     *
44     * @param attribute the attribute attached to this annotation. This may be
45     *        {@code null}.
46     */
47    public Annotation(Object attribute) {
48        value = attribute;
49    }
50
51    /**
52     * Returns the value of this annotation. The value may be {@code null}.
53     *
54     * @return the value of this annotation or {@code null}.
55     */
56    public Object getValue() {
57        return value;
58    }
59
60    /**
61     * Returns this annotation in string representation.
62     *
63     * @return the string representation of this annotation.
64     */
65    @Override
66    public String toString() {
67        return getClass().getName() + "[value=" + value + ']'; //$NON-NLS-1$
68    }
69}
70