Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2010-01-13 17:29:41 +0000
committerPascal Rapicault2010-01-13 17:29:41 +0000
commit18189f0d42f7375660762dc6c885cf31683ae562 (patch)
tree17775d847bed9a33f3c68b74db2df75a2139c0bc /bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java
parentc363f2984a09b73c422e38f4556fd3b23eafe958 (diff)
downloadrt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.gz
rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.xz
rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.zip
Merging api branch back to HEADv20100113
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java132
1 files changed, 70 insertions, 62 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java
index b5dd1ac29..018f26cb6 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java
@@ -11,40 +11,45 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
-import java.util.ArrayList;
-import java.util.Map;
+import org.eclipse.equinox.p2.metadata.Version;
+
+import java.util.*;
+import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
+import org.osgi.framework.Filter;
public class InstallableUnit implements IInstallableUnit {
private static final OrderedProperties NO_PROPERTIES = new OrderedProperties();
private static final IProvidedCapability[] NO_PROVIDES = new IProvidedCapability[0];
- private static final IRequiredCapability[] NO_REQUIRES = new IRequiredCapability[0];
+ private static final IRequirement[] NO_REQUIRES = new IRequirement[0];
private static final IArtifactKey[] NO_ARTIFACTS = new IArtifactKey[0];
private static final ITouchpointData[] NO_TOUCHPOINT_DATA = new ITouchpointData[0];
+ private static final ILicense[] NO_LICENSE = new ILicense[0];
private IArtifactKey[] artifacts = NO_ARTIFACTS;
- private String filter;
+ private Filter filter;
private String id;
private OrderedProperties properties;
private OrderedProperties localizedProperties;
IProvidedCapability[] providedCapabilities = NO_PROVIDES;
- private IRequiredCapability[] requires = NO_REQUIRES;
- private IRequiredCapability[] metaRequires = NO_REQUIRES;
+ private IRequirement[] requires = NO_REQUIRES;
+ private IRequirement[] metaRequires = NO_REQUIRES;
private boolean singleton;
- private ArrayList touchpointData = null;
+ private ITouchpointData[] touchpointData = NO_TOUCHPOINT_DATA;
private ITouchpointType touchpointType;
- private Version version;
+ private Version version = Version.emptyVersion;
private IUpdateDescriptor updateInfo;
- private ILicense license;
+ private ILicense[] licenses = NO_LICENSE;
private ICopyright copyright;
public InstallableUnit() {
@@ -52,26 +57,22 @@ public class InstallableUnit implements IInstallableUnit {
}
public void addTouchpointData(ITouchpointData newData) {
- ensureTouchpointDataCapacity(1);
- touchpointData.add(newData);
- }
-
- public int compareTo(Object toCompareTo) {
- if (!(toCompareTo instanceof IInstallableUnit)) {
- return -1;
+ int tl = touchpointData.length;
+ if (tl == 0)
+ touchpointData = new ITouchpointData[] {newData};
+ else {
+ ITouchpointData[] newDatas = new ITouchpointData[tl + 1];
+ System.arraycopy(touchpointData, 0, newDatas, 0, tl);
+ newDatas[tl] = newData;
+ touchpointData = newDatas;
}
- IInstallableUnit other = (IInstallableUnit) toCompareTo;
- if (getId().compareTo(other.getId()) == 0)
- return (getVersion().compareTo(other.getVersion()));
- return getId().compareTo(other.getId());
}
- private void ensureTouchpointDataCapacity(int size) {
- if (touchpointData != null) {
- touchpointData.ensureCapacity(size);
- } else {
- touchpointData = new ArrayList(size);
- }
+ public int compareTo(IInstallableUnit other) {
+ int cmp = getId().compareTo(other.getId());
+ if (cmp == 0)
+ cmp = getVersion().compareTo(other.getVersion());
+ return cmp;
}
public boolean equals(Object obj) {
@@ -95,16 +96,16 @@ public class InstallableUnit implements IInstallableUnit {
return true;
}
- public IArtifactKey[] getArtifacts() {
- return artifacts;
+ public Collection<IArtifactKey> getArtifacts() {
+ return CollectionUtils.unmodifiableList(artifacts);
}
- public String getFilter() {
+ public Filter getFilter() {
return filter;
}
- public IInstallableUnitFragment[] getFragments() {
- return null;
+ public List<IInstallableUnitFragment> getFragments() {
+ return CollectionUtils.emptyList();
}
public String getId() {
@@ -117,7 +118,7 @@ public class InstallableUnit implements IInstallableUnit {
*
* @return an <i>unmodifiable copy</i> of the IU properties.
*/
- public Map getProperties() {
+ public Map<String, String> getProperties() {
return OrderedProperties.unmodifiableProperties(properties());
}
@@ -135,18 +136,21 @@ public class InstallableUnit implements IInstallableUnit {
return properties().getProperty(key);
}
- public IProvidedCapability[] getProvidedCapabilities() {
- return providedCapabilities;
+ public Collection<IProvidedCapability> getProvidedCapabilities() {
+ return CollectionUtils.unmodifiableList(providedCapabilities);
}
- public IRequiredCapability[] getRequiredCapabilities() {
- return requires;
+ public String getProperty(String key, String locale) {
+ return TranslationSupport.getInstance().getIUProperty(this, key, locale);
+ }
+
+ public List<IRequirement> getRequiredCapabilities() {
+ return CollectionUtils.unmodifiableList(requires);
}
- public ITouchpointData[] getTouchpointData() {
- return (touchpointData == null ? NO_TOUCHPOINT_DATA //
- : (ITouchpointData[]) touchpointData.toArray(new ITouchpointData[touchpointData.size()]));
+ public List<ITouchpointData> getTouchpointData() {
+ return CollectionUtils.unmodifiableList(touchpointData);
}
public ITouchpointType getTouchpointType() {
@@ -165,10 +169,6 @@ public class InstallableUnit implements IInstallableUnit {
return result;
}
- public boolean isFragment() {
- return false;
- }
-
public boolean isResolved() {
return false;
}
@@ -195,10 +195,14 @@ public class InstallableUnit implements IInstallableUnit {
providedCapabilities = newCapabilities;
}
- public void setFilter(String filter) {
+ public void setFilter(Filter filter) {
this.filter = filter;
}
+ public void setFilter(String filter) {
+ setFilter(filter == null ? null : ExpressionUtil.parseLDAP(filter));
+ }
+
public void setId(String id) {
this.id = id;
}
@@ -209,7 +213,7 @@ public class InstallableUnit implements IInstallableUnit {
public String setLocalizedProperty(String key, String value) {
if (localizedProperties == null)
localizedProperties = new OrderedProperties();
- return (String) localizedProperties.put(key, value);
+ return localizedProperties.put(key, value);
}
public String setProperty(String key, String value) {
@@ -220,12 +224,12 @@ public class InstallableUnit implements IInstallableUnit {
return (String) properties.setProperty(key, value);
}
- public void setRequiredCapabilities(IRequiredCapability[] capabilities) {
+ public void setRequiredCapabilities(IRequirement[] capabilities) {
if (capabilities.length == 0) {
this.requires = NO_REQUIRES;
} else {
//copy array for safety
- this.requires = (IRequiredCapability[]) capabilities.clone();
+ this.requires = capabilities.clone();
}
}
@@ -257,12 +261,16 @@ public class InstallableUnit implements IInstallableUnit {
this.updateInfo = updateInfo;
}
- public void setLicense(ILicense license) {
- this.license = license;
+ public void setLicenses(ILicense[] license) {
+ this.licenses = license == null ? NO_LICENSE : license;
}
- public ILicense getLicense() {
- return license;
+ public Collection<ILicense> getLicenses() {
+ return CollectionUtils.unmodifiableList(licenses);
+ }
+
+ public ILicense[] getLicenses(String locale) {
+ return TranslationSupport.getInstance().getLicenses(this, locale);
}
public void setCopyright(ICopyright copyright) {
@@ -273,24 +281,24 @@ public class InstallableUnit implements IInstallableUnit {
return copyright;
}
- public boolean satisfies(IRequiredCapability candidate) {
- IProvidedCapability[] provides = getProvidedCapabilities();
- for (int i = 0; i < provides.length; i++)
- if (provides[i].satisfies(candidate))
- return true;
- return false;
+ public ICopyright getCopyright(String locale) {
+ return TranslationSupport.getInstance().getCopyright(this, locale);
+ }
+
+ public boolean satisfies(IRequirement candidate) {
+ return candidate.isMatch(this);
}
- public IRequiredCapability[] getMetaRequiredCapabilities() {
- return metaRequires;
+ public Collection<IRequirement> getMetaRequiredCapabilities() {
+ return CollectionUtils.unmodifiableList(metaRequires);
}
- public void setMetaRequiredCapabilities(IRequiredCapability[] metaReqs) {
+ public void setMetaRequiredCapabilities(IRequirement[] metaReqs) {
if (metaReqs.length == 0) {
this.metaRequires = NO_REQUIRES;
} else {
//copy array for safety
- this.metaRequires = (IRequiredCapability[]) metaReqs.clone();
+ this.metaRequires = metaReqs.clone();
}
}
}

Back to the top