001package jmri.jmrit.logixng.expressions.configurexml;
002
003import jmri.*;
004import jmri.configurexml.JmriConfigureXmlException;
005import jmri.jmrit.logixng.*;
006import jmri.jmrit.logixng.expressions.ExpressionLinuxLinePower;
007
008import org.jdom2.Element;
009
010/**
011 * Handle XML configuration for ExpressionLinuxLinePowerXml objects.
012 *
013 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010
014 * @author Daniel Bergqvist Copyright (C) 2023
015 */
016public class ExpressionLinuxLinePowerXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML {
017
018    public ExpressionLinuxLinePowerXml() {
019    }
020
021    /**
022     * Default implementation for storing the contents of a ExpressionLinuxLinePower
023     *
024     * @param o Object to store, of type ExpressionLinuxLinePower
025     * @return Element containing the complete info
026     */
027    @Override
028    public Element store(Object o) {
029        ExpressionLinuxLinePower p = (ExpressionLinuxLinePower) o;
030
031        Element element = new Element("ExpressionLinuxLinePower");
032        element.setAttribute("class", this.getClass().getName());
033        element.addContent(new Element("systemName").addContent(p.getSystemName()));
034
035        storeCommon(p, element);
036
037        element.addContent(new Element("is_isNot").addContent(p.get_Is_IsNot().name()));
038
039        return element;
040    }
041
042    @Override
043    public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException {
044        String sys = getSystemName(shared);
045        String uname = getUserName(shared);
046        ExpressionLinuxLinePower h = new ExpressionLinuxLinePower(sys, uname);
047
048        loadCommon(h, shared);
049
050        Element is_IsNot = shared.getChild("is_isNot");
051        if (is_IsNot != null) {
052            h.set_Is_IsNot(Is_IsNot_Enum.valueOf(is_IsNot.getTextTrim()));
053        }
054
055        InstanceManager.getDefault(DigitalExpressionManager.class).registerExpression(h);
056        return true;
057    }
058
059//    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ExpressionLinuxLinePowerXml.class);
060}