package eu.ydp.empiria.player.client.controller.communication;

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

import com.google.gwt.xml.client.NodeList;
import eu.ydp.empiria.player.client.controller.variables.objects.outcome.Outcome;
import eu.ydp.empiria.player.client.util.xml.document.XMLData;

public class InitialItemData {

	protected Map<String, Outcome> outcomes;
	
	public InitialItemData(XMLData itemData){

		NodeList outcomeDeclarationNodes = null;
		
		if (itemData != null)
			outcomeDeclarationNodes = itemData.getDocument().getElementsByTagName("outcomeDeclaration");
		
		outcomes = new HashMap<String, Outcome>();
		
		Outcome currOutcome;
		for (int i = 0 ; i < outcomeDeclarationNodes.getLength() ; i ++){
			currOutcome = new Outcome(outcomeDeclarationNodes.item(i));
			if (currOutcome != null){
				outcomes.put(currOutcome.identifier, currOutcome);
			}
		}
	}
	
	public Map<String, Outcome> getOutcomes(){		
		return outcomes;
	}
	
}

@@ -531,16 +531,66 @@
 l;%0D%0A%09%09%0D%0A
+%09%09outcomes = new HashMap%3CString, Outcome%3E();%0D%0A%09%09%0D%0A
 %09%09if (it
@@ -604,16 +604,17 @@
 != null)
+%7B
 %0D%0A%09%09%09out
@@ -713,57 +713,8 @@
 %09%0D%0A%09
-%09outcomes = new HashMap%3CString, Outcome%3E();%0D%0A%09%09%0D%0A
 %09%09Ou
@@ -735,16 +735,17 @@
 ome;%0D%0A%09%09
+%09
 for (int
@@ -803,16 +803,17 @@
 i ++)%7B%0D%0A
+%09
 %09%09%09currO
@@ -871,16 +871,17 @@
 ));%0D%0A%09%09%09
+%09
 if (curr
@@ -895,24 +895,25 @@
  != null)%7B%0D%0A
+%09
 %09%09%09%09outcomes
@@ -956,16 +956,23 @@
 come);%0D%0A
+%09%09%09%09%7D%0D%0A
 %09%09%09%7D%0D%0A%09%09

fix potential npe