au.com.swz.swttocom.swt.types.pointer
Class LongPointer

java.lang.Object
  extended by au.com.swz.swttocom.swt.types.pointer.LongPointer
All Implemented Interfaces:
IDisposeableResource, IPointer

public class LongPointer
extends java.lang.Object
implements IPointer, IDisposeableResource

A pointer for use with the long Java type.

Author:
Mark richter

Constructor Summary
LongPointer()
          Constructs a new pointer for which no memotry is allocated.
LongPointer(int address)
          Constructs a new pointer that will use the specified memory address to store data.
 
Method Summary
 void dispose()
          Releases the memory (if any) allocated by this pointer.
protected  void finalize()
           
 int getAddress()
          Returns the memory address for this pointer.
 long getValue()
          Returns the value of this pointer.
 void setAddress(int address)
          Sets the memory address for this pointer.
 void setValue(long longData)
          Sets the value of this pointer.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LongPointer

public LongPointer()
Constructs a new pointer for which no memotry is allocated.


LongPointer

public LongPointer(int address)
Constructs a new pointer that will use the specified memory address to store data.

Parameters:
address - the memory address to use for storing data.
Method Detail

getValue

public long getValue()
Returns the value of this pointer. If memory is allocated for this pointer then the internal value is first retrieved from the memory address before it is returned. If no memory is yet allocated then the internal value is returned directly.

Returns:
the value for this pointer.

setValue

public void setValue(long longData)
Sets the value of this pointer. If memory is allocated for this pointer then the value is placed in to the memory address as well as the internal value updated. If no memory is yet allocated then only the internal value is updated.

Parameters:
longData - the new value for this pointer.

getAddress

public int getAddress()
Returns the memory address for this pointer. If no memory has yet been allocated then it is allocated before being returned. This method along with the release and setAddress methods are managed by SWTtoCOM and should not be used by clients since it may result in memory leaks.

Specified by:
getAddress in interface IPointer
Returns:
the memory address for this pointer.

setAddress

public void setAddress(int address)
Sets the memory address for this pointer. If the specified value is 0 (NULL) then the memory address is cleared (but not released). This method is used by SWTtoCOM to invalidate a memory address to ensure a reference to this class continues to function even after it has been passed through COM.

Specified by:
setAddress in interface IPointer
Parameters:
address - the new memory address for this pointer or 0 to clear the memory address of this pointer.

dispose

public void dispose()
Releases the memory (if any) allocated by this pointer. The internal value is first retrieved from the memory to ensure it is the most up to date value. This method along with the getAddress and setAddress methods are managed by SWTtoCOM and should not be used by clients since releasing memory that is not owned can have severe consequences.

Specified by:
dispose in interface IDisposeableResource
Specified by:
dispose in interface IPointer

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable