2010 FRC Java API


com.sun.cldc.jna
Class Structure

java.lang.Object
  extended by com.sun.cldc.jna.Structure
Direct Known Subclasses:
CurveOptions, DynamicStructure, EllipseDescriptor, FRCCommonControlData, FRCControl.DynamicControlData, LibCImpl.statImpl, LibCImpl.statImpl, NetDBImpl.hostentImpl, NetDBImpl.hostentImpl, OpaqueStructure, RegionOfInterest, ShapeDetectionOptions, TimeImpl.timevalImpl, TimeImpl.timevalImpl

public abstract class Structure
extends Object

Abstract class for proxies to native structure types.


Field Summary
protected  Pointer backingNativeMemory
           
static Structure NULL
          Singleton object that can be used as a NULL structure instance.
 
Constructor Summary
protected Structure()
           
protected Structure(Pointer backingNativeMemory)
           
 
Method Summary
 void allocateMemory()
          Attempt to allocate backing memory for the structure.
 void allocateMemory(int size)
          Attempt to allocate backing memory for the structure.
 void clear()
          Set the backing memory to zeros.
 void freeMemory()
          Free the backing memory for the structure.
 Pointer getPointer()
          Get the backing native memory used by this structure.
abstract  void read()
          Copy the fields of the struct from native memory to the Java fields
 void release()
          Release the backing memory for the structure, if it was malloced
abstract  int size()
           
 String toString()
          Returns a string representation of the object.
 void useMemory(Pointer m)
          Set the backing native memory used by this structure.
abstract  void write()
          Copy the java fields of the struct to native memory from the Java fields
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final Structure NULL
Singleton object that can be used as a NULL structure instance.


backingNativeMemory

protected Pointer backingNativeMemory
Constructor Detail

Structure

protected Structure()

Structure

protected Structure(Pointer backingNativeMemory)
Method Detail

allocateMemory

public void allocateMemory()
                    throws OutOfMemoryError
Attempt to allocate backing memory for the structure. This memory should be freed when not needed

Throws:
OutOfMemoryError - if backing native memory cannot be allocated.
IllegalStateException - if this structure already has memory allocated

allocateMemory

public void allocateMemory(int size)
                    throws OutOfMemoryError
Attempt to allocate backing memory for the structure.

Parameters:
size - in bytes ito allocate
Throws:
IllegalArgumentException - if the requested size is smaller than the default size
OutOfMemoryError - if backing native memory cannot be allocated.
IllegalStateException - if this structure already has memory allocated

clear

public void clear()
Set the backing memory to zeros.


freeMemory

public void freeMemory()
                throws IllegalStateException
Free the backing memory for the structure.

Throws:
IllegalStateException - if the memory has already been freed.

getPointer

public final Pointer getPointer()
Get the backing native memory used by this structure. May return null if allocateMemory() has not been called, or if the Structure is permantently attached to C memory.

Returns:
the memory

read

public abstract void read()
Copy the fields of the struct from native memory to the Java fields


release

public void release()
             throws IllegalStateException
Release the backing memory for the structure, if it was malloced

Throws:
IllegalStateException - if the memory has already been freed.

size

public abstract int size()
Returns:
the size of the native structure

toString

public String toString()
Description copied from class: Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.

useMemory

public final void useMemory(Pointer m)
Set the backing native memory used by this structure.

Parameters:
m - the native memory
Throws:
IllegalStateException - if this structure already has memory allocated

write

public abstract void write()
Copy the java fields of the struct to native memory from the Java fields


2010 FRC Java API


Copyright © 2006-2009 Sun Microsystems, Inc. All Rights Reserved.