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 BinaryToLongTransform extends Transform {
	public Object transformDirect(Object value) throws TransformationException {
        BinaryType contents = (BinaryType) value;
		return new BigInteger(contents.getBytesDirect()).longValue();
	}

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

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

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