KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > internal > resolver > ExportPackageDescriptionImpl


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
12 package org.eclipse.osgi.internal.resolver;
13
14 import java.util.*;
15 import org.eclipse.osgi.framework.internal.core.Constants;
16 import org.eclipse.osgi.service.resolver.BundleDescription;
17 import org.eclipse.osgi.service.resolver.ExportPackageDescription;
18
19 public class ExportPackageDescriptionImpl extends BaseDescriptionImpl implements ExportPackageDescription {
20     public static final String JavaDoc EQUINOX_EE = "x-equinox-ee"; //$NON-NLS-1$
21
private static final Integer JavaDoc EQUINOX_EE_DEFAULT = new Integer JavaDoc(-1);
22     private String JavaDoc[] uses;
23     private Map attributes;
24     private BundleDescription exporter;
25     private String JavaDoc exclude;
26     private String JavaDoc include;
27     private String JavaDoc[] friends;
28     private String JavaDoc[] mandatory;
29     private Boolean JavaDoc internal = Boolean.FALSE;
30     private int equinox_ee = -1;
31     private boolean root;
32     private int tableIndex;
33
34     public Map getDirectives() {
35         Map result = new HashMap(5);
36         if (uses != null)
37             result.put(Constants.USES_DIRECTIVE, uses);
38         if (exclude != null)
39             result.put(Constants.EXCLUDE_DIRECTIVE, exclude);
40         if (include != null)
41             result.put(Constants.INCLUDE_DIRECTIVE, include);
42         if (mandatory != null)
43             result.put(Constants.MANDATORY_DIRECTIVE, mandatory);
44         if (friends != null)
45             result.put(Constants.FRIENDS_DIRECTIVE, friends);
46         result.put(Constants.INTERNAL_DIRECTIVE, internal);
47         result.put(EQUINOX_EE, equinox_ee == -1 ? EQUINOX_EE_DEFAULT : new Integer JavaDoc(equinox_ee));
48         return result;
49     }
50
51     public Object JavaDoc getDirective(String JavaDoc key) {
52         if (key.equals(Constants.USES_DIRECTIVE))
53             return uses;
54         if (key.equals(Constants.EXCLUDE_DIRECTIVE))
55             return exclude;
56         if (key.equals(Constants.INCLUDE_DIRECTIVE))
57             return include;
58         if (key.equals(Constants.MANDATORY_DIRECTIVE))
59             return mandatory;
60         if (key.equals(Constants.FRIENDS_DIRECTIVE))
61             return friends;
62         if (key.equals(Constants.INTERNAL_DIRECTIVE))
63             return internal;
64         if (key.equals(EQUINOX_EE))
65             return equinox_ee == -1 ? EQUINOX_EE_DEFAULT : new Integer JavaDoc(equinox_ee);
66         return null;
67     }
68
69     public Object JavaDoc setDirective(String JavaDoc key, Object JavaDoc value) {
70         if (key.equals(Constants.USES_DIRECTIVE))
71             return uses = (String JavaDoc[]) value;
72         if (key.equals(Constants.EXCLUDE_DIRECTIVE))
73             return exclude = (String JavaDoc) value;
74         if (key.equals(Constants.INCLUDE_DIRECTIVE))
75             return include = (String JavaDoc) value;
76         if (key.equals(Constants.MANDATORY_DIRECTIVE))
77             return mandatory = (String JavaDoc[]) value;
78         if (key.equals(Constants.FRIENDS_DIRECTIVE))
79             return friends = (String JavaDoc[]) value;
80         if (key.equals(Constants.INTERNAL_DIRECTIVE))
81             return internal = (Boolean JavaDoc) value;
82         if (key.equals(EQUINOX_EE)) {
83             equinox_ee = ((Integer JavaDoc) value).intValue();
84             return value;
85         }
86         return null;
87     }
88
89     public void setDirectives(Map directives) {
90         if (directives == null)
91             return;
92         uses = (String JavaDoc[]) directives.get(Constants.USES_DIRECTIVE);
93         exclude = (String JavaDoc) directives.get(Constants.EXCLUDE_DIRECTIVE);
94         include = (String JavaDoc) directives.get(Constants.INCLUDE_DIRECTIVE);
95         mandatory = (String JavaDoc[]) directives.get(Constants.MANDATORY_DIRECTIVE);
96         friends = (String JavaDoc[]) directives.get(Constants.FRIENDS_DIRECTIVE);
97         internal = (Boolean JavaDoc) directives.get(Constants.INTERNAL_DIRECTIVE);
98         equinox_ee = ((Integer JavaDoc) directives.get(EQUINOX_EE)).intValue();
99     }
100
101     public Map getAttributes() {
102         return attributes;
103     }
104
105     public BundleDescription getSupplier() {
106         return getExporter();
107     }
108
109     public BundleDescription getExporter() {
110         return exporter;
111     }
112
113     public boolean isRoot() {
114         return root;
115     }
116
117     protected void setAttributes(Map attributes) {
118         this.attributes = attributes;
119     }
120
121     protected void setExporter(BundleDescription exporter) {
122         this.exporter = exporter;
123     }
124
125     protected void setRoot(boolean root) {
126         this.root = root;
127     }
128
129     public String JavaDoc toString() {
130         return "Export-Package: " + getName() + "; version=\"" + getVersion() + "\""; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
131
}
132
133     int getTableIndex() {
134         return tableIndex;
135     }
136
137     void setTableIndex(int tableIndex) {
138         this.tableIndex = tableIndex;
139     }
140 }
141
Popular Tags