Search in sources :

Example 56 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project bioformats by ome.

the class NetCDFServiceImpl method parseAttributesAndVariables.

// -- Helper methods --
/**
 * Recursively parses attribute and variable paths, filling
 * <code>attributeList</code> and <code>variableList</code>.
 * @param groups List of groups to recursively parse.
 */
private void parseAttributesAndVariables(List<Group> groups) {
    for (Group group : groups) {
        String groupName = group.getName();
        List<Attribute> attributes = group.getAttributes();
        for (Attribute attribute : attributes) {
            String attributeName = attribute.getName();
            if (!groupName.endsWith("/"))
                attributeName = "/" + attributeName;
            attributeList.add(groupName + attributeName);
        }
        List<Variable> variables = group.getVariables();
        for (Variable variable : variables) {
            String variableName = variable.getName();
            if (!groupName.endsWith("/"))
                variableName = "/" + variableName;
            variableList.add(variableName);
        }
        groups = group.getGroups();
        parseAttributesAndVariables(groups);
    }
}
Also used : Group(ucar.nc2.Group) Variable(ucar.nc2.Variable) Attribute(ucar.nc2.Attribute)

Example 57 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project bioformats by ome.

the class NetCDFServiceImpl method getVariableAttributes.

/* (non-Javadoc)
   * @see loci.formats.NetCDFService#getVariableAttributes(java.lang.String)
   */
@Override
public Hashtable<String, Object> getVariableAttributes(String name) {
    String groupName = getDirectory(name);
    String variableName = getName(name);
    Group group = getGroup(groupName);
    Variable variable = group.findVariable(variableName);
    Hashtable<String, Object> toReturn = new Hashtable<String, Object>();
    if (variable != null) {
        List<Attribute> attributes = variable.getAttributes();
        for (Attribute attribute : attributes) {
            toReturn.put(attribute.getName(), arrayToString(attribute.getValues()));
        }
    }
    return toReturn;
}
Also used : Group(ucar.nc2.Group) Variable(ucar.nc2.Variable) Attribute(ucar.nc2.Attribute) Hashtable(java.util.Hashtable)

Example 58 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project goobi-workflow by intranda.

the class XsltPreparatorDocket method startExport.

/**
 * This method exports the production metadata for a list of processes as a single file to a given stream.
 *
 * @param processList
 * @param outputStream
 * @param xslt
 */
public void startExport(List<Process> processList, OutputStream outputStream, String xslt) {
    Document answer = new Document();
    Element root = new Element("processes");
    answer.setRootElement(root);
    Namespace xmlns = Namespace.getNamespace("http://www.goobi.io/logfile");
    Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    root.addNamespaceDeclaration(xsi);
    root.setNamespace(xmlns);
    Attribute attSchema = new Attribute("schemaLocation", "http://www.goobi.io/logfile" + " XML-logfile.xsd", xsi);
    root.setAttribute(attSchema);
    for (Process p : processList) {
        Document doc = createDocument(p, false, true);
        Element processRoot = doc.getRootElement();
        processRoot.detach();
        root.addContent(processRoot);
    }
    XMLOutputter outp = new XMLOutputter();
    outp.setFormat(Format.getPrettyFormat());
    try {
        outp.output(answer, outputStream);
    } catch (IOException e) {
    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                outputStream = null;
            }
        }
    }
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) Process(org.goobi.beans.Process) IOException(java.io.IOException) Document(org.jdom2.Document) Namespace(org.jdom2.Namespace)

Example 59 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project goobi-workflow by intranda.

the class XsltPreparatorMetadata method startExport.

/**
 * This method exports the production metadata for a list of processes as a single file to a given stream.
 *
 * @param processList
 * @param outputStream
 * @param xslt
 */
public void startExport(List<Process> processList, OutputStream outputStream, String xslt) {
    Document answer = new Document();
    Element root = new Element("processes");
    answer.setRootElement(root);
    Namespace xmlns = Namespace.getNamespace("http://www.goobi.io/logfile");
    Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    root.addNamespaceDeclaration(xsi);
    root.setNamespace(xmlns);
    Attribute attSchema = new Attribute("schemaLocation", "http://www.goobi.io/logfile" + " XML-logfile.xsd", xsi);
    root.setAttribute(attSchema);
    for (Process p : processList) {
        Document doc = createDocument(p, false);
        Element processRoot = doc.getRootElement();
        processRoot.detach();
        root.addContent(processRoot);
    }
    XMLOutputter outp = new XMLOutputter();
    outp.setFormat(Format.getPrettyFormat());
    try {
        outp.output(answer, outputStream);
    } catch (IOException e) {
    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                outputStream = null;
            }
        }
    }
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) Process(org.goobi.beans.Process) IOException(java.io.IOException) Document(org.jdom2.Document) DigitalDocument(ugh.dl.DigitalDocument) Namespace(org.jdom2.Namespace)

Example 60 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project n2o-framework by i-novus-llc.

the class IOProcessorImpl method childAttributeInteger.

@Override
public void childAttributeInteger(Element element, String childName, String name, Supplier<Integer> getter, Consumer<Integer> setter) {
    if (r) {
        Element child = element.getChild(childName, element.getNamespace());
        if (child == null)
            return;
        Attribute attribute = child.getAttribute(name);
        if (attribute != null) {
            setter.accept(Integer.parseInt(process(attribute.getValue())));
        }
    } else {
        if (getter.get() == null)
            return;
        Element childElement = element.getChild(childName, element.getNamespace());
        if (childElement == null) {
            childElement = new Element(childName, element.getNamespace());
            childElement.setAttribute(new Attribute(name, getter.get().toString()));
            element.addContent(childElement);
        } else {
            childElement.setAttribute(new Attribute(name, getter.get().toString()));
        }
    }
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

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