Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.collections
Class TKVSerializer

java.lang.Object
  extended by com.genesyslab.platform.commons.collections.TKVSerializer

public class TKVSerializer
extends java.lang.Object

This class contains methods to convert the list to/from its binary representation (in TKV binary format).


Constructor Summary
TKVSerializer()
           
 
Method Summary
static KeyValueCollection deserialize(byte[] bytes)
          Deprecated. use according method with additional encoding parameter
static KeyValueCollection deserialize(byte[] bytes, boolean getLen)
          Deprecated. use according method with additional encoding parameter
static KeyValueCollection deserialize(byte[] bytes, java.lang.String encoding)
          Unpacks TKV list from byte array.
static KeyValueCollection deserialize(byte[] bytes, java.lang.String encoding, boolean getLen)
          Unpacks TKV list from byte array.
static KeyValueCollection deserialize(byte[] bytes, java.lang.String encoding, int offset, int length, boolean readLen)
          Unpacks TKV list from byte array.
static KeyValueCollection deserialize(java.io.InputStream in)
          Reads packed TKV list from OutputStream and unpacks it.
static KeyValueCollection deserialize(java.io.InputStream in, java.lang.String encoding, boolean readLen)
          Reads packed TKV list from OutputStream and unpacks it.
static byte[] getBytes(KeyValueCollection list)
          Packs the list and returns it as byte array.
static byte[] getBytes(KVList list, boolean useUtfString, java.lang.String encoding)
          Packs the list and returns it as byte array.
static byte[] getBytes(KVList list, boolean useUtfString, java.lang.String encoding, boolean useLen)
          Packs the list and returns it as byte array.
static byte[] getBytes(KVList list, java.lang.String encoding)
          Deprecated.  
static byte[] getBytes(KVList list, java.lang.String encoding, boolean useLen)
          Deprecated.  
static void serialize(KVList list, java.io.OutputStream out)
          Packs the list and writes it to OutputStream.
static void serialize(KVList list, java.io.OutputStream out, java.lang.String encoding, boolean writeLen)
          Packs the list and writes it to OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TKVSerializer

public TKVSerializer()
Method Detail

deserialize

public static KeyValueCollection deserialize(java.io.InputStream in)
                                      throws java.io.IOException,
                                             DataFormatException
Reads packed TKV list from OutputStream and unpacks it. To create strings from bytes uses platform default encoding.

Parameters:
in - the stream to read list from
Returns:
the list
Throws:
java.io.IOException - if some IO problems occur
DataFormatException - if stream is invalid

deserialize

public static KeyValueCollection deserialize(java.io.InputStream in,
                                             java.lang.String encoding,
                                             boolean readLen)
                                      throws java.io.IOException,
                                             DataFormatException
Reads packed TKV list from OutputStream and unpacks it. To create strings from bytes uses supplied encoding. If encoding is null than default platform encoding will be used.

Parameters:
in - the stream to read list from
encoding - the encoding for byte to string conversion
readLen - if true - length bytes are expected
Returns:
the list
Throws:
java.io.IOException - if some IO problems occur
DataFormatException - if byte array is invalid

deserialize

@Deprecated
public static KeyValueCollection deserialize(byte[] bytes)
                                      throws DataFormatException
Deprecated. use according method with additional encoding parameter

Unpacks TKV list from byte array. To create strings from bytes uses supplied encoding. If encoding is null than default platform encoding will be used.

Parameters:
bytes - bytes to unpack list from
Returns:
the list
Throws:
DataFormatException - if byte array is invalid
See Also:
deserialize(byte[], String)

deserialize

@Deprecated
public static KeyValueCollection deserialize(byte[] bytes,
                                                        boolean getLen)
                                      throws DataFormatException
Deprecated. use according method with additional encoding parameter

Unpacks TKV list from byte array. To create strings from bytes uses supplied encoding. If encoding is null than default platform encoding will be used.

Parameters:
bytes - bytes to unpack list from
getLen - if true - length bytes are expected
Returns:
the list
Throws:
DataFormatException - if byte array is invalid
See Also:
deserialize(byte[], String, boolean)

deserialize

public static KeyValueCollection deserialize(byte[] bytes,
                                             java.lang.String encoding)
                                      throws DataFormatException,
                                             java.io.UnsupportedEncodingException
Unpacks TKV list from byte array. To create strings from bytes uses supplied encoding. If encoding is null than default platform encoding will be used.

Parameters:
bytes - bytes to unpack list from
encoding - the encoding for byte to string conversion
Returns:
the list
Throws:
DataFormatException - if byte array is invalid
java.io.UnsupportedEncodingException - if encoding is unsupported

