Examples of InputStreamDataSource


Examples of org.apache.abdera.i18n.text.io.InputStreamDataSource

 
  /**
   * Sets the content for this entry
   */
  public Content setContent(InputStream in, String mediatype){
    InputStreamDataSource ds = new InputStreamDataSource(in, mediatype);
    DataHandler dh = new DataHandler(ds);
    return setContent(dh, mediatype);
  }
View Full Code Here

Examples of org.apache.axiom.om.ds.InputStreamDataSource

        String ENCODING = "utf-8";
        String payload1 = "<tns:myPayload xmlns:tns=\"urn://test\">Payload One</tns:myPayload>";
        String payload2 = "<tns:myPayload xmlns:tns=\"urn://test\">Payload Two</tns:myPayload>";
        ByteArrayDataSource bads1 = new ByteArrayDataSource(payload1.getBytes(ENCODING), ENCODING);
        ByteArrayDataSource bads2 = new ByteArrayDataSource(payload2.getBytes(ENCODING), ENCODING);
        InputStreamDataSource isds1 = new InputStreamDataSource(new ByteArrayInputStream(payload1.getBytes(ENCODING)), ENCODING);
        InputStreamDataSource isds2 = new InputStreamDataSource(new ByteArrayInputStream(payload2.getBytes(ENCODING)), ENCODING);
       
        OMFactory factory = metaFactory.getOMFactory();
        OMElement parent = factory.createOMElement("parent", null);
        OMSourcedElement omse = factory.createOMElement(bads1, "myPayload", factory.createOMNamespace("urn://test", "tns"));
        parent.addChild(omse);
View Full Code Here

Examples of org.apache.axiom.om.ds.InputStreamDataSource

        String localName = "myPayload";
        String encoding = "utf-8";
        String payload1 = "<tns:myPayload xmlns:tns=\"urn://test\">Payload One</tns:myPayload>";
        OMNamespace ns = factory.createOMNamespace("urn://test", "tns");
        ByteArrayInputStream bais1 = new ByteArrayInputStream(payload1.getBytes(encoding));
        InputStreamDataSource isds1 = new InputStreamDataSource(bais1, encoding);
       
        OMElement parent = factory.createOMElement("root", null);
        OMSourcedElement omse = factory.createOMElement(isds1, localName, ns);
        parent.addChild(omse);
        OMNode firstChild = parent.getFirstOMChild();
        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
        OMSourcedElement child = (OMSourcedElement) firstChild;
        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
        assertTrue("OMSourcedElement should be backed by a InputStreamDataSource",
                   child.getDataSource() instanceof InputStreamDataSource);
       
        // A InputStreamDataSource consumes the backing object when read.
        // Thus getting the XMLStreamReader of the ByteArrayDataSource should 
        // cause expansion of the OMSourcedElement.
        XMLStreamReader reader = child.getXMLStreamReader();
        reader.next();
        assertTrue("OMSourcedElement is not expanded.  This is unexpected",
                   child.isExpanded());
       
        child.detach();
       
        // Reset the tree
        isds1 = new InputStreamDataSource(
            new ByteArrayInputStream(payload1.getBytes(encoding)),
            encoding);
        omse = factory.createOMElement(isds1, localName, ns);
        parent.addChild(omse);
        firstChild = parent.getFirstOMChild();
        child = (OMSourcedElement) firstChild;
       
        // Likewise, an InputStreamDataSource consumes the backing object when
        // written.  Thus serializing the OMSourcedElement should cause the expansion
        // of the OMSourcedElement.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        parent.serialize(baos);
        String output = baos.toString(encoding);
        assertTrue("The payload was not present in the output",
                   output.indexOf(payload1) > 0);
        assertTrue("OMSourcedElement is not expanded.  This is unexpected", child.isExpanded());
       
        // Reset the tree
        child.detach();
        isds1 = new InputStreamDataSource(
            new ByteArrayInputStream(payload1.getBytes(encoding)),
            encoding);
        omse = factory.createOMElement(isds1, localName, ns);
        parent.addChild(omse);
        firstChild = parent.getFirstOMChild();
View Full Code Here

Examples of org.apache.axiom.om.ds.InputStreamDataSource

       
        bads1 = new ByteArrayDataSource(payload1.getBytes(ENCODING), ENCODING);
        bads2 = new ByteArrayDataSource(payload2.getBytes(ENCODING), ENCODING);
        ByteArrayInputStream bais1 = new ByteArrayInputStream(payload1.getBytes(ENCODING));
        ByteArrayInputStream bais2 = new ByteArrayInputStream(payload2.getBytes(ENCODING));
        isds1 = new InputStreamDataSource(bais1, ENCODING);
        isds2 = new InputStreamDataSource(bais2, ENCODING);
        cads = new CharArrayDataSource(payload1.toCharArray());
        ns = soapFactory.createOMNamespace("urn://test", "tns");
    }
View Full Code Here

