use of jmri.SignalHeadManager in project JMRI by JMRI.
the class AbstractSignalHeadManagerXml method store.
/**
* Default implementation for storing the contents of a SignalHeadManager.
* <P>
* Unlike most other managers, the individual SignalHead objects are stored
* separately via the configuration system so they can have separate type
* information.
*
* @param o Object to store, of type SignalHeadManager
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
Element signalheads = new Element("signalheads");
setStoreElementClass(signalheads);
SignalHeadManager sm = (SignalHeadManager) o;
if (sm != null) {
java.util.Iterator<String> iter = sm.getSystemNameList().iterator();
// don't return an element if there are not signalheads to include
if (!iter.hasNext()) {
return null;
}
// store the signalheads
while (iter.hasNext()) {
String sname = iter.next();
if (sname == null) {
log.error("System name null during store, skipped");
continue;
}
log.debug("system name is " + sname);
SignalHead sub = sm.getBySystemName(sname);
try {
Element e = jmri.configurexml.ConfigXmlManager.elementFromObject(sub);
if (e != null) {
signalheads.addContent(e);
}
} catch (Exception e) {
log.error("Error storing signalhead: {}", e, e);
}
}
}
return signalheads;
}
use of jmri.SignalHeadManager in project JMRI by JMRI.
the class JUnitUtil method initInternalSignalHeadManager.
public static void initInternalSignalHeadManager() {
SignalHeadManager m = new AbstractSignalHeadManager();
InstanceManager.setSignalHeadManager(m);
if (InstanceManager.getNullableDefault(ConfigureManager.class) != null) {
InstanceManager.getDefault(ConfigureManager.class).registerConfig(m, jmri.Manager.SIGNALHEADS);
}
}
Aggregations