diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/hooks/Supplementer.java')
-rw-r--r-- | bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/hooks/Supplementer.java | 206 |
1 files changed, 108 insertions, 98 deletions
diff --git a/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/hooks/Supplementer.java b/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/hooks/Supplementer.java index 005d88b1a..792909e70 100644 --- a/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/hooks/Supplementer.java +++ b/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/hooks/Supplementer.java @@ -20,103 +20,113 @@ import org.osgi.framework.Bundle; public class Supplementer { - private ManifestElement[] supplementBundle; - private ManifestElement[] supplementImporter; - private ManifestElement[] supplementExporter; - private Bundle supplementer; - private List supplementedBundles; // elements of type Bundle - - public Supplementer(Bundle bundle, - ManifestElement[] supplementBundle, - ManifestElement[] supplementImporter, - ManifestElement[] supplementExporter) { - this.supplementer = bundle; - this.supplementBundle = supplementBundle; - this.supplementImporter = supplementImporter; - this.supplementExporter = supplementExporter; - this.supplementedBundles = new ArrayList(); - } - - public Bundle getSupplementerBundle() { - return supplementer; - } - - public String getSymbolicName() { - return supplementer.getSymbolicName(); - } - - public void addSupplementedBundle(Bundle supplementedBundle) { - this.supplementedBundles.add(supplementedBundle); - } - - public void removeSupplementedBundle(Bundle supplementedBundle) { - this.supplementedBundles.remove(supplementedBundle); - } - - public Bundle[] getSupplementedBundles() { - return (Bundle[]) supplementedBundles.toArray(new Bundle[supplementedBundles.size()]); - } - - public boolean isSupplemented(Bundle bundle) { - return supplementedBundles.contains(bundle); - } - - public boolean matchSupplementer(String symbolicName) { - boolean matches = false; - - if (supplementBundle != null) for (int i = 0; !matches && i < supplementBundle.length; i++) { - ManifestElement bundle = supplementBundle[i]; - if (equals_wild(bundle.getValue(),symbolicName)) matches = true; - } - - return matches; - } - - public boolean matchesSupplementImporter(ManifestElement[] imports) { - boolean matches = false; - - if (supplementImporter != null) for (int i = 0; !matches && i < supplementImporter.length; i++) { - ManifestElement supplementImport = supplementImporter[i]; - for (int j = 0; !matches && j < imports.length; j++) { - ManifestElement importPackage = imports[j]; - if (supplementImport.getValue().equals(importPackage.getValue())) matches = true; - } - } - - return matches; - } - - public boolean matchesSupplementExporter(ManifestElement[] exports) { - boolean matches = false; - - if (supplementExporter != null) for (int i = 0; !matches && i < supplementExporter.length; i++) { - ManifestElement supplementExport = supplementExporter[i]; - for (int j = 0; !matches && j < exports.length; j++) { - ManifestElement exportPackage = exports[j]; - if (supplementExport.getValue().equals(exportPackage.getValue())) matches = true; - } - } - - return matches; - } - - //knibb - //test if two Strings are equal - //with wild card support - only supports strings ending in * - private boolean equals_wild(String input, String match){ - if(input.equals(match)){ - //its a match so just return true - return true; - } - if(input.endsWith("*")==false){ - //no wildcards are being used here - return false; - } - String wild_in = input.substring(0, input.length()-1); - if(match.startsWith(wild_in)) - return true; - - return false; - } + private final ManifestElement[] supplementBundle; + + private final List supplementedBundles; // elements of type Bundle + + private final Bundle supplementer; + + private final ManifestElement[] supplementExporter; + + private final ManifestElement[] supplementImporter; + + public Supplementer(final Bundle bundle, + final ManifestElement[] supplementBundle, + final ManifestElement[] supplementImporter, + final ManifestElement[] supplementExporter) { + this.supplementer = bundle; + this.supplementBundle = supplementBundle; + this.supplementImporter = supplementImporter; + this.supplementExporter = supplementExporter; + this.supplementedBundles = new ArrayList(); + } + + public void addSupplementedBundle(final Bundle supplementedBundle) { + this.supplementedBundles.add(supplementedBundle); + } + + public Bundle[] getSupplementedBundles() { + return (Bundle[]) supplementedBundles + .toArray(new Bundle[supplementedBundles.size()]); + } + + public Bundle getSupplementerBundle() { + return supplementer; + } + + public String getSymbolicName() { + return supplementer.getSymbolicName(); + } + + public boolean isSupplemented(final Bundle bundle) { + return supplementedBundles.contains(bundle); + } + + public boolean matchesSupplementExporter(final ManifestElement[] exports) { + boolean matches = false; + + if (supplementExporter != null) + for (int i = 0; !matches && i < supplementExporter.length; i++) { + final ManifestElement supplementExport = supplementExporter[i]; + for (int j = 0; !matches && j < exports.length; j++) { + final ManifestElement exportPackage = exports[j]; + if (supplementExport.getValue().equals( + exportPackage.getValue())) matches = true; + } + } + + return matches; + } + + public boolean matchesSupplementImporter(final ManifestElement[] imports) { + boolean matches = false; + + if (supplementImporter != null) + for (int i = 0; !matches && i < supplementImporter.length; i++) { + final ManifestElement supplementImport = supplementImporter[i]; + for (int j = 0; !matches && j < imports.length; j++) { + final ManifestElement importPackage = imports[j]; + if (supplementImport.getValue().equals( + importPackage.getValue())) matches = true; + } + } + + return matches; + } + + public boolean matchSupplementer(final String symbolicName) { + boolean matches = false; + + if (supplementBundle != null) + for (int i = 0; !matches && i < supplementBundle.length; i++) { + final ManifestElement bundle = supplementBundle[i]; + if (equals_wild(bundle.getValue(), symbolicName)) + matches = true; + } + + return matches; + } + + public void removeSupplementedBundle(final Bundle supplementedBundle) { + this.supplementedBundles.remove(supplementedBundle); + } + + //knibb + //test if two Strings are equal + //with wild card support - only supports strings ending in * + private boolean equals_wild(final String input, final String match) { + if (input.equals(match)) { + //its a match so just return true + return true; + } + if (input.endsWith("*") == false) { + //no wildcards are being used here + return false; + } + final String wild_in = input.substring(0, input.length() - 1); + if (match.startsWith(wild_in)) return true; + + return false; + } } |