use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class WarrantManagerXml method loadThrottleCommand.
static ThrottleSetting loadThrottleCommand(Element elem) {
long time = 0;
try {
time = elem.getAttribute("time").getLongValue();
} catch (org.jdom2.DataConversionException dce) {
}
Attribute attr = elem.getAttribute("command");
String command = null;
if (attr != null)
command = attr.getValue();
attr = elem.getAttribute("value");
String value = null;
if (attr != null)
value = attr.getValue();
attr = elem.getAttribute("block");
String block = null;
if (attr != null)
block = attr.getValue();
return new ThrottleSetting(time, command, value, block);
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class CarManager method store.
/**
* Create an XML element to represent this Entry. This member has to remain
* synchronized with the detailed DTD in operations-cars.dtd.
* @param root The common Element for operations-cars.dtd.
*/
public void store(Element root) {
// nothing to save under
root.addContent(new Element(Xml.OPTIONS));
// options
Element values;
List<String> names = getKernelNameList();
if (Control.backwardCompatible) {
root.addContent(values = new Element(Xml.KERNELS));
for (String name : names) {
// NOI18N
String kernelNames = name + "%%";
values.addContent(kernelNames);
}
}
// new format using elements
Element kernels = new Element(Xml.NEW_KERNELS);
for (String name : names) {
Element kernel = new Element(Xml.KERNEL);
kernel.setAttribute(new Attribute(Xml.NAME, name));
kernels.addContent(kernel);
}
root.addContent(kernels);
root.addContent(values = new Element(Xml.CARS));
// add entries
List<RollingStock> carList = getByIdList();
for (RollingStock rs : carList) {
Car car = (Car) rs;
values.addContent(car.store());
}
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class TrainManager method load.
public void load(Element root) {
if (root.getChild(Xml.OPTIONS) != null) {
Element options = root.getChild(Xml.OPTIONS);
TrainCustomManifest.instance().load(options);
TrainCustomSwitchList.instance().load(options);
Element e = options.getChild(Xml.TRAIN_OPTIONS);
Attribute a;
if (e != null) {
if ((a = e.getAttribute(Xml.BUILD_MESSAGES)) != null) {
_buildMessages = a.getValue().equals(Xml.TRUE);
}
if ((a = e.getAttribute(Xml.BUILD_REPORT)) != null) {
_buildReport = a.getValue().equals(Xml.TRUE);
}
if ((a = e.getAttribute(Xml.PRINT_PREVIEW)) != null) {
_printPreview = a.getValue().equals(Xml.TRUE);
}
if ((a = e.getAttribute(Xml.OPEN_FILE)) != null) {
_openFile = a.getValue().equals(Xml.TRUE);
}
if ((a = e.getAttribute(Xml.RUN_FILE)) != null) {
_runFile = a.getValue().equals(Xml.TRUE);
}
// verify that the Trains Window action is valid
if ((a = e.getAttribute(Xml.TRAIN_ACTION)) != null && (a.getValue().equals(TrainsTableFrame.MOVE) || a.getValue().equals(TrainsTableFrame.RESET) || a.getValue().equals(TrainsTableFrame.TERMINATE) || a.getValue().equals(TrainsTableFrame.CONDUCTOR))) {
_trainAction = a.getValue();
}
}
// Row color options
Element eRowColorOptions = options.getChild(Xml.ROW_COLOR_OPTIONS);
if (eRowColorOptions != null) {
if ((a = eRowColorOptions.getAttribute(Xml.ROW_COLOR_MANUAL)) != null) {
_rowColorManual = a.getValue().equals(Xml.TRUE);
}
if ((a = eRowColorOptions.getAttribute(Xml.ROW_COLOR_BUILD_FAILED)) != null) {
_rowColorBuildFailed = a.getValue();
}
if ((a = eRowColorOptions.getAttribute(Xml.ROW_COLOR_BUILT)) != null) {
_rowColorBuilt = a.getValue();
}
if ((a = eRowColorOptions.getAttribute(Xml.ROW_COLOR_TRAIN_EN_ROUTE)) != null) {
_rowColorTrainEnRoute = a.getValue();
}
if ((a = eRowColorOptions.getAttribute(Xml.ROW_COLOR_TERMINATED)) != null) {
_rowColorTerminated = a.getValue();
}
}
e = options.getChild(Xml.TRAIN_SCHEDULE_OPTIONS);
if (e != null) {
if ((a = e.getAttribute(Xml.ACTIVE_ID)) != null) {
_trainScheduleActiveId = a.getValue();
}
}
// check for scripts
if (options.getChild(Xml.SCRIPTS) != null) {
@SuppressWarnings("unchecked") List<Element> lm = options.getChild(Xml.SCRIPTS).getChildren(Xml.START_UP);
for (Element es : lm) {
if ((a = es.getAttribute(Xml.NAME)) != null) {
addStartUpScript(a.getValue());
}
}
@SuppressWarnings("unchecked") List<Element> lt = options.getChild(Xml.SCRIPTS).getChildren(Xml.SHUT_DOWN);
for (Element es : lt) {
if ((a = es.getAttribute(Xml.NAME)) != null) {
addShutDownScript(a.getValue());
}
}
}
}
if (root.getChild(Xml.TRAINS) != null) {
@SuppressWarnings("unchecked") List<Element> eTrains = root.getChild(Xml.TRAINS).getChildren(Xml.TRAIN);
log.debug("readFile sees {} trains", eTrains.size());
for (Element eTrain : eTrains) {
register(new Train(eTrain));
}
}
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class TrainManifestHeaderText method load.
public static void load(Element e) {
Element emts = e.getChild(Xml.MANIFEST_HEADER_TEXT_STRINGS);
if (emts == null) {
return;
}
Attribute a;
if (emts.getChild(Xml.ROAD) != null) {
if ((a = emts.getChild(Xml.ROAD).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Road(a.getValue());
}
}
if (emts.getChild(Xml.NUMBER) != null) {
if ((a = emts.getChild(Xml.NUMBER).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Number(a.getValue());
}
}
if (emts.getChild(Xml.ENGINE_NUMBER) != null) {
if ((a = emts.getChild(Xml.ENGINE_NUMBER).getAttribute(Xml.TEXT)) != null) {
setStringHeader_EngineNumber(a.getValue());
}
}
if (emts.getChild(Xml.TYPE) != null) {
if ((a = emts.getChild(Xml.TYPE).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Type(a.getValue());
}
}
if (emts.getChild(Xml.MODEL) != null) {
if ((a = emts.getChild(Xml.MODEL).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Model(a.getValue());
}
}
if (emts.getChild(Xml.LENGTH) != null) {
if ((a = emts.getChild(Xml.LENGTH).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Length(a.getValue());
}
}
if (emts.getChild(Xml.LOAD) != null) {
if ((a = emts.getChild(Xml.LOAD).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Load(a.getValue());
}
}
if (emts.getChild(Xml.COLOR) != null) {
if ((a = emts.getChild(Xml.COLOR).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Color(a.getValue());
}
}
if (emts.getChild(Xml.TRACK) != null) {
if ((a = emts.getChild(Xml.TRACK).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Track(a.getValue());
}
}
if (emts.getChild(Xml.DESTINATION) != null) {
if ((a = emts.getChild(Xml.DESTINATION).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Destination(a.getValue());
}
}
if (emts.getChild(Xml.DEST_TRACK) != null) {
if ((a = emts.getChild(Xml.DEST_TRACK).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Dest_Track(a.getValue());
}
}
if (emts.getChild(Xml.FINAL_DEST) != null) {
if ((a = emts.getChild(Xml.FINAL_DEST).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Final_Dest(a.getValue());
}
}
if (emts.getChild(Xml.FINAL_DEST_TRACK) != null) {
if ((a = emts.getChild(Xml.FINAL_DEST_TRACK).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Final_Dest_Track(a.getValue());
}
}
if (emts.getChild(Xml.LOCATION) != null) {
if ((a = emts.getChild(Xml.LOCATION).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Location(a.getValue());
}
}
if (emts.getChild(Xml.CONSIST) != null) {
if ((a = emts.getChild(Xml.CONSIST).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Consist(a.getValue());
}
}
if (emts.getChild(Xml.KERNEL) != null) {
if ((a = emts.getChild(Xml.KERNEL).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Kernel(a.getValue());
}
}
if (emts.getChild(Xml.OWNER) != null) {
if ((a = emts.getChild(Xml.OWNER).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Owner(a.getValue());
}
}
if (emts.getChild(Xml.RWE) != null) {
if ((a = emts.getChild(Xml.RWE).getAttribute(Xml.TEXT)) != null) {
setStringHeader_RWE(a.getValue());
}
}
if (emts.getChild(Xml.COMMENT) != null) {
if ((a = emts.getChild(Xml.COMMENT).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Comment(a.getValue());
}
}
if (emts.getChild(Xml.DROP_COMMENT) != null) {
if ((a = emts.getChild(Xml.DROP_COMMENT).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Drop_Comment(a.getValue());
}
}
if (emts.getChild(Xml.PICKUP_COMMENT) != null) {
if ((a = emts.getChild(Xml.PICKUP_COMMENT).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Pickup_Comment(a.getValue());
}
}
if (emts.getChild(Xml.HAZARDOUS) != null) {
if ((a = emts.getChild(Xml.HAZARDOUS).getAttribute(Xml.TEXT)) != null) {
setStringHeader_Hazardous(a.getValue());
}
}
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class AbstractServerPreferences method load.
public void load(Element child) {
Attribute a;
a = child.getAttribute(PORT);
if (a != null) {
try {
this.setPort(a.getIntValue());
this.asLoadedPort = this.getPort();
} catch (DataConversionException e) {
this.setPort(getDefaultPort());
log.error("Unable to read port. Setting to default value.", e);
}
}
}
Aggregations