org.netbeans.modules.sendopts/2 2.22

org.netbeans.api.sendopts
Class CommandLine

java.lang.Object
  extended by org.netbeans.api.sendopts.CommandLine

public final class CommandLine
extends Object

A class for clients that have an array of strings and want to process it - e.g. parse it and also invoke associated OptionProcessors and declarative options.


Method Summary
static CommandLine create(Class<?>... classes)
          Creates new command line processor based on options defined in the provided classes.
static CommandLine getDefault()
          Getter for the default command line processor in the system.
 void process(String... args)
          Process the array of arguments and invoke associated OptionProcessors.
 void process(String[] args, InputStream is, OutputStream os, OutputStream err, File currentDir)
          Process the array of arguments and invoke associated OptionProcessors.
 void usage(PrintWriter w)
          Prints the usage information about options provided by associated OptionProcessors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDefault

public static CommandLine getDefault()
Getter for the default command line processor in the system. List of OptionProcessors is taken from default Lookup.getDefault().


create

public static CommandLine create(Class<?>... classes)
Creates new command line processor based on options defined in the provided classes. These classes are scanned for fields annotated with @Arg annotation.

Parameters:
classes - classes that declare the options
Returns:
new command line object that contains options declared in the provided classes
Since:
2.20

process

public void process(String... args)
             throws CommandException
Process the array of arguments and invoke associated OptionProcessors.

Parameters:
args - the array of strings to process
Throws:
CommandException - if processing is not possible or failed

process

public void process(String[] args,
                    InputStream is,
                    OutputStream os,
                    OutputStream err,
                    File currentDir)
             throws CommandException
Process the array of arguments and invoke associated OptionProcessors.

Parameters:
args - the array of strings to process
is - the input stream that processors can read
os - the output stream that processors can write to
err - the output stream that processors can send error messages to
currentDir - directory that processors should use as current user dir
Throws:
CommandException - if processing is not possible or failed

usage

public void usage(PrintWriter w)
Prints the usage information about options provided by associated OptionProcessors.

Parameters:
w - the writer to output usage info to
Since:
1.7

org.netbeans.modules.sendopts/2 2.22

Built on May 25 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.