package org.granite.grails.integration;

import java.lang.reflect.Type;
import java.sql.Blob;
import java.sql.Clob;

import org.granite.messaging.amf.io.convert.Converter;
import org.granite.messaging.amf.io.convert.Converters;
import org.granite.messaging.amf.io.convert.Reverter;


public class GrailsBinaryConverter extends Converter implements Reverter {
	
	public GrailsBinaryConverter(Converters converters) {
		super(converters);
	}

	@Override
	protected boolean internalCanConvert(Object value, Type targetType) {
		return targetType instanceof Class && (Blob.class.isAssignableFrom((Class<?>)targetType) 
			|| Clob.class.isAssignableFrom((Class<?>)targetType));
	}

	@Override
	protected Object internalConvert(Object value, Type targetType) {
		return null;
	}

	@Override
	public boolean canRevert(Object value) {
		return value != null && 
			(value instanceof Blob || value instanceof Clob);
	}

	@Override
	public Object revert(Object value) {
		return value != null ? "" : null;
	}

}

@@ -788,32 +788,34 @@
 n null;%0D%0A%09%7D%0D%0A%0D%0A%09
+//
 @Override%0D%0A%09publ
@@ -933,32 +933,34 @@
  Clob);%0D%0A%09%7D%0D%0A%0D%0A%09
+//
 @Override%0D%0A%09publ

fix GrailsBinaryConverter.java:29: method does not override a method from its superclass