fr.ocelet.runtime
Class Hproperty<T>

Package class diagram package Hproperty
java.lang.Object
  extended by fr.ocelet.runtime.Hproperty<T>
All Implemented Interfaces:
java.lang.Iterable<T>

public class Hproperty<T>
extends java.lang.Object
implements java.lang.Iterable<T>

Entity's historic property. A property has the capacity to hold past values. They also are coherent with the transaction mechanism present in entities, meaning that several values can be given as candidates to be set to this property in the future and an AffectOperator will be used to compute the next state of the property at commit time.


Nested Class Summary
 class Hproperty.HistoryIterator
           
 
Field Summary
(package private)  AffectOperator<T> ao
           
(package private)  boolean containsFuture
           
(package private)  java.util.ArrayList<T> content
           
(package private)  int DEFAULT_MAX_ARCS
           
(package private)  java.util.ArrayList<T> future
           
(package private)  int historySize
           
(package private)  int index
           
 
Constructor Summary
Hproperty(int size)
          Produces an instance of a Hproperty with the specified history size.
Hproperty(int size, int futsz)
          Produces an instance of a Hproperty with the specified history size
 
Method Summary
 void commitFuture()
          Processes the list of candidate values using the AffectOperator assigned to this Hproperty.
 void flushFuture()
          Clears the list of candidate values.
 T get()
           
 T get(int pastIndex)
          Obtain the historic value of this Hproperty pointed to by the argument pastIndex
 java.util.Iterator<T> iterator()
          Returns an Iterator on the historic values of this Hproperty.
 void set(T val)
          Changes the actual state of this property with the argument val.
 void setAffectOperator(AffectOperator<T> newao)
          Set an AffectOperator to process the list of candidate values to be affected to this Hproperty.
 void setFuture(T futureval)
          Adds a candidate value to the candidate list.
 java.lang.String toString()
          Overrides the Object.toString() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MAX_ARCS

final int DEFAULT_MAX_ARCS
See Also:
Constant Field Values

content

java.util.ArrayList<T> content

future

java.util.ArrayList<T> future

containsFuture

boolean containsFuture

index

int index

historySize

int historySize

ao

AffectOperator<T> ao
Constructor Detail

Hproperty

public Hproperty(int size)
Produces an instance of a Hproperty with the specified history size.

Parameters:
size - Number of history steps

Hproperty

public Hproperty(int size,
                 int futsz)
Produces an instance of a Hproperty with the specified history size

Parameters:
size - Number of history steps
futsz - Initial number of expected concurrent values (to be processed by AffectOperators).
Method Detail

set

public void set(T val)
Changes the actual state of this property with the argument val. The history is shifted by one step. Any future candidate value is removed from the candidate list.

Parameters:
val - The new value to affect to this Hproperty

setFuture

public void setFuture(T futureval)
Adds a candidate value to the candidate list. That list will be processed later using an AffectOperator.

Parameters:
futureval - The candidate value

setAffectOperator

public void setAffectOperator(AffectOperator<T> newao)
Set an AffectOperator to process the list of candidate values to be affected to this Hproperty. If no AffectOperator has been specified through this method, the Any operator will be used by default.

Parameters:
newao - An AffectOperator

commitFuture

public void commitFuture()
Processes the list of candidate values using the AffectOperator assigned to this Hproperty. If no AffectOperator has been specified through this method, the Any operator is used by default.


flushFuture

public void flushFuture()
Clears the list of candidate values.


get

public T get()
Returns:
The actual value of this Hproperty

get

public T get(int pastIndex)
Obtain the historic value of this Hproperty pointed to by the argument pastIndex

Parameters:
pastIndex - Negative or null index to point the historic value to obtain. If 0 the actual value is returned. If -1 the last step value is returned, and so on.
Returns:
A historic value indexed by pastIndex

toString

public java.lang.String toString()
Overrides the Object.toString() method.

Overrides:
toString in class java.lang.Object

iterator

public java.util.Iterator<T> iterator()
Returns an Iterator on the historic values of this Hproperty. The first value returned is the oldest, and the last is the most recent (actual state of this Hproperty).

Specified by:
iterator in interface java.lang.Iterable<T>