commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r639943 [1/17] - in /commons/proper/cli/trunk/src: java/org/apache/commons/cli2/ java/org/apache/commons/cli2/builder/ java/org/apache/commons/cli2/commandline/ java/org/apache/commons/cli2/option/ java/org/apache/commons/cli2/resource/ jav...
Date Sat, 22 Mar 2008 03:08:35 GMT
Author: bayard
Date: Fri Mar 21 20:08:23 2008
New Revision: 639943

URL: http://svn.apache.org/viewvc?rev=639943&view=rev
Log:
Removing all new lines in every source file - priceless. Arse. Reverting by exporting the old version on top and committing

Modified:
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Argument.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/CommandLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/DisplaySetting.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Group.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/HelpLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/OptionException.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Parent.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/WriteableCommandLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/builder/ArgumentBuilder.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/builder/CommandBuilder.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/builder/DefaultOptionBuilder.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/builder/GroupBuilder.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/builder/PatternBuilder.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/builder/SwitchBuilder.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/CommandLineImpl.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/DefaultingCommandLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PreferencesCommandLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PropertiesCommandLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ArgumentImpl.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Command.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/DefaultOption.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/HelpLineImpl.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/OptionImpl.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ParentImpl.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/SourceDestArgument.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Switch.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/resource/ResourceConstants.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/resource/ResourceHelper.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/Comparators.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/validation/ClassValidator.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/validation/DateValidator.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/validation/EnumValidator.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/validation/FileValidator.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/validation/InvalidArgumentException.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/validation/NumberValidator.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/validation/UrlValidator.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/validation/Validator.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/CLITestCase.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/CommandLineDefaultsTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/CommandLineTestCase.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/PrecedenceTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/WriteableCommandLineTestCase.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/AntTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/CpTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/CvsTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/LsTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug13886Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug13935Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug15046Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug15648Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug27575Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug28005Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug32533Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI122Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI12Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI18Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI80Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/builder/ArgumentBuilderTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/builder/DefaultOptionBuilderTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/DefaultingCommandLineTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/ParserTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/PreferencesCommandLineTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/PropertiesCommandLineTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/WriteableCommandLineImplTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/jdepend/JDependTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ArgumentTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ArgumentTestCase.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/CommandTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/DefaultOptionTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/GroupTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/GroupTestCase.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/NestedGroupTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/OptionTestCase.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ParentTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ParentTestCase.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/SwitchTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/resource/ResourceHelperTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/ComparatorsTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/ClassValidatorTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/DateValidatorTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/EnumValidatorTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/FileValidatorTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/NumberValidatorTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/TimeZoneTestSuite.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/UrlValidatorTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/protect/ProtectedClass.java

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Argument.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Argument.java?rev=639943&r1=639942&r2=639943&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Argument.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Argument.java Fri Mar 21 20:08:23 2008
@@ -1 +1,107 @@
-/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2;import java.util.ListIterator;/** * An Option that can process values passed on the command line in the form * "--file README". */public interface Argument extends Option
  {    /**     * Returns the initial separator character or     * '\0' if no character has been set.     *     * @return char the initial separator character     */    char getInitialSeparator();    /**     * Processes the "README" style element of the argument.     *     * Values identified should be added to the CommandLine object in     * association with this Argument.     *     * @see WriteableCommandLine#addValue(Option,Object)     *     * @param commandLine The CommandLine object to store results in.     * @param args The arguments to process.     * @param option The option to register value against.     * @throws OptionException if any problems occur.     */    void processValues(        final WriteableCommandLine commandLine,        final ListIterator args,        final Option option)            throws OptionException;    /**     * Adds defaults to a CommandLine.     *     * @param commandLine     *            The CommandLine object to store defaults in.     * @param
  option     *            The Option to store the defaults against.     */    void defaultValues(final WriteableCommandLine commandLine, final Option option);    /**     * Performs any necessary validation on the values added to the     * CommandLine.     *     * Validation will typically involve using the     * CommandLine.getValues(option) method to retrieve the values     * and then either checking each value.  Optionally the String     * value can be replaced by another Object such as a Number     * instance or a File instance.     *     * @see CommandLine#getValues(Option)     *     * @param commandLine The CommandLine object to query.     * @param option The option to lookup values with.     * @throws OptionException if any problems occur.     */    void validate(final WriteableCommandLine commandLine, final Option option)        throws OptionException;    /**     * Indicates whether argument values must be present for the CommandLine to     * be valid.     *     * @see
  #getMinimum()     * @see #getMaximum()     * @return true iff the CommandLine will be invalid without at least one     *         value     */    boolean isRequired();    /**     * Retrieves the minimum number of values required for a valid Argument     *     * @return the minimum number of values     */    int getMinimum();    /**     * Retrieves the maximum number of values acceptable for a valid Argument     *     * @return the maximum number of values     */    int getMaximum();}
