package de.hsadmin.core.qserv;

import java.util.ArrayList;
import java.util.List;

public class CompoundProcessor extends AbstractProcessor {

	private static final long serialVersionUID = 1L;

	private List<Processor> aProcessors;

	public CompoundProcessor(Processor... aProcessor) {
		aProcessors = new ArrayList<Processor>();
		for (Processor aP : aProcessor) {
			aProcessors.add(aP);
		}
	}

	public Object process() throws ProcessorException {
		for (Processor aProcessor : aProcessors) {
			aProcessor.process();
		}
		return null;
	}

	public void appendProcessor(Processor aProcessor) {
		aProcessors.add(aProcessor);
	}

	@Override
	public String logInfo() {
		StringBuffer log = new StringBuffer();
		for (Processor aProcessor : aProcessors) {
			log.append(aProcessor.logInfo());
			log.append("\n\n");
		}
		return log.toString();
	}
	
}
