Search in sources :

Example 51 with Element

use of org.w3c.dom.Element in project jmonkeyengine by jMonkeyEngine.

the class DOMOutputCapsule method write.

@Override
public void write(boolean[][] value, String name, boolean[][] defVal) throws IOException {
    if (value == null)
        return;
    if (Arrays.deepEquals(value, defVal))
        return;
    Element el = appendElement(name);
    el.setAttribute("size", String.valueOf(value.length));
    for (int i = 0; i < value.length; i++) {
        boolean[] array = value[i];
        write(array, "array_" + i, defVal == null ? null : defVal[i]);
    }
    currentElement = (Element) el.getParentNode();
}
Also used : Element(org.w3c.dom.Element)

Example 52 with Element

use of org.w3c.dom.Element in project jmonkeyengine by jMonkeyEngine.

the class DOMOutputCapsule method write.

@Override
public void write(byte[][] value, String name, byte[][] defVal) throws IOException {
    StringBuilder buf = new StringBuilder();
    if (value == null) {
        value = defVal;
    }
    for (byte[] bs : value) {
        for (byte b : bs) {
            buf.append(b);
            buf.append(" ");
        }
        buf.append(" ");
    }
    if (buf.length() > 1) {
        //remove last spaces
        buf.setLength(buf.length() - 2);
    } else if (buf.length() > 0) {
        buf.setLength(buf.length() - 1);
    }
    Element el = appendElement(name);
    el.setAttribute("size_outer", String.valueOf(value.length));
    el.setAttribute("size_inner", String.valueOf(value[0].length));
    el.setAttribute(dataAttributeName, buf.toString());
    currentElement = (Element) currentElement.getParentNode();
}
Also used : Element(org.w3c.dom.Element)

Example 53 with Element

use of org.w3c.dom.Element in project jmonkeyengine by jMonkeyEngine.

the class DOMOutputCapsule method writeByteBufferArrayList.

@Override
public void writeByteBufferArrayList(ArrayList<ByteBuffer> array, String name, ArrayList<ByteBuffer> defVal) throws IOException {
    if (array == null) {
        return;
    }
    if (array.equals(defVal)) {
        return;
    }
    Element el = appendElement(name);
    el.setAttribute("size", String.valueOf(array.size()));
    for (ByteBuffer o : array) {
        write(o, "ByteBuffer", null);
    }
    currentElement = (Element) el.getParentNode();
}
Also used : Element(org.w3c.dom.Element) ByteBuffer(java.nio.ByteBuffer)

Example 54 with Element

use of org.w3c.dom.Element in project jmonkeyengine by jMonkeyEngine.

the class DOMOutputCapsule method write.

@Override
public void write(long[] value, String name, long[] defVal) throws IOException {
    StringBuilder buf = new StringBuilder();
    if (value == null) {
        value = defVal;
    }
    for (long b : value) {
        buf.append(b);
        buf.append(" ");
    }
    if (buf.length() > 0) {
        //remove last space
        buf.setLength(buf.length() - 1);
    }
    Element el = appendElement(name);
    el.setAttribute("size", String.valueOf(value.length));
    el.setAttribute(dataAttributeName, buf.toString());
    currentElement = (Element) currentElement.getParentNode();
}
Also used : Element(org.w3c.dom.Element)

Example 55 with Element

use of org.w3c.dom.Element in project jmonkeyengine by jMonkeyEngine.

the class DOMOutputCapsule method write.

@Override
public void write(double[] value, String name, double[] defVal) throws IOException {
    StringBuilder buf = new StringBuilder();
    if (value == null) {
        value = defVal;
    }
    for (double b : value) {
        buf.append(b);
        buf.append(" ");
    }
    if (buf.length() > 0) {
        //remove last space
        buf.setLength(buf.length() - 1);
    }
    Element el = appendElement(name);
    el.setAttribute("size", String.valueOf(value.length));
    el.setAttribute(dataAttributeName, buf.toString());
    currentElement = (Element) currentElement.getParentNode();
}
Also used : Element(org.w3c.dom.Element)

Aggregations

Element (org.w3c.dom.Element)9072 Document (org.w3c.dom.Document)2651 NodeList (org.w3c.dom.NodeList)2103 Node (org.w3c.dom.Node)1855 ArrayList (java.util.ArrayList)957 DocumentBuilder (javax.xml.parsers.DocumentBuilder)793 IOException (java.io.IOException)732 Test (org.junit.Test)693 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)591 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)489 HashMap (java.util.HashMap)434 SAXException (org.xml.sax.SAXException)406 File (java.io.File)358 Attr (org.w3c.dom.Attr)333 InputStream (java.io.InputStream)309 QName (javax.xml.namespace.QName)292 Map (java.util.Map)285 JAXBElement (javax.xml.bind.JAXBElement)285 NamedNodeMap (org.w3c.dom.NamedNodeMap)266 List (java.util.List)264