Package org.apache.xindice.xml.dom

Examples of org.apache.xindice.xml.dom.DocumentImpl


        try {
            Object entry = col.getEntry(id);
            if (entry == null) {
                return null;
            } else if (entry instanceof Document) {
                DocumentImpl doc = (DocumentImpl) entry;

                // This should probably just pass the document.
                return new XMLResourceImpl(id, id, this,
                                           doc.getSymbols(),
                                           doc.getDataBytes());

            } else if (entry instanceof byte[]) {
                return new BinaryResourceImpl(id, this, (byte[])entry);
            } else {
                throw new XMLDBException(ErrorCodes.UNKNOWN_RESOURCE_TYPE,
View Full Code Here


    /* see superclass for documentation */
    public org.xmldb.api.base.Collection createCollection(String name) throws XMLDBException {

        checkOpen();
        try {
            Document doc = new DocumentImpl();

            Element colEle = doc.createElement("collection");
            colEle.setAttribute("compressed", "true");
            colEle.setAttribute("name", name);
            doc.appendChild(colEle);

            Element filEle = doc.createElement("filer");
            filEle.setAttribute("class", "org.apache.xindice.core.filer.BTreeFiler");
            colEle.appendChild(filEle);

            return createCollection(name, doc);
        } catch (Exception e) {
View Full Code Here

        // FIXME: There is a copy of this same code in org.apache.xindice.server.xmldb.rpc.messages.Query#queryWrapper
        //        It should be refactored into some common place. May be, NodeSetUtil?
        //

        // Turn the NodeSet into a document.
        DocumentImpl doc = new DocumentImpl();

        Element root = doc.createElement("result");
        doc.appendChild(root);
        int count = 0;
        while (ns != null && ns.hasMoreNodes()) {
            final Object element = ns.getNextNode();
            if (element instanceof Node) {
                Node n = (Node) element;

                if (n.getNodeType() == Node.DOCUMENT_NODE) {
                    n = ((Document) n).getDocumentElement();
                }

                if (n instanceof DBNode) {
                    ((DBNode) n).expandSource();
                }

                root.appendChild(doc.importNode(n, true));
            } else if (element instanceof Boolean || element instanceof Double) {
                root.appendChild(doc.createTextNode(element.toString()));
            } else if (element instanceof String) {
                root.appendChild(doc.createTextNode((String) element));
            } else {
                throw new XindiceRuntimeException("Unknown result type (" + element.getClass().getName() + ") in nodeset");
            }

            count++;
View Full Code Here

                throw new Exception("Unable to parse Collection configuration");
            }
        }
        // Otherwise we need to build the configuration from the name and pattern.
        else {
            doc = new DocumentImpl();

            Element colEle = doc.createElement("collection");
            colEle.setAttribute("compressed", "true");
            colEle.setAttribute("name", (String) message.get(NAME));
            doc.appendChild(colEle);
View Full Code Here

     * @param buffer The Hashtable
     * @return The Document
     */
    public Document convertToDocument(Hashtable buffer) {
        SymbolTable s = getSymbols(buffer);
        return new DocumentImpl((byte[]) buffer.get("document"), s, null);
    }
View Full Code Here

     */
    public SymbolTable getSymbols(Hashtable buffer) {
        //if ( ((Long) buffer.get("timestamp")).longValue() != lastMod ) {
        // lastMod = ((Long) buffer.get("timestamp")).longValue();

        Document doc = new DocumentImpl((byte[]) buffer.get("symbols"), hcSyms, null);

        if (syms == null) {
            syms = new SymbolTable();
        }

        synchronized (syms) {
            syms.streamFromXML(doc.getDocumentElement());
        }
        // }
        return syms;
    }
View Full Code Here

        meta.streamFromXML(doc.getDocumentElement());
        col.setCollectionMeta(meta);

        // Retreive stored meta data and sent back
        meta = col.getCollectionMeta();
        doc = new DocumentImpl();
        doc.appendChild(meta.streamToXML(doc, true));
        result.put(RESULT, TextWriter.toString(doc));
        return result;
    }
View Full Code Here

        meta.streamFromXML(doc.getDocumentElement());
        col.setDocumentMeta(docname, meta);

        // Retreive stored meta data and sent back
        meta = col.getDocumentMeta(docname);
        doc = new DocumentImpl();
        meta.streamToXML(doc, true);
        result.put(RESULT, TextWriter.toString(doc));
        return result;
    }
View Full Code Here

        } catch (Exception e) {
            fail("Can't parse xml document! "+e.getMessage());
        }
        MetaData meta = new MetaData();
        meta.streamFromXML(doc.getDocumentElement(), true);
        Document doc2 = new DocumentImpl();
        doc2.appendChild(meta.streamToXML(doc2, true));
        assertEquals(TextWriter.toString(doc), TextWriter.toString(doc2));
    }
View Full Code Here

    public void testCompressedDocument() throws Exception {
        // Compress the document with own symbol table
        Document document = DOMParser.toDocument(XML);
        SymbolTable symbols = new SymbolTable();
        byte[] data = DOMCompressor.compress(document, symbols);
        Document compressedDoc = new DocumentImpl(data, symbols, null);

        // Store it in the collection
        collection.insertDocument("document", compressedDoc);
        Document res = collection.getDocument("document");
View Full Code Here

TOP

Related Classes of org.apache.xindice.xml.dom.DocumentImpl

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.