commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Keyes <j...@mac.com>
Subject [CLI] canPreProcess and preProcess
Date Sun, 15 Feb 2004 23:42:42 GMT
Looking at the Argument API I was looking at the canPreProcess
and preProcess methods.  I dislike the names as they don't
describe what the methods do.  I think we can eliminate both
of these methods from Argument and add a getInitialSeparator
method.  Then we modify ParentImpl to use this method rather
than the badly named ones we currently use.

So ParentImpl.canProcess will look like:

   public boolean canProcess(final String arg) {

       final Set triggers = getTriggers();
       if (argument != null) {
           final char separator = argument.getInitialSeparator();
           // if there is a valid separator character
           if (separator != '\0') {
               final int initialIndex = arg.indexOf(separator);
               // if there is a separator present
               if (initialIndex > 0) {
                   return triggers.contains(arg.substring(0, 
initialIndex));
               }
           }
       }
       return triggers.contains(arg);
   }

and the process method:

   public void process(
        final WriteableCommandLine commandLine,
        final ListIterator arguments)
        throws OptionException {

        if (argument != null) {
            splitArgumentToken(arguments, 
argument.getInitialSeparator());
        }

        processParent(commandLine, arguments);

        if (argument != null) {
            argument.processValues(commandLine, arguments, this);
        }

        if (children != null && children.canProcess(arguments)) {
            children.process(commandLine, arguments);
        }
    }

Any comments?

-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