Interface INativeHandle

All Known Implementing Classes:
JnaNativeHandle

public interface INativeHandle
A "handle" to a piece of memory (in c space).

The handle combines an address and a memory chunk of a specified size.

  • Method Summary

    Modifier and Type
    Method
    Description
    long
    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).
    getNativeHandle(int index)
    Marshal the data at byte offset index from the start of the memory chunk to an INativeHandle.
    short
    getShort(int index)
    Marshal the data at byte offset index from the start of the memory chunk to a short.
    int
    The size for the handle in bytes.
    getString(int index)
    Marshal the data at byte offset index from the start of the memory chunk to a 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.
    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 valueHandle)
    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 count)
    Set the valid size for the handle to count bytes.
    void
    setString(int index, String value)
    Write a String to the memory at byte offset indexfrom the start of the memory chunk.
    void
    setWideString(int index, String value)
    Write a String to the memory at byte offset indexfrom the start of the memory chunk using the platform wide character conversion.
  • Method Details

    • getAddress

      long getAddress()
      The start address of the memory chunk
      Returns:
      The start address of the memory chunk
    • getByte

      byte getByte(int index)
      Marshal the data at byte offset index from the start of the memory chunk to a byte.
      Parameters:
      index - The byte offset from the start of the memory chunk
      Returns:
      A byte marshaled from the memory chunk
    • getByteArray

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

      long getCLong(int index)
      Marshal the data at byte offset index from the start of the memory chunk to a long. Get only the "platform" number of bytes.
      Parameters:
      index - The byte offset from the start of the memory chunk
      Returns:
      A long marshaled from the memory chunk
    • getInt

      int getInt(int index)
      Marshal the data at byte offset index from the start of the memory chunk to an int.
      Parameters:
      index - The byte offset from the start of the memory chunk
      Returns:
      An int marshaled from the memory chunk
    • getLong

      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).
      Parameters:
      index - The byte offset from the start of the memory chunk
      Returns:
      A long marshaled from the memory chunk
    • getNativeHandle

      INativeHandle getNativeHandle(int index)
      Marshal the data at byte offset index from the start of the memory chunk to an INativeHandle.
      Parameters:
      index - The byte offset from the start of the memory chunk
      Returns:
      An INativeHandle marshaled from the memory chunk
    • getShort

      short getShort(int index)
      Marshal the data at byte offset index from the start of the memory chunk to a short.
      Parameters:
      index - The byte offset from the start of the memory chunk
      Returns:
      A short marshaled from the memory chunk
    • getSize

      int getSize()
      The size for the handle in bytes.

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

    • getString

      String getString(int index)
      Marshal the data at byte offset index from the start of the memory chunk to a String.
      Parameters:
      index - The byte offset from the start of the memory chunk
      Returns:
      A String marshaled from the memory chunk
    • getWideString

      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.
      Parameters:
      index - The byte offset from the start of the memory chunk
      Returns:
      A String marshaled from the memory chunk
    • offset

      INativeHandle offset(int offset)
      Create a new INativeHandle, offset from this by offset bytes.
      Parameters:
      offset - The byte offset from the start of the memory chunk
      Returns:
      A new INativeHandle pointing to "getAddress() + offset".
    • setByte

      void setByte(int index, byte value)
      Write a byte to the memory at byte offset index from the start of the memory chunk.
      Parameters:
      index - The byte offset from the start of the memory chunk
      value - The value to write.
    • setByteArray

      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. The method will write valueCount bytes from value starting at valueOffset.
      Parameters:
      index - The byte offset from the start of the memory chunk
      value - The value to write.
    • setCLong

      void setCLong(int index, long value)
      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.
      Parameters:
      index - The byte offset from the start of the memory chunk
      value - The value to write.
    • setInt

      void setInt(int index, int value)
      Write an int to the memory at byte offset index from the start of the memory chunk.
      Parameters:
      index - The byte offset from the start of the memory chunk
      value - The value to write.
    • setLong

      void setLong(int index, long value)
      Write a long to the memory at byte offset index from the start of the memory chunk.
      Parameters:
      index - The byte offset from the start of the memory chunk
      value - The value to write.
    • setNativeHandle

      void setNativeHandle(int index, INativeHandle valueHandle)
      Write an INativeHandle to the memory at byte offset index from the start of the memory chunk.
      Parameters:
      index - The byte offset from the start of the memory chunk
      valueHandle - The value to write.
    • setShort

      void setShort(int index, short value)
      Write a short to the memory at byte offset index from the start of the memory chunk.
      Parameters:
      index - The byte offset from the start of the memory chunk
      value - The value to write.
    • setSize

      void setSize(int count)
      Set the valid size for the handle to count bytes.

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

      Parameters:
      count - The size of the memory managed by the INativeHandle
    • setString

      void setString(int index, String value)
      Write a String to the memory at byte offset indexfrom the start of the memory chunk.
      Parameters:
      index - The byte offset from the start of the memory chunk
      value - The value to write.
    • setWideString

      void setWideString(int index, String value)
      Write a String to the memory at byte offset indexfrom the start of the memory chunk using the platform wide character conversion.
      Parameters:
      index - The byte offset from the start of the memory chunk
      value - The value to write.