Class PluginImpl


  • public class PluginImpl
    extends Plugin
    Entry point of a plugin. See the javadoc of Plugin for what those methods mean.
    Author:
    Kohsuke Kawaguchi
    • Constructor Summary

      Constructors 
      Constructor Description
      PluginImpl()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.String> getCustomizationURIs()
      Returns the list of namespace URIs that are supported by this plug-in as schema annotations.
      java.lang.String getOptionName()
      Gets the option name to turn on this add-on.
      java.lang.String getUsage()
      Gets the description of this add-on.
      boolean isCustomizationTagName​(java.lang.String nsUri, java.lang.String localName)
      Checks if the given tag name is a valid tag name for the customization element in this plug-in.
      boolean run​(Outline model, Options opt, org.xml.sax.ErrorHandler errorHandler)
      Run the add-on.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PluginImpl

        public PluginImpl()
    • Method Detail

      • getOptionName

        public java.lang.String getOptionName()
        Description copied from class: Plugin
        Gets the option name to turn on this add-on.

        For example, if "abc" is returned, "-abc" will turn on this plugin. A plugin needs to be turned on explicitly, or else no other methods of Plugin will be invoked.

        Starting 2.1, when an option matches the name returned from this method, XJC will then invoke Plugin.parseArgument(Options, String[], int), allowing plugins to handle arguments to this option.

        Specified by:
        getOptionName in class Plugin
      • getCustomizationURIs

        public java.util.List<java.lang.String> getCustomizationURIs()
        Description copied from class: Plugin
        Returns the list of namespace URIs that are supported by this plug-in as schema annotations.

        If a plug-in returns a non-empty list, the JAXB RI will recognize these namespace URIs as vendor extensions (much like "http://java.sun.com/xml/ns/jaxb/xjc"). This allows users to write those annotations inside a schema, or in external binding files, and later plug-ins can access those annotations as DOM nodes.

        See http://java.sun.com/webservices/docs/1.5/jaxb/vendorCustomizations.html for the syntax that users need to use to enable extension URIs.

        Overrides:
        getCustomizationURIs in class Plugin
        Returns:
        can be empty, be never be null.
      • isCustomizationTagName

        public boolean isCustomizationTagName​(java.lang.String nsUri,
                                              java.lang.String localName)
        Description copied from class: Plugin
        Checks if the given tag name is a valid tag name for the customization element in this plug-in.

        This method is invoked by XJC to determine if the user-specified customization element is really a customization or not. This information is used to pick the proper error message.

        A plug-in is still encouraged to do the validation of the customization element in the Plugin.run(com.sun.tools.xjc.outline.Outline, com.sun.tools.xjc.Options, org.xml.sax.ErrorHandler) method before using any CPluginCustomization, to make sure that it has proper child elements and attributes.

        Overrides:
        isCustomizationTagName in class Plugin
        Parameters:
        nsUri - the namespace URI of the element. Never null.
        localName - the local name of the element. Never null.
      • getUsage

        public java.lang.String getUsage()
        Description copied from class: Plugin
        Gets the description of this add-on. Used to generate a usage screen.
        Specified by:
        getUsage in class Plugin
        Returns:
        localized description message. should be terminated by \n.
      • run

        public boolean run​(@NotNull
                           Outline model,
                           Options opt,
                           org.xml.sax.ErrorHandler errorHandler)
        Description copied from class: Plugin
        Run the add-on.

        This method is invoked after XJC has internally finished the code generation. Plugins can tweak some of the generated code (or add more code) by using Outline and Options.

        Note that this method is invoked only when a Plugin is activated.

        Specified by:
        run in class Plugin
        Parameters:
        model - This object allows access to various generated code.
        errorHandler - Errors should be reported to this handler.
        Returns:
        If the add-on executes successfully, return true. If it detects some errors but those are reported and recovered gracefully, return false.