commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r644470 [7/7] - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/ main/java/org/apache/commons/functor/adapter/ main/java/org/apache/commons/functor/core/ main/java/org/apache/commons/functor/core/collection/ main...
Date Thu, 03 Apr 2008 20:23:31 GMT
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java
Thu Apr  3 13:23:16 2008
@@ -31,25 +31,25 @@
 
 /**
  * Examples of binary search implementations.
- * 
+ *
  * A binary search algorithm is the same strategy used in
  * that number guessing game, where one player picks a number
  * between 1 and 100, and the second player tries to guess it.
  * Each time the second player guesses a number, the first player
  * tells whether the chosen number is higher, lower or equal to
  * the guess.
- * 
+ *
  * An effective strategy for this sort of game is always guess
- * the midpoint between what you know to be the lowest and 
+ * the midpoint between what you know to be the lowest and
  * highest possible number.  This will find the number in
  * log2(N) guesses (when N = 100, this is at most 7 guesses).
- * 
+ *
  * For example, suppose the first player (secretly) picks the
  * number 63.  The guessing goes like this:
- * 
- * P1> I'm thinking of a number between 1 and 100. 
+ *
+ * P1> I'm thinking of a number between 1 and 100.
  * P2> Is it 50?
- * P1> Higher. 
+ * P1> Higher.
  * P2> 75?
  * P1> Lower.
  * P2> 62?
@@ -62,13 +62,13 @@
  * P1> That's it.
  *
  * Dave Thomas's Kata Two asks us to implement a binary search algorithm
- * in several ways.  Here we'll use this as an opportunity to 
- * consider some common approaches and explore 
- * some functor based approaches as well. 
- *  
+ * in several ways.  Here we'll use this as an opportunity to
+ * consider some common approaches and explore
+ * some functor based approaches as well.
+ *
  * See http://pragprog.com/pragdave/Practices/Kata/KataTwo.rdoc,v
  * for more information on this Kata.
- * 
+ *
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
@@ -82,10 +82,10 @@
     }
 
     /**
-     * This is Dave's test case, plus 
+     * This is Dave's test case, plus
      * a quick check of searching a fairly large
-     * list, just to make sure the time and space 
-     * requirements are reasonable. 
+     * list, just to make sure the time and space
+     * requirements are reasonable.
      */
     private void chopTest(BinaryChop chopper) {
         assertEquals(-1, chopper.find(3, new int[0]));
@@ -119,9 +119,9 @@
     }
 
     /**
-     * In practice, one would most likely use the 
-     * binary search method already available in 
-     * java.util.Collections, but that's not 
+     * In practice, one would most likely use the
+     * binary search method already available in
+     * java.util.Collections, but that's not
      * really the point of this exercise.
      */
     public void testBuiltIn() {
@@ -130,25 +130,25 @@
                 int result = Collections.binarySearch(list,seeking);
                 //
                 // Collections.binarySearch is a bit smarter than our
-                // "find". It returns 
+                // "find". It returns
                 //  (-(insertionPoint) - 1)
                 // when the value is not found, rather than
                 // simply -1.
                 //
-                return result >= 0 ? result : -1; 
+                return result >= 0 ? result : -1;
             }
         });
     }
 
     /**
      * Here's a basic iterative approach.
-     * 
+     *
      * We set the lower or upper bound to the midpoint
      * until there's only one element between the lower
      * and upper bound.  Then the lower bound is where
      * the element would be found if it existed in the
      * list.
-     * 
+     *
      * We add an additional comparision at the end so
      * that we can return -1 if the element is not yet
      * in the list.
@@ -174,54 +174,54 @@
     /*
      * At http://onestepback.org/index.cgi/Tech/Programming/Kata/KataTwoVariation1.rdoc,
      * Jim Weirich discusses Kata Two from the perspective of loop invariants.
-     * 
+     *
      * Loop invariants provide a way of deductive reasoning about loops.
-     *   
+     *
      * Let P, Q. and R be predicates and A and B be
      * procedures.  Note that if:
-     *   assert(P.test()); 
-     *   A.run(); 
+     *   assert(P.test());
+     *   A.run();
      *   assert(Q.test());
-     * and 
-     *   assert(Q.test()); 
-     *   B.run(); 
+     * and
+     *   assert(Q.test());
+     *   B.run();
      *   assert(R.test());
      * are both valid, then:
-     *   assert(P.test()); 
-     *   A.run(); 
-     *   B.run(); 
+     *   assert(P.test());
+     *   A.run();
+     *   B.run();
      *   assert(R.test());
      * is valid as well.
-     * 
+     *
      * Similiarly, if INV and TERM are predicates and BODY is a procedure,
      * then if:
-     *   assert(INV.test()); 
-     *   BODY.run(); 
+     *   assert(INV.test());
+     *   BODY.run();
      *   assert(INV.test());
      * is valid, then so is:
-     *   assert(INV.test()); 
-     *   while(! TERM.test() ) { BODY.run(); } 
+     *   assert(INV.test());
+     *   while(! TERM.test() ) { BODY.run(); }
      *   assert(INV.test());
      *   assert(TERM.test());
-     * 
+     *
      * Here INV is an "loop invariant", a statement that is true for every
      * single iteration through the loop.  TERM is a terminating condition,
      * a statement that is true (by construction) when the loop exits.
-     * 
-     * We can use loop invariants to reason about our iterative binary 
+     *
+     * We can use loop invariants to reason about our iterative binary
      * search loop.  In particular, note that:
-     * 
-     * // assert that the list is empty, or 
-     * // the result index is between 
+     *
+     * // assert that the list is empty, or
+     * // the result index is between
      * // low (inclusive) and high (exclusive),
      * // or high is 0 (the list is empty)
      * Predicate INV = new Predicate() {
      *   public boolean test() {
-     *    return high == 0 || 
+     *    return high == 0 ||
      *          (low <= result && result < high);
      *   }
      * };
-     * 
+     *
      * is a valid invariant in our binary search, and that:
      *
      * Predicate TERM = new Predicate() {
@@ -229,13 +229,13 @@
      *    return (high - low) <= 1;
      *   }
      * };
-     * 
+     *
      * is a valid terminating condition.
-     * 
-     * The BODY in our case simply moves the endpoints 
-     * closer together, without violating  
+     *
+     * The BODY in our case simply moves the endpoints
+     * closer together, without violating
      * our invariant:
-     * 
+     *
      * Procedure BODY = new Procedure() {
      *   public void run() {
      *     int mid = (high + low) / 2;
@@ -246,22 +246,22 @@
      *     }
      *   }
      * };
-     * 
+     *
      * One could assert our invariant before and after
      * the execution of BODY, and the terminating condition
      * at the end of the loop, but we can tell by construction
      * that these assertions will hold.
-     * 
+     *
      * Using the functor framework, we can make these notions
      * explict.  Specifically, the construction above is:
-     * 
-     *   Algorithms.untildo(BODY,TERM); 
-     * 
+     *
+     *   Algorithms.untildo(BODY,TERM);
+     *
      * Since we'll want to share state among the TERM and BODY,
      * let's declare a single interface for the TERM Predicate and
      * the BODY Procedure.  We'll be calculating a result within
      * the loop, so let's add a Function implementation as well,
-     * as a way of retrieving that result: 
+     * as a way of retrieving that result:
      */
     interface Loop extends Predicate, Procedure, Function {
         /** The terminating condition. */
@@ -273,12 +273,12 @@
     };
 
     /*
-     * Now we can use the Algorithms.dountil method to 
-     * execute that loop: 
+     * Now we can use the Algorithms.dountil method to
+     * execute that loop:
      */
     public void testIterativeWithInvariants() {
         chopTest(new BaseBinaryChop() {
-            
+
             public int find(final Object seeking, final List list) {
                 Loop loop = new Loop() {
                     int high = list.size();
@@ -286,9 +286,9 @@
 
                     /** Our terminating condition. */
                     public boolean test() {
-                        return (high - low) <= 1;                    
+                        return (high - low) <= 1;
                     }
-                    
+
                     /** Our loop body. */
                     public void run() {
                         int mid = (high + low) / 2;
@@ -298,18 +298,18 @@
                             low = mid;
                         }
                     }
-                    
-                    /** 
-                     * A way of returning the result 
-                     * at the end of the loop. 
+
+                    /**
+                     * A way of returning the result
+                     * at the end of the loop.
                      */
                     public Object evaluate() {
                         return new Integer(
-                            list.isEmpty() ? 
-                            -1 : 
-                            (BaseBinaryChop.equals(list,low,seeking) ? low : -1));      
                 
+                            list.isEmpty() ?
+                            -1 :
+                            (BaseBinaryChop.equals(list,low,seeking) ? low : -1));
                     }
-                    
+
                 };
                 Algorithms.untildo(loop,loop);
                 return ((Number)loop.evaluate()).intValue();
@@ -319,7 +319,7 @@
 
     /*
      * Jim Weirich notes how Eiffel is very explict about loop invariants:
-     * 
+     *
      *   from
      *     low := list.lower
      *     high := list.upper + 1
@@ -334,18 +334,18 @@
      *     mid := (high + low) // 2
      *     if list.at(mid) > seeking then
      *       high := mid
-     *     else 
+     *     else
      *       low := mid
      *     end
      *   end
-     * 
+     *
      * We can do that too, using EiffelStyleLoop.
      */
     class BinarySearchLoop extends EiffelStyleLoop {
         BinarySearchLoop(Object aSeeking, List aList) {
             seeking = aSeeking;
             list = aList;
-            
+
             from(new Procedure() {
                 public void run() {
                     low = 0;
@@ -382,37 +382,37 @@
                 }
             });
         }
-        
+
         int getResult() {
             return list.isEmpty() ? -1 : BaseBinaryChop.equals(list,low,seeking) ? low :
-1;
         }
-        
+
         private int high;
         private int low;
         private final Object seeking;
         private final List list;
     }
-    
+
     public void testIterativeWithInvariantsAndAssertions() {
-        chopTest(new BaseBinaryChop() {            
+        chopTest(new BaseBinaryChop() {
             public int find(Object seeking, List list) {
                 BinarySearchLoop loop = new BinarySearchLoop(seeking,list);
                 loop.run();
                 return loop.getResult();
             }});
     }
-    
+
     /**
-     * A recursive version of that implementation uses 
-     * method parameters to track the upper and 
-     * lower bounds. 
+     * A recursive version of that implementation uses
+     * method parameters to track the upper and
+     * lower bounds.
      */
     public void testRecursive() {
         chopTest(new BaseBinaryChop() {
             public int find(Object seeking, List list) {
                 return find(seeking, list, 0, list.size());
             }
-            
+
             private int find(Object seeking, List list, int low, int high) {
                 if(high - low > 1) {
                     int mid = (high + low) / 2;
@@ -429,13 +429,13 @@
     }
 
     /**
-     * We can use the Algorithms.recuse method 
+     * We can use the Algorithms.recuse method
      * to implement that as tail recursion.
-     * 
+     *
      * Here the anonymous Function implemenation
      * holds this itermediate state, rather than
      * the VM's call stack.
-     * 
+     *
      * Arguably this is more like a continuation than
      * tail recursion, since there is a bit of state
      * to be tracked.
@@ -454,10 +454,10 @@
                             }
                             return this;
                         } else {
-                            return list.isEmpty() ? 
-                                BaseBinaryChop.NEGATIVE_ONE : 
-                                (BaseBinaryChop.equals(list,low,seeking) ? 
-                                    new Integer(low) : 
+                            return list.isEmpty() ?
+                                BaseBinaryChop.NEGATIVE_ONE :
+                                (BaseBinaryChop.equals(list,low,seeking) ?
+                                    new Integer(low) :
                                     BaseBinaryChop.NEGATIVE_ONE);
                         }
                     }
@@ -469,18 +469,18 @@
     }
 
     /**
-     * One fun functional approach is to "slice" up the 
-     * list as we search,  looking at smaller and 
-     * smaller slices until we've found the element 
+     * One fun functional approach is to "slice" up the
+     * list as we search,  looking at smaller and
+     * smaller slices until we've found the element
      * we're looking for.
      *
-     * Note that while any given call to this recursive 
+     * Note that while any given call to this recursive
      * function may only be looking at a sublist, we
      * need to return the index in the overall list.
      * Hence we'll split out a method so that we can
-     * pass the offset in the original list as a 
+     * pass the offset in the original list as a
      * parameter.
-     *  
+     *
      * With all of the subList creation, this approach
      * is probably less efficient than either the iterative
      * or the recursive implemenations above.
@@ -490,7 +490,7 @@
             public int find(Object seeking, List list) {
                 return find(seeking,list,0);
             }
-            
+
             private int find(Object seeking, List list, int offset) {
                 if(list.isEmpty()) {
                     return -1;
@@ -510,7 +510,7 @@
 
     /**
      * We can do that using tail recursion as well.
-     * 
+     *
      * Again, the anonymous Function implemenation
      * holds the "continuation" state.
      */
@@ -522,8 +522,8 @@
                         if(sublist.isEmpty()) {
                             return BaseBinaryChop.NEGATIVE_ONE;
                         } if(sublist.size() == 1) {
-                            return (BaseBinaryChop.equals(sublist,0,seeking) ? 
-                                new Integer(offset) : 
+                            return (BaseBinaryChop.equals(sublist,0,seeking) ?
+                                new Integer(offset) :
                                 BaseBinaryChop.NEGATIVE_ONE);
                         } else {
                             int mid = sublist.size() / 2;

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Contains.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Contains.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Contains.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Contains.java
Thu Apr  3 13:23:16 2008
@@ -27,7 +27,7 @@
     public Contains(String str) {
         this.str = str;
     }
-    
+
     public boolean test(Object obj) {
         return null != obj && obj.toString().indexOf(str) != -1;
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Count.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Count.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Count.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Count.java
Thu Apr  3 13:23:16 2008
@@ -26,10 +26,10 @@
     public void run() {
         count++;
     }
-    
+
     public int getCount() {
         return count;
     }
-    
+
     private int count = 0;
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/StartsWith.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/StartsWith.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/StartsWith.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/StartsWith.java
Thu Apr  3 13:23:16 2008
@@ -27,7 +27,7 @@
     public StartsWith(String prefix) {
         this.prefix = prefix;
     }
-    
+
     public boolean test(Object obj) {
         return null != obj && obj.toString().startsWith(prefix);
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Sum.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Sum.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Sum.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Sum.java
Thu Apr  3 13:23:16 2008
@@ -24,13 +24,13 @@
  */
 public class Sum implements BinaryFunction {
     public Object evaluate(Object left, Object right) {
-        return new Integer( ((Number)left).intValue() + ((Number)right).intValue() ); 
+        return new Integer( ((Number)left).intValue() + ((Number)right).intValue() );
     }
-    
-    
+
+
     public static final Sum instance() {
         return INSTANCE;
     }
-    
+
     private static final Sum INSTANCE = new Sum();
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/TestAll.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/TestAll.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/TestAll.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/TestAll.java
Thu Apr  3 13:23:16 2008
@@ -33,7 +33,7 @@
         TestSuite suite = new TestSuite();
 
         suite.addTest(TestLines.suite());
-        
+
         return suite;
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/TestLines.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/TestLines.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/TestLines.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/TestLines.java
Thu Apr  3 13:23:16 2008
@@ -42,34 +42,34 @@
     public static Test suite() {
         return new TestSuite(TestLines.class);
     }
-    
+
     private Reader reader = null;
-    
+
     public void setUp() throws Exception {
         super.setUp();
-        reader = new StringReader(DOCUMENT);        
+        reader = new StringReader(DOCUMENT);
     }
-    
+
     public void tearDown() throws Exception {
         super.tearDown();
         reader = null;
     }
-    
+
     public void testCountCharacters() throws Exception {
         Object result = Lines
             .from(reader)
                 .apply(Size.instance())
                     .inject(new Integer(0),Sum.instance());
-                    
+
         assertEquals("Expected 990 characters",new Integer(990),result);
-    }                    
+    }
 
     public void testCountWords() throws Exception {
         Object result = Lines
             .from(reader)
                 .apply(WordCount.instance())
                     .inject(new Integer(0),Sum.instance());
-                    
+
         assertEquals("Expected 157 words",new Integer(157),result);
     }
 
@@ -78,7 +78,7 @@
         Lines
             .from(reader)
                 .foreach(ProcedureUnaryProcedure.adapt(count));
-                                   
+
         assertEquals("Expected 16 lines",16,count.getCount());
     }
 
@@ -88,7 +88,7 @@
                 .reject(new StartsWith("#"))
                     .apply(WordCount.instance())
                         .inject(new Integer(0),Sum.instance());
-                    
+
         assertEquals("Expected 90 words",new Integer(90),result);
     }
 
@@ -98,12 +98,12 @@
             .from(reader)
                 .select(new StartsWith("#"))
                     .foreach(ProcedureUnaryProcedure.adapt(count));
-                                   
+
         assertEquals("Expected 6 lines",6,count.getCount());
     }
 
     public void testFindMatchingLines() throws Exception {
-        Collection matches = 
+        Collection matches =
             Lines
                 .from(reader)
                     .select(new Contains("lo"))
@@ -112,7 +112,7 @@
     }
 
     public void testFindMatchingFromTail() throws Exception {
-        Collection matches = 
+        Collection matches =
             Lines
                 .from(reader)
                     .select(new Offset(8))
@@ -120,9 +120,9 @@
                             .toCollection();
         assertEquals("Expected 2 lines",2,matches.size());
     }
-    
-    
-    private static final String DOCUMENT = 
+
+
+    private static final String DOCUMENT =
         "# Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \n" +
         "# Aliquam erat volutpat. Donec nec eros. Etiam eget tortor eu \n" +
         "tortor rutrum cursus. Pellentesque ornare pretium risus. Nulla \n" +

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/WordCount.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/WordCount.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/WordCount.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/WordCount.java
Thu Apr  3 13:23:16 2008
@@ -33,6 +33,6 @@
     public static WordCount instance() {
         return INSTANCE;
     }
-    
+
     private static final WordCount INSTANCE = new WordCount();
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java
Thu Apr  3 13:23:16 2008
@@ -44,12 +44,12 @@
                 }
             }
         });
-        
+
         setOnPutAll(new BinaryProcedure() {
             public void run(Object a, Object b) {
                 Map dest = (Map)a;
                 Map src = (Map)b;
-                
+
                 if(Algorithms.contains(src.keySet().iterator(),UnaryNot.not(new ContainsKey(dest))))
{
                     throw new IllegalArgumentException();
                 } else {
@@ -57,7 +57,7 @@
                 }
             }
         });
-        
+
         setOnRemove(new BinaryProcedureBinaryFunction(new Throw(new UnsupportedOperationException())));
         setOnClear(new Throw(new UnsupportedOperationException()));
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/FunctoredMap.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/FunctoredMap.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/FunctoredMap.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/FunctoredMap.java
Thu Apr  3 13:23:16 2008
@@ -95,9 +95,9 @@
     public boolean containsValue(Object value) {
         return map.containsValue(value);
     }
-    
+
     // protected
-    
+
     protected void setOnClear(UnaryProcedure procedure) {
         onclear = procedure;
     }
@@ -119,7 +119,7 @@
     }
 
     // attributes
-    
+
     protected static final BinaryFunction DEFAULT_ON_PUT = new BinaryFunction() {
         public Object evaluate(Object a, Object b) {
             Map map = (Map)a;
@@ -128,7 +128,7 @@
             return map.put(key,value);
         }
     };
-    
+
     private BinaryFunction onput = DEFAULT_ON_PUT;
 
     protected static final BinaryFunction DEFAULT_ON_GET = new BinaryFunction() {
@@ -136,9 +136,9 @@
             return ((Map)map).get(key);
         }
     };
-    
+
     private BinaryFunction onget = DEFAULT_ON_GET;
-    
+
     protected static final BinaryProcedure DEFAULT_ON_PUT_ALL = new BinaryProcedure() {
         public void run(Object a, Object b) {
             Map dest = (Map)a;
@@ -147,8 +147,8 @@
         }
     };
 
-    private BinaryProcedure onputall = DEFAULT_ON_PUT_ALL;    
-    
+    private BinaryProcedure onputall = DEFAULT_ON_PUT_ALL;
+
     protected static final BinaryFunction DEFAULT_ON_REMOVE = new BinaryFunction() {
         public Object evaluate(Object a, Object key) {
             Map map = (Map)a;
@@ -165,20 +165,20 @@
     };
 
     private UnaryProcedure onclear = DEFAULT_ON_CLEAR;
-    
+
     private Map map = null;
 
     // inner classes
-    
+
     protected static class ContainsKey implements UnaryPredicate {
         ContainsKey(Map map) {
             this.map = map;
         }
-        
+
         public boolean test(Object obj) {
             return map.containsKey(obj);
         }
-        
+
         private Map map = null;
     }
 
@@ -204,7 +204,7 @@
         public void run(Object a, Object b) {
             run();
         }
-        
+
         private Class klass = null;
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/LazyMap.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/LazyMap.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/LazyMap.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/LazyMap.java
Thu Apr  3 13:23:16 2008
@@ -34,7 +34,7 @@
                 if(map.containsKey(key)) {
                     return map.get(key);
                 } else {
-                    Object value = factory.evaluate(key);                    
+                    Object value = factory.evaluate(key);
                     map.put(key,value);
                     return value;
                 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/PredicatedMap.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/PredicatedMap.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/PredicatedMap.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/PredicatedMap.java
Thu Apr  3 13:23:16 2008
@@ -36,8 +36,8 @@
         setOnPut(new ConditionalBinaryFunction(
             new BinaryPredicate() {
                 public boolean test(Object a, Object b) {
-                    return keyPredicate.test(Array.get(b,0)) && 
-                        valuePredicate.test(Array.get(b,1)); 
+                    return keyPredicate.test(Array.get(b,0)) &&
+                        valuePredicate.test(Array.get(b,1));
                 }
             },
             DEFAULT_ON_PUT,
@@ -49,7 +49,7 @@
                 Map src = (Map)s;
                 for(Iterator iter = src.entrySet().iterator(); iter.hasNext(); ) {
                     Map.Entry pair = (Map.Entry)iter.next();
-                    if(keyPredicate.test(pair.getKey()) && 
+                    if(keyPredicate.test(pair.getKey()) &&
                         valuePredicate.test(pair.getValue())) {
                         dest.put(pair.getKey(),pair.getValue());
                     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestAll.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestAll.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestAll.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestAll.java
Thu Apr  3 13:23:16 2008
@@ -35,7 +35,7 @@
         suite.addTest(TestPredicatedMap.suite());
         suite.addTest(TestFixedSizeMap.suite());
         suite.addTest(TestLazyMap.suite());
-        
+
         return suite;
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestFixedSizeMap.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestFixedSizeMap.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestFixedSizeMap.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestFixedSizeMap.java
Thu Apr  3 13:23:16 2008
@@ -37,10 +37,10 @@
     public static Test suite() {
         return new TestSuite(TestFixedSizeMap.class);
     }
-    
+
     private Map baseMap = null;
     private Map fixedMap = null;
-    
+
     public void setUp() throws Exception {
         super.setUp();
         baseMap = new HashMap();
@@ -49,10 +49,10 @@
         baseMap.put(new Integer(3),"three");
         baseMap.put(new Integer(4),"four");
         baseMap.put(new Integer(5),"five");
-        
+
         fixedMap = new FixedSizeMap(baseMap);
     }
-    
+
     public void tearDown() throws Exception {
         super.tearDown();
         baseMap = null;
@@ -60,7 +60,7 @@
     }
 
     // tests
-    
+
     public void testCantPutNewPair() {
         try {
             fixedMap.put("xyzzy","xyzzy");
@@ -75,15 +75,15 @@
         map.put(new Integer(1),"uno");
         map.put("xyzzy","xyzzy");
         map.put(new Integer(2),"dos");
-        
+
         try {
             fixedMap.putAll(map);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
             // expected
         }
-        
-        assertEquals("one",fixedMap.get(new Integer(1)));        
+
+        assertEquals("one",fixedMap.get(new Integer(1)));
         assertEquals("two",fixedMap.get(new Integer(2)));
     }
 
@@ -104,10 +104,10 @@
             // expected
         }
     }
-        
+
     public void testCanAssociateNewValueWithOldKey() {
         fixedMap.put(new Integer(1),"uno");
-        assertEquals("uno",fixedMap.get(new Integer(1)));        
+        assertEquals("uno",fixedMap.get(new Integer(1)));
         assertEquals("two",fixedMap.get(new Integer(2)));
         assertEquals("three",fixedMap.get(new Integer(3)));
     }
@@ -118,8 +118,8 @@
         map.put(new Integer(2),"dos");
 
         fixedMap.putAll(map);
-        
-        assertEquals("uno",fixedMap.get(new Integer(1)));        
+
+        assertEquals("uno",fixedMap.get(new Integer(1)));
         assertEquals("dos",fixedMap.get(new Integer(2)));
         assertEquals("three",fixedMap.get(new Integer(3)));
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestLazyMap.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestLazyMap.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestLazyMap.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestLazyMap.java
Thu Apr  3 13:23:16 2008
@@ -40,11 +40,11 @@
     public static Test suite() {
         return new TestSuite(TestLazyMap.class);
     }
-    
+
     private Map baseMap = null;
     private Map lazyMap = null;
     private Map expectedMap = null;
-    
+
     public void setUp() throws Exception {
         super.setUp();
         expectedMap = new HashMap();
@@ -54,10 +54,10 @@
         expectedMap.put("four", new Integer(4));
         expectedMap.put("five", new Integer(4));
 
-        baseMap = new HashMap();        
+        baseMap = new HashMap();
         lazyMap = new LazyMap(baseMap,Size.instance());
     }
-    
+
     public void tearDown() throws Exception {
         super.tearDown();
         baseMap = null;
@@ -66,7 +66,7 @@
     }
 
     // tests
-    
+
     public void test() {
         for(Iterator iter = expectedMap.keySet().iterator(); iter.hasNext();) {
             Object key = iter.next();

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestPredicatedMap.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestPredicatedMap.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestPredicatedMap.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestPredicatedMap.java
Thu Apr  3 13:23:16 2008
@@ -39,7 +39,7 @@
     public static Test suite() {
         return new TestSuite(TestPredicatedMap.class);
     }
-    
+
     private Map baseMap = null;
     private Map predicatedMap = null;
     public void setUp() throws Exception {
@@ -47,7 +47,7 @@
         baseMap = new HashMap();
         predicatedMap = new PredicatedMap(baseMap,new IsInstanceOf(String.class),new IsInstanceOf(Integer.class));
     }
-    
+
     public void tearDown() throws Exception {
         super.tearDown();
         baseMap = null;
@@ -55,14 +55,14 @@
     }
 
     // tests
-    
+
     public void testCanPutMatchingPair() {
         predicatedMap.put("xyzzy", new Integer(17));
     }
     public void testCantPutInvalidValue() {
         try {
             predicatedMap.put("xyzzy", "xyzzy");
-            fail("Expected IllegalArgumentException");            
+            fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
             // expected
         }
@@ -71,7 +71,7 @@
     public void testCantPutInvalidKey() {
         try {
             predicatedMap.put(new Long(1), new Integer(3));
-            fail("Expected IllegalArgumentException");            
+            fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
             // expected
         }
@@ -83,13 +83,13 @@
         map.put("two", "rejected");
         map.put(new Integer(17), "xyzzy");
         map.put(new Integer(7), new Integer(3));
-        
+
         predicatedMap.putAll(map);
         assertEquals(new Integer(17), predicatedMap.get("one"));
         assertFalse(predicatedMap.containsKey("two"));
-/*        
+/*
         assertFalse(predicatedMap.containsKey(new Integer(17)));
         assertFalse(predicatedMap.containsKey(new Integer(7)));
-*/        
+*/
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
Thu Apr  3 13:23:16 2008
@@ -177,9 +177,9 @@
             }
         };
         Summer summer = new Summer();
-                
+
         gen.apply(dbl).run(summer);
-        
+
         assertEquals(2*(1+2+3+4),summer.sum);
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java
Thu Apr  3 13:23:16 2008
@@ -48,12 +48,12 @@
         list.add("1");
         return new IteratorToGeneratorAdapter(list.iterator());
     }
-    
+
     // Lifecycle
     // ------------------------------------------------------------------------
-    
+
     private List list = null;
-    
+
     public void setUp() throws Exception {
         super.setUp();
         list = new ArrayList();
@@ -85,7 +85,7 @@
         list2.addAll(gen.toCollection());
         assertEquals(list,list2);
     }
-    
+
     public void testConstructNull() {
         try {
             new IteratorToGeneratorAdapter(null);

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java
Thu Apr  3 13:23:16 2008
@@ -86,20 +86,20 @@
             new IntegerRange(0, 1, 0);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
-            // expected 
-        }  
+            // expected
+        }
         try {
             new IntegerRange(0, 1, -1);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
-            // expected 
-        }  
+            // expected
+        }
         try {
             new IntegerRange(0, -1, 1);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
-            // expected 
-        }  
+            // expected
+        }
     }
 
     public void testObjectConstructor() {

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java?rev=644470&r1=644469&r2=644470&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java
Thu Apr  3 13:23:16 2008
@@ -86,20 +86,20 @@
             new LongRange(0, 1, 0);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
-            // expected 
-        }  
+            // expected
+        }
         try {
             new LongRange(0, 1, -1);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
-            // expected 
-        }  
+            // expected
+        }
         try {
             new LongRange(0, -1, 1);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
-            // expected 
-        }  
+            // expected
+        }
     }
 
     public void testObjectConstructor() {



Mime
View raw message