Class JnaNativeHandle

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      long getAddress()
      The start address of the memory chunk
      byte getByte​(int index)
      Marshal the data at byte offset index from the start of the memory chunk to a byte.
      byte[] getByteArray​(int index, int count)
      Marshal the data at byte offset index from the start of the memory chunk to a byte array of length count.
      long getCLong​(int index)
      Marshal the data at byte offset index from the start of the memory chunk to a long.
      int getInt​(int index)
      Marshal the data at byte offset index from the start of the memory chunk to an int.
      long getLong​(int index)
      Marshal the data at byte offset index from the start of the memory chunk to a long value (which is always 8 byte).
      INativeHandle getNativeHandle​(int index)
      Marshal the data at byte offset index from the start of the memory chunk to an INativeHandle.
      com.sun.jna.Pointer getPointer()  
      short getShort​(int index)
      Marshal the data at byte offset index from the start of the memory chunk to a short.
      int getSize()
      The size for the handle in bytes.
      java.lang.String getString​(int index)
      Marshal the data at byte offset index from the start of the memory chunk to a String.
      java.lang.String getWideString​(int index)
      Marshal the data at byte offset index from the start of the memory chunk to a String using the platform wide character conversion.
      int hashCode()  
      INativeHandle offset​(int offset)
      Create a new INativeHandle, offset from this by offset bytes.
      void setByte​(int index, byte value)
      Write a byte to the memory at byte offset index from the start of the memory chunk.
      void setByteArray​(int index, byte[] value, int valueOffset, int valueCount)
      Write a byte array to the memory at byte offset index from the start of the memory chunk.
      void setCLong​(int index, long value)
      Write a long to the memory at byte offset index from the start of the memory chunk.
      void setInt​(int index, int value)
      Write an int to the memory at byte offset index from the start of the memory chunk.
      void setLong​(int index, long value)
      Write a long to the memory at byte offset index from the start of the memory chunk.
      void setNativeHandle​(int index, INativeHandle handle)
      Write an INativeHandle to the memory at byte offset index from the start of the memory chunk.
      void setShort​(int index, short value)
      Write a short to the memory at byte offset index from the start of the memory chunk.
      void setSize​(int pSize)
      Set the valid size for the handle to count bytes.
      void setString​(int index, java.lang.String value)
      Write a String to the memory at byte offset indexfrom the start of the memory chunk.
      void setWideString​(int index, java.lang.String value)
      Write a String to the memory at byte offset indexfrom the start of the memory chunk using the platform wide character conversion.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JnaNativeHandle

        public JnaNativeHandle​(JnaNativeHandle handle,
                               int offset)
      • JnaNativeHandle

        public JnaNativeHandle​(long address)
      • JnaNativeHandle

        public JnaNativeHandle​(com.sun.jna.Pointer pointer)
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getAddress

        public long getAddress()
        Description copied from interface: INativeHandle
        The start address of the memory chunk
        Specified by:
        getAddress in interface INativeHandle
        Returns:
        The start address of the memory chunk
      • getByte

        public byte getByte​(int index)
        Description copied from interface: INativeHandle
        Marshal the data at byte offset index from the start of the memory chunk to a byte.
        Specified by:
        getByte in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        Returns:
        A byte marshaled from the memory chunk
      • getByteArray

        public byte[] getByteArray​(int index,
                                   int count)
        Description copied from interface: INativeHandle
        Marshal the data at byte offset index from the start of the memory chunk to a byte array of length count.
        Specified by:
        getByteArray in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        count - The size of the byte array
        Returns:
        A byte array marshaled from the memory chunk
      • getCLong

        public long getCLong​(int index)
        Description copied from interface: INativeHandle
        Marshal the data at byte offset index from the start of the memory chunk to a long. Get only the "platform" number of bytes.
        Specified by:
        getCLong in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        Returns:
        A long marshaled from the memory chunk
      • getInt

        public int getInt​(int index)
        Description copied from interface: INativeHandle
        Marshal the data at byte offset index from the start of the memory chunk to an int.
        Specified by:
        getInt in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        Returns:
        An int marshaled from the memory chunk
      • getLong

        public long getLong​(int index)
        Description copied from interface: INativeHandle
        Marshal the data at byte offset index from the start of the memory chunk to a long value (which is always 8 byte).
        Specified by:
        getLong in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        Returns:
        A long marshaled from the memory chunk
      • getNativeHandle

        public INativeHandle getNativeHandle​(int index)
        Description copied from interface: INativeHandle
        Marshal the data at byte offset index from the start of the memory chunk to an INativeHandle.
        Specified by:
        getNativeHandle in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        Returns:
        An INativeHandle marshaled from the memory chunk
      • getPointer

        public com.sun.jna.Pointer getPointer()
      • getShort

        public short getShort​(int index)
        Description copied from interface: INativeHandle
        Marshal the data at byte offset index from the start of the memory chunk to a short.
        Specified by:
        getShort in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        Returns:
        A short marshaled from the memory chunk
      • getSize

        public int getSize()
        Description copied from interface: INativeHandle
        The size for the handle in bytes.

        You can not access bytes from outside the range defined by getAdddress + size.

        Specified by:
        getSize in interface INativeHandle
      • getString

        public java.lang.String getString​(int index)
        Description copied from interface: INativeHandle
        Marshal the data at byte offset index from the start of the memory chunk to a String.
        Specified by:
        getString in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        Returns:
        A String marshaled from the memory chunk
      • getWideString

        public java.lang.String getWideString​(int index)
        Description copied from interface: INativeHandle
        Marshal the data at byte offset index from the start of the memory chunk to a String using the platform wide character conversion.
        Specified by:
        getWideString in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        Returns:
        A String marshaled from the memory chunk
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • setByte

        public void setByte​(int index,
                            byte value)
        Description copied from interface: INativeHandle
        Write a byte to the memory at byte offset index from the start of the memory chunk.
        Specified by:
        setByte in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        value - The value to write.
      • setByteArray

        public void setByteArray​(int index,
                                 byte[] value,
                                 int valueOffset,
                                 int valueCount)
        Description copied from interface: INativeHandle
        Write a byte array to the memory at byte offset index from the start of the memory chunk. The method will write valueCount bytes from value starting at valueOffset.
        Specified by:
        setByteArray in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        value - The value to write.
      • setCLong

        public void setCLong​(int index,
                             long value)
        Description copied from interface: INativeHandle
        Write a long to the memory at byte offset index from the start of the memory chunk. Write only the "platform" number of bytes. The caller is responsible for observing the value range.
        Specified by:
        setCLong in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        value - The value to write.
      • setInt

        public void setInt​(int index,
                           int value)
        Description copied from interface: INativeHandle
        Write an int to the memory at byte offset index from the start of the memory chunk.
        Specified by:
        setInt in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        value - The value to write.
      • setLong

        public void setLong​(int index,
                            long value)
        Description copied from interface: INativeHandle
        Write a long to the memory at byte offset index from the start of the memory chunk.
        Specified by:
        setLong in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        value - The value to write.
      • setNativeHandle

        public void setNativeHandle​(int index,
                                    INativeHandle handle)
        Description copied from interface: INativeHandle
        Write an INativeHandle to the memory at byte offset index from the start of the memory chunk.
        Specified by:
        setNativeHandle in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
      • setShort

        public void setShort​(int index,
                             short value)
        Description copied from interface: INativeHandle
        Write a short to the memory at byte offset index from the start of the memory chunk.
        Specified by:
        setShort in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        value - The value to write.
      • setSize

        public void setSize​(int pSize)
        Description copied from interface: INativeHandle
        Set the valid size for the handle to count bytes.

        You can not access bytes from outside the range defined by getAdddress + size.

        Specified by:
        setSize in interface INativeHandle
        Parameters:
        pSize - The size of the memory managed by the INativeHandle
      • setString

        public void setString​(int index,
                              java.lang.String value)
        Description copied from interface: INativeHandle
        Write a String to the memory at byte offset indexfrom the start of the memory chunk.
        Specified by:
        setString in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        value - The value to write.
      • setWideString

        public void setWideString​(int index,
                                  java.lang.String value)
        Description copied from interface: INativeHandle
        Write a String to the memory at byte offset indexfrom the start of the memory chunk using the platform wide character conversion.
        Specified by:
        setWideString in interface INativeHandle
        Parameters:
        index - The byte offset from the start of the memory chunk
        value - The value to write.