Author: simonetripodi Date: Thu Sep 15 20:46:08 2011 New Revision: 1171267 URL: http://svn.apache.org/viewvc?rev=1171267&view=rev Log: tabs replaced by spaces
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAbstractLoopProcedure.java commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/FlexiMapExample.java commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/DataMunger.java commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/TestSoccer.java commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/TestWeather.java Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAbstractLoopProcedure.java URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAbstractLoopProcedure.java?rev=1171267&r1=1171266&r2=1171267&view=diff ============================================================================== --- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAbstractLoopProcedure.java (original) +++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAbstractLoopProcedure.java Thu Sep 15 20:46:08 2011 @@ -38,27 +38,27 @@ public class TestAbstractLoopProcedure e // ------------------------------------------------------------------------ protected Object makeFunctor() { - return new MockLoopProcedure(Constant.FALSE, NoOp.INSTANCE); + return new MockLoopProcedure(Constant.FALSE, NoOp.INSTANCE); } - // tests - // ------------------------------------------------------------------------ + // tests + // ------------------------------------------------------------------------ @Test public void testEqualsAndHashCodeWithNullArgs() { - Procedure p = new MockLoopProcedure(null,null); - assertNotNull(p.toString()); - assertFalse(p.equals(null)); - assertTrue(p.equals(p)); - assertEquals(p.hashCode(),p.hashCode()); - } + Procedure p = new MockLoopProcedure(null,null); + assertNotNull(p.toString()); + assertFalse(p.equals(null)); + assertTrue(p.equals(p)); + assertEquals(p.hashCode(),p.hashCode()); + } } class MockLoopProcedure extends AbstractLoopProcedure { - public MockLoopProcedure(Predicate condition, Procedure action) { - super(condition,action); - } + public MockLoopProcedure(Predicate condition, Procedure action) { + super(condition,action); + } - public void run() { - } + public void run() { + } } Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/FlexiMapExample.java URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/FlexiMapExample.java?rev=1171267&r1=1171266&r2=1171267&view=diff ============================================================================== --- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/FlexiMapExample.java (original) +++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/FlexiMapExample.java Thu Sep 15 20:46:08 2011 @@ -197,16 +197,16 @@ public class FlexiMapExample { */ @Test public void testIntegerValuesOnly() { - Map map = makeTypeConstrainedMap(Integer.class); - map.put("key", new Integer(2)); - assertEquals( new Integer(2), map.get("key") ); - try { - map.put("key2","value"); - fail("Expected ClassCastException"); - } catch(ClassCastException e) { - // expected - } - } + Map map = makeTypeConstrainedMap(Integer.class); + map.put("key", new Integer(2)); + assertEquals( new Integer(2), map.get("key") ); + try { + map.put("key2","value"); + fail("Expected ClassCastException"); + } catch(ClassCastException e) { + // expected + } + } /* * A more interesting specialization is that used by the @@ -219,38 +219,38 @@ public class FlexiMapExample { */ @Test public void testMultiMap() { - Map map = makeMultiMap(); + Map map = makeMultiMap(); + + map.put("key", "value 1"); + + { + Collection result = (Collection)(map.get("key")); + assertEquals(1,result.size()); + assertEquals("value 1", result.iterator().next()); + } - map.put("key", "value 1"); + map.put("key", "value 2"); - { - Collection result = (Collection)(map.get("key")); - assertEquals(1,result.size()); - assertEquals("value 1", result.iterator().next()); - } - - map.put("key", "value 2"); - - { - Collection result = (Collection)(map.get("key")); - assertEquals(2,result.size()); - Iterator iter = result.iterator(); - assertEquals("value 1", iter.next()); - assertEquals("value 2", iter.next()); - } - - map.put("key", "value 3"); - - { - Collection result = (Collection)(map.get("key")); - assertEquals(3,result.size()); - Iterator iter = result.iterator(); - assertEquals("value 1", iter.next()); - assertEquals("value 2", iter.next()); - assertEquals("value 3", iter.next()); - } + { + Collection result = (Collection)(map.get("key")); + assertEquals(2,result.size()); + Iterator iter = result.iterator(); + assertEquals("value 1", iter.next()); + assertEquals("value 2", iter.next()); + } + + map.put("key", "value 3"); - } + { + Collection result = (Collection)(map.get("key")); + assertEquals(3,result.size()); + Iterator iter = result.iterator(); + assertEquals("value 1", iter.next()); + assertEquals("value 2", iter.next()); + assertEquals("value 3", iter.next()); + } + + } /* * Here's another variation on the MultiMap theme. @@ -261,14 +261,14 @@ public class FlexiMapExample { */ @Test public void testStringConcatMap() { - Map map = makeStringConcatMap(); - map.put("key", "value 1"); - assertEquals("value 1",map.get("key")); - map.put("key", "value 2"); - assertEquals("value 1, value 2",map.get("key")); - map.put("key", "value 3"); - assertEquals("value 1, value 2, value 3",map.get("key")); - } + Map map = makeStringConcatMap(); + map.put("key", "value 1"); + assertEquals("value 1",map.get("key")); + map.put("key", "value 2"); + assertEquals("value 1, value 2",map.get("key")); + map.put("key", "value 3"); + assertEquals("value 1, value 2, value 3",map.get("key")); + } /* * ---------------------------------------------------------------------------- @@ -424,123 +424,123 @@ public class FlexiMapExample { * provide an onGet function, simliar to the onPut method used * above. */ - private Map makeDefaultValueForNullMap(Object defaultValue) { - return new FlexiMap( + private Map makeDefaultValueForNullMap(Object defaultValue) { + return new FlexiMap( null, /* * We ignore the left-hand argument, */ - IgnoreLeftFunction.adapt( + IgnoreLeftFunction.adapt( /* * and for the right-hand, */ - Conditional.function( + Conditional.function( /* * we'll test for null, */ - IsNull.instance(), + IsNull.instance(), /* * returning our default when the value is otherwise null, */ - new Constant(defaultValue), + new Constant(defaultValue), /* * and passing through all non-null values. */ - Identity.instance() - ) - ) - ); - } + Identity.instance() + ) + ) + ); + } /* * To constrain the value types, we'll * provide an onPut function, */ - private Map makeTypeConstrainedMap(Class clazz) { - return new FlexiMap( + private Map makeTypeConstrainedMap(Class clazz) { + return new FlexiMap( /* * ignore the left-hand argument, */ - IgnoreLeftFunction.adapt( - Conditional.function( + IgnoreLeftFunction.adapt( + Conditional.function( /* * we'll test the type of the right-hand argument, */ - IsInstance.of(clazz), + IsInstance.of(clazz), /* * and either pass the given value through, */ - Identity.instance(), + Identity.instance(), /* * or throw a ClassCastException. */ - throwCCE - ) - ), - null - ); - } + throwCCE + ) + ), + null + ); + } /* * The MultiMap is a bit more interesting, since we'll * need to consider both the old and new values during * onPut: */ - private Map makeMultiMap() { - return new FlexiMap( - new BinaryFunction() { - public Object evaluate(Object oldval, Object newval) { - List list = null; - if (null == oldval) { - list = new ArrayList(); - } else { - list = (List) oldval; - } - list.add(newval); - return list; - } - }, - null - ); - } + private Map makeMultiMap() { + return new FlexiMap( + new BinaryFunction() { + public Object evaluate(Object oldval, Object newval) { + List list = null; + if (null == oldval) { + list = new ArrayList(); + } else { + list = (List) oldval; + } + list.add(newval); + return list; + } + }, + null + ); + } /* * The StringConcatMap is more interesting still. */ - private Map makeStringConcatMap() { - return new FlexiMap( + private Map makeStringConcatMap() { + return new FlexiMap( /* * The onPut function looks similiar to the MultiMap * method: */ - new BinaryFunction() { - public Object evaluate(Object oldval, Object newval) { - StringBuffer buf = null; - if (null == oldval) { - buf = new StringBuffer(); - } else { - buf = (StringBuffer) oldval; - buf.append(", "); - } - buf.append(newval); - return buf; - } - }, + new BinaryFunction() { + public Object evaluate(Object oldval, Object newval) { + StringBuffer buf = null; + if (null == oldval) { + buf = new StringBuffer(); + } else { + buf = (StringBuffer) oldval; + buf.append(", "); + } + buf.append(newval); + return buf; + } + }, /* * but we'll also need an onGet functor to convert * the StringBuffer to a String: */ - new BinaryFunction() { - public Object evaluate(Object key, Object val) { - if (null == val) { - return null; - } else { - return ((StringBuffer) val).toString(); - } - } - } - ); - } + new BinaryFunction() { + public Object evaluate(Object key, Object val) { + if (null == val) { + return null; + } else { + return ((StringBuffer) val).toString(); + } + } + } + ); + } /* * (This "UniversalFunctor" type provides a functor @@ -574,16 +574,16 @@ public class FlexiMapExample { } } - private UniversalFunctor throwNPE = new UniversalFunctor() { - public void run() { - throw new NullPointerException(); - } - }; - - private UniversalFunctor throwCCE = new UniversalFunctor() { - public void run() { - throw new ClassCastException(); - } - }; + private UniversalFunctor throwNPE = new UniversalFunctor() { + public void run() { + throw new NullPointerException(); + } + }; + + private UniversalFunctor throwCCE = new UniversalFunctor() { + public void run() { + throw new ClassCastException(); + } + }; } Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/DataMunger.java URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/DataMunger.java?rev=1171267&r1=1171266&r2=1171267&view=diff ============================================================================== --- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/DataMunger.java (original) +++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/DataMunger.java Thu Sep 15 20:46:08 2011 @@ -44,16 +44,16 @@ import org.apache.commons.functor.genera * @author Rodney Waldhoff */ public class DataMunger { - /** See {@link #process(Reader,int,int,int)} */ + /** See {@link #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. Note that lines that don't begin with an Integer are ignored. - */ + /** + * 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. Note that lines that don't begin with an Integer are ignored. + */ public static final Object process(final Reader file, final int selected, final int col1, final int col2) { return NthColumn.instance(selected).evaluate( new FoldLeft<String>(lesserSpread(col1, col2)).evaluate(new FilteredGenerator<String>(Lines.from(file), @@ -81,11 +81,11 @@ public class DataMunger { ); } - /** - * 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). - */ + /** + * 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<String, Integer> absSpread(final int col1, final int col2) { return Composite.function( Abs.instance(), Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/TestSoccer.java URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/TestSoccer.java?rev=1171267&r1=1171266&r2=1171267&view=diff ============================================================================== --- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/TestSoccer.java (original) +++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/TestSoccer.java Thu Sep 15 20:46:08 2011 @@ -31,8 +31,8 @@ public class TestSoccer { @Test 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. + // 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)); Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/TestWeather.java URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/TestWeather.java?rev=1171267&r1=1171266&r2=1171267&view=diff ============================================================================== --- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/TestWeather.java (original) +++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/TestWeather.java Thu Sep 15 20:46:08 2011 @@ -37,8 +37,8 @@ public class TestWeather extends TestCas } 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. + // 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));