Search in sources :

Example 91 with Attribute

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);
}
Also used : Attribute(org.jdom2.Attribute) DataConversionException(org.jdom2.DataConversionException) ThrottleSetting(jmri.jmrit.logix.ThrottleSetting)

Example 92 with Attribute

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());
    }
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) RollingStock(jmri.jmrit.operations.rollingstock.RollingStock)

Example 93 with Attribute

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));
        }
    }
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Example 94 with Attribute

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());
        }
    }
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Example 95 with Attribute

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);
        }
    }
}
Also used : Attribute(org.jdom2.Attribute) DataConversionException(org.jdom2.DataConversionException)

Aggregations

Attribute (org.jdom2.Attribute)148 Element (org.jdom2.Element)104 Document (org.jdom2.Document)18 ArrayList (java.util.ArrayList)17 DataConversionException (org.jdom2.DataConversionException)16 Editor (jmri.jmrit.display.Editor)15 Test (org.junit.Test)15 IOException (java.io.IOException)14 NamedIcon (jmri.jmrit.catalog.NamedIcon)13 Attribute (org.bouncycastle.asn1.x509.Attribute)11 HashMap (java.util.HashMap)10 List (java.util.List)9 HashSet (java.util.HashSet)7 Map (java.util.Map)7 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)7 Attribute (ucar.nc2.Attribute)7 Asn1Integer (com.android.hotspot2.asn1.Asn1Integer)5 Asn1Object (com.android.hotspot2.asn1.Asn1Object)5 Asn1Oid (com.android.hotspot2.asn1.Asn1Oid)5 OidMappings (com.android.hotspot2.asn1.OidMappings)5