org.magnos.data
Class AbstractData

java.lang.Object
  extended by org.magnos.data.AbstractData
All Implemented Interfaces:
Data
Direct Known Subclasses:
AbstractVar, DataArray, DataSet

public abstract class AbstractData
extends java.lang.Object
implements Data

An abstract implementation of Data.

Author:
Philip Diffenderfer

Constructor Summary
AbstractData(int size)
          Instantiates a new AbstractData.
 
Method Summary
 int getActualLocation()
          Returns the actual location of this Data in its store with respect to the parent if one exists.
 int getLocation()
          Returns the location in bytes of this variable in the store.
 Data getParent()
          Returns the parent Data object if one exists.
 int getSize()
          Returns the size of this variable in a store.
 Store getStore()
          Returns the store this variable is read and written to and from.
protected abstract  void onRead(int location, Store store)
          Reads this data from the given store at the given location.
protected abstract  void onWrite(int location, Store store)
          Writes this data to the given store at the given location.
 void read()
          Reads the value from the store at the location.
 void read(int offset)
          Reads the value from the store at the location with the given offset.
 void read(int offset, Store store)
          Reads the value from the given store at the location with the given offset.
 void read(Store store)
          Reads the value from the given store at the location.
 void setLocation(int newLocation)
          Sets the location in bytes of this variable in the store.
 void setParent(Data parent)
          Sets the parent Data object.
 void setStore(Store newStore)
          Sets the store this variable is read and written to and from.
 void write()
          Writes the value to the store at the location.
 void write(int offset)
          Writes the value to the store at the location with the given offset.
 void write(int offset, Store store)
          Writes the value to the given store at the location with the given offset.
 void write(Store store)
          Writes the value to the given store at the location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.magnos.data.Data
copy
 

Constructor Detail

AbstractData

public AbstractData(int size)
Instantiates a new AbstractData.

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

onRead

protected abstract void onRead(int location,
                               Store store)
Reads this data from the given store at the given location.

Parameters:
location - The offset in bytes from the beginning of the store to read from.
store - The store to read from.

onWrite

protected abstract void onWrite(int location,
                                Store store)
Writes this data to the given store at the given location.

Parameters:
location - The offset in bytes from the beginning of the store to write to.
store - The store to write to.

setLocation

public final void setLocation(int newLocation)
Sets the location in bytes of this variable in the store.

Specified by:
setLocation in interface Data
Parameters:
newLocation - The offset in bytes from beginning of the store.

getLocation

public final int getLocation()
Returns the location in bytes of this variable in the store.

Specified by:
getLocation in interface Data
Returns:
The offset in bytes from the beginning of the store.

getSize

public final int getSize()
Returns the size of this variable in a store.

Specified by:
getSize in interface Data
Returns:
The number of bytes this variable takes up in a store.

setStore

public final void setStore(Store newStore)
Sets the store this variable is read and written to and from.

Specified by:
setStore in interface Data
Parameters:
newStore - The new store of this variable.

getStore

public final Store getStore()
Returns the store this variable is read and written to and from.

Specified by:
getStore in interface Data
Returns:
The reference to the store.

getParent

public final Data getParent()
Returns the parent Data object if one exists.

Specified by:
getParent in interface Data
Returns:
The reference to the parent Data object.

setParent

public final void setParent(Data parent)
Sets the parent Data object.

Specified by:
setParent in interface Data
Parameters:
parent - The parent Data object.

getActualLocation

public final int getActualLocation()
Returns the actual location of this Data in its store with respect to the parent if one exists.

Specified by:
getActualLocation in interface Data
Returns:
The actual location of the data in bytes.

read

public final void read()
Reads the value from the store at the location.

Specified by:
read in interface Data

read

public final void read(int offset)
Reads the value from the store at the location with the given offset.

Specified by:
read in interface Data
Parameters:
offset - The offset from the location to read the value.

read

public final void read(Store store)
Reads the value from the given store at the location.

Specified by:
read in interface Data
Parameters:
store - The store to read from.

read

public final void read(int offset,
                       Store store)
Reads the value from the given store at the location with the given offset.

Specified by:
read in interface Data
Parameters:
offset - The offset from the location to read the value.
store - The store to read from.

write

public final void write()
Writes the value to the store at the location.

Specified by:
write in interface Data

write

public final void write(int offset)
Writes the value to the store at the location with the given offset.

Specified by:
write in interface Data
Parameters:
offset - The offset from the location to write the value.

write

public final void write(Store store)
Writes the value to the given store at the location.

Specified by:
write in interface Data
Parameters:
store - The store to write to.

write

public final void write(int offset,
                        Store store)
Writes the value to the given store at the location with the given offset.

Specified by:
write in interface Data
Parameters:
offset - The offset from the location to write the value.
store - The store to write to.