package org.cocolab.inpro.incremental.listener;

import java.io.PrintStream;
import java.util.Collection;
import java.util.List;

import org.cocolab.inpro.incremental.unit.EditMessage;
import org.cocolab.inpro.incremental.unit.IU;
import org.cocolab.inpro.incremental.unit.WordIU;

public class OutputForSimpleText extends HypothesisChangeListener {
	
	PrintStream outputStream = System.out;
	
	@Override
	public void hypChange(Collection<? extends IU> ius,
			List<? extends EditMessage<? extends IU>> edits) {
		if (ius.size() > 0) {
			boolean commitFlag = false;
			for (EditMessage<?> e : edits) {
				switch (e.getType()) {
				case REVOKE: 
					outputStream.print("!1 "); 
					break; 
				case ADD: 
					outputStream.print(((WordIU) e.getIU()).getWord() + " ");
					break;
				case COMMIT: 
					commitFlag = true;
					break;
				default:
					assert false : "You defined a new edit type without telling me!";
				}		
			}
			if (commitFlag) {
				outputStream.println();
				outputStream.println();
			}
		}
	}

}

@@ -385,16 +385,43 @@
 em.out;%0A
+%09String outputString = %22%22;%0A
 %09%0A%09@Over
@@ -668,16 +668,46 @@
 EVOKE: %0A
+%09%09%09%09%09outputString += %22!1 %22;%0A//
 %09%09%09%09%09out
@@ -759,16 +759,77 @@
 e ADD: %0A
+%09%09%09%09%09outputString += ((WordIU) e.getIU()).getWord() + %22 %22;%0A//
 %09%09%09%09%09out
@@ -1063,24 +1063,83 @@
 mmitFlag) %7B%0A
+%09%09%09%09outputStream.print(%22For SimpleText: %22 + outputString);%0A
 %09%09%09%09outputSt
@@ -1163,37 +1163,32 @@
 %09%09%09outputStr
-eam.println()
+ing = %22%22
 ;%0A%09%09%09%7D%0A%09%09%7D%0A%09

Creates a string output on wordIU commit messages.