use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project JMRI by JMRI.
the class AbstractNamedBeanManagerConfigXMLTest method testStoreNullProperty.
public void testStoreNullProperty() {
// Create the manager to test
AbstractNamedBeanManagerConfigXML x = new NamedBeanManagerConfigXMLTest();
// create a NamedBean with two properties to store
NamedBean from = new AbstractNamedBean("sys", "usr") {
@Override
public int getState() {
return 0;
}
@Override
public void setState(int i) {
}
@Override
public String getBeanType() {
return "";
}
};
from.setProperty("foo", null);
from.setProperty("biff", Boolean.valueOf(true));
// create element for properties
Element p = new Element("test");
x.storeProperties(from, p);
// create NamedBean to load
NamedBean to = new AbstractNamedBean("sys", "usr") {
@Override
public int getState() {
return 0;
}
@Override
public void setState(int i) {
}
@Override
public String getBeanType() {
return "";
}
};
x.loadProperties(to, p);
// and test
Assert.assertEquals(null, to.getProperty("foo"));
Assert.assertEquals(Boolean.valueOf(true), to.getProperty("biff"));
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project JMRI by JMRI.
the class LocaleSelectorTest method testFindPartialCode.
public void testFindPartialCode() {
LocaleSelector.suffixes = new String[] { "kl_KL", "kl" };
Namespace xml = Namespace.XML_NAMESPACE;
Element el = new Element("foo").setAttribute("temp", "a").addContent(new Element("temp").setAttribute("lang", "aa_BB", xml).addContent("b")).addContent(new Element("temp").setAttribute("lang", "kl", xml).addContent("c")).addContent(new Element("temp").setAttribute("lang", "kl_AA", xml).addContent("d"));
String result = LocaleSelector.getAttribute(el, "temp");
Assert.assertEquals("find default", "c", result);
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project JMRI by JMRI.
the class LocaleSelectorTest method testFindFullCode.
public void testFindFullCode() {
LocaleSelector.suffixes = new String[] { "kl_KL", "kl" };
Namespace xml = Namespace.XML_NAMESPACE;
Element el = new Element("foo").setAttribute("temp", "a").addContent(new Element("temp").setAttribute("lang", "aa_BB", xml).addContent("b")).addContent(new Element("temp").setAttribute("lang", "kl", xml).addContent("b")).addContent(new Element("temp").setAttribute("lang", "kl_KL", xml).addContent("c"));
String result = LocaleSelector.getAttribute(el, "temp");
Assert.assertEquals("find default", "c", result);
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project JMRI by JMRI.
the class SE8cSignalHeadXml method addTurnoutElement.
Element addTurnoutElement(NamedBeanHandle<Turnout> to, String which) {
Element el = new Element("turnoutname");
el.setAttribute("defines", which);
el.addContent(to.getName());
return el;
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project JMRI by JMRI.
the class BlockBossLogicXml method store.
/**
* Default implementation for storing the contents of all the BLockBossLogic
* elements.
* <P>
* Static members in the BlockBossLogic class record the complete set of
* items. This function writes those out as a single XML element.
*
* @param o Object to start process, but not actually used
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
Enumeration<BlockBossLogic> e = BlockBossLogic.entries();
if (!e.hasMoreElements()) {
// nothing to write!
return null;
}
Element blocks = new Element("signalelements");
blocks.setAttribute("class", this.getClass().getName());
while (e.hasMoreElements()) {
BlockBossLogic p = e.nextElement();
Element block = new Element("signalelement");
block.setAttribute("signal", p.getDrivenSignal());
block.setAttribute("mode", "" + p.getMode());
if (p.getApproachSensor1() != null) {
block.setAttribute("approachsensor1", p.getApproachSensor1());
}
if (p.getSensor1() != null) {
block.addContent(storeSensor(p.getSensor1()));
}
if (p.getSensor2() != null) {
block.addContent(storeSensor(p.getSensor2()));
}
if (p.getSensor3() != null) {
block.addContent(storeSensor(p.getSensor3()));
}
if (p.getSensor4() != null) {
block.addContent(storeSensor(p.getSensor4()));
}
if (p.getSensor5() != null) {
block.addContent(storeSensor(p.getSensor5()));
}
if (p.getTurnout() != null) {
block.setAttribute("watchedturnout", p.getTurnout());
}
if (p.getWatchedSignal1() != null) {
block.setAttribute("watchedsignal1", p.getWatchedSignal1());
}
if (p.getWatchedSignal1Alt() != null) {
block.setAttribute("watchedsignal1alt", p.getWatchedSignal1Alt());
}
if (p.getWatchedSignal2() != null) {
block.setAttribute("watchedsignal2", p.getWatchedSignal2());
}
if (p.getWatchedSignal2Alt() != null) {
block.setAttribute("watchedsignal2alt", p.getWatchedSignal2Alt());
}
if (p.getWatchedSensor1() != null) {
block.setAttribute("watchedsensor1", p.getWatchedSensor1());
}
if (p.getWatchedSensor1Alt() != null) {
block.setAttribute("watchedsensor1alt", p.getWatchedSensor1Alt());
}
if (p.getWatchedSensor2() != null) {
block.setAttribute("watchedsensor2", p.getWatchedSensor2());
}
if (p.getWatchedSensor2Alt() != null) {
block.setAttribute("watchedsensor2alt", p.getWatchedSensor2Alt());
}
block.setAttribute("limitspeed1", "" + p.getLimitSpeed1());
block.setAttribute("limitspeed2", "" + p.getLimitSpeed2());
block.setAttribute("useflashyellow", "" + p.getUseFlash());
block.setAttribute("distantsignal", "" + p.getDistantSignal());
// add comment, if present
if (p.getComment() != null) {
Element c = new Element("comment");
c.addContent(p.getComment());
block.addContent(c);
}
blocks.addContent(block);
}
return blocks;
}
Aggregations