Package org.apache.xindice.xml

Examples of org.apache.xindice.xml.NodeSource


        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 = null;

        if (compressed) {
            try {
                documentBytes = DOMCompressor.Compress(document, symbols);
                if (log.isTraceEnabled()) {
                    log.trace(localDebugHeader + "length=" + documentBytes.length);
                }

                // Why must it be re-created?
                document = new DocumentImpl(documentBytes, symbols, new NodeSource(this, key));
                if (log.isTraceEnabled()) {
                    log.trace(localDebugHeader + "packedDocument: length=" + documentBytes.length +
                              " document=<" + TextWriter.toString(document) + ">");
                }
            } catch (Exception e) {
View Full Code Here


                Key key = rec.getKey();
                Value val = rec.getValue();
                if (val.getData() != null) {
                    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

    public short getSymbolID() {
        return symbolID;
    }

    public void expandSource() {
        NodeSource src = getSource();
        if (src != null) {
            final String prefix = sourcePrefix("src");

            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

                    continue;
                }

                Key key = rec.getKey();
                // FIXME: What about inline metadata???
                Document doc = new DocumentImpl(rec.getValue().getData(), symbols, new NodeSource(collection, key));
                try {
                    new SAXHandler(key, doc, ACTION_CREATE, list);
                } catch (Exception e) {
                    if (log.isWarnEnabled()) {
                        log.warn("ignored exception", e);
View Full Code Here

        } else if (v instanceof Document) {
            return (Document) v;
        } 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

                            continue; // We only have to process it once
                        } else {
                            lastDoc = doc;
                        }
                       
                        NodeSource source = node.getSource();

                        Node contextNode = doc.getDocumentElement();
                        execute(contextNode);

                        col.setDocument(source.getKey(), doc);
                    }
                }
            }
        }
    }
View Full Code Here

            }

            if (inlineMetaService == null || metaMap.get("type").equals(ResourceTypeReader.XML)) {
                Document document;
                if (compressed) {
                    document = new DocumentImpl(value.getData(), symbols, new NodeSource(this, key));
                    flushSymbolTable();
                    if (log.isTraceEnabled()) {
                        log.trace(localDebugHeader +
                                  "Compressed XML document=<" + TextWriter.toString(document) + ">");
                    }
View Full Code Here

     * @return A parsed DOM document or null if failure
     */
    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

    /**
     * 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

        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;
        String documentChars = null;

        // FIXME: concurrent symbol table access.
        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

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.