001package jmri.jmrix.sprog.serialdriver.configurexml; 002 003import jmri.jmrix.configurexml.AbstractSerialConnectionConfigXml; 004import jmri.jmrix.sprog.serialdriver.ConnectionConfig; 005import jmri.jmrix.sprog.serialdriver.SerialDriverAdapter; 006 007/** 008 * Handle XML persistance of layout connections by persistening the 009 * SerialDriverAdapter (and connections). 010 * <p> 011 * Note this is named as the XML version of a ConnectionConfig object, 012 * but it's actually persisting the SerialDriverAdapter. 013 * <p> 014 * This class is invoked from jmrix.JmrixConfigPaneXml on write, as that class 015 * is the one actually registered. Reads are brought here directly via the class 016 * attribute in the XML. 017 * 018 * @author Bob Jacobsen Copyright (c) 2003 019 */ 020public class ConnectionConfigXml extends AbstractSerialConnectionConfigXml { 021 022 public ConnectionConfigXml() { 023 super(); 024 } 025 026 @Override 027 protected void getInstance() { 028 if (adapter == null) { 029 adapter = new SerialDriverAdapter(); 030 } 031 } 032 033 @Override 034 protected void getInstance(Object object) { 035 adapter = ((ConnectionConfig) object).getAdapter(); 036 } 037 038 @Override 039 protected void register() { 040 this.register(new ConnectionConfig(adapter)); 041 } 042 043}