deserialize

public static KeyValueCollection deserialize(byte[] bytes,
                                             java.lang.String encoding,
                                             boolean getLen)
                                      throws DataFormatException,
                                             java.io.UnsupportedEncodingException
Unpacks TKV list from byte array. To create strings from bytes uses supplied encoding. If encoding is null than default platform encoding will be used.

Parameters:
bytes - bytes to unpack list from
encoding - the encoding for byte to string conversion
getLen - if true - length bytes are expected
Returns:
the list
Throws:
DataFormatException - if byte array is invalid
java.io.UnsupportedEncodingException - if encoding is unsupported

deserialize

public static KeyValueCollection deserialize(byte[] bytes,
                                             java.lang.String encoding,
                                             int offset,
                                             int length,
                                             boolean readLen)
                                      throws DataFormatException,
                                             java.io.UnsupportedEncodingException
Unpacks TKV list from byte array. To create strings from bytes uses supplied encoding. If encoding is null than default platform encoding will be used.

Parameters:
bytes - bytes to unpack list from
encoding - the encoding for byte to string conversion
offset - offset in array to read from
length - number of bytes to read
readLen - if true - length bytes are expected
Returns:
the list
Throws:
DataFormatException - if byte array is invalid
java.io.UnsupportedEncodingException - if encoding is unsupported

serialize

public static void serialize(KVList list,
                             java.io.OutputStream out)
                      throws java.io.IOException
Packs the list and writes it to OutputStream. This method will use default encoding to convert strings to bytes

Parameters:
list - List to serialize
out - stream to write the list to
Throws:
java.io.IOException - if some IO problems occur

serialize

public static void serialize(KVList list,
                             java.io.OutputStream out,
                             java.lang.String encoding,
                             boolean writeLen)
                      throws java.io.IOException
Packs the list and writes it to OutputStream. To convert strings to bytes this method will use specified encoding. If encoding is null than default platform encoding will be used.

Parameters:
list - List to serialize
out - stream to write the list to
encoding - Encoding to convert strings
writeLen - if true - length bytes are written
Throws:
java.io.UnsupportedEncodingException - if encoding is unsupported
java.io.IOException - if some IO problems occur

getBytes

public static byte[] getBytes(KeyValueCollection list)
Packs the list and returns it as byte array. This method will use default encoding to convert strings to bytes

Parameters:
list - List to serialize
Returns:
packed list

getBytes

@Deprecated
public static byte[] getBytes(KVList list,
                                         java.lang.String encoding)
                       throws java.io.UnsupportedEncodingException
Deprecated. 

Packs the list and returns it as byte array. To convert strings to bytes this method will use specified encoding. If encoding is null than default platform encoding will be used.

Parameters:
list - List to serialize
encoding - Encoding to convert strings
Returns:
packed list
Throws:
java.io.UnsupportedEncodingException - if wrong encoding is specified

getBytes

@Deprecated
public static byte[] getBytes(KVList list,
                                         java.lang.String encoding,
                                         boolean useLen)
                       throws java.io.UnsupportedEncodingException
Deprecated. 

Packs the list and returns it as byte array. To convert strings to bytes this method will use specified encoding. If encoding is null than default platform encoding will be used.

Parameters:
list - List to serialize
encoding - Encoding to convert strings
useLen - if true - buffer contains length bytes for the list
Returns:
packed list
Throws:
java.io.UnsupportedEncodingException - if wrong encoding is specified

getBytes

public static byte[] getBytes(KVList list,
                              boolean useUtfString,
                              java.lang.String encoding,
                              boolean useLen)
                       throws java.io.UnsupportedEncodingException
Packs the list and returns it as byte array. To convert strings to bytes this method will use specified encoding. If encoding is null than default platform encoding will be used.

Parameters:
list - List to serialize
encoding - Encoding to convert strings
useLen - if true - buffer contains length bytes for the list
Returns:
packed list
Throws:
java.io.UnsupportedEncodingException - if wrong encoding is specified

getBytes

public static byte[] getBytes(KVList list,
                              boolean useUtfString,
                              java.lang.String encoding)
                       throws java.io.UnsupportedEncodingException
Packs the list and returns it as byte array. To convert strings to bytes this method will use specified encoding. If encoding is null than default platform encoding will be used.

Parameters:
list - List to serialize
encoding - Encoding to convert strings
useLen - if true - buffer contains length bytes for the list
Returns:
packed list
Throws:
java.io.UnsupportedEncodingException - if wrong encoding is specified

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.