Changeset 293 in josm for src/org/openstreetmap/josm/plugins
- Timestamp:
- 2007-07-20T16:35:06+02:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/plugins/PluginInformation.java
r292 r293 1 1 package org.openstreetmap.josm.plugins; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import java.io.File; … … 8 10 import java.util.ArrayList; 9 11 import java.util.Collection; 12 import java.util.LinkedList; 10 13 import java.util.List; 11 14 import java.util.Map; … … 33 36 public final int stage; 34 37 public final String version; 35 public final List<URL> libraries = new ArrayList<URL>();38 public final List<URL> libraries = new LinkedList<URL>(); 36 39 37 40 public final Map<String, String> attr = new TreeMap<String, String>(); … … 52 55 this(file, file.getName().substring(0, file.getName().length()-4), null); 53 56 } 54 57 55 58 public PluginInformation(File file, String name, InputStream manifestStream) { 56 59 this.name = name; … … 68 71 manifest.read(manifestStream); 69 72 } 70 Attributes attr = manifest.getMainAttributes(); 71 className = attr.getValue("Plugin-Class"); 72 description = attr.getValue("Plugin-Description"); 73 early = Boolean.parseBoolean(attr.getValue("Plugin-Early")); 74 String stageStr = attr.getValue("Plugin-Stage"); 75 stage = stageStr == null ? 50 : Integer.parseInt(stageStr); 76 version = attr.getValue("Plugin-Version"); 77 author = attr.getValue("Author"); 73 if (manifest != null) { 74 Attributes attr = manifest.getMainAttributes(); 75 className = attr.getValue("Plugin-Class"); 76 description = attr.getValue("Plugin-Description"); 77 early = Boolean.parseBoolean(attr.getValue("Plugin-Early")); 78 String stageStr = attr.getValue("Plugin-Stage"); 79 stage = stageStr == null ? 50 : Integer.parseInt(stageStr); 80 version = attr.getValue("Plugin-Version"); 81 author = attr.getValue("Author"); 82 83 String classPath = attr.getValue(Attributes.Name.CLASS_PATH); 84 if (classPath != null) { 85 String[] cp = classPath.split(" "); 86 StringBuilder entry = new StringBuilder(); 87 for (String s : cp) { 88 entry.append(s); 89 if (s.endsWith("\\")) { 90 entry.setLength(entry.length()-1); 91 entry.append("%20"); // append the split character " " as html-encode 92 continue; 93 } 94 s = entry.toString(); 95 entry = new StringBuilder(); 96 if (!s.startsWith("/") && !s.startsWith("\\") && !s.matches("^.\\:") && file != null) 97 s = file.getParent() + File.separator + s; 98 libraries.add(new URL(getURLString(s))); 99 } 100 } 101 for (Object o : attr.keySet()) 102 this.attr.put(o.toString(), attr.getValue(o.toString())); 103 } else { 104 // resource-only plugin 105 className = null; 106 description = tr("unknown"); 107 early = false; 108 stage = 50; 109 version = null; 110 author = null; 111 } 78 112 if (file != null) 79 libraries.add(new URL(getURLString(file.getAbsolutePath()))); 80 String classPath = attr.getValue(Attributes.Name.CLASS_PATH); 81 if (classPath != null) { 82 String[] cp = classPath.split(" "); 83 StringBuilder entry = new StringBuilder(); 84 for (String s : cp) { 85 entry.append(s); 86 if (s.endsWith("\\")) { 87 entry.setLength(entry.length()-1); 88 entry.append("%20"); // append the split character " " as html-encode 89 continue; 90 } 91 s = entry.toString(); 92 entry = new StringBuilder(); 93 if (!s.startsWith("/") && !s.startsWith("\\") && !s.matches("^.\\:") && file != null) 94 s = file.getParent() + File.separator + s; 95 libraries.add(new URL(getURLString(s))); 96 } 97 } 98 99 for (Object o : attr.keySet()) 100 this.attr.put(o.toString(), attr.getValue(o.toString())); 113 libraries.add(0, new URL(getURLString(file.getAbsolutePath()))); 114 101 115 if (jar != null) 102 116 jar.close(); … … 122 136 */ 123 137 public Class<?> loadClass(ClassLoader classLoader) { 138 if (className == null) 139 return null; 124 140 try { 125 141 Class<?> realClass = Class.forName(className, true, classLoader);
Note:
See TracChangeset
for help on using the changeset viewer.