org.biojava.bio.structure.align.util
Class CliTools

java.lang.Object
  extended by org.biojava.bio.structure.align.util.CliTools

public class CliTools
extends Object

Utilities for autoconfiguring javabeans based on command line arguments.

Author:
Thomas Down

Method Summary
static String[] configureBean(Object bean, String[] args)
          Configure a JavaBean based on a set of command line arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

configureBean

public static String[] configureBean(Object bean,
                                     String[] args)
                              throws ConfigurationException
Configure a JavaBean based on a set of command line arguments. For a command line construct such as "-foo 42", this method will use available BeanInfo (usually obtained by introspection) to find a property named "foo". The argument will be interpreted according to the type of the "foo" property, then the appropriate mutator method (generally named setFoo) will be called to configure the property on the bean.

Currently supported property types are int, double, boolean, String, File, Reader, Writer, InputStream, OutputStream, plus arrays of all the above types. In the case of arrays, the option may appear multiple times on the command line, otherwise recurrance of the same option is an error.

For stream types, the parameter is interpreted as a filename unless it is equal to "-" in which case standard input or standard output are used as appropriate. Each of the standard streams may only be used one.

In the future, this method will probably be extended to handle multiple parameter occurances, and use Annotations to generate more useful help messages when something goes wrong.

Parameters:
bean -
args -
Returns:
A string array which contains any 'anonymous' arguments (may be empty)
Throws:
ConfigurationException