From 3ffa62ef21592fbd8cab56be6c61dd4b1c6c6d43 Mon Sep 17 00:00:00 2001 From: Jason Height Date: Tue, 25 Jul 2006 11:50:55 +0000 Subject: [PATCH] Clean up of HSSFDataFormat. Whilst Bug 22456 was probably not an issue with the previous code, these changes are even better ;-) Squashing Bug 22456 now. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@425376 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/usermodel/HSSFDataFormat.java | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java b/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java index b4de075be..b2b145b2b 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java @@ -80,7 +80,7 @@ import java.util.Vector; public class HSSFDataFormat { - private static Vector builtinFormats; + private static List builtinFormats = createBuiltinFormats(); private Vector formats = new Vector(); private Workbook workbook; @@ -97,7 +97,6 @@ public class HSSFDataFormat public HSSFDataFormat( Workbook workbook ) { this.workbook = workbook; - if ( builtinFormats == null ) populateBuiltinFormats(); Iterator i = workbook.getFormats().iterator(); while ( i.hasNext() ) { @@ -111,9 +110,9 @@ public class HSSFDataFormat } - private static synchronized void populateBuiltinFormats() + private static synchronized List createBuiltinFormats() { - builtinFormats = new Vector(); + List builtinFormats = new Vector(); builtinFormats.add( 0, "General" ); builtinFormats.add( 1, "0" ); builtinFormats.add( 2, "0.00" ); @@ -169,14 +168,11 @@ public class HSSFDataFormat builtinFormats.add( 0x2f, "mm:ss.0" ); builtinFormats.add( 0x30, "##0.0E+0" ); builtinFormats.add( 0x31, "@" ); + return builtinFormats; } public static List getBuiltinFormats() { - if ( builtinFormats == null ) - { - populateBuiltinFormats(); - } return builtinFormats; } @@ -192,10 +188,6 @@ public class HSSFDataFormat if (format.toUpperCase().equals("TEXT")) format = "@"; - if ( builtinFormats == null ) - { - populateBuiltinFormats(); - } short retval = -1; for (short k = 0; k <= 0x31; k++) @@ -282,10 +274,6 @@ public class HSSFDataFormat public static String getBuiltinFormat( short index ) { - if ( builtinFormats == null ) - { - populateBuiltinFormats(); - } return (String) builtinFormats.get( index ); } @@ -296,10 +284,6 @@ public class HSSFDataFormat public static int getNumberOfBuiltinBuiltinFormats() { - if ( builtinFormats == null ) - { - populateBuiltinFormats(); - } return builtinFormats.size(); } }