Example usage for com.google.gwt.user.server.rpc.impl ServerSerializationStreamWriterCopy_GWT16 serializeValue

List of usage examples for com.google.gwt.user.server.rpc.impl ServerSerializationStreamWriterCopy_GWT16 serializeValue

Introduction

In this page you can find the example usage for com.google.gwt.user.server.rpc.impl ServerSerializationStreamWriterCopy_GWT16 serializeValue.

Prototype

public void serializeValue(Object value, Class<?> type) throws SerializationException 

Source Link

Usage

From source file:us.gibb.dev.gwt.server.remote.RPCAppengine.java

License:Apache License

/**
 * Returns a string that encodes the results of an RPC call. Private overload
 * that takes a flag signaling the preamble of the response payload.
 * /*from  w  w w .  j  a  v  a 2 s .  c  o  m*/
 * @param object the object that we wish to send back to the client
 * @param wasThrown if true, the object being returned was an exception thrown
 *          by the service method; if false, it was the result of the service
 *          method's invocation
 * @return a string that encodes the response from a service method
 * @throws SerializationException if the object cannot be serialized
 */
private static String encodeResponse(Class<?> responseClass, Object object, boolean wasThrown,
        SerializationPolicy serializationPolicy) throws SerializationException {

    ServerSerializationStreamWriterCopy_GWT16 stream = new ServerSerializationStreamWriterCopy_GWT16(
            serializationPolicy);
    stream.prepareToWrite();
    if (responseClass != void.class) {
        stream.serializeValue(object, responseClass);
    }

    String bufferStr = (wasThrown ? "//EX" : "//OK") + stream.toString();
    return bufferStr;
}