KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > model > bundle > ImportPackageObject


1 /*******************************************************************************
2  * Copyright (c) 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.pde.internal.ui.model.bundle;
12
13 import org.eclipse.osgi.service.resolver.*;
14 import org.eclipse.osgi.util.*;
15 import org.osgi.framework.*;
16
17 public class ImportPackageObject extends PackageObject {
18     
19     private static final long serialVersionUID = 1L;
20     
21     private boolean fOptional;
22     
23     private static String JavaDoc getVersion(ExportPackageDescription desc) {
24         String JavaDoc version = desc.getVersion().toString();
25         if (!version.equals(Version.emptyVersion.toString()))
26             return desc.getVersion().toString();
27         return null;
28     }
29     
30     public ImportPackageObject(ManifestHeader header, ManifestElement element, String JavaDoc versionAttribute) {
31         super(header, element, versionAttribute);
32         fOptional = Constants.RESOLUTION_OPTIONAL.equals(element.getDirective(Constants.RESOLUTION_DIRECTIVE));
33     }
34     
35     public ImportPackageObject(ManifestHeader header, ExportPackageDescription desc, String JavaDoc versionAttribute) {
36         super(header, desc.getName(), getVersion(desc), versionAttribute);
37         fOptional = Constants.RESOLUTION_OPTIONAL.equals(desc.getDirective(Constants.RESOLUTION_DIRECTIVE));
38     }
39    
40     protected void appendSupportedAttributes(StringBuffer JavaDoc buffer) {
41         super.appendSupportedAttributes(buffer);
42         if (fOptional) {
43             buffer.append(";"); //$NON-NLS-1$
44
buffer.append(Constants.RESOLUTION_DIRECTIVE);
45             buffer.append(":="); //$NON-NLS-1$
46
buffer.append(Constants.RESOLUTION_OPTIONAL);
47         }
48     }
49     public boolean isOptional() {
50         return fOptional;
51     }
52
53     public void setOptional(boolean optional) {
54         fOptional = optional;
55     }
56
57 }
58
Popular Tags