package com.tarisan.chipcard.tpvvs.webservicetrayicon.messages; /** * @author jjrider */ import es.chipcard.util.*; import org.w3c.dom.*; import java.io.*; public abstract class Msg { public static int TYPE_OF_MESSAGE_ERROR=-1; public static int TYPE_OF_MESSAGE_CCREQ=1; public static int TYPE_OF_MESSAGE_CCRES=2; public static String DEFAULT_XML_DECLARATION=""; private Document xmlDoc=null; public Msg(String sMessage) throws Exception{ xmlDoc=SerClsXMLUtils.parsearDocumento(new StringReader(DEFAULT_XML_DECLARATION+""+sMessage+"")); } public Msg(Document doc) throws Exception{ if(doc==null) throw new Exception("El XML dado como argumento no puede ser NULL"); if(!doc.getDocumentElement().getNodeName().equals("Msg")){ throw new Exception("El XML dado como argumento no es un Msg"); } xmlDoc=doc; } public abstract int getTypeOfMessage(); protected Document getDocument(){ return xmlDoc; } public void setRepeticion(boolean blnValue){ xmlDoc.getDocumentElement().setAttribute("repeticion",((blnValue)?"true":"false")); } public String toString(){ return SerClsXMLUtils.dameTextoXml(xmlDoc); } public void saveToOutputStream(OutputStream out) throws Exception{ SerClsXMLUtils.toOutputStream(getDocument(),out); } /****** * Crea un objeto Msg a partir de una cadena * @param sResponse * @return * @throws Exception */ public static Msg createMsgFromString(String sResponse) throws Exception{ /**if(sResponse!=null){ if(!sResponse.trim().startsWith("