org.apache.gora.persistency
Interface Persistent

All Superinterfaces:
Cloneable, org.apache.avro.generic.GenericContainer, org.apache.avro.generic.IndexedRecord, org.apache.avro.specific.SpecificRecord
All Known Implementing Classes:
Employee, Metadata, MetricDatum, Pageview, PersistentBase, TokenDatum, WebPage

public interface Persistent
extends org.apache.avro.specific.SpecificRecord, Cloneable

Objects that are persisted by Gora implements this interface.


Method Summary
 void clear()
          Clears the inner state of the object without any modification to the actual data on the data store.
 void clearDirty()
          Clears the dirty state.
 void clearDirty(int fieldIndex)
          Clears the field as dirty.
 void clearDirty(String field)
          Clears the field as dirty.
 void clearNew()
          Clears the new state
 void clearReadable()
          Clears the readable state.
 void clearReadable(int fieldIndex)
          Clears the field as readable.
 void clearReadable(String field)
          Sets the field as readable.
 Persistent clone()
           
 String getField(int index)
          Returns the field name with the given index
 int getFieldIndex(String field)
          Returns the index of the field with the given name
 String[] getFields()
          Returns sorted field names of the object
 StateManager getStateManager()
          Returns the StateManager which manages the persistent state of the object.
 boolean isDirty()
          Returns whether any of the fields of the object has been modified after construction or loading.
 boolean isDirty(int fieldIndex)
          Returns whether the field has been modified.
 boolean isDirty(String field)
          Returns whether the field has been modified.
 boolean isNew()
          Returns whether the object is newly constructed.
 boolean isReadable(int fieldIndex)
          Returns whether the field has been loaded from the datastore.
 boolean isReadable(String field)
          Returns whether the field has been loaded from the datastore.
 Persistent newInstance(StateManager stateManager)
          Constructs a new instance of the object with the given StateManager.
 void setDirty()
          Sets all the fields of the object as dirty.
 void setDirty(int fieldIndex)
          Sets the field as dirty.
 void setDirty(String field)
          Sets the field as dirty.
 void setNew()
          Sets the state of the object as new for persistency
 void setReadable(int fieldIndex)
          Sets the field as readable.
 void setReadable(String field)
          Sets the field as readable.
 
Methods inherited from interface org.apache.avro.generic.IndexedRecord
get, put
 
Methods inherited from interface org.apache.avro.generic.GenericContainer
getSchema
 

Method Detail

getStateManager

StateManager getStateManager()
Returns the StateManager which manages the persistent state of the object.

Returns:
the StateManager of the object

newInstance

Persistent newInstance(StateManager stateManager)
Constructs a new instance of the object with the given StateManager. This method is intended to be used by Gora framework.

Parameters:
stateManager - the StateManager to manage the persistent state of the object
Returns:
a new instance of the object

getFields

String[] getFields()
Returns sorted field names of the object

Returns:
the field names of the object as a String[]

getField

String getField(int index)
Returns the field name with the given index

Parameters:
index - the index of the field
Returns:
the name of the field

getFieldIndex

int getFieldIndex(String field)
Returns the index of the field with the given name

Parameters:
field - the name of the field
Returns:
the index of the field

clear

void clear()
Clears the inner state of the object without any modification to the actual data on the data store. This method should be called before re-using the object to hold the data for another result.


isNew

boolean isNew()
Returns whether the object is newly constructed.

Returns:
true if the object is newly constructed, false if retrieved from a datastore.

setNew

void setNew()
Sets the state of the object as new for persistency


clearNew

void clearNew()
Clears the new state


isDirty

boolean isDirty()
Returns whether any of the fields of the object has been modified after construction or loading.

Returns:
whether any of the fields of the object has changed

isDirty

boolean isDirty(int fieldIndex)
Returns whether the field has been modified.

Parameters:
fieldIndex - the offset of the field in the object
Returns:
whether the field has been modified.

isDirty

boolean isDirty(String field)
Returns whether the field has been modified.

Parameters:
field - the name of the field
Returns:
whether the field has been modified.

setDirty

void setDirty()
Sets all the fields of the object as dirty.


setDirty

void setDirty(int fieldIndex)
Sets the field as dirty.

Parameters:
fieldIndex - the offset of the field in the object

setDirty

void setDirty(String field)
Sets the field as dirty.

Parameters:
field - the name of the field

clearDirty

void clearDirty(int fieldIndex)
Clears the field as dirty.

Parameters:
fieldIndex - the offset of the field in the object

clearDirty

void clearDirty(String field)
Clears the field as dirty.

Parameters:
field - the name of the field

clearDirty

void clearDirty()
Clears the dirty state.


isReadable

boolean isReadable(int fieldIndex)
Returns whether the field has been loaded from the datastore.

Parameters:
fieldIndex - the offset of the field in the object
Returns:
whether the field has been loaded

isReadable

boolean isReadable(String field)
Returns whether the field has been loaded from the datastore.

Parameters:
field - the name of the field
Returns:
whether the field has been loaded

setReadable

void setReadable(int fieldIndex)
Sets the field as readable.

Parameters:
fieldIndex - the offset of the field in the object

setReadable

void setReadable(String field)
Sets the field as readable.

Parameters:
field - the name of the field

clearReadable

void clearReadable(int fieldIndex)
Clears the field as readable.

Parameters:
fieldIndex - the offset of the field in the object

clearReadable

void clearReadable(String field)
Sets the field as readable.

Parameters:
field - the name of the field

clearReadable

void clearReadable()
Clears the readable state.


clone

Persistent clone()


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.