\ No newline at end of file
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli2;
+
+import java.util.ListIterator;
+
+/**
+ * An Option that can process values passed on the command line in the form
+ * "--file README".
+ */
+public interface Argument extends Option {
+
+    /**
+     * Returns the initial separator character or
+     * '\0' if no character has been set.
+     * 
+     * @return char the initial separator character
+     */
+    char getInitialSeparator();
+    
+    /**
+     * Processes the "README" style element of the argument.
+     *
+     * Values identified should be added to the CommandLine object in
+     * association with this Argument.
+     *
+     * @see WriteableCommandLine#addValue(Option,Object)
+     *
+     * @param commandLine The CommandLine object to store results in.
+     * @param args The arguments to process.
+     * @param option The option to register value against.
+     * @throws OptionException if any problems occur.
+     */
+    void processValues(
+        final WriteableCommandLine commandLine,
+        final ListIterator args,
+        final Option option)
+            throws OptionException;
+    
+    /**
+     * Adds defaults to a CommandLine.
+     * 
+     * @param commandLine
+     *            The CommandLine object to store defaults in.
+     * @param option
+     *            The Option to store the defaults against.
+     */
+    void defaultValues(final WriteableCommandLine commandLine, final Option option);
+
+    /**
+     * Performs any necessary validation on the values added to the
+     * CommandLine.
+     *
+     * Validation will typically involve using the
+     * CommandLine.getValues(option) method to retrieve the values
+     * and then either checking each value.  Optionally the String
+     * value can be replaced by another Object such as a Number
+     * instance or a File instance.
+     *
+     * @see CommandLine#getValues(Option)
+     *
+     * @param commandLine The CommandLine object to query.
+     * @param option The option to lookup values with.
+     * @throws OptionException if any problems occur.
+     */
+    void validate(final WriteableCommandLine commandLine, final Option option)
+        throws OptionException;
+
+    /**
+     * Indicates whether argument values must be present for the CommandLine to
+     * be valid.
+     *
+     * @see #getMinimum()
+     * @see #getMaximum()
+     * @return true iff the CommandLine will be invalid without at least one 
+     *         value
+     */
+    boolean isRequired();
+
+    /**
+     * Retrieves the minimum number of values required for a valid Argument
+     *
+     * @return the minimum number of values
+     */
+    int getMinimum();
+
+    /**
+     * Retrieves the maximum number of values acceptable for a valid Argument
+     *
+     * @return the maximum number of values
+     */
+    int getMaximum();
+}

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/CommandLine.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/CommandLine.java?rev=639943&r1=639942&r2=639943&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/CommandLine.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/CommandLine.java Fri Mar 21 20:08:23 2008
@@ -1 +1,215 @@
-/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2;import java.util.List;import java.util.Set;/** * Instances of CommandLine represent a command line that has been processed * according to the definition supplied to the p
 arser. */public interface CommandLine {    /**     * Detects the presence of an option with the specified trigger in this     * CommandLine.     *     * @param trigger the trigger to search for     * @return true iff an option with this trigger is present     */    boolean hasOption(final String trigger);    /**     * Detects the presence of an option in this CommandLine.     *     * @param option the Option to search for     * @return true iff the option is present     */    boolean hasOption(final Option option);    /**     * Finds the Option with the specified trigger     *     * @param trigger the name of the option to retrieve     * @return the Option matching the trigger or null if none exists     */    Option getOption(final String trigger);    /**     * Retrieves the Argument values associated with the specified Option     *     * @param trigger a trigger used to lookup the Option     * @return a list of values or an empty List if none are found     */    List getVal
 ues(final String trigger);    /**     * Retrieves the Argument values associated with the specified Option     *     * @param trigger a trigger used to lookup the Option     * @param defaultValues the result to return if no values are found     * @return a list of values or defaultValues if none are found     */    List getValues(final String trigger, final List defaultValues);    /**     * Retrieves the Argument values associated with the specified Option     *     * @param option the Option associated with the values     * @return a list of values or an empty List if none are found     */    List getValues(final Option option);    /**     * Retrieves the Argument values associated with the specified Option     *     * @param option the Option associated with the values     * @param defaultValues the result to return if no values are found     * @return a list of values or defaultValues if none are found     */    List getValues(final Option option, final List defaultValues
 );    /**     * Retrieves the single Argument value associated with the specified Option     *     * @param trigger a trigger used to lookup the Option     * @return the matching value or null if none exists     * @throws IllegalStateException if more than one values are found     */    Object getValue(final String trigger) throws IllegalStateException;    /**     * Retrieves the single Argument value associated with the specified Option     *     * @param trigger a trigger used to lookup the Option     * @param defaultValue the result to use if no values are found     * @return the matching value or defaultValue if none exists     * @throws IllegalStateException if more than one values are found     */    Object getValue(final String trigger, final Object defaultValue) throws IllegalStateException;    /**     * Retrieves the single Argument value associated with the specified Option     *     * @param option the Option associated with the value     * @return the matching va
 lue or null if none exists     * @throws IllegalStateException if more than one values are found     */    Object getValue(final Option option) throws IllegalStateException;    /**     * Retrieves the single Argument value associated with the specified Option     *     * @param option the Option associated with the value     * @param defaultValue the result to use if no values are found     * @return the matching value or defaultValue if none exists     * @throws IllegalStateException if more than one values are found     */    Object getValue(final Option option, final Object defaultValue) throws IllegalStateException;    /**     * Retrieves the Boolean value associated with the specified Switch     *     * @param trigger a trigger used to lookup the Option     * @return the Boolean associated with trigger or null if none exists     */    Boolean getSwitch(final String trigger);    /**     * Retrieves the Boolean value associated with the specified Switch     *     * @param
  trigger a trigger used to lookup the Option     * @param defaultValue the Boolean to use if none match     * @return the Boolean associated with trigger or defaultValue if none exists     */    Boolean getSwitch(final String trigger, final Boolean defaultValue);    /**     * Retrieves the Boolean value associated with the specified Switch     *     * @param option the Option associated with the value     * @return the Boolean associated with option or null if none exists     */    Boolean getSwitch(final Option option);    /**     * Retrieves the Boolean value associated with the specified Switch     *     * @param option the Option associated with the value     * @param defaultValue the Boolean to use if none match     * @return the Boolean associated with option or defaultValue if none exists     */    Boolean getSwitch(final Option option, final Boolean defaultValue);    /**     * Retrieves the value associated with the specified property     *     * @param property the 
 property name to lookup     * @return the value of the property or null     */    String getProperty(final String property);    /**     * Retrieves the value associated with the specified property     *     * @param property the property name to lookup     * @param defaultValue the value to use if no other is found     * @return the value of the property or defaultValue     */    String getProperty(final String property, final String defaultValue);    /**     * Retrieves the set of all property names associated with this CommandLine     *     * @return a none null set of property names     */    Set getProperties();    /**     * Retrieves the number of times the specified Option appeared in this     * CommandLine     *     * @param trigger a trigger used to lookup the Option     * @return the number of occurrences of the option     */    int getOptionCount(final String trigger);    /**     * Retrieves the number of times the specified Option appeared in this     * CommandLin
 e     *     * @param option the Option associated to check     * @return the number of occurrences of the option     */    int getOptionCount(final Option option);    /**     * Retrieves a list of all Options found in this CommandLine     *     * @return a none null list of Options     */    List getOptions();    /**     * Retrieves a list of all Option triggers found in this CommandLine     *     * @return a none null list of Option triggers     */    Set getOptionTriggers();}
