Package pivot.serialization

Examples of pivot.serialization.BinarySerializer


import pivot.serialization.BinarySerializer;

public class BinarySerializerTest {

    public static void main(String[] args) {
        Serializer<Object> serializer = new BinarySerializer();

        Object[] testData = {
            "Hello World",
            123.456,
            true
        };

        ByteArrayOutputStream outputStream = null;
        try {
            try {
                outputStream = new ByteArrayOutputStream();
                serializer.writeObject(testData, outputStream);
            } finally {
                outputStream.close();
            }
        } catch(Exception exception) {
            System.out.println(exception);
        }

        ByteArrayInputStream inputStream = null;
        try {
            try {
                inputStream = new ByteArrayInputStream(outputStream.toByteArray());
                testData = (Object[])serializer.readObject(inputStream);

                for (int i = 0, n = testData.length; i < n; i++) {
                    System.out.println("[" + i + "] " + testData[i]);
                }
            } finally {
View Full Code Here


        final BasicAuthentication authentication = new BasicAuthentication("foo", "bar");

        // GET
        final GetQuery getQuery = new GetQuery(HOSTNAME, PORT, PATH, SECURE);
        getQuery.getArguments().put("a", "b");
        getQuery.setSerializer(new BinarySerializer());
        authentication.authenticate(getQuery);

        getQuery.execute(new TaskListener<Object>() {
            @SuppressWarnings("unchecked")
            public void taskExecuted(Task<Object> task) {
View Full Code Here

        map.put("pathInfo", pathInfo);
        map.put("queryString", queryString);

        response.setStatus(200);

        BinarySerializer serializer = new BinarySerializer();
        response.setContentType(serializer.getMIMEType(map));

        try {
            serializer.writeObject(map, response.getOutputStream());
        } catch(SerializationException exception) {
            throw new ServletException(exception);
        }
    }
View Full Code Here

        final BasicAuthentication authentication = new BasicAuthentication("foo", "bar");

        // GET
        final GetQuery getQuery = new GetQuery(HOSTNAME, PORT, PATH, SECURE);
        getQuery.getParameters().put("a", "b");
        getQuery.setSerializer(new BinarySerializer());
        getQuery.getRequestHeaders().add("bar", "hello");
        getQuery.getRequestHeaders().add("bar", "world");
        authentication.authenticate(getQuery);

        getQuery.execute(new TaskListener<Object>() {
View Full Code Here

        response.setStatus(200);
        response.setHeader("foo", "hello");
        response.addHeader("foo", "world");

        BinarySerializer serializer = new BinarySerializer();
        response.setContentType(serializer.getMIMEType(map));

        try {
            serializer.writeObject(map, response.getOutputStream());
        } catch(SerializationException exception) {
            throw new ServletException(exception);
        }
    }
View Full Code Here

TOP

Related Classes of pivot.serialization.BinarySerializer

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.