1 19 package org.java.plugin.registry.xml; 20 21 import java.net.URL ; 22 23 import org.java.plugin.registry.Documentation; 24 import org.java.plugin.registry.Identity; 25 import org.java.plugin.registry.ManifestProcessingException; 26 import org.java.plugin.registry.PluginDescriptor; 27 import org.java.plugin.registry.PluginFragment; 28 import org.java.plugin.registry.PluginRegistry; 29 import org.java.plugin.registry.Version; 30 31 34 class PluginFragmentImpl extends IdentityImpl implements PluginFragment { 35 private final PluginRegistry registry; 36 private final URL location; 37 private final ModelPluginFragment model; 38 private Documentation doc; 39 40 PluginFragmentImpl(final PluginRegistry aRegistry, 41 final ModelPluginFragment aModel, final URL aLocation) 42 throws ManifestProcessingException { 43 super(aModel.getId()); 44 registry = aRegistry; 45 model = aModel; 46 location = aLocation; 47 if (model.getVendor() == null) { 48 model.setVendor(""); } 50 if ((model.getPluginId() == null) 51 || (model.getPluginId().trim().length() == 0)) { 52 throw new ManifestProcessingException( 53 PluginRegistryImpl.PACKAGE_NAME, 54 "fragmentPliginIdIsBlank", getId()); } 56 if (getId().equals(model.getPluginId())) { 57 throw new ManifestProcessingException( 58 PluginRegistryImpl.PACKAGE_NAME, 59 "invalidFragmentPluginId", getId()); } 61 if ((model.getDocsPath() == null) 62 || (model.getDocsPath().trim().length() == 0)) { 63 model.setDocsPath("docs"); } 65 if (model.getDocumentation() != null) { 66 doc = new DocumentationImpl(this, model.getDocumentation()); 67 } 68 if (log.isDebugEnabled()) { 69 log.debug("object instantiated: " + this); } 71 } 72 73 ModelPluginFragment getModel() { 74 return model; 75 } 76 77 80 public String getUniqueId() { 81 return registry.makeUniqueId(getId(), model.getVersion()); 82 } 83 84 87 public String getVendor() { 88 return model.getVendor(); 89 } 90 91 94 public Version getVersion() { 95 return model.getVersion(); 96 } 97 98 101 public String getPluginId() { 102 return model.getPluginId(); 103 } 104 105 108 public Version getPluginVersion() { 109 return model.getPluginVersion(); 110 } 111 112 115 public PluginRegistry getRegistry() { 116 return registry; 117 } 118 119 123 public boolean matches(final PluginDescriptor descr) { 124 return PluginPrerequisiteImpl.matches(model.getPluginVersion(), 125 descr.getVersion(), model.getMatch()); 126 } 127 128 131 public Documentation getDocumentation() { 132 return doc; 133 } 134 135 138 public String getDocsPath() { 139 return model.getDocsPath(); 140 } 141 142 145 public URL getLocation() { 146 return location; 147 } 148 149 153 protected boolean isEqualTo(final Identity idt) { 154 if (!(idt instanceof PluginFragmentImpl)) { 155 return false; 156 } 157 PluginFragmentImpl other = (PluginFragmentImpl) idt; 158 return getUniqueId().equals(other.getUniqueId()) 159 && getLocation().toExternalForm().equals( 160 other.getLocation().toExternalForm()); 161 } 162 163 166 public String toString() { 167 return "{PluginFragment: uid=" + getUniqueId() + "}"; } 169 } 170 | Popular Tags |