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/CoerceToExpression.java
CoerceToExpression.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import org.gvsig.expressionevaluator.Expression; |
27 | 27 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
28 |
import org.gvsig.tools.dataTypes.AbstractCoercion; |
|
28 | 29 |
import org.gvsig.tools.dataTypes.CoercionException; |
29 |
import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
|
|
30 |
import org.gvsig.tools.dataTypes.CoercionContext;
|
|
30 | 31 |
|
31 | 32 |
/** |
32 | 33 |
* Convert a object to Expression. |
33 | 34 |
* |
34 | 35 |
*/ |
35 |
public class CoerceToExpression implements Coercion { |
|
36 |
@SuppressWarnings("UseSpecificCatch") |
|
37 |
public class CoerceToExpression extends AbstractCoercion { |
|
36 | 38 |
|
37 |
@Override |
|
38 |
public Object coerce(Object value) throws CoercionException { |
|
39 |
try { |
|
40 |
if (value == null || value instanceof Expression) { |
|
41 |
return value; |
|
42 |
} |
|
43 |
Expression expression = ExpressionEvaluatorLocator.getManager().createExpression(); |
|
44 |
expression.setPhrase(value.toString()); |
|
45 |
return expression; |
|
46 |
} catch (Exception e) { |
|
47 |
throw new CoercionException(e); |
|
48 |
} |
|
49 |
|
|
39 |
@Override |
|
40 |
public Object coerce(Object value, CoercionContext context) throws CoercionException { |
|
41 |
if (value == null || value instanceof Expression) { |
|
42 |
return value; |
|
50 | 43 |
} |
44 |
try { |
|
45 |
Expression expression = ExpressionEvaluatorLocator.getManager().createExpression(); |
|
46 |
expression.setPhrase(value.toString()); |
|
47 |
return expression; |
|
48 |
} catch (Exception e) { |
|
49 |
throw new CoercionException(e); |
|
50 |
} |
|
51 | 51 |
|
52 |
} |
|
53 |
|
|
52 | 54 |
} |
Also available in: Unified diff