Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7117e222b205b26402db435477e71d15bcd3fe65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*******************************************************************************
 * Copyright (c) 2000, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jface.text.source;


/**
 * Annotation managed by an
 * {@link org.eclipse.jface.text.source.IAnnotationModel}.
 * <p>
 * Annotations are types, associated text, and can be marked as persistent and
 * deleted. Annotations which are not explicitly initialized with an annotation
 * type are of type <code>"org.eclipse.text.annotation.unknown"</code>.
 */
public class Annotation {

	/**
	 * Constant for unknown annotation types.<p>
	 * Value: <code>"org.eclipse.text.annotation.unknown"</code>
	 * @since 3.0
	 */
	public final static String TYPE_UNKNOWN= "org.eclipse.text.annotation.unknown";  //$NON-NLS-1$


	/**
	 * The type of this annotation.
	 * @since 3.0
	 */
	private String fType;
	/**
	 * Indicates whether this annotation is persistent or not.
	 * @since 3.0
	 */
	private boolean fIsPersistent= false;
	/**
	 * Indicates whether this annotation is marked as deleted or not.
	 * @since 3.0
	 */
	private boolean fMarkedAsDeleted= false;
	/**
	 * The text associated with this annotation.
	 * @since 3.0
	 */
	private String fText;


	/**
	 * Creates a new annotation that is not persistent and type less.
	 */
	protected Annotation() {
		this(null, false, null);
	}

	/**
	 * Creates a new annotation with the given properties.
	 *
	 * @param type the type of this annotation
	 * @param isPersistent <code>true</code> if this annotation is
	 *            persistent, <code>false</code> otherwise
	 * @param text the text associated with this annotation
	 * @since 3.0
	 */
	public Annotation(String type, boolean isPersistent, String text) {
		fType= type;
		fIsPersistent= isPersistent;
		fText= text;
	}

	/**
	 * Creates a new annotation with the given persistence state.
	 *
	 * @param isPersistent <code>true</code> if persistent, <code>false</code> otherwise
	 * @since 3.0
	 */
	public Annotation(boolean isPersistent) {
		this(null, isPersistent, null);
	}

	/**
	 * Returns whether this annotation is persistent.
	 *
	 * @return <code>true</code> if this annotation is persistent, <code>false</code>
	 *         otherwise
	 * @since 3.0
	 */
	public boolean isPersistent() {
		return fIsPersistent;
	}

	/**
	 * Sets the type of this annotation.
	 *
	 * @param type the annotation type
	 * @since 3.0
	 */
	public void setType(String type) {
		fType= type;
	}

	/**
	 * Returns the type of the annotation.
	 *
	 * @return the type of the annotation
	 * @since 3.0
	 */
	public String getType() {
		return fType == null? TYPE_UNKNOWN : fType;
	}

	/**
	 * Marks this annotation deleted according to the value of the
	 * <code>deleted</code> parameter.
	 *
	 * @param deleted <code>true</code> if annotation should be marked as deleted
	 * @since 3.0
	 */
	public void markDeleted(boolean deleted) {
		fMarkedAsDeleted= deleted;
	}

	/**
	 * Returns whether this annotation is marked as deleted.
	 *
	 * @return <code>true</code> if annotation is marked as deleted, <code>false</code>
	 *         otherwise
	 * @since 3.0
	 */
	public boolean isMarkedDeleted() {
		return fMarkedAsDeleted;
	}

	/**
	 * Sets the text associated with this annotation.
	 *
	 * @param text the text associated with this annotation
	 * @since 3.0
	 */
	public void setText(String text) {
		fText= text;
	}

	/**
	 * Returns the text associated with this annotation.
	 *
	 * @return the text associated with this annotation or <code>null</code>
	 * @since 3.0
	 */
	public String getText() {
		return fText;
	}
}

Back to the top