You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by sg...@apache.org on 2005/05/09 14:02:52 UTC

cvs commit: jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/cli Getopt.java

sgoeschl    2005/05/09 05:02:52

  Modified:    yaafi/src/java/org/apache/fulcrum/yaafi/cli Getopt.java
  Log:
  Got rid of PMD warning
  
  Revision  Changes    Path
  1.2       +47 -47    jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java
  
  Index: Getopt.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Getopt.java	26 Apr 2005 12:28:58 -0000	1.1
  +++ Getopt.java	9 May 2005 12:02:52 -0000	1.2
  @@ -25,39 +25,39 @@
   {
       /** the prefix for determining command line parameters, e.g "-" or "--" */
       private String prefix;
  -
  +    
       /** the command line parameters */
  -    private String[] args;
  -
  -    /**
  -     * Constructor
  -     * @param args the command line parameters
  -     */
  -    public Getopt( String[] args )
  -    {
  -        this(args,"--");
  -    }
  -
  -    /**
  -     * Constructor.
  -     *
  -     * @param args the command line parameters
  -     * @param prefix the prefix for command line paramters
  -     */
  -    public Getopt( String[] args, String prefix )
  -    {
  -        this.prefix = prefix;
  -
  -        if( args == null )
  -        {
  -            this.args = new String[0];
  -        }
  -        else
  -        {
  -            this.args = args;
  -        }
  -    }
  +	private String[] args;
   
  +	/**
  +	 * Constructor
  +	 * @param args the command line parameters
  +	 */
  +	public Getopt( String[] args )
  +	{
  +	    this(args,"--");
  +	}
  +
  +	/**
  +	 * Constructor.
  +	 * 
  +	 * @param args the command line parameters
  +	 * @param prefix the prefix for command line paramters
  +	 */
  +	public Getopt( String[] args, String prefix )
  +	{
  +	    this.prefix = prefix;
  +	    
  +	    if( args == null )
  +	    {
  +	        this.args = new String[0];
  +	    }
  +	    else
  +	    {
  +	        this.args = args;
  +	    }
  +	}
  +	
       /**
        * @param option the option we are looking for
        * @return is the given option contained in the command line arguments?
  @@ -68,14 +68,14 @@
           return( this.find(option) >= 0 ? true : false );
       }
   
  -    /**
  +    /** 
        * @return the number of command line arguments
        */
       public int length()
       {
           return this.args.length;
       }
  -
  +    
       /**
        * Returns the string value for the given option.
        * @param option the option
  @@ -116,22 +116,22 @@
        */
       public boolean getBooleanValue( String option, boolean defaultValue )
       {
  -        String temp = new Boolean(defaultValue).toString();
  +        String temp = Boolean.toString(defaultValue);
           return Boolean.valueOf(this.getValue(option,temp)).booleanValue();
       }
   
       /**
        * Get the given argument.
        * @param index the index of the command line argument
  -     * @return the commandl ine argument
  +     * @return the commandl ine argument 
        */
       private String getArg( int index )
       {
           return this.args[index];
       }
  -
  +    
       /**
  -     * @option the option
  +     * @option the option 
        * @return the index of the give option or -1 otherwise
        */
       private int find( String option )
  @@ -152,7 +152,7 @@
       }
   
       /**
  -     * Determines if a value is defined for the given option
  +     * Determines if a value is defined for the given option 
        * @param option the given option
        * @return true if a value is defined
        */
  @@ -162,18 +162,18 @@
       }
   
       /**
  -     * Determines if a value is defined for the given option
  +     * Determines if a value is defined for the given option 
        * @param option the given option
        * @return true if a value is defined
        */
       private boolean hasValue( int index )
       {
           String value = null;
  -
  +        
           if( (index+1) < this.length() )
           {
               value = this.getArg(index+1);
  -
  +            
               if( value.startsWith(this.prefix) )
               {
                   return false;
  @@ -186,7 +186,7 @@
           else
           {
               return false;
  -        }
  +        }        
       }
   
       /**
  @@ -198,7 +198,7 @@
       private String getValue( String option )
       {
           String value = this.getValue(option,null);
  -
  +        
           if( value == null )
           {
               // the options is there but no value was defined by the caller
  @@ -210,7 +210,7 @@
               return value;
           }
       }
  -
  +    
       /**
        * Get the value of a command line option
        * @param option the option
  @@ -220,13 +220,13 @@
       private String getValue( String option, String defaultValue )
       {
           int index = this.find(option);
  -
  +        
           if( index < 0 )
           {
               // the option is not found
               return defaultValue;
           }
  -
  +        
           if( this.hasValue(index) )
           {
               // a value is available for this option
  @@ -238,6 +238,6 @@
               String msg = "No value supplied for " + this.prefix + option;
               throw new IllegalArgumentException( msg );
           }
  -    }
  +    }    
   }
   
  
  
  

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