Package de.intarsys.nativec.jna
Class JnaNativeHandle
- java.lang.Object
-
- de.intarsys.nativec.jna.JnaNativeHandle
-
- All Implemented Interfaces:
INativeHandle
public class JnaNativeHandle extends java.lang.Object implements INativeHandle
-
-
Constructor Summary
Constructors Constructor Description JnaNativeHandle(long address)JnaNativeHandle(com.sun.jna.Pointer pointer)JnaNativeHandle(JnaNativeHandle handle, int offset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)longgetAddress()The start address of the memory chunkbytegetByte(int index)Marshal the data at byte offsetindexfrom the start of the memory chunk to a byte.byte[]getByteArray(int index, int count)Marshal the data at byte offsetindexfrom the start of the memory chunk to a byte array of lengthcount.longgetCLong(int index)Marshal the data at byte offsetindexfrom the start of the memory chunk to a long.intgetInt(int index)Marshal the data at byte offsetindexfrom the start of the memory chunk to an int.longgetLong(int index)Marshal the data at byte offsetindexfrom the start of the memory chunk to a long value (which is always 8 byte).INativeHandlegetNativeHandle(int index)Marshal the data at byte offsetindexfrom the start of the memory chunk to anINativeHandle.com.sun.jna.PointergetPointer()shortgetShort(int index)Marshal the data at byte offsetindexfrom the start of the memory chunk to a short.intgetSize()The size for the handle in bytes.java.lang.StringgetString(int index)Marshal the data at byte offsetindexfrom the start of the memory chunk to a String.java.lang.StringgetWideString(int index)Marshal the data at byte offsetindexfrom the start of the memory chunk to a String using the platform wide character conversion.inthashCode()INativeHandleoffset(int offset)Create a newINativeHandle, offset from this byoffsetbytes.voidsetByte(int index, byte value)Write a byte to the memory at byte offsetindexfrom the start of the memory chunk.voidsetByteArray(int index, byte[] value, int valueOffset, int valueCount)Write a byte array to the memory at byte offsetindexfrom the start of the memory chunk.voidsetCLong(int index, long value)Write a long to the memory at byte offsetindexfrom the start of the memory chunk.voidsetInt(int index, int value)Write an int to the memory at byte offsetindexfrom the start of the memory chunk.voidsetLong(int index, long value)Write a long to the memory at byte offsetindexfrom the start of the memory chunk.voidsetNativeHandle(int index, INativeHandle handle)Write anINativeHandleto the memory at byte offsetindexfrom the start of the memory chunk.voidsetShort(int index, short value)Write a short to the memory at byte offsetindexfrom the start of the memory chunk.voidsetSize(int pSize)Set the valid size for the handle tocountbytes.voidsetString(int index, java.lang.String value)Write a String to the memory at byte offsetindexfrom the start of the memory chunk.voidsetWideString(int index, java.lang.String value)Write a String to the memory at byte offsetindexfrom the start of the memory chunk using the platform wide character conversion.
-
-
-
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:
equalsin classjava.lang.Object
-
getAddress
public long getAddress()
Description copied from interface:INativeHandleThe start address of the memory chunk- Specified by:
getAddressin interfaceINativeHandle- Returns:
- The start address of the memory chunk
-
getByte
public byte getByte(int index)
Description copied from interface:INativeHandleMarshal the data at byte offsetindexfrom the start of the memory chunk to a byte.- Specified by:
getBytein 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:INativeHandleMarshal the data at byte offsetindexfrom the start of the memory chunk to a byte array of lengthcount.- Specified by:
getByteArrayin 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:INativeHandleMarshal the data at byte offsetindexfrom the start of the memory chunk to a long. Get only the "platform" number of bytes.- Specified by:
getCLongin 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:INativeHandleMarshal the data at byte offsetindexfrom the start of the memory chunk to an int.- Specified by:
getIntin 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:INativeHandleMarshal the data at byte offsetindexfrom the start of the memory chunk to a long value (which is always 8 byte).- Specified by:
getLongin interfaceINativeHandle- 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:INativeHandleMarshal the data at byte offsetindexfrom the start of the memory chunk to anINativeHandle.- Specified by:
getNativeHandlein interfaceINativeHandle- Parameters:
index- The byte offset from the start of the memory chunk- Returns:
- An
INativeHandlemarshaled from the memory chunk
-
getPointer
public com.sun.jna.Pointer getPointer()
-
getShort
public short getShort(int index)
Description copied from interface:INativeHandleMarshal the data at byte offsetindexfrom the start of the memory chunk to a short.- Specified by:
getShortin 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:INativeHandleThe size for the handle in bytes.You can not access bytes from outside the range defined by getAdddress + size.
- Specified by:
getSizein interfaceINativeHandle
-
getString
public java.lang.String getString(int index)
Description copied from interface:INativeHandleMarshal the data at byte offsetindexfrom the start of the memory chunk to a String.- Specified by:
getStringin interfaceINativeHandle- 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:INativeHandleMarshal the data at byte offsetindexfrom the start of the memory chunk to a String using the platform wide character conversion.- Specified by:
getWideStringin 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()
- Overrides:
hashCodein classjava.lang.Object
-
offset
public INativeHandle offset(int offset)
Description copied from interface:INativeHandleCreate a newINativeHandle, offset from this byoffsetbytes.- Specified by:
offsetin interfaceINativeHandle- Parameters:
offset- The byte offset from the start of the memory chunk- Returns:
- A new
INativeHandlepointing to "getAddress() + offset".
-
setByte
public void setByte(int index, byte value)Description copied from interface:INativeHandleWrite a byte to the memory at byte offsetindexfrom the start of the memory chunk.- Specified by:
setBytein 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:INativeHandleWrite a byte array to the memory at byte offsetindexfrom the start of the memory chunk. The method will writevalueCountbytes fromvaluestarting atvalueOffset.- Specified by:
setByteArrayin 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:INativeHandleWrite a long to the memory at byte offsetindexfrom the start of the memory chunk. Write only the "platform" number of bytes. The caller is responsible for observing the value range.- Specified by:
setCLongin 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:INativeHandleWrite an int to the memory at byte offsetindexfrom the start of the memory chunk.- Specified by:
setIntin 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:INativeHandleWrite a long to the memory at byte offsetindexfrom the start of the memory chunk.- Specified by:
setLongin interfaceINativeHandle- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-
setNativeHandle
public void setNativeHandle(int index, INativeHandle handle)Description copied from interface:INativeHandleWrite anINativeHandleto the memory at byte offsetindexfrom the start of the memory chunk.- Specified by:
setNativeHandlein interfaceINativeHandle- Parameters:
index- The byte offset from the start of the memory chunk
-
setShort
public void setShort(int index, short value)Description copied from interface:INativeHandleWrite a short to the memory at byte offsetindexfrom the start of the memory chunk.- Specified by:
setShortin 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:INativeHandleSet the valid size for the handle tocountbytes.You can not access bytes from outside the range defined by getAdddress + size.
- Specified by:
setSizein interfaceINativeHandle- Parameters:
pSize- The size of the memory managed by theINativeHandle
-
setString
public void setString(int index, java.lang.String value)Description copied from interface:INativeHandleWrite a String to the memory at byte offsetindexfrom the start of the memory chunk.- Specified by:
setStringin interfaceINativeHandle- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-
setWideString
public void setWideString(int index, java.lang.String value)Description copied from interface:INativeHandleWrite a String to the memory at byte offsetindexfrom the start of the memory chunk using the platform wide character conversion.- Specified by:
setWideStringin interfaceINativeHandle- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-
-