\ No newline at end of file
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli2;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Instances of CommandLine represent a command line that has been processed
+ * according to the definition supplied to the parser.
+ */
+public interface CommandLine {
+	
+    /**
+     * Detects the presence of an option with the specified trigger in this 
+     * CommandLine.
+     * 
+     * @param trigger the trigger to search for
+     * @return true iff an option with this trigger is present
+     */
+    boolean hasOption(final String trigger);
+    
+    /**
+     * Detects the presence of an option in this CommandLine.
+     * 
+     * @param option the Option to search for
+     * @return true iff the option is present
+     */
+    boolean hasOption(final Option option);
+    
+    /**
+     * Finds the Option with the specified trigger
+     * 
+     * @param trigger the name of the option to retrieve
+     * @return the Option matching the trigger or null if none exists
+     */
+    Option getOption(final String trigger);
+    
+    /**
+     * Retrieves the Argument values associated with the specified Option
+     * 
+     * @param trigger a trigger used to lookup the Option
+     * @return a list of values or an empty List if none are found
+     */
+    List getValues(final String trigger);
+    
+    /**
+     * Retrieves the Argument values associated with the specified Option
+     * 
+     * @param trigger a trigger used to lookup the Option
+     * @param defaultValues the result to return if no values are found
+     * @return a list of values or defaultValues if none are found
+     */
+    List getValues(final String trigger, final List defaultValues);
+    
+    /**
+     * Retrieves the Argument values associated with the specified Option
+     * 
+     * @param option the Option associated with the values
+     * @return a list of values or an empty List if none are found
+     */
+    List getValues(final Option option);
+    
+    /**
+     * Retrieves the Argument values associated with the specified Option
+     * 
+     * @param option the Option associated with the values
+     * @param defaultValues the result to return if no values are found
+     * @return a list of values or defaultValues if none are found
+     */
+    List getValues(final Option option, final List defaultValues);
+    
+    /**
+     * Retrieves the single Argument value associated with the specified Option
+     * 
+     * @param trigger a trigger used to lookup the Option
+     * @return the matching value or null if none exists
+     * @throws IllegalStateException if more than one values are found
+     */
+    Object getValue(final String trigger) throws IllegalStateException;
+    
+    /**
+     * Retrieves the single Argument value associated with the specified Option
+     * 
+     * @param trigger a trigger used to lookup the Option
+     * @param defaultValue the result to use if no values are found
+     * @return the matching value or defaultValue if none exists
+     * @throws IllegalStateException if more than one values are found
+     */
+    Object getValue(final String trigger, final Object defaultValue) throws IllegalStateException;
+    
+    /**
+     * Retrieves the single Argument value associated with the specified Option
+     * 
+     * @param option the Option associated with the value
+     * @return the matching value or null if none exists
+     * @throws IllegalStateException if more than one values are found
+     */
+    Object getValue(final Option option) throws IllegalStateException;
+    
+    /**
+     * Retrieves the single Argument value associated with the specified Option
+     * 
+     * @param option the Option associated with the value
+     * @param defaultValue the result to use if no values are found
+     * @return the matching value or defaultValue if none exists
+     * @throws IllegalStateException if more than one values are found
+     */
+    Object getValue(final Option option, final Object defaultValue) throws IllegalStateException;
+    
+    /**
+     * Retrieves the Boolean value associated with the specified Switch
+     * 
+     * @param trigger a trigger used to lookup the Option
+     * @return the Boolean associated with trigger or null if none exists
+     */
+    Boolean getSwitch(final String trigger);
+    
+    /**
+     * Retrieves the Boolean value associated with the specified Switch
+     * 
+     * @param trigger a trigger used to lookup the Option
+     * @param defaultValue the Boolean to use if none match
+     * @return the Boolean associated with trigger or defaultValue if none exists
+     */
+    Boolean getSwitch(final String trigger, final Boolean defaultValue);
+    
+    /**
+     * Retrieves the Boolean value associated with the specified Switch
+     * 
+     * @param option the Option associated with the value
+     * @return the Boolean associated with option or null if none exists
+     */
+    Boolean getSwitch(final Option option);
+    
+    /**
+     * Retrieves the Boolean value associated with the specified Switch
+     * 
+     * @param option the Option associated with the value
+     * @param defaultValue the Boolean to use if none match
+     * @return the Boolean associated with option or defaultValue if none exists
+     */
+    Boolean getSwitch(final Option option, final Boolean defaultValue);
+    
+    
+    /**
+     * Retrieves the value associated with the specified property 
+     * 
+     * @param property the property name to lookup
+     * @return the value of the property or null
+     */
+    String getProperty(final String property);
+    
+    /**
+     * Retrieves the value associated with the specified property 
+     * 
+     * @param property the property name to lookup
+     * @param defaultValue the value to use if no other is found
+     * @return the value of the property or defaultValue
+     */
+    String getProperty(final String property, final String defaultValue);
+    
+    /**
+     * Retrieves the set of all property names associated with this CommandLine
+     * 
+     * @return a none null set of property names 
+     */
+    Set getProperties();
+    
+    /**
+     * Retrieves the number of times the specified Option appeared in this 
+     * CommandLine
+     * 
+     * @param trigger a trigger used to lookup the Option
+     * @return the number of occurrences of the option
+     */
+    int getOptionCount(final String trigger);
+    
+    /**
+     * Retrieves the number of times the specified Option appeared in this 
+     * CommandLine
+     * 
+     * @param option the Option associated to check
+     * @return the number of occurrences of the option
+     */
+    int getOptionCount(final Option option);
+    
+    /**
+     * Retrieves a list of all Options found in this CommandLine
+     * 
+     * @return a none null list of Options
+     */
+    List getOptions();
+    
+    /**
+     * Retrieves a list of all Option triggers found in this CommandLine
+     * 
+     * @return a none null list of Option triggers
+     */
+    Set getOptionTriggers();
+}

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/DisplaySetting.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/DisplaySetting.java?rev=639943&r1=639942&r2=639943&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/DisplaySetting.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/DisplaySetting.java Fri Mar 21 20:08:23 2008
@@ -1 +1,155 @@
-/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2;import java.util.Collections;import java.util.HashSet;import java.util.Set;/** * An enum of possible display settings. These settings are used to control the * presence o
 f various features in the String representations of options, * CommandLines and usage strings.  Usually a Set of DisplaySetting instances * will be passed to a method that will lookup the presence of the values. */public class DisplaySetting {    private static final Set all = new HashSet();    /**     * A Set guarenteed to contain all possible DisplaySetting values     */    public static final Set ALL = Collections.unmodifiableSet(all);    /**     * A Set guarenteed to contain no DisplaySetting values     */    public static final Set NONE = Collections.EMPTY_SET;    /**     * Indicates that aliases should be included     */    public static final DisplaySetting DISPLAY_ALIASES =        new DisplaySetting("DISPLAY_ALIASES");    /**     * Indicates that optionality should be included     */    public static final DisplaySetting DISPLAY_OPTIONAL =        new DisplaySetting("DISPLAY_OPTIONAL");    /**     * Indicates that property options should be included     */    public s
 tatic final DisplaySetting DISPLAY_PROPERTY_OPTION =        new DisplaySetting("DISPLAY_PROPERTY_OPTION");    /**     * Indicates that switches should be included enabled     */    public static final DisplaySetting DISPLAY_SWITCH_ENABLED =        new DisplaySetting("DISPLAY_SWITCH_ENABLED");    /**     * Indicates that switches should be included disabled     */    public static final DisplaySetting DISPLAY_SWITCH_DISABLED =        new DisplaySetting("DISPLAY_SWITCH_DISABLED");    /**     * Indicates that group names should be included     */    public static final DisplaySetting DISPLAY_GROUP_NAME =        new DisplaySetting("DISPLAY_GROUP_NAME");    /**     * Indicates that groups should be included expanded     */    public static final DisplaySetting DISPLAY_GROUP_EXPANDED =        new DisplaySetting("DISPLAY_GROUP_EXPANDED");    /**     * Indicates that group arguments should be included     */    public static final DisplaySetting DISPLAY_GROUP_ARGUMENT =        new D
 isplaySetting("DISPLAY_GROUP_ARGUMENT");    /**     * Indicates that group outer brackets should be included     */    public static final DisplaySetting DISPLAY_GROUP_OUTER =        new DisplaySetting("DISPLAY_GROUP_OUTER");    /**     * Indicates that arguments should be included numbered     */    public static final DisplaySetting DISPLAY_ARGUMENT_NUMBERED =        new DisplaySetting("DISPLAY_ARGUMENT_NUMBERED");    /**     * Indicates that arguments should be included bracketed     */    public static final DisplaySetting DISPLAY_ARGUMENT_BRACKETED =        new DisplaySetting("DISPLAY_ARGUMENT_BRACKETED");    /**     * Indicates that arguments of Parents should be included     */    public static final DisplaySetting DISPLAY_PARENT_ARGUMENT =        new DisplaySetting("DISPLAY_PARENT_ARGUMENT");    /**     * Indicates that children of Parents should be included     */    public static final DisplaySetting DISPLAY_PARENT_CHILDREN =        new DisplaySetting("DISPLAY_PARE
 NT_CHILDREN");    /**     * The name of the setting     */    private final String name;    /**     * The hashCode of the setting     */    private final int hashCode;    /**     * Creates a new DisplaySetting with the specified name     * @param name the name of the setting     */    private DisplaySetting(final String name) {        this.name = name;        this.hashCode = name.hashCode();        all.add(this);    }    public int hashCode() {        return hashCode;    }    public boolean equals(final Object that) {        if (that instanceof DisplaySetting) {            return name.compareTo(that.toString()) == 0;        }        return false;    }    public String toString() {        return name;    }}
\ No newline at end of file
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli2;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * An enum of possible display settings. These settings are used to control the
+ * presence of various features in the String representations of options,
+ * CommandLines and usage strings.  Usually a Set of DisplaySetting instances
+ * will be passed to a method that will lookup the presence of the values.
+ */
+public class DisplaySetting {
+	
+    private static final Set all = new HashSet();
+
+    /**
+     * A Set guarenteed to contain all possible DisplaySetting values
+     */
+    public static final Set ALL = Collections.unmodifiableSet(all);
+    
+    /**
+     * A Set guarenteed to contain no DisplaySetting values
+     */
+    public static final Set NONE = Collections.EMPTY_SET;
+    
+    /**
+     * Indicates that aliases should be included
+     */
+    public static final DisplaySetting DISPLAY_ALIASES =
+        new DisplaySetting("DISPLAY_ALIASES");
+    
+    /**
+     * Indicates that optionality should be included
+     */
+    public static final DisplaySetting DISPLAY_OPTIONAL =
+        new DisplaySetting("DISPLAY_OPTIONAL");
+    
+    /**
+     * Indicates that property options should be included
+     */
+    public static final DisplaySetting DISPLAY_PROPERTY_OPTION =
+        new DisplaySetting("DISPLAY_PROPERTY_OPTION");
+    
+    /**
+     * Indicates that switches should be included enabled
+     */
+    public static final DisplaySetting DISPLAY_SWITCH_ENABLED =
+        new DisplaySetting("DISPLAY_SWITCH_ENABLED");
+    
+    /**
+     * Indicates that switches should be included disabled
+     */
+    public static final DisplaySetting DISPLAY_SWITCH_DISABLED =
+        new DisplaySetting("DISPLAY_SWITCH_DISABLED");
+    
+    /**
+     * Indicates that group names should be included
+     */
+    public static final DisplaySetting DISPLAY_GROUP_NAME =
+        new DisplaySetting("DISPLAY_GROUP_NAME");
+    
+    /**
+     * Indicates that groups should be included expanded
+     */
+    public static final DisplaySetting DISPLAY_GROUP_EXPANDED =
+        new DisplaySetting("DISPLAY_GROUP_EXPANDED");
+    
+    /**
+     * Indicates that group arguments should be included
+     */
+    public static final DisplaySetting DISPLAY_GROUP_ARGUMENT =
+        new DisplaySetting("DISPLAY_GROUP_ARGUMENT");
+    
+    /**
+     * Indicates that group outer brackets should be included
+     */
+    public static final DisplaySetting DISPLAY_GROUP_OUTER =
+        new DisplaySetting("DISPLAY_GROUP_OUTER");
+    
+    /**
+     * Indicates that arguments should be included numbered
+     */
+    public static final DisplaySetting DISPLAY_ARGUMENT_NUMBERED =
+        new DisplaySetting("DISPLAY_ARGUMENT_NUMBERED");
+    
+    /**
+     * Indicates that arguments should be included bracketed
+     */
+    public static final DisplaySetting DISPLAY_ARGUMENT_BRACKETED =
+        new DisplaySetting("DISPLAY_ARGUMENT_BRACKETED");
+    
+    /**
+     * Indicates that arguments of Parents should be included
+     */
+    public static final DisplaySetting DISPLAY_PARENT_ARGUMENT =
+        new DisplaySetting("DISPLAY_PARENT_ARGUMENT");
+    
+    /**
+     * Indicates that children of Parents should be included
+     */
+    public static final DisplaySetting DISPLAY_PARENT_CHILDREN =
+        new DisplaySetting("DISPLAY_PARENT_CHILDREN");
+    
+    /**
+     * The name of the setting
+     */
+    private final String name;
+    
+    /**
+     * The hashCode of the setting
+     */
+    private final int hashCode;
+
+    /**
+     * Creates a new DisplaySetting with the specified name
+     * @param name the name of the setting
+     */
+    private DisplaySetting(final String name) {
+        this.name = name;
+        this.hashCode = name.hashCode();
+        all.add(this);
+    }
+
+    public int hashCode() {
+        return hashCode;
+    }
+
+    public boolean equals(final Object that) {
+        if (that instanceof DisplaySetting) {
+            return name.compareTo(that.toString()) == 0;
+        }
+        return false;
+    }
+
+    public String toString() {
+        return name;
+    }
+}

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Group.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Group.java?rev=639943&r1=639942&r2=639943&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Group.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Group.java Fri Mar 21 20:08:23 2008
@@ -1 +1,65 @@
-/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2;import java.util.Comparator;import java.util.Set;/** * An Option representing a choice or group of Options in the form "-a|-b|-c". */public interface Group extends Option
  {    /**     * Appends usage information to the specified StringBuffer     *     * @param buffer the buffer to append to     * @param helpSettings a set of display settings @see DisplaySetting     * @param comp a comparator used to sort the Options     * @param separator the String used to separate member Options     */    void appendUsage(        final StringBuffer buffer,        final Set helpSettings,        final Comparator comp,        final String separator);    /**     * Indicates whether group members must be present for the CommandLine to be     * valid.     *     * @see #getMinimum()     * @see #getMaximum()     * @return true iff the CommandLine will be invalid without at least one     *         member option     */    boolean isRequired();    /**     * Retrieves the minimum number of members required for a valid Group     *     * @return the minimum number of members     */    int getMinimum();    /**     * Retrieves the maximum number of members acceptable for 
 a valid Group     *     * @return the maximum number of members     */    int getMaximum();}
\ No newline at end of file
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli2;
+
+import java.util.Comparator;
+import java.util.Set;
+
+/**
+ * An Option representing a choice or group of Options in the form "-a|-b|-c".
+ */
+public interface Group extends Option {
+
+    /**
+     * Appends usage information to the specified StringBuffer
+     * 
+     * @param buffer the buffer to append to
+     * @param helpSettings a set of display settings @see DisplaySetting
+     * @param comp a comparator used to sort the Options
+     * @param separator the String used to separate member Options 
+     */
+    void appendUsage(
+        final StringBuffer buffer,
+        final Set helpSettings,
+        final Comparator comp,
+        final String separator);
+
+    /**
+     * Indicates whether group members must be present for the CommandLine to be
+     * valid.
+     *
+     * @see #getMinimum()
+     * @see #getMaximum()
+     * @return true iff the CommandLine will be invalid without at least one 
+     *         member option
+     */
+    boolean isRequired();
+
+    /**
+     * Retrieves the minimum number of members required for a valid Group
+     *
+     * @return the minimum number of members
+     */
+    int getMinimum();
+
+    /**
+     * Retrieves the maximum number of members acceptable for a valid Group
+     *
+     * @return the maximum number of members
+     */
+    int getMaximum();
+}

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/HelpLine.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/HelpLine.java?rev=639943&r1=639942&r2=639943&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/HelpLine.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/HelpLine.java Fri Mar 21 20:08:23 2008
@@ -1 +1,53 @@
-/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2;import java.util.Comparator;import java.util.Set;/** * Represents a line of help for a particular Option. */public interface HelpLine {    /**     * @return The descripti
 on of the option     */    String getDescription();    /**     * @return The level of indentation for this line     */    int getIndent();    /**     * @return The Option that the help line relates to     */    Option getOption();    /**     * Builds a usage string for the option using the specified settings and     * comparator.     *     * @param helpSettings     *            the settings to apply     * @param comparator     *            a comparator to sort options when applicable     * @return the usage string     */    String usage(final Set helpSettings, final Comparator comparator);}
\ No newline at end of file
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli2;
+
+import java.util.Comparator;
+import java.util.Set;
+
+/**
+ * Represents a line of help for a particular Option.
+ */
+public interface HelpLine {
+
+    /**
+     * @return The description of the option
+     */
+    String getDescription();
+
+    /**
+     * @return The level of indentation for this line
+     */
+    int getIndent();
+
+    /**
+     * @return The Option that the help line relates to
+     */
+    Option getOption();
+
+    /**
+     * Builds a usage string for the option using the specified settings and
+     * comparator.
+     * 
+     * @param helpSettings
+     *            the settings to apply
+     * @param comparator
+     *            a comparator to sort options when applicable
+     * @return the usage string
+     */
+    String usage(final Set helpSettings, final Comparator comparator);
+}
\ No newline at end of file

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java?rev=639943&r1=639942&r2=639943&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java Fri Mar 21 20:08:23 2008
@@ -1 +1,197 @@
-/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2;import java.util.Comparator;import java.util.List;import java.util.ListIterator;import java.util.Set;/** * The super type of all options representing a particular element 
 of the * command line interface. */public interface Option {    /**     * Processes String arguments into a CommandLine.     *     * The iterator will initially point at the first argument to be processed     * and at the end of the method should point to the first argument not     * processed. This method MUST process at least one argument from the     * ListIterator.     *     * @param commandLine     *            The CommandLine object to store results in     * @param args     *            The arguments to process     * @throws OptionException     *             if any problems occur     */    void process(        final WriteableCommandLine commandLine,        final ListIterator args)        throws OptionException;    /**     * Adds defaults to a CommandLine.     *     * Any defaults for this option are applied as well as the defaults for     * any contained options     *     * @param commandLine     *            The CommandLine object to store defaults in     */    void d
 efaults(final WriteableCommandLine commandLine);    /**     * Indicates whether this Option will be able to process the particular     * argument.     *     * @param argument     *            The argument to be tested     * @return true if the argument can be processed by this Option     */    boolean canProcess(final WriteableCommandLine commandLine, final String argument);    /**     * Indicates whether this Option will be able to process the particular     * argument. The ListIterator must be restored to the initial state before     * returning the boolean.     *     * @see #canProcess(WriteableCommandLine,String)     * @param arguments     *            the ListIterator over String arguments     * @return true if the argument can be processed by this Option     */    boolean canProcess(final WriteableCommandLine commandLine, final ListIterator arguments);    /**     * Identifies the argument prefixes that should trigger this option. This     * is used to decide which of m
 any Options should be tried when processing     * a given argument string.     *     * The returned Set must not be null.     *     * @return The set of triggers for this Option     */    Set getTriggers();    /**     * Identifies the argument prefixes that should be considered options. This     * is used to identify whether a given string looks like an option or an     * argument value. Typically an option would return the set [--,-] while     * switches might offer [-,+].     *     * The returned Set must not be null.     *     * @return The set of prefixes for this Option     */    Set getPrefixes();    /**     * Checks that the supplied CommandLine is valid with respect to this     * option.     *     * @param commandLine     *            The CommandLine to check.     * @throws OptionException     *             if the CommandLine is not valid.     */    void validate(final WriteableCommandLine commandLine)        throws OptionException;    /**     * Builds up a list of H
 elpLineImpl instances to be presented by HelpFormatter.     *     * @see HelpLine     * @see org.apache.commons.cli2.util.HelpFormatter     * @param depth     *            the initial indent depth     * @param helpSettings     *            the HelpSettings that should be applied     * @param comp     *            a comparator used to sort options when applicable.     * @return a List of HelpLineImpl objects     */    List helpLines(        final int depth,        final Set helpSettings,        final Comparator comp);    /**     * Appends usage information to the specified StringBuffer     *     * @param buffer the buffer to append to     * @param helpSettings a set of display settings @see DisplaySetting     * @param comp a comparator used to sort the Options     */    void appendUsage(        final StringBuffer buffer,        final Set helpSettings,        final Comparator comp);    /**     * The preferred name of an option is used for generating help and usage     * inform
 ation.     *     * @return The preferred name of the option     */    String getPreferredName();    /**     * Returns a description of the option. This string is used to build help     * messages as in the HelpFormatter.     *     * @see org.apache.commons.cli2.util.HelpFormatter     * @return a description of the option.     */    String getDescription();    /**     * Returns the id of the option.  This can be used in a loop and switch     * construct:     *     * <code>     * for(Option o : cmd.getOptions()){     *     switch(o.getId()){     *         case POTENTIAL_OPTION:     *             ...     *     }     * }     * </code>     *     * The returned value is not guarenteed to be unique.     *     * @return the id of the option.     */    int getId();	/**	 * Recursively searches for an option with the supplied trigger.	 *	 * @param trigger the trigger to search for.	 * @return the matching option or null.	 */	Option findOption(final String trigger);    /**     * Indicat
 es whether this option is required to be present.     * @return true iff the CommandLine will be invalid without this Option     */    boolean isRequired();}
\ No newline at end of file
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli2;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Set;
+
+/**
+ * The super type of all options representing a particular element of the
+ * command line interface.
+ */
+public interface Option {
+
+    /**
+     * Processes String arguments into a CommandLine.
+     * 
+     * The iterator will initially point at the first argument to be processed
+     * and at the end of the method should point to the first argument not
+     * processed. This method MUST process at least one argument from the
+     * ListIterator.
+     * 
+     * @param commandLine
+     *            The CommandLine object to store results in
+     * @param args
+     *            The arguments to process
+     * @throws OptionException
+     *             if any problems occur
+     */
+    void process(
+        final WriteableCommandLine commandLine,
+        final ListIterator args)
+        throws OptionException;
+    
+    /**
+     * Adds defaults to a CommandLine.
+     * 
+     * Any defaults for this option are applied as well as the defaults for 
+     * any contained options
+     * 
+     * @param commandLine
+     *            The CommandLine object to store defaults in
+     */
+    void defaults(final WriteableCommandLine commandLine);
+
+    /**
+     * Indicates whether this Option will be able to process the particular
+     * argument.
+     * 
+     * @param argument
+     *            The argument to be tested
+     * @return true if the argument can be processed by this Option
+     */
+    boolean canProcess(final WriteableCommandLine commandLine, final String argument);
+
+    /**
+     * Indicates whether this Option will be able to process the particular
+     * argument. The ListIterator must be restored to the initial state before
+     * returning the boolean.
+     * 
+     * @see #canProcess(WriteableCommandLine,String)
+     * @param arguments
+     *            the ListIterator over String arguments
+     * @return true if the argument can be processed by this Option
+     */
+    boolean canProcess(final WriteableCommandLine commandLine, final ListIterator arguments);
+
+    /**
+     * Identifies the argument prefixes that should trigger this option. This
+     * is used to decide which of many Options should be tried when processing
+     * a given argument string.
+     * 
+     * The returned Set must not be null.
+     * 
+     * @return The set of triggers for this Option
+     */
+    Set getTriggers();
+
+    /**
+     * Identifies the argument prefixes that should be considered options. This
+     * is used to identify whether a given string looks like an option or an
+     * argument value. Typically an option would return the set [--,-] while
+     * switches might offer [-,+].
+     * 
+     * The returned Set must not be null.
+     * 
+     * @return The set of prefixes for this Option
+     */
+    Set getPrefixes();
+
+    /**
+     * Checks that the supplied CommandLine is valid with respect to this
+     * option.
+     * 
+     * @param commandLine
+     *            The CommandLine to check.
+     * @throws OptionException
+     *             if the CommandLine is not valid.
+     */
+    void validate(final WriteableCommandLine commandLine)
+        throws OptionException;
+
+    /**
+     * Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.
+     * 
+     * @see HelpLine
+     * @see org.apache.commons.cli2.util.HelpFormatter
+     * @param depth
+     *            the initial indent depth
+     * @param helpSettings
+     *            the HelpSettings that should be applied
+     * @param comp
+     *            a comparator used to sort options when applicable.
+     * @return a List of HelpLineImpl objects
+     */
+    List helpLines(
+        final int depth,
+        final Set helpSettings,
+        final Comparator comp);
+
+    /**
+     * Appends usage information to the specified StringBuffer
+     * 
+     * @param buffer the buffer to append to
+     * @param helpSettings a set of display settings @see DisplaySetting
+     * @param comp a comparator used to sort the Options
+     */
+    void appendUsage(
+        final StringBuffer buffer,
+        final Set helpSettings,
+        final Comparator comp);
+
+    /**
+     * The preferred name of an option is used for generating help and usage
+     * information.
+     * 
+     * @return The preferred name of the option
+     */
+    String getPreferredName();
+
+    /**
+     * Returns a description of the option. This string is used to build help
+     * messages as in the HelpFormatter.
+     * 
+     * @see org.apache.commons.cli2.util.HelpFormatter
+     * @return a description of the option.
+     */
+    String getDescription();
+
+    /**
+     * Returns the id of the option.  This can be used in a loop and switch 
+     * construct:
+     * 
+     * <code>
+     * for(Option o : cmd.getOptions()){
+     *     switch(o.getId()){
+     *         case POTENTIAL_OPTION:
+     *             ...
+     *     }
+     * }
+     * </code> 
+     * 
+     * The returned value is not guarenteed to be unique.
+     * 
+     * @return the id of the option.
+     */
+    int getId();
+
+	/**
+	 * Recursively searches for an option with the supplied trigger.
+	 *
+	 * @param trigger the trigger to search for.
+	 * @return the matching option or null.
+	 */
+	Option findOption(final String trigger);
+
+    /**
+     * Indicates whether this option is required to be present.
+     * @return true iff the CommandLine will be invalid without this Option
+     */
+    boolean isRequired();
+}

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/OptionException.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/OptionException.java?rev=639943&r1=639942&r2=639943&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/OptionException.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/OptionException.java Fri Mar 21 20:08:23 2008
@@ -1 +1,107 @@
-/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2;import java.util.Collections;import java.util.Set;import org.apache.commons.cli2.resource.ResourceHelper;/** * A problem found while dealing with command line options. */p
 ublic class OptionException    extends Exception {    /**     * The settings used when displaying the related Option.     *     * @see DisplaySetting     */    public static final Set HELP_SETTINGS =        Collections.unmodifiableSet(Collections.singleton(DisplaySetting.DISPLAY_PROPERTY_OPTION));    /** resource helper instance */    private static final ResourceHelper helper = ResourceHelper.getResourceHelper();    /** The Option the exception relates to */    private final Option option;    /** The message explaining the Exception */    private final String message;    /**     * Creates a new OptionException.     *     * @param option     *            The Option the exception relates to     */    public OptionException(final Option option) {        this(option, null, null);    }    /**     * Creates a new OptionException.     * @param option the Option the exception relates to     * @param messageKey the id of the message to display     */    public OptionException(final 
 Option option,                           final String messageKey) {        this(option, messageKey, null);    }    /**     * Creates a new OptionException.     * @param option the Option the exception relates to     * @param messageKey the id of the message to display     * @param value a value to display with the message     */    public OptionException(final Option option,                           final String messageKey,                           final String value) {        this.option = option;        if (messageKey != null) {            final StringBuffer buffer = new StringBuffer();            if (value != null) {                buffer.append(helper.getMessage(messageKey, value));            } else {                buffer.append(helper.getMessage(messageKey));            }            buffer.append(" ");            option.appendUsage(buffer, HELP_SETTINGS, null);            message = buffer.toString();        } else {            message = "";        }    }    /**     
 * Gets the Option the exception relates to     *     * @return The related Option     */    public Option getOption() {        return option;    }    public String getMessage() {        return message;    }}
\ No newline at end of file
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli2;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.commons.cli2.resource.ResourceHelper;
+
+/**
+ * A problem found while dealing with command line options.
+ */
+public class OptionException
+    extends Exception {
+    /**
+     * The settings used when displaying the related Option.
+     *
+     * @see DisplaySetting
+     */
+    public static final Set HELP_SETTINGS =
+        Collections.unmodifiableSet(Collections.singleton(DisplaySetting.DISPLAY_PROPERTY_OPTION));
+
+    /** resource helper instance */
+    private static final ResourceHelper helper = ResourceHelper.getResourceHelper();
+
+    /** The Option the exception relates to */
+    private final Option option;
+
+    /** The message explaining the Exception */
+    private final String message;
+
+    /**
+     * Creates a new OptionException.
+     *
+     * @param option
+     *            The Option the exception relates to
+     */
+    public OptionException(final Option option) {
+        this(option, null, null);
+    }
+
+    /**
+     * Creates a new OptionException.
+     * @param option the Option the exception relates to
+     * @param messageKey the id of the message to display
+     */
+    public OptionException(final Option option,
+                           final String messageKey) {
+        this(option, messageKey, null);
+    }
+
+    /**
+     * Creates a new OptionException.
+     * @param option the Option the exception relates to
+     * @param messageKey the id of the message to display
+     * @param value a value to display with the message
+     */
+    public OptionException(final Option option,
+                           final String messageKey,
+                           final String value) {
+        this.option = option;
+
+        if (messageKey != null) {
+            final StringBuffer buffer = new StringBuffer();
+
+            if (value != null) {
+                buffer.append(helper.getMessage(messageKey, value));
+            } else {
+                buffer.append(helper.getMessage(messageKey));
+            }
+
+            buffer.append(" ");
+
+            option.appendUsage(buffer, HELP_SETTINGS, null);
+            message = buffer.toString();
+        } else {
+            message = "";
+        }
+    }
+
+    /**
+     * Gets the Option the exception relates to
+     *
+     * @return The related Option
+     */
+    public Option getOption() {
+        return option;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+}

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Parent.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Parent.java?rev=639943&r1=639942&r2=639943&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Parent.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Parent.java Fri Mar 21 20:08:23 2008
@@ -1 +1,41 @@
-/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2;import java.util.ListIterator;/** * An Option that can have an argument and/or group of child Options in the form * "-f &lt;arg&gt; [-a|-b|-c]". */public interface Parent
  extends Option {    /**     * Processes the parent part of the Option.  The combination of parent,     * argument and children is handled by the process method.     * @see Option#process(WriteableCommandLine, ListIterator)     *     * @param commandLine the CommandLine to write results to     * @param args a ListIterator over argument strings positioned at the next     *             argument to process     * @throws OptionException if an error occurs while processing     */    void processParent(        final WriteableCommandLine commandLine,        final ListIterator args)        throws OptionException;}
\ No newline at end of file
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli2;
+
+import java.util.ListIterator;
+
+/**
+ * An Option that can have an argument and/or group of child Options in the form 
+ * "-f &lt;arg&gt; [-a|-b|-c]".
+ */
+public interface Parent extends Option {
+
+    /**
+     * Processes the parent part of the Option.  The combination of parent,
+     * argument and children is handled by the process method.
+     * @see Option#process(WriteableCommandLine, ListIterator)
+     * 
+     * @param commandLine the CommandLine to write results to
+     * @param args a ListIterator over argument strings positioned at the next
+     *             argument to process
+     * @throws OptionException if an error occurs while processing
+     */
+    void processParent(
+        final WriteableCommandLine commandLine,
+        final ListIterator args)
+        throws OptionException;
+}

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/WriteableCommandLine.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/WriteableCommandLine.java?rev=639943&r1=639942&r2=639943&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/WriteableCommandLine.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/WriteableCommandLine.java Fri Mar 21 20:08:23 2008
@@ -1 +1,76 @@
-/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2;import java.util.List;/** * A CommandLine that detected values and options can be written to. */public interface WriteableCommandLine extends CommandLine {    /**     * A
 dds an Option to the CommandLine     * @param option the Option to add     */    void addOption(final Option option);    /**     * Adds a value to an Option in the CommandLine.     * @param option the Option to add to     * @param value the value to add     */    void addValue(final Option option, final Object value);    /**     * Sets the default values for an Option in the CommandLine     * @param option the Option to add to     * @param defaultValues the defaults for the option     */    void setDefaultValues(final Option option, final List defaultValues);    /**     * Adds a switch value to an Option in the CommandLine.     * @param option the Option to add to     * @param value the switch value to add     * @throws IllegalStateException if the switch has already been added     */    void addSwitch(final Option option, final boolean value) throws IllegalStateException;    /**     * Sets the default state for a Switch in the CommandLine.     * @param option the Option to 
 add to     * @param defaultSwitch the defaults state for ths switch     */    void setDefaultSwitch(final Option option, final Boolean defaultSwitch);    /**     * Adds a property value to a name in the CommandLine.     * Replaces any existing value for the property.     *     * @param property the name of the property     * @param value the value of the property     */    void addProperty(final String property, final String value);    /**     * Detects whether the argument looks like an Option trigger     * @param argument the argument to test     * @return true if the argument looks like an Option trigger     */    boolean looksLikeOption(final String argument);}
\ No newline at end of file
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli2;
+
+import java.util.List;
+
+/**
+ * A CommandLine that detected values and options can be written to.
+ */
+public interface WriteableCommandLine extends CommandLine {
+    
+    /**
+     * Adds an Option to the CommandLine
+     * @param option the Option to add
+     */
+    void addOption(final Option option);
+    
+    /**
+     * Adds a value to an Option in the CommandLine.
+     * @param option the Option to add to
+     * @param value the value to add
+     */
+    void addValue(final Option option, final Object value);
+
+    /**
+     * Sets the default values for an Option in the CommandLine
+     * @param option the Option to add to
+     * @param defaultValues the defaults for the option
+     */
+    void setDefaultValues(final Option option, final List defaultValues);
+    
+    /**
+     * Adds a switch value to an Option in the CommandLine.
+     * @param option the Option to add to
+     * @param value the switch value to add
+     * @throws IllegalStateException if the switch has already been added
+     */
+    void addSwitch(final Option option, final boolean value) throws IllegalStateException;
+    
+    /**
+     * Sets the default state for a Switch in the CommandLine.
+     * @param option the Option to add to
+     * @param defaultSwitch the defaults state for ths switch
+     */
+    void setDefaultSwitch(final Option option, final Boolean defaultSwitch);
+    
+    /**
+     * Adds a property value to a name in the CommandLine.
+     * Replaces any existing value for the property.
+     * 
+     * @param property the name of the property
+     * @param value the value of the property
+     */
+    void addProperty(final String property, final String value);
+    
+    /**
+     * Detects whether the argument looks like an Option trigger 
+     * @param argument the argument to test
+     * @return true if the argument looks like an Option trigger
+     */
+    boolean looksLikeOption(final String argument);
+}



Mime
View raw message