commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roxspr...@apache.org
Subject cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2 Option.java CommandLine.java Command.java ArgumentImpl.java GroupImpl.java DefaultOption.java ParentImpl.java PropertyOption.java Comparators.java Switch.java
Date Thu, 29 Jan 2004 22:05:04 GMT
roxspring    2004/01/29 14:05:04

  Modified:    cli/src/test/org/apache/commons/cli2 Tag:
                        RESEARCH_CLI_2_ROXSPRING GroupTest.java
                        ParentTest.java ArgumentTest.java SwitchTest.java
                        PropertyOptionTest.java CommandTest.java
                        DefaultOptionTest.java
               cli/src/java/org/apache/commons/cli2 Tag:
                        RESEARCH_CLI_2_ROXSPRING Option.java
                        CommandLine.java Command.java ArgumentImpl.java
                        GroupImpl.java DefaultOption.java ParentImpl.java
                        PropertyOption.java Comparators.java Switch.java
  Log:
  Refactored Option naming bean-like methods in a bean-like manor
  prefixes() operation is now getPrefixes() accessor
  triggers() operation is now getTriggers() accessor
  
  Improved option Impl integrity by wrapping internal collections using Collections.unmodifiableX(X)
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +2 -2      jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/GroupTest.java
  
  Index: GroupTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/GroupTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- GroupTest.java	22 Jan 2004 22:40:50 -0000	1.1.2.2
  +++ GroupTest.java	29 Jan 2004 22:05:03 -0000	1.1.2.3
  @@ -184,7 +184,7 @@
   	 */
   	public void testPrefixes() {
   		final Group option = buildApachectlGroup();
  -		assertContentsEqual(list("-", "--"), option.prefixes());
  +		assertContentsEqual(list("-", "--"), option.getPrefixes());
   	}
   
   	/* (non-Javadoc)
  @@ -230,7 +230,7 @@
   		final Group option = buildApachectlGroup();
   		assertContentsEqual(
   			list("--help", "-?", "-h", "-k"),
  -			option.triggers());
  +			option.getTriggers());
   	}
   
   	/* (non-Javadoc)
  
  
  
  1.1.2.3   +2 -2      jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/ParentTest.java
  
  Index: ParentTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/ParentTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ParentTest.java	22 Jan 2004 22:40:50 -0000	1.1.2.2
  +++ ParentTest.java	29 Jan 2004 22:05:03 -0000	1.1.2.3
  @@ -182,7 +182,7 @@
   	 */
   	public void testPrefixes() {
   		final Parent option = buildKParent();
  -		assertContentsEqual(list("-", "--"), option.prefixes());
  +		assertContentsEqual(list("-", "--"), option.getPrefixes());
   	}
   
   	/* (non-Javadoc)
  @@ -242,7 +242,7 @@
   	 */
   	public void testTriggers() {
   		final Parent option = buildKParent();
  -		assertContentsEqual(list("-k"), option.triggers());
  +		assertContentsEqual(list("-k"), option.getTriggers());
   	}
   
   	/* (non-Javadoc)
  
  
  
  1.1.2.3   +2 -2      jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/ArgumentTest.java
  
  Index: ArgumentTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/ArgumentTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ArgumentTest.java	22 Jan 2004 22:40:50 -0000	1.1.2.2
  +++ ArgumentTest.java	29 Jan 2004 22:05:03 -0000	1.1.2.3
  @@ -328,7 +328,7 @@
   	 */
   	public void testPrefixes() {
   		final Argument option = buildTargetsArgument();
  -		assertTrue(option.prefixes().isEmpty());
  +		assertTrue(option.getPrefixes().isEmpty());
   	}
   
   	/* (non-Javadoc)
  @@ -357,7 +357,7 @@
   	 */
   	public void testTriggers() {
   		final Argument option = buildTargetsArgument();
  -		assertTrue(option.triggers().isEmpty());
  +		assertTrue(option.getTriggers().isEmpty());
   	}
   
   	/* (non-Javadoc)
  
  
  
  1.1.2.3   +2 -2      jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/SwitchTest.java
  
  Index: SwitchTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/SwitchTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- SwitchTest.java	22 Jan 2004 22:40:50 -0000	1.1.2.2
  +++ SwitchTest.java	29 Jan 2004 22:05:03 -0000	1.1.2.3
  @@ -138,7 +138,7 @@
   	 */
   	public void testPrefixes() {
   		final Switch option = buildDisplaySwitch();
  -		assertContentsEqual(list("-", "+"), option.prefixes());
  +		assertContentsEqual(list("-", "+"), option.getPrefixes());
   	}
   
   	/* (non-Javadoc)
  @@ -156,7 +156,7 @@
   		final Switch option = buildDisplaySwitch();
   		assertContentsEqual(
   			list("-d", "+d", "-disp", "+disp", "+display", "-display"),
  -			option.triggers());
  +			option.getTriggers());
   	}
   
   	/* (non-Javadoc)
  
  
  
  1.1.2.4   +2 -2      jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/PropertyOptionTest.java
  
  Index: PropertyOptionTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/PropertyOptionTest.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- PropertyOptionTest.java	23 Jan 2004 00:18:07 -0000	1.1.2.3
  +++ PropertyOptionTest.java	29 Jan 2004 22:05:03 -0000	1.1.2.4
  @@ -95,7 +95,7 @@
   	 */
   	public void testPrefixes() {
   		final Option option = new PropertyOption();
  -		assertContentsEqual(list("-D"), option.prefixes());
  +		assertContentsEqual(list("-D"), option.getPrefixes());
   	}
   
   	/* (non-Javadoc)
  @@ -160,7 +160,7 @@
   	public void testTriggers() {
   		final Option option = new PropertyOption();
   
  -		assertContentsEqual(list("-D"), option.triggers());
  +		assertContentsEqual(list("-D"), option.getTriggers());
   	}
   
   	/* (non-Javadoc)
  
  
  
  1.1.2.3   +2 -2      jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/CommandTest.java
  
  Index: CommandTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/CommandTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- CommandTest.java	22 Jan 2004 22:40:50 -0000	1.1.2.2
  +++ CommandTest.java	29 Jan 2004 22:05:03 -0000	1.1.2.3
  @@ -156,7 +156,7 @@
   	 */
   	public void testPrefixes() {
   		final Command option = buildStartCommand();
  -		assertTrue(option.prefixes().isEmpty());
  +		assertTrue(option.getPrefixes().isEmpty());
   	}
   
   	/* (non-Javadoc)
  @@ -181,7 +181,7 @@
   	 */
   	public void testTriggers() {
   		final Command option = buildStartCommand();
  -		final Set triggers = option.triggers();
  +		final Set triggers = option.getTriggers();
   		assertContentsEqual(list("start", "go"), triggers);
   	}
   
  
  
  
  1.1.2.3   +2 -2      jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/DefaultOptionTest.java
  
  Index: DefaultOptionTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/DefaultOptionTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DefaultOptionTest.java	22 Jan 2004 22:40:50 -0000	1.1.2.2
  +++ DefaultOptionTest.java	29 Jan 2004 22:05:03 -0000	1.1.2.3
  @@ -154,7 +154,7 @@
   	 */
   	public void testPrefixes() {
   		final DefaultOption option = buildHelpOption();
  -		assertContentsEqual(list("-", "--"), option.prefixes());
  +		assertContentsEqual(list("-", "--"), option.getPrefixes());
   	}
   
   	/* (non-Javadoc)
  @@ -170,7 +170,7 @@
   	 */
   	public void testTriggers() {
   		final DefaultOption option = buildHelpOption();
  -		assertContentsEqual(list("-?", "-h", "--help"), option.triggers());
  +		assertContentsEqual(list("-?", "-h", "--help"), option.getTriggers());
   	}
   
   	/* (non-Javadoc)
  
  
  
  No                   revision
  No                   revision
  1.1.2.3   +2 -2      jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Option.java
  
  Index: Option.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Option.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Option.java	22 Jan 2004 22:40:51 -0000	1.1.2.2
  +++ Option.java	29 Jan 2004 22:05:04 -0000	1.1.2.3
  @@ -113,7 +113,7 @@
   	 * 
   	 * @return The set of triggers for this Option
   	 */
  -	public Set triggers();
  +	public Set getTriggers();
   
   	/**
   	 * Identifies the argument prefixes that should be considered options.
  @@ -125,7 +125,7 @@
   	 *    
   	 * @return The set of prefixes for this Option
   	 */
  -	public Set prefixes();
  +	public Set getPrefixes();
   
   	/**
   	 * Checks that the supplied CommandLine is valid with respect to this option.
  
  
  
  1.1.2.3   +2 -2      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.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- CommandLine.java	22 Jan 2004 22:40:51 -0000	1.1.2.2
  +++ CommandLine.java	29 Jan 2004 22:05:04 -0000	1.1.2.3
  @@ -87,14 +87,14 @@
       private CommandLine defaultCommandLine = null;
   
   	public CommandLine(final Option rootOption, final List arguments) {
  -		this.prefixes = rootOption.prefixes();
  +		this.prefixes = rootOption.getPrefixes();
   		this.normalised = arguments;
   	}
   
   	public void addOption(Option option) {
   		options.add(option);
   		nameToOption.put(option.getPreferredName(), option);
  -		for (Iterator i = option.triggers().iterator(); i.hasNext();) {
  +		for (Iterator i = option.getTriggers().iterator(); i.hasNext();) {
   			nameToOption.put(i.next(), option);
   		}
   	}
  
  
  
  1.1.2.3   +13 -9     jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Command.java
  
  Index: Command.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Command.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Command.java	22 Jan 2004 22:40:51 -0000	1.1.2.2
  +++ Command.java	29 Jan 2004 22:05:04 -0000	1.1.2.3
  @@ -78,13 +78,13 @@
   	private final String preferredName;
   
   	/** The aliases for this command */
  -	private final Set aliases = new HashSet();
  +	private final Set aliases;
   
   	/** Whether or not the command is required */
   	private final boolean required;
   
   	/** All the names for this command */
  -	private final Set triggers = new HashSet();
  +	private final Set triggers;
   
   	/**
   	 * Creates a new Command instance.
  @@ -118,13 +118,18 @@
   		this.required = required;
   
   		// gracefully and defensively handle aliases
  -		if (aliases != null) {
  -			this.aliases.addAll(aliases);
  +		if (aliases == null) {
  +		    this.aliases = Collections.EMPTY_SET;
  +		}
  +		else{
  +		    this.aliases = Collections.unmodifiableSet(new HashSet(aliases));
   		}
   
   		// populate the triggers Set
  -		this.triggers.add(preferredName);
  -		this.triggers.addAll(this.aliases);
  +		final Set triggers = new HashSet();
  +		triggers.add(preferredName);
  +		triggers.addAll(this.aliases);
  +		this.triggers = Collections.unmodifiableSet(triggers);
   	}
   
   	/* (non-Javadoc)
  @@ -154,9 +159,8 @@
   	/* (non-Javadoc)
   	 * @see org.apache.commons.cli2.Option#triggers()
   	 */
  -	public Set triggers() {
  -		// return the triggers defensively
  -		return Collections.unmodifiableSet(triggers);
  +	public Set getTriggers() {
  +		return triggers;
   	}
   
   	/* (non-Javadoc)
  
  
  
  1.1.2.3   +2 -2      jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/ArgumentImpl.java
  
  Index: ArgumentImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/ArgumentImpl.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ArgumentImpl.java	22 Jan 2004 22:40:51 -0000	1.1.2.2
  +++ ArgumentImpl.java	29 Jan 2004 22:05:04 -0000	1.1.2.3
  @@ -264,7 +264,7 @@
       /* (non-Javadoc)
        * @see org.apache.commons.cli2.Option#prefixes()
        */
  -    public Set prefixes()
  +    public Set getPrefixes()
       {
           return Collections.EMPTY_SET;
       }
  @@ -284,7 +284,7 @@
       /* (non-Javadoc)
        * @see org.apache.commons.cli2.Option#triggers()
        */
  -    public Set triggers()
  +    public Set getTriggers()
       {
           return Collections.EMPTY_SET;
       }
  
  
  
  1.1.2.3   +22 -17    jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/GroupImpl.java
  
  Index: GroupImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/GroupImpl.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- GroupImpl.java	22 Jan 2004 22:40:51 -0000	1.1.2.2
  +++ GroupImpl.java	29 Jan 2004 22:05:04 -0000	1.1.2.3
  @@ -76,9 +76,9 @@
   	private final List options;
   	private final int minimum;
   	private final int maximum;
  -	private final List anonymous = new ArrayList();
  -	private final SortedMap optionMap =
  -		new TreeMap(StringComparator.getReverseInstance());
  +	private final List anonymous;
  +	private final SortedMap optionMap;
  +	private final Set prefixes;
   
   	public GroupImpl(
   		final Collection options,
  @@ -91,22 +91,34 @@
   		this.description = description;
   		this.minimum = minimum;
   		this.maximum = maximum;
  -
  -		this.options = new ArrayList(options);
  -		for (final Iterator i = this.options.iterator(); i.hasNext();) {
  +		
  +		final List optionsCopy = new ArrayList(options);
  +		this.options = Collections.unmodifiableList(optionsCopy);
  +		
  +		final List anonymous = new ArrayList();
  +		final SortedMap optionMap = new TreeMap(StringComparator.getReverseInstance());
  +		for (final Iterator i = optionsCopy.iterator(); i.hasNext();) {
   			final Option option = (Option) i.next();
   
   			if (option instanceof Argument) {
   				i.remove();
   				anonymous.add(option);
   			} else {
  -				for (Iterator j = option.triggers().iterator(); j.hasNext();) {
  +				for (Iterator j = option.getTriggers().iterator(); j.hasNext();) {
   					String prefix = (String) j.next();
   					optionMap.put(prefix, option);
   				}
   			}
   		}
  -
  +		this.anonymous = Collections.unmodifiableList(anonymous);
  +		this.optionMap = Collections.unmodifiableSortedMap(optionMap);
  +		
  +		final Set prefixes = new HashSet();
  +		for (final Iterator i = options.iterator(); i.hasNext();) {
  +		    final Option option = (Option) i.next();
  +		    prefixes.addAll(option.getPrefixes());
  +		}
  +		this.prefixes = Collections.unmodifiableSet(prefixes);
   	}
   
   	/* (non-Javadoc)
  @@ -145,21 +157,14 @@
   	/* (non-Javadoc)
   	 * @see org.apache.commons.cli2.Option#prefixes()
   	 */
  -	public Set prefixes() {
  -		final Set prefixes = new HashSet();
  -
  -		for (final Iterator i = options.iterator(); i.hasNext();) {
  -			final Option option = (Option) i.next();
  -			prefixes.addAll(option.prefixes());
  -		}
  -
  +	public Set getPrefixes() {
   		return prefixes;
   	}
   
   	/* (non-Javadoc)
   	 * @see org.apache.commons.cli2.Option#triggers()
   	 */
  -	public Set triggers() {
  +	public Set getTriggers() {
   		return optionMap.keySet();
   	}
   
  
  
  
  1.1.2.3   +17 -14    jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/DefaultOption.java
  
  Index: DefaultOption.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/DefaultOption.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DefaultOption.java	22 Jan 2004 22:40:51 -0000	1.1.2.2
  +++ DefaultOption.java	29 Jan 2004 22:05:04 -0000	1.1.2.3
  @@ -75,7 +75,8 @@
       private final Set aliases;
       private final Set burstAliases;
       private final boolean required;
  -    private final Set triggers = new HashSet();
  +    private final Set triggers;
  +    private final Set prefixes;
   
       private final String shortPrefix;
       private final String longPrefix;
  @@ -108,20 +109,27 @@
               this.aliases = Collections.EMPTY_SET;
           }
           else {
  -            this.aliases = aliases;
  +            this.aliases = Collections.unmodifiableSet(new HashSet(aliases));
           }
   
           if (burstAliases == null) {
               this.burstAliases = Collections.EMPTY_SET;
           }
           else {
  -            this.burstAliases = burstAliases;
  +            this.burstAliases = Collections.unmodifiableSet(new HashSet(burstAliases));
           }
           this.required = required;
  -
  -        this.triggers.add(preferredName);
  -        this.triggers.addAll(this.aliases);
  -        this.triggers.addAll(this.burstAliases);
  +        
  +        final Set triggers = new HashSet();
  +        triggers.add(preferredName);
  +        triggers.addAll(this.aliases);
  +        triggers.addAll(this.burstAliases);
  +        this.triggers = Collections.unmodifiableSet(triggers);
  +        
  +        final Set prefixes = new HashSet(super.getPrefixes());
  +        prefixes.add(shortPrefix);
  +        prefixes.add(longPrefix);
  +        this.prefixes = Collections.unmodifiableSet(prefixes);
       }
   
       /*
  @@ -184,7 +192,7 @@
   	 * 
   	 * @see org.apache.commons.cli2.Option#triggers()
   	 */
  -    public Set triggers() {
  +    public Set getTriggers() {
           return triggers;
       }
       /*
  @@ -192,12 +200,7 @@
   	 * 
   	 * @see org.apache.commons.cli2.Option#prefixes()
   	 */
  -    public Set prefixes() {
  -        final Set prefixes = new HashSet(super.prefixes());
  -
  -        prefixes.add(shortPrefix);
  -        prefixes.add(longPrefix);
  -
  +    public Set getPrefixes() {
           return prefixes;
       }
   
  
  
  
  1.1.2.3   +3 -3      jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/ParentImpl.java
  
  Index: ParentImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/ParentImpl.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ParentImpl.java	22 Jan 2004 22:40:51 -0000	1.1.2.2
  +++ ParentImpl.java	29 Jan 2004 22:05:04 -0000	1.1.2.3
  @@ -121,17 +121,17 @@
   			trimmed = arg;
   		}
   
  -		return triggers().contains(trimmed);
  +		return getTriggers().contains(trimmed);
   	}
   
   	/* (non-Javadoc)
   	 * @see org.apache.commons.cli2.Option#prefixes()
   	 */
  -	public Set prefixes() {
  +	public Set getPrefixes() {
   		if (children == null) {
   			return Collections.EMPTY_SET;
   		} else {
  -			return children.prefixes();
  +			return children.getPrefixes();
   		}
   	}
   
  
  
  
  1.1.2.4   +5 -3      jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/PropertyOption.java
  
  Index: PropertyOption.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/PropertyOption.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- PropertyOption.java	29 Jan 2004 20:47:28 -0000	1.1.2.3
  +++ PropertyOption.java	29 Jan 2004 22:05:04 -0000	1.1.2.4
  @@ -76,6 +76,7 @@
   
   	private final String optionString;
   	private final String description;
  +	private final Set prefixes;
   
   	public PropertyOption() {
   		this(DEFAULT_OPTION_STRING, DEFAULT_DESCRIPTION, 'D');
  @@ -88,6 +89,7 @@
           super(id);
   		this.optionString = optionString;
   		this.description = description;
  +		this.prefixes = Collections.singleton(optionString);
   	}
   
   	public static final PropertyOption INSTANCE = new PropertyOption();
  @@ -104,8 +106,8 @@
   	/* (non-Javadoc)
   	 * @see org.apache.commons.cli2.Option#prefixes()
   	 */
  -	public Set prefixes() {
  -		return Collections.singleton(optionString);
  +	public Set getPrefixes() {
  +		return prefixes;
   	}
   
   	/* (non-Javadoc)
  @@ -139,7 +141,7 @@
   	/* (non-Javadoc)
   	 * @see org.apache.commons.cli2.Option#triggers()
   	 */
  -	public Set triggers() {
  +	public Set getTriggers() {
   		return Collections.singleton(optionString);
   	}
   	/* (non-Javadoc)
  
  
  
  1.1.2.3   +4 -4      jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Comparators.java
  
  Index: Comparators.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Comparators.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Comparators.java	22 Jan 2004 22:40:51 -0000	1.1.2.2
  +++ Comparators.java	29 Jan 2004 22:05:04 -0000	1.1.2.3
  @@ -334,7 +334,7 @@
   	/**
   	 * Forces Comparators with a particular trigger to appear at the beginning of lists 
   	 * @param name the trigger name to select
  -	 * @see Option#triggers() 
  +	 * @see Option#getTriggers() 
   	 * @return a new comparator
   	 */
   	public static Comparator namedFirst(final String name) {
  @@ -344,7 +344,7 @@
   	/**
   	 * Forces Comparators with a particular trigger to appear at the end of lists 
   	 * @param name the trigger name to select
  -	 * @see Option#triggers() 
  +	 * @see Option#getTriggers() 
   	 * @return a new comparator
   	 */
   	public static Comparator namedLast(final String name) {
  @@ -360,8 +360,8 @@
   			final Option left = (Option) oleft;
   			final Option right = (Option) oright;
   
  -			final boolean l = left.triggers().contains(name);
  -			final boolean r = right.triggers().contains(name);
  +			final boolean l = left.getTriggers().contains(name);
  +			final boolean r = right.getTriggers().contains(name);
   
   			if (l ^ r) {
   				if (l) {
  
  
  
  1.1.2.3   +20 -13    jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Switch.java
  
  Index: Switch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Switch.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Switch.java	22 Jan 2004 22:40:51 -0000	1.1.2.2
  +++ Switch.java	29 Jan 2004 22:05:04 -0000	1.1.2.3
  @@ -73,9 +73,10 @@
   	private final String enabledPrefix;
   	private final String disabledPrefix;
   	private final boolean required;
  -	private final Set triggers = new HashSet();
  +	private final Set triggers;
   	private final String preferredName;
  -	private final Set aliases = new HashSet();
  +	private final Set aliases;
  +	private final Set prefixes;
   
   	protected Switch(
   		final String enabledPrefix,
  @@ -113,18 +114,29 @@
   		if (preferredName == null || preferredName.length() < 1) {
   			throw new IllegalArgumentException("preferredName must be at least 1 character");
   		}
  -
  +		
  +		final Set triggers = new HashSet();
   		triggers.add(enabledPrefix + preferredName);
   		triggers.add(disabledPrefix + preferredName);
  +		this.triggers = Collections.unmodifiableSet(triggers);
   
  -		if (aliases != null) {
  -			this.aliases.addAll(aliases);
  +		if (aliases == null) {
  +		    this.aliases = Collections.EMPTY_SET;
  +		}
  +		else {
  +			this.aliases = Collections.unmodifiableSet(new HashSet(aliases));
   			for (final Iterator i = aliases.iterator(); i.hasNext();) {
   				final String alias = (String) i.next();
   				triggers.add(enabledPrefix + alias);
   				triggers.add(disabledPrefix + alias);
   			}
   		}
  +		
  +		final Set prefixes = new HashSet(super.getPrefixes());
  +		prefixes.add(enabledPrefix);
  +		prefixes.add(disabledPrefix);
  +		this.prefixes = Collections.unmodifiableSet(prefixes);
  +
   	}
   
   	/* (non-Javadoc)
  @@ -155,19 +167,14 @@
   	/* (non-Javadoc)
   	 * @see org.apache.commons.cli2.Option#triggers()
   	 */
  -	public Set triggers() {
  -		return Collections.unmodifiableSet(triggers);
  +	public Set getTriggers() {
  +		return triggers;
   	}
   
   	/* (non-Javadoc)
   	 * @see org.apache.commons.cli2.Option#prefixes()
   	 */
  -	public Set prefixes() {
  -		final Set prefixes = new HashSet(super.prefixes());
  -
  -		prefixes.add(enabledPrefix);
  -		prefixes.add(disabledPrefix);
  -
  +	public Set getPrefixes() {
   		return prefixes;
   	}
   
  
  
  

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


Mime
View raw message