package org.jerrymouse.cc.site.convert;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jerrymouse.cc.site.bean.Format;
import org.jerrymouse.cc.site.bean.Resource;
import org.jerrymouse.cc.site.bean.Type;

public abstract class AbstractConvertor implements Convertor {

	public List<Type> support(Type type) {
		return support().get(type);
	}

	public byte[] convert(Resource resource) {
		return couvert(resource.getOrgBytes(), resource.getOrgType(), resource
				.getFormat());
	}

	public abstract byte[] couvert(byte[] src, Type from, Format format);

	public Map<Type, List<Type>> support() {
		Map<Type, List<Type>> map = new HashMap<Type, List<Type>>();
		for (Type in : input()) {
			map.put(in, output());
		}
		return map;
	}

	protected abstract List<Type> input();

	protected abstract List<Type> output();

}
