org.hibernate.search.backend.impl.jgroups
Class MessageSerializationHelper

java.lang.Object
  extended by org.hibernate.search.backend.impl.jgroups.MessageSerializationHelper

public 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.

Constructor Summary
MessageSerializationHelper()
           
 
Method Summary
static String extractIndexName(byte[] rawBuffer)
          Extracts the string only from the header of a byte array.
static byte[] extractSerializedQueue(byte[] rawBuffer)
          Inverse operation of {@link #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
 

Constructor Detail

MessageSerializationHelper

public MessageSerializationHelper()
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(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:
rawBuffer -
Returns:
the String, assuming it's encoded by this same class.

extractSerializedQueue

public static byte[] extractSerializedQueue(byte[] rawBuffer)
Inverse operation of {@link #prependString(String, byte[]): extracts the original buffer discarding the prefixed string. The buffer is not altered.

Parameters:
rawBuffer -
Returns:
the smaller byte buffer

fromByteToInt

public static int fromByteToInt(byte b)

fromIntToByte

public static byte fromIntToByte(int i)


Copyright © 2006-2012 Red Hat Middleware, LLC. All Rights Reserved