diff options
author | Andrew Niefer | 2008-11-28 20:57:50 +0000 |
---|---|---|
committer | Andrew Niefer | 2008-11-28 20:57:50 +0000 |
commit | 4ee4fc0cf716bf84561bcdd42571fa87bae76ec7 (patch) | |
tree | 8983af4e87db2013855d81123f8f64451e35eafa /bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2 | |
parent | bb09f708c706da7b9b8499edb4d50f9724ad8fa7 (diff) | |
download | rt.equinox.p2-4ee4fc0cf716bf84561bcdd42571fa87bae76ec7.tar.gz rt.equinox.p2-4ee4fc0cf716bf84561bcdd42571fa87bae76ec7.tar.xz rt.equinox.p2-4ee4fc0cf716bf84561bcdd42571fa87bae76ec7.zip |
bug 255678 - compare while mirroring
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/ArtifactComparatorFactory.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/ArtifactComparatorFactory.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/ArtifactComparatorFactory.java new file mode 100644 index 000000000..e65e32903 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/ArtifactComparatorFactory.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2008 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * compeople AG (Stefan Liebig) - various ongoing maintenance + *******************************************************************************/ +package org.eclipse.equinox.internal.provisional.p2.artifact.repository; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.equinox.internal.p2.artifact.repository.Messages; +import org.eclipse.osgi.util.NLS; + +public class ArtifactComparatorFactory { + private static final String comparatorPoint = "org.eclipse.equinox.p2.artifact.repository.artifactComparators"; //$NON-NLS-1$ + private static final String ATTR_ID = "id"; //$NON-NLS-1$ + private static final String ATTR_CLASS = "class"; //$NON-NLS-1$ + + public static IArtifactComparator getArtifactComparator(String comparatorID) { + IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(comparatorPoint); + + IConfigurationElement element = null; + if (comparatorID == null && extensions.length > 0) { + element = extensions[0]; //just take the first one + } else { + for (int i = 0; i < extensions.length; i++) { + if (extensions[i].getAttribute(ATTR_ID).equals(comparatorID)) { + element = extensions[i]; + break; + } + } + } + if (element != null) { + try { + Object execExt = element.createExecutableExtension(ATTR_CLASS); + if (execExt instanceof IArtifactComparator) + return (IArtifactComparator) execExt; + } catch (Exception e) { + //fall through + } + } + + if (comparatorID != null) + throw new IllegalArgumentException(NLS.bind(Messages.exception_comparatorNotFound, comparatorID)); + throw new IllegalArgumentException(Messages.exception_noComparators); + } +} |