use of org.jdom2.Element in project JMRI by JMRI.
the class LsDecSignalHeadXml method store.
/**
* Default implementation for storing the contents of a LsDecSignalHead
*
* @param o Object to store, of type LsDecSignalHead
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
LsDecSignalHead p = (LsDecSignalHead) o;
Element element = new Element("signalhead");
element.setAttribute("class", this.getClass().getName());
element.addContent(new Element("systemName").addContent(p.getSystemName()));
storeCommon(p, element);
element.addContent(addTurnoutElement(p.getGreen().getName(), p.getGreenState()));
element.addContent(addTurnoutElement(p.getYellow().getName(), p.getYellowState()));
element.addContent(addTurnoutElement(p.getRed().getName(), p.getRedState()));
element.addContent(addTurnoutElement(p.getFlashGreen().getName(), p.getFlashGreenState()));
element.addContent(addTurnoutElement(p.getFlashYellow().getName(), p.getFlashYellowState()));
element.addContent(addTurnoutElement(p.getFlashRed().getName(), p.getFlashRedState()));
element.addContent(addTurnoutElement(p.getDark().getName(), p.getDarkState()));
return element;
}
use of org.jdom2.Element in project JMRI by JMRI.
the class QuadOutputSignalHeadXml method store.
/**
* Default implementation for storing the contents of a QuadOutputSignalHead
*
* @param o Object to store, of type TripleTurnoutSignalHead
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
QuadOutputSignalHead p = (QuadOutputSignalHead) o;
Element element = new Element("signalhead");
element.setAttribute("class", this.getClass().getName());
element.addContent(new Element("systemName").addContent(p.getSystemName()));
storeCommon(p, element);
element.addContent(addTurnoutElement(p.getGreen(), "green"));
element.addContent(addTurnoutElement(p.getYellow(), "yellow"));
element.addContent(addTurnoutElement(p.getRed(), "red"));
element.addContent(addTurnoutElement(p.getLunar(), "lunar"));
return element;
}
use of org.jdom2.Element in project JMRI by JMRI.
the class DoubleTurnoutSignalHeadXml method store.
/**
* Default implementation for storing the contents of a
* DoubleTurnoutSignalHead
*
* @param o Object to store, of type TripleTurnoutSignalHead
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
DoubleTurnoutSignalHead p = (DoubleTurnoutSignalHead) o;
Element element = new Element("signalhead");
element.setAttribute("class", this.getClass().getName());
element.addContent(new Element("systemName").addContent(p.getSystemName()));
storeCommon(p, element);
element.addContent(addTurnoutElement(p.getGreen(), "green"));
element.addContent(addTurnoutElement(p.getRed(), "red"));
return element;
}
use of org.jdom2.Element in project JMRI by JMRI.
the class DccSignalMastXml method loadCommonDCCMast.
protected boolean loadCommonDCCMast(DccSignalMast m, Element element) {
loadCommon(m, element);
if (element.getChild("unlit") != null) {
Element unlit = element.getChild("unlit");
if (unlit.getAttribute("allowed") != null) {
if (unlit.getAttribute("allowed").getValue().equals("no")) {
m.setAllowUnLit(false);
} else {
m.setAllowUnLit(true);
m.setUnlitId(Integer.parseInt(unlit.getChild("aspect").getValue()));
}
}
}
List<Element> list = element.getChildren("aspect");
for (int i = 0; i < list.size(); i++) {
Element e = list.get(i);
String aspect = e.getAttribute("defines").getValue();
int number = -1;
try {
String value = e.getChild("number").getValue();
number = Integer.parseInt(value);
} catch (Exception ex) {
log.error("failed to convert DCC number");
}
m.setOutputForAppearance(aspect, number);
}
Element e = element.getChild("disabledAspects");
if (e != null) {
list = e.getChildren("disabledAspect");
for (Element aspect : list) {
m.setAspectDisabled(aspect.getText());
}
}
InstanceManager.getDefault(jmri.SignalMastManager.class).register(m);
return true;
}
use of org.jdom2.Element in project JMRI by JMRI.
the class VirtualSignalMastXml method load.
@Override
public boolean load(Element shared, Element perNode) {
VirtualSignalMast m;
String sys = getSystemName(shared);
m = new jmri.implementation.VirtualSignalMast(sys);
if (getUserName(shared) != null) {
m.setUserName(getUserName(shared));
}
loadCommon(m, shared);
if (shared.getChild("unlit") != null) {
Element unlit = shared.getChild("unlit");
if (unlit.getAttribute("allowed") != null) {
if (unlit.getAttribute("allowed").getValue().equals("no")) {
m.setAllowUnLit(false);
} else {
m.setAllowUnLit(true);
}
}
}
Element e = shared.getChild("disabledAspects");
if (e != null) {
List<Element> list = e.getChildren("disabledAspect");
for (Element aspect : list) {
m.setAspectDisabled(aspect.getText());
}
}
InstanceManager.getDefault(jmri.SignalMastManager.class).register(m);
return true;
}
Aggregations