Ignore:
Timestamp:
2007-06-30T22:01:02+02:00 (19 years ago)
Author:
imi
Message:
  • added and fixed some tests
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/plugins/Plugin.java

    r237 r267  
    4040public abstract class Plugin {
    4141
    42         private String name;
     42        String name;
    4343
    4444        public Plugin() {
    45                 URL[] urls = ((URLClassLoader)getClass().getClassLoader()).getURLs();
    46                 name = urls[urls.length-1].toString();
    47                 if (name.toLowerCase().endsWith(".jar")) {
    48                         int lastSlash = name.lastIndexOf('/');
    49                         name = name.substring(lastSlash+1, name.length()-4);
    50                 }
     45                try {
     46                URL[] urls = ((URLClassLoader)getClass().getClassLoader()).getURLs();
     47                name = urls[urls.length-1].toString();
     48                if (name.toLowerCase().endsWith(".jar")) {
     49                        int lastSlash = name.lastIndexOf('/');
     50                        name = name.substring(lastSlash+1, name.length()-4);
     51                }
     52        } catch (RuntimeException e) {
     53                name = "unknown";
     54        }
    5155    }
    5256
    5357        /**
    5458         * @return The name of this plugin. This is the name of the .jar file.
     59         * @deprecated Plugins have to know their name by themself.
    5560         */
    56         public final String getName() {
     61        @Deprecated public final String getName() {
    5762                return name;
    5863        }
    5964        /**
    6065         * @return The directory for the plugin to store all kind of stuff.
     66         * @deprecated Use <code>Main.pref.getPreferencesDir()+"plugins/"+name+"/";</code> instead.
    6167         */
    62         public final String getPluginDir() {
     68        @Deprecated public final String getPluginDir() {
    6369                return Main.pref.getPreferencesDir()+"plugins/"+name+"/";
    6470        }
Note: See TracChangeset for help on using the changeset viewer.