Examples of org.apache.axiom.om.ds.InputStreamDataSource

                   child.isExpanded());
       
        child.detach();
       
        // Reset the tree
        isds1 = new InputStreamDataSource(
            new ByteArrayInputStream(payload1.getBytes(ENCODING)),
            ENCODING);
        omse = factory.createOMElement(isds1, localName, ns);
        soapBody.addChild(omse);
        firstChild = soapBody.getFirstOMChild();
        child = (OMSourcedElement) firstChild;
       
        // Likewise, an InputStreamDataSource consumes the backing object when
        // written.  Thus serializing the OMSourcedElement should cause the expansion
        // of the OMSourcedElement.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        soapBody.serialize(baos);
        String output = baos.toString(ENCODING);
        assertTrue("The payload was not present in the output",
                   output.indexOf(payload1) > 0);
        assertTrue("OMSourcedElement is not expanded.  This is unexpected", child.isExpanded());
       
        // Reset the tree
        child.detach();
        isds1 = new InputStreamDataSource(
            new ByteArrayInputStream(payload1.getBytes(ENCODING)),
            ENCODING);
        omse = factory.createOMElement(isds1, localName, ns);
        soapBody.addChild(omse);
        firstChild = soapBody.getFirstOMChild();
View Full Code Here

Examples of org.apache.axiom.om.ds.InputStreamDataSource

       
        bads1 = new ByteArrayDataSource(payload1.getBytes(ENCODING), ENCODING);
        bads2 = new ByteArrayDataSource(payload2.getBytes(ENCODING), ENCODING);
        ByteArrayInputStream bais1 = new ByteArrayInputStream(payload1.getBytes(ENCODING));
        ByteArrayInputStream bais2 = new ByteArrayInputStream(payload2.getBytes(ENCODING));
        isds1 = new InputStreamDataSource(bais1, ENCODING);
        isds2 = new InputStreamDataSource(bais2, ENCODING);
        cads = new CharArrayDataSource(payload1.toCharArray());
        ns = soapFactory.createOMNamespace("urn://test", "tns");
    }
View Full Code Here

Examples of org.apache.axiom.om.ds.InputStreamDataSource

                   child.isExpanded());
       
        child.detach();
       
        // Reset the tree
        isds1 = new InputStreamDataSource(
            new ByteArrayInputStream(payload1.getBytes(ENCODING)),
            ENCODING);
        omse = factory.createOMElement(isds1, localName, ns);
        soapBody.addChild(omse);
        firstChild = soapBody.getFirstOMChild();
        child = (OMSourcedElement) firstChild;
       
        // Likewise, an InputStreamDataSource consumes the backing object when
        // written.  Thus serializing the OMSourcedElement should cause the expansion
        // of the OMSourcedElement.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        soapBody.serialize(baos);
        String output = baos.toString(ENCODING);
        assertTrue("The payload was not present in the output",
                   output.indexOf(payload1) > 0);
        assertTrue("OMSourcedElement is not expanded.  This is unexpected", child.isExpanded());
       
        // Reset the tree
        child.detach();
        isds1 = new InputStreamDataSource(
            new ByteArrayInputStream(payload1.getBytes(ENCODING)),
            ENCODING);
        omse = factory.createOMElement(isds1, localName, ns);
        soapBody.addChild(omse);
        firstChild = soapBody.getFirstOMChild();
View Full Code Here

Examples of org.apache.cocoon.mail.datasource.InputStreamDataSource

            } else if (getObject() instanceof Part) {
                Part part = (Part) getObject();
                ds = new FilePartDataSource(part, getType(), getName());
            } else if (getObject() instanceof InputStream) {
                InputStream in = (InputStream) getObject();
                ds = new InputStreamDataSource(in, getType(), getName());
            } else if (getObject() instanceof byte[]) {
                byte[] data = (byte[]) getObject();
                ds = new InputStreamDataSource(data, getType(), getName());
            } else {
                // TODO: other classes?
                throw new MessagingException("Not yet supported: " + getObject());
            }
View Full Code Here

Examples of org.apache.cocoon.mail.datasource.InputStreamDataSource

            } else if (getObject() instanceof Part) {
                Part part = (Part) getObject();
                ds = new FilePartDataSource(part, getType(), getName());
            } else if (getObject() instanceof InputStream) {
                InputStream in = (InputStream) getObject();
                ds = new InputStreamDataSource(in, getType(), getName());
            } else if (getObject() instanceof byte[]) {
                byte[] data = (byte[]) getObject();
                ds = new InputStreamDataSource(data, getType(), getName());
            } else {
                // TODO: other classes?
                throw new MessagingException("Not yet supported: " + getObject());
            }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.InputStreamDataSource

        }
        return new MessageBodyWriterDataHandler(r, obj, cls, genericType, anns, mt);
    }
   
    private DataHandler createInputStreamDH(InputStream is, String mimeType) {
        return new DataHandler(new InputStreamDataSource(is, mimeType));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.