org.jnetpcap.nio
Class JObjectBuffer
java.lang.Object
org.jnetpcap.nio.JMemory
org.jnetpcap.nio.JBuffer
org.jnetpcap.nio.JObjectBuffer
- All Implemented Interfaces:
- JByteBuffer
- Direct Known Subclasses:
- JStructBuffer
public class JObjectBuffer
- extends JBuffer
A special buffer that also allows java object references to be set within the
buffer's memory. At JNI level, global JNI references are created and this
buffer will keep track of them, to be released when this buffer is released.
References are setup to work at JMemory level and will be transfered to other
objects if a peer or transfer method is used.
JObjectBuffer does not keep track of which reference is set at which memory
location within this buffer. Therefore it is impossible to release a
individual JNI global reference.
- Author:
- Mark Bednarczyk, Sly Technologies, Inc.
|
Field Summary |
static int |
REF
Size of JNI's jobject reference in bytes. |
|
Method Summary |
|
getObject(java.lang.Class<T> c,
int offset)
Retrieves a jobject reference from the specified memory location. |
|
getObject(java.lang.Class<T> c,
Offset offset)
Retrieves a jobject reference from the specified memory location. |
|
setObject(int offset,
T value)
Sets the jobject reference at specified location within the buffer. |
|
setObject(Offset offset,
T value)
Sets the jobject reference at specified location within the buffer. |
static int |
sizeofJObject()
Returns the native size of JNI's jobject type. |
| Methods inherited from class org.jnetpcap.nio.JBuffer |
findUTF8String, getByte, getByteArray, getByteArray, getDouble, getFloat, getInt, getLong, getShort, getUByte, getUInt, getUShort, getUTF8Char, getUTF8String, getUTF8String, getUTF8String, getUTF8String, isReadonly, order, order, peer, peer, peer, peer, setByte, setByteArray, setByteBuffer, setDouble, setFloat, setInt, setLong, setShort, setUByte, setUInt, setUShort, transferFrom, transferFrom, transferFrom, transferTo, transferTo, transferTo |
| Methods inherited from class org.jnetpcap.nio.JMemory |
check, cleanup, finalize, isInitialized, isJMemoryBasedOwner, isOwner, peer, setSize, size, toDebugString, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
REF
public static final int REF
- Size of JNI's jobject reference in bytes.
JObjectBuffer
public JObjectBuffer(JMemory.Type type)
- Parameters:
type -
JObjectBuffer
public JObjectBuffer(java.nio.ByteBuffer peer)
- Parameters:
peer -
JObjectBuffer
public JObjectBuffer(int size)
- Parameters:
size -
JObjectBuffer
public JObjectBuffer(JMemory peer)
- Parameters:
peer -
JObjectBuffer
public JObjectBuffer(byte[] data)
- Parameters:
data -
getObject
public <T> T getObject(java.lang.Class<T> c,
Offset offset)
- Retrieves a jobject reference from the specified memory location.
- Type Parameters:
T - - Parameters:
c - offset -
- Returns:
getObject
public <T> T getObject(java.lang.Class<T> c,
int offset)
- Retrieves a jobject reference from the specified memory location.
- Type Parameters:
T - - Parameters:
c - offset -
- Returns:
setObject
public <T> void setObject(int offset,
T value)
- Sets the jobject reference at specified location within the buffer. The
buffer will keep track of the global JNI object reference that is created
and it will be deallocated when this object buffer is released.
- Type Parameters:
T - - Parameters:
value -
setObject
public <T> void setObject(Offset offset,
T value)
- Sets the jobject reference at specified location within the buffer. The
buffer will keep track of the global JNI object reference that is created
and it will be deallocated when this object buffer is released.
- Type Parameters:
T - - Parameters:
value -
sizeofJObject
public static int sizeofJObject()
- Returns the native size of JNI's jobject type. sizeof(jobject)
- Returns: