KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 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.osgi.internal.resolver;
12
13 import java.util.Dictionary JavaDoc;
14 import org.eclipse.osgi.service.resolver.BundleDescription;
15 import org.eclipse.osgi.service.resolver.GenericDescription;
16 import org.osgi.framework.Constants;
17
18 public class GenericDescriptionImpl extends BaseDescriptionImpl implements GenericDescription {
19     private Dictionary JavaDoc attributes;
20     private BundleDescription supplier;
21     private String JavaDoc type = GenericDescription.DEFAULT_TYPE;
22
23     public Dictionary JavaDoc getAttributes() {
24         return attributes;
25     }
26
27     public BundleDescription getSupplier() {
28         return supplier;
29     }
30
31     void setAttributes(Dictionary JavaDoc attributes) {
32         this.attributes = attributes;
33         // always add/replace the version attribute with the actual Version object
34
attributes.put(Constants.VERSION_ATTRIBUTE, getVersion());
35     }
36
37     void setSupplier(BundleDescription supplier) {
38         this.supplier = supplier;
39     }
40
41     public String JavaDoc toString() {
42         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
43         sb.append(StateBuilder.GENERIC_CAPABILITY).append(": ").append(getName()); //$NON-NLS-1$
44
if (getType() != GenericDescription.DEFAULT_TYPE)
45             sb.append(':').append(getType());
46         return sb.toString();
47     }
48
49     public String JavaDoc getType() {
50         return type;
51     }
52
53     void setType(String JavaDoc type) {
54         if (type == null || type.equals(GenericDescription.DEFAULT_TYPE))
55             this.type = GenericDescription.DEFAULT_TYPE;
56         else
57             this.type = type;
58     }
59 }
60
Popular Tags