Revision 41199 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/csv/CSVStoreProvider.java
CSVStoreProvider.java | ||
---|---|---|
28 | 28 |
import java.io.FileWriter; |
29 | 29 |
import java.io.IOException; |
30 | 30 |
import java.net.URL; |
31 |
import java.text.NumberFormat; |
|
32 |
import java.text.ParsePosition; |
|
31 | 33 |
import java.text.SimpleDateFormat; |
32 | 34 |
import java.util.ArrayList; |
33 | 35 |
import java.util.HashMap; |
... | ... | |
880 | 882 |
final int T_URL = 4; |
881 | 883 |
final int T_DATE = 5; |
882 | 884 |
boolean possibleDataTypes[][] = null; |
885 |
Locale locale = null; |
|
883 | 886 |
int[] types = null; |
884 | 887 |
|
885 | 888 |
FileReader in = null; |
... | ... | |
904 | 907 |
possibleDataTypes[i][j] = true; |
905 | 908 |
} |
906 | 909 |
} |
907 |
List<String> row = reader.read(); |
|
910 |
locale = CSVStoreParameters.getLocale(getCSVParameters()); |
|
911 |
if( locale == null ) { |
|
912 |
locale = Locale.getDefault(); |
|
913 |
} |
|
914 |
|
|
915 |
DataTypesManager typeManager = ToolsLocator.getDataTypesManager(); |
|
916 |
CoercionWithLocale toDouble = (CoercionWithLocale) typeManager.getCoercion(DataTypes.DOUBLE); |
|
917 |
CoercionWithLocale toFloat = (CoercionWithLocale) typeManager.getCoercion(DataTypes.FLOAT); |
|
918 |
|
|
919 |
List<String> row = reader.read(); |
|
908 | 920 |
|
909 | 921 |
while (row != null) { |
910 | 922 |
for (int i = 0; i < row.size(); i++) { |
... | ... | |
912 | 924 |
Object value = null; |
913 | 925 |
if( possibleDataTypes[i][T_DOUBLE] ) { |
914 | 926 |
try { |
915 |
value = Double.parseDouble((String) rawvalue);
|
|
916 |
possibleDataTypes[i][T_DOUBLE] = true;
|
|
927 |
value = toDouble.coerce(rawvalue, locale);
|
|
928 |
possibleDataTypes[i][T_DOUBLE] = true;
|
|
917 | 929 |
} catch (Exception ex) { |
918 | 930 |
possibleDataTypes[i][T_DOUBLE] = false; |
919 | 931 |
} |
920 | 932 |
} |
921 | 933 |
if( possibleDataTypes[i][T_FLOAT] ) { |
922 | 934 |
try { |
923 |
value = Float.parseFloat((String) rawvalue);
|
|
924 |
possibleDataTypes[i][T_FLOAT] = true;
|
|
935 |
value = toFloat.coerce(rawvalue, locale);
|
|
936 |
possibleDataTypes[i][T_FLOAT] = true;
|
|
925 | 937 |
} catch (Exception ex) { |
926 | 938 |
possibleDataTypes[i][T_FLOAT] = false; |
927 | 939 |
} |
Also available in: Unified diff