KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2003, 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.osgi.internal.resolver;
12
13 import org.eclipse.osgi.service.resolver.*;
14 import org.eclipse.osgi.service.resolver.BaseDescription;
15 import org.eclipse.osgi.service.resolver.BundleSpecification;
16
17 public class BundleSpecificationImpl extends VersionConstraintImpl implements BundleSpecification {
18     private boolean exported;
19     private boolean optional;
20
21     protected void setExported(boolean exported) {
22         this.exported = exported;
23     }
24
25     protected void setOptional(boolean optional) {
26         this.optional = optional;
27     }
28
29     public boolean isExported() {
30         return exported;
31     }
32
33     public boolean isOptional() {
34         return optional;
35     }
36
37     public boolean isSatisfiedBy(BaseDescription supplier) {
38         if (!(supplier instanceof BundleDescription))
39             return false;
40         BundleDescription candidate = (BundleDescription) supplier;
41         if (candidate.getHost() != null)
42             return false;
43         if (getName() != null && getName().equals(candidate.getSymbolicName()) &&
44                 (getVersionRange() == null || getVersionRange().isIncluded(candidate.getVersion())))
45             return true;
46         return false;
47     }
48
49     public String JavaDoc toString() {
50         return "Require-Bundle: " + getName() + "; bundle-version=\"" + getVersionRange() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
51
}
52 }
53
Popular Tags