Package org.lwjgl

Class MemoryUtil


  • public final class MemoryUtil
    extends java.lang.Object
    [INTERNAL USE ONLY]

    This class provides utility methods for passing buffers to JNI API calls.

    Author:
    Spasi
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String decodeASCII​(java.nio.ByteBuffer buffer)  
      static java.lang.String decodeUTF16​(java.nio.ByteBuffer buffer)  
      static java.lang.String decodeUTF8​(java.nio.ByteBuffer buffer)  
      static java.nio.ByteBuffer encodeASCII​(java.lang.CharSequence text)
      Returns a ByteBuffer containing the specified text ASCII encoded and null-terminated.
      static java.nio.ByteBuffer encodeUTF16​(java.lang.CharSequence text)
      Returns a ByteBuffer containing the specified text UTF-16LE encoded and null-terminated.
      static java.nio.ByteBuffer encodeUTF8​(java.lang.CharSequence text)
      Returns a ByteBuffer containing the specified text UTF-8 encoded and null-terminated.
      static long getAddress​(java.nio.ByteBuffer buffer)  
      static long getAddress​(java.nio.ByteBuffer buffer, int position)  
      static long getAddress​(java.nio.CharBuffer buffer)  
      static long getAddress​(java.nio.CharBuffer buffer, int position)  
      static long getAddress​(java.nio.DoubleBuffer buffer)  
      static long getAddress​(java.nio.DoubleBuffer buffer, int position)  
      static long getAddress​(java.nio.FloatBuffer buffer)  
      static long getAddress​(java.nio.FloatBuffer buffer, int position)  
      static long getAddress​(java.nio.IntBuffer buffer)  
      static long getAddress​(java.nio.IntBuffer buffer, int position)  
      static long getAddress​(java.nio.LongBuffer buffer)  
      static long getAddress​(java.nio.LongBuffer buffer, int position)  
      static long getAddress​(java.nio.ShortBuffer buffer)  
      static long getAddress​(java.nio.ShortBuffer buffer, int position)  
      static long getAddress​(PointerBuffer buffer)  
      static long getAddress​(PointerBuffer buffer, int position)  
      static long getAddress0​(java.nio.Buffer buffer)
      Returns the memory address of the specified buffer.
      static long getAddress0​(PointerBuffer buffer)  
      static long getAddress0Safe​(java.nio.Buffer buffer)  
      static long getAddress0Safe​(PointerBuffer buffer)  
      static long getAddressSafe​(java.nio.ByteBuffer buffer)  
      static long getAddressSafe​(java.nio.ByteBuffer buffer, int position)  
      static long getAddressSafe​(java.nio.CharBuffer buffer)  
      static long getAddressSafe​(java.nio.CharBuffer buffer, int position)  
      static long getAddressSafe​(java.nio.DoubleBuffer buffer)  
      static long getAddressSafe​(java.nio.DoubleBuffer buffer, int position)  
      static long getAddressSafe​(java.nio.FloatBuffer buffer)  
      static long getAddressSafe​(java.nio.FloatBuffer buffer, int position)  
      static long getAddressSafe​(java.nio.IntBuffer buffer)  
      static long getAddressSafe​(java.nio.IntBuffer buffer, int position)  
      static long getAddressSafe​(java.nio.LongBuffer buffer)  
      static long getAddressSafe​(java.nio.LongBuffer buffer, int position)  
      static long getAddressSafe​(java.nio.ShortBuffer buffer)  
      static long getAddressSafe​(java.nio.ShortBuffer buffer, int position)  
      static long getAddressSafe​(PointerBuffer buffer)  
      static long getAddressSafe​(PointerBuffer buffer, int position)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getAddress0

        public static long getAddress0​(java.nio.Buffer buffer)
        Returns the memory address of the specified buffer. [INTERNAL USE ONLY]
        Parameters:
        buffer - the buffer
        Returns:
        the memory address
      • getAddress0Safe

        public static long getAddress0Safe​(java.nio.Buffer buffer)
      • getAddress0

        public static long getAddress0​(PointerBuffer buffer)
      • getAddress0Safe

        public static long getAddress0Safe​(PointerBuffer buffer)
      • getAddress

        public static long getAddress​(java.nio.ByteBuffer buffer)
      • getAddress

        public static long getAddress​(java.nio.ByteBuffer buffer,
                                      int position)
      • getAddress

        public static long getAddress​(java.nio.ShortBuffer buffer)
      • getAddress

        public static long getAddress​(java.nio.ShortBuffer buffer,
                                      int position)
      • getAddress

        public static long getAddress​(java.nio.CharBuffer buffer)
      • getAddress

        public static long getAddress​(java.nio.CharBuffer buffer,
                                      int position)
      • getAddress

        public static long getAddress​(java.nio.IntBuffer buffer)
      • getAddress

        public static long getAddress​(java.nio.IntBuffer buffer,
                                      int position)
      • getAddress

        public static long getAddress​(java.nio.FloatBuffer buffer)
      • getAddress

        public static long getAddress​(java.nio.FloatBuffer buffer,
                                      int position)
      • getAddress

        public static long getAddress​(java.nio.LongBuffer buffer)
      • getAddress

        public static long getAddress​(java.nio.LongBuffer buffer,
                                      int position)
      • getAddress

        public static long getAddress​(java.nio.DoubleBuffer buffer)
      • getAddress

        public static long getAddress​(java.nio.DoubleBuffer buffer,
                                      int position)
      • getAddress

        public static long getAddress​(PointerBuffer buffer)
      • getAddress

        public static long getAddress​(PointerBuffer buffer,
                                      int position)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.ByteBuffer buffer)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.ByteBuffer buffer,
                                          int position)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.ShortBuffer buffer)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.ShortBuffer buffer,
                                          int position)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.CharBuffer buffer)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.CharBuffer buffer,
                                          int position)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.IntBuffer buffer)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.IntBuffer buffer,
                                          int position)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.FloatBuffer buffer)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.FloatBuffer buffer,
                                          int position)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.LongBuffer buffer)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.LongBuffer buffer,
                                          int position)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.DoubleBuffer buffer)
      • getAddressSafe

        public static long getAddressSafe​(java.nio.DoubleBuffer buffer,
                                          int position)
      • getAddressSafe

        public static long getAddressSafe​(PointerBuffer buffer)
      • getAddressSafe

        public static long getAddressSafe​(PointerBuffer buffer,
                                          int position)
      • encodeASCII

        public static java.nio.ByteBuffer encodeASCII​(java.lang.CharSequence text)
        Returns a ByteBuffer containing the specified text ASCII encoded and null-terminated. If text is null, null is returned.
        Parameters:
        text - the text to encode
        Returns:
        the encoded text or null
        See Also:
        String.getBytes()
      • encodeUTF8

        public static java.nio.ByteBuffer encodeUTF8​(java.lang.CharSequence text)
        Returns a ByteBuffer containing the specified text UTF-8 encoded and null-terminated. If text is null, null is returned.
        Parameters:
        text - the text to encode
        Returns:
        the encoded text or null
        See Also:
        String.getBytes()
      • encodeUTF16

        public static java.nio.ByteBuffer encodeUTF16​(java.lang.CharSequence text)
        Returns a ByteBuffer containing the specified text UTF-16LE encoded and null-terminated. If text is null, null is returned.
        Parameters:
        text - the text to encode
        Returns:
        the encoded text
      • decodeASCII

        public static java.lang.String decodeASCII​(java.nio.ByteBuffer buffer)
      • decodeUTF8

        public static java.lang.String decodeUTF8​(java.nio.ByteBuffer buffer)
      • decodeUTF16

        public static java.lang.String decodeUTF16​(java.nio.ByteBuffer buffer)