Package org.apache.axiom.attachments

Examples of org.apache.axiom.attachments.ByteArrayDataSource


                    entry.addAttribute(TYPE, BYTE, attrNS);
                    entry.setText(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


    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

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

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

    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMDataSource ds = new WrappedTextNodeOMDataSourceFromDataSource(new QName("wrapper"),
                new ByteArrayDataSource("test".getBytes("utf-8")), Charset.forName("utf-8"));
        OMSourcedElement element = factory.createOMElement(ds);
        OMCloneOptions options = new OMCloneOptions();
        options.setCopyOMDataSources(copyOMDataSources);
        OMElement clone = (OMElement)element.clone(options);
        if (copyOMDataSources) {
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

    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

import org.apache.axiom.util.base64.Base64Utils;

public class DataHandlerUtils {

    public static Object getDataHandlerFromText(String value, String mimeType) {
        ByteArrayDataSource dataSource;
        byte[] data = Base64Utils.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

        return new HexBinary(s);
    }

    public static javax.activation.DataHandler convertToBase64Binary(String s) {
        // reusing the byteArrayDataSource from the Axiom classes
        ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(
                Base64.decode(s)
        );
        return new DataHandler(byteArrayDataSource);
    }
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.