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

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

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

A pointer for use with the java.lang.String Java type.

Author:
Mark richter

Constructor Summary
StringPointer()
          Constructs a new pointer for which no memotry is allocated.
StringPointer(int address)
          Constructs a new pointer that will use the specified memory address to store data.
StringPointer(java.lang.String initString)
          Constructs a new string pointer that will point to the specified String.
 
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.
 java.lang.String getValue()
          Returns the value of this pointer.
 void setAddress(int address)
          Sets the memory address for this pointer.
 void setValue(java.lang.String stringData)
          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

StringPointer

public StringPointer(java.lang.String initString)
Constructs a new string pointer that will point to the specified String. Memory allocation for the String is not performed until the gaddress is required by calling getAddress.

Parameters:
initString - the string to which to point.

StringPointer

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


StringPointer

public StringPointer(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 java.lang.String 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(java.lang.String stringData)
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:
stringData - 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