package org.teiid.core.types.basic;

import java.math.BigInteger;

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

public class LongToBinaryTransform extends Transform {
	public Object transformDirect(Object value) throws TransformationException {
		Long contents = (Long) value;
		return new BinaryType(BigInteger.valueOf(contents).toByteArray());
	}

	public Class<?> getSourceType() {
		return DataTypeManager.DefaultDataClasses.LONG;
	}

	public Class<?> getTargetType() {
		return DataTypeManager.DefaultDataClasses.VARBINARY;
	}

	@Override
	public boolean isExplicit() {
		return true;
	}
}
