001package jmri.jmrit.logixng.tools.debugger.configurexml; 002 003import jmri.jmrit.logixng.*; 004import jmri.jmrit.logixng.configurexml.MaleSocketXml; 005 006import org.jdom2.Element; 007 008// import jmri.jmrit.logixng.implementation.AbstractMaleSocket; 009 010/** 011 * Handle XML configuration for AbstractDebuggerMaleSocket objects. 012 * 013 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010 014 * @author Daniel Bergqvist Copyright (C) 2019 015 */ 016public class AbstractDebuggerMaleSocketXml 017 extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML 018 implements MaleSocketXml { 019 020 public AbstractDebuggerMaleSocketXml() { 021 } 022 023 /** 024 * Default implementation for storing the contents of a ActionMany 025 * 026 * @param o Object to store, of type ActionMany 027 * @return Element containing the complete info 028 */ 029 @Override 030 public Element store(Object o) { 031// AbstractMaleSocket maleSocket = (AbstractMaleSocket) o; 032 033 Element element = new Element("AbstractDebuggerMaleSocket"); 034 element.setAttribute("class", this.getClass().getName()); 035/* 036 element.addContent(new Element("errorHandling").addContent(maleSocket.getErrorHandlingType().name())); 037 for (SymbolTable.VariableData data : maleSocket.getLocalVariables()) { 038 Element elementVariable = new Element("localVariable"); 039 elementVariable.addContent(new Element("name").addContent(data._name)); 040 elementVariable.addContent(new Element("type").addContent(data._initalValueType.name())); 041 elementVariable.addContent(new Element("data").addContent(data._initialValueData)); 042 element.addContent(elementVariable); 043 } 044*/ 045 return element; 046 } 047 048 @Override 049 public boolean load(Element shared, Element perNode) { 050 return false; 051 } 052 053 @Override 054 public boolean load(Element maleSocketElement, MaleSocket maleSocket) { 055/* 056 Element errorHandlingElement = maleSocketElement.getChild("errorHandling"); 057 if (errorHandlingElement != null) { 058 maleSocket.setErrorHandlingType(MaleSocket.ErrorHandlingType 059 .valueOf(errorHandlingElement.getTextTrim())); 060 } 061 062 List<Element> localVariableList = maleSocketElement.getChildren("localVariable"); // NOI18N 063 log.debug("Found " + localVariableList.size() + " male sockets"); // NOI18N 064 065 for (Element e : localVariableList) { 066 Element elementName = e.getChild("name"); 067 068 InitialValueType type = null; 069 Element elementType = e.getChild("type"); 070 if (elementType != null) { 071 type = InitialValueType.valueOf(elementType.getTextTrim()); 072 } 073 074 Element elementData = e.getChild("data"); 075 076 if (elementName == null) throw new IllegalArgumentException("Element 'name' does not exists"); 077 if (type == null) throw new IllegalArgumentException("Element 'type' does not exists"); 078 if (elementData == null) throw new IllegalArgumentException("Element 'data' does not exists"); 079 080 maleSocket.addLocalVariable(elementName.getTextTrim(), type, elementData.getTextTrim()); 081 } 082*/ 083 return true; 084 } 085 086// private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(AbstractDebuggerMaleSocketXml.class); 087}