KickJava   Java API By Example, From Geeks To Geeks.

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


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
12 package org.eclipse.osgi.internal.resolver;
13
14 import org.eclipse.osgi.service.resolver.*;
15
16 public class HostSpecificationImpl extends VersionConstraintImpl implements HostSpecification {
17
18     private BundleDescription[] hosts;
19     private boolean multihost = false;
20
21     public boolean isSatisfiedBy(BaseDescription supplier) {
22         if (!(supplier instanceof BundleDescription))
23             return false;
24         BundleDescription candidate = (BundleDescription) supplier;
25         if (candidate.getHost() != null)
26             return false;
27         if (getName() != null && getName().equals(candidate.getSymbolicName()) && (getVersionRange() == null || getVersionRange().isIncluded(candidate.getVersion())))
28             return true;
29         return false;
30     }
31
32     public BundleDescription[] getHosts() {
33         return hosts;
34     }
35
36     public boolean isResolved() {
37         return hosts != null && hosts.length > 0;
38     }
39
40     /*
41      * The resolve algorithm will call this method to set the hosts.
42      */

43     void setHosts(BundleDescription[] hosts) {
44         this.hosts = hosts;
45     }
46
47     public String JavaDoc toString() {
48         return "Fragment-Host: " + getName() + "; bundle-version=\"" + getVersionRange() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
49
}
50
51     public BaseDescription getSupplier() {
52         if (hosts == null || hosts.length == 0)
53             return null;
54         return hosts[0];
55     }
56
57     public boolean isMultiHost() {
58         return multihost;
59     }
60
61     void setIsMultiHost(boolean multihost) {
62         this.multihost = multihost;
63     }
64 }
65
Popular Tags