001package jmri.jmrit.logixng.implementation.configurexml; 002 003import jmri.jmrit.logixng.MaleSocket; 004import jmri.jmrit.logixng.implementation.DefaultMaleDigitalExpressionSocket; 005 006import org.jdom2.Attribute; 007import org.jdom2.Element; 008 009/** 010 * Handle XML configuration for ActionLightXml objects. 011 * 012 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010 013 * @author Daniel Bergqvist Copyright (C) 2019 014 */ 015public class DefaultMaleDigitalExpressionSocketXml extends AbstractMaleSocketXml { 016 017 /** 018 * Default implementation for storing the contents of a ActionMany 019 * 020 * @param o Object to store, of type ActionMany 021 * @return Element containing the complete info 022 */ 023 @Override 024 public Element store(Object o) { 025 Element element = super.store(o); 026 027 DefaultMaleDigitalExpressionSocket maleSocket = (DefaultMaleDigitalExpressionSocket) o; 028 029 element.setAttribute("DefaultMaleDigitalExpressionSocketListen", maleSocket.getListen()? "yes" : "no"); // NOI18N 030 031 return element; 032 } 033 034 @Override 035 public boolean load(Element maleSocketElement, MaleSocket maleSocket) { 036 if (!(maleSocket instanceof DefaultMaleDigitalExpressionSocket)) { 037 throw new IllegalArgumentException("maleSocket is not an AbstractMaleSocket: "+maleSocket.getClass().getName()); 038 } 039 040 String listen = "yes"; 041 Attribute attribute = maleSocketElement.getAttribute("DefaultMaleDigitalExpressionSocketListen"); 042 if (attribute != null) { // NOI18N 043 listen = attribute.getValue(); // NOI18N 044 } 045 ((DefaultMaleDigitalExpressionSocket)maleSocket).setListen("yes".equals(listen)); 046 047 return super.load(maleSocketElement, maleSocket); 048 } 049 050// private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(DefaultMaleDigitalExpressionSocketXml.class); 051}