package at.gv.egovernment.moa.id.auth.parser;
import java.util.List;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import at.gv.egovernment.moa.id.ParseException;
import at.gv.egovernment.moa.util.DOMUtils;
/**
* Parses an <ErrorResponse>
.
*
* @author Stefan Knirsch
* @version $Id$
*/
public class ErrorResponseParser {
/**
* The error code included in this error response.
* 1000
is used as default value, if some problems occur on
* evaluating the error response.
*/
private String errorCode_ = "1000";
/**
* The error info included in this error response.
* <Unklassifizierter Fehler.>
is used as default value,
* if some problems occur on evaluating the error response.
*/
private String errorInfo_ = "Unklassifizierter Fehler.";
/**
* This Constructor extracts the error code and error info included in this
* error response.
*
* @param errorElement The error element. This is the root element of
* the error response.
*/
public ErrorResponseParser(Element errorElement) throws ParseException {
if (errorElement != null) {
String namespace = errorElement.getNamespaceURI();
NodeList nl = errorElement.getElementsByTagNameNS(namespace, "ErrorCode");
if (nl.getLength() == 1) {
errorCode_ = ((Element)nl.item(0)).getFirstChild().getNodeValue();
}
nl = errorElement.getElementsByTagNameNS(namespace, "Info");
if (nl.getLength() == 1) {
errorInfo_ = ((Element)nl.item(0)).getFirstChild().getNodeValue();
}
}
}
/**
* Returns the error code included in this error response.
*/
public String getErrorCode() {
return errorCode_ ;
}
/**
* Returns the information included in this error response.
* @return The error infomation String
*/
public String getErrorInfo() {
return errorInfo_ ;
}
}