Package org.apache.vxquery.datamodel.builders.nodes

Examples of org.apache.vxquery.datamodel.builders.nodes.ElementNodeBuilder


    private final SequencePointable seqp;

    public ElementNodeConstructorScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
        super(ctx, args);
        enb = new ElementNodeBuilder();
        anb = new AttributeNodeBuilder();
        freeENBList = new ArrayList<ElementNodeBuilder>();
        namep = (XSQNamePointable) XSQNamePointable.FACTORY.createPointable();
        cqp = (CodedQNamePointable) CodedQNamePointable.FACTORY.createPointable();
        strp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
View Full Code Here


        SequencePointable seqp = ppool.takeOne(SequencePointable.class);
        AttributeNodePointable anp = ppool.takeOne(AttributeNodePointable.class);
        TaggedValuePointable tvp = ppool.takeOne(TaggedValuePointable.class);
        ElementNodePointable cenp = ppool.takeOne(ElementNodePointable.class);
        try {
            ElementNodeBuilder tempEnb = createENB();
            enb.startChild(tempEnb);
            enp.getName(cqp);
            int newURICode = recode(cqp.getNamespaceCode(), ntp, db, strp);
            int newPrefixCode = recode(cqp.getPrefixCode(), ntp, db, strp);
            int newLocalCode = recode(cqp.getLocalCode(), ntp, db, strp);
            tempEnb.setName(newURICode, newLocalCode, newPrefixCode);
            tempEnb.startAttributeChunk();
            if (enp.attributesChunkExists()) {
                enp.getAttributeSequence(ntp, seqp);
                for (int i = 0; i < seqp.getEntryCount(); ++i) {
                    seqp.getEntry(i, tvp);
                    tvp.getValue(anp);
                    copyAttribute(tempEnb, db, ntp, anp);
                }
            }
            tempEnb.endAttributeChunk();
            tempEnb.startChildrenChunk();
            if (enp.childrenChunkExists()) {
                enp.getChildrenSequence(ntp, seqp);
                for (int i = 0; i < seqp.getEntryCount(); ++i) {
                    seqp.getEntry(i, tvp);
                    byte nTag = tvp.getTag();
                    switch (nTag) {
                        case ValueTag.ELEMENT_NODE_TAG: {
                            tvp.getValue(cenp);
                            copyElement(tempEnb, db, ntp, cenp);
                            break;
                        }
                        case ValueTag.COMMENT_NODE_TAG:
                        case ValueTag.PI_NODE_TAG:
                        case ValueTag.TEXT_NODE_TAG: {
                            tempEnb.addChild(tvp);
                            break;
                        }
                    }
                }
            }
            tempEnb.endChildrenChunk();
            enb.endChild(tempEnb);
            freeENB(tempEnb);
        } finally {
            ppool.giveBack(cenp);
            ppool.giveBack(tvp);
View Full Code Here

        }
    }

    private ElementNodeBuilder createENB() {
        if (freeENBList.isEmpty()) {
            return new ElementNodeBuilder();
        }
        return freeENBList.remove(freeENBList.size() - 1);
    }
