com.beust.jcommander
Class JCommander

java.lang.Object
  extended by com.beust.jcommander.JCommander

public class JCommander
extends Object

The main class for JCommander. It's responsible for parsing the object that contains all the annotated fields, parse the command line and assign the fields with the correct values and a few other helper methods, such as usage().

Author:
cbeust

Constructor Summary
JCommander(Object object)
           
JCommander(Object object, ResourceBundle bundle, String... args)
           
JCommander(Object object, String... args)
           
 
Method Summary
 List<ParameterDescription> getParameters()
           
 void parse(String... args)
          Parse the command line parameters.
static List<String> readFile(String fileName)
          Reads the file specified by filename and returns the file content as a string.
 void usage()
          Display a the help on System.out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCommander

public JCommander(Object object)

JCommander

public JCommander(Object object,
                  ResourceBundle bundle,
                  String... args)

JCommander

public JCommander(Object object,
                  String... args)
Method Detail

parse

public void parse(String... args)
Parse the command line parameters.


readFile

public static List<String> readFile(String fileName)
Reads the file specified by filename and returns the file content as a string. End of lines are replaced by a space

Parameters:
fileName - the command line filename
Returns:
the file content as a string.

usage

public void usage()
Display a the help on System.out.


getParameters

public List<ParameterDescription> getParameters()
Returns:
a Collection of all the @Parameter annotations found on the target class. This can be used to display the usage() in a different format (e.g. HTML).


Copyright © 2010. All Rights Reserved.