be.cardon.nativecall
Class NativeByteArray

java.lang.Object
  extended by be.cardon.nativecall.NativeObject
      extended by be.cardon.nativecall.NativeByteArray

public class NativeByteArray
extends NativeObject

Wrapped class for native char, char[] type. Class with read only support.


Field Summary
 
Fields inherited from class be.cardon.nativecall.NativeObject
BYTE_SIZE, INT_SIZE, LLC
 
Constructor Summary
NativeByteArray(int LengthInBytes)
          allocates a new byte array
NativeByteArray(int LengthInBytes, int address)
          existing byte array.
NativeByteArray(int LengthInBytes, int address, boolean readOnly)
          existing byte array, with protection or not.
 
Method Summary
static NativeByteArray newInstance(NativeObject obj)
          Convert a NativeObject in a NativeByteArray.
 byte[] read()
          return the whole buffer content.
 byte[] read(int offset, int len)
          return the bytes, beginning at the given offset, and with the given length.
 void write(byte[] data)
          write the given byte in the buffer.
 void write(byte[] data, int offset)
          write the given byte array in the buffer.
 
Methods inherited from class be.cardon.nativecall.NativeObject
finalize, getAddress, getLength, isReadOnly, setReadOnly
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NativeByteArray

public NativeByteArray(int LengthInBytes)
                throws NativeCallException
allocates a new byte array

Throws:
NativeCallException

NativeByteArray

public NativeByteArray(int LengthInBytes,
                       int address)
                throws NativeCallException
existing byte array.

Throws:
NativeCallException

NativeByteArray

public NativeByteArray(int LengthInBytes,
                       int address,
                       boolean readOnly)
                throws NativeCallException
existing byte array, with protection or not.

Throws:
NativeCallException
Method Detail

newInstance

public static NativeByteArray newInstance(NativeObject obj)
                                   throws NativeCallException
Convert a NativeObject in a NativeByteArray.

Throws:
NativeCallException

read

public byte[] read()
            throws NativeCallException
return the whole buffer content.

Throws:
NativeCallException

read

public byte[] read(int offset,
                   int len)
            throws NativeCallException
return the bytes, beginning at the given offset, and with the given length.

Throws:
NativeCallException

write

public void write(byte[] data,
                  int offset)
           throws NativeCallException
write the given byte array in the buffer. (length of data may be < buffer length)

Throws:
NativeCallException

write

public void write(byte[] data)
           throws NativeCallException
write the given byte in the buffer.

Throws:
NativeCallException