org.magnos.data.var
Class AbstractVar<E>

java.lang.Object
  extended by org.magnos.data.AbstractData
      extended by org.magnos.data.var.AbstractVar<E>
Type Parameters:
E -
All Implemented Interfaces:
Data, Var<E>
Direct Known Subclasses:
BooleanVar, ByteVar, DoubleVar, FloatVar, IntVar, LongVar, ShortVar, StringVar, UByteVar, UIntVar, UShortVar

public abstract class AbstractVar<E>
extends AbstractData
implements Var<E>

An abstract implementation of Var.

Author:
Philip Diffenderfer

Constructor Summary
AbstractVar(int size)
          Instantiates a new AbstractVar.
 
Method Summary
 boolean equals(java.lang.Object o)
          
 int hashCode()
          
 boolean putValue(E newValue)
          Sets the value of this var and writes it to the store.
 E takeValue()
          Returns the value of this var by reading it from the store and updating the cached value.
 java.lang.String toString()
          
 
Methods inherited from class org.magnos.data.AbstractData
getActualLocation, getLocation, getParent, getSize, getStore, onRead, onWrite, read, read, read, read, setLocation, setParent, setStore, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.magnos.data.Var
getValue, setValue
 
Methods inherited from interface org.magnos.data.Data
copy, getActualLocation, getLocation, getParent, getSize, getStore, read, read, read, read, setLocation, setParent, setStore, write, write, write, write
 

Constructor Detail

AbstractVar

public AbstractVar(int size)
Instantiates a new AbstractVar.

Parameters:
size - The fixed size of the Var in bytes.
Method Detail

takeValue

public E takeValue()
Returns the value of this var by reading it from the store and updating the cached value. If there is a problem reading the value from the store this will throw a RuntimeException and not update the cached value.

Specified by:
takeValue in interface Var<E>
Returns:
The value read from the store.

putValue

public boolean putValue(E newValue)
Sets the value of this var and writes it to the store.

Specified by:
putValue in interface Var<E>
Parameters:
newValue - The value to write to the store.

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object