fix of human readable size and media info
[mir.git] / source / mir / generator / VelocityGenerator.java
index 1735701..340aa4b 100755 (executable)
  */
 package mir.generator;
 
+import java.io.File;
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.io.File;
 import java.util.AbstractList;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Vector;
+
+import mir.log.LoggerWrapper;
+import mir.util.GeneratorFormatAdapters;
+import mir.util.RewindableIterator;
 
 import org.apache.commons.beanutils.MethodUtils;
 import org.apache.commons.beanutils.PropertyUtils;
@@ -49,9 +53,6 @@ import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.log.LogSystem;
-import mir.log.LoggerWrapper;
-import mir.util.GeneratorFormatAdapters;
-import mir.util.RewindableIterator;
 
 public class VelocityGenerator implements Generator {
   private String templateIdentifier;
@@ -170,8 +171,7 @@ public class VelocityGenerator implements Generator {
     if (anObject instanceof VelocityAdapter) {
       return ((VelocityAdapter) anObject).getOriginal();
     }
-    else
-      return anObject;
+               return anObject;
   }
 
   /**
@@ -229,7 +229,7 @@ public class VelocityGenerator implements Generator {
     }
 
     public Object call(Object aParameters[]) throws GeneratorExc {
-      List parameters = new Vector();
+      List parameters = new ArrayList();
 
       for (int i = 0; i<aParameters.length; i++) {
         parameters.add(unmakeAdapter(aParameters[i]));
@@ -239,7 +239,7 @@ public class VelocityGenerator implements Generator {
     }
 
     public Object call() throws GeneratorExc {
-      return makeAdapter(function.perform(new Vector()));
+      return makeAdapter(function.perform(new ArrayList()));
     }
 
     public Object call(Object anObject) throws GeneratorExc {
@@ -337,7 +337,7 @@ public class VelocityGenerator implements Generator {
     private IteratorAdapter(Iterator anIterator) {
       iterator = anIterator;
 
-      valuesCache = new Vector();
+      valuesCache = new ArrayList();
 
       if (iterator instanceof RewindableIterator) {
         ((RewindableIterator) iterator).rewind();
@@ -349,7 +349,7 @@ public class VelocityGenerator implements Generator {
       {
         valuesCache.add(makeAdapter(iterator.next()));
       }
-    };
+    }
 
     public Object getOriginal() {
       return iterator;
@@ -366,8 +366,7 @@ public class VelocityGenerator implements Generator {
 
         return result;
       }
-      else
-        throw new RuntimeException( "Iterator out of bounds" );
+                       throw new RuntimeException( "Iterator out of bounds" );
     }
 
     public int size() {
@@ -393,7 +392,7 @@ public class VelocityGenerator implements Generator {
     private ListAdapter(List aList) {
       list = aList;
 
-      valuesCache = new Vector();
+      valuesCache = new ArrayList();
     }
 
     private void getUntil(int anIndex) {
@@ -401,7 +400,7 @@ public class VelocityGenerator implements Generator {
       {
         valuesCache.add(makeAdapter(list.get(valuesCache.size())));
       }
-    };
+    }
 
     public Object getOriginal() {
       return list;
@@ -418,8 +417,7 @@ public class VelocityGenerator implements Generator {
 
         return result;
       }
-      else
-        throw new RuntimeException( "Iterator out of bounds" );
+                       throw new RuntimeException( "Iterator out of bounds" );
     }
 
     public int size() {
@@ -497,8 +495,7 @@ public class VelocityGenerator implements Generator {
    * @version 1.0
    */
   private static class VelocityLoggerWrapper implements LogSystem {
-    private LoggerWrapper logger;
-
+   
     public VelocityLoggerWrapper(LoggerWrapper aLogger) {
       logger = aLogger;
     }
@@ -561,8 +558,6 @@ public class VelocityGenerator implements Generator {
         engine.init();
       }
       catch (Throwable t) {
-        t.printStackTrace(logger.asPrintWriter(logger.ERROR_MESSAGE));
-
         logger.error("Failed to set up a VelocityGeneratorLibrary: " + t.toString());
         throw new GeneratorFailure(t);
       }
@@ -591,6 +586,6 @@ public class VelocityGenerator implements Generator {
 
     public Library makeLibrary(String anInitializationString) throws GeneratorExc, GeneratorFailure {
       return new VelocityGeneratorLibrary(new File(basePath, anInitializationString));
-    };
+    }
   }
 }