Search in sources :

Example 41 with Attribute

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

the class VariableTableModel method setDefaultValue.

/**
     * If there's a "default" attribute, set that value to start
     *
     * @return true if the value was set
     */
protected boolean setDefaultValue(Element e, VariableValue v) {
    Attribute a;
    if ((a = e.getAttribute("default")) != null) {
        String val = a.getValue();
        v.setIntValue(Integer.valueOf(val).intValue());
        return true;
    }
    return false;
}
Also used : Attribute(org.jdom2.Attribute)

Example 42 with Attribute

use of 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 43 with Attribute

use of 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 44 with Attribute

use of 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 45 with Attribute

use of 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)

Aggregations

Attribute (org.jdom2.Attribute)149 Element (org.jdom2.Element)104 IOException (java.io.IOException)42 ArrayList (java.util.ArrayList)38 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)33 Attribute (org.bouncycastle.asn1.cms.Attribute)29 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)26 X509Certificate (java.security.cert.X509Certificate)25 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)23 Test (org.junit.Test)22 DERSequence (org.bouncycastle.asn1.DERSequence)20 DERSet (org.bouncycastle.asn1.DERSet)20 List (java.util.List)19 Attribute (org.bouncycastle.asn1.pkcs.Attribute)18 Document (org.jdom2.Document)18 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)17 DataConversionException (org.jdom2.DataConversionException)16 Editor (jmri.jmrit.display.Editor)15 CertificateEncodingException (java.security.cert.CertificateEncodingException)14 ASN1Set (org.bouncycastle.asn1.ASN1Set)14