@InterfaceAudience.Private @InterfaceStability.Evolving public final class UnsafeAccess extends Object
| Modifier and Type | Field and Description | 
|---|---|
| static long | BYTE_ARRAY_BASE_OFFSETThe offset to the first element in a byte array. | 
| static boolean | LITTLE_ENDIAN | 
| private static org.slf4j.Logger | LOG | 
| static sun.misc.Unsafe | theUnsafe | 
| (package private) static long | UNSAFE_COPY_THRESHOLD | 
| Modifier | Constructor and Description | 
|---|---|
| private  | UnsafeAccess() | 
| Modifier and Type | Method and Description | 
|---|---|
| static void | copy(byte[] src,
    int srcOffset,
    ByteBuffer dest,
    int destOffset,
    int length)Copies the bytes from given array's offset to length part into the given buffer. | 
| static void | copy(ByteBuffer src,
    int srcOffset,
    byte[] dest,
    int destOffset,
    int length)Copies specified number of bytes from given offset of  srcByteBuffer to thedestarray. | 
| static void | copy(ByteBuffer src,
    int srcOffset,
    ByteBuffer dest,
    int destOffset,
    int length)Copies specified number of bytes from given offset of  srcbuffer into thedestbuffer. | 
| (package private) static int | getAsInt(ByteBuffer buf,
        int offset)Reads bytes at the given offset as an int value. | 
| (package private) static long | getAsLong(ByteBuffer buf,
         int offset)Reads bytes at the given offset as a long value. | 
| (package private) static short | getAsShort(ByteBuffer buf,
          int offset)Reads bytes at the given offset as a short value. | 
| static int | putByte(ByteBuffer buf,
       int offset,
       byte b)Put a byte value out to the specified BB position in big-endian format. | 
| static int | putInt(byte[] bytes,
      int offset,
      int val)Put an int value out to the specified byte array position in big-endian format. | 
| static int | putInt(ByteBuffer buf,
      int offset,
      int val)Put an int value out to the specified ByteBuffer offset in big-endian format. | 
| static int | putLong(byte[] bytes,
       int offset,
       long val)Put a long value out to the specified byte array position in big-endian format. | 
| static int | putLong(ByteBuffer buf,
       int offset,
       long val)Put a long value out to the specified BB position in big-endian format. | 
| static int | putShort(byte[] bytes,
        int offset,
        short val)Put a short value out to the specified byte array position in big-endian format. | 
| static int | putShort(ByteBuffer buf,
        int offset,
        short val)Put a short value out to the specified BB position in big-endian format. | 
| static byte | toByte(ByteBuffer buf,
      int offset)Returns the byte at the given offset | 
| static byte | toByte(Object ref,
      long offset)Returns the byte at the given offset of the object | 
| static int | toInt(byte[] bytes,
     int offset)Converts a byte array to an int value considering it was written in big-endian format. | 
| static int | toInt(ByteBuffer buf,
     int offset)Reads an int value at the given buffer's offset considering it was written in big-endian
 format. | 
| static int | toInt(Object ref,
     long offset)Reads a int value at the given Object's offset considering it was written in big-endian
 format. | 
| static long | toLong(byte[] bytes,
      int offset)Converts a byte array to a long value considering it was written in big-endian format. | 
| static long | toLong(ByteBuffer buf,
      int offset)Reads a long value at the given buffer's offset considering it was written in big-endian
 format. | 
| static long | toLong(Object ref,
      long offset)Reads a long value at the given Object's offset considering it was written in big-endian
 format. | 
| static short | toShort(byte[] bytes,
       int offset)Converts a byte array to a short value considering it was written in big-endian format. | 
| static short | toShort(ByteBuffer buf,
       int offset)Reads a short value at the given buffer's offset considering it was written in big-endian
 format. | 
| static short | toShort(Object ref,
       long offset)Reads a short value at the given Object's offset considering it was written in big-endian
 format. | 
| private static void | unsafeCopy(Object src,
          long srcAddr,
          Object dst,
          long destAddr,
          long len) | 
private static final org.slf4j.Logger LOG
public static final sun.misc.Unsafe theUnsafe
public static final long BYTE_ARRAY_BASE_OFFSET
public static final boolean LITTLE_ENDIAN
static final long UNSAFE_COPY_THRESHOLD
private UnsafeAccess()
public static short toShort(byte[] bytes, int offset)
bytes - byte arrayoffset - offset into arraypublic static int toInt(byte[] bytes, int offset)
bytes - byte arrayoffset - offset into arraypublic static long toLong(byte[] bytes, int offset)
bytes - byte arrayoffset - offset into arraypublic static int putShort(byte[] bytes, int offset, short val)
bytes - the byte arrayoffset - position in the arrayval - short to write outpublic static int putInt(byte[] bytes, int offset, int val)
bytes - the byte arrayoffset - position in the arrayval - int to write outpublic static int putLong(byte[] bytes, int offset, long val)
bytes - the byte arrayoffset - position in the arrayval - long to write outpublic static short toShort(ByteBuffer buf, int offset)
buf - offset - public static short toShort(Object ref, long offset)
ref - offset - static short getAsShort(ByteBuffer buf, int offset)
buf - offset - public static int toInt(ByteBuffer buf, int offset)
buf - offset - public static int toInt(Object ref, long offset)
ref - offset - static int getAsInt(ByteBuffer buf, int offset)
buf - offset - public static long toLong(ByteBuffer buf, int offset)
buf - offset - public static long toLong(Object ref, long offset)
ref - offset - static long getAsLong(ByteBuffer buf, int offset)
buf - offset - public static int putInt(ByteBuffer buf, int offset, int val)
buf - the ByteBuffer to write tooffset - offset in the ByteBufferval - int to write outpublic static void copy(byte[] src, int srcOffset, ByteBuffer dest, int destOffset, int length)
src - srcOffset - dest - destOffset - length - private static void unsafeCopy(Object src, long srcAddr, Object dst, long destAddr, long len)
public static void copy(ByteBuffer src, int srcOffset, byte[] dest, int destOffset, int length)
src ByteBuffer to the
 dest array.src - srcOffset - dest - destOffset - length - public static void copy(ByteBuffer src, int srcOffset, ByteBuffer dest, int destOffset, int length)
src buffer into the dest
 buffer.src - srcOffset - dest - destOffset - length - public static int putShort(ByteBuffer buf, int offset, short val)
buf - the byte bufferoffset - position in the bufferval - short to write outpublic static int putLong(ByteBuffer buf, int offset, long val)
buf - the byte bufferoffset - position in the bufferval - long to write outpublic static int putByte(ByteBuffer buf, int offset, byte b)
buf - the byte bufferoffset - position in the bufferb - byte to write outpublic static byte toByte(ByteBuffer buf, int offset)
buf - the buffer to readoffset - the offset at which the byte has to be readCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.