| Modifier and Type | Field and Description |
|---|---|
protected OAVEventHandler |
eventhandler
The OAV event handler.
|
protected IOAVIdGenerator |
generator
The id generator.
|
protected boolean |
nocheck
The flag to disable type checking.
|
protected java.util.Map |
objects
The objects table (id -> map).
|
protected java.util.Map |
objectusages
The usages of object ids (object id -> usages).
|
protected static java.lang.Class[] |
PCL
The argument types for property change listener adding/removal (cached for speed).
|
protected java.util.Map |
pcls
The Java beans property change listeners.
|
protected IProfiler |
profiler
The profiler.
|
protected java.lang.ref.ReferenceQueue |
queue
The reference queue for stale objects.
|
protected java.util.Set |
rootobjects
The root objects (will not be cleaned up when usages==0).
|
protected jadex.commons.concurrent.ISynchronizator |
synchronizator
The synchronizator (if any).
|
protected OAVTypeModel |
tmodel
The type models.
|
protected java.util.Map |
types
The object types (object -> type).
|
| Constructor and Description |
|---|
OAVWeakState(OAVTypeModel tmodel)
Create a new empty OAV state representation.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAttributeValue(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object value)
Add an attribute of an object to the given value.
|
void |
addExternalObjectUsage(java.lang.Object id,
java.lang.Object external)
Add an external usage of a state object.
|
protected void |
addJavaObjectUsage(java.lang.Object whichid,
OAVAttributeType whichattr,
java.lang.Object value)
When it is a Java object, it is not created in state,
so we have to notify object addition to listeners on first usage.
|
void |
addJavaRootObject(java.lang.Object object)
Add a Java object as root object.
|
void |
addStateListener(IOAVStateListener listener,
boolean bunch)
Add a new state listener.
|
void |
addSubstate(IOAVState substate)
Add a substate.
|
protected boolean |
checkMultiplicity(java.lang.Object object,
OAVAttributeType attribute,
java.util.Set allowedmults)
Ensure that multiplicity is ok.
|
protected boolean |
checkMultiplicity(java.lang.Object object,
OAVAttributeType attribute,
java.lang.String allowedmult)
Ensure that multiplicity is ok.
|
protected boolean |
checkTypeDefined(OAVObjectType type)
Test if a type is defined in one of the models.
|
protected boolean |
checkTypeHasAttribute(java.lang.Object object,
OAVAttributeType attribute)
Ensure that a type has an attribute.
|
protected boolean |
checkValidStateObject(java.lang.Object object)
Test if the object is a valid state object, meaning
that is either a root object or a non-root object with
at least one usage.
|
protected boolean |
checkValueCompatibility(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object value)
Check if it is allowed to set or add an attribute value.
|
java.lang.Object |
cloneObject(java.lang.Object object,
IOAVState targetstate)
Clone an object in the state (deep copy).
|
boolean |
containsKey(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object key)
Test if a key is contained in the map attribute.
|
boolean |
containsObject(java.lang.Object id)
Test if the state contains a specific object.
|
java.lang.Object |
createObject(OAVObjectType type)
Create an object.
|
java.lang.Object |
createRootObject(OAVObjectType type)
Create a root object.
|
protected void |
deregisterValue(java.lang.Object value)
Deregister a value for observation.
|
void |
dispose()
Dispose the state.
|
void |
dropObject(java.lang.Object object)
Drop an object from the state.
|
boolean |
equals(java.lang.Object a,
java.lang.Object b)
Test if two values are equal
according to current identity/equality
settings.
|
void |
expungeStaleObjects()
Expunge stale objects.
|
java.util.List |
findCycle(java.util.Collection objects)
Find a cycle in a given set of objects.
|
java.util.Collection |
getAttributeKeys(java.lang.Object object,
OAVAttributeType attribute)
Get the keys of an attribute of an object.
|
java.lang.Object |
getAttributeValue(java.lang.Object object,
OAVAttributeType attribute)
Get an attribute value of an object.
|
java.lang.Object |
getAttributeValue(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object key)
Get an attribute value of an object.
|
java.util.Collection |
getAttributeValues(java.lang.Object object,
OAVAttributeType attribute)
Get the values of an attribute of an object.
|
protected java.lang.Object |
getClonedOAVObject(IOAVState targetstate,
java.util.Map handles,
java.util.List todo,
java.lang.Object oldval)
Get or create a clone of an oav object.
|
java.util.Iterator |
getDeepObjects()
Get all objects in the state.
|
protected OAVWeakIdGenerator.OAVInternalObjectId |
getInternalId(java.lang.Object id)
Get the internal object id.
|
protected java.util.Map |
getJavaObjectUsages(java.lang.Object id)
Get all object usages.
|
protected java.util.Map |
getObject(java.lang.Object id)
Get an object map for its id.
|
java.util.Iterator |
getObjects()
Get all objects in the state.
|
IProfiler |
getProfiler()
Get the profiler.
|
java.util.Collection |
getReferencingObjects(java.lang.Object value)
Get those objects referencing a given object.
|
java.util.Iterator |
getRootObjects()
Get the root objects of the state.
|
int |
getSize()
Get the number of objects in the state.
|
IOAVState[] |
getSubstates()
Get the substates.
|
jadex.commons.concurrent.ISynchronizator |
getSynchronizator()
Get the synchronizator (if any).
|
OAVObjectType |
getType(java.lang.Object id)
Get the type of an object.
|
OAVTypeModel |
getTypeModel()
Get the type model.
|
java.util.Collection |
getUnreferencedObjects()
Get all unreferenced objects.
|
boolean |
isIdentifier(java.lang.Object object)
Test if the object represents an identifier.
|
boolean |
isJavaIdentity()
Flag indicating that java objects are
stored by identity instead of equality.
|
protected boolean |
isJavaNonValue(java.lang.Object obj)
Check if an object is a java object but not a value.
|
void |
notifyEventListeners()
Throw collected events and notify the listeners.
|
protected void |
registerValue(OAVJavaType type,
java.lang.Object value)
Register a value for observation.
|
void |
removeAttributeValue(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object value)
Remove an attribute of an object to the given value.
|
void |
removeExternalObjectUsage(java.lang.Object id,
java.lang.Object external)
Remove an external usage of a state object.
|
protected void |
removeJavaObjectUsage(java.lang.Object whichid,
OAVAttributeType whichattr,
java.lang.Object value)
Remove an object usage.
|
void |
removeJavaRootObject(java.lang.Object object)
Drop a Java object from root objects.
|
void |
removeStateListener(IOAVStateListener listener)
Remove a state listener.
|
void |
setAttributeValue(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object value)
Set an attribute of an object to the given value.
|
void |
setProfiler(IProfiler profiler)
Set the profiler.
|
void |
setSynchronizator(jadex.commons.concurrent.ISynchronizator synchronizator)
Set the synchronizator.
|
java.lang.String |
toString()
Get the string representation of the object.
|
protected static java.lang.Class[] PCL
protected OAVTypeModel tmodel
protected java.util.Map objects
protected java.util.Map types
protected IOAVIdGenerator generator
protected boolean nocheck
protected java.util.Map objectusages
protected java.util.Set rootobjects
protected java.util.Map pcls
protected OAVEventHandler eventhandler
protected java.lang.ref.ReferenceQueue queue
protected jadex.commons.concurrent.ISynchronizator synchronizator
protected IProfiler profiler
public OAVWeakState(OAVTypeModel tmodel)
public OAVTypeModel getTypeModel()
getTypeModel in interface IOAVStatepublic java.lang.Object createObject(OAVObjectType type)
createObject in interface IOAVStatetype - The object type (null for defining meta types).public java.lang.Object createRootObject(OAVObjectType type)
createRootObject in interface IOAVStatepublic void dropObject(java.lang.Object object)
dropObject in interface IOAVStateobject - The identifier of the object to remove.public void addJavaRootObject(java.lang.Object object)
addJavaRootObject in interface IOAVStateobject - The Java object.public void removeJavaRootObject(java.lang.Object object)
removeJavaRootObject in interface IOAVStateobject - The Java object.public java.lang.Object cloneObject(java.lang.Object object,
IOAVState targetstate)
object - The handle to the object to be cloned.targetstate - The target state in which the clone should be created.protected java.lang.Object getClonedOAVObject(IOAVState targetstate, java.util.Map handles, java.util.List todo, java.lang.Object oldval)
targetstate - The target state.handles - The handles.todo - The todo list.oldval - The old object.public boolean containsObject(java.lang.Object id)
containsObject in interface IOAVStateid - The object id.public boolean isIdentifier(java.lang.Object object)
isIdentifier in interface IOAVStateobject - The suspected object identifier.public OAVObjectType getType(java.lang.Object id)
public java.util.Iterator getObjects()
getObjects in interface IOAVStatepublic java.util.Iterator getDeepObjects()
getDeepObjects in interface IOAVStatepublic java.util.Iterator getRootObjects()
getRootObjects in interface IOAVStatepublic int getSize()
public java.util.Collection getUnreferencedObjects()
getUnreferencedObjects in interface IOAVStatepublic java.util.List findCycle(java.util.Collection objects)
public java.util.Collection getReferencingObjects(java.lang.Object value)
getReferencingObjects in interface IOAVStatepublic java.lang.Object getAttributeValue(java.lang.Object object,
OAVAttributeType attribute)
getAttributeValue in interface IOAVStateobject - The identifier of the object.attribute - The attribute identifier.public void setAttributeValue(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object value)
setAttributeValue in interface IOAVStateobject - The identifier of the object.attribute - The attribute identifier.value - The value (basic, object id or java object).protected boolean isJavaNonValue(java.lang.Object obj)
public java.util.Collection getAttributeValues(java.lang.Object object,
OAVAttributeType attribute)
getAttributeValues in interface IOAVStateobject - The identifier of the object.attribute - The attribute identifier.public java.util.Collection getAttributeKeys(java.lang.Object object,
OAVAttributeType attribute)
getAttributeKeys in interface IOAVStateobject - The identifier of the object.attribute - The attribute identifier.public java.lang.Object getAttributeValue(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object key)
getAttributeValue in interface IOAVStateobject - The identifier of the object.attribute - The attribute identifier.key - The key.public boolean containsKey(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object key)
containsKey in interface IOAVStateobject - The identifier of the object.attribute - The attribute identifier.key - The key.public void addAttributeValue(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object value)
addAttributeValue in interface IOAVStateobject - The identifier of the object.attribute - The attribute identifier.value - The value (basic, object id or java object).public void removeAttributeValue(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object value)
removeAttributeValue in interface IOAVStateobject - The identifier of the object.attribute - The attribute identifier.value - The value (basic, object id or java object).public void addStateListener(IOAVStateListener listener, boolean bunch)
addStateListener in interface IOAVStatelistener - The state listener.bunch - True, for adding a bunch listener.public void removeStateListener(IOAVStateListener listener)
removeStateListener in interface IOAVStatelistener - The state listener.public void notifyEventListeners()
notifyEventListeners in interface IOAVStatepublic void expungeStaleObjects()
expungeStaleObjects in interface IOAVStatepublic void addExternalObjectUsage(java.lang.Object id,
java.lang.Object external)
addExternalObjectUsage in interface IOAVStateid - The oav object id.external - The user object.public void removeExternalObjectUsage(java.lang.Object id,
java.lang.Object external)
removeExternalObjectUsage in interface IOAVStateid - The oav object id.external - The state external object.public IProfiler getProfiler()
getProfiler in interface IOAVStatepublic void setProfiler(IProfiler profiler)
setProfiler in interface IOAVStatepublic void setSynchronizator(jadex.commons.concurrent.ISynchronizator synchronizator)
setSynchronizator in interface IOAVStatepublic jadex.commons.concurrent.ISynchronizator getSynchronizator()
getSynchronizator in interface IOAVStatepublic java.lang.String toString()
toString in class java.lang.Objectprotected java.util.Map getObject(java.lang.Object id)
id - The id.protected boolean checkValueCompatibility(java.lang.Object object,
OAVAttributeType attribute,
java.lang.Object value)
java.lang.RuntimeException - if value is not allowed.protected boolean checkTypeHasAttribute(java.lang.Object object,
OAVAttributeType attribute)
object - The object.attribute - The attribute.java.lang.RuntimeException - if value is not allowed.protected boolean checkMultiplicity(java.lang.Object object,
OAVAttributeType attribute,
java.util.Set allowedmults)
object - The object.attribute - The attribute.multiplicity - The multiplicity.java.lang.RuntimeException - if value is not allowed.protected boolean checkMultiplicity(java.lang.Object object,
OAVAttributeType attribute,
java.lang.String allowedmult)
object - The object.attribute - The attribute.multiplicity - The multiplicity.java.lang.RuntimeException - if value is not allowed.protected boolean checkTypeDefined(OAVObjectType type)
type - The type.protected boolean checkValidStateObject(java.lang.Object object)
object - The object.protected void addJavaObjectUsage(java.lang.Object whichid,
OAVAttributeType whichattr,
java.lang.Object value)
protected void removeJavaObjectUsage(java.lang.Object whichid,
OAVAttributeType whichattr,
java.lang.Object value)
whichid - The object that references the object.whichattr - The attribute which references the object.value - The object id/value to remove.dropset - Already dropped objects in recursive drop (or null if none).protected java.util.Map getJavaObjectUsages(java.lang.Object id)
protected void registerValue(OAVJavaType type, java.lang.Object value)
protected void deregisterValue(java.lang.Object value)
protected OAVWeakIdGenerator.OAVInternalObjectId getInternalId(java.lang.Object id)
id - The id.public void addSubstate(IOAVState substate)
addSubstate in interface IOAVStatepublic IOAVState[] getSubstates()
getSubstates in interface IOAVStatepublic boolean isJavaIdentity()
isJavaIdentity in interface IOAVState