Package org.exist.storage.serializers

Examples of org.exist.storage.serializers.Serializer


        try {
          final Writer writer = new OutputStreamWriter(os, encoding);
          try {
            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);

              serializer.serialize(nodeValue, writer);
            } else {
              writer.write(item.getStringValue());
            }
          } finally {
            try {
View Full Code Here


            broker = factory.getBrokerPool().get(user);
            final QueryResult qr = factory.resultSets.getResult(resultId);
            if (qr == null)
                {throw new EXistException("result set unknown or timed out");}
            qr.touch();
            final Serializer serializer = broker.getSerializer();
            serializer.reset();
            serializer.setProperties(qr.serialization);
           
            final SAXSerializer handler = (SAXSerializer) SerializerPool.getInstance().borrowObject(SAXSerializer.class);
            final StringWriter writer = new StringWriter();
            handler.setOutput(writer, getProperties(parameters));
           
View Full Code Here

        broker = factory.getBrokerPool().get(user);
        final QueryResult qr = factory.resultSets.getResult(resultId);
        if (qr == null)
          {throw new EXistException("result set unknown or timed out");}
        qr.touch();
        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);
        final SAXSerializer handler = (SAXSerializer) SerializerPool.getInstance().borrowObject(SAXSerializer.class);

        final HashMap<String, Object> result = new HashMap<String, Object>();
        VirtualTempFile vtempFile = new VirtualTempFile(MAX_DOWNLOAD_CHUNK_SIZE,MAX_DOWNLOAD_CHUNK_SIZE);
        vtempFile.setTempPrefix("eXistRPCC");
View Full Code Here

            }
           
            mgr.commit(transaction);
            System.out.println("Transaction commited ...");
           
            Serializer serializer = broker.getSerializer();
            serializer.reset();
           
            DocumentImpl doc = broker.getXMLResource(TestConstants.TEST_COLLECTION_URI2.append(TestConstants.TEST_XML_URI), Lock.READ_LOCK);
            assertNotNull("Document '" + XmldbURI.ROOT_COLLECTION + "/test/test2/test.xml' should not be null", doc);
            String data = serializer.serialize(doc);
            System.out.println(data);
            doc.getUpdateLock().release(Lock.READ_LOCK);
           
            // the following transaction will not be committed and thus undone during recovery
            transaction = mgr.beginTransaction();
View Full Code Here

          System.out.println("testRead() ...\n");
          pool = startDB();
          assertNotNull(pool);
             broker = pool.get(pool.getSecurityManager().getSystemSubject());
             assertNotNull(broker);
            Serializer serializer = broker.getSerializer();
            assertNotNull(serializer);
            serializer.reset();
           
            DocumentImpl doc = broker.getXMLResource(TestConstants.TEST_COLLECTION_URI2.append(TestConstants.TEST_XML_URI), Lock.READ_LOCK);
            assertNotNull("Document '" + XmldbURI.ROOT_COLLECTION + "/test/test2/test.xml' should not be null", doc);
            String data = serializer.serialize(doc);
            assertNotNull(data);
            System.out.println(data);
            doc.getUpdateLock().release(Lock.READ_LOCK);
        } catch (Exception e) {           
          fail(e.getMessage());                   
View Full Code Here

          System.out.println("testRead() ...\n");
          pool = startDB();
          assertNotNull(pool);
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);
            Serializer serializer = broker.getSerializer();
            serializer.reset();
           
            DocumentImpl doc = broker.getXMLResource(TestConstants.TEST_COLLECTION_URI2.append("terms-eng.xml"), Lock.READ_LOCK);
            assertNotNull("Document should not be null", doc);
            String data = serializer.serialize(doc);
            assertNotNull(data);
            System.out.println(data);
            doc.getUpdateLock().release(Lock.READ_LOCK);
      } catch (Exception e) {           
          fail(e.getMessage());
View Full Code Here

          System.out.println("testRead() ...\n");
          pool = startDB();
          assertNotNull(pool);
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);
            Serializer serializer = broker.getSerializer();
            serializer.reset();
           
            DocumentImpl doc = broker.getXMLResource(XmldbURI.ROOT_COLLECTION_URI.append("/destination1/test3/test.xml"), Lock.READ_LOCK);
            assertNotNull("Document should not be null", doc);
            String data = serializer.serialize(doc);
            assertNotNull(data);
            System.out.println(data);
            doc.getUpdateLock().release(Lock.READ_LOCK);
      } catch (Exception e) {           
          fail(e.getMessage());             
View Full Code Here

          System.out.println("testRead() ...\n");
          pool = startDB();
          assertNotNull(pool);
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);
            Serializer serializer = broker.getSerializer();
            serializer.reset();           
            DocumentImpl doc = broker.getXMLResource(XmldbURI.ROOT_COLLECTION_URI.append("destination2/test3/test.xml"), Lock.READ_LOCK);
            assertNull("Document should be null", doc);
      } catch (Exception e) {           
          fail(e.getMessage());             
        } finally {
View Full Code Here

            Collection root = broker.openCollection(TestConstants.TEST_COLLECTION_URI, Lock.READ_LOCK);
            assertNotNull(root);

            DocumentImpl doc = root.getDocument(broker, XmldbURI.create("test.xml"));
            assertNotNull(doc);
            Serializer serializer = broker.getSerializer();
            serializer.reset();
            File tempFile = File.createTempFile("eXist", ".xml");
            Writer writer = new OutputStreamWriter(new FileOutputStream(tempFile), "UTF-8");
            serializer.serialize(doc, writer);
            tempFile.delete();
//            XQuery xquery = broker.getXQueryService();
//            DocumentSet docs = broker.getAllXMLResources(new DefaultDocumentSet());
//            Sequence result = xquery.execute("//key/@id/string()", docs.docsToNodeSet(), AccessContext.TEST);
//            assertEquals(KEY_COUNT, result.getItemCount());
View Full Code Here

          pool = startDB();
          assertNotNull(pool);
          broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);
           
            Serializer serializer = broker.getSerializer();
            serializer.reset();
           
            DocumentImpl doc = broker.getXMLResource(XmldbURI.ROOT_COLLECTION_URI.append("destination/test3/test.xml"), Lock.READ_LOCK);
            assertNotNull("Document should not be null", doc);
            String data = serializer.serialize(doc);
            System.out.println(data);
            doc.getUpdateLock().release(Lock.READ_LOCK);               
      } catch (Exception e) { 
        e.printStackTrace();
          fail(e.getMessage());             
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.