~ubuntu-branches/ubuntu/saucy/ivy/saucy-proposed

« back to all changes in this revision

Viewing changes to src/java/org/apache/ivy/osgi/core/BundleInfo.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-15 17:44:57 UTC
  • mfrom: (3.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130515174457-ogntd0vxluwalq11
Tags: 2.3.0-2
* Team upload.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
8
 *
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
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.
 
16
 *
 
17
 */
 
18
package org.apache.ivy.osgi.core;
 
19
 
 
20
import java.net.URI;
 
21
import java.util.Collections;
 
22
import java.util.Iterator;
 
23
import java.util.LinkedHashSet;
 
24
import java.util.List;
 
25
import java.util.Set;
 
26
 
 
27
import org.apache.ivy.osgi.util.Version;
 
28
 
 
29
/**
 
30
 * Bundle info extracted from the bundle manifest.
 
31
 * 
 
32
 */
 
33
public class BundleInfo {
 
34
 
 
35
    public static final Version DEFAULT_VERSION = new Version(1, 0, 0, null);
 
36
 
 
37
    public static final String PACKAGE_TYPE = "package";
 
38
 
 
39
    public static final String BUNDLE_TYPE = "bundle";
 
40
 
 
41
    public static final String SERVICE_TYPE = "service";
 
42
 
 
43
    private String symbolicName;
 
44
 
 
45
    private String presentationName;
 
46
 
 
47
    private String id;
 
48
 
 
49
    private Version version;
 
50
 
 
51
    private Set/* <BundleRequirement> */requirements = new LinkedHashSet/* <BundleRequirement> */();
 
52
 
 
53
    private Set/* <BundleCapability> */capabilities = new LinkedHashSet/* <BundleCapability> */();
 
54
 
 
55
    private List/* <String> */executionEnvironments = Collections.EMPTY_LIST;
 
56
 
 
57
    private String description;
 
58
 
 
59
    private String documentation;
 
60
 
 
61
    private String license;
 
62
 
 
63
    private Integer size;
 
64
 
 
65
    private URI uri;
 
66
 
 
67
    public BundleInfo(String name, Version version) {
 
68
        this.symbolicName = name;
 
69
        this.version = version;
 
70
    }
 
71
 
 
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);
 
84
        builder.append("]");
 
85
        return builder.toString();
 
86
    }
 
87
 
 
88
    public String getSymbolicName() {
 
89
        return symbolicName;
 
90
    }
 
91
 
 
92
    public Version getVersion() {
 
93
        return version == null ? DEFAULT_VERSION : version;
 
94
    }
 
95
 
 
96
    public Version getRawVersion() {
 
97
        return version;
 
98
    }
 
99
 
 
100
    public void setUri(URI uri) {
 
101
        this.uri = uri;
 
102
    }
 
103
 
 
104
    public URI getUri() {
 
105
        return uri;
 
106
    }
 
107
 
 
108
    public void setId(String id) {
 
109
        this.id = id;
 
110
    }
 
111
 
 
112
    public String getId() {
 
113
        return id;
 
114
    }
 
115
 
 
116
    public void setPresentationName(String presentationName) {
 
117
        this.presentationName = presentationName;
 
118
    }
 
119
 
 
120
    public String getPresentationName() {
 
121
        return presentationName;
 
122
    }
 
123
 
 
124
    public void setDescription(String description) {
 
125
        this.description = description;
 
126
    }
 
127
 
 
128
    public String getDescription() {
 
129
        return description;
 
130
    }
 
131
 
 
132
    public void setDocumentation(String documentation) {
 
133
        this.documentation = documentation;
 
134
    }
 
135
 
 
136
    public String getDocumentation() {
 
137
        return documentation;
 
138
    }
 
139
 
 
140
    public void setLicense(String license) {
 
141
        this.license = license;
 
142
    }
 
143
 
 
144
    public String getLicense() {
 
145
        return license;
 
146
    }
 
147
 
 
148
    public void setSize(Integer size) {
 
149
        this.size = size;
 
150
    }
 
151
 
 
152
    public Integer getSize() {
 
153
        return size;
 
154
    }
 
155
 
 
156
    public void addRequirement(BundleRequirement requirement) {
 
157
        requirements.add(requirement);
 
158
    }
 
159
 
 
160
    public Set/* <BundleRequirement> */getRequirements() {
 
161
        return requirements;
 
162
    }
 
163
 
 
164
    public void addCapability(BundleCapability capability) {
 
165
        capabilities.add(capability);
 
166
    }
 
167
 
 
168
    public Set/* <BundleCapability> */getCapabilities() {
 
169
        return capabilities;
 
170
    }
 
171
 
 
172
    public List/* <String> */getExecutionEnvironments() {
 
173
        return executionEnvironments;
 
174
    }
 
175
 
 
176
    public void setExecutionEnvironments(List/* <String> */executionEnvironment) {
 
177
        this.executionEnvironments = executionEnvironment;
 
178
    }
 
179
 
 
180
    public int hashCode() {
 
181
        final int prime = 31;
 
182
        int result = 1;
 
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());
 
189
        return result;
 
190
    }
 
191
 
 
192
    public boolean equals(Object obj) {
 
193
        if (this == obj) {
 
194
            return true;
 
195
        }
 
196
        if (obj == null) {
 
197
            return false;
 
198
        }
 
199
        if (!(obj instanceof BundleInfo)) {
 
200
            return false;
 
201
        }
 
202
        BundleInfo other = (BundleInfo) obj;
 
203
        if (capabilities == null) {
 
204
            if (other.capabilities != null) {
 
205
                return false;
 
206
            }
 
207
        } else if (!capabilities.equals(other.capabilities)) {
 
208
            return false;
 
209
        }
 
210
        if (requirements == null) {
 
211
            if (other.requirements != null) {
 
212
                return false;
 
213
            }
 
214
        } else if (!requirements.equals(other.requirements)) {
 
215
            return false;
 
216
        }
 
217
        if (symbolicName == null) {
 
218
            if (other.symbolicName != null) {
 
219
                return false;
 
220
            }
 
221
        } else if (!symbolicName.equals(other.symbolicName)) {
 
222
            return false;
 
223
        }
 
224
        if (version == null) {
 
225
            if (other.version != null) {
 
226
                return false;
 
227
            }
 
228
        } else if (!version.equals(other.version)) {
 
229
            return false;
 
230
        }
 
231
        if (executionEnvironments == null) {
 
232
            if (other.executionEnvironments != null) {
 
233
                return false;
 
234
            }
 
235
        } else if (!executionEnvironments.equals(other.executionEnvironments)) {
 
236
            return false;
 
237
        }
 
238
        return true;
 
239
    }
 
240
 
 
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);
 
248
            }
 
249
        }
 
250
        return set;
 
251
    }
 
252
 
 
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);
 
260
            }
 
261
        }
 
262
        return set;
 
263
    }
 
264
 
 
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);
 
272
            }
 
273
        }
 
274
        return set;
 
275
    }
 
276
 
 
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())) {
 
283
                set.add(capability);
 
284
            }
 
285
        }
 
286
        return set;
 
287
    }
 
288
 
 
289
}
 
 
b'\\ No newline at end of file'