KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > equinox > internal > app > ProductExtensionBranding


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.equinox.internal.app;
12
13 import java.util.HashMap JavaDoc;
14 import org.eclipse.core.runtime.*;
15 import org.osgi.framework.Bundle;
16
17 public class ProductExtensionBranding implements IBranding{
18     private static final String JavaDoc ATTR_DESCRIPTION = "description"; //$NON-NLS-1$
19
private static final String JavaDoc ATTR_NAME = "name"; //$NON-NLS-1$
20
private static final String JavaDoc ATTR_APPLICATION = "application"; //$NON-NLS-1$
21
private static final String JavaDoc ATTR_VALUE = "value"; //$NON-NLS-1$
22

23     String JavaDoc application = null;
24     String JavaDoc name = null;
25     String JavaDoc id = null;
26     String JavaDoc description = null;
27     HashMap JavaDoc properties;
28     Bundle definingBundle = null;
29
30     public ProductExtensionBranding(String JavaDoc id, IConfigurationElement element) {
31         this.id = id;
32         if (element == null)
33             return;
34         application = element.getAttribute(ATTR_APPLICATION);
35         name = element.getAttribute(ATTR_NAME);
36         description = element.getAttribute(ATTR_DESCRIPTION);
37         loadProperties(element);
38     }
39
40     private void loadProperties(IConfigurationElement element) {
41         IConfigurationElement[] children = element.getChildren();
42         properties = new HashMap JavaDoc(children.length);
43         for (int i = 0; i < children.length; i++) {
44             IConfigurationElement child = children[i];
45             String JavaDoc key = child.getAttribute(ATTR_NAME);
46             String JavaDoc value = child.getAttribute(ATTR_VALUE);
47             if (key != null && value != null)
48                 properties.put(key, value);
49         }
50         definingBundle = Activator.getBundle(element.getContributor());
51     }
52
53     public Bundle getDefiningBundle() {
54         return definingBundle;
55     }
56
57     public String JavaDoc getApplication() {
58         return application;
59     }
60
61     public String JavaDoc getName() {
62         return name;
63     }
64
65     public String JavaDoc getDescription() {
66         return description;
67     }
68
69     public String JavaDoc getId() {
70         return id;
71     }
72
73     public String JavaDoc getProperty(String JavaDoc key) {
74         return (String JavaDoc) properties.get(key);
75     }
76
77     public Object JavaDoc getProduct() {
78         return null;
79     }
80 }
81
Popular Tags