org.qi4j.spi.entitystore.helpers
Class JSONEntityState

java.lang.Object
  extended by org.qi4j.spi.entitystore.helpers.JSONEntityState
All Implemented Interfaces:
EntityState

public final class JSONEntityState
extends java.lang.Object
implements EntityState

Standard implementation of EntityState.


Field Summary
static java.lang.String JSON_KEY_APPLICATION_VERSION
           
static java.lang.String JSON_KEY_ASSOCIATIONS
           
static java.lang.String JSON_KEY_IDENTITY
           
static java.lang.String JSON_KEY_MANYASSOCIATIONS
           
static java.lang.String JSON_KEY_MODIFIED
           
static java.lang.String JSON_KEY_PROPERTIES
           
static java.lang.String JSON_KEY_TYPE
           
static java.lang.String JSON_KEY_VERSION
           
 
Method Summary
 EntityReference associationValueOf(QualifiedName stateName)
           
 EntityDescriptor entityDescriptor()
           
 EntityReference identity()
          Returns the identity of the entity that this EntityState represents.
 boolean isAssignableTo(java.lang.Class<?> type)
           
 long lastModified()
          Last modified timestamp of the entity.
 ManyAssociationState manyAssociationValueOf(QualifiedName stateName)
           
 void markUpdated()
           
 java.lang.Object propertyValueOf(QualifiedName stateName)
           
 void remove()
          Remove the entity represented by this EntityState when the unit of work is completed.
 void setAssociationValue(QualifiedName stateName, EntityReference newEntity)
           
 void setPropertyValue(QualifiedName stateName, java.lang.Object newValue)
           
 org.json.JSONObject state()
           
 EntityStatus status()
          The status of this EntityState
 java.lang.String toString()
           
 java.lang.String version()
          Version of the entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JSON_KEY_PROPERTIES

public static final java.lang.String JSON_KEY_PROPERTIES
See Also:
Constant Field Values

JSON_KEY_ASSOCIATIONS

public static final java.lang.String JSON_KEY_ASSOCIATIONS
See Also:
Constant Field Values

JSON_KEY_MANYASSOCIATIONS

public static final java.lang.String JSON_KEY_MANYASSOCIATIONS
See Also:
Constant Field Values

JSON_KEY_IDENTITY

public static final java.lang.String JSON_KEY_IDENTITY
See Also:
Constant Field Values

JSON_KEY_APPLICATION_VERSION

public static final java.lang.String JSON_KEY_APPLICATION_VERSION
See Also:
Constant Field Values

JSON_KEY_TYPE

public static final java.lang.String JSON_KEY_TYPE
See Also:
Constant Field Values

JSON_KEY_VERSION

public static final java.lang.String JSON_KEY_VERSION
See Also:
Constant Field Values

JSON_KEY_MODIFIED

public static final java.lang.String JSON_KEY_MODIFIED
See Also:
Constant Field Values
Method Detail

version

public final java.lang.String version()
Description copied from interface: EntityState
Version of the entity. This is managed by the EntityStore.

If the underlying EntityStore does not support versioning, then version must always be set to 0.

Specified by:
version in interface EntityState
Returns:
version of the entity

lastModified

public long lastModified()
Description copied from interface: EntityState
Last modified timestamp of the entity. This is managed by the EntityStore.

If the underlying EntityStore does not support timestamping, then last modified must always be set to the current time.

Specified by:
lastModified in interface EntityState
Returns:
last modified timestamp of the entity, as defined by System.currentTimeMillis()

identity

public EntityReference identity()
Description copied from interface: EntityState
Returns the identity of the entity that this EntityState represents.

Specified by:
identity in interface EntityState
Returns:
the identity of the entity that this EntityState represents.

propertyValueOf

public java.lang.Object propertyValueOf(QualifiedName stateName)
Specified by:
propertyValueOf in interface EntityState

setPropertyValue

public void setPropertyValue(QualifiedName stateName,
                             java.lang.Object newValue)
Specified by:
setPropertyValue in interface EntityState

associationValueOf

public EntityReference associationValueOf(QualifiedName stateName)
Specified by:
associationValueOf in interface EntityState

setAssociationValue

public void setAssociationValue(QualifiedName stateName,
                                EntityReference newEntity)
Specified by:
setAssociationValue in interface EntityState

manyAssociationValueOf

public ManyAssociationState manyAssociationValueOf(QualifiedName stateName)
Specified by:
manyAssociationValueOf in interface EntityState

remove

public void remove()
Description copied from interface: EntityState
Remove the entity represented by this EntityState when the unit of work is completed.

Specified by:
remove in interface EntityState

status

public EntityStatus status()
Description copied from interface: EntityState
The status of this EntityState

Specified by:
status in interface EntityState
Returns:
the status

isAssignableTo

public boolean isAssignableTo(java.lang.Class<?> type)
Specified by:
isAssignableTo in interface EntityState

entityDescriptor

public EntityDescriptor entityDescriptor()
Specified by:
entityDescriptor in interface EntityState

state

public org.json.JSONObject state()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

markUpdated

public void markUpdated()