1 19 package org.java.plugin.registry.xml; 20 21 import java.util.ArrayList ; 22 import java.util.Collection ; 23 import java.util.Collections ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 27 import org.java.plugin.registry.Library; 28 import org.java.plugin.registry.ManifestProcessingException; 29 import org.java.plugin.registry.Version; 30 31 34 class LibraryImpl extends PluginElementImpl implements Library { 35 private final ModelLibrary model; 36 private List exports; 38 LibraryImpl(final PluginDescriptorImpl descr, 39 final PluginFragmentImpl aFragment, final ModelLibrary aModel) 40 throws ManifestProcessingException { 41 super(descr, aFragment, aModel.getId(), aModel.getDocumentation()); 42 model = aModel; 43 if ((model.getPath() == null) 44 || (model.getPath().trim().length() == 0)) { 45 throw new ManifestProcessingException( 46 PluginRegistryImpl.PACKAGE_NAME, 47 "libraryPathIsBlank"); } 49 exports = new ArrayList (model.getExports().size()); 50 for (Iterator it = model.getExports().iterator(); it.hasNext();) { 51 String exportPrefix = (String ) it.next(); 52 if ((exportPrefix == null) || (exportPrefix.trim().length() == 0)) { 53 throw new ManifestProcessingException( 54 PluginRegistryImpl.PACKAGE_NAME, 55 "exportPrefixIBlank"); } 57 exportPrefix = exportPrefix.replace('\\', '.').replace('/', '.'); 58 if (exportPrefix.startsWith(".")) { exportPrefix = exportPrefix.substring(1); 60 } 61 exports.add(exportPrefix); 62 } 63 exports = Collections.unmodifiableList(exports); 64 if (log.isDebugEnabled()) { 65 log.debug("object instantiated: " + this); } 67 } 68 69 72 public String getPath() { 73 return model.getPath(); 74 } 75 76 79 public Collection getExports() { 80 return exports; 81 } 82 83 86 public boolean isCodeLibrary() { 87 return model.isCodeLibrary(); 88 } 89 90 93 public String getUniqueId() { 94 return getDeclaringPluginDescriptor().getRegistry().makeUniqueId( 95 getDeclaringPluginDescriptor().getId(), getId()); 96 } 97 98 101 public String toString() { 102 return "{Library: uid=" + getUniqueId() + "}"; } 104 105 108 public Version getVersion() { 109 return model.getVersion(); 110 } 111 } 112 | Popular Tags |