站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

OptionProcessor (Command Line Parsing API) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.sendopts/2 2.0

org.netbeans.spi.sendopts
Class OptionProcessor

java.lang.Object
  extended by org.netbeans.spi.sendopts.OptionProcessor

public abstract class OptionProcessor
extends Object

A subclass of this class shall be registered in META-INF/services/org.netbeans.spi.sendopts.OptionProcessor file (see Lookup for description of how to do it and why) in order to register it for participation on handling and processing of command line options initiated by CommandLine.getDefault()'s CommandLine.process(java.lang.String[]). When the Options provided by this processor are found on the command line and are consistent, this processor's process(org.netbeans.spi.sendopts.Env, java.util.Map) method is going to be called to handle their values and invoke an action.

The usual pattern for writing a subclass of processor is:

 public class MyProcessor extends OptionProcessor {
   private Option option1 = ...;
   private Option option2 = ...;
   private Option option3 = ...;
 
   protected Set


Constructor Summary
protected OptionProcessor()
          Constructor for subclasses.
 
Method Summary
protected abstract  Set<Option> getOptions()
          Method to override in subclasses to create the right set of Options.
protected abstract  void process(Env env, Map<Option,String[]> optionValues)
          Called by the sendopts parsing infrastructure as a result of CommandLine.process(java.lang.String[]).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionProcessor

protected OptionProcessor()
Constructor for subclasses.

Method Detail

getOptions

protected abstract Set<Option> getOptions()
Method to override in subclasses to create the right set of Options. See the factory methods that are part of the Option's javadoc or read the usecases for the sendopts API.

Returns:
a set of options this processor is interested in, if during processing at least on of the options appears on command line the process(org.netbeans.spi.sendopts.Env, java.util.Map) method will be invoked to handle such option and its values

process

protected abstract void process(Env env,
                                Map<Option,String[]> optionValues)
                         throws CommandException
Called by the sendopts parsing infrastructure as a result of CommandLine.process(java.lang.String[]). The method shall read the values associated with the option(s) this OptionProcessor defines and invoke an action to handle them. While doing this it can communicate with external world using its environment (see Env). Such environment provides access to current user directory, standard output and error streams, as well standard input stream. In case the processing of options fails, the code shall thrown CommandException.

Parameters:
env - the environment to communicate with
optionValues - map of all options that appeared on command line with their values
Throws:
CommandException - in case the processing fails1

org.netbeans.modules.sendopts/2 2.0

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.