Overview | Package | Class | Tree | Deprecated | Index | Help
| SMILA API documentation
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.smila.datamodel.ipc
Class IpcSerializationUtils

    java.lang.Object
      org.eclipse.smila.datamodel.ipc.IpcSerializationUtils

    public class IpcSerializationUtils

extends java.lang.Object

Utility class for converting record objects to binary (BON) and json objects and vice versa. Note that the record Id is NOT part of the BON representation by design.

Author:
  stuc07

Field Summary
`static java.lang.String` | `ENCODING` Encoding to use for String (de)serialization.

Constructor Summary
`IpcSerializationUtils()` create instance with (JSON) pretty-printing enabled.
`IpcSerializationUtils(boolean printPretty)` create instance with (JSON) printing as specified.

Method Summary
`byte[]` | `any2BinaryObject(Any object)` Convert an Any object to a byte array.
`void` | `any2BinaryStream(java.io.OutputStream stream, Any object)` Writes an Any object to a stream as BON.
`void` | `any2JsonStream(java.io.OutputStream stream, Any object)` Converts Any object to JSON stream.
`void` | `any2Stream(IpcStreamWriter writer, Any object)` Converts Any object to IPC stream.
`Any` | `binaryObject2any(byte[] binaryObject)` Converts binary (BON) object to record object.
`Record` | `binaryObject2record(byte[] binaryObject)` Converts binary (BON) object to record object.
`Any` | `binaryStream2any(java.io.InputStream stream)` Converts binary (BON) stream to record object.
`Record` | `binaryStream2record(java.io.InputStream stream)` Converts binary (BON) stream to record object.
`IpcFactory` | `getBinaryFactory()`
`IpcFactory` | `getJsonFactory()`
`Record` | `jsonObject2record(java.lang.String jsonString)` Converts JSON string to record object.
`Any` | `jsonStream2any(java.io.InputStream stream)` Converts JSON stream to Any object.
`Record` | `jsonStream2record(java.io.InputStream stream)` Converts JSON stream to record object.
`java.lang.String` | `map2JsonObject(AnyMap object)` Converts AnyMap object to JSON object.
`void` | `map2JsonStream(java.io.OutputStream stream, AnyMap object)` Converts AnyMap object to JSON stream.
`byte[]` | `record2BinaryObject(Record record)` Converts record object to binary (BON) object.
`void` | `record2BinaryStream(java.io.OutputStream stream, Record record)` Converts record object to binary (BON) stream.
`java.lang.String` | `record2JsonObject(Record record)` Converts record object to JSON object.
`void` | `record2JsonStream(java.io.OutputStream stream, Record record)` Converts record object to JSON stream.
`void` | `record2Stream(IpcStreamWriter writer, Record record)` Converts record object to stream.
`Any` | `stream2any(IpcStreamReader reader)` Converts stream to record object.
`Record` | `stream2record(IpcStreamReader reader)` Converts stream to record object.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ENCODING

    public static final java.lang.String ENCODING

  Encoding to use for String (de)serialization.

  See Also:
    Constant Field Values

Constructor Detail

### IpcSerializationUtils

    public IpcSerializationUtils()

  create instance with (JSON) pretty-printing enabled.

### IpcSerializationUtils

    public IpcSerializationUtils(boolean printPretty)

  create instance with (JSON) printing as specified.

Method Detail

### getBinaryFactory

    public IpcFactory getBinaryFactory()

  Returns:
    BON reader/writer factory.

### binaryObject2record

    public Record binaryObject2record(byte[] binaryObject)
                               throws java.io.IOException

  Converts binary (BON) object to record object.

  Parameters:
    `binaryObject` - input object
  Returns:
    record object
  Throws:
    `java.io.IOException` - in case of conversion error

### binaryStream2record

    public Record binaryStream2record(java.io.InputStream stream)
                               throws java.io.IOException

  Converts binary (BON) stream to record object.

  Parameters:
    `stream` - an input stream
  Returns:
    a record with no Id set
  Throws:
    `java.io.IOException` - in case of conversion error

### binaryObject2any

    public Any binaryObject2any(byte[] binaryObject)
                         throws java.io.IOException

  Converts binary (BON) object to record object.

  Parameters:
    `binaryObject` - input object
  Returns:
    record object
  Throws:
    `java.io.IOException` - in case of conversion error

### binaryStream2any

    public Any binaryStream2any(java.io.InputStream stream)
                         throws java.io.IOException

  Converts binary (BON) stream to record object.

  Parameters:
    `stream` - an input stream
  Returns:
    a record with no Id set
  Throws:
    `java.io.IOException` - in case of conversion error

### record2BinaryObject

    public byte[] record2BinaryObject(Record record)
                               throws java.io.IOException

  Converts record object to binary (BON) object.

  Parameters:
    `record` - input record
  Returns:
    byte array representing the binary object.
  Throws:
    `java.io.IOException` - in case of conversion error

### record2BinaryStream

    public void record2BinaryStream(java.io.OutputStream stream,
                                    Record record)
                             throws java.io.IOException

  Converts record object to binary (BON) stream.

  Parameters:
    `stream` - output stream
    `record` - input record
  Throws:
    `java.io.IOException` - in case of conversion error

### any2BinaryStream

    public void any2BinaryStream(java.io.OutputStream stream,
                                 Any object)
                          throws java.io.IOException

  Writes an Any object to a stream as BON.

  Parameters:
    `stream` - output stream
    `object` - input object
  Throws:
    `java.io.IOException` - in case of conversion error

### any2BinaryObject

    public byte[] any2BinaryObject(Any object)
                            throws java.io.IOException

  Convert an Any object to a byte array.

  Parameters:
    `object` - input object
  Throws:
    `java.io.IOException` - in case of conversion error

### getJsonFactory

    public IpcFactory getJsonFactory()

### jsonObject2record

    public Record jsonObject2record(java.lang.String jsonString)
                             throws java.io.IOException

  Converts JSON string to record object.

  Parameters:
    `jsonString` - input object
  Returns:
    record object
  Throws:
    `java.io.IOException` - in case of conversion error

### jsonStream2record

    public Record jsonStream2record(java.io.InputStream stream)
                             throws java.io.IOException

  Converts JSON stream to record object.

  Parameters:
    `stream` - an input stream
  Returns:
    a record with no Id set
  Throws:
    `java.io.IOException` - in case of conversion error

### jsonStream2any

    public Any jsonStream2any(java.io.InputStream stream)
                       throws java.io.IOException

  Converts JSON stream to Any object.

  Parameters:
    `stream` - an input stream
  Returns:
    a record with no Id set
  Throws:
    `java.io.IOException` - in case of conversion error

### stream2record

    public Record stream2record(IpcStreamReader reader)
                         throws java.io.IOException

  Converts stream to record object.

  Parameters:
    `reader` - an ipc reader (binary/json)
  Returns:
    record parsed from stream, or null if end-of-stream reached.
  Throws:
    `java.io.IOException` - IO errors from underlying stream.
    `java.lang.IllegalStateException` - parse errors.

### stream2any

    public Any stream2any(IpcStreamReader reader)
                   throws java.io.IOException

  Converts stream to record object.

  Parameters:
    `reader` - an ipc reader (binary/json)
  Returns:
    an Any, or null if end-of-stream reached.
  Throws:
    `java.io.IOException` - in case of conversion error

### record2JsonObject

    public java.lang.String record2JsonObject(Record record)
                                       throws java.io.IOException

  Converts record object to JSON object.

  Parameters:
    `record` - input record
  Returns:
    JSON string representing the record.
  Throws:
    `java.io.IOException` - in case of conversion error

### record2JsonStream

    public void record2JsonStream(java.io.OutputStream stream,
                                  Record record)
                           throws java.io.IOException

  Converts record object to JSON stream.

  Parameters:
    `stream` - output stream
    `record` - input record
  Throws:
    `java.io.IOException` - in case of conversion error

### map2JsonStream

    public void map2JsonStream(java.io.OutputStream stream,
                               AnyMap object)
                        throws java.io.IOException

  Converts AnyMap object to JSON stream.

  Parameters:
    `stream` - output stream
    `object` - input record
  Throws:
    `java.io.IOException` - in case of conversion error

### map2JsonObject

    public java.lang.String map2JsonObject(AnyMap object)
                                    throws java.io.IOException

  Converts AnyMap object to JSON object.

  Parameters:
    `object` - an AnyMap object
  Returns:
    JSON string representing the input object.
  Throws:
    `java.io.IOException` - in case of conversion error

### any2JsonStream

    public void any2JsonStream(java.io.OutputStream stream,
                               Any object)
                        throws java.io.IOException

  Converts Any object to JSON stream.

  Parameters:
    `stream` - output stream
    `object` - input object
  Throws:
    `java.io.IOException` - in case of conversion error

### any2Stream

    public void any2Stream(IpcStreamWriter writer,
                           Any object)
                    throws java.io.IOException

  Converts Any object to IPC stream.

  Parameters:
    `writer` - an IPC writer
    `object` - input object
  Throws:
    `java.io.IOException` - in case of conversion error

### record2Stream

    public void record2Stream(IpcStreamWriter writer,
                              Record record)
                       throws java.io.IOException

  Converts record object to stream.

  Parameters:
    `writer` - an ipc stream writer (bon/json)
    `record` - input record
  Throws:
    `java.io.IOException` - in case of conversion error

Overview | Package | Class | Tree | Deprecated | Index | Help
| SMILA API documentation
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD