Package org.apache.axiom.attachments

Examples of org.apache.axiom.attachments.ByteArrayDataSource


    content.setSrc("foo");
    assertNotNull(content);
    assertEquals(content.getMimeType().toString(), "text/foo");
    assertEquals(content.getSrc().toString(), "foo");
    content = factory.newContent(new MimeType("text/foo"));
    content.setDataHandler(new DataHandler(new ByteArrayDataSource("foo".getBytes())));
    assertEquals(content.getValue(), "Zm9v");
    assertEquals(content.getContentType(), Content.Type.MEDIA);
    el = factory.newName();
    assertNotNull(el);
    el = factory.newName();
View Full Code Here


          entry.addAttribute(TYPE, BYTE, attrNS);
          entry.setText(((Byte) o).toString());
        } else if (o instanceof byte[]) {
          entry.addAttribute(TYPE, BYTEARRAY, attrNS);
          OMText text = fac.createOMText(new DataHandler(
              new ByteArrayDataSource((byte[]) o)), true);
          entry.addChild(text);
        } else if (o instanceof Float) {
          entry.addAttribute(TYPE, FLOAT, attrNS);
          entry.setText(o.toString());
        } else if (o instanceof Double) {
View Full Code Here

                msgField.addAttribute(soapFactory.createOMAttribute(FIXConstants.FIX_FIELD_ID,
                        null, String.valueOf(field.getTag())));
                Object value = field.getObject();

                if (value instanceof byte[]) {
                    DataSource dataSource = new ByteArrayDataSource((byte[]) value);
                    DataHandler dataHandler = new DataHandler(dataSource);
                    String contentID = msgCtx.addAttachment(dataHandler);
                    OMElement binaryData = soapFactory.createOMElement(
                            FIXConstants.FIX_BINARY_FIELD, null);
                    String binaryCID = "cid:" + contentID;
                    binaryData.addAttribute(FIXConstants.FIX_MESSAGE_REFERENCE, binaryCID, null);
                    msgField.addChild(binaryData);
                } else {
                    soapFactory.createOMText(msgField, value.toString(),
                            OMElement.CDATA_SECTION_NODE);
                }
                header.addChild(msgField);
            }
        }
        //process FIX body
        convertFIXBodyToXML(message, body, soapFactory, msgCtx);

        //process FIX trailer
        iter = message.getTrailer().iterator();
        if (iter != null) {
            while (iter.hasNext()) {
                Field<?> field = iter.next();
                OMElement msgField = soapFactory.createOMElement(FIXConstants.FIX_FIELD, null);
                msgField.addAttribute(soapFactory.
                        createOMAttribute(FIXConstants.FIX_FIELD_ID, null,
                        String.valueOf(field.getTag())));
                Object value = field.getObject();

                if (value instanceof byte[]) {
                    DataSource dataSource = new ByteArrayDataSource((byte[]) value);
                    DataHandler dataHandler = new DataHandler(dataSource);
                    String contentID = msgCtx.addAttachment(dataHandler);
                    OMElement binaryData = soapFactory.createOMElement(
                            FIXConstants.FIX_BINARY_FIELD, null);
                    String binaryCID = "cid:" + contentID;
View Full Code Here

                         createOMAttribute(FIXConstants.FIX_FIELD_ID, null,
                         String.valueOf(field.getTag())));
                 Object value = field.getObject();

                 if (value instanceof byte[]) {
                     DataSource dataSource = new ByteArrayDataSource((byte[]) value);
                     DataHandler dataHandler = new DataHandler(dataSource);
                     String contentID = msgCtx.addAttachment(dataHandler);
                     OMElement binaryData = soapFactory.createOMElement(
                             FIXConstants.FIX_BINARY_FIELD, null);
                     String binaryCID = "cid:" + contentID;
View Full Code Here

    private void performTestNewDataHandler(StandardTypesServiceClient serviceClient) throws IOException {
        DataHandler[] dha = new DataHandler[3];
        dha[0] = new DataHandler("Some data", "text/plain");
        dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
        dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));

        for (int i = 0; i < dha.length; ++i) {
            DataHandler actual = serviceClient.getNewDataHandlerForward(dha[i]);
            // Note: The DataHandler returned may use a different type of DataSource.
            // Compare the data content instead of using equals().
View Full Code Here

    private void performTestNewDataHandlerArray(StandardTypesServiceClient serviceClient) throws IOException {
        DataHandler[] dha = new DataHandler[3];
        dha[0] = new DataHandler("Some data", "text/plain");
        dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
        dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));

        DataHandler[] actual = serviceClient.getNewDataHandlerArrayForward(dha);
        Assert.assertEquals(dha.length, actual.length);
        for (int i = 0; i < dha.length; ++i) {
            // Note: The DataHandler returned may use a different type of DataSource.
View Full Code Here

        OMAttribute cType1 = new OMAttributeImpl("contentType", mime,
                "text/plain", fac);
        text.addAttribute(cType1);
        byte[] byteArray = new byte[]{13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
                                      98};
        dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
        OMTextImpl textData = new OMTextImpl(dataHandler, false, fac);

        envelope.addChild(body);
        body.addChild(data);
        data.addChild(text);
View Full Code Here

        String contentType = org.apache.axiom.om.impl.MIMEOutputUtils
        .getContentTypeForMime(boundary, omOutput.getRootContentId(),
            omOutput.getCharSetEncoding(),SOAP12Constants.SOAP_12_CONTENT_TYPE);
        DataHandler dataHandler;
        dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
        OMText textData = factory.createOMText(dataHandler, true);
        assertNotNull(textData.getContentID());

        DataHandler dataHandler2 = new DataHandler(
                "Apache Software Foundation", "text/plain");
View Full Code Here

import javax.activation.DataHandler;

public class DataHandlerUtils {

    public static Object getDataHandlerFromText(String value, String mimeType) {
        ByteArrayDataSource dataSource;
        byte[] data = Base64.decode(value);
        if (mimeType != null) {
            dataSource = new ByteArrayDataSource(data, mimeType);
        } else {
            // Assumes type as application/octet-stream
            dataSource = new ByteArrayDataSource(data);
        }
        return new DataHandler(dataSource);
    }
View Full Code Here

    private void performTestNewDataHandler(StandardTypesServiceClient serviceClient) throws IOException {
        DataHandler[] dha = new DataHandler[3];
        dha[0] = new DataHandler("Some data", "text/plain");
        dha[1] = new DataHandler(this.getClass().getClassLoader().getResource("standard-types-service.composite"));
        dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));

        for (int i = 0; i < dha.length; ++i) {
            DataHandler actual = serviceClient.getNewDataHandlerForward(dha[i]);
            // Note: The DataHandler returned may use a different type of DataSource.
            // Compare the data content instead of using equals().
View Full Code Here

TOP

Related Classes of org.apache.axiom.attachments.ByteArrayDataSource

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.