001package jmri.jmrit.logixng.actions.configurexml;
002
003import jmri.*;
004import jmri.configurexml.JmriConfigureXmlException;
005import jmri.jmrit.logixng.StringActionManager;
006import jmri.jmrit.logixng.actions.StringActionMemory;
007import jmri.jmrit.logixng.util.configurexml.LogixNG_SelectNamedBeanXml;
008
009import org.jdom2.Element;
010
011/**
012 *
013 */
014public class StringActionMemoryXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML {
015
016    public StringActionMemoryXml() {
017    }
018
019    /**
020     * Default implementation for storing the contents of a SE8cSignalHead
021     *
022     * @param o Object to store, of type TripleLightSignalHead
023     * @return Element containing the complete info
024     */
025    @Override
026    public Element store(Object o) {
027        StringActionMemory p = (StringActionMemory) o;
028
029        Element element = new Element("StringActionMemory");
030        element.setAttribute("class", this.getClass().getName());
031        element.addContent(new Element("systemName").addContent(p.getSystemName()));
032
033        storeCommon(p, element);
034
035        var selectNamedBeanXml = new LogixNG_SelectNamedBeanXml<Memory>();
036        element.addContent(selectNamedBeanXml.store(p.getSelectNamedBean(), "namedBean"));
037
038        return element;
039    }
040
041    @Override
042    public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException {     // Test class that inherits this class throws exception
043        String sys = getSystemName(shared);
044        String uname = getUserName(shared);
045        StringActionMemory h = new StringActionMemory(sys, uname);
046
047        loadCommon(h, shared);
048
049        var selectNamedBeanXml = new LogixNG_SelectNamedBeanXml<Memory>();
050        selectNamedBeanXml.load(shared.getChild("namedBean"), h.getSelectNamedBean());
051        selectNamedBeanXml.loadLegacy(shared, h.getSelectNamedBean(), "memory");
052
053        InstanceManager.getDefault(StringActionManager.class).registerAction(h);
054        return true;
055    }
056
057//    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(StringActionMemoryXml.class);
058}