intarsys nativeC library

de.intarsys.nativec.type
Class NativeObject

java.lang.Object
  extended by de.intarsys.nativec.type.NativeObject
All Implemented Interfaces:
INativeObject
Direct Known Subclasses:
NativeArray, NativeBuffer, NativeReference, NativeSimple, NativeStruct

public abstract class NativeObject
extends Object
implements INativeObject

An instance of an external (C memory) represented object. The C-object is represented using the handle (the pointer to the object in C memory) and its type INativeType.

Supported data types are


Field Summary
static boolean DEBUG
          DEBUG flag
static int SHIFT_INT
           
static int SHIFT_LONG
           
static int SHIFT_LONGLONG
           
static int SIZE_BYTE
           
static int SIZE_INT
           
static int SIZE_LONG
           
static int SIZE_LONGLONG
           
static int SIZE_SHORT
           
 
Method Summary
 INativeObject cast(INativeType declaration)
          This is a special form of the "createNative" signature, implementing a "type cast" on the same memory location.
 INativeObject createReference()
           
 byte getByte(int index)
          The byte at index as a native byte.
 byte[] getByteArray(int index, int count)
          The element at index as an array of native byte with dimension count.
abstract  int getByteCount()
          The number of bytes occupied by this.
 byte[] getBytes()
          The bytes copied from C-memory that represent this.
 long getCLong(int index)
          The element at index as a native long.
 int getInt(int index)
          The element at index as a native int.
 INativeHandle getNativeHandle()
          The C-Pointer where the associated memory is found.
 INativeHandle getNativeHandle(int index)
           
abstract  INativeType getNativeType()
          The meta information and behavior for the NativeObject.
 short getShort(int index)
          The element at index as a native short.
 String getString(int index)
           
 String getWideString(int index)
           
 boolean isNull()
          Answer true if this is "null".
 void setByte(int index, byte value)
           
 void setByteArray(int index, byte[] value, int valueOffset, int valueCount)
           
 void setCLong(int index, long value)
           
 void setInt(int index, int value)
           
 void setNativeHandle(int index, INativeHandle value)
           
 void setShort(int index, short value)
           
 void setString(int index, String value)
           
 void setWideString(int index, String value)
           
 String toNestedString()
          A string for debugging purposes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.intarsys.nativec.type.INativeObject
getValue, setValue
 

Field Detail

SIZE_INT

public static final int SIZE_INT
See Also:
Constant Field Values

SHIFT_INT

public static final int SHIFT_INT
See Also:
Constant Field Values

SIZE_LONGLONG

public static final int SIZE_LONGLONG
See Also:
Constant Field Values

SHIFT_LONGLONG

public static final int SHIFT_LONGLONG
See Also:
Constant Field Values

SIZE_LONG

public static final int SIZE_LONG

SHIFT_LONG

public static final int SHIFT_LONG

SIZE_SHORT

public static final int SIZE_SHORT
See Also:
Constant Field Values

SIZE_BYTE

public static final int SIZE_BYTE
See Also:
Constant Field Values

DEBUG

public static boolean DEBUG
DEBUG flag

Method Detail

cast

public INativeObject cast(INativeType declaration)
This is a special form of the "createNative" signature, implementing a "type cast" on the same memory location.

Parameters:
declaration - The new base declaration type.
Returns:
The INativeObject at the same memory location as this, but of a different type.

createReference

public INativeObject createReference()

getByte

public byte getByte(int index)
The byte at index as a native byte.

Parameters:
index - The index of the element to be reported.
Returns:
The element at index as a native byte.

getByteArray

public byte[] getByteArray(int index,
                           int count)
The element at index as an array of native byte with dimension count. This is a lightweight optimization.

Parameters:
index - The index of the element to be reported.
Returns:
The element at index as an array of native byte with dimension count.

getByteCount

public abstract int getByteCount()
The number of bytes occupied by this.

Returns:
The number of bytes occupied by this.

getBytes

public byte[] getBytes()
The bytes copied from C-memory that represent this.

Specified by:
getBytes in interface INativeObject
Returns:
The bytes copied from C-memory that represent this.

getCLong

public long getCLong(int index)
The element at index as a native long. Only the "platform" number of bytes are read.

Parameters:
index - The index of the element to be reported.
Returns:
The element at index as a native long.

getInt

public int getInt(int index)
The element at index as a native int.

Parameters:
index - The index of the element to be reported.
Returns:
The element at index as a native int.

getNativeHandle

public INativeHandle getNativeHandle()
The C-Pointer where the associated memory is found.

Specified by:
getNativeHandle in interface INativeObject
Returns:
The C-Pointer where the associated memory is found.

getNativeHandle

public INativeHandle getNativeHandle(int index)

getNativeType

public abstract INativeType getNativeType()
The meta information and behavior for the NativeObject.

There is exactly one meta instance for all NativeObject instances of a certain type.

Specified by:
getNativeType in interface INativeObject
Returns:
The meta information and behavior for the NativeObject.

getShort

public short getShort(int index)
The element at index as a native short. This is a lightweight optimization.

Parameters:
index - The index of the element to be reported.
Returns:
The element at index as a native short.

getString

public String getString(int index)

getWideString

public String getWideString(int index)

isNull

public boolean isNull()
Answer true if this is "null". This means the associated C-pointer is pointing to 0.

Returns:
Answer true if this is "null".

setByte

public void setByte(int index,
                    byte value)

setByteArray

public void setByteArray(int index,
                         byte[] value,
                         int valueOffset,
                         int valueCount)

setCLong

public void setCLong(int index,
                     long value)

setInt

public void setInt(int index,
                   int value)

setNativeHandle

public void setNativeHandle(int index,
                            INativeHandle value)

setShort

public void setShort(int index,
                     short value)

setString

public void setString(int index,
                      String value)

setWideString

public void setWideString(int index,
                          String value)

toNestedString

public String toNestedString()
A string for debugging purposes.

Returns:
A string for debugging purposes.

intarsys nativeC library

Copyright © 2008 intarsys consulting GmbH. All Rights Reserved.