|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.jniwrapper.Parameter | +--com.jniwrapper.Pointer
This class represents a pointer to object in terms of C language.
Pointer type is defined by its referenced object. E.g. an int pointer (int *
)
is a Pointer
to Int
.
Int value = new Int(); Pointer pValue = new Pointer(value); // this is int*
Nested Class Summary | |
static class |
Pointer.Const
Represents a pointer to constant object. |
static class |
Pointer.OutOnly
Represents a pointer to object with undefined initial value. |
static class |
Pointer.Void
Represents a void * . |
Field Summary | |
static int |
POINTER_LENGTH
|
Constructor Summary | |
Pointer(Parameter ref)
Constructs a new pointer to the given object. |
|
Pointer(Parameter ref,
boolean isNull)
Constructs a new pointer to the given object. |
Method Summary | |
protected void |
acceptIOPerformer(IOPerformer performer,
DataBuffer source,
int initialOffset)
Realization of a Visitor pattern for parameter IO. |
protected void |
checkMemHandleLength()
Checks that memory block referred to by this pointer is big enough to hold the referenced object and allocates a new one if required. |
java.lang.Object |
clone()
|
int |
getLength()
Returns a length of the parameter in memory. |
protected long |
getPointerHandle()
Returns the value of pointer as used by the native side. |
Parameter |
getReferencedObject()
Returns the referenced object of this pointer. |
boolean |
isNull()
Tests if this pointer is null. |
void |
pop(DataBuffer stackBuffer,
int offset)
Default implementation, which does nothing as most primitive types do nothing on pop. |
void |
read(byte[] arr,
int offset)
Reads the parameter value from a byte array. |
void |
read(DataBuffer stackBuffer,
int offset)
Reads this parameter from a specified data source. |
protected void |
readPointer(DataBuffer stackBuffer,
int offset)
Reads this pointer handle part (not the referenced object) from the given data buffer. |
protected void |
readReferencedObject()
Reads the referenced object only. |
protected void |
setExternalSource(long newHandle,
int length)
Makes this pointer use external (unmanaged) memory area. |
void |
setNull(boolean isNull)
Sets pointer null value. |
void |
setReferencedObject(Parameter ref)
Changes the pointer referenced object. |
void |
setReferencedObject(Parameter ref,
boolean isNull)
Changes the pointer referenced object. |
java.lang.String |
toString()
|
void |
write(byte[] arr,
int offset)
Writes the parameter value to a byte array. |
void |
write(DataBuffer stackBuffer,
int offset)
Writes this parameter to a specified data source. |
protected void |
writePointer(DataBuffer stackBuffer,
int offset)
Writes this pointer handle part (not the referenced object) to a given data buffer. |
protected void |
writeReferencedObject()
Writes the referenced object only. |
Methods inherited from class com.jniwrapper.Parameter |
asReturnValue, equals, getAlignedLength, getBuffer, getOffset, indent, push, setBuffer, toByteArray |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int POINTER_LENGTH
Constructor Detail |
public Pointer(Parameter ref)
ref
- referenced object.public Pointer(Parameter ref, boolean isNull)
ref
- referenced objectisNull
- if true
the constructed pointer is null.Method Detail |
public final Parameter getReferencedObject()
public void setReferencedObject(Parameter ref)
public void setReferencedObject(Parameter ref, boolean isNull)
ref
- new referenced object.isNull
- if true
this pointer becomes null.public final boolean isNull()
public final void setNull(boolean isNull)
true
makes the
pointer to be null, setting to false
makes it to reference
its referenced object.
public int getLength()
Parameter
sizeof()
operator.
getLength
in class Parameter
public void write(byte[] arr, int offset)
Parameter
write
in class Parameter
public void read(byte[] arr, int offset)
Parameter
read
in class Parameter
public java.lang.Object clone()
clone
in class Parameter
public java.lang.String toString()
toString
in class java.lang.Object
protected long getPointerHandle()
public void write(DataBuffer stackBuffer, int offset) throws MemoryAccessViolationException
Parameter
write
in class Parameter
MemoryAccessViolationException
protected void writePointer(DataBuffer stackBuffer, int offset) throws MemoryAccessViolationException
MemoryAccessViolationException
public void read(DataBuffer stackBuffer, int offset) throws MemoryAccessViolationException
Parameter
read
in class Parameter
MemoryAccessViolationException
protected void readPointer(DataBuffer stackBuffer, int offset) throws MemoryAccessViolationException
MemoryAccessViolationException
protected void setExternalSource(long newHandle, int length)
newHandle
- memory handlelength
- known allocated lengthpublic void pop(DataBuffer stackBuffer, int offset) throws MemoryAccessViolationException
Parameter
pop
in class Parameter
MemoryAccessViolationException
protected final void checkMemHandleLength()
protected void acceptIOPerformer(IOPerformer performer, DataBuffer source, int initialOffset)
Parameter
performer
is responsible for I/Oing the
parameter. Users implementing a complex parameter from scratch (i.e. not by extending a pre-existing class
such as Structure
or Pointer
) may wish to override this method to make a performer
visit object internal parts.
acceptIOPerformer
in class Parameter
performer
- visitor responsible for I/Oing the parametersource
- data buffer for I/O operationinitialOffset
- I/O operation offset of this parameter in the bufferprotected final void writeReferencedObject()
protected void readReferencedObject()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |