Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2011-01-19 21:42:03 +0000
committerDJ Houghton2011-01-19 21:42:03 +0000
commit399a463c78ff025543a7c04b35394fe5f9777430 (patch)
tree91f58ef4ea88b049dbb6ac7ee1ce4484ce5990ea /bundles/org.eclipse.equinox.p2.metadata/src
parenta21e9016630cd6d7ac5d0fd38a35b3e520686280 (diff)
downloadrt.equinox.p2-399a463c78ff025543a7c04b35394fe5f9777430.tar.gz
rt.equinox.p2-399a463c78ff025543a7c04b35394fe5f9777430.tar.xz
rt.equinox.p2-399a463c78ff025543a7c04b35394fe5f9777430.zip
Bug 324873 - [repository] Share IUs for Composite Repositories
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.metadata/src')
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java
index 99d7b7531..674387912 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,7 +12,9 @@
package org.eclipse.equinox.internal.p2.metadata;
import java.util.*;
+import java.util.Map.Entry;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
+import org.eclipse.equinox.p2.core.IPool;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.query.*;
@@ -224,4 +226,31 @@ public class IUMap implements Cloneable {
for (IInstallableUnit iu : toRemove)
remove(iu);
}
+
+ /**
+ * Replace all instances of the IInstallableUnits in the receiver
+ * with the shared IInstallableUnits from the provided iuPool.
+ * This operation is a no-op if iuPool is null.
+ *
+ * @param iuPool an IPool containing the shared IInstallableUnits
+ */
+ public void compress(IPool<IInstallableUnit> iuPool) {
+ if (iuPool == null) {
+ return;
+ }
+
+ Iterator<Entry<String, Object>> entries = units.entrySet().iterator();
+ while (entries.hasNext()) {
+ Entry<String, Object> entry = entries.next();
+ Object value = entry.getValue();
+ if (value.getClass().isArray()) {
+ IInstallableUnit[] array = (IInstallableUnit[]) value;
+ for (int i = 0; i < array.length; i++) {
+ array[i] = iuPool.add(array[i]);
+ }
+ } else {
+ entry.setValue(iuPool.add((IInstallableUnit) value));
+ }
+ }
+ }
}

Back to the top