Package org.exist.util.serializer

Examples of org.exist.util.serializer.AttrList


        }

        @Override
        public void startElement(QName qname, AttrList attribs) {
            stack.push(qname.getLocalName());
            AttrList newAttrs = attribs;
            if (attribs != null && "permissions".equals(qname.getLocalName())) {
                newAttrs = new AttrList();
                for (int i = 0; i < attribs.getLength(); i++) {
                    if (!"password". equals(attribs.getQName(i).getLocalName())) {
                        newAttrs.addAttribute(attribs.getQName(i), attribs.getValue(i), attribs.getType(i));
                    }
                }
            }

            if (!"deployed".equals(qname.getLocalName())) {
View Full Code Here


                    }
                    ++ns;
                }
            }
            //Create the attribute list
            AttrList attribs = null;
            int attr = document.alpha[nr];
            if (-1 < attr) {
                attribs = new AttrList();
                while ((attr < document.nextAttr) && (document.attrParent[attr] == nr)) {
                    final QName attrQName = document.attrName[attr];
                    attribs.addAttribute(attrQName, attrValue[attr]);
                    ++attr;
                }
            }
            receiver.startElement(nodeName, attribs);
            break;
View Full Code Here

            super(APPEND, reference, otherDoc);
        }

        public void serialize(DBBroker broker, Receiver handler) {
            try {
                AttrList attribs = new AttrList();
                attribs.addAttribute(ATTR_REF, refChild.getNodeId().toString());
                handler.startElement(ELEMENT_APPEND, attribs);
                serializeChildren(broker, handler);
                handler.endElement(ELEMENT_APPEND);
            } catch (SAXException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
View Full Code Here

            this.event = event;
        }

        public void serialize(DBBroker broker, Receiver handler) {
            try {
                AttrList attribs = new AttrList();
                if (event == XMLStreamReader.START_ELEMENT || event == XMLStreamReader.END_ELEMENT) {
                    String ev = event == XMLStreamReader.START_ELEMENT ? "start" : "end";
                    attribs.addAttribute(ATTR_EVENT, ev);
                }
                attribs.addAttribute(ATTR_REF, refChild.getNodeId().toString());
                handler.startElement(ELEMENT_DELETE, attribs);
                handler.endElement(ELEMENT_DELETE);
            } catch (SAXException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
View Full Code Here

        }
    }

    private void copyNode(ExtendedXMLStreamReader reader, Receiver receiver, int status,
                          boolean onFirstNode, String changeMessage) throws SAXException, XMLStreamException, IOException {
        AttrList attrs;
        switch (status) {
            case XMLStreamReader.START_ELEMENT:
                attrs = new AttrList();
                if (annotate) {
                    if (onFirstNode)
                        attrs.addAttribute(ATTR_CHANGE, changeMessage);
                    else {
                        NodeId nodeId = (NodeId) reader.getProperty(EmbeddedXMLStreamReader.PROPERTY_NODE_ID);
                        NodeSet children = changeSet.selectParentChild(new NodeProxy(diffDoc, nodeId), NodeSet.ANCESTOR);
                        if (children != null && !children.isEmpty())
                            attrs.addAttribute(ATTR_CHANGE, "changed");
                    }
                    if (elementStack.size() == 0)
                        receiver.startPrefixMapping(StandardDiff.PREFIX, StandardDiff.NAMESPACE);
                }

                for (int i = 0; i < reader.getAttributeCount(); i++) {
                    // check if an attribute has to be inserted before the current attribute
                    NodeId nodeId = reader.getAttributeId(i);

                    // check if an attribute has to be inserted before the current attribute
                    ElementImpl insertedNode = insertedNodes.get(nodeId);
                    if (insertedNode != null) {
                        StoredNode child = (StoredNode) insertedNode.getFirstChild();
                        while (child != null) {
                            if (StandardDiff.NAMESPACE.equals(child.getNamespaceURI()) && "attribute".equals(child.getLocalName())) {
                                NamedNodeMap map = child.getAttributes();
                                for (int j = 0; j < map.getLength(); j++) {
                                    AttrImpl attr = (AttrImpl) map.item(j);
                                    if (!attr.getName().startsWith("xmlns"))
                                        attrs.addAttribute(attr.getQName(), attr.getValue(),
                                                attr.getType(), attr.getNodeId());
                                }
                            }
                            child = (StoredNode) child.getNextSibling();
                        }
                    }

                    if (deletedNodes.get(nodeId) == null) {
                        QName attrQn = new QName(reader.getAttributeLocalName(i), reader.getAttributeNamespace(i),
                                reader.getAttributePrefix(i));
                        attrs.addAttribute(
                                attrQn,
                                reader.getAttributeValue(i),
                                getAttributeType(reader.getAttributeType(i))
                        );
                    }
                }
                QName qn = new QName(reader.getLocalName(), reader.getNamespaceURI(), reader.getPrefix());
                receiver.startElement(qn, attrs);
                if (elementStack != null)
                    elementStack.push(qn);
                break;
            case XMLStreamReader.END_ELEMENT:
                receiver.endElement(new QName(reader.getLocalName(), reader.getNamespaceURI(), reader.getPrefix()));
                if (elementStack != null) {
                    if (elementStack.isEmpty())
                        receiver.endPrefixMapping(StandardDiff.PREFIX);
                    elementStack.pop();
                }
                break;
            case XMLStreamReader.CHARACTERS:
                if (onFirstNode && annotate) {
                    attrs = new AttrList();
                    attrs.addAttribute(ATTR_CHANGE, changeMessage);
                    receiver.startElement(ELEMENT_WRAPPER, attrs);
                }
                receiver.characters(reader.getText());
                if (onFirstNode && annotate)
                    receiver.endElement(ELEMENT_WRAPPER);
View Full Code Here

            }
        }

        public void serialize(DBBroker broker, Receiver handler) {
            try {
                AttrList attribs = new AttrList();
                attribs.addAttribute(ATTR_REF, refChild.getNodeId().toString());
                handler.startElement(ELEMENT_INSERT, attribs);
                serializeChildren(broker, handler);
                handler.endElement(ELEMENT_INSERT);
            } catch (SAXException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
View Full Code Here

                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
        }

        protected void serializeChildren(DBBroker broker, Receiver handler) throws SAXException {
            AttrList attribs;
            for (int i = 0; i < nodes.length; i++) {
                switch (nodes[i].nodeType) {
                    case XMLStreamReader.ATTRIBUTE:
                        attribs = new AttrList();
                        AttrImpl attr = (AttrImpl) broker.objectWith(otherDoc, nodes[i].nodeId);
                        attribs.addAttribute(new QName(attr.getLocalName(), attr.getNamespaceURI(), attr.getPrefix()),
                                attr.getValue(), attr.getType());
                        handler.startElement(ELEMENT_ATTRIBUTE, attribs);
                        handler.endElement(ELEMENT_ATTRIBUTE);
                        break;
                    case XMLStreamReader.START_ELEMENT:
                        // check if there's a complete element to write, not just a start or end tag
                        // if yes, just copy the element, if no, write a start-tag node
                        boolean isClosed = false;
                        NodeId nodeId = nodes[i].nodeId;
                        for (int j = i; j < nodes.length; j++) {
                            if (nodes[j].nodeType == XMLStreamReader.END_ELEMENT &&
                                    nodes[j].nodeId.equals(nodeId)) {
                                isClosed = true;
                                NodeProxy proxy = new NodeProxy(otherDoc, nodes[i].nodeId);
                                Serializer serializer = broker.getSerializer();
                                serializer.reset();
                                serializer.setProperty(Serializer.GENERATE_DOC_EVENTS, "false");
                                serializer.setReceiver(handler);
                                serializer.toReceiver(proxy, false);
                                i = j;
                                break;
                            }
                        }
                        if (!isClosed) {
                            attribs = new AttrList();
                            if (nodes[i].qname.needsNamespaceDecl())
                                attribs.addAttribute(ATTR_NAMESPACE, nodes[i].qname.getNamespaceURI());
                            attribs.addAttribute(ATTR_NAME, nodes[i].qname.getStringValue());
                            handler.startElement(ELEMENT_START, attribs);
                            handler.endElement(ELEMENT_START);
                        }
                        break;
                    case XMLStreamReader.END_ELEMENT:
                        attribs = new AttrList();
                        if (nodes[i].qname.needsNamespaceDecl())
                            attribs.addAttribute(ATTR_NAMESPACE, nodes[i].qname.getNamespaceURI());
                        attribs.addAttribute(ATTR_NAME, nodes[i].qname.getStringValue());
                        handler.startElement(ELEMENT_END, attribs);
                        handler.endElement(ELEMENT_END);
                        break;
                    case XMLStreamReader.COMMENT:
                        attribs = new AttrList();
                        handler.startElement(ELEMENT_COMMENT, attribs);
                        handler.characters(nodes[i].value);
                        handler.endElement(ELEMENT_COMMENT);
                        break;
                    default:
View Full Code Here

        File file = new File(outFile);
        try {
            writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(file)), "UTF-8");
            serializer = new SAXSerializer(writer, defaultProperties);
            serializer.startDocument();
            AttrList attribs = new AttrList();
            serializer.startElement(ROOT_ELEMENT, attribs);
        } catch (Exception e) {
            throw new EXistException("error while configuring test output file: " + file.getAbsolutePath(), e);
        }
    }
View Full Code Here

            throw new EXistException("error while configuring test output file: " + file.getAbsolutePath(), e);
        }
    }

    public synchronized void report(Action action, String message, long elapsed) {
        AttrList attribs = new AttrList();
        attribs.addAttribute(THREAD_ATTRIB, Thread.currentThread().getName());
        attribs.addAttribute(NAME_ATTRIB, action.getClass().getName());
        attribs.addAttribute(ELAPSED_ATTRIB, Long.toString(elapsed));
        attribs.addAttribute(ID_ATTRIB, action.getId());
        if (action.getParent() != null && !(action.getParent() instanceof ActionThread))
            attribs.addAttribute(PARENT_ATTRIB, action.getParent().getId());
        if (action.getDescription() != null)
            attribs.addAttribute(DESCRIPTION_ATTRIB, action.getDescription());
        if (action.getLastResult() != null)
            attribs.addAttribute(RESULT_ATTRIB, action.getLastResult());
        try {
            serializer.startElement(ACTION_ELEMENT, attribs);
            if (message != null)
                serializer.characters(message);
            serializer.endElement(ACTION_ELEMENT);
View Full Code Here

            e.printStackTrace();
        }
    }

    public synchronized void threadStarted(ActionThread thread) {
        AttrList attribs = new AttrList();
        attribs.addAttribute(NAME_ATTRIB, thread.getName());
        try {
            serializer.startElement(THREAD_ELEMENT, attribs);
            serializer.endElement(ACTION_ELEMENT);
        } catch (SAXException e) {
            e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.exist.util.serializer.AttrList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.