KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > source > Annotation


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jface.text.source;
12
13
14 /**
15  * Annotation managed by an
16  * {@link org.eclipse.jface.text.source.IAnnotationModel}.
17  * <p>
18  * Annotations are types, associated text, and can be marked as persistent and
19  * deleted. Annotations which are not explicitly initialized with an annotation
20  * type are of type <code>"org.eclipse.text.annotation.unknown"</code>.
21  */

22 public class Annotation {
23
24     /**
25      * Constant for unknown annotation types.<p>
26      * Value: <code>"org.eclipse.text.annotation.unknown"</code>
27      * @since 3.0
28      */

29     public final static String JavaDoc TYPE_UNKNOWN= "org.eclipse.text.annotation.unknown"; //$NON-NLS-1$
30

31
32     /**
33      * The type of this annotation.
34      * @since 3.0
35      */

36     private String JavaDoc fType;
37     /**
38      * Indicates whether this annotation is persistent or not.
39      * @since 3.0
40      */

41     private boolean fIsPersistent= false;
42     /**
43      * Indicates whether this annotation is marked as deleted or not.
44      * @since 3.0
45      */

46     private boolean fMarkedAsDeleted= false;
47     /**
48      * The text associated with this annotation.
49      * @since 3.0
50      */

51     private String JavaDoc fText;
52
53
54     /**
55      * Creates a new annotation that is not persistent and type less.
56      */

57     protected Annotation() {
58         this(null, false, null);
59     }
60
61     /**
62      * Creates a new annotation with the given properties.
63      *
64      * @param type the unique name of this annotation type
65      * @param isPersistent <code>true</code> if this annotation is
66      * persistent, <code>false</code> otherwise
67      * @param text the text associated with this annotation
68      * @since 3.0
69      */

70     public Annotation(String JavaDoc type, boolean isPersistent, String JavaDoc text) {
71         fType= type;
72         fIsPersistent= isPersistent;
73         fText= text;
74     }
75
76     /**
77      * Creates a new annotation with the given persistence state.
78      *
79      * @param isPersistent <code>true</code> if persistent, <code>false</code> otherwise
80      * @since 3.0
81      */

82     public Annotation(boolean isPersistent) {
83         this(null, isPersistent, null);
84     }
85
86     /**
87      * Returns whether this annotation is persistent.
88      *
89      * @return <code>true</code> if this annotation is persistent, <code>false</code>
90      * otherwise
91      * @since 3.0
92      */

93     public boolean isPersistent() {
94         return fIsPersistent;
95     }
96
97     /**
98      * Sets the type of this annotation.
99      *
100      * @param type the annotation type
101      * @since 3.0
102      */

103     public void setType(String JavaDoc type) {
104         fType= type;
105     }
106
107     /**
108      * Returns the type of the annotation.
109      *
110      * @return the type of the annotation
111      * @since 3.0
112      */

113     public String JavaDoc getType() {
114         return fType == null? TYPE_UNKNOWN : fType;
115     }
116
117     /**
118      * Marks this annotation deleted according to the value of the
119      * <code>deleted</code> parameter.
120      *
121      * @param deleted <code>true</code> if annotation should be marked as deleted
122      * @since 3.0
123      */

124     public void markDeleted(boolean deleted) {
125         fMarkedAsDeleted= deleted;
126     }
127
128     /**
129      * Returns whether this annotation is marked as deleted.
130      *
131      * @return <code>true</code> if annotation is marked as deleted, <code>false</code>
132      * otherwise
133      * @since 3.0
134      */

135     public boolean isMarkedDeleted() {
136         return fMarkedAsDeleted;
137     }
138
139     /**
140      * Sets the text associated with this annotation.
141      *
142      * @param text the text associated with this annotation
143      * @since 3.0
144      */

145     public void setText(String JavaDoc text) {
146         fText= text;
147     }
148
149     /**
150      * Returns the text associated with this annotation.
151      *
152      * @return the text associated with this annotation or <code>null</code>
153      * @since 3.0
154      */

155     public String JavaDoc getText() {
156         return fText;
157     }
158 }
159
Popular Tags