Class PluginInformation


  • public class PluginInformation
    extends Object
    Encapsulate general information about a plugin. This information is available without the need of loading any class from the plugin jar file.
    Since:
    153
    • Field Detail

      • file

        public File file
        The plugin jar file.
      • mainversion

        public int mainversion
        The lowest JOSM version required by this plugin (from plugin list).
      • localmainversion

        public int localmainversion
        The lowest JOSM version required by this plugin (from locally available jar).
      • minjavaversion

        public int minjavaversion
        The lowest Java version required by this plugin (from plugin list).
      • localminjavaversion

        public int localminjavaversion
        The lowest Java version required by this plugin (from locally available jar).
      • oldmode

        public boolean oldmode
        Determines if the plugin is an old version loaded for incompatibility with latest JOSM (from plugin list)
      • requires

        public String requires
        The list of required plugins, separated by ';' (from plugin list).
      • localrequires

        public String localrequires
        The list of required plugins, separated by ';' (from locally available jar).
      • platform

        public String platform
        The plugin platform on which it is meant to run (windows, osx, unixoid).
      • provides

        public String provides
        The virtual plugin provided by this plugin, if native for a given platform.
      • link

        public String link
        The plugin link (for documentation).
      • early

        public boolean early
        Determines if the plugin must be loaded early or not.
      • stage

        public int stage
        The plugin stage, determining the loading sequence order of plugins.
      • version

        public String version
        The plugin version (from plugin list).
      • localversion

        public String localversion
        The plugin version (from locally available jar).
      • canloadatruntime

        public boolean canloadatruntime
        Plugin can be loaded at any time and not just at start.
      • libraries

        public List<URL> libraries
        The libraries referenced in Class-Path manifest attribute.
      • emptyIcon

        private static final ImageIcon emptyIcon
        Empty icon for these plugins which have none
    • Constructor Detail

      • PluginInformation

        public PluginInformation​(File file)
                          throws PluginException
        Creates a plugin information object by reading the plugin information from the manifest in the plugin jar. The plugin name is derived from the file name.
        Parameters:
        file - the plugin jar file
        Throws:
        PluginException - if reading the manifest fails
      • PluginInformation

        public PluginInformation​(File file,
                                 String name)
                          throws PluginException
        Creates a plugin information object for the plugin with name name. Information about the plugin is extracted from the manifest file in the plugin jar file.
        Parameters:
        file - the plugin jar
        name - the plugin name
        Throws:
        PluginException - if reading the manifest file fails
      • PluginInformation

        public PluginInformation​(InputStream manifestStream,
                                 String name,
                                 String url)
                          throws PluginException
        Creates a plugin information object by reading plugin information in Manifest format from the input stream manifestStream.
        Parameters:
        manifestStream - the stream to read the manifest from
        name - the plugin name
        url - the download URL for the plugin
        Throws:
        PluginException - if the plugin information can't be read from the input stream
      • PluginInformation

        public PluginInformation​(Attributes attr,
                                 String name,
                                 String url)
                          throws PluginException
        Creates a plugin information object by reading plugin information in Manifest format from the input stream manifestStream.
        Parameters:
        attr - the manifest attributes
        name - the plugin name
        url - the download URL for the plugin
        Throws:
        PluginException - if the plugin information can't be read from the input stream
    • Method Detail

      • updateFromPluginSite

        public void updateFromPluginSite​(PluginInformation other)
        Updates the plugin information of this plugin information object with the plugin information in a plugin information object retrieved from a plugin update site.
        Parameters:
        other - the plugin information object retrieved from the update site
      • updateFromJar

        public void updateFromJar​(PluginInformation other)
        Updates the plugin information of this plugin information object with the plugin information in a plugin information object retrieved from a plugin jar.
        Parameters:
        other - the plugin information object retrieved from the jar file
        Since:
        5601
      • getDescriptionAsHtml

        public String getDescriptionAsHtml()
        Replies the description as HTML document, including a link to a web page with more information, provided such a link is available.
        Returns:
        the description as HTML document
      • isExternal

        public boolean isExternal()
        Determines if this plugin comes from an external, non-official source.
        Returns:
        true if this plugin comes from an external, non-official source.
        Since:
        18267
      • load

        public PluginProxy load​(Class<?> klass,
                                PluginClassLoader classLoader)
                         throws PluginException
        Loads and instantiates the plugin.
        Parameters:
        klass - the plugin class
        classLoader - the class loader for the plugin
        Returns:
        the instantiated and initialized plugin
        Throws:
        PluginException - if the plugin cannot be loaded or instanciated
        Since:
        12322
      • findPlugin

        public static PluginInformation findPlugin​(String pluginName)
                                            throws PluginException
        Try to find a plugin after some criteria. Extract the plugin-information from the plugin and return it. The plugin is searched in the following way:
        1. first look after an MANIFEST.MF in the package org.openstreetmap.josm.plugins.<plugin name> (After removing all fancy characters from the plugin name). If found, the plugin is loaded using the bootstrap classloader.
        2. If not found, look for a jar file in the user specific plugin directory (~/.josm/plugins/<plugin name>.jar)
        3. If not found and the environment variable JOSM_RESOURCES + "/plugins/" exist, look there.
        4. Try for the java property josm.resources + "/plugins/" (set via java -Djosm.plugins.path=...)
        5. If the environment variable ALLUSERSPROFILE and APPDATA exist, look in ALLUSERSPROFILE/<the last stuff from APPDATA>/JOSM/plugins. (*sic* There is no easy way under Windows to get the All User's application directory)
        6. Finally, look in some typical unix paths:
          • /usr/local/share/josm/plugins/
          • /usr/local/lib/josm/plugins/
          • /usr/share/josm/plugins/
          • /usr/lib/josm/plugins/
        If a plugin class or jar file is found earlier in the list but seem not to be working, an PluginException is thrown rather than continuing the search. This is so JOSM can detect broken user-provided plugins and do not go silently ignore them. The plugin is not initialized. If the plugin is a .jar file, it is not loaded (only the manifest is extracted). In the classloader-case, the class is bootstraped (e.g. static {} - declarations will run. However, nothing else is done.
        Parameters:
        pluginName - The name of the plugin (in all lowercase). E.g. "lang-de"
        Returns:
        Information about the plugin or null, if the plugin was nowhere to be found.
        Throws:
        PluginException - In case of broken plugins.
      • isUpdateRequired

        public boolean isUpdateRequired​(String referenceVersion)
        Replies true if the plugin with the given information is most likely outdated with respect to the referenceVersion.
        Parameters:
        referenceVersion - the reference version. Can be null if we don't know a reference version
        Returns:
        true, if the plugin needs to be updated; false, otherweise
      • isUpdateRequired

        public boolean isUpdateRequired()
        Replies true if this this plugin should be updated/downloaded because either it is not available locally (its local version is null) or its local version is older than the available version on the server.
        Returns:
        true if the plugin should be updated
      • matches

        public boolean matches​(String filter)
        Replies true if either the name, the description, or the version match (case insensitive) one of the words in filter. Replies true if filter is null.
        Parameters:
        filter - the filter expression
        Returns:
        true if this plugin info matches with the filter
      • getName

        public String getName()
        Replies the name of the plugin.
        Returns:
        The plugin name
      • setName

        public void setName​(String name)
        Sets the name
        Parameters:
        name - Plugin name
      • getScaledIcon

        public ImageIcon getScaledIcon()
        Replies the plugin icon, scaled to LARGE_ICON size.
        Returns:
        the plugin icon, scaled to LARGE_ICON size.
      • getRequiredPlugins

        public List<StringgetRequiredPlugins()
        Replies the list of plugins required by the up-to-date version of this plugin.
        Returns:
        List of plugins required. Empty if no plugin is required.
        Since:
        5601
      • getLocalRequiredPlugins

        public List<StringgetLocalRequiredPlugins()
        Replies the list of plugins required by the local instance of this plugin.
        Returns:
        List of plugins required. Empty if no plugin is required.
        Since:
        5601
      • isForCurrentPlatform

        public boolean isForCurrentPlatform()
        Determines if this plugin can be run on the current platform.
        Returns:
        true if this plugin can be run on the current platform
        Since:
        14384