org.apache.blur.thirdparty.thrift_0_9_0
Class TSerializer

java.lang.Object
  extended by org.apache.blur.thirdparty.thrift_0_9_0.TSerializer

public class TSerializer
extends Object

Generic utility for easily serializing objects into a byte array or Java String.


Constructor Summary
TSerializer()
          Create a new TSerializer that uses the TBinaryProtocol by default.
TSerializer(TProtocolFactory protocolFactory)
          Create a new TSerializer.
 
Method Summary
 byte[] serialize(TBase base)
          Serialize the Thrift object into a byte array.
 String toString(TBase base)
          Serialize the Thrift object into a Java string, using the default JVM charset encoding.
 String toString(TBase base, String charset)
          Serialize the Thrift object into a Java string, using a specified character set for encoding.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TSerializer

public TSerializer()
Create a new TSerializer that uses the TBinaryProtocol by default.


TSerializer

public TSerializer(TProtocolFactory protocolFactory)
Create a new TSerializer. It will use the TProtocol specified by the factory that is passed in.

Parameters:
protocolFactory - Factory to create a protocol
Method Detail

serialize

public byte[] serialize(TBase base)
                 throws TException
Serialize the Thrift object into a byte array. The process is simple, just clear the byte array output, write the object into it, and grab the raw bytes.

Parameters:
base - The object to serialize
Returns:
Serialized object in byte[] format
Throws:
TException

toString

public String toString(TBase base,
                       String charset)
                throws TException
Serialize the Thrift object into a Java string, using a specified character set for encoding.

Parameters:
base - The object to serialize
charset - Valid JVM charset
Returns:
Serialized object as a String
Throws:
TException

toString

public String toString(TBase base)
                throws TException
Serialize the Thrift object into a Java string, using the default JVM charset encoding.

Parameters:
base - The object to serialize
Returns:
Serialized object as a String
Throws:
TException


Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.