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
Date Sat, 27 Mar 2004 00:15:43 GMT
roxspring    2004/03/26 16:15:43

  Modified:    cli/src/java/org/apache/commons/cli2/impl Tag:
                        RESEARCH_CLI_2_ROXSPRING GroupImpl.java
                        ParentImpl.java OptionImpl.java
               cli/src/java/org/apache/commons/cli2 Tag:
                        RESEARCH_CLI_2_ROXSPRING Option.java
  Log:
  Added findOption(trigger) method to Option. This allows more flexibility for CommandLine
implementations that are driven by queries rather than the initial data
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.15  +15 -0     jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/GroupImpl.java
  
  Index: GroupImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/GroupImpl.java,v
  retrieving revision 1.1.2.14
  retrieving revision 1.1.2.15
  diff -u -r1.1.2.14 -r1.1.2.15
  --- GroupImpl.java	26 Mar 2004 02:07:10 -0000	1.1.2.14
  +++ GroupImpl.java	27 Mar 2004 00:15:42 -0000	1.1.2.15
  @@ -442,6 +442,21 @@
       }
   	
       
  +	/* (non-Javadoc)
  +	 * @see org.apache.commons.cli2.Option#findOption(java.lang.String)
  +	 */
  +	public Option findOption(final String trigger) {
  +		final Iterator i = getOptions().iterator();
  +		while(i.hasNext()){
  +			final Option option = (Option)i.next();
  +			final Option found = option.findOption(trigger);
  +			if(found!=null){
  +				return found;
  +			}
  +		}
  +		
  +		return null;
  +	}
   }
   
   class ReverseStringComparator implements Comparator {
  
  
  
  1.1.2.7   +13 -0     jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ParentImpl.java
  
  Index: ParentImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ParentImpl.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- ParentImpl.java	25 Feb 2004 00:01:57 -0000	1.1.2.6
  +++ ParentImpl.java	27 Mar 2004 00:15:42 -0000	1.1.2.7
  @@ -25,6 +25,7 @@
   import org.apache.commons.cli2.Argument;
   import org.apache.commons.cli2.Group;
   import org.apache.commons.cli2.HelpSetting;
  +import org.apache.commons.cli2.Option;
   import org.apache.commons.cli2.OptionException;
   import org.apache.commons.cli2.Parent;
   import org.apache.commons.cli2.WriteableCommandLine;
  @@ -237,4 +238,16 @@
           arguments.previous();        
       }
       
  +	/*
  +	 * @see org.apache.commons.cli2.Option#findOption(java.lang.String)
  +	 */
  +	public Option findOption(final String trigger) {
  +		final Option found = super.findOption(trigger);
  +		if(found==null && children!=null){
  +			return children.findOption(trigger);
  +		}
  +		else{
  +			return found;
  +		}
  +	}
   }
  
  
  
  1.1.2.4   +14 -0     jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/OptionImpl.java
  
  Index: OptionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/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	8 Feb 2004 13:08:59 -0000	1.1.2.3
  +++ OptionImpl.java	27 Mar 2004 00:15:42 -0000	1.1.2.4
  @@ -99,4 +99,18 @@
           hashCode = hashCode * 37 + getTriggers().hashCode();
           return hashCode;
       }
  +    
  +	/**
  +	 * Returns this if the trigger is one of the triggers returned by getTriggers().
  +	 * @see #getTriggers()
  +	 * @return this or null.
  +	 */
  +	public Option findOption(String trigger) {
  +		if(getTriggers().contains(trigger)){
  +			return this;
  +		}
  +		else{
  +			return null;
  +		}
  +	}
   }
  
  
  
  No                   revision
  No                   revision
  1.1.2.8   +8 -0      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.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- Option.java	8 Feb 2004 14:01:46 -0000	1.1.2.7
  +++ Option.java	27 Mar 2004 00:15:42 -0000	1.1.2.8
  @@ -146,4 +146,12 @@
       String getDescription();
   
       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);
   }
  
  
  

---------------------------------------------------------------------
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