package org.jbehave.scenario.steps;

import java.io.OutputStream;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import org.jbehave.scenario.annotations.Aliases;
import org.jbehave.scenario.annotations.Given;
import org.jbehave.scenario.annotations.Then;
import org.jbehave.scenario.annotations.When;

public class DefaultStepDocGenerator implements StepDocGenerator {

	public List<StepDoc> generate(Class<?> stepsClass) {
		List<StepDoc> stepdocs = new LinkedList<StepDoc>();
		for (Method method : stepsClass.getMethods()) {
			if (method.isAnnotationPresent(Given.class)) {
				stepdocs.add(new StepDoc(Given.class, method.getAnnotation(Given.class).value(), 
						aliases(method), method));
			}
			if (method.isAnnotationPresent(When.class)) {
				stepdocs.add(new StepDoc(When.class, method.getAnnotation(When.class).value(), 
						aliases(method), method));
			}
			if (method.isAnnotationPresent(Then.class)) {
				stepdocs.add(new StepDoc(Then.class, method.getAnnotation(Then.class).value(), 
						aliases(method), method));
			}
		}
		Collections.sort(stepdocs);
		return stepdocs;		
	}

	private String[] aliases(Method method) {
		if (method.isAnnotationPresent(Aliases.class)) {
			return method.getAnnotation(Aliases.class).values();
		}
		return new String[]{};
	}

	public void reportTo(List<StepDoc> stepdocs, OutputStream outputStream) {
		// TODO Auto-generated method stub
		
	}


}

@@ -34,37 +34,8 @@
 s;%0A%0A
-import java.io.OutputStream;%0A
 impo
@@ -1323,126 +1323,6 @@
 %09%7D%0A%0A
-%09public void reportTo(List%3CStepDoc%3E stepdocs, OutputStream outputStream) %7B%0A%09%09// TODO Auto-generated method stub%0A%09%09%0A%09%7D%0A%0A%0A
 %7D%0A

Removed empty method.