jkeyes 2003/06/06 15:17:09 Modified: cli/src/java/org/apache/commons/cli Tag: cli_1_x Option.java OptionImpl.java OptionGroup.java ExclusiveOptionGroup.java AnonymousArgumentImpl.java Options.java InclusiveOptionGroup.java BaseOptionGroup.java Log: o renamed isValid to validate o changed method signatures to use Collection rather than Set Revision Changes Path No revision No revision 1.20.2.4 +3 -3 jakarta-commons/cli/src/java/org/apache/commons/cli/Option.java Index: Option.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Option.java,v retrieving revision 1.20.2.3 retrieving revision 1.20.2.4 diff -u -r1.20.2.3 -r1.20.2.4 --- Option.java 24 May 2003 22:20:53 -0000 1.20.2.3 +++ Option.java 6 Jun 2003 22:17:08 -0000 1.20.2.4 @@ -60,7 +60,7 @@ */ package org.apache.commons.cli; -import java.util.Set; +import java.util.Collection; /** * An Option is a command line flag. It specifies some type of @@ -114,7 +114,7 @@ * * @see Option.addChild(cli.Option) */ - void addChildren(Set children); + void addChildren(Collection children); /** * Returns whether this Option has any child Options @@ -138,5 +138,5 @@ * @return the Set of children, if there are no children * return null */ - Set getChildren(); + Collection getChildren(); } 1.1.2.4 +8 -8 jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/OptionImpl.java Index: OptionImpl.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/OptionImpl.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- OptionImpl.java 6 Jun 2003 19:29:30 -0000 1.1.2.3 +++ OptionImpl.java 6 Jun 2003 22:17:08 -0000 1.1.2.4 @@ -60,7 +60,7 @@ */ package org.apache.commons.cli; -import java.util.Set; +import java.util.Collection; import java.util.HashSet; /** @@ -83,7 +83,7 @@ private boolean required; /** the child Options */ - private Set children; + private Collection children; /** * Creates an Option @@ -108,7 +108,7 @@ final String longName, final String description, final boolean required, - final Set children) { + final Collection children) { // if the name and longName are null throw an exception if (name == null && longName == null) { @@ -163,7 +163,7 @@ /** * @see Option#addChildren(java.util.Set) */ - public void addChildren(Set children) { + public void addChildren(Collection children) { this.children.addAll(children); } @@ -177,7 +177,7 @@ /** * @see Option#getChildren() */ - public Set getChildren() { + public Collection getChildren() { return this.children; } 1.8.2.5 +15 -1 jakarta-commons/cli/src/java/org/apache/commons/cli/OptionGroup.java Index: OptionGroup.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/OptionGroup.java,v retrieving revision 1.8.2.4 retrieving revision 1.8.2.5 diff -u -r1.8.2.4 -r1.8.2.5 --- OptionGroup.java 5 Jun 2003 23:28:10 -0000 1.8.2.4 +++ OptionGroup.java 6 Jun 2003 22:17:08 -0000 1.8.2.5 @@ -60,6 +60,8 @@ */ package org.apache.commons.cli; +import java.util.Collection; + /** * @author John Keyes */ @@ -113,5 +115,17 @@ * @throws ParseException * if the OptionGroup is not valid */ - void isValid(CommandLine line) throws ParseException; + void validate(CommandLine line) throws ParseException; + + /** + * + * @return + */ + Collection getOptions(); + + /** + * + * @return + */ + Collection getOptionGroups(); } 1.1.2.4 +10 -5 jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/ExclusiveOptionGroup.java Index: ExclusiveOptionGroup.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/ExclusiveOptionGroup.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- ExclusiveOptionGroup.java 5 Jun 2003 23:28:10 -0000 1.1.2.3 +++ ExclusiveOptionGroup.java 6 Jun 2003 22:17:08 -0000 1.1.2.4 @@ -60,6 +60,7 @@ */ package org.apache.commons.cli; +import java.util.Collection; import java.util.Iterator; /** @@ -69,11 +70,13 @@ /** @task return a descriptive message for the case * when the group is not valid */ - public void isValid(CommandLine cmdLine) + public void validate(CommandLine cmdLine) throws ParseException { boolean optionFound = false; + Collection options = getOptions(); + // validate all Options are present if (!options.isEmpty()) { for (Iterator iter = options.iterator(); iter.hasNext();) { @@ -88,6 +91,8 @@ } } + Collection optionGroups = getOptionGroups(); + // validate all OptionGroups are present if (!optionGroups.isEmpty()) { for (Iterator iter = optionGroups.iterator(); iter.hasNext();) { @@ -96,7 +101,7 @@ boolean valid = true; try { - group.isValid(cmdLine); + group.validate(cmdLine); } catch (ParseException exp) { valid = false; 1.1.2.4 +9 -9 jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/AnonymousArgumentImpl.java Index: AnonymousArgumentImpl.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/AnonymousArgumentImpl.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- AnonymousArgumentImpl.java 4 Jun 2003 01:11:40 -0000 1.1.2.3 +++ AnonymousArgumentImpl.java 6 Jun 2003 22:17:08 -0000 1.1.2.4 @@ -60,7 +60,7 @@ */ package org.apache.commons.cli; -import java.util.Set; +import java.util.Collection; /** * AnonyousArgumentImpl is a special Argument that consumes trailing @@ -80,7 +80,7 @@ private String valueName; /** the arguments children */ - private Set children; + private Collection children; /** * Creates an anonymous Argument with the specified name. @@ -102,7 +102,7 @@ * @param children * the child Options */ - AnonymousArgumentImpl(final String name, final Set children) { + AnonymousArgumentImpl(final String name, final Collection children) { this.valueName = name; this.children = children; } @@ -161,16 +161,16 @@ } /** - * @see Option#addChildren(java.util.Set) + * @see Option#addChildren(java.util.Collection) */ - public void addChildren(Set children) { + public void addChildren(Collection children) { this.children = children; } /** * @see Option#getChildren() */ - public Set getChildren() { + public Collection getChildren() { return this.children; } 1.19.2.5 +25 -8 jakarta-commons/cli/src/java/org/apache/commons/cli/Options.java Index: Options.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Options.java,v retrieving revision 1.19.2.4 retrieving revision 1.19.2.5 diff -u -r1.19.2.4 -r1.19.2.5 --- Options.java 4 Jun 2003 01:11:40 -0000 1.19.2.4 +++ Options.java 6 Jun 2003 22:17:08 -0000 1.19.2.5 @@ -58,12 +58,9 @@ * <http://www.apache.org/>;. * */ -/* - */ -/* - */ package org.apache.commons.cli; +import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -73,13 +70,33 @@ */ public class Options { - Set options = new HashSet(); - Set optionGroups = new HashSet(); + private Set options = new HashSet(); + private Set optionGroups = new HashSet(); /** the AnonymousArgument */ private Argument anonymousArgument; /** + * Return the OptionGroups defined in this instance. + * + * @return Collection + * of OptionGroups defined in this instance. + */ + public Collection getOptionGroups() { + return this.optionGroups; + } + + /** + * Return the Options defined in this instance. + * + * @return Collection + * of Options defined in this instance. + */ + public Collection getOptions() { + return this.options; + } + + /** * Returns whether this definition has an AnonymousArgument * specified. * @@ -107,7 +124,7 @@ options.add(option); } - public void add(Set options) { + public void add(Collection options) { this.options.addAll(options); } @@ -182,7 +199,7 @@ OptionGroup group = (OptionGroup)iter.next(); try { - group.isValid(line); + group.validate(line); } catch(ParseException exp) { exception = exp; 1.1.2.4 +11 -6 jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/InclusiveOptionGroup.java Index: InclusiveOptionGroup.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/InclusiveOptionGroup.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- InclusiveOptionGroup.java 5 Jun 2003 23:28:10 -0000 1.1.2.3 +++ InclusiveOptionGroup.java 6 Jun 2003 22:17:08 -0000 1.1.2.4 @@ -60,6 +60,7 @@ */ package org.apache.commons.cli; +import java.util.Collection; import java.util.Iterator; /** @@ -69,11 +70,13 @@ /** @task return a descriptive message for the case * when the group is not valid */ - public void isValid(CommandLine cmdLine) + public void validate(CommandLine cmdLine) throws ParseException { ParseException exp = null; - + + Collection options = getOptions(); + // validate all Options are present if (!options.isEmpty()) { for (Iterator iter = options.iterator(); iter.hasNext();) { @@ -97,12 +100,14 @@ } } + Collection optionGroups = getOptionGroups(); + // validate all OptionGroups are present if (!optionGroups.isEmpty()) { for (Iterator iter = optionGroups.iterator(); iter.hasNext();) { OptionGroup group = (OptionGroup)iter.next(); - group.isValid(cmdLine); + group.validate(cmdLine); // reset exp exp = null; } 1.1.2.2 +14 -5 jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/BaseOptionGroup.java Index: BaseOptionGroup.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/BaseOptionGroup.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- BaseOptionGroup.java 5 Jun 2003 23:28:10 -0000 1.1.2.1 +++ BaseOptionGroup.java 6 Jun 2003 22:17:08 -0000 1.1.2.2 @@ -60,6 +60,7 @@ */ package org.apache.commons.cli; +import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -70,11 +71,19 @@ abstract class BaseOptionGroup implements OptionGroup { /** Option store */ - protected Set options = new HashSet(); + private Set options = new HashSet(); /** OptionGroup store */ - protected Set optionGroups = new HashSet(); + private Set optionGroups = new HashSet(); + public Collection getOptions() { + return this.options; + } + + public Collection getOptionGroups() { + return this.optionGroups; + } + /** * @see org.apache.commons.cli.OptionGroup#add(org.apache.commons.cli.Option) */
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]