Search in sources :

Example 81 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project rascal by usethesource.

the class DOM method nodeToAttribute.

private Attribute nodeToAttribute(IConstructor n) {
    IConstructor ns = (IConstructor) n.get(0);
    IString name = (IString) n.get(1);
    IString data = (IString) n.get(2);
    return new Attribute(name.getValue(), data.getValue(), namespaceToNamespace(ns));
}
Also used : IConstructor(io.usethesource.vallang.IConstructor) Attribute(org.jdom2.Attribute) IString(io.usethesource.vallang.IString)

Example 82 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project rascal by usethesource.

the class DOM method convertElement.

private IConstructor convertElement(Element e, boolean trim) {
    IListWriter kids = vf.listWriter();
    for (Object o : e.getAttributes()) {
        Attribute attr = (Attribute) o;
        IString key = vf.string(attr.getName());
        IString val = vf.string(attr.getValue());
        kids.insert(vf.constructor(Factory.Node_attribute, convertNamespace(attr.getNamespace()), key, val));
    }
    int len = e.getContentSize();
    for (int i = 0; i < len; i++) {
        try {
            kids.append(convertContent(e.getContent(i), trim));
        } catch (Skip c) {
            // Ugh, terrible, but I'm in hurry
            continue;
        }
    }
    IString name = vf.string(e.getName());
    return vf.constructor(Factory.Node_element, convertNamespace(e.getNamespace()), name, kids.done());
}
Also used : Attribute(org.jdom2.Attribute) IListWriter(io.usethesource.vallang.IListWriter) IString(io.usethesource.vallang.IString)

Example 83 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project s1tbx by senbox-org.

the class BinaryDBReader method DecodeElement.

private static void DecodeElement(final BinaryFileReader reader, final Map metaMap, final Element child, final String suffix) {
    String name = "";
    try {
        final Attribute nameAttrib = child.getAttribute("name");
        final Attribute typeAttrib = child.getAttribute("type");
        final Attribute numAttrib = child.getAttribute("num");
        if (nameAttrib != null && typeAttrib != null && numAttrib != null) {
            name = nameAttrib.getValue();
            if (suffix != null)
                name += suffix;
            final int type = Integer.parseInt(typeAttrib.getValue());
            final int num = Integer.parseInt(numAttrib.getValue());
            switch(type) {
                case Skip:
                    {
                        // blank
                        reader.skipBytes(num);
                        break;
                    }
                case An:
                    {
                        metaMap.put(name, reader.readAn(num));
                        break;
                    }
                case In:
                    {
                        metaMap.put(name, (int) reader.readIn(num));
                        break;
                    }
                case B1:
                    {
                        metaMap.put(name, reader.readB1());
                        break;
                    }
                case B2:
                    {
                        metaMap.put(name, reader.readB2());
                        break;
                    }
                case B4:
                    {
                        metaMap.put(name, reader.readB4());
                        break;
                    }
                case B8:
                    {
                        metaMap.put(name, reader.readB8());
                        break;
                    }
                case Fn:
                    {
                        metaMap.put(name, reader.readFn(num));
                        break;
                    }
                case En:
                    {
                        metaMap.put(name, reader.readEn(num));
                        break;
                    }
                case Debug:
                    {
                        System.out.print(" = ");
                        for (int i = 0; i < num; ++i) {
                            final String tmp = reader.readAn(1);
                            if (!tmp.isEmpty() && !tmp.equals(" "))
                                System.out.print(tmp);
                        }
                        System.out.println();
                        break;
                    }
                default:
                    {
                        throw new IllegalBinaryFormatException("Unknown type " + type, reader.getCurrentPos());
                    }
            }
        }
    } catch (Exception e) {
        if (e.getCause() != null)
            SystemUtils.LOG.severe(' ' + e.toString() + ':' + e.getCause().toString() + " for " + name);
        else
            SystemUtils.LOG.severe(' ' + e.toString() + ':' + " for " + name);
    }
}
Also used : Attribute(org.jdom2.Attribute) MetadataAttribute(org.esa.snap.core.datamodel.MetadataAttribute) IOException(java.io.IOException)

Example 84 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project s1tbx by senbox-org.

the class BinaryDBReader method DecodeElementDebug.

private void DecodeElementDebug(final BinaryFileReader reader, final Map metaMap, final Element child, final String suffix) {
    String name = "";
    try {
        final Attribute nameAttrib = child.getAttribute("name");
        final Attribute typeAttrib = child.getAttribute("type");
        final Attribute numAttrib = child.getAttribute("num");
        if (nameAttrib != null && typeAttrib != null && numAttrib != null) {
            name = nameAttrib.getValue();
            if (suffix != null)
                name += suffix;
            final int type = Integer.parseInt(typeAttrib.getValue());
            final int num = Integer.parseInt(numAttrib.getValue());
            System.out.print(" " + reader.getCurrentPos() + ' ' + (reader.getCurrentPos() - startPos + 1) + ' ' + name + ' ' + type + ' ' + num);
            switch(type) {
                case Skip:
                    {
                        // blank
                        reader.skipBytes(num);
                        break;
                    }
                case An:
                    {
                        final String tmp = reader.readAn(num);
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case In:
                    {
                        final int tmp = (int) reader.readIn(num);
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case B1:
                    {
                        final int tmp = reader.readB1();
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case B2:
                    {
                        final int tmp = reader.readB2();
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case B4:
                    {
                        final int tmp = reader.readB4();
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case B8:
                    {
                        final long tmp = reader.readB8();
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case Fn:
                    {
                        double tmp = reader.readFn(num);
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case En:
                    {
                        double tmp = reader.readEn(num);
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case Debug:
                    {
                        System.out.print(" = ");
                        for (int i = 0; i < num; ++i) {
                            final String tmp = reader.readAn(1);
                            if (!tmp.isEmpty() && !tmp.equals(" "))
                                System.out.print(tmp);
                        }
                        System.out.println();
                        break;
                    }
                default:
                    {
                        throw new IllegalBinaryFormatException("Unknown type " + type, reader.getCurrentPos());
                    }
            }
            System.out.println();
        }
    } catch (Exception e) {
        if (e.getCause() != null)
            SystemUtils.LOG.severe(' ' + e.toString() + ':' + e.getCause().toString() + " for " + name);
        else
            SystemUtils.LOG.severe(' ' + e.toString() + ':' + " for " + name);
    // throw new IllegalBinaryFormatException(e.toString(), reader.getCurrentPos());
    }
}
Also used : Attribute(org.jdom2.Attribute) MetadataAttribute(org.esa.snap.core.datamodel.MetadataAttribute) IOException(java.io.IOException)

Example 85 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project s1tbx by senbox-org.

the class NetCDFUtils method addAttributes.

public static MetadataElement addAttributes(final MetadataElement parentElem, final String elemName, final List<Attribute> attribList) {
    final MetadataElement globalElem = new MetadataElement(elemName);
    parentElem.addElement(globalElem);
    for (Attribute at : attribList) {
        createMetadataAttributes(globalElem, at, at.getName());
    }
    return globalElem;
}
Also used : Attribute(ucar.nc2.Attribute) MetadataAttribute(org.esa.snap.core.datamodel.MetadataAttribute) MetadataElement(org.esa.snap.core.datamodel.MetadataElement)

Aggregations

Attribute (org.jdom2.Attribute)316 Element (org.jdom2.Element)210 IOException (java.io.IOException)98 ArrayList (java.util.ArrayList)75 Attribute (ucar.nc2.Attribute)65 List (java.util.List)46 Document (org.jdom2.Document)43 Variable (ucar.nc2.Variable)39 HashMap (java.util.HashMap)26 Extensions (org.bouncycastle.asn1.x509.Extensions)26 X509Certificate (java.security.cert.X509Certificate)24 Namespace (org.jdom2.Namespace)24 File (java.io.File)23 Attribute (org.bouncycastle.asn1.pkcs.Attribute)21 GeneralName (org.bouncycastle.asn1.x509.GeneralName)21 Array (ucar.ma2.Array)21 Test (org.junit.Test)20 GeneralNames (org.bouncycastle.asn1.x509.GeneralNames)19 Dimension (ucar.nc2.Dimension)19 Map (java.util.Map)17