Changeset 17571 in josm for trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
- Timestamp:
- 2021-03-16T21:56:57+01:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r16874 r17571 19 19 import java.util.Map; 20 20 import java.util.Optional; 21 import java.util.TreeMap;22 21 import java.util.jar.Attributes; 23 22 import java.util.jar.JarInputStream; … … 94 93 public List<URL> libraries = new LinkedList<>(); 95 94 /** All manifest attributes. */ 96 public final Map<String, String> attr = new TreeMap<>();95 public Attributes attr; 97 96 /** Invalid manifest entries */ 98 97 final List<String> invalidManifestEntries = new ArrayList<>(); … … 134 133 if (manifest == null) 135 134 throw new PluginException(tr("The plugin file ''{0}'' does not include a Manifest.", file.toString())); 136 scanManifest(manifest , false);135 scanManifest(manifest.getMainAttributes(), false); 137 136 libraries.add(0, Utils.fileToURL(file)); 138 137 } catch (IOException | InvalidPathException e) { … … 151 150 */ 152 151 public PluginInformation(InputStream manifestStream, String name, String url) throws PluginException { 153 this.name = name;154 152 try { 155 153 Manifest manifest = new Manifest(); … … 158 156 downloadlink = url; 159 157 } 160 scanManifest(manifest , url != null);158 scanManifest(manifest.getMainAttributes(), url != null); 161 159 } catch (IOException e) { 162 160 throw new PluginException(name, e); 163 161 } 162 } 163 164 /** 165 * Creates a plugin information object by reading plugin information in Manifest format 166 * from the input stream {@code manifestStream}. 167 * 168 * @param attr the manifest attributes 169 * @param name the plugin name 170 * @param url the download URL for the plugin 171 * @throws PluginException if the plugin information can't be read from the input stream 172 */ 173 public PluginInformation(Attributes attr, String name, String url) throws PluginException { 174 this.name = name; 175 if (url != null) { 176 downloadlink = url; 177 } 178 scanManifest(attr, url != null); 164 179 } 165 180 … … 189 204 this.canloadatruntime = other.canloadatruntime; 190 205 this.libraries = other.libraries; 191 this.attr.clear(); 192 this.attr.putAll(other.attr); 206 this.attr = new Attributes(other.attr); 193 207 this.invalidManifestEntries.clear(); 194 208 this.invalidManifestEntries.addAll(other.invalidManifestEntries); … … 215 229 } 216 230 217 private void scanManifest( Manifest manifest, boolean oldcheck) {231 private void scanManifest(Attributes attr, boolean oldcheck) { 218 232 String lang = LanguageInfo.getLanguageCodeManifest(); 219 Attributes attr = manifest.getMainAttributes();220 233 className = attr.getValue("Plugin-Class"); 221 234 String s = Optional.ofNullable(attr.getValue(lang+"Plugin-Link")).orElseGet(() -> attr.getValue("Plugin-Link")); … … 318 331 } 319 332 } 320 for (Object o : attr.keySet()) { 321 this.attr.put(o.toString(), attr.getValue(o.toString())); 322 } 333 this.attr = attr; 323 334 } 324 335
Note:
See TracChangeset
for help on using the changeset viewer.