package de.sekmi.li2b2.hive;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class HiveResponse extends HiveMessage{

	public HiveResponse(Document dom) {
		super(dom);
	}

	public Element getResponseHeader(){
		return (Element)getMessageHeader().getNextSibling();
	}
	public ResultStatus getResultStatus(){
		Element rh = getResponseHeader();
		NodeList nl = rh.getElementsByTagName("result_status");
		if( nl.getLength() == 0 ){
			return null;
		}else{
			return new ResultStatus((Element)nl.item(0).getFirstChild());
		}
	}
	public static class ResultStatus{
		private Element status;
		public ResultStatus(Element status){
			this.status = status;
		}
		public String getCode(){
			return status.getAttribute("type");
		}
		public String getMessage(){
			return status.getTextContent();
		}
	}
}

@@ -84,33 +84,8 @@
 nt;%0A
-import org.w3c.dom.Node;%0A
 impo
@@ -564,24 +564,307 @@
 ());%0A%09%09%7D%0A%09%7D%0A
+%09public void setResultStatus(String type, String message)%7B%0A%09%09Element rh = getResponseHeader();%0A%09%09NodeList nl = rh.getElementsByTagName(%22result_status%22);%0A%09%09Element status = (Element)nl.item(0).getFirstChild();%0A%09%09status.setAttribute(%22type%22, type);%0A%09%09status.setTextContent(message);%0A%09%7D%0A
 %09public stat

allow setting the response status