KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > texteditor > AnnotationType


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.ui.internal.texteditor;
12
13 import org.eclipse.jface.text.TextUtilities;
14 import org.eclipse.ui.texteditor.AnnotationPreference;
15
16 /**
17  * Represents an annotation type.
18  *
19  * @since 3.0
20  */

21 public final class AnnotationType {
22     private String JavaDoc fType;
23     private String JavaDoc[] fSuperTypes;
24     private AnnotationPreference fPreference;
25
26     public AnnotationType(String JavaDoc type, String JavaDoc[] superTypes) {
27         fType= type;
28         fSuperTypes= TextUtilities.copy(superTypes);
29     }
30
31     public String JavaDoc getType() {
32         return fType;
33     }
34
35     /**
36      * Returns the list of super types of this annotation type. This list is owned by
37      * this annotation type and may not be manipulated by clients.
38      *
39      * @return the list of super types
40      */

41     public String JavaDoc[] getSuperTypes() {
42         return fSuperTypes;
43     }
44
45     /**
46      * For internal use only.
47      *
48      * @return the annotation preference
49      */

50     public AnnotationPreference getPreference() {
51         return fPreference;
52     }
53
54     /**
55      * For internal use only.
56      *
57      * @param preference the annotation preference
58      */

59     public void setAnnotationPreference(AnnotationPreference preference) {
60         fPreference= preference;
61     }
62
63     public boolean isSubtype(String JavaDoc superType) {
64         if (fSuperTypes == null || superType == null)
65             return false;
66
67         if (superType.equals(fType))
68             return true;
69
70         for (int i= fSuperTypes.length -1; i > -1; i--) {
71             if (superType.equals(fSuperTypes[i]))
72                 return true;
73         }
74
75         return false;
76     }
77 }
78
Popular Tags