001package jmri.jmrit.logixng.expressions.configurexml;
002
003import jmri.InstanceManager;
004import jmri.configurexml.JmriConfigureXmlException;
005import jmri.jmrit.logixng.StringExpressionManager;
006import jmri.jmrit.logixng.expressions.StringExpressionConstant;
007
008import org.jdom2.Element;
009
010/**
011 * Handle XML configuration for ActionLightXml objects.
012 *
013 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010
014 * @author Daniel Bergqvist Copyright (C) 2019
015 */
016public class StringExpressionConstantXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML {
017
018    public StringExpressionConstantXml() {
019    }
020    
021    /**
022     * Default implementation for storing the contents of a SE8cSignalHead
023     *
024     * @param o Object to store, of type TripleLightSignalHead
025     * @return Element containing the complete info
026     */
027    @Override
028    public Element store(Object o) {
029        StringExpressionConstant p = (StringExpressionConstant) o;
030
031        Element element = new Element("StringExpressionConstant");
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("value").addContent(p.getValue()));
038        
039        return element;
040    }
041    
042    @Override
043    public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException {     // Test class that inherits this class throws exception
044        String sys = getSystemName(shared);
045        String uname = getUserName(shared);
046        StringExpressionConstant h;
047        h = new StringExpressionConstant(sys, uname);
048
049        loadCommon(h, shared);
050
051        Element valueElement = shared.getChild("value");
052        h.setValue(valueElement.getTextTrim());
053
054        InstanceManager.getDefault(StringExpressionManager.class).registerExpression(h);
055        return true;
056    }
057    
058//    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(AnalogExpressionConstantXml.class);
059}