/**
* Copyright © 2012-2017 by Data Virtuality GmbH
 */
package org.teiid.core.types.basic;

import org.teiid.core.types.BinaryType;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.Transform;
import org.teiid.core.types.TransformationException;

/**
 * 
 * @author Fabio Franco <fabio.franco@datavirtuality.de>
 *
 */
public class StringToBlobTypeTransform extends Transform {

	public Object transformDirect(Object value) throws TransformationException {
		BinaryType contents = (BinaryType) new StringToBinaryTypeTransform().transformDirect(value);                
		return contents.toBlob();
	}

	/**
	 * Type of the incoming value.
	 * @return Source type
	 */
	public Class<?> getSourceType() {
		return DataTypeManager.DefaultDataClasses.STRING;
	}

	/**
	 * Type of the outgoing value.
	 * @return Target type
	 */
	public Class<?> getTargetType() {
		return DataTypeManager.DefaultDataClasses.BLOB;
	}
	
	@Override
	public boolean isExplicit() {
		return true;
	}
	
}
