Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2010-01-06 16:32:22 +0000
committerPascal Rapicault2010-01-06 16:32:22 +0000
commite594c43740643f4e3dd76286b903c6ea0be36d5a (patch)
tree73f44146adbc01ff62b972cf15023cf620a3a257
parent21fc7d05c8089f4d13a919fc498ca70c84a542ea (diff)
downloadrt.equinox.p2-e594c43740643f4e3dd76286b903c6ea0be36d5a.tar.gz
rt.equinox.p2-e594c43740643f4e3dd76286b903c6ea0be36d5a.tar.xz
rt.equinox.p2-e594c43740643f4e3dd76286b903c6ea0be36d5a.zip
Changing from List to Collection for licenses
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/LicenseAnalyzer.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java12
12 files changed, 40 insertions, 32 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
index e177819c3..be486c229 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
@@ -262,15 +262,14 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
}
}
- private void writeLicenses(List<ILicense> licenses) {
+ private void writeLicenses(Collection<ILicense> licenses) {
if (licenses != null && licenses.size() > 0) {
// In the future there may be more than one license, so we write this
// as a collection of one.
// See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=216911
start(LICENSES_ELEMENT);
attribute(COLLECTION_SIZE_ATTRIBUTE, licenses.size());
- for (int i = 0; i < licenses.size(); i++) {
- ILicense license = licenses.get(i);
+ for (ILicense license : licenses) {
if (license == null)
continue;
start(LICENSE_ELEMENT);
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 59d2c6d4f..cdc735362 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,6 +11,9 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
+import java.util.Collection;
+import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense;
+
import java.util.*;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
@@ -260,7 +263,7 @@ public class InstallableUnit implements IInstallableUnit {
this.licenses = license == null ? NO_LICENSE : license;
}
- public List<ILicense> getLicenses() {
+ public Collection<ILicense> getLicenses() {
return CollectionUtils.unmodifiableList(licenses);
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java
index f705473ad..6ac399e15 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java
@@ -11,6 +11,9 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
+import java.util.Collection;
+import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense;
+
import java.util.*;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
@@ -169,7 +172,7 @@ public class ResolvedInstallableUnit implements IInstallableUnit {
return original.getUpdateDescriptor();
}
- public List<ILicense> getLicenses() {
+ public Collection<ILicense> getLicenses() {
return original.getLicenses();
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java
index bbbd2f170..832e4c7bd 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java
@@ -169,10 +169,11 @@ public class TranslationSupport {
public ILicense[] getLicenses(IInstallableUnit iu, String locale) {
if (locale == null)
locale = getCurrentLocale();
- List<ILicense> licenses = iu.getLicenses();
+ Collection<ILicense> licenses = iu.getLicenses();
ILicense[] translatedLicenses = new ILicense[licenses.size()];
- for (int i = 0; i < licenses.size(); i++) {
- translatedLicenses[i] = getLicense(iu, licenses.get(i), locale);
+ int i = 0;
+ for (ILicense iLicense : licenses) {
+ translatedLicenses[i++] = getLicense(iu, iLicense, locale);
}
return translatedLicenses;
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java
index bc6f614bf..06086a0e7 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java
@@ -11,6 +11,9 @@
******************************************************************************/
package org.eclipse.equinox.p2.metadata;
+import java.util.Collection;
+import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense;
+
import java.util.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.IQuery;
@@ -208,7 +211,7 @@ public interface IInstallableUnit extends IVersionedId, Comparable<IInstallableU
* </p>
* @return the licenses that apply to this installable unit
*/
- public List<ILicense> getLicenses();
+ public Collection<ILicense> getLicenses();
/**
* Returns the licenses that apply to this installable unit. Any translation of the
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/LicenseAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/LicenseAnalyzer.java
index c0aa31b12..0338bc17a 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/LicenseAnalyzer.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/LicenseAnalyzer.java
@@ -9,7 +9,7 @@
******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.tools.analyzer;
-import java.util.List;
+import java.util.Collection;
import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -23,18 +23,16 @@ public class LicenseAnalyzer extends IUAnalyzer {
public void analyzeIU(IInstallableUnit iu) {
if (Boolean.valueOf(iu.getProperty(InstallableUnitDescription.PROP_TYPE_GROUP)).booleanValue()) {
- List<ILicense> licenses = iu.getLicenses();
+ Collection<ILicense> licenses = iu.getLicenses();
if (iu.getLicenses() == null || licenses.size() == 0) {
// If there is no license then this is an error
error(iu, "[ERROR] " + iu.getId() + " has no license");
return;
- } else if (licenses.get(0).getBody().length() == 0) {
+ } else if (licenses.iterator().next().getBody().length() == 0) {
error(iu, "[ERROR] " + iu.getId() + " has no license");
return;
}
-
- for (int i = 0; i < licenses.size(); i++) {
- ILicense license = licenses.get(i);
+ for (ILicense license : licenses) {
if (license.getBody().startsWith("%")) {
String licenseProperty = license.getBody().substring(1);
if (iu.getProperty("df_LT." + licenseProperty) == null) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
index 8d4430b2e..e993d73dc 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
@@ -486,7 +486,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
desc.setCopyright(prototype.getCopyright());
desc.setFilter(prototype.getFilter() == null ? null : ((LDAPQuery) prototype.getFilter()).getFilter());
desc.setId(prototype.getId());
- List<ILicense> originalLicenses = prototype.getLicenses();
+ Collection<ILicense> originalLicenses = prototype.getLicenses();
desc.setLicenses(originalLicenses.toArray(new ILicense[originalLicenses.size()]));
Collection<IRequirement> originalRequirements = prototype.getRequiredCapabilities();
desc.setRequiredCapabilities(originalRequirements.toArray(new IRequirement[originalRequirements.size()]));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java
index 3bbfebd38..8d007e29a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java
@@ -63,10 +63,11 @@ public class IUPropertyUtils {
}
public ILicense[] getLicenses(IInstallableUnit iu, Locale locale) {
- List<ILicense> licenses = iu.getLicenses();
+ Collection<ILicense> licenses = iu.getLicenses();
ILicense[] translatedLicenses = new ILicense[licenses.size()];
- for (int i = 0; i < licenses.size(); i++) {
- translatedLicenses[i] = getLicense(iu, licenses.get(i), locale);
+ int i = 0;
+ for (ILicense license : translatedLicenses) {
+ translatedLicenses[i++] = getLicense(iu, license, locale);
}
return translatedLicenses;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
index 3078b2476..bc2993700 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
@@ -252,7 +252,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
return this.id;
}
- public List<ILicense> getLicenses() {
+ public Collection<ILicense> getLicenses() {
return CollectionUtils.unmodifiableList(license);
}
@@ -811,11 +811,11 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
assertEquals(unit.getProvidedCapabilities().iterator().next(), spiProvidedCapability);
assertEquals(unit.getTouchpointData().get(0), spiTouchpointData);
assertEquals(unit.getTouchpointType(), spiTouchpointType);
- assertEquals(unit.getLicenses().get(0), spiLicense);
+ assertEquals(unit.getLicenses().iterator().next(), spiLicense);
assertEquals(spiProvidedCapability, unit.getProvidedCapabilities().iterator().next());
assertEquals(spiTouchpointData, unit.getTouchpointData().get(0));
assertEquals(spiTouchpointType, unit.getTouchpointType());
- assertEquals(spiLicense, unit.getLicenses().get(0));
+ assertEquals(spiLicense, unit.getLicenses().iterator().next());
assertEquals(patchUnit.getRequirementsChange().size(), 1);
assertEquals(patchUnit.getRequirementsChange().get(0), spiRequirementChange);
@@ -827,6 +827,6 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
assertFalse(spiRequiredCapability == unit.getRequiredCapabilities().iterator().next());
assertFalse(spiProvidedCapability == unit.getProvidedCapabilities().iterator().next());
assertFalse(spiTouchpointType == unit.getTouchpointType());
- assertFalse(spiLicense == unit.getLicenses().get(0));
+ assertFalse(spiLicense == unit.getLicenses().iterator().next());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
index 8e72f9ee6..00a9b0123 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
@@ -300,8 +300,8 @@ public class AdviceFileParserTest extends TestCase {
assertEquals("testCopyright", iu1.getCopyright().getBody());
assertEquals("http://localhost/test", iu1.getCopyright().getLocation().toString());
assertEquals("test=testFilter", ((LDAPQuery) iu1.getFilter()).getFilter());
- assertEquals("testLicense", iu1.getLicenses().get(0).getBody());
- assertEquals("http://localhost/license", iu1.getLicenses().get(0).getLocation().toString());
+ assertEquals("testLicense", iu1.getLicenses().iterator().next().getBody());
+ assertEquals("http://localhost/license", iu1.getLicenses().iterator().next().getLocation().toString());
assertEquals("testValue1", iu1.getProperty("testName1"));
assertEquals("testValue2", iu1.getProperty("testName2"));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java
index bda2ea0e3..a4126a47c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java
@@ -83,7 +83,7 @@ public class FeaturesActionTest extends ActionTest {
assertTrue(foo.getVersion().equals(fooVersion));
assertEquals("Foo Feature", foo.getProperty(IInstallableUnit.PROP_NAME));
assertEquals("Foo Description", foo.getProperty(IInstallableUnit.PROP_DESCRIPTION));
- assertEquals("Foo License", foo.getLicenses().get(0).getBody());
+ assertEquals("Foo License", foo.getLicenses().iterator().next().getBody());
assertEquals("Foo Copyright", foo.getCopyright().getBody());
assertTrue(foo.getProperty("key1").equals("value1")); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue(foo.getProperty("key2").equals("value2")); //$NON-NLS-1$//$NON-NLS-2$
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java
index 5cd30a25f..ae858b5ea 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java
@@ -92,8 +92,8 @@ public class ProductActionTest extends ActionTest {
Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT);
assertEquals("1.0", 1, ius.size());
IInstallableUnit iu = (IInstallableUnit) ius.iterator().next();
- assertEquals("1.1", "http://www.example.com", iu.getLicenses().get(0).getLocation().toString());
- assertEquals("1.2", "This is the liCenSE.", iu.getLicenses().get(0).getBody().trim());
+ assertEquals("1.1", "http://www.example.com", iu.getLicenses().iterator().next().getLocation().toString());
+ assertEquals("1.2", "This is the liCenSE.", iu.getLicenses().iterator().next().getBody().trim());
}
public void testLicenseNoURL() throws Exception {
@@ -105,8 +105,8 @@ public class ProductActionTest extends ActionTest {
Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT);
assertEquals("1.0", 1, ius.size());
IInstallableUnit iu = (IInstallableUnit) ius.iterator().next();
- assertEquals("1.1", "", iu.getLicenses().get(0).getLocation().toString());
- assertEquals("1.2", "This is the liCenSE.", iu.getLicenses().get(0).getBody().trim());
+ assertEquals("1.1", "", iu.getLicenses().iterator().next().getLocation().toString());
+ assertEquals("1.2", "This is the liCenSE.", iu.getLicenses().iterator().next().getBody().trim());
}
public void testLicenseNoText() throws Exception {
@@ -118,8 +118,8 @@ public class ProductActionTest extends ActionTest {
Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT);
assertEquals("1.0", 1, ius.size());
IInstallableUnit iu = (IInstallableUnit) ius.iterator().next();
- assertEquals("1.1", "http://www.example.com", iu.getLicenses().get(0).getLocation().toString());
- assertEquals("1.2", "", iu.getLicenses().get(0).getBody().trim());
+ assertEquals("1.1", "http://www.example.com", iu.getLicenses().iterator().next().getLocation().toString());
+ assertEquals("1.2", "", iu.getLicenses().iterator().next().getBody().trim());
}
public void testMissingLicense() throws Exception {

Back to the top