Search in sources :

Example 31 with Attribute

use of com.android.org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.

the class VariableTableModel method processIndexedVal.

protected VariableValue processIndexedVal(Element child, String name, String comment, String cvName, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, String cv, String mask, String item) throws NumberFormatException {
    VariableValue iv;
    int minVal = 0;
    int maxVal = 255;
    Attribute a;
    if ((a = child.getAttribute("min")) != null) {
        minVal = Integer.valueOf(a.getValue()).intValue();
    }
    if ((a = child.getAttribute("max")) != null) {
        maxVal = Integer.valueOf(a.getValue()).intValue();
    }
    iv = new IndexedVariableValue(name, comment, cvName, readOnly, infoOnly, writeOnly, opsOnly, cv, mask, minVal, maxVal, _indxCvModel.allIndxCvMap(), _status, item);
    return iv;
}
Also used : Attribute(org.jdom2.Attribute)

Example 32 with Attribute

use of com.android.org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.

the class PositionFile method getReceiverMax.

/**
     * Get the nth receiver max time.
     *
     * @return 0 if not present
     */
public int getReceiverMax(int n) {
    List<Element> kids = root.getChildren("receiver");
    for (int i = 0; i < kids.size(); i++) {
        Element e = kids.get(i);
        Attribute a = e.getAttribute("number");
        if (a == null) {
            continue;
        }
        int num = -1;
        try {
            num = a.getIntValue();
        } catch (org.jdom2.DataConversionException ex1) {
            log.error("in getReceiverMax", ex1);
        }
        if (num != n) {
            continue;
        }
        a = e.getAttribute("maxtime");
        if (a == null) {
            // default value
            return 99999;
        }
        try {
            return a.getIntValue();
        } catch (org.jdom2.DataConversionException ex2) {
            return 99999;
        }
    }
    return 99999;
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Example 33 with Attribute

use of com.android.org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.

the class PositionFile method getReceiverPosition.

/**
     * Get the nth receiver position in the file.
     *
     * @return null if not present
     */
public Point3d getReceiverPosition(int n) {
    List<Element> kids = root.getChildren("receiver");
    for (int i = 0; i < kids.size(); i++) {
        Element e = kids.get(i);
        Attribute a = e.getAttribute("number");
        if (a == null) {
            continue;
        }
        int num = -1;
        try {
            num = a.getIntValue();
        } catch (org.jdom2.DataConversionException ex) {
            log.error("in getReceiverPosition", ex);
        }
        if (num == n) {
            return positionFromElement(e.getChild("position"));
        }
    }
    return null;
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Example 34 with Attribute

use of com.android.org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.

the class PositionFile method getReceiverActive.

/**
     * Get the nth receiver active state in the file.
     *
     * @return true if not present
     */
public boolean getReceiverActive(int n) {
    List<Element> kids = root.getChildren("receiver");
    for (int i = 0; i < kids.size(); i++) {
        Element e = kids.get(i);
        Attribute a = e.getAttribute("number");
        if (a == null) {
            continue;
        }
        int num = -1;
        try {
            num = a.getIntValue();
        } catch (org.jdom2.DataConversionException ex) {
            log.error("in getReceiverActive", ex);
        }
        if (num != n) {
            continue;
        }
        a = e.getAttribute("active");
        if (a == null) {
            // default value
            return true;
        }
        if (a.getValue().equals("false")) {
            return false;
        }
        return true;
    }
    return true;
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Example 35 with Attribute

use of com.android.org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.

the class NameCheckAction method actionPerformed.

@SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent e) {
    if (fci == null) {
        fci = jmri.jmrit.XmlFile.userFileChooser("XML files", "xml");
    }
    // request the filename from an open dialog
    fci.rescanCurrentDirectory();
    int retVal = fci.showOpenDialog(_who);
    // handle selection or cancel
    if (retVal == JFileChooser.APPROVE_OPTION) {
        File file = fci.getSelectedFile();
        if (log.isDebugEnabled()) {
            log.debug("located file " + file + " for XML processing");
        }
        // handle the file (later should be outside this thread?)
        try {
            Element root = readFile(file);
            if (log.isDebugEnabled()) {
                log.debug("parsing complete");
            }
            // check to see if there's a decoder element
            if (root.getChild("decoder") == null) {
                log.warn("Does not appear to be a decoder file");
                return;
            }
            Iterator<Element> iter = root.getChild("decoder").getChild("variables").getDescendants(new ElementFilter("variable"));
            jmri.jmrit.symbolicprog.NameFile nfile = jmri.jmrit.symbolicprog.NameFile.instance();
            String warnings = "";
            while (iter.hasNext()) {
                Element varElement = iter.next();
                // for each variable, see if can find in names file
                Attribute labelAttr = varElement.getAttribute("label");
                String label = null;
                if (labelAttr != null) {
                    label = labelAttr.getValue();
                }
                Attribute itemAttr = varElement.getAttribute("item");
                String item = null;
                if (itemAttr != null) {
                    item = itemAttr.getValue();
                }
                if (log.isDebugEnabled()) {
                    log.debug("Variable called \"" + ((label != null) ? label : "<none>") + "\" \"" + ((item != null) ? item : "<none>"));
                }
                if (!(label == null ? false : nfile.checkName(label)) && !(item == null ? false : nfile.checkName(item))) {
                    log.warn("Variable not found: label=\"" + ((label != null) ? label : "<none>") + "\" item=\"" + ((item != null) ? label : "<none>") + "\"");
                    warnings += "Variable not found: label=\"" + ((label != null) ? label : "<none>") + "\" item=\"" + ((item != null) ? item : "<none>") + "\"\n";
                }
            }
            if (!warnings.equals("")) {
                JOptionPane.showMessageDialog(_who, warnings);
            } else {
                JOptionPane.showMessageDialog(_who, "No mismatched items found");
            }
        } catch (HeadlessException | IOException | JDOMException ex) {
            JOptionPane.showMessageDialog(_who, "Error parsing decoder file: " + ex);
        }
    } else {
        log.debug("XmlFileCheckAction cancelled in open dialog");
    }
}
Also used : HeadlessException(java.awt.HeadlessException) Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) IOException(java.io.IOException) JDOMException(org.jdom2.JDOMException) ElementFilter(org.jdom2.filter.ElementFilter) File(java.io.File) XmlFile(jmri.jmrit.XmlFile)

Aggregations

Attribute (org.jdom2.Attribute)149 Element (org.jdom2.Element)104 IOException (java.io.IOException)31 ArrayList (java.util.ArrayList)27 Document (org.jdom2.Document)18 DataConversionException (org.jdom2.DataConversionException)16 X509Certificate (java.security.cert.X509Certificate)15 Editor (jmri.jmrit.display.Editor)15 GeneralName (org.bouncycastle.asn1.x509.GeneralName)15 Test (org.junit.Test)14 List (java.util.List)13 NamedIcon (jmri.jmrit.catalog.NamedIcon)13 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)12 Attribute (org.bouncycastle.asn1.pkcs.Attribute)12 Extensions (org.bouncycastle.asn1.x509.Extensions)12 GeneralNames (org.bouncycastle.asn1.x509.GeneralNames)12 CertificateEncodingException (java.security.cert.CertificateEncodingException)11 Attribute (org.bouncycastle.asn1.x509.Attribute)11 HashMap (java.util.HashMap)10 HashSet (java.util.HashSet)9