Revision 44895 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.daltransform.app/org.gvsig.daltransform.app.join/src/main/java/org/gvsig/app/join/dal/feature/JoinTransform.java
JoinTransform.java | ||
---|---|---|
30 | 30 |
import java.util.List; |
31 | 31 |
import java.util.Map; |
32 | 32 |
import java.util.Map.Entry; |
33 |
import java.util.Objects; |
|
34 |
import java.util.logging.Level; |
|
33 | 35 |
import org.apache.commons.lang3.StringUtils; |
34 | 36 |
import org.gvsig.fmap.dal.DataTypes; |
35 | 37 |
|
... | ... | |
46 | 48 |
import org.gvsig.fmap.dal.feature.FeatureType; |
47 | 49 |
import org.gvsig.fmap.dal.feature.exception.SetReadOnlyAttributeException; |
48 | 50 |
import org.gvsig.tools.ToolsLocator; |
51 |
import org.gvsig.tools.dataTypes.Coercion; |
|
52 |
import org.gvsig.tools.dataTypes.CoercionException; |
|
53 |
import org.gvsig.tools.dataTypes.DataType; |
|
49 | 54 |
import org.gvsig.tools.dispose.DisposableIterator; |
50 | 55 |
import org.gvsig.tools.dynobject.DynStruct; |
51 | 56 |
import org.gvsig.tools.evaluator.Evaluator; |
... | ... | |
414 | 419 |
private Object value; |
415 | 420 |
private String sql; |
416 | 421 |
private EvaluatorFieldsInfo info = null; |
422 |
private Coercion coercion; |
|
417 | 423 |
|
418 | 424 |
// private int attributeIndex; |
419 | 425 |
public JoinTransformEvaluator(String attribute, boolean is_numeric) { |
... | ... | |
427 | 433 |
|
428 | 434 |
public void updateValue(Object value) { |
429 | 435 |
this.value = value; |
430 |
String qt = this.isNumeric ? "" : "'"; |
|
431 |
this.sql = this.attribute + " = " + qt + this.value + qt; |
|
436 |
this.coercion = null; |
|
437 |
if (this.value!=null) { |
|
438 |
DataType dataType = ToolsLocator.getDataTypesManager().getDataType(value.getClass()); |
|
439 |
if (dataType!=null) { |
|
440 |
this.coercion = dataType.getCoercion(); |
|
441 |
} |
|
442 |
String qt = this.isNumeric ? "" : "'"; |
|
443 |
this.sql = this.attribute + " = " + qt + this.value + qt; |
|
444 |
} else { |
|
445 |
this.sql = this.attribute + " = null"; |
|
446 |
} |
|
432 | 447 |
this.info = new EvaluatorFieldsInfo(); |
433 | 448 |
this.info.addMatchFieldValue(this.attribute, value); |
434 | 449 |
} |
... | ... | |
439 | 454 |
if( curValue == null ) { |
440 | 455 |
return value == null; |
441 | 456 |
} |
442 |
return curValue.equals(value); |
|
457 |
if ( value == null) { |
|
458 |
return false; |
|
459 |
} |
|
460 |
Object coerceValue; |
|
461 |
if (this.coercion == null) { |
|
462 |
return StringUtils.equals(Objects.toString(curValue), Objects.toString(value)); |
|
463 |
} |
|
464 |
try { |
|
465 |
coerceValue = this.coercion.coerce(curValue); |
|
466 |
return coerceValue.equals(value); |
|
467 |
} catch (CoercionException ex) { |
|
468 |
return StringUtils.equals(Objects.toString(curValue), Objects.toString(value)); |
|
469 |
} |
|
443 | 470 |
} |
444 | 471 |
|
445 | 472 |
@Override |
Also available in: Unified diff