Revision 966 org.gvsig.projection/trunk/org.gvsig.projection.api/src/main/java/org/cresques/coerce/CoerceToString.java

View differences:

CoerceToString.java
24 24
package org.cresques.coerce;
25 25

  
26 26
import org.cresques.cts.IProjection;
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.Coercion;
30
import org.gvsig.tools.dataTypes.CoercionContext;
29 31

  
30 32
/**
31 33
 * Convert a Projection to String.
......
37 39
 * @version $Id$
38 40
 * 
39 41
 */
40
public class CoerceToString implements Coercion {
42
public class CoerceToString extends AbstractCoercion {
41 43

  
42
	Coercion previous = null;
43
	
44 44
	public CoerceToString() {
45 45
		// Do nothing
46 46
	}
47 47
	
48
	public CoerceToString(Coercion previous) {
49
		this.previous = previous;
50
	}
51
	
52
	
53
	public Object coerce(Object value) throws CoercionException {
48
	public Object coerce(Object value, CoercionContext context) throws CoercionException {
49
    if( value == null || value instanceof String ) {
50
      return value;
51
    }
54 52
		try {
55
			if( value == null || value instanceof String ) {
56
				return value;
57
			}
58 53
			if( value instanceof IProjection ) {
59 54
				return ((IProjection)value).getFullCode();
60 55
			}
61
			if( previous != null ) {
62
				return previous.coerce(value);
63
			}
64 56
		} catch (Exception e) {
65 57
			throw new CoercionException(e);
66 58
		}

Also available in: Unified diff