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