commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r757266 [2/2] - in /commons/sandbox/flatfile/trunk/src: main/antlr/ main/java/org/apache/commons/flatfile/ main/java/org/apache/commons/flatfile/dsl/ main/java/org/apache/commons/flatfile/entityfactory/ main/java/org/apache/commons/flatfile...
Date Sun, 22 Mar 2009 22:12:29 GMT
Modified: commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/ApplyOptions.java
URL: http://svn.apache.org/viewvc/commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/ApplyOptions.java?rev=757266&r1=757265&r2=757266&view=diff
==============================================================================
--- commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/ApplyOptions.java
(original)
+++ commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/ApplyOptions.java
Sun Mar 22 22:12:27 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.flatfile.util;
 
-import java.util.Iterator;
 import java.util.Map;
 
 import net.sf.morph.lang.languages.SimpleLanguage;
@@ -48,26 +47,27 @@
 
     /**
      * Apply the specified option map to <code>o</code>.
-     * @param o Object
-     * @param options
+     * @param <T> type of fluent arg/result.
+     * @param o Object target
+     * @param options option map
      * @return <code>o</code>.
      */
-    public static Object apply(Object o, Map options) {
-        for (Iterator iter = options.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            apply(o, (String) entry.getKey(), entry.getValue());
+    public static <T> T apply(T o, Map<String, ? extends Object> options) {
+        for (Map.Entry<String, ? extends Object> option : options.entrySet()) {
+            apply(o, option.getKey(), option.getValue());
         }
         return o;
     }
 
     /**
      * Apply the specified option to <code>o</code>.
-     * @param o Object
+     * @param <T> type of fluent arg/result.
+     * @param o Object target
      * @param option String option name.
      * @param value option value.
      * @return <code>o</code>.
      */
-    public static Object apply(Object o, String option, Object value) {
+    public static <T> T apply(T o, String option, Object value) {
         MORPH_LANGUAGE.set(o, option, value);
         return o;
     }

Modified: commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/BasicFilterFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/BasicFilterFactory.java?rev=757266&r1=757265&r2=757266&view=diff
==============================================================================
--- commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/BasicFilterFactory.java
(original)
+++ commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/BasicFilterFactory.java
Sun Mar 22 22:12:27 2009
@@ -25,16 +25,16 @@
  */
 public class BasicFilterFactory extends FilterFactory {
     private static final long serialVersionUID = 9080292216759574895L;
-    private static final Class[] PARAMETER_TYPES = new Class[] { InputStream.class };
+    private static final Class<?>[] PARAMETER_TYPES = new Class[] { InputStream.class
};
     private static final String HIERARCHY_ERROR = " does not inherit from "
             + InputStream.class.getName();
 
-    private Constructor constructor;
+    private Constructor<? extends InputStream> constructor;
 
     /**
      * Create a new BasicFilterFactory.
      */
-    public BasicFilterFactory(Class clazz) {
+    public BasicFilterFactory(Class<? extends InputStream> clazz) {
         if (!InputStream.class.isAssignableFrom(clazz)) {
             throw new IllegalArgumentException(clazz + HIERARCHY_ERROR);
         }
@@ -45,18 +45,15 @@
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.pgac.fixedlength.util.FilterFactory#iGetFilter(java.io.InputStream)
+    /**
+     * {@inheritDoc}
      */
     protected InputStream iGetFilter(InputStream markIsSupported) {
         if (constructor == null) {
             throw new IllegalStateException();
         }
         try {
-            return (InputStream) constructor
-                    .newInstance(new Object[] { markIsSupported });
+            return constructor.newInstance(new Object[] { markIsSupported });
         } catch (Exception e) {
             throw new RuntimeException(e);
         }

Modified: commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/ConcatenatedInputStream.java
URL: http://svn.apache.org/viewvc/commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/ConcatenatedInputStream.java?rev=757266&r1=757265&r2=757266&view=diff
==============================================================================
--- commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/ConcatenatedInputStream.java
(original)
+++ commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/ConcatenatedInputStream.java
Sun Mar 22 22:12:27 2009
@@ -38,14 +38,14 @@
         }
     };
 
-    private Iterator iter;
+    private Iterator<InputStream> iter;
     private InputStream current;
 
     /**
      * Create a new ConcatenatedInputStream.
      * @param src
      */
-    public ConcatenatedInputStream(List/* <InputStream> */src) {
+    public ConcatenatedInputStream(List<InputStream>src) {
         if (src == null) {
             throw new IllegalArgumentException(NO_NULL);
         }
@@ -58,6 +58,7 @@
      * @param is0
      * @param is1
      */
+    @SuppressWarnings("unchecked")
     public ConcatenatedInputStream(InputStream is0, InputStream is1) {
         if (is0 == null || is1 == null) {
             throw new IllegalArgumentException(NO_NULL);
@@ -67,10 +68,8 @@
         iter = IteratorUtils.singletonIterator(is1);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.io.InputStream#read()
+    /**
+     * {@inheritDoc}
      */
     public int read() throws IOException {
         int n = current.read();

Modified: commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/FilterFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/FilterFactory.java?rev=757266&r1=757265&r2=757266&view=diff
==============================================================================
--- commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/FilterFactory.java
(original)
+++ commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/FilterFactory.java
Sun Mar 22 22:12:27 2009
@@ -27,6 +27,9 @@
  * @version $Revision$ $Date$
  */
 public abstract class FilterFactory implements Serializable {
+    /** Serialization version */
+    private static final long serialVersionUID = -172092815628700041L;
+
     /**
      * Get an InputStream that filters the specified {@link InputStream}
      * @param is the {@link InputStream} to filter

Modified: commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/RepeatingInputStream.java
URL: http://svn.apache.org/viewvc/commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/RepeatingInputStream.java?rev=757266&r1=757265&r2=757266&view=diff
==============================================================================
--- commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/RepeatingInputStream.java
(original)
+++ commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/util/RepeatingInputStream.java
Sun Mar 22 22:12:27 2009
@@ -86,16 +86,16 @@
      * Holds cached instances of single-byte RepeatingInputStreams.
      */
     // go ahead and init b/c we know we'll want a single-byte instance:
-    private static HashMap/* <Byte, RepeatOneByte> */INSTANCE_MAP = new HashMap();
+    private static HashMap<Byte, InputStream> INSTANCE_MAP = new HashMap<Byte, InputStream>();
 
     /**
      * Get an InputStream that will return the specified byte forever.
      * @param b
-     * @return
+     * @return InputStream
      */
     public static synchronized InputStream getInstance(byte b) {
         Byte bigByte = new Byte(b);
-        InputStream result = (InputStream) INSTANCE_MAP.get(bigByte);
+        InputStream result = INSTANCE_MAP.get(bigByte);
         if (result == null) {
             result = new RepeatOneByte(b);
             INSTANCE_MAP.put(bigByte, result);
@@ -106,7 +106,7 @@
     /**
      * Get an InputStream that will return the specified byte[] forever.
      * @param b
-     * @return
+     * @return InputStream
      */
     public static InputStream getInstance(byte[] b) {
         return b.length == 1 ? getInstance(b[0]) : new RepeatArray(b);

Modified: commons/sandbox/flatfile/trunk/src/test/java/org/apache/commons/flatfile/EntityArrayLifecycleTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/flatfile/trunk/src/test/java/org/apache/commons/flatfile/EntityArrayLifecycleTest.java?rev=757266&r1=757265&r2=757266&view=diff
==============================================================================
--- commons/sandbox/flatfile/trunk/src/test/java/org/apache/commons/flatfile/EntityArrayLifecycleTest.java
(original)
+++ commons/sandbox/flatfile/trunk/src/test/java/org/apache/commons/flatfile/EntityArrayLifecycleTest.java
Sun Mar 22 22:12:27 2009
@@ -71,7 +71,7 @@
     }
 
     private void expectInvalidSize(EntityArray e, int size,
-            String failureMessage, Class exceptionType) {
+            String failureMessage, Class<? extends Exception> exceptionType) {
         try {
             e.setSize(size);
             fail(failureMessage);



Mime
View raw message