]> source.dussan.org Git - poi.git/commitdiff
Add some missing close() calls and fix some generics warnings
authorDominik Stadler <centic@apache.org>
Sun, 9 Nov 2014 17:53:10 +0000 (17:53 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 9 Nov 2014 17:53:10 +0000 (17:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1637703 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/format/CellDateFormatter.java
src/java/org/apache/poi/ss/format/CellElapsedFormatter.java
src/java/org/apache/poi/ss/format/CellGeneralFormatter.java
src/java/org/apache/poi/ss/format/CellNumberFormatter.java
src/java/org/apache/poi/util/BitFieldFactory.java
src/java/org/apache/poi/util/DrawingDump.java
src/java/org/apache/poi/util/HexRead.java

index e45fa267df5c63923e666989a2663f9590e1f870..952b15c13168276c1cb5dcb9e443bb9c5c07011c 100644 (file)
@@ -183,8 +183,12 @@ public class CellDateFormatter extends CellFormatter {
                     Date dateObj = (Date) value;
                     int pos = toAppendTo.length();
                     Formatter formatter = new Formatter(toAppendTo);
-                    long msecs = dateObj.getTime() % 1000;
-                    formatter.format(LOCALE, sFmt, msecs / 1000.0);
+                    try {
+                        long msecs = dateObj.getTime() % 1000;
+                        formatter.format(LOCALE, sFmt, msecs / 1000.0);
+                    } finally {
+                        formatter.close();
+                    }
                     toAppendTo.delete(pos, pos + 2);
                     doneMillis = true;
                 }
index 07ebadf2a02fe74ab93aa936d0603d67d83ae68a..716ade906586932e05d4372076104c198e0a91f9 100644 (file)
@@ -201,7 +201,11 @@ public class CellElapsedFormatter extends CellFormatter {
         }
 
         Formatter formatter = new Formatter(toAppendTo);
-        formatter.format(printfFmt, parts);
+        try {
+            formatter.format(printfFmt, parts);
+        } finally {
+            formatter.close();
+        }
     }
 
     /**
index e00a54c904412992fb604666e19117c201f7d670..8c067576f3e41acfd9268bd4f515d3d227fe05c3 100644 (file)
@@ -57,7 +57,11 @@ public class CellGeneralFormatter extends CellFormatter {
             }
 
             Formatter formatter = new Formatter(toAppendTo);
-            formatter.format(LOCALE, fmt, value);
+            try {
+                formatter.format(LOCALE, fmt, value);
+            } finally {
+                formatter.close();
+            }
             if (stripZeros) {
                 // strip off trailing zeros
                 int removeFrom;
index 485d335e344e45f15fb8a24e4003c4803ee8cff5..2ea72cc693ed9deac96fac5c24a3dc1eceaf907f 100644 (file)
@@ -595,7 +595,11 @@ public class CellNumberFormatter extends CellFormatter {
         } else {
             StringBuffer result = new StringBuffer();
             Formatter f = new Formatter(result);
-            f.format(LOCALE, printfFmt, value);
+            try {
+                f.format(LOCALE, printfFmt, value);
+            } finally {
+                f.close();
+            }
 
             if (numerator == null) {
                 writeFractional(result, output);
@@ -866,7 +870,11 @@ public class CellNumberFormatter extends CellFormatter {
 
         StringBuffer sb = new StringBuffer();
         Formatter formatter = new Formatter(sb);
-        formatter.format(LOCALE, fmt, num);
+        try {
+            formatter.format(LOCALE, fmt, num);
+        } finally {
+            formatter.close();
+        }
         writeInteger(sb, output, numSpecials, mods, false);
     }
 
index d022ee66ce1b402a43da4c4808db76745d9020cc..4159074d76ec45e6b60f63c6d17ace341ca26a5b 100644 (file)
@@ -27,10 +27,10 @@ import java.util.*;
  */
 
 public class BitFieldFactory {
-    private static Map instances = new HashMap();
+    private static Map<Integer, BitField> instances = new HashMap<Integer, BitField>();
 
     public static BitField getInstance(int mask) {
-      BitField f = (BitField)instances.get(Integer.valueOf(mask));
+      BitField f = instances.get(Integer.valueOf(mask));
       if (f == null) {
         f = new BitField(mask);
         instances.put(Integer.valueOf(mask), f);
index 3a9d656a9a1065646042380f001f2d306f327a05..1055ab2da0cdaeacc68b035ce866cc9659308271 100644 (file)
@@ -35,15 +35,18 @@ public class DrawingDump
         POIFSFileSystem fs      =
                 new POIFSFileSystem(new FileInputStream(args[0]));
         HSSFWorkbook wb = new HSSFWorkbook(fs);
-        System.out.println( "Drawing group:" );
-        wb.dumpDrawingGroupRecords(true);
-
-        for (int sheetNum = 1; sheetNum <= wb.getNumberOfSheets(); sheetNum++)
-        {
-            System.out.println( "Sheet " + sheetNum + ":" );
-            HSSFSheet sheet = wb.getSheetAt(sheetNum - 1);
-            sheet.dumpDrawingRecords(true);
+        try {
+            System.out.println( "Drawing group:" );
+            wb.dumpDrawingGroupRecords(true);
+    
+            for (int sheetNum = 1; sheetNum <= wb.getNumberOfSheets(); sheetNum++)
+            {
+                System.out.println( "Sheet " + sheetNum + ":" );
+                HSSFSheet sheet = wb.getSheetAt(sheetNum - 1);
+                sheet.dumpDrawingRecords(true);
+            }
+        } finally {
+            wb.close();
         }
-
     }
 }
index fa7ecb5c4b51debf38f0a2c519118dc0316bd1a4..51b0ceeb2eac641f496345e32df121e49f4cc56e 100644 (file)
@@ -109,7 +109,7 @@ public class HexRead
     {
         int characterCount = 0;
         byte b = (byte) 0;
-        List bytes = new ArrayList();
+        List<Byte> bytes = new ArrayList<Byte>();
         boolean done = false;
         while ( !done )
         {
@@ -163,7 +163,7 @@ public class HexRead
                     break;
             }
         }
-        Byte[] polished = (Byte[]) bytes.toArray( new Byte[0] );
+        Byte[] polished = bytes.toArray( new Byte[0] );
         byte[] rval = new byte[polished.length];
         for ( int j = 0; j < polished.length; j++ )
         {