Search in sources :

Example 41 with Element

use of org.w3c.dom.Element in project Openfire by igniterealtime.

the class MonitoringDWR method configure.

@Override
public void configure(ServletConfig servletConfig, Configuration configuration) throws ServletException {
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = dbf.newDocumentBuilder();
        document = builder.newDocument();
        Element root = document.createElement("dwr");
        document.appendChild(root);
        Element allowElement = document.createElement("allow");
        // Build stats bean
        Element createElement = buildCreator("Stats", org.jivesoftware.openfire.reporting.stats.StatsAction.class.getName());
        Element convertConversationElement = document.createElement("convert");
        convertConversationElement.setAttribute("converter", "bean");
        convertConversationElement.setAttribute("match", org.jivesoftware.openfire.archive.ConversationInfo.class.getName());
        // Build conversation Element.
        Element conversationElement = buildCreator("conversations", org.jivesoftware.openfire.archive.ConversationUtils.class.getName());
        allowElement.appendChild(createElement);
        allowElement.appendChild(convertConversationElement);
        allowElement.appendChild(conversationElement);
        root.appendChild(allowElement);
    } catch (ParserConfigurationException e) {
        Log.error("error creating DWR configuration: " + e);
    }
    configuration.addConfig(document);
    // Specify the path for the Stat.js file 
    Object bean = container.getBean("interface");
    if (bean instanceof DefaultInterfaceProcessor) {
        DefaultInterfaceProcessor processor = (DefaultInterfaceProcessor) bean;
        processor.setOverridePath("/plugins/" + MonitoringConstants.NAME + "/dwr");
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Element(org.w3c.dom.Element) DefaultInterfaceProcessor(uk.ltd.getahead.dwr.impl.DefaultInterfaceProcessor) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 42 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 {
    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++) {
        long[] array = value[i];
        write(array, "array_" + i, defVal == null ? null : defVal[i]);
    }
    currentElement = (Element) el.getParentNode();
}
Also used : Element(org.w3c.dom.Element)

Example 43 with Element

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

the class DOMOutputCapsule method write.

@Override
public void write(float[] value, String name, float[] defVal) throws IOException {
    StringBuilder buf = new StringBuilder();
    if (value == null) {
        value = defVal;
    }
    if (value != null) {
        for (float 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", value == null ? "0" : String.valueOf(value.length));
    el.setAttribute(dataAttributeName, buf.toString());
    currentElement = (Element) currentElement.getParentNode();
}
Also used : Element(org.w3c.dom.Element)

Example 44 with Element

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

the class DOMOutputCapsule method write.

@Override
public void write(int[] value, String name, int[] defVal) throws IOException {
    StringBuilder buf = new StringBuilder();
    if (value == null) {
        return;
    }
    if (Arrays.equals(value, defVal)) {
        return;
    }
    for (int 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 45 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 {
    StringBuilder buf = new StringBuilder();
    if (value == null) {
        value = defVal;
    }
    for (boolean 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