KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > resources > MarkerTypeDefinition


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

11 package org.eclipse.core.internal.resources;
12
13 import java.util.HashSet JavaDoc;
14 import java.util.Set JavaDoc;
15 import org.eclipse.core.runtime.IConfigurationElement;
16 import org.eclipse.core.runtime.IExtension;
17
18 //
19
public class MarkerTypeDefinition {
20     protected String JavaDoc type;
21     protected Set JavaDoc superTypes;
22     protected Set JavaDoc attributeNames;
23     protected boolean persistent = false;
24     protected String JavaDoc name;
25
26     public MarkerTypeDefinition(IExtension ext) {
27         super();
28         this.type = ext.getUniqueIdentifier();
29         this.name = ext.getLabel();
30         IConfigurationElement[] elements = ext.getConfigurationElements();
31         Set JavaDoc types = null;
32         Set JavaDoc attributes = null;
33         for (int i = 0; i < elements.length; i++) {
34             IConfigurationElement element = elements[i];
35
36             // supertype
37
final String JavaDoc elementName = element.getName();
38             if (elementName.equalsIgnoreCase("super")) { //$NON-NLS-1$
39
String JavaDoc type = element.getAttribute("type"); //$NON-NLS-1$
40
if (type != null) {
41                     if (types == null)
42                         types = new HashSet JavaDoc(3);
43                     types.add(type);
44                 }
45             }
46
47             // attribute name
48
if (elementName.equalsIgnoreCase("attribute")) { //$NON-NLS-1$
49
String JavaDoc name = element.getAttribute("name"); //$NON-NLS-1$
50
if (name != null) {
51                     if (attributes == null)
52                         attributes = new HashSet JavaDoc(3);
53                     attributes.add(name);
54                 }
55             }
56
57             // persistent
58
if (elementName.equalsIgnoreCase("persistent")) { //$NON-NLS-1$
59
String JavaDoc bool = element.getAttribute("value"); //$NON-NLS-1$
60
if (bool != null)
61                     this.persistent = Boolean.valueOf(bool).booleanValue();
62             }
63             // XXX: legacy code for support of <transient> tag. remove later.
64
if (elementName.equalsIgnoreCase("transient")) { //$NON-NLS-1$
65
String JavaDoc bool = element.getAttribute("value"); //$NON-NLS-1$
66
if (bool != null)
67                     this.persistent = !Boolean.valueOf(bool).booleanValue();
68             }
69         }
70
71         //
72
this.superTypes = types;
73         this.attributeNames = attributes;
74     }
75
76     public Set JavaDoc getAttributeNames() {
77         return attributeNames;
78     }
79
80     public String JavaDoc getName() {
81         return name;
82     }
83
84     public Set JavaDoc getSuperTypes() {
85         return superTypes;
86     }
87
88     public String JavaDoc getType() {
89         return type;
90     }
91
92     public boolean persistent() {
93         return persistent;
94     }
95
96     public String JavaDoc toString() {
97         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(40);
98         buffer.append(this.getClass().getName());
99         buffer.append("\n\ttype=" + type); //$NON-NLS-1$
100
buffer.append("\n\tname=" + name); //$NON-NLS-1$
101
buffer.append("\n\tsupertypes=" + superTypes); //$NON-NLS-1$
102
buffer.append("\n\tattributenames=" + attributeNames); //$NON-NLS-1$
103
buffer.append("\n\tpersistent=" + persistent); //$NON-NLS-1$
104
return buffer.toString();
105     }
106 }
Popular Tags