Package de.intarsys.nativec.jna
Class JnaNativeHandle
java.lang.Object
de.intarsys.nativec.jna.JnaNativeHandle
- All Implemented Interfaces:
INativeHandle
-
Constructor Summary
ConstructorsConstructorDescriptionJnaNativeHandle
(long address) JnaNativeHandle
(com.sun.jna.Pointer pointer) JnaNativeHandle
(JnaNativeHandle handle, int offset) -
Method Summary
Modifier and TypeMethodDescriptionboolean
long
The start address of the memory chunkbyte
getByte
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a byte.byte[]
getByteArray
(int index, int count) Marshal the data at byte offsetindex
from the start of the memory chunk to a byte array of lengthcount
.long
getCLong
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a long.int
getInt
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to an int.long
getLong
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a long value (which is always 8 byte).getNativeHandle
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to anINativeHandle
.com.sun.jna.Pointer
short
getShort
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a short.int
getSize()
The size for the handle in bytes.getString
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a String.getWideString
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a String using the platform wide character conversion.int
hashCode()
offset
(int offset) Create a newINativeHandle
, offset from this byoffset
bytes.void
setByte
(int index, byte value) Write a byte to the memory at byte offsetindex
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 offsetindex
from the start of the memory chunk.void
setCLong
(int index, long value) Write a long to the memory at byte offsetindex
from the start of the memory chunk.void
setInt
(int index, int value) Write an int to the memory at byte offsetindex
from the start of the memory chunk.void
setLong
(int index, long value) Write a long to the memory at byte offsetindex
from the start of the memory chunk.void
setNativeHandle
(int index, INativeHandle handle) Write anINativeHandle
to the memory at byte offsetindex
from the start of the memory chunk.void
setShort
(int index, short value) Write a short to the memory at byte offsetindex
from the start of the memory chunk.void
setSize
(int pSize) Set the valid size for the handle tocount
bytes.void
Write a String to the memory at byte offsetindex
from the start of the memory chunk.void
setWideString
(int index, String value) Write a String to the memory at byte offsetindex
from the start of the memory chunk using the platform wide character conversion.
-
Constructor Details
-
JnaNativeHandle
-
JnaNativeHandle
public JnaNativeHandle(long address) -
JnaNativeHandle
public JnaNativeHandle(com.sun.jna.Pointer pointer)
-
-
Method Details
-
equals
-
getAddress
public long getAddress()Description copied from interface:INativeHandle
The start address of the memory chunk- Specified by:
getAddress
in interfaceINativeHandle
- Returns:
- The start address of the memory chunk
-
getByte
public byte getByte(int index) Description copied from interface:INativeHandle
Marshal the data at byte offsetindex
from the start of the memory chunk to a byte.- Specified by:
getByte
in interfaceINativeHandle
- 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 offsetindex
from the start of the memory chunk to a byte array of lengthcount
.- Specified by:
getByteArray
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunkcount
- 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 offsetindex
from the start of the memory chunk to a long. Get only the "platform" number of bytes.- Specified by:
getCLong
in interfaceINativeHandle
- 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 offsetindex
from the start of the memory chunk to an int.- Specified by:
getInt
in interfaceINativeHandle
- 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 offsetindex
from the start of the memory chunk to a long value (which is always 8 byte).- Specified by:
getLong
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunk- Returns:
- A long marshaled from the memory chunk
-
getNativeHandle
Description copied from interface:INativeHandle
Marshal the data at byte offsetindex
from the start of the memory chunk to anINativeHandle
.- Specified by:
getNativeHandle
in interfaceINativeHandle
- 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 offsetindex
from the start of the memory chunk to a short.- Specified by:
getShort
in interfaceINativeHandle
- 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 interfaceINativeHandle
-
getString
Description copied from interface:INativeHandle
Marshal the data at byte offsetindex
from the start of the memory chunk to a String.- Specified by:
getString
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunk- Returns:
- A String marshaled from the memory chunk
-
getWideString
Description copied from interface:INativeHandle
Marshal the data at byte offsetindex
from the start of the memory chunk to a String using the platform wide character conversion.- Specified by:
getWideString
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunk- Returns:
- A String marshaled from the memory chunk
-
hashCode
public int hashCode() -
offset
Description copied from interface:INativeHandle
Create a newINativeHandle
, offset from this byoffset
bytes.- Specified by:
offset
in interfaceINativeHandle
- Parameters:
offset
- The byte offset from the start of the memory chunk- Returns:
- A new
INativeHandle
pointing to "getAddress() + offset".
-
setByte
public void setByte(int index, byte value) Description copied from interface:INativeHandle
Write a byte to the memory at byte offsetindex
from the start of the memory chunk.- Specified by:
setByte
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunkvalue
- 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 offsetindex
from the start of the memory chunk. The method will writevalueCount
bytes fromvalue
starting atvalueOffset
.- Specified by:
setByteArray
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunkvalue
- 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 offsetindex
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 interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunkvalue
- 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 offsetindex
from the start of the memory chunk.- Specified by:
setInt
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunkvalue
- 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 offsetindex
from the start of the memory chunk.- Specified by:
setLong
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunkvalue
- The value to write.
-
setNativeHandle
Description copied from interface:INativeHandle
Write anINativeHandle
to the memory at byte offsetindex
from the start of the memory chunk.- Specified by:
setNativeHandle
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunkhandle
- The value to write.
-
setShort
public void setShort(int index, short value) Description copied from interface:INativeHandle
Write a short to the memory at byte offsetindex
from the start of the memory chunk.- Specified by:
setShort
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunkvalue
- The value to write.
-
setSize
public void setSize(int pSize) Description copied from interface:INativeHandle
Set the valid size for the handle tocount
bytes.You can not access bytes from outside the range defined by getAdddress + size.
- Specified by:
setSize
in interfaceINativeHandle
- Parameters:
pSize
- The size of the memory managed by theINativeHandle
-
setString
Description copied from interface:INativeHandle
Write a String to the memory at byte offsetindex
from the start of the memory chunk.- Specified by:
setString
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunkvalue
- The value to write.
-
setWideString
Description copied from interface:INativeHandle
Write a String to the memory at byte offsetindex
from the start of the memory chunk using the platform wide character conversion.- Specified by:
setWideString
in interfaceINativeHandle
- Parameters:
index
- The byte offset from the start of the memory chunkvalue
- The value to write.
-