Class BufferUtil

java.lang.Object
io.camunda.zeebe.util.buffer.BufferUtil

public final class BufferUtil extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
     
    static byte[]
    bufferAsArray(org.agrona.DirectBuffer buffer)
     
    static String
    bufferAsHexString(org.agrona.DirectBuffer buffer)
     
    static String
    bufferAsString(org.agrona.DirectBuffer buffer)
     
    static String
    bufferAsString(org.agrona.DirectBuffer buffer, int offset, int length)
     
    static String
    bytesAsHexString(byte[] bytes)
     
    static String
    bytesAsHexString(byte[] bytes, int wrap)
     
    static org.agrona.DirectBuffer
    cloneBuffer(org.agrona.DirectBuffer src)
    Creates a new instance of the src buffer class and copies the underlying bytes.
    static org.agrona.DirectBuffer
    cloneBuffer(org.agrona.DirectBuffer src, int offset, int length)
    Creates a new instance of the src buffer class and copies the underlying bytes.
    static boolean
    contentsEqual(org.agrona.DirectBuffer buffer1, org.agrona.DirectBuffer buffer2)
    byte-by-byte comparison of two buffers
    static void
    Copies the contents of the source writer into the destination reader via a fresh intermediate buffer.
    static org.agrona.DirectBuffer
     
    static boolean
    equals(org.agrona.DirectBuffer buffer1, org.agrona.DirectBuffer buffer2)
    Compare the given buffers.
    static boolean
    startsWith(byte[] prefix, int prefixOffset, int prefixLength, byte[] content, int contentOffset, int contentLength)
    Performs byte wise comparison of a given byte array and a prefix.
    static org.agrona.MutableDirectBuffer
    wrapArray(byte[] array)
     
    static org.agrona.DirectBuffer
    wrapString(String argument)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • bufferAsString

      public static String bufferAsString(org.agrona.DirectBuffer buffer)
    • bufferAsString

      public static String bufferAsString(org.agrona.DirectBuffer buffer, int offset, int length)
    • wrapString

      public static org.agrona.DirectBuffer wrapString(String argument)
    • equals

      public static boolean equals(org.agrona.DirectBuffer buffer1, org.agrona.DirectBuffer buffer2)
      Compare the given buffers.
    • contentsEqual

      public static boolean contentsEqual(org.agrona.DirectBuffer buffer1, org.agrona.DirectBuffer buffer2)
      byte-by-byte comparison of two buffers
    • createCopy

      public static org.agrona.DirectBuffer createCopy(BufferWriter writer)
    • copy

      public static void copy(BufferWriter source, BufferReader dest)
      Copies the contents of the source writer into the destination reader via a fresh intermediate buffer.
      Parameters:
      source - the buffer to copy from
      dest - the buffer to write to
    • cloneBuffer

      public static org.agrona.DirectBuffer cloneBuffer(org.agrona.DirectBuffer src)
      Creates a new instance of the src buffer class and copies the underlying bytes.
      Parameters:
      src - the buffer to copy from
      Returns:
      the new buffer instance
    • cloneBuffer

      public static org.agrona.DirectBuffer cloneBuffer(org.agrona.DirectBuffer src, int offset, int length)
      Creates a new instance of the src buffer class and copies the underlying bytes.
      Parameters:
      src - the buffer to copy from
      offset - the offset to start in the src buffer
      length - the number of bytes to clone
      Returns:
      the new buffer instance
    • bufferAsHexString

      public static String bufferAsHexString(org.agrona.DirectBuffer buffer)
    • bytesAsHexString

      public static String bytesAsHexString(byte[] bytes)
    • bytesAsHexString

      public static String bytesAsHexString(byte[] bytes, int wrap)
    • bufferAsArray

      public static byte[] bufferAsArray(org.agrona.DirectBuffer buffer)
      Returns:
      a new array that is a copy of the buffer's contents
    • bufferAsArray

      public static byte[] bufferAsArray(BufferWriter buffer)
    • wrapArray

      public static org.agrona.MutableDirectBuffer wrapArray(byte[] array)
    • startsWith

      public static boolean startsWith(byte[] prefix, int prefixOffset, int prefixLength, byte[] content, int contentOffset, int contentLength)
      Performs byte wise comparison of a given byte array and a prefix.
      Parameters:
      prefix - the prefix to look for
      prefixOffset - offset in the prefix array
      prefixLength - length of the prefix
      content - the array to check against
      contentOffset - the offset in the content array
      contentLength - the length of the content to check
      Returns:
      true if array starts with the all bytes contained in prefix