|
JNative project : see http://jnative.sf.net |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xvolks.jnative.pointers.Pointer
public class Pointer
$Id: Pointer.java,v 1.4 2006/01/14 19:27:01 mdenty Exp $;
This class encapsulate a native pointer.
To create a pointer you should first create a memory block that can be addressed by this Pointer. See org.xvolks.jnative.pointers.memory.MemoryBlockFactory
A Pointer can also be obtained by using a Structure (BasicData) or one of its concreate implementation (LONG, MemoryStatusEx...) with the method BasicData.createPointer().
MemoryBlockFactory
,
This software is released under the GPL.
Constructor Summary | |
---|---|
Pointer(MemoryBlock mem)
Constructor : allocates size memory block in the native side |
Method Summary | |
---|---|
void |
dispose()
Method dispose frees the memory addressed by this pointer |
protected void |
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
byte |
getAsByte(int offset)
Method getAsByte |
int |
getAsInt(int offset)
Method getAsInt |
long |
getAsLong(int offset)
Method getAsLong |
short |
getAsShort(int offset)
Method getAsShort |
java.lang.String |
getAsString()
Method getAsString |
byte[] |
getMemory()
Method getMemory |
int |
getPointer()
Method getPointer |
int |
getSize()
Method getSize |
int |
setByteAt(int offset,
byte value)
Method setByteAt |
int |
setIntAt(int offset,
int value)
Method setIntAt |
int |
setLongAt(int offset,
long value)
Method setLongAt |
void |
setMemory(byte[] buffer)
Method setMemory fills the native memory with the content of buffer |
void |
setMemory(java.lang.String buffer)
Method setMemory fills the native memory with the content of buffer |
int |
setShortAt(int offset,
short value)
Method setShortAt |
int |
setStringAt(int offset,
java.lang.String value)
Method setStringAt |
void |
zeroMemory()
Method zeroMemory performs a memset(pointer, 0) |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Pointer(MemoryBlock mem)
size
memory block in the native side
size
- : memory size to allocateMethod Detail |
---|
public void dispose() throws NativeException
NativeException
public int getPointer()
public int getSize()
public void setMemory(java.lang.String buffer) throws NativeException, java.lang.ArrayIndexOutOfBoundsException
buffer
buffer
- the source to strcpy
NativeException
java.lang.ArrayIndexOutOfBoundsException
- if the size of the buffer is greater than the size of the native memorypublic void setMemory(byte[] buffer) throws NativeException
buffer
buffer
- the source to memcpy
NativeException
java.lang.ArrayIndexOutOfBoundsException
- if the size of the buffer is greater than the size of the native memorypublic int setByteAt(int offset, byte value) throws NativeException
offset
- int the native memory blockvalue
- the byte to write
NativeException
java.lang.ArrayIndexOutOfBoundsException
- if offset > size of the native buuferpublic int setShortAt(int offset, short value) throws NativeException
offset
- int the native memory blockvalue
- the short to write
NativeException
java.lang.ArrayIndexOutOfBoundsException
- if offset + 2 > size of the native buuferpublic int setIntAt(int offset, int value) throws NativeException
offset
- int the native memory blockvalue
- the integer to write
NativeException
java.lang.ArrayIndexOutOfBoundsException
- if offset + 4 > size of the native buuferpublic int setLongAt(int offset, long value) throws NativeException
offset
- int the native memory blockvalue
- the long to write
NativeException
java.lang.ArrayIndexOutOfBoundsException
- if offset + 8 > size of the native buuferpublic int setStringAt(int offset, java.lang.String value) throws NativeException
offset
- int the native memory blockvalue
- the String to write
value
NativeException
java.lang.ArrayIndexOutOfBoundsException
- if offset + len(value) > size of the native buuferpublic void zeroMemory() throws NativeException
NativeException
public byte[] getMemory() throws NativeException
NativeException
public java.lang.String getAsString() throws NativeException
NativeException
public byte getAsByte(int offset) throws NativeException
offset
-
offset
NativeException
public short getAsShort(int offset) throws NativeException
offset
- an int
offset
NativeException
public int getAsInt(int offset) throws NativeException
offset
- an int
offset
NativeException
public long getAsLong(int offset) throws NativeException
offset
- an int
offset
NativeException
protected void finalize() throws java.lang.Throwable
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.
The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.
The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.
After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.
The finalize method is never invoked more than once by a Java virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
Calls dispose()
finalize
in class java.lang.Object
java.lang.Throwable
- the Exception
raised by this method
|
JNative project : see http://jnative.sf.net |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |