Package org.exist.storage.serializers

Examples of org.exist.storage.serializers.Serializer


                            }
                        }
                        else
                        {
                            //xml
                            Serializer serializer = context.getBroker().getSerializer();
                            serializer.setUser(context.getUser());
                            serializer.setProperty("omit-xml-declaration", "no");
                            getDynamicSerializerOptions(serializer);
                            value = serializer.serialize((NodeValue) content).getBytes();
                        }
                    }

                    if (entry instanceof ZipEntry &&
                        "store".equals(element.getAttribute("method"))) {
View Full Code Here


      entry = newEntry(doc.getFileURI().toString());
    }

    if (doc.getResourceType() == DocumentImpl.XML_FILE) {
      // xml file
      Serializer serializer = context.getBroker().getSerializer();
      serializer.setUser(context.getUser());
      serializer.setProperty("omit-xml-declaration", "no");
            getDynamicSerializerOptions(serializer);
            String strDoc = serializer.serialize(doc);
            value = strDoc.getBytes();           
    } else if (doc.getResourceType() == DocumentImpl.BINARY_FILE) {
      // binary file
            InputStream is = context.getBroker().getBinaryResource((BinaryDocument)doc);
      byte[] data = new byte[16384];
View Full Code Here

    @Override
    protected void startNode(Node node) throws TransformerException {
        if(node.getNodeType() == NodeImpl.REFERENCE_NODE) {
            final SAXSerializer handler = (SAXSerializer) SerializerPool.getInstance().borrowObject(SAXSerializer.class);
            handler.setReceiver(receiver);
            final Serializer serializer = broker.getSerializer();
            serializer.setSAXHandlers(handler, handler);
            try {
                serializer.setProperties(outputProperties);
                serializer.setProperty(Serializer.GENERATE_DOC_EVENTS, "false");
            } catch (final SAXNotRecognizedException e) {
                //Nothing to do ?
            } catch (final SAXNotSupportedException e) {
                //Nothing to do ?
            }
            try {
                serializer.toSAX(((ReferenceNode)node).getReference());
            } catch (final SAXException e) {
                throw new TransformerException(e.getMessage(), e);
            } finally {
                SerializerPool.getInstance().returnObject(handler);
            }
View Full Code Here

        case NodeImpl.REFERENCE_NODE:
            if (expandRefs) {
                DBBroker broker = null;
                try {
                    broker = getDatabase().get(null);
                    final Serializer serializer = broker.getSerializer();
                    serializer.reset();
                    serializer.setProperty(Serializer.GENERATE_DOC_EVENTS, "false");
                    serializer.setReceiver(receiver);
                    serializer.toReceiver(document.references[document.alpha[nr]], false, false);
                } catch (final EXistException e) {
                    throw new SAXException(e);
                } finally {
                    getDatabase().release(broker);
                }
View Full Code Here

    /* (non-Javadoc)
     * @see org.exist.xquery.value.Item#toSAX(org.exist.storage.DBBroker, org.xml.sax.ContentHandler)
     */
    public void toSAX( DBBroker broker, ContentHandler handler, Properties properties )
        throws SAXException {
        final Serializer serializer = broker.getSerializer();
        serializer.reset();
        serializer.setProperty( Serializer.GENERATE_DOC_EVENTS, "false" );

        if( properties != null ) {
            serializer.setProperties( properties );
        }

        if( handler instanceof LexicalHandler ) {
            serializer.setSAXHandlers( handler, (LexicalHandler)handler );
        } else {
            serializer.setSAXHandlers( handler, null );
        }

        serializer.toSAX( this );
    }
View Full Code Here

    private synchronized File serialize(final DBBroker broker, final DocumentImpl doc) throws IOException {
      if (file != null)
        {throw new IOException(doc.getFileURI().toString()+" locked.");}
       
      try {
      final Serializer serializer = broker.getSerializer();
      serializer.setUser(broker.getSubject());
      serializer.setProperties(XML_OUTPUT_PROPERTIES);
     
            file = File.createTempFile("eXist-resource-", ".xml");
            file.deleteOnExit();

            final Writer w = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
     
      serializer.serialize(doc, w);
      w.flush();
      w.close();
     
      return file;
     
View Full Code Here

                broker.moveResource(txn, doc, destination, newName);
               
            } else {
                //convert XML to BINARY
                // xml file
                final Serializer serializer = broker.getSerializer();
                serializer.setUser(broker.getSubject());
                serializer.setProperties(XML_OUTPUT_PROPERTIES);
               
                File tempFile = null;
                FileInputStream is = null;
        try {
                    tempFile = File.createTempFile("eXist-resource-", ".xml");
                    tempFile.deleteOnExit();
                   
                    final Writer w = new OutputStreamWriter(new FileOutputStream(tempFile), "UTF-8");

                    serializer.serialize(doc, w);
                    w.flush();
                    w.close();
                   
                    is = new FileInputStream(tempFile);
                   
View Full Code Here

        String label = args[1].getStringValue();
        if(label==null){
            label="";
        }
       
        final Serializer serializer= context.getBroker().getSerializer();
       
        Sequence result ;
       
        if(args[0].isEmpty()){
            result = Sequence.EMPTY_SEQUENCE;
           
        } else {
            // Copy all Items from input to output sequence
            result = new ValueSequence();
           
            int position = 0;

            for (final SequenceIterator i = args[0].iterate(); i.hasNext();) {

                // Get item
                final Item next = i.nextItem();

                // Only write if debug mode
                if (true) {
                   
                    String value = null;
                    position++;

                    final int type = next.getType();
                   
                    // Serialize an element type
                    if (Type.ELEMENT == type) {
                        final Writer sw = new StringWriter();
                        try {
                            serializer.serialize((NodeValue) next, sw);

                        } catch (final SAXException ex) {
                            LOG.error(ex.getMessage());
                        }
                        value = sw.toString();
View Full Code Here

           
            if (requestAttr != null && (XmldbURI.API_LOCAL.equals(collectionURI.getApiName())) ) {
                request.setAttribute(requestAttr, resultSequence);
               
            } else {
              final Serializer serializer = broker.getSerializer();
              serializer.reset();
           
              final SerializerPool serializerPool = SerializerPool.getInstance();

              final SAXSerializer sax = (SAXSerializer) serializerPool.borrowObject(SAXSerializer.class);
              try {
                sax.setOutput(output, outputProperties);
                serializer.setProperties(outputProperties);
                serializer.setSAXHandlers(sax, sax);
                serializer.toSAX(resultSequence, 1, resultSequence.getItemCount(), false, false);
                   
              } finally {
                serializerPool.returnObject(sax);
              }
            }
View Full Code Here

                SerializerUtils.getSerializationOptions(this, (NodeValue) args[1].itemAt(0), outputProperties);
        }

        final StringBuilder out = new StringBuilder();

        final Serializer serializer = context.getBroker().getSerializer();
        serializer.reset();
        try {
            serializer.setProperties(outputProperties);
            final Sequence normalized = normalize(args[0]);
            for (final SequenceIterator i = normalized.iterate(); i.hasNext(); ) {
                final Item next = i.nextItem();
                if (Type.subTypeOf(next.getType(), Type.NODE)) {
                    final String val = serializer.serialize((NodeValue) next);
                    out.append(val);
                }
            }
            return new StringValue(out.toString());
        } catch (final SAXNotRecognizedException e) {
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.