Hi Bob,

In CLI 1.0 the parameter was Object, so you would pass an instance
e.g. new Integer(1);

We are currently developing the next version and the parameter
type has changed to Class.

So an example usage is:
  Argument i = builder.withValueType(Integer.class).create("i");
  Integer svalue = (Integer) cmdline.getValueAsObject("-i");

This will throw a ClassCastException if the type cannot be converted.

There is also the new Validator functionality.  This allows you
to write your own validators for an Argument.  In this case you
can write one to check that the values are numeric.

In CLI 1.0 you would call:

cmdline.getOptionObject("-i");

and cast the result to the type you need.

Hope that helps,
-John K

On Thursday, Jun 12, 2003, at 20:35 Europe/Dublin, Bob Essa wrote:

Hello:

I have a question about type checking for arguments in CLI. Is it possible to specify that all argument values for a certain option must be numeric and if not ParseException should be thrown while parsing? I see that there is a method "withType" in OptionBuilder but the parameter type of the method is Object - if it supports type checking it should have been "class". The JavaDoc does not give more information on this method. Any help will be highly appreciated.

Thanks
Bob


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


- - - - - - - - - - - - - - - - - - - - - - -
Jakarta Commons CLI
http://jakarta.apache.org/commons/cli


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to