roxspring 2004/02/17 13:14:14
Modified: cli/src/java/org/apache/commons/cli2/commandline Tag:
RESEARCH_CLI_2_ROXSPRING CommandLineImpl.java
cli/src/java/org/apache/commons/cli2 Tag:
RESEARCH_CLI_2_ROXSPRING CommandLine.java
cli/src/test/org/apache/commons/cli2/impl Tag:
RESEARCH_CLI_2_ROXSPRING OptionTestCase.java
cli/src/test/org/apache/commons/cli2 Tag:
RESEARCH_CLI_2_ROXSPRING
CommandLineDefaultsTest.java
Added: cli/src/java/org/apache/commons/cli2/commandline Tag:
RESEARCH_CLI_2_ROXSPRING
WriteableCommandLineImpl.java
Log:
CommandLineImpl refactoring
Removed toString() from CommandLine
Added getProperty(prop,default) for completeness
Split CommandLineImpl into CommandLineImpl and WriteableCommandLineImpl
Revision Changes Path
No revision
No revision
1.1.2.4 +19 -221
jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/CommandLineImpl.java
Index: CommandLineImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/CommandLineImpl.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- CommandLineImpl.java 8 Feb 2004 13:09:00 -0000 1.1.2.3
+++ CommandLineImpl.java 17 Feb 2004 21:14:14 -0000 1.1.2.4
@@ -36,127 +36,37 @@
*
* @since 1.0
*/
-public class CommandLineImpl implements WriteableCommandLine {
+public abstract class CommandLineImpl implements CommandLine {
- private final Properties properties = new Properties();
- private final List options = new ArrayList();
- private final Map nameToOption = new HashMap();
- private final Map values = new HashMap();
- private final Map switches = new HashMap();
- private final Map defaults = new HashMap();
- private final List normalised;
- private final Set prefixes;
-
- private CommandLine defaultCommandLine = null;
-
- public CommandLineImpl(final Option rootOption, final List arguments) {
- this.prefixes = rootOption.getPrefixes();
- this.normalised = arguments;
- }
-
- public void addOption(Option option) {
- options.add(option);
- nameToOption.put(option.getPreferredName(), option);
- for (Iterator i = option.getTriggers().iterator(); i.hasNext();) {
- nameToOption.put(i.next(), option);
- }
- }
-
- public void addValue(final Option option, final Object value) {
- if (option instanceof Argument) {
- addOption(option);
- }
- List valueList = (List)values.get(option);
- if (valueList == null) {
- valueList = new ArrayList();
- values.put(option, valueList);
- }
- valueList.add(value);
- }
-
- public void addSwitch(final Option option, final boolean value) {
- addOption(option);
- if (switches.containsKey(option)) {
- throw new IllegalStateException("Switch already set");
- }
- else {
- switches.put(option, value ? Boolean.TRUE : Boolean.FALSE);
- }
- }
-
- public boolean hasOption(final String trigger) {
+ public final boolean hasOption(final String trigger) {
return hasOption(getOption(trigger));
}
- public boolean hasOption(final Option option) {
- final boolean present = options.contains(option);
- if (!present && defaultCommandLine != null) {
- return defaultCommandLine.hasOption(option);
- }
- else {
- return present;
- }
- }
-
- public Option getOption(final String trigger) {
- return (Option)nameToOption.get(trigger);
- }
-
- public List getValues(final String trigger) {
- return getValues(getOption(trigger));
+ public final List getValues(final String trigger) {
+ return getValues(getOption(trigger),null);
}
- public List getValues(final String trigger, final List defaultValues) {
+ public final List getValues(final String trigger, final List defaultValues) {
return getValues(getOption(trigger), defaultValues);
}
- public List getValues(final Option option) {
+ public final List getValues(final Option option) {
return getValues(option, null);
}
- //TODO Document the order of values and defaults
- public List getValues(final Option option, final List defaultValues) {
-
- // First grab the command line values
- List valueList = (List)values.get(option);
-
- // Secondly try alternate CommandLines
- if ((valueList == null || valueList.isEmpty())
- && defaultCommandLine != null) {
- valueList = defaultCommandLine.getValues(option, null);
- }
-
- // Thirdly try the defaults supplied to the method
- if (valueList == null || valueList.isEmpty()) {
- valueList = defaultValues;
- }
-
- // Fourthly try the option's default values
- if (valueList == null || valueList.isEmpty()) {
- valueList = (List)this.defaults.get(option);
- }
-
- // Finally use an empty list
- if (valueList == null) {
- valueList = Collections.EMPTY_LIST;
- }
-
- return valueList;
- }
-
- public Object getValue(final String trigger) {
- return getValue(getOption(trigger));
+ public final Object getValue(final String trigger) {
+ return getValue(getOption(trigger),null);
}
- public Object getValue(final String trigger, final Object defaultValue) {
+ public final Object getValue(final String trigger, final Object defaultValue) {
return getValue(getOption(trigger), defaultValue);
}
- public Object getValue(final Option option) {
+ public final Object getValue(final Option option) {
return getValue(option, null);
}
- public Object getValue(final Option option, final Object defaultValue) {
+ public final Object getValue(final Option option, final Object defaultValue) {
final List values;
if (defaultValue == null) {
@@ -177,152 +87,40 @@
return values.get(0);
}
- public Boolean getSwitch(final String trigger) {
+ public final Boolean getSwitch(final String trigger) {
return getSwitch(getOption(trigger), null);
}
- public Boolean getSwitch(
+ public final Boolean getSwitch(
final String trigger,
final Boolean defaultValue) {
return getSwitch(getOption(trigger), defaultValue);
}
- public Boolean getSwitch(final Option option) {
+ public final Boolean getSwitch(final Option option) {
return getSwitch(option, null);
}
- public Boolean getSwitch(final Option option, final Boolean defaultValue) {
- // First grab the command line values
- Boolean bool = (Boolean)switches.get(option);
-
- // Secondly try alternate CommandLines
- if (bool == null && defaultCommandLine != null) {
- bool = defaultCommandLine.getSwitch(option);
- }
-
- // Thirdly try the defaults supplied to the method
- if (bool == null) {
- bool = defaultValue;
- }
-
- // Fourthly try the option's default values
- //????
-
- return bool;
+ public final String getProperty(final String property) {
+ return getProperty(property,null);
}
- public void addProperty(final String property, final String value) {
- properties.setProperty(property, value);
- }
-
- public String getProperty(final String property) {
- final String value = properties.getProperty(property);
- if (value == null && defaultCommandLine != null) {
- return defaultCommandLine.getProperty(property);
- }
- else {
- return value;
- }
- }
-
- public Set getProperties() {
- if (defaultCommandLine == null) {
- return Collections.unmodifiableSet(properties.keySet());
- }
- else {
- final Set props = new HashSet();
- props.addAll(properties.keySet());
- props.addAll(defaultCommandLine.getProperties());
- return Collections.unmodifiableSet(props);
- }
- }
-
- public List getNormalised() {
- return Collections.unmodifiableList(normalised);
- }
-
- public boolean looksLikeOption(final String trigger) {
- for (final Iterator i = prefixes.iterator(); i.hasNext();) {
- final String prefix = (String)i.next();
- if (trigger.startsWith(prefix)) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- final StringBuffer buffer = new StringBuffer();
-
- // need to add group header
-
- for (final Iterator i = normalised.iterator(); i.hasNext();) {
- final String arg = (String)i.next();
- if (arg.indexOf(' ') >= 0) {
- buffer.append("\"").append(arg).append("\"");
- }
- else {
- buffer.append(arg);
- }
- if (i.hasNext()) {
- buffer.append(' ');
- }
- }
-
- return buffer.toString();
- }
-
- public int getOptionCount(final String trigger) {
+ public final int getOptionCount(final String trigger) {
return getOptionCount(getOption(trigger));
}
- public int getOptionCount(final Option option) {
+ public final int getOptionCount(final Option option) {
if (option == null) {
return 0;
}
int count = 0;
- for (Iterator i = options.iterator(); i.hasNext();) {
+ for (Iterator i = getOptions().iterator(); i.hasNext();) {
if (option.equals(i.next())) {
++count;
}
}
return count;
- }
-
- public void setDefaultValues(final Option option, final List values) {
- this.defaults.put(option, values);
- }
-
- public List getOptions() {
- return Collections.unmodifiableList(options);
- }
-
- public Set getOptionTriggers() {
- return Collections.unmodifiableSet(nameToOption.keySet());
- }
-
- public CommandLine getDefaultCommandLine() {
- return defaultCommandLine;
- }
-
- public void setDefaultCommandLine(final CommandLine newCommandLine) {
- this.defaultCommandLine = newCommandLine;
- }
-
- public void addDefaultCommandLine(final CommandLine added) {
- if (defaultCommandLine == null) {
- defaultCommandLine = added;
- }
- else {
- defaultCommandLine.addDefaultCommandLine(added);
- }
- }
-
- public void pushDefaultCommandLine(final CommandLine pushed) {
- pushed.addDefaultCommandLine(defaultCommandLine);
- defaultCommandLine = pushed;
}
}
No revision
Index: CommandLineImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/CommandLineImpl.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- CommandLineImpl.java 8 Feb 2004 13:09:00 -0000 1.1.2.3
+++ CommandLineImpl.java 17 Feb 2004 21:14:14 -0000 1.1.2.4
@@ -36,127 +36,37 @@
*
* @since 1.0
*/
-public class CommandLineImpl implements WriteableCommandLine {
+public abstract class CommandLineImpl implements CommandLine {
- private final Properties properties = new Properties();
- private final List options = new ArrayList();
- private final Map nameToOption = new HashMap();
- private final Map values = new HashMap();
- private final Map switches = new HashMap();
- private final Map defaults = new HashMap();
- private final List normalised;
- private final Set prefixes;
-
- private CommandLine defaultCommandLine = null;
-
- public CommandLineImpl(final Option rootOption, final List arguments) {
- this.prefixes = rootOption.getPrefixes();
- this.normalised = arguments;
- }
-
- public void addOption(Option option) {
- options.add(option);
- nameToOption.put(option.getPreferredName(), option);
- for (Iterator i = option.getTriggers().iterator(); i.hasNext();) {
- nameToOption.put(i.next(), option);
- }
- }
-
- public void addValue(final Option option, final Object value) {
- if (option instanceof Argument) {
- addOption(option);
- }
- List valueList = (List)values.get(option);
- if (valueList == null) {
- valueList = new ArrayList();
- values.put(option, valueList);
- }
- valueList.add(value);
- }
-
- public void addSwitch(final Option option, final boolean value) {
- addOption(option);
- if (switches.containsKey(option)) {
- throw new IllegalStateException("Switch already set");
- }
- else {
- switches.put(option, value ? Boolean.TRUE : Boolean.FALSE);
- }
- }
-
- public boolean hasOption(final String trigger) {
+ public final boolean hasOption(final String trigger) {
return hasOption(getOption(trigger));
}
- public boolean hasOption(final Option option) {
- final boolean present = options.contains(option);
- if (!present && defaultCommandLine != null) {
- return defaultCommandLine.hasOption(option);
- }
- else {
- return present;
- }
- }
-
- public Option getOption(final String trigger) {
- return (Option)nameToOption.get(trigger);
- }
-
- public List getValues(final String trigger) {
- return getValues(getOption(trigger));
+ public final List getValues(final String trigger) {
+ return getValues(getOption(trigger),null);
}
- public List getValues(final String trigger, final List defaultValues) {
+ public final List getValues(final String trigger, final List defaultValues) {
return getValues(getOption(trigger), defaultValues);
}
- public List getValues(final Option option) {
+ public final List getValues(final Option option) {
return getValues(option, null);
}
- //TODO Document the order of values and defaults
- public List getValues(final Option option, final List defaultValues) {
-
- // First grab the command line values
- List valueList = (List)values.get(option);
-
- // Secondly try alternate CommandLines
- if ((valueList == null || valueList.isEmpty())
- && defaultCommandLine != null) {
- valueList = defaultCommandLine.getValues(option, null);
- }
-
- // Thirdly try the defaults supplied to the method
- if (valueList == null || valueList.isEmpty()) {
- valueList = defaultValues;
- }
-
- // Fourthly try the option's default values
- if (valueList == null || valueList.isEmpty()) {
- valueList = (List)this.defaults.get(option);
- }
-
- // Finally use an empty list
- if (valueList == null) {
- valueList = Collections.EMPTY_LIST;
- }
-
- return valueList;
- }
-
- public Object getValue(final String trigger) {
- return getValue(getOption(trigger));
+ public final Object getValue(final String trigger) {
+ return getValue(getOption(trigger),null);
}
- public Object getValue(final String trigger, final Object defaultValue) {
+ public final Object getValue(final String trigger, final Object defaultValue) {
return getValue(getOption(trigger), defaultValue);
}
- public Object getValue(final Option option) {
+ public final Object getValue(final Option option) {
return getValue(option, null);
}
- public Object getValue(final Option option, final Object defaultValue) {
+ public final Object getValue(final Option option, final Object defaultValue) {
final List values;
if (defaultValue == null) {
@@ -177,152 +87,40 @@
return values.get(0);
}
- public Boolean getSwitch(final String trigger) {
+ public final Boolean getSwitch(final String trigger) {
return getSwitch(getOption(trigger), null);
}
- public Boolean getSwitch(
+ public final Boolean getSwitch(
final String trigger,
final Boolean defaultValue) {
return getSwitch(getOption(trigger), defaultValue);
}
- public Boolean getSwitch(final Option option) {
+ public final Boolean getSwitch(final Option option) {
return getSwitch(option, null);
}
- public Boolean getSwitch(final Option option, final Boolean defaultValue) {
- // First grab the command line values
- Boolean bool = (Boolean)switches.get(option);
-
- // Secondly try alternate CommandLines
- if (bool == null && defaultCommandLine != null) {
- bool = defaultCommandLine.getSwitch(option);
- }
-
- // Thirdly try the defaults supplied to the method
- if (bool == null) {
- bool = defaultValue;
- }
-
- // Fourthly try the option's default values
- //????
-
- return bool;
+ public final String getProperty(final String property) {
+ return getProperty(property,null);
}
- public void addProperty(final String property, final String value) {
- properties.setProperty(property, value);
- }
-
- public String getProperty(final String property) {
- final String value = properties.getProperty(property);
- if (value == null && defaultCommandLine != null) {
- return defaultCommandLine.getProperty(property);
- }
- else {
- return value;
- }
- }
-
- public Set getProperties() {
- if (defaultCommandLine == null) {
- return Collections.unmodifiableSet(properties.keySet());
- }
- else {
- final Set props = new HashSet();
- props.addAll(properties.keySet());
- props.addAll(defaultCommandLine.getProperties());
- return Collections.unmodifiableSet(props);
- }
- }
-
- public List getNormalised() {
- return Collections.unmodifiableList(normalised);
- }
-
- public boolean looksLikeOption(final String trigger) {
- for (final Iterator i = prefixes.iterator(); i.hasNext();) {
- final String prefix = (String)i.next();
- if (trigger.startsWith(prefix)) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- final StringBuffer buffer = new StringBuffer();
-
- // need to add group header
-
- for (final Iterator i = normalised.iterator(); i.hasNext();) {
- final String arg = (String)i.next();
- if (arg.indexOf(' ') >= 0) {
- buffer.append("\"").append(arg).append("\"");
- }
- else {
- buffer.append(arg);
- }
- if (i.hasNext()) {
- buffer.append(' ');
- }
- }
-
- return buffer.toString();
- }
-
- public int getOptionCount(final String trigger) {
+ public final int getOptionCount(final String trigger) {
return getOptionCount(getOption(trigger));
}
- public int getOptionCount(final Option option) {
+ public final int getOptionCount(final Option option) {
if (option == null) {
return 0;
}
int count = 0;
- for (Iterator i = options.iterator(); i.hasNext();) {
+ for (Iterator i = getOptions().iterator(); i.hasNext();) {
if (option.equals(i.next())) {
++count;
}
}
return count;
- }
-
- public void setDefaultValues(final Option option, final List values) {
- this.defaults.put(option, values);
- }
-
- public List getOptions() {
- return Collections.unmodifiableList(options);
- }
-
- public Set getOptionTriggers() {
- return Collections.unmodifiableSet(nameToOption.keySet());
- }
-
- public CommandLine getDefaultCommandLine() {
- return defaultCommandLine;
- }
-
- public void setDefaultCommandLine(final CommandLine newCommandLine) {
- this.defaultCommandLine = newCommandLine;
- }
-
- public void addDefaultCommandLine(final CommandLine added) {
- if (defaultCommandLine == null) {
- defaultCommandLine = added;
- }
- else {
- defaultCommandLine.addDefaultCommandLine(added);
- }
- }
-
- public void pushDefaultCommandLine(final CommandLine pushed) {
- pushed.addDefaultCommandLine(defaultCommandLine);
- defaultCommandLine = pushed;
}
}
No revision
Index: CommandLineImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/CommandLineImpl.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- CommandLineImpl.java 8 Feb 2004 13:09:00 -0000 1.1.2.3
+++ CommandLineImpl.java 17 Feb 2004 21:14:14 -0000 1.1.2.4
@@ -36,127 +36,37 @@
*
* @since 1.0
*/
-public class CommandLineImpl implements WriteableCommandLine {
+public abstract class CommandLineImpl implements CommandLine {
- private final Properties properties = new Properties();
- private final List options = new ArrayList();
- private final Map nameToOption = new HashMap();
- private final Map values = new HashMap();
- private final Map switches = new HashMap();
- private final Map defaults = new HashMap();
- private final List normalised;
- private final Set prefixes;
-
- private CommandLine defaultCommandLine = null;
-
- public CommandLineImpl(final Option rootOption, final List arguments) {
- this.prefixes = rootOption.getPrefixes();
- this.normalised = arguments;
- }
-
- public void addOption(Option option) {
- options.add(option);
- nameToOption.put(option.getPreferredName(), option);
- for (Iterator i = option.getTriggers().iterator(); i.hasNext();) {
- nameToOption.put(i.next(), option);
- }
- }
-
- public void addValue(final Option option, final Object value) {
- if (option instanceof Argument) {
- addOption(option);
- }
- List valueList = (List)values.get(option);
- if (valueList == null) {
- valueList = new ArrayList();
- values.put(option, valueList);
- }
- valueList.add(value);
- }
-
- public void addSwitch(final Option option, final boolean value) {
- addOption(option);
- if (switches.containsKey(option)) {
- throw new IllegalStateException("Switch already set");
- }
- else {
- switches.put(option, value ? Boolean.TRUE : Boolean.FALSE);
- }
- }
-
- public boolean hasOption(final String trigger) {
+ public final boolean hasOption(final String trigger) {
return hasOption(getOption(trigger));
}
- public boolean hasOption(final Option option) {
- final boolean present = options.contains(option);
- if (!present && defaultCommandLine != null) {
- return defaultCommandLine.hasOption(option);
- }
- else {
- return present;
- }
- }
-
- public Option getOption(final String trigger) {
- return (Option)nameToOption.get(trigger);
- }
-
- public List getValues(final String trigger) {
- return getValues(getOption(trigger));
+ public final List getValues(final String trigger) {
+ return getValues(getOption(trigger),null);
}
- public List getValues(final String trigger, final List defaultValues) {
+ public final List getValues(final String trigger, final List defaultValues) {
return getValues(getOption(trigger), defaultValues);
}
- public List getValues(final Option option) {
+ public final List getValues(final Option option) {
return getValues(option, null);
}
- //TODO Document the order of values and defaults
- public List getValues(final Option option, final List defaultValues) {
-
- // First grab the command line values
- List valueList = (List)values.get(option);
-
- // Secondly try alternate CommandLines
- if ((valueList == null || valueList.isEmpty())
- && defaultCommandLine != null) {
- valueList = defaultCommandLine.getValues(option, null);
- }
-
- // Thirdly try the defaults supplied to the method
- if (valueList == null || valueList.isEmpty()) {
- valueList = defaultValues;
- }
-
- // Fourthly try the option's default values
- if (valueList == null || valueList.isEmpty()) {
- valueList = (List)this.defaults.get(option);
- }
-
- // Finally use an empty list
- if (valueList == null) {
- valueList = Collections.EMPTY_LIST;
- }
-
- return valueList;
- }
-
- public Object getValue(final String trigger) {
- return getValue(getOption(trigger));
+ public final Object getValue(final String trigger) {
+ return getValue(getOption(trigger),null);
}
- public Object getValue(final String trigger, final Object defaultValue) {
+ public final Object getValue(final String trigger, final Object defaultValue) {
return getValue(getOption(trigger), defaultValue);
}
- public Object getValue(final Option option) {
+ public final Object getValue(final Option option) {
return getValue(option, null);
}
- public Object getValue(final Option option, final Object defaultValue) {
+ public final Object getValue(final Option option, final Object defaultValue) {
final List values;
if (defaultValue == null) {
@@ -177,152 +87,40 @@
return values.get(0);
}
- public Boolean getSwitch(final String trigger) {
+ public final Boolean getSwitch(final String trigger) {
return getSwitch(getOption(trigger), null);
}
- public Boolean getSwitch(
+ public final Boolean getSwitch(
final String trigger,
final Boolean defaultValue) {
return getSwitch(getOption(trigger), defaultValue);
}
- public Boolean getSwitch(final Option option) {
+ public final Boolean getSwitch(final Option option) {
return getSwitch(option, null);
}
- public Boolean getSwitch(final Option option, final Boolean defaultValue) {
- // First grab the command line values
- Boolean bool = (Boolean)switches.get(option);
-
- // Secondly try alternate CommandLines
- if (bool == null && defaultCommandLine != null) {
- bool = defaultCommandLine.getSwitch(option);
- }
-
- // Thirdly try the defaults supplied to the method
- if (bool == null) {
- bool = defaultValue;
- }
-
- // Fourthly try the option's default values
- //????
-
- return bool;
+ public final String getProperty(final String property) {
+ return getProperty(property,null);
}
- public void addProperty(final String property, final String value) {
- properties.setProperty(property, value);
- }
-
- public String getProperty(final String property) {
- final String value = properties.getProperty(property);
- if (value == null && defaultCommandLine != null) {
- return defaultCommandLine.getProperty(property);
- }
- else {
- return value;
- }
- }
-
- public Set getProperties() {
- if (defaultCommandLine == null) {
- return Collections.unmodifiableSet(properties.keySet());
- }
- else {
- final Set props = new HashSet();
- props.addAll(properties.keySet());
- props.addAll(defaultCommandLine.getProperties());
- return Collections.unmodifiableSet(props);
- }
- }
-
- public List getNormalised() {
- return Collections.unmodifiableList(normalised);
- }
-
- public boolean looksLikeOption(final String trigger) {
- for (final Iterator i = prefixes.iterator(); i.hasNext();) {
- final String prefix = (String)i.next();
- if (trigger.startsWith(prefix)) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- final StringBuffer buffer = new StringBuffer();
-
- // need to add group header
-
- for (final Iterator i = normalised.iterator(); i.hasNext();) {
- final String arg = (String)i.next();
- if (arg.indexOf(' ') >= 0) {
- buffer.append("\"").append(arg).append("\"");
- }
- else {
- buffer.append(arg);
- }
- if (i.hasNext()) {
- buffer.append(' ');
- }
- }
-
- return buffer.toString();
- }
-
- public int getOptionCount(final String trigger) {
+ public final int getOptionCount(final String trigger) {
return getOptionCount(getOption(trigger));
}
- public int getOptionCount(final Option option) {
+ public final int getOptionCount(final Option option) {
if (option == null) {
return 0;
}
int count = 0;
- for (Iterator i = options.iterator(); i.hasNext();) {
+ for (Iterator i = getOptions().iterator(); i.hasNext();) {
if (option.equals(i.next())) {
++count;
}
}
return count;
- }
-
- public void setDefaultValues(final Option option, final List values) {
- this.defaults.put(option, values);
- }
-
- public List getOptions() {
- return Collections.unmodifiableList(options);
- }
-
- public Set getOptionTriggers() {
- return Collections.unmodifiableSet(nameToOption.keySet());
- }
-
- public CommandLine getDefaultCommandLine() {
- return defaultCommandLine;
- }
-
- public void setDefaultCommandLine(final CommandLine newCommandLine) {
- this.defaultCommandLine = newCommandLine;
- }
-
- public void addDefaultCommandLine(final CommandLine added) {
- if (defaultCommandLine == null) {
- defaultCommandLine = added;
- }
- else {
- defaultCommandLine.addDefaultCommandLine(added);
- }
- }
-
- public void pushDefaultCommandLine(final CommandLine pushed) {
- pushed.addDefaultCommandLine(defaultCommandLine);
- defaultCommandLine = pushed;
}
}
1.1.2.1 +263 -0
jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/WriteableCommandLineImpl.java
No revision
No revision
1.1.2.7 +1 -1
jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/CommandLine.java
Index: CommandLine.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/CommandLine.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- CommandLine.java 8 Feb 2004 13:08:58 -0000 1.1.2.6
+++ CommandLine.java 17 Feb 2004 21:14:14 -0000 1.1.2.7
@@ -41,9 +41,9 @@
Boolean getSwitch(final Option option);
Boolean getSwitch(final Option option, final Boolean defaultValue);
String getProperty(final String property);
+ String getProperty(final String property, final String defaultValue);
Set getProperties();
List getNormalised();
- String toString();
int getOptionCount(final String trigger);
int getOptionCount(final Option option);
void setDefaultValues(final Option option, final List values);
No revision
No revision
1.1.2.4 +4 -4
jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/OptionTestCase.java
Index: OptionTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/OptionTestCase.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- OptionTestCase.java 8 Feb 2004 13:09:01 -0000 1.1.2.3
+++ OptionTestCase.java 17 Feb 2004 21:14:14 -0000 1.1.2.4
@@ -22,12 +22,12 @@
import java.util.LinkedList;
import java.util.List;
+import junit.framework.TestCase;
+
import org.apache.commons.cli2.Option;
import org.apache.commons.cli2.OptionException;
import org.apache.commons.cli2.WriteableCommandLine;
-import org.apache.commons.cli2.commandline.CommandLineImpl;
-
-import junit.framework.TestCase;
+import org.apache.commons.cli2.commandline.WriteableCommandLineImpl;
/**
* @author Rob Oxspring
@@ -37,7 +37,7 @@
public static WriteableCommandLine commandLine(
final Option option,
final List args) {
- return new CommandLineImpl(option, args);
+ return new WriteableCommandLineImpl(option, args);
}
public static List list() {
No revision
No revision
1.1.2.7 +4 -4
jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/CommandLineDefaultsTest.java
Index: CommandLineDefaultsTest.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/CommandLineDefaultsTest.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- CommandLineDefaultsTest.java 8 Feb 2004 13:09:00 -0000 1.1.2.6
+++ CommandLineDefaultsTest.java 17 Feb 2004 21:14:14 -0000 1.1.2.7
@@ -17,15 +17,15 @@
import java.util.ArrayList;
+import junit.framework.TestCase;
+
import org.apache.commons.cli2.builders.ArgumentBuilder;
import org.apache.commons.cli2.builders.SwitchBuilder;
-import org.apache.commons.cli2.commandline.CommandLineImpl;
-
-import junit.framework.TestCase;
+import org.apache.commons.cli2.commandline.WriteableCommandLineImpl;
public class CommandLineDefaultsTest extends TestCase {
private WriteableCommandLine commandLine(final Option option) {
- return new CommandLineImpl(option, new ArrayList());
+ return new WriteableCommandLineImpl(option, new ArrayList());
}
private void parsed(
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]