- java.lang.Object
-
- com.sun.tools.xjc.Plugin
-
- com.sun.tools.xjc.addon.episode.PluginImpl
-
public class PluginImpl extends Plugin
Creates the episode file,- Author:
- Kohsuke Kawaguchi, Ben Tomasini ([email protected])
-
-
Constructor Summary
Constructors Constructor Description PluginImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getOptionName()
Gets the option name to turn on this add-on.String
getUsage()
Gets the description of this add-on.int
parseArgument(Options opt, String[] args, int i)
Parses an optionargs[i]
and augment theopt
object appropriately, then return the number of tokens consumed.boolean
run(Outline model, Options opt, ErrorHandler errorHandler)
Capture all the generated classes from global schema components and generate them in an episode file.-
Methods inherited from class com.sun.tools.xjc.Plugin
getCustomizationURIs, isCustomizationTagName, onActivated, postProcessModel
-
-
-
-
Method Detail
-
getOptionName
public 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 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 classPlugin
-
getUsage
public String getUsage()
Description copied from class:Plugin
Gets the description of this add-on. Used to generate a usage screen.
-
parseArgument
public int parseArgument(Options opt, String[] args, int i) throws BadCommandLineException, IOException
Description copied from class:Plugin
Parses an optionargs[i]
and augment theopt
object appropriately, then return the number of tokens consumed.The callee doesn't need to recognize the option that the getOptionName method returns.
Once a plugin is activated, this method is called for options that XJC didn't recognize. This allows a plugin to define additional options to customize its behavior.
Since options can appear in no particular order, XJC allows sub-options of a plugin to show up before the option that activates a plugin (one that's returned by
Plugin.getOptionName()
. But nevertheless a needs to be activated to participate in further processing.- Overrides:
parseArgument
in classPlugin
- Returns:
- 0 if the argument is not understood. Otherwise return the number of tokens that are consumed, including the option itself. (so if you have an option like "-foo 3", return 2.)
- Throws:
BadCommandLineException
- If the option was recognized but there's an error. This halts the argument parsing process and causes XJC to abort, reporting an error.IOException
-
run
public boolean run(Outline model, Options opt, ErrorHandler errorHandler) throws SAXException
Capture all the generated classes from global schema components and generate them in an episode file.- Specified by:
run
in classPlugin
- 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.
- Throws:
SAXException
- After an error is reported toErrorHandler
, the same exception can be thrown to indicate a fatal irrecoverable error.ErrorHandler
itself may throw it, if it chooses not to recover from the error.
-
-