de.aitools.aq.value
Class Value

java.lang.Object
  extended by de.aitools.aq.value.Value
Direct Known Subclasses:
DoubleDouble, DoubleDoubleDouble, DoubleDoubleIntInt, DoubleDoubleLongLong, DoubleInt, DoubleIntDouble, DoubleIntInt, DoubleLong, DoubleLongLongInt, DoubleString, IntDouble, IntDoubleDouble, IntInt, IntIntDouble, IntIntDoubleDouble, IntIntInt, IntIntLongLong, IntLong, IntString, LongDouble, LongDoubleDouble, LongDoubleLongInt, LongInt, LongIntDouble, LongIntInt, LongLong, LongLongDoubleDouble, LongLongIntInt, LongString, ShortInt, SingleBuffer, SingleDouble, SingleInt, SingleLong, SingleString

public abstract class Value
extends java.lang.Object

Version:
$Id: Value.java,v 1.5 2011/04/08 17:25:55 trenkman Exp $
Author:
martin.trenkmann@uni-weimar.de

Field Summary
static char DELIMITER_C
           
static java.lang.String DELIMITER_S
           
static int SIZEOF_BYTE
           
static int SIZEOF_DOUBLE
           
static int SIZEOF_FLOAT
           
static int SIZEOF_INT
           
static int SIZEOF_LONG
           
static int SIZEOF_SHORT
           
 
Constructor Summary
Value()
           
 
Method Summary
abstract  void copyFrom(com.sun.jna.Pointer buffer)
          Reads all elements of that value from a piece of memory pointed to by buffer.
abstract  void copyTo(com.sun.jna.Pointer buffer)
          Writes all elements of that value to a piece of memory pointed to by buffer.
static
<V extends Value>
int
getNativeTypeId(java.lang.Class<V> clazz)
          Returns the native type id of the given class or -1, if that type id cannot be obtained.
abstract  int getSerializedSize()
          Returns the size in bytes of this object when serialized.
abstract  com.sun.jna.Memory getSharedMemory()
          Returns a pointer to a piece of memory, that provides space for at least getSerializedSize() bytes and can be directly used in conjunction with copyTo(Pointer) and copyFrom(Pointer).
abstract  boolean parseFrom(java.util.Scanner sc)
          Parses new content of that value from the given Scanner.
abstract  java.io.PrintStream printTo(java.io.PrintStream ps)
          Prints all elements of that value to a stream in a human-readable format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELIMITER_C

public static final char DELIMITER_C
See Also:
Constant Field Values

DELIMITER_S

public static final java.lang.String DELIMITER_S

SIZEOF_BYTE

public static final int SIZEOF_BYTE
See Also:
Constant Field Values

SIZEOF_SHORT

public static final int SIZEOF_SHORT
See Also:
Constant Field Values

SIZEOF_INT

public static final int SIZEOF_INT
See Also:
Constant Field Values

SIZEOF_LONG

public static final int SIZEOF_LONG
See Also:
Constant Field Values

SIZEOF_FLOAT

public static final int SIZEOF_FLOAT
See Also:
Constant Field Values

SIZEOF_DOUBLE

public static final int SIZEOF_DOUBLE
See Also:
Constant Field Values
Constructor Detail

Value

public Value()
Method Detail

getNativeTypeId

public static <V extends Value> int getNativeTypeId(java.lang.Class<V> clazz)
Returns the native type id of the given class or -1, if that type id cannot be obtained. The native type id is used for mapping derivatives of Value to its corresponding C++ type.

Type Parameters:
V - the value type parameter
Parameters:
clazz - the class object of the value type
Returns:
the native type id or -1

copyFrom

public abstract void copyFrom(com.sun.jna.Pointer buffer)
Reads all elements of that value from a piece of memory pointed to by buffer. You have to make sure, that the size of this buffer is at least getSerializedSize().

Parameters:
buffer - a pointer to free memory

copyTo

public abstract void copyTo(com.sun.jna.Pointer buffer)
Writes all elements of that value to a piece of memory pointed to by buffer. You have to make sure, that the size of this buffer is at least getSerializedSize().

Parameters:
buffer - a pointer to free memory

parseFrom

public abstract boolean parseFrom(java.util.Scanner sc)
Parses new content of that value from the given Scanner.

Parameters:
sc - a Scanner to parse the data from
Returns:
true if on success, false otherwise.

printTo

public abstract java.io.PrintStream printTo(java.io.PrintStream ps)
Prints all elements of that value to a stream in a human-readable format.

Parameters:
ps - a stream to print all elements to

getSharedMemory

public abstract com.sun.jna.Memory getSharedMemory()

Returns a pointer to a piece of memory, that provides space for at least getSerializedSize() bytes and can be directly used in conjunction with copyTo(Pointer) and copyFrom(Pointer).

For the sake of efficiency the provided memory may be some sort of shared memory, which can be used temporarily, to transfer data somewhere, e.g. to native code. Please note that the usage of this buffer in multi-threaded code has to be synchronized.

Returns:
a pointer to some shared memory, which is large enough to serialize this object to
See Also:
copyFrom(Pointer), copyTo(Pointer), getSerializedSize()

getSerializedSize

public abstract int getSerializedSize()
Returns the size in bytes of this object when serialized.

Returns:
the size in bytes