commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Keyes <j...@mac.com>
Subject Re: [CLI] 2.x Tasks
Date Wed, 22 Oct 2003 16:10:54 GMT
<snip/>

> 1.3) Enum Argument Values
> 
> Options should allow a list of possible values to validate against.
> Currently this is in StringValidator but would EnumValidator be better name?
> StringArrayValidator is also a suggested name.
> 
> http://marc.theaimsgroup.com/?l=jakarta-commons-dev&m=102750803811805&w=2
> http://marc.theaimsgroup.com/?l=jakarta-commons-dev&m=103951380212779&w=2

I have renamed the StringValidator.  

We should not modify the List that is passed to the validate 
method.  It can lead to behaviour not defined by the API e.g.

(taken from DateValidatorTest):
    final Object[] array = new Object[] { "23/12/03", "2002-10-12" };
    final List list = Arrays.asList(array);
    validator.validate(list);

This will actually modify 'array' (see Arrays.asList).  This smells.

I think we should leave the Validator as is and not 
perform any instance creation.  In CLI 1 there was
an optional type attribute for Arguments 
(java.lang.Class).  The value of an Argument could
be retrieved using two different methods:

   CommandLine.getOptionValue : String
   CommandLine.getOptionObject : Object

The getOptionObject created the relevant instance from
the string value.

I think we should use a similar mechanism now.

-John K



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message