Revision 44669 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/coercion/CoerceToString.java
CoerceToString.java | ||
---|---|---|
24 | 24 |
package org.gvsig.expressionevaluator.impl.coercion; |
25 | 25 |
|
26 | 26 |
import org.gvsig.expressionevaluator.Expression; |
27 |
import org.gvsig.tools.dataTypes.AbstractCoercion; |
|
27 | 28 |
import org.gvsig.tools.dataTypes.CoercionException; |
28 |
import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
|
|
29 |
import org.gvsig.tools.dataTypes.CoercionContext;
|
|
29 | 30 |
|
30 | 31 |
/** |
31 | 32 |
* Convert a Expression to String. |
32 | 33 |
* |
33 | 34 |
*/ |
34 |
public class CoerceToString implements Coercion {
|
|
35 |
public class CoerceToString extends AbstractCoercion {
|
|
35 | 36 |
|
36 |
public CoerceToString() {
|
|
37 |
// Do nothing
|
|
38 |
}
|
|
37 |
public CoerceToString() { |
|
38 |
// Do nothing |
|
39 |
} |
|
39 | 40 |
|
40 |
@Override |
|
41 |
public Object coerce(Object value) throws CoercionException { |
|
42 |
try { |
|
43 |
if (value == null || value instanceof String) { |
|
44 |
return value; |
|
45 |
} |
|
46 |
if (value instanceof Expression) { |
|
47 |
return ((Expression) value).getPhrase(); |
|
48 |
} |
|
49 |
} catch (Exception e) { |
|
50 |
throw new CoercionException(e); |
|
51 |
} |
|
52 |
throw new CoercionException(); |
|
41 |
@Override |
|
42 |
public Object coerce(Object value, CoercionContext context) throws CoercionException { |
|
43 |
if (value == null || value instanceof String) { |
|
44 |
return value; |
|
53 | 45 |
} |
46 |
try { |
|
47 |
if (value instanceof Expression) { |
|
48 |
return ((Expression) value).getPhrase(); |
|
49 |
} |
|
50 |
} catch (Exception e) { |
|
51 |
throw new CoercionException(e); |
|
52 |
} |
|
53 |
throw new CoercionException(); |
|
54 |
} |
|
54 | 55 |
|
55 | 56 |
} |
Also available in: Unified diff