01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.texteditor;
11:
12: import org.eclipse.jface.text.TextUtilities;
13: import org.eclipse.ui.texteditor.AnnotationPreference;
14:
15: /**
16: * Represents an annotation type.
17: *
18: * @since 3.0
19: */
20: public final class AnnotationType {
21: private String fType;
22: private String[] fSuperTypes;
23: private AnnotationPreference fPreference;
24:
25: public AnnotationType(String type, String[] super Types) {
26: fType = type;
27: fSuperTypes = TextUtilities.copy(super Types);
28: }
29:
30: public String getType() {
31: return fType;
32: }
33:
34: /**
35: * Returns the list of super types of this annotation type. This list is owned by
36: * this annotation type and may not be manipulated by clients.
37: *
38: * @return the list of super types
39: */
40: public String[] getSuperTypes() {
41: return fSuperTypes;
42: }
43:
44: /**
45: * For internal use only.
46: *
47: * @return the annotation preference
48: */
49: public AnnotationPreference getPreference() {
50: return fPreference;
51: }
52:
53: /**
54: * For internal use only.
55: *
56: * @param preference the annotation preference
57: */
58: public void setAnnotationPreference(AnnotationPreference preference) {
59: fPreference = preference;
60: }
61:
62: public boolean isSubtype(String super Type) {
63: if (fSuperTypes == null || super Type == null)
64: return false;
65:
66: if (super Type.equals(fType))
67: return true;
68:
69: for (int i = fSuperTypes.length - 1; i > -1; i--) {
70: if (super Type.equals(fSuperTypes[i]))
71: return true;
72: }
73:
74: return false;
75: }
76: }
|