Package org.exist.storage.serializers

Examples of org.exist.storage.serializers.Serializer


        try {
          System.out.println("testRead() ...\n")
         
          pool = startDB();
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            Serializer serializer = broker.getSerializer();
            serializer.reset();
           
            DocumentImpl doc;
            String data;
           
            doc = broker.getXMLResource(TEST_COLLECTION_URI.append("test2/test.xml"), Lock.READ_LOCK);
            assertNotNull("Document '"+ TEST_COLLECTION_URI.append("test2/test.xml")+"' should not be null", doc);
            data = serializer.serialize(doc);
            System.out.println(data);
            doc.getUpdateLock().release(Lock.READ_LOCK);
           
            XQuery xquery = broker.getXQueryService();
            Sequence seq = xquery.execute("/products/product[last()]", null, AccessContext.TEST);
            System.out.println("Found: " + seq.getItemCount());
            for (SequenceIterator i = seq.iterate(); i.hasNext(); ) {
                Item next = i.nextItem();
                System.out.println(serializer.serialize((NodeValue) next));
            }
        } catch (Exception e) {           
            fail(e.getMessage());
        } finally {
            if (pool != null) pool.release(broker);
View Full Code Here


                final OutputStream os = new FileOutputStream(file, doAppend);
                final String encoding = outputProperties.getProperty(OutputKeys.ENCODING, "UTF-8");
                writer = new OutputStreamWriter(os, encoding);

                sax.setOutput(writer, outputProperties);
                final Serializer serializer = context.getBroker().getSerializer();
                serializer.reset();
                serializer.setProperties(outputProperties);
                serializer.setReceiver(sax);

                sax.startDocument();

                while(siNode.hasNext()) {
                    final NodeValue next = (NodeValue)siNode.nextItem();
                    serializer.toSAX(next)
                }

                sax.endDocument();
               
            } catch(final SAXException e) {
View Full Code Here

        OUTPUT_PROPERTIES.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
    }
   
  protected String serialize(Sequence q) throws SAXException, XPathException {
    String tmp = "";
    Serializer serializer = context.getBroker().getSerializer();
        serializer.reset();
        serializer.setProperties(OUTPUT_PROPERTIES);
        for (SequenceIterator i = q.iterate(); i.hasNext();){
          Item item = i.nextItem();
          try {
              NodeValue node = (NodeValue)item;
              tmp += serializer.serialize(node);
          } catch (ClassCastException e){
            tmp += item.getStringValue();
          }
        }
        return tmp;
View Full Code Here

  return result;
    }
 
    private String serialize(NodeValue node) throws SAXException {
  Serializer serializer = context.getBroker().getSerializer();
        serializer.reset();
        serializer.setProperties(OUTPUT_PROPERTIES);
        return serializer.serialize(node);
    }
View Full Code Here

                throw new EXistException("document not found");
            }
           
            if(!doc.getPermissions().validate(user, Permission.READ))
                {throw new PermissionDeniedException("Insufficient privileges to read resource " + docUri);}
            final Serializer serializer = broker.getSerializer();
            serializer.setProperties(parametri);
            final String xml = serializer.serialize(doc);
           
            return xml;
        } catch (final NoSuchMethodError nsme) {
            LOG.error(nsme.getMessage(), nsme);
            return null;
View Full Code Here

                vtempFile.setTempPrefix("eXistRPCC");

                // binary check TODO dwes
                if(doc.getResourceType() == DocumentImpl.XML_FILE) {
                    vtempFile.setTempPostfix(".xml");
                    final Serializer serializer = broker.getSerializer();
                    serializer.setProperties(parameters);

                    Writer writer = null;
                    try {
                        writer = new OutputStreamWriter(vtempFile, encoding);
                        serializer.serialize(doc, writer);
                    } finally {
                        if(writer != null) {
                            writer.close();
                        }
                    }
View Full Code Here

        writer.write(Integer.toString(start));
        writer.write("\" count=\"");
        writer.write(Integer.toString(howmany));
        writer.write("\">\n");
       
        final Serializer serializer = broker.getSerializer();
        serializer.reset();
        serializer.setProperties(properties);
       
        Item item;
        for (int i = --start; i < start + howmany; i++) {
            item = resultSet.itemAt(i);
            if (item == null)
                {continue;}
            if (item.getType() == Type.ELEMENT) {
                final NodeValue node = (NodeValue) item;
                writer.write(serializer.serialize(node));
            } else {
                writer.write("<exist:value type=\"");
                writer.write(Type.getTypeName(item.getType()));
                writer.write("\">");
                writer.write(item.getStringValue());
View Full Code Here

            final NodeId nodeId = factory.getBrokerPool().getNodeFactory().createFromString(s_id);
            DocumentImpl doc;
                LOG.debug("loading doc " + docUri);
                doc = (DocumentImpl) broker.getXMLResource(docUri);
            final NodeProxy node = new NodeProxy(doc, nodeId);
            final Serializer serializer = broker.getSerializer();
            serializer.reset();
            serializer.setProperties(parameters);
            return serializer.serialize(node);

        } catch (final Throwable e) {
            handleException(e);
            return null;
View Full Code Here

        DocumentImpl doc;
        LOG.debug("loading doc " + docUri);
        doc = (DocumentImpl) broker.getXMLResource(docUri);
        final NodeProxy node = new NodeProxy(doc, nodeId);

        final Serializer serializer = broker.getSerializer();
        serializer.reset();
        serializer.setProperties(parameters);

        final HashMap<String, Object> result = new HashMap<String, Object>();
        VirtualTempFile vtempFile = new VirtualTempFile(MAX_DOWNLOAD_CHUNK_SIZE,MAX_DOWNLOAD_CHUNK_SIZE);
        vtempFile.setTempPrefix("eXistRPCC");
        vtempFile.setTempPostfix(".xml");

        OutputStream os=null;
        if("yes".equals(compression)) {
          LOG.debug("get result with compression");
          os = new DeflaterOutputStream(vtempFile);
        } else {
          os = vtempFile;
        }
        try {
          final Writer writer = new OutputStreamWriter(os, encoding);
          try {
            serializer.serialize(node, writer);
          } finally {
            writer.close();
          }
        } finally {
          try {
View Full Code Here

            if (item == null)
                {throw new EXistException("index out of range");}
           
            if(Type.subTypeOf(item.getType(), Type.NODE)) {
                final NodeValue nodeValue = (NodeValue)item;
                final Serializer serializer = broker.getSerializer();
                serializer.reset();
                for (final Map.Entry<Object, Object> entry : qr.serialization.entrySet()) {
                    parameters.put(entry.getKey().toString(), entry.getValue().toString());
                }
                serializer.setProperties(parameters);
                return serializer.serialize(nodeValue);
            } else {
                return item.getStringValue();
            }
        } finally {
            factory.getBrokerPool().release(broker);
View Full Code Here

TOP

Related Classes of org.exist.storage.serializers.Serializer

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.