Package org.apache.xindice.xml

Examples of org.apache.xindice.xml.NodeSource


                Key key = rec.getKey();
                Value val = rec.getValue();
                if (val.getLength() > 0) {
                    try {
                        if (compressed) {
                            Document doc = new DocumentImpl(val.getData(), symbols, new NodeSource(Collection.this, key));
                            return new ColContainer(key, doc);
                        } else {
                            return new ColContainer(key, DOMParser.toDocument(val));
                        }
                    } catch (Exception e) {
View Full Code Here


            return (Document) v;

        } else if (v instanceof String) {
            try {
                Document doc = DOMParser.toDocument((String) v);
                ((DBDocument) doc).setSource(new NodeSource(col, key));
                return doc;
            } catch (Exception e) {
                if (log.isWarnEnabled()) {
                    log.warn("ignored exception", e);
                }
            }

        } else if (v instanceof byte[]) {
            try {
                SymbolTable s = col.getSymbols();
                NodeSource ns = new NodeSource(col, key);
                return new DocumentImpl((byte[]) v, s, ns);
            } catch (Exception e) {
                if (log.isWarnEnabled()) {
                    log.warn("ignored exception", e);
                }
View Full Code Here

                if (selector != null && !selector.startsWith("$")) {
                    NodeSet ns = col.queryCollection("XPath", selector, nsMap);
                    while (ns != null && ns.hasMoreNodes()) {
                        DBNode node = (DBNode) ns.getNextNode();
                        Document doc = node.getOwnerDocument();
                        NodeSource source = node.getSource();

                        if (docsUpdated.containsKey(source.getKey())) {
                            continue; // We only have to process it once
                        } else {
                            docsUpdated.put(source.getKey(), doc);
                        }

                        execute(doc.getDocumentElement());
                    }
                }
View Full Code Here

                if (selector != null && !selector.startsWith("$")) {
                    NodeSet ns = col.queryCollection("XPath", selector, nsMap);
                    while (ns != null && ns.hasMoreNodes()) {
                        DBNode node = (DBNode) ns.getNextNode();
                        Document doc = node.getOwnerDocument();
                        NodeSource source = node.getSource();

                        if (docsUpdated.containsKey(source.getKey())) {
                            continue; // We only have to process it once
                        } else {
                            docsUpdated.put(source.getKey(), doc);
                        }

                        execute(doc.getDocumentElement());
                    }
                }
View Full Code Here

        switch (e.getType()) {
            case DocumentCache.COMPRESSED:
                {          
                    SymbolTable s = col.getSymbols();
                    NodeSource ns = new NodeSource(col, key);
                    Document doc =  new DocumentImpl(e.getValue().getData(), s, ns);
                    return new Entry(key, doc, e.getMeta());
                }

            case DocumentCache.UNCOMPRESSED:
                try {
                    Document doc = DOMParser.toDocument(e.getValue());
                    ((DBDocument) doc).setSource(new NodeSource(col, key));
                    return new Entry(key, doc, e.getMeta());
                } catch (Exception ex) {
                    if (log.isWarnEnabled()) {
                        log.warn("ignored exception", ex);
                    }
View Full Code Here

     * @throws DBException if operation failed
     */
    private Document parseDocument(Key key, String xml) throws DBException {
        try {
            Document doc = DOMParser.toDocument(xml);
            ((DBDocument) doc).setSource(new NodeSource(this, key));

            // Have to compress to update collection's SymbolTable,
            // which is used even for uncompressed collections
            DOMCompressor.compress(doc, symbols);

View Full Code Here

            Map entryMeta = Entry.createMetaMap(record);
            if (isDocument) {
                Document document;
                if (compressed) {
                    document = new DocumentImpl(value.getData(), symbols, new NodeSource(this, key));
                    if (log.isTraceEnabled()) {
                        log.trace(localDebugHeader +
                                  "Compressed XML document=<" + TextWriter.toString(document) + ">");
                    }
                } else {
View Full Code Here

        if (document instanceof DBDocument) {
            // FIXME: This is a shitty shitty hack... Kill immediately
            DBDocument dbDoc = (DBDocument) document;
            if (dbDoc.getSource() == null) {
                dbDoc.setSource(new NodeSource(this, key));
            }
        }

        /*
         * The possibilities are restricted because only XML
         * is handled by this method.  There are only a few
         * pieces of information that need to be constructed:
         * 1) the xindice DOM document is needed for all XML objects, as
         *         it is handed to the IndexManager and the DBObserver.
         * 2) the packed document, if this is a compressed XML object,
         *        is needed for the cache and the BTree (via the Value object).
         * 3) the string-converted-to-utf-8 bytes, if this is a non-compressed
         *        XML object, is needed for the BTree (via the Value object).
         * 4) A Value object, with a header if headers are enabled, and
         *        otherwise without headers, for the BTree.
         */

        byte[] documentBytes;

        if (compressed) {
            // Create compressed document bytes to be stored in the filer
            documentBytes = DOMCompressor.compress(document, symbols);
            if (log.isTraceEnabled()) {
                log.trace(localDebugHeader + "length=" + documentBytes.length);
            }

            // Create xindice document with just compressed bytes.
            // Passed in document might not necessarily be xindice document,
            // but we should be passing only our documents to index manager.
            document = new DocumentImpl(documentBytes, symbols, new NodeSource(this, key));

            if (log.isTraceEnabled()) {
                log.trace(localDebugHeader + "packedDocument: length=" + documentBytes.length +
                          " document=<" + TextWriter.toString(document) + ">");
            }
View Full Code Here

                Key key = rec.getKey();
                Value val = rec.getValue();
                if (val.getLength() > 0) {
                    try {
                        if (compressed) {
                            Document doc = new DocumentImpl(val.getData(), symbols, new NodeSource(Collection.this, key));
                            return new ColContainer(key, doc);
                        } else {
                            return new ColContainer(key, DOMParser.toDocument(val));
                        }
                    } catch (Exception e) {
View Full Code Here

    /**
     * Add "src" and "col" attributes in {@link NodeSource#SOURCE_NS} namespace.
     */
    public void expandSource() {
        NodeSource src = getSource();
        if (src != null) {
            final String prefix = sourcePrefix("src", NodeSource.SOURCE_NS);

            setAttribute(XMLNS_PREFIX + ":" + prefix, NodeSource.SOURCE_NS);
            setAttribute(prefix + ":" + NodeSource.SOURCE_COL, src.getCollection().getCanonicalName());
            Key k = src.getKey();
            if (k != null) {
                setAttribute(prefix + ":" + NodeSource.SOURCE_KEY, k.toString());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.xindice.xml.NodeSource

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.