Revision 966 org.gvsig.projection/trunk/org.gvsig.projection.api/src/main/java/org/cresques/coerce/CoerceToCRS.java
CoerceToCRS.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import org.cresques.cts.IProjection; |
26 | 26 |
import org.gvsig.fmap.crs.CRSFactory; |
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 string value of projection code to IProjection |
... | ... | |
34 | 35 |
* @version $Id$ |
35 | 36 |
* |
36 | 37 |
*/ |
37 |
public class CoerceToCRS implements Coercion {
|
|
38 |
public class CoerceToCRS extends AbstractCoercion {
|
|
38 | 39 |
|
39 |
public Object coerce(Object value) throws CoercionException { |
|
40 |
if (value == null) { |
|
41 |
return null;
|
|
40 |
public Object coerce(Object value, CoercionContext context) throws CoercionException {
|
|
41 |
if (value == null || value instanceof IProjection) {
|
|
42 |
return value;
|
|
42 | 43 |
} |
43 | 44 |
try { |
44 |
if (value instanceof IProjection) { |
|
45 |
return value; |
|
46 |
} |
|
47 | 45 |
Object proj = CRSFactory.getCRS(value.toString()); |
48 | 46 |
if (proj == null) { |
49 | 47 |
throw new CoercionException("Can't convert value '" + getValueAsString(value) + "' to IProjection. Probably not a valid format for a projection."); |
Also available in: Unified diff