com.smardec.j2native
Class DelegatedArgument

java.lang.Object
  |
  +--com.smardec.j2native.Argument
        |
        +--com.smardec.j2native.DelegatedArgument
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Bool, Char, Const, Int, OutOnly, UInt, WideChar

public abstract class DelegatedArgument
extends Argument

Abstract DelegatedArgument class represents a base class for all classes exact value of which is delegated to different object.


Field Summary
 
Fields inherited from class com.smardec.j2native.Argument
JAVA_SIDE, NATIVE_SIDE
 
Constructor Summary
DelegatedArgument()
           
 
Method Summary
protected  void finalize()
          Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
 void free()
          To avoid memory leaks in native memory should be used this method.
 void fromBytesValue(byte[] bytes, int offset)
          Restores itself from provided array of bytes.
protected  int getAlignedLength()
          Returns aligned to mashine word lenght of the Argument.
protected  Argument getInternalValue()
          Returns internal Argument object to which all invokes are passed.
 int getLength()
          Returns length in bytes.
protected  boolean isFixedLength()
          Identify if Argument is a fixed length variable.
protected  void read(long handle, int offset)
          Reads itself from the memory.
 void readFromRAM(long handle, int offset)
          Public method to read Argument from the native memmory.
protected  void readFromStack(byte[] stack, int offset)
          Read itself from stack.
protected  void restoreFromRAM()
          Restores itself from native memory.
protected  void setInternalValue(Argument internalValue)
          Sets internal Argument object to which all invokes are passed.
protected  long storeToRAM()
          Stores itself to the native memory.
 byte[] toBytesValue()
          Encodes itself and returns it's representation as array of bytes.
 void toBytesValue(byte[] bytes, int offset)
          Encodes itself to the provided array of bytes.
protected  void write(long handle, int offset)
          Writes itself to the memory.
 void writeToRAM(long handle, int offset)
          Public method to write Argument to the native memmory.
protected  void writeToStack(byte[] stack, int offset)
          Writes itself to stack.
 
Methods inherited from class com.smardec.j2native.Argument
clone, getResultFlags, update
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatedArgument

public DelegatedArgument()
Method Detail

getInternalValue

protected Argument getInternalValue()
Returns internal Argument object to which all invokes are passed.


setInternalValue

protected void setInternalValue(Argument internalValue)
Sets internal Argument object to which all invokes are passed.

Parameters:
internalValue - Argument object to set

toBytesValue

public byte[] toBytesValue()
Description copied from class: Argument
Encodes itself and returns it's representation as array of bytes.

Specified by:
toBytesValue in class Argument
Returns:
byte[] representation of Argument

toBytesValue

public void toBytesValue(byte[] bytes,
                         int offset)
Description copied from class: Argument
Encodes itself to the provided array of bytes.

Specified by:
toBytesValue in class Argument
Parameters:
bytes - array of bytes to which Argument will be written
offset - offset in array

fromBytesValue

public void fromBytesValue(byte[] bytes,
                           int offset)
Description copied from class: Argument
Restores itself from provided array of bytes.

Specified by:
fromBytesValue in class Argument
Parameters:
bytes - array of bytes from which Argument will be restored
offset - offset in array

write

protected void write(long handle,
                     int offset)
              throws MemoryException
Description copied from class: Argument
Writes itself to the memory. Exact memory address specified by params.

Specified by:
write in class Argument
Parameters:
handle - identifies location in memory where Argument will be written
offset - memory address offset
Throws:
MemoryException - if memory manipulations or memory access failed

read

protected void read(long handle,
                    int offset)
             throws MemoryException
Description copied from class: Argument
Reads itself from the memory. Exact memory address specified by params.

Specified by:
read in class Argument
Parameters:
handle - identifies location in memory from which Argument will be read
offset - memory address offset
Throws:
MemoryException - if memory manipulations or memory access failed

writeToStack

protected void writeToStack(byte[] stack,
                            int offset)
Description copied from class: Argument
Writes itself to stack.

Specified by:
writeToStack in class Argument
Parameters:
stack - it's byte array, where Argument will be written
offset - offset in stack

readFromStack

protected void readFromStack(byte[] stack,
                             int offset)
Description copied from class: Argument
Read itself from stack.

Specified by:
readFromStack in class Argument
Parameters:
stack - it's byte array, from which Argument will be restored
offset - offset in stack

getLength

public int getLength()
Description copied from class: Argument
Returns length in bytes.

Specified by:
getLength in class Argument
Returns:
an int

getAlignedLength

protected int getAlignedLength()
Description copied from class: Argument
Returns aligned to mashine word lenght of the Argument.

Overrides:
getAlignedLength in class Argument
Returns:
length in bytes

storeToRAM

protected long storeToRAM()
Description copied from class: Argument
Stores itself to the native memory. Argument takes care of memory allocation and writes itself to this allocated memory. After all operations complete method returns this memory address.

Overrides:
storeToRAM in class Argument
Returns:
memory address

restoreFromRAM

protected void restoreFromRAM()
Description copied from class: Argument
Restores itself from native memory. To perform this operation Argument should be written to native memory previously.

Overrides:
restoreFromRAM in class Argument

writeToRAM

public void writeToRAM(long handle,
                       int offset)
Description copied from class: Argument
Public method to write Argument to the native memmory. This method uses void write(long handle, int offset) method to perform operation.

Overrides:
writeToRAM in class Argument
Parameters:
handle - identifies location in memory where Argument will be written
offset - memory address offset
See Also:
Argument.write(long, int)

readFromRAM

public void readFromRAM(long handle,
                        int offset)
Description copied from class: Argument
Public method to read Argument from the native memmory. This method uses void read(long handle, int offset) method to perform operation.

Overrides:
readFromRAM in class Argument
Parameters:
handle - identifies location in memory from which Argument will be read
offset - memory address offset
See Also:
Argument.read(long, int)

free

public void free()
Description copied from class: Argument
To avoid memory leaks in native memory should be used this method.

Overrides:
free in class Argument

finalize

protected void finalize()
Description copied from class: Argument
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. Method frees native memory if it was used.

Overrides:
finalize in class Argument

isFixedLength

protected boolean isFixedLength()
Description copied from class: Argument
Identify if Argument is a fixed length variable.

Specified by:
isFixedLength in class Argument
Returns:
true if it is so, and false otherwise


Copyright © 2004-2005 Smardec. All Rights Reserved.