Search in sources :

Example 1 with VectorNodeList

use of com.cosylab.logging.engine.VectorNodeList in project ACS by ACS-Community.

the class LogEntryXML method addData.

/**
	 *	Add a data node to this log:
	 *  <Data Name=name>value</Data>
	 * 
	 * @param name The name, i.e. the key of the pair
	 * @param value The value of the field
	 */
public void addData(String name, String value) {
    Document doc = log.getOwnerDocument();
    Element ele = doc.createElement("Data");
    ele.setAttribute("Name", name);
    Text txt = doc.createTextNode(value);
    ele.appendChild(txt);
    if (datas == null) {
        datas = new VectorNodeList(1, 1);
    }
    datas.add(ele);
}
Also used : VectorNodeList(com.cosylab.logging.engine.VectorNodeList) Element(org.w3c.dom.Element) Text(org.w3c.dom.Text) Document(org.w3c.dom.Document)

Example 2 with VectorNodeList

use of com.cosylab.logging.engine.VectorNodeList in project ACS by ACS-Community.

the class LogEntryXML method initBody.

private void initBody(Node log) throws DOMException {
    NodeList list = log.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
        Node node = list.item(i);
        boolean isData = node.getNodeName().equals("Data");
        short type = node.getNodeType();
        if (isData) {
            DataNode dataNode = new DataNode(node);
            if (datas == null) {
                datas = new VectorNodeList(1, 2);
            }
            datas.add(dataNode);
        } else {
            if (isLogEntrySimple) {
                isLogEntrySimple = !node.hasChildNodes();
            }
            if (isLogEntrySimple) {
                // simpleLogEntryMessage = node.getNodeValue();
                setField(LogField.LOGMESSAGE, node.getNodeValue());
            } else {
                if (complexLogEntryMessage == null)
                    complexLogEntryMessage = new VectorNodeList(1, 2);
                complexLogEntryMessage.add(node);
            }
        }
    }
}
Also used : VectorNodeList(com.cosylab.logging.engine.VectorNodeList) DataNode(com.cosylab.logging.engine.DataNode) NodeList(org.w3c.dom.NodeList) VectorNodeList(com.cosylab.logging.engine.VectorNodeList) DataNode(com.cosylab.logging.engine.DataNode) Node(org.w3c.dom.Node)

Aggregations

VectorNodeList (com.cosylab.logging.engine.VectorNodeList)2 DataNode (com.cosylab.logging.engine.DataNode)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1 Text (org.w3c.dom.Text)1