Revision 44669 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 | ||
---|---|---|
88 | 88 |
import org.gvsig.tools.ToolsLocator; |
89 | 89 |
import org.gvsig.tools.dataTypes.DataType; |
90 | 90 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
91 |
import org.gvsig.tools.dataTypes.DataTypesManager.Coercion; |
|
92 |
import org.gvsig.tools.dataTypes.DataTypesManager.CoercionWithLocale; |
|
91 |
import org.gvsig.tools.dataTypes.Coercion; |
|
93 | 92 |
import org.gvsig.tools.dispose.DisposableIterator; |
94 | 93 |
import org.gvsig.tools.dynobject.Tags; |
95 | 94 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
... | ... | |
107 | 106 |
import org.slf4j.Logger; |
108 | 107 |
import org.slf4j.LoggerFactory; |
109 | 108 |
import org.supercsv.prefs.CsvPreference; |
109 |
import org.gvsig.tools.dataTypes.CoercionContext; |
|
110 | 110 |
|
111 | 111 |
@SuppressWarnings("UseSpecificCatch") |
112 | 112 |
public class CSVStoreProvider extends AbstractMemoryStoreProvider implements |
... | ... | |
114 | 114 |
|
115 | 115 |
private static final Logger LOGGER = LoggerFactory.getLogger(CSVStoreProvider.class); |
116 | 116 |
|
117 |
public static final String NAME = "CSV";
|
|
117 |
public static final String NAME = DataStore.CSV_PROVIDER_NAME;
|
|
118 | 118 |
public static final String DESCRIPTION = "CSV file"; |
119 | 119 |
|
120 | 120 |
public static final String METADATA_DEFINITION_NAME = NAME; |
... | ... | |
538 | 538 |
this.type = DataTypes.GEOMETRY; |
539 | 539 |
} |
540 | 540 |
} |
541 |
this.size = DALLocator.getManager().getDefaultSize(this.type);
|
|
541 |
this.size = 0;
|
|
542 | 542 |
|
543 | 543 |
while (n < args.length) { |
544 | 544 |
String option = StringUtils.trim(args[n++].toLowerCase()); |
... | ... | |
976 | 976 |
store.setFeatureTypes(ftypes, ftype); |
977 | 977 |
|
978 | 978 |
Coercion coercion[] = new Coercion[ftype.size()]; |
979 |
CoercionContext coercionContext[] = new CoercionContext[ftype.size()]; |
|
979 | 980 |
int sizes[] = new int[ftype.size()]; |
980 | 981 |
for (int i = 0; i < ftype.size(); i++) { |
981 | 982 |
sizes[i] = -1; |
982 | 983 |
FeatureAttributeDescriptor ad = ftype.getAttributeDescriptor(i); |
983 |
coercion[i] = ad.getDataType().getCoercion(); |
|
984 |
coercion[i] = ad.getCoercion(); |
|
985 |
coercionContext[i] = ad.getCoercionContext(); |
|
984 | 986 |
switch (ad.getDataType().getType()) { |
985 | 987 |
case DataTypes.INT: |
986 |
sizes[i] = 10;
|
|
988 |
sizes[i] = 0; |
|
987 | 989 |
break; |
988 | 990 |
case DataTypes.LONG: |
989 |
sizes[i] = 20;
|
|
991 |
sizes[i] = 0; |
|
990 | 992 |
break; |
991 | 993 |
case DataTypes.STRING: |
992 | 994 |
if (ad.getSize() == 0) { |
... | ... | |
1025 | 1027 |
Object rawvalue = row.get(i); |
1026 | 1028 |
try { |
1027 | 1029 |
Object value = null; |
1028 |
if (locale != null && coercion[i] instanceof CoercionWithLocale) { |
|
1029 |
value = ((CoercionWithLocale) (coercion[i])).coerce(rawvalue, locale); |
|
1030 |
} else { |
|
1031 |
value = coercion[i].coerce(rawvalue); |
|
1032 |
} |
|
1030 |
value = coercion[i].coerce(rawvalue, coercionContext[i]); |
|
1033 | 1031 |
feature.set(i, value); |
1034 | 1032 |
if (sizes[i] >= 0 |
1035 | 1033 |
&& (value instanceof String || value instanceof URL |
Also available in: Unified diff