rwaldhoff    2003/12/17 14:13:52

  Modified:    functor/src/test/org/apache/commons/functor/example/kata/four
                        ToInteger.java TestSoccer.java IsInteger.java
                        Abs.java TestWeather.java NthColumn.java
                        DataMunger.java
  Log:
  add comments
  
  Revision  Changes    Path
  1.2       +8 -2      
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/ToInteger.java
  
  Index: ToInteger.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/ToInteger.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ToInteger.java    2 Dec 2003 16:36:11 -0000       1.1
  +++ ToInteger.java    17 Dec 2003 22:13:51 -0000      1.2
  @@ -59,6 +59,12 @@
   import org.apache.commons.functor.UnaryFunction;
   
   /**
  + * Converts a String value to an Integer, throwing 
  + * an exception if no such conversion can be made.
  + * 
  + * Trailing, [EMAIL PROTECTED] Character#isDigit digit} characters
  + * are ignored.
  + * 
    * @version $Revision$ $Date$
    * @author Rodney Waldhoff
    */
  
  
  
  1.4       +4 -2      
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/TestSoccer.java
  
  Index: TestSoccer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/TestSoccer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestSoccer.java   3 Dec 2003 01:04:12 -0000       1.3
  +++ TestSoccer.java   17 Dec 2003 22:13:51 -0000      1.4
  @@ -77,6 +77,8 @@
       }
       
       public void testProcess() {
  +     // for our soccer example, we want to select the second column of the
  +     // line with the minimal difference between the seventh and ninth columns.
           assertEquals(
               "Aston_Villa",
               
DataMunger.process(getClass().getResourceAsStream("soccer.txt"),1,6,8));            
  
  
  
  1.2       +5 -2      
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/IsInteger.java
  
  Index: IsInteger.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/IsInteger.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IsInteger.java    2 Dec 2003 16:36:11 -0000       1.1
  +++ IsInteger.java    17 Dec 2003 22:13:51 -0000      1.2
  @@ -59,6 +59,9 @@
   import org.apache.commons.functor.UnaryPredicate;
   
   /**
  + * Tests to true iff the input object can be converted to
  + * an Integer by [EMAIL PROTECTED] ToInteger}.
  + *  
    * @version $Revision$ $Date$
    * @author Rodney Waldhoff
    */
  
  
  
  1.2       +5 -2      
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/Abs.java
  
  Index: Abs.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/Abs.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Abs.java  2 Dec 2003 16:36:11 -0000       1.1
  +++ Abs.java  17 Dec 2003 22:13:51 -0000      1.2
  @@ -59,6 +59,9 @@
   import org.apache.commons.functor.UnaryFunction;
   
   /**
  + * Evaluates to the absolute Integer value of the Number-valued
  + * input parameter.
  + * 
    * @version $Revision$ $Date$
    * @author Rodney Waldhoff
    */
  
  
  
  1.4       +4 -2      
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/TestWeather.java
  
  Index: TestWeather.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/TestWeather.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestWeather.java  3 Dec 2003 01:04:12 -0000       1.3
  +++ TestWeather.java  17 Dec 2003 22:13:51 -0000      1.4
  @@ -77,6 +77,8 @@
       }
   
       public void testProcess() {
  +             // for our soccer example, we want to select the first column of the
  +             // line with the minimal difference between the second and third 
columns.
           assertEquals(
               "14",
               
DataMunger.process(getClass().getResourceAsStream("weather.txt"),0,1,2));            
  
  
  
  1.2       +5 -2      
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/NthColumn.java
  
  Index: NthColumn.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/NthColumn.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NthColumn.java    2 Dec 2003 16:36:11 -0000       1.1
  +++ NthColumn.java    17 Dec 2003 22:13:51 -0000      1.2
  @@ -61,6 +61,9 @@
   import org.apache.commons.functor.UnaryFunction;
   
   /**
  + * Evaluates the input String to extrace the nth whitespace
  + * delmited column.
  + * 
    * @version $Revision$ $Date$
    * @author Rodney Waldhoff
    */
  
  
  
  1.7       +17 -3     
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/DataMunger.java
  
  Index: DataMunger.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/DataMunger.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DataMunger.java   17 Dec 2003 22:05:26 -0000      1.6
  +++ DataMunger.java   17 Dec 2003 22:13:51 -0000      1.7
  @@ -75,15 +75,24 @@
   import org.apache.commons.functor.example.lines.Lines;
   
   /**
  + * The real workhorse of this Kata excercise.
  + * 
  + * DataMunger wires together various functors and exposes them
  + * as static utility methhods. 
    * @version $Revision$ $Date$
    * @author Rodney Waldhoff
    */
   public class DataMunger {
  -
  +     /** See [EMAIL PROTECTED] #process(Reader,int,int,int)} */
       public static final Object process(final InputStream file, final int selected, 
final int col1, final int col2) {
           return process(new InputStreamReader(file),selected,col1,col2);
       }
   
  +     /**
  +      * Processes each line of the given Reader, returning the <i>selected</i> 
column for the 
  +      * line where the absolute difference between the integer value of <i>col1</i> 
and <i>col2</i>
  +      * is least.  
  +      */
       public static final Object process(final Reader file, final int selected, final 
int col1, final int col2) {
           return NthColumn.instance(selected).evaluate(
               Algorithms.inject(
  @@ -115,6 +124,11 @@
           );
       }
   
  +     /**
  +      * A UnaryFunction that returns the absolute value of the difference 
  +      * between the Integers stored in the <i>col1</i> and <i>col2</i>th
  +      * whitespace delimited columns of the input line (a String).
  +      */
       private static UnaryFunction absSpread(final int col1, final int col2) {
           return Composite.function(
               Abs.instance(),
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to