2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.ivy.osgi.core;
21
import java.util.Collections;
22
import java.util.Iterator;
23
import java.util.LinkedHashSet;
24
import java.util.List;
27
import org.apache.ivy.osgi.util.Version;
30
* Bundle info extracted from the bundle manifest.
33
public class BundleInfo {
35
public static final Version DEFAULT_VERSION = new Version(1, 0, 0, null);
37
public static final String PACKAGE_TYPE = "package";
39
public static final String BUNDLE_TYPE = "bundle";
41
public static final String SERVICE_TYPE = "service";
43
private String symbolicName;
45
private String presentationName;
49
private Version version;
51
private Set/* <BundleRequirement> */requirements = new LinkedHashSet/* <BundleRequirement> */();
53
private Set/* <BundleCapability> */capabilities = new LinkedHashSet/* <BundleCapability> */();
55
private List/* <String> */executionEnvironments = Collections.EMPTY_LIST;
57
private String description;
59
private String documentation;
61
private String license;
67
public BundleInfo(String name, Version version) {
68
this.symbolicName = name;
69
this.version = version;
72
public String toString() {
73
StringBuffer builder = new StringBuffer();
74
builder.append("BundleInfo [executionEnvironments=");
75
builder.append(executionEnvironments);
76
builder.append(", capabilities=");
77
builder.append(capabilities);
78
builder.append(", requirements=");
79
builder.append(requirements);
80
builder.append(", symbolicName=");
81
builder.append(symbolicName);
82
builder.append(", version=");
83
builder.append(version);
85
return builder.toString();
88
public String getSymbolicName() {
92
public Version getVersion() {
93
return version == null ? DEFAULT_VERSION : version;
96
public Version getRawVersion() {
100
public void setUri(URI uri) {
104
public URI getUri() {
108
public void setId(String id) {
112
public String getId() {
116
public void setPresentationName(String presentationName) {
117
this.presentationName = presentationName;
120
public String getPresentationName() {
121
return presentationName;
124
public void setDescription(String description) {
125
this.description = description;
128
public String getDescription() {
132
public void setDocumentation(String documentation) {
133
this.documentation = documentation;
136
public String getDocumentation() {
137
return documentation;
140
public void setLicense(String license) {
141
this.license = license;
144
public String getLicense() {
148
public void setSize(Integer size) {
152
public Integer getSize() {
156
public void addRequirement(BundleRequirement requirement) {
157
requirements.add(requirement);
160
public Set/* <BundleRequirement> */getRequirements() {
164
public void addCapability(BundleCapability capability) {
165
capabilities.add(capability);
168
public Set/* <BundleCapability> */getCapabilities() {
172
public List/* <String> */getExecutionEnvironments() {
173
return executionEnvironments;
176
public void setExecutionEnvironments(List/* <String> */executionEnvironment) {
177
this.executionEnvironments = executionEnvironment;
180
public int hashCode() {
181
final int prime = 31;
183
result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode());
184
result = prime * result + ((requirements == null) ? 0 : requirements.hashCode());
185
result = prime * result + ((symbolicName == null) ? 0 : symbolicName.hashCode());
186
result = prime * result + ((version == null) ? 0 : version.hashCode());
187
result = prime * result
188
+ ((executionEnvironments == null) ? 0 : executionEnvironments.hashCode());
192
public boolean equals(Object obj) {
199
if (!(obj instanceof BundleInfo)) {
202
BundleInfo other = (BundleInfo) obj;
203
if (capabilities == null) {
204
if (other.capabilities != null) {
207
} else if (!capabilities.equals(other.capabilities)) {
210
if (requirements == null) {
211
if (other.requirements != null) {
214
} else if (!requirements.equals(other.requirements)) {
217
if (symbolicName == null) {
218
if (other.symbolicName != null) {
221
} else if (!symbolicName.equals(other.symbolicName)) {
224
if (version == null) {
225
if (other.version != null) {
228
} else if (!version.equals(other.version)) {
231
if (executionEnvironments == null) {
232
if (other.executionEnvironments != null) {
235
} else if (!executionEnvironments.equals(other.executionEnvironments)) {
241
public Set/* <BundleRequirement> */getRequires() {
242
Set/* <BundleRequirement> */set = new LinkedHashSet/* <BundleRequirement> */();
243
Iterator itRequirements = requirements.iterator();
244
while (itRequirements.hasNext()) {
245
BundleRequirement requirement = (BundleRequirement) itRequirements.next();
246
if (requirement.getType().equals(BUNDLE_TYPE)) {
247
set.add(requirement);
253
public Set/* <BundleRequirement> */getImports() {
254
Set/* <BundleRequirement> */set = new LinkedHashSet/* <BundleRequirement> */();
255
Iterator itRequirements = requirements.iterator();
256
while (itRequirements.hasNext()) {
257
BundleRequirement requirement = (BundleRequirement) itRequirements.next();
258
if (requirement.getType().equals(PACKAGE_TYPE)) {
259
set.add(requirement);
265
public Set/* <ExportPackage> */getExports() {
266
Set/* <ExportPackage> */set = new LinkedHashSet/* <ExportPackage> */();
267
Iterator itCapabilities = capabilities.iterator();
268
while (itCapabilities.hasNext()) {
269
BundleCapability capability = (BundleCapability) itCapabilities.next();
270
if (PACKAGE_TYPE.equals(capability.getType())) {
271
set.add((ExportPackage) capability);
277
public Set/* <BundleCapability> */getServices() {
278
Set/* <BundleCapability> */set = new LinkedHashSet/* <BundleCapability> */();
279
Iterator itCapabilities = capabilities.iterator();
280
while (itCapabilities.hasNext()) {
281
BundleCapability capability = (BundleCapability) itCapabilities.next();
282
if (SERVICE_TYPE.equals(capability.getType())) {
b'\\ No newline at end of file'