Home about services products contact login
   com.smardec

J2Native

  j2native
com.smardec.j2native
Class TypedPointer

java.lang.Object
|
+--com.smardec.j2native.Argument
|
+--com.smardec.j2native.PointerArgument
|
+--com.smardec.j2native.TypedPointer
All Implemented Interfaces:
java.lang.Cloneable, PointerType
Direct Known Subclasses:
Pointer, Pointer.Const, Pointer.OutOnly

public abstract class TypedPointer
extends PointerArgument

Pointer class represents a pointer to object in terms of C language. Pointer type is defined by its referenced object.


Field Summary
Fields inherited from class com.smardec.j2native.Argument
JAVA_SIDE, NATIVE_SIDE
Constructor Summary
protected TypedPointer(Argument refArgument)
Constructs a new pointer to a given object.
Method Summary
Argument getAt(int elementIndex)
If we know exactly lenght of the referenced Argument, we can represent this pointer as array pointer and perform iteration through this array.
Argument getAt(int elementOffset, int elementSize)
Returns new Argument object, constructed from referenced Argument and filled with a value retrieved from native memory.
Argument getReferencedArgument()
Return Argument this pointer is referenced to.
long getValue()
Returns native memory handle
boolean isNull()
Tests if this pointer is null.
protected void read(long handle, int offset)
Reads itself from the memory.
protected void readFromStack(byte[] stack, int offset)
Read itself from stack.
void setReferencedArgument(Argument refArgument)
Sets referenced Argument.
void setValue(long handle)
Sets memory handle
protected void update(byte side)
This method is used to synchronize Java side and native part.
protected void write(long handle, int offset)
Writes itself to the memory.
protected void writeToStack(byte[] stack, int offset)
Writes itself to stack.
Methods inherited from class com.smardec.j2native.PointerArgument
fromBytesValue, getLength, isFixedLength, toBytesValue, toBytesValue
Methods inherited from class com.smardec.j2native.Argument
clone, finalize, free, getAlignedLength, getResultFlags, readFromRAM, restoreFromRAM, storeToRAM, writeToRAM
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
TypedPointer
protected TypedPointer(Argument refArgument)

Constructs a new pointer to a given object. The constructed pointer is a non-null pointer parameter that points to the given object.

Parameters:
refArgument - referenced object
Method Detail
getReferencedArgument
public Argument getReferencedArgument()
Return Argument this pointer is referenced to.

Returns:
referenced Argument

setReferencedArgument
public void setReferencedArgument(Argument refArgument)
Sets referenced Argument.

Parameters:
refArgument - Argument to set

getValue
public long getValue()
Description copied from interface: PointerType
Returns native memory handle


setValue
public void setValue(long handle)
Description copied from interface: PointerType
Sets memory handle

Parameters:
handle - memory handle

isNull
public boolean isNull()
Description copied from interface: PointerType
Tests if this pointer is null.

Returns:
boolean

writeToStack
protected void writeToStack(byte[] stack, int offset)
Description copied from class: Argument
Writes itself to stack.

Overrides:
writeToStack in class PointerArgument
Parameters:
stack - it's byte array, where Argument will be written
offset - offset in stack

readFromStack
protected void readFromStack(byte[] stack, int offset)
Description copied from class: Argument
Read itself from stack.

Overrides:
readFromStack in class PointerArgument
Parameters:
stack - it's byte array, from which Argument will be restored
offset - offset in stack

write
protected void write(long handle, int offset)
Description copied from class: Argument
Writes itself to the memory. Exact memory address specified by params.

Overrides:
write in class PointerArgument
Parameters:
handle - identifies location in memory where Argument will be written
offset - memory address offset

read
protected void read(long handle, int offset)
Description copied from class: Argument
Reads itself from the memory. Exact memory address specified by params.

Overrides:
read in class PointerArgument
Parameters:
handle - identifies location in memory from which Argument will be read
offset - memory address offset

getAt
public Argument getAt(int elementIndex) throws java.lang.RuntimeException
If we know exactly lenght of the referenced Argument, we can represent this pointer as array pointer and perform iteration through this array.

Parameters:
elementIndex - index of this imaginary array
Throws:
java.lang.RuntimeException - if referenced Argument is not fixed length

getAt
public Argument getAt(int elementOffset, int elementSize)
Returns new Argument object, constructed from referenced Argument and filled with a value retrieved from native memory.

Parameters:
elementOffset - offset from the referenced Argument's memory handle value
elementSize - size of the retrieved data in bytes

update
protected void update(byte side)
Description copied from class: Argument
This method is used to synchronize Java side and native part.

Overrides:
update in class Argument
Parameters:
side - identifies part that should be updated
Home about services products contact login