org.hibernate.search.backend.jgroups.impl

## Class MessageSerializationHelper

- java.lang.Object
- - org.hibernate.search.backend.jgroups.impl.MessageSerializationHelper

-     public final class MessageSerializationHelper
      extends Object

  While we use the configured LuceneWorkSerializer to serialize the Work queue, the JGroups backend needs to prefix the stream with the index name.
  Author:
    Sanne Grinovero (C) 2012 Red Hat Inc.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `extractIndexName(int startingOffset, byte[] rawBuffer)` Extracts the string only from the header of a byte array.
    `static byte[]` | `extractSerializedQueue(int startingOffset, int bufferLength, byte[] rawBuffer)` Inverse operation of `prependString(String, byte[])`: extracts the original buffer discarding the prefixed string.
    `static int` | `fromByteToInt(byte b)`
    `static byte` | `fromIntToByte(int i)`
    `static byte[]` | `prependString(String name, byte[] data)` Byte encodes a String as a prefix for an existing byte buffer

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### prependString

          public static byte[] prependString(String name,
                                             byte[] data)

      Byte encodes a String as a prefix for an existing byte buffer
      Parameters:
        `name` - the string to encode
        `data` - the existing buffer
      Returns:
        a new buffer containing the length of the string buffer, the string buffer and then the data.

    - #### extractIndexName

          public static String extractIndexName(int startingOffset,
                                                byte[] rawBuffer)

      Extracts the string only from the header of a byte array. Is the reverse operation of `prependString(String, byte[])` The buffer is not altered.
      Parameters:
        `startingOffset` - the starting offset of our message in the larger network buffer
        `rawBuffer` - an array of byte.
      Returns:
        the String, assuming it's encoded by this same class.

    - #### extractSerializedQueue

          public static byte[] extractSerializedQueue(int startingOffset,
                                                      int bufferLength,
                                                      byte[] rawBuffer)

      Inverse operation of `prependString(String, byte[])`: extracts the original buffer discarding the prefixed string. The buffer is not altered.
      Parameters:
        `startingOffset` - the starting offset of our message in the larger network buffer
        `bufferLength` - we won't attempt to access the buffer beyond this index
        `rawBuffer` - an array of byte.
      Returns:
        the smaller byte buffer

    - #### fromByteToInt

          public static int fromByteToInt(byte b)

    - #### fromIntToByte

          public static byte fromIntToByte(int i)

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved