From: Jason Height Date: Tue, 25 Jul 2006 11:50:55 +0000 (+0000) Subject: Clean up of HSSFDataFormat. Whilst Bug 22456 was probably not an issue with the previ... X-Git-Tag: REL_3_0_ALPHA3~64 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3499a86c405b169264599344a127cea9321ea9de;p=poi.git 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 --- diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java b/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java index b4de075bea..b2b145b2b7 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(); } }