Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java44
1 files changed, 40 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java
index 2ee7e25b5..84afa69f5 100644
--- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java
+++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Task top Technologies and others.
+ * Copyright (c) 2009 Tasktop Technologies 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.discovery.compatibility;
+import java.util.*;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.equinox.internal.p2.discovery.model.*;
@@ -45,7 +46,13 @@ public class ConnectorDiscoveryExtensionReader {
public static Tag VCS = new Tag("vcs", Messages.ConnectorDiscoveryExtensionReader_Version_Control); //$NON-NLS-1$
- public static final Tag[] TAGS = new Tag[] {DOCUMENT, TASK, VCS};
+ public static final Tag[] DEFAULT_TAGS = new Tag[] {DOCUMENT, TASK, VCS};
+
+ private Map<String, Tag> tagById = new HashMap<String, Tag>();
+
+ public ConnectorDiscoveryExtensionReader() {
+ // constructor
+ }
/**
* return the enum constant whose {@link Tag#getValue() value} is the same as the given value.
@@ -60,7 +67,7 @@ public class ConnectorDiscoveryExtensionReader {
if (value == null) {
return null;
}
- for (Tag tag : TAGS) {
+ for (Tag tag : DEFAULT_TAGS) {
if (tag.getValue().equals(value)) {
return tag;
}
@@ -68,6 +75,32 @@ public class ConnectorDiscoveryExtensionReader {
throw new IllegalArgumentException(value);
}
+ public Set<Tag> getTags() {
+ return new HashSet<Tag>(tagById.values());
+ }
+
+ private Tag getTag(String id) {
+ if (id == null) {
+ return null;
+ }
+ // first, look for known tag
+ Tag result = tagById.get(id);
+ if (result != null) {
+ return result;
+ }
+ // second, search default tags
+ for (Tag tag : DEFAULT_TAGS) {
+ if (tag.getValue().equals(id)) {
+ tagById.put(id, tag);
+ return tag;
+ }
+ }
+ // third, create new tag
+ result = new Tag(id, id);
+ tagById.put(id, result);
+ return result;
+ }
+
public CatalogItem readConnectorDescriptor(IConfigurationElement element) throws ValidationException {
return readConnectorDescriptor(element, CatalogItem.class);
}
@@ -85,7 +118,10 @@ public class ConnectorDiscoveryExtensionReader {
if (kinds != null) {
String[] akinds = kinds.split("\\s*,\\s*"); //$NON-NLS-1$
for (String kind : akinds) {
- connectorDescriptor.addTag(fromValue(kind));
+ Tag tag = getTag(kind);
+ if (tag != null) {
+ connectorDescriptor.addTag(tag);
+ }
}
}
} catch (IllegalArgumentException e) {

Back to the top