View Full Code Here

    @Override
    public void endElement(String uri, String localName, String name) throws SAXException {
        try {
            flushText();
            ElementNodeBuilder enb = enbStack.remove(enbStack.size() - 1);
            enb.endChildrenChunk();
            endChildInParent(enb);
            freeENB(enb);
        } catch (IOException e) {
            e.printStackTrace();
            throw new SAXException(e);
View Full Code Here

    public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
        try {
            flushText();
            int idx = name.indexOf(':');
            String prefix = idx < 0 ? "" : name.substring(0, idx);
            ElementNodeBuilder enb = createENB();
            startChildInParent(enb);
            int uriCode = db.lookup(uri);
            int localNameCode = db.lookup(localName);
            int prefixCode = db.lookup(prefix);
            enb.setName(uriCode, localNameCode, prefixCode);
            if (attachTypes) {
                int typeUriCode = db.lookup(XQueryConstants.XS_NSURI);
                int typeLocalNameCode = db.lookup(BuiltinTypeQNames.UNTYPED_STR);
                int typePrefixCode = db.lookup(XQueryConstants.XS_PREFIX);
                enb.setType(typeUriCode, typeLocalNameCode, typePrefixCode);
            }
            if (createNodeIds) {
                enb.setLocalNodeId(nodeIdCounter++);
            }
            enb.startAttributeChunk();
            final int nAttrs = atts.getLength();
            for (int i = 0; i < nAttrs; ++i) {
                String aName = atts.getQName(i);
                int aIdx = aName.indexOf(':');
                int aPrefixCode = db.lookup(aIdx < 0 ? "" : aName.substring(0, aIdx));
                int aLocalNameCode = db.lookup(atts.getLocalName(i));
                int aUriCode = db.lookup(atts.getURI(i));
                String aValue = atts.getValue(i);
                tempABVS.reset();
                DataOutput tempOut = tempABVS.getDataOutput();
                tempOut.write(ValueTag.XS_UNTYPED_ATOMIC_TAG);
                tempOut.writeUTF(aValue);
                enb.startAttribute(anb);
                anb.setName(aUriCode, aLocalNameCode, aPrefixCode);
                if (attachTypes) {
                    int typeUriCode = db.lookup(XQueryConstants.XS_NSURI);
                    int typeLocalNameCode = db.lookup(BuiltinTypeQNames.UNTYPED_ATOMIC_STR);
                    int typePrefixCode = db.lookup(XQueryConstants.XS_PREFIX);
                    anb.setType(typeUriCode, typeLocalNameCode, typePrefixCode);
                }
                if (createNodeIds) {
                    anb.setLocalNodeId(nodeIdCounter++);
                }
                anb.setValue(tempABVS);
                enb.endAttribute(anb);
            }
            enb.endAttributeChunk();
            enb.startChildrenChunk();
            enbStack.add(enb);
        } catch (IOException e) {
            e.printStackTrace();
            throw new SAXException(e);
        }
View Full Code Here

        out.write(docABVS.getByteArray(), docABVS.getStartOffset(), docABVS.getLength());
    }

    private ElementNodeBuilder createENB() {
        if (freeENBList.isEmpty()) {
            return new ElementNodeBuilder();
        }
        return freeENBList.remove(freeENBList.size() - 1);
    }
View Full Code Here

    private final PointablePool ppool;

    public ElementNodeConstructorScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
        super(ctx, args);
        enb = new ElementNodeBuilder();
        anb = new AttributeNodeBuilder();
        freeENBList = new ArrayList<ElementNodeBuilder>();
        namep = (XSQNamePointable) XSQNamePointable.FACTORY.createPointable();
        cqp = (CodedQNamePointable) CodedQNamePointable.FACTORY.createPointable();
        strp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
View Full Code Here

        SequencePointable seqp = ppool.takeOne(SequencePointable.class);
        AttributeNodePointable anp = ppool.takeOne(AttributeNodePointable.class);
        TaggedValuePointable tvp = ppool.takeOne(TaggedValuePointable.class);
        ElementNodePointable cenp = ppool.takeOne(ElementNodePointable.class);
        try {
            ElementNodeBuilder tempEnb = createENB();
            enb.startChild(tempEnb);
            enp.getName(cqp);
            int newURICode = recode(cqp.getNamespaceCode(), ntp, db, strp);
            int newPrefixCode = recode(cqp.getPrefixCode(), ntp, db, strp);
            int newLocalCode = recode(cqp.getLocalCode(), ntp, db, strp);
            tempEnb.setName(newURICode, newLocalCode, newPrefixCode);
            tempEnb.startAttributeChunk();
            if (enp.attributesChunkExists()) {
                enp.getAttributeSequence(ntp, seqp);
                for (int i = 0; i < seqp.getEntryCount(); ++i) {
                    seqp.getEntry(i, tvp);
                    tvp.getValue(anp);
                    copyAttribute(tempEnb, db, ntp, anp);
                }
            }
            tempEnb.endAttributeChunk();
            tempEnb.startChildrenChunk();
            if (enp.childrenChunkExists()) {
                enp.getChildrenSequence(ntp, seqp);
                for (int i = 0; i < seqp.getEntryCount(); ++i) {
                    seqp.getEntry(i, tvp);
                    byte nTag = tvp.getTag();
                    switch (nTag) {
                        case ValueTag.ELEMENT_NODE_TAG: {
                            tvp.getValue(cenp);
                            copyElement(tempEnb, db, ntp, cenp);
                            break;
                        }
                        case ValueTag.COMMENT_NODE_TAG:
                        case ValueTag.PI_NODE_TAG:
                        case ValueTag.TEXT_NODE_TAG: {
                            tempEnb.addChild(tvp);
                            break;
                        }
                    }
                }
            }
            tempEnb.endChildrenChunk();
            enb.endChild(tempEnb);
            freeENB(tempEnb);
        } finally {
            ppool.giveBack(cenp);
            ppool.giveBack(tvp);
View Full Code Here

        }
    }

    private ElementNodeBuilder createENB() {
        if (freeENBList.isEmpty()) {
            return new ElementNodeBuilder();
        }
        return freeENBList.remove(freeENBList.size() - 1);
    }
View Full Code Here

    @Override
    public void endElement(String uri, String localName, String name) throws SAXException {
        try {
            flushText();
            ElementNodeBuilder enb = enbStack.remove(enbStack.size() - 1);
            enb.endChildrenChunk();
            endChildInParent(enb);
            freeENB(enb);
        } catch (IOException e) {
            e.printStackTrace();
            throw new SAXException(e);
View Full Code Here

TOP

Related Classes of org.apache.vxquery.datamodel.builders.nodes.ElementNodeBuilder

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.