Class EntityInstance
- All Implemented Interfaces:
IEventChannel
,IPropertyContainer
,IEntityInstance
,Serializable
- Since:
- 5.0
- Author:
- O. Kerpershoek, F. v.d. Meer, v.jansen
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
EntityInstance
(DefaultProfileFactory factory, IEntityDefinition definition, EntityValue id, InstanceType type, InstanceManager instanceManager) protected
EntityInstance
(DefaultProfileFactory factory, IEntityInstance other, EntityValue id, InstanceManager instanceManager) -
Method Summary
Modifier and TypeMethodDescriptionboolean
addEventListener
(IEventListener listener) This method will add the passed event listener to the list of listeners.protected void
addReferrer
(EntityValue instanceId, String attribute) boolean
addValue
(String attributeName, ISingleValue singleValue) This function will add the designated value to the existing profile's value.boolean
clearValue
(String attributeName) Clears the designated value, returning its state to UNKNOWN.boolean
protected IAttributeDefinition
getAttributeDefinition
(String attributeName) getAttributeState
(String attributeName) When the attribute is known, it will return the state of the attribute.This method caches the entityDefinition if it is null and returns the cached definition.protected IEventDispatcher
getId()
This method returns the unique ID of this instance.returns the instance identifier denoting this instance.getInstanceValue
(String attributeName) This method returns the instances that is referred to by the given attribute.getInstanceValues
(String attributeName) This method returns an array containing all the instances that are referred to by the given attribute.getName()
This method returns the unique name of the instance.getProperty
(String name) This method will return the value of the specified property.String[]
Returns the names of the properties.protected int
This method returns information about the instances that are referring this instance.int
This method returns a bit-mask containing all event types that are supported by this event channel.This method can be used to retrieve a value for an attribute of this instance in a non-type safe manner.int
hashCode()
boolean
hasProperty
(String name) This method will return a boolean indicating if a property with the specified name is present.boolean
instanceOf
(String entityName) This method checks if the instance is of the specified type.boolean
This method returns a boolean indicating if the instance has been deleted.boolean
This method returns a boolean indicating whether this instance is the singleton instance for its entity type.boolean
Checks whether the entity instance is a static instance.protected int
release()
boolean
removeEventListener
(IEventListener listener) This method will remove the specified event listener from the list of listeners.protected boolean
removeReferrer
(EntityValue instanceId, String attribute) boolean
removeValue
(String attributeName, ISingleValue singleValue) Removes a specified value from the multivalued-attribute.protected IEntityInstance
retain()
protected void
boolean
setProperty
(String name, IValue propertyValue) This method may be used to set the value of a property.boolean
This method sets the specified value for the given attribute.toString()
protected void
validateExclusiveness
(IRelationDefinition relation, IEntityInstance target) protected void
validateReference
(IRelationDefinition relation, IEntityInstance target)
-
Constructor Details
-
EntityInstance
protected EntityInstance(DefaultProfileFactory factory, IEntityDefinition definition, EntityValue id, InstanceType type, InstanceManager instanceManager) -
EntityInstance
protected EntityInstance(DefaultProfileFactory factory, IEntityInstance other, EntityValue id, InstanceManager instanceManager)
-
-
Method Details
-
setDeleted
protected void setDeleted() -
isDeleted
public boolean isDeleted()Description copied from interface:IEntityInstance
This method returns a boolean indicating if the instance has been deleted. A reference to a deleted instance may still be used, but certain methods will no longer be available. Any method that would modify the state of the instance, for example the setValue method, will throw an UnknownInstanceException when invoked on a deleted instance. Methods that return information about the state, for example the getValue method, will still be available.
Note: Deleted instances never refer to other instances, so the getInstanceValue(s) method will not be available. Requesting the value for any relation attribute on a deleted instance will always result in an unknown value.
- Specified by:
isDeleted
in interfaceIEntityInstance
- Returns:
- A boolean indicating if the instance has been deleted.
-
getEventDispatcher
-
getSupportedEvents
public int getSupportedEvents()Description copied from interface:IEventChannel
This method returns a bit-mask containing all event types that are supported by this event channel. The bit-mask is a bitwise OR of the diverse event types. To check whether a specific event-listener is supported, you can do the following:// This checks if a VALUE listener is supported if ((channel.getSupportedEvents() & IEvent.Mask.VALUE) != 0) { // VALUE event listeners that are supported }
- Specified by:
getSupportedEvents
in interfaceIEventChannel
- Returns:
- Bit-mask containing the event types that are supported by this event channel.
-
addEventListener
Description copied from interface:IEventChannel
This method will add the passed event listener to the list of listeners.- Specified by:
addEventListener
in interfaceIEventChannel
- Parameters:
listener
- The event listener that should be added.- Returns:
- boolean indicating is the listener was actually added.
-
removeEventListener
Description copied from interface:IEventChannel
This method will remove the specified event listener from the list of listeners.- Specified by:
removeEventListener
in interfaceIEventChannel
- Parameters:
listener
- The event listener that should be removed.- Returns:
- boolean indicating if the listener was actually removed.
-
getPropertyNames
Description copied from interface:IPropertyContainer
Returns the names of the properties.- Specified by:
getPropertyNames
in interfaceIPropertyContainer
- Returns:
- All available properties.
-
hasProperty
Description copied from interface:IPropertyContainer
This method will return a boolean indicating if a property with the specified name is present.- Specified by:
hasProperty
in interfaceIPropertyContainer
- Parameters:
name
- The name of the property that should be checked.- Returns:
- boolean indicating if a property with the specified name is present.
-
getProperty
Description copied from interface:IPropertyContainer
This method will return the value of the specified property.- Specified by:
getProperty
in interfaceIPropertyContainer
- Parameters:
name
- The name of the property whose value is requested.- Returns:
- The value of the property.
-
setProperty
Description copied from interface:IPropertyContainer
This method may be used to set the value of a property.- Specified by:
setProperty
in interfaceIPropertyContainer
- Parameters:
name
- The name of the property whose value should be set.propertyValue
- The new value of the property.- Returns:
- boolean indicating if the set operation was successful.
-
addReferrer
-
removeReferrer
-
getReferringInstances
Description copied from interface:IEntityInstance
This method returns information about the instances that are referring this instance. The InstanceReferrer objects can be used to determine what instance is referring this one, and through what attribute. The attribute by which this instance is referenced is needed, as an instance may have multiple references to another through different attributes.- Specified by:
getReferringInstances
in interfaceIEntityInstance
- Returns:
- Array of reference objects containing information about the referring instance.
-
getReferenceCount
protected int getReferenceCount() -
retain
-
release
protected int release() -
getEntityDefinition
This method caches the entityDefinition if it is null and returns the cached definition. The cachedEntityDefinition could be null after deserialization of the EntityInstance after it was stored in the session store.- Specified by:
getEntityDefinition
in interfaceIEntityInstance
- Returns:
- the cached entity definition
-
getId
Description copied from interface:IEntityInstance
This method returns the unique ID of this instance. The id of an instance is generated upon creation.- Specified by:
getId
in interfaceIEntityInstance
- Returns:
- long containing the unique identifier of this instance.
-
getName
Description copied from interface:IEntityInstance
This method returns the unique name of the instance. The name of an instance is either provided upon construction with createInstance, provided as a property of a static instance, or automatically generated when none was available.- Specified by:
getName
in interfaceIEntityInstance
- Returns:
- Unique name of the instance
-
getInstanceReference
Description copied from interface:IEntityInstance
returns the instance identifier denoting this instance.- Specified by:
getInstanceReference
in interfaceIEntityInstance
- Returns:
- EntityValue never null.
-
isSingletonInstance
public boolean isSingletonInstance()Description copied from interface:IEntityInstance
This method returns a boolean indicating whether this instance is the singleton instance for its entity type. A singleton instance always has the same id (zero), and is guaranteed to be the only instance of its type.- Specified by:
isSingletonInstance
in interfaceIEntityInstance
- Returns:
- boolean indicating whether this instance is the singleton instance for its entity type.
-
isStaticInstance
public boolean isStaticInstance()Description copied from interface:IEntityInstance
Checks whether the entity instance is a static instance. Static instances are defined in KnowledgeStudio and will always be present in the profile with the same name.- Specified by:
isStaticInstance
in interfaceIEntityInstance
- Returns:
- boolean indicating whether the entity instance is a static instance.
-
instanceOf
Description copied from interface:IEntityInstance
This method checks if the instance is of the specified type. The instance is considered to be of the given type when either the type matches the actual type directly, or when the actual type is a specialization of the supplied type.Example: An instance of polygon that extends shape will return true for the types polygon and shape, but false for the type square (which extends the polygon type).
This method is the direct equivalent of getEntityDefinition().typeOf( String entityName ).- Specified by:
instanceOf
in interfaceIEntityInstance
- Parameters:
entityName
- The name of the entity type that should be used to check this instance against.- Returns:
- boolean indicating if the instance is either directly of the supplied type, or extends the type.
-
getValue
Description copied from interface:IEntityInstance
This method can be used to retrieve a value for an attribute of this instance in a non-type safe manner.- DataType.Boolean returns a BooleanValue
- DataType.Currency returns a DoubleValue
- DataType.Date returns a DateValue
- DataType.Number returns a NumberValue
- DataType.Integer returns a IntegerValue
- DataType.Percentage returns a DoubleValue
- DataType.String returns a StringValue
- DataType.Domain returns a StringValue containing the short value, and has the display value as well.
- DataType.Entity returns an EntityValue object denoting the instance this relation was pointing to.
- If the value was not answered the return value is as specified but on the IValue object the isUnknown function renders true
- If the value was answered and the single value was
null
the return value is not null, but the isUnknown function results in true - If the value is a multivalued attribute a collection containing the only the object types listed above.
- Specified by:
getValue
in interfaceIEntityInstance
- Parameters:
attributeName
- String (without the entity name)- Returns:
- The value for the specified attribute name.
-
addValue
Description copied from interface:IEntityInstance
This function will add the designated value to the existing profile's value. If there was one, otherwise a single value is put in. Duplicate values are not allowed, and invoking this method with a value that is already present in the attribute has no effect.- Specified by:
addValue
in interfaceIEntityInstance
- Parameters:
attributeName
- The name of the attribute to which the value should be added.singleValue
- The value that should be added to the attribute specified.- Returns:
- boolean indicating whether the value was actually added (a duplicate value will result in false).
-
setValue
Description copied from interface:IEntityInstance
This method sets the specified value for the given attribute. Possible objects to pass to this method:- IEntityInstance denoting an instance.
- EntityValue denoting an instance.
- Number/NumberValue/IntegerValue/Currency/Percentage denoting one of [ number, currency, percentage ]
- Boolean/BooleanValue denoting a boolean type.
- Date/DateValue/DateTimeValue denoting a date object
- String/StringValue denoting a string object, domain's short value
- Collection containing any combination of above. Mixed is allowed i.e. [ EntityValue, IEntityInstance ]
- Object[] containing any combination of above. Mixed is allowed i.e. [ EntityValue, IEntityInstance ]
- Specified by:
setValue
in interfaceIEntityInstance
- Parameters:
attributeName
- the attribute name, preferredname
instead ofPerson.name
objValue
- The objects value to set as value (can be null).- Returns:
- Boolean indicating whether the value of the attribute did change.
-
validateExclusiveness
-
validateReference
- Parameters:
relation
- the relation that needs to be validatedtarget
- the targetIEntityInstance
to validate
-
removeValue
Description copied from interface:IEntityInstance
Removes a specified value from the multivalued-attribute. Possible datatypes for singleValue:- DataType.IEntityInstance denoting an instance.
- DataType.EntityValue denoting an instance.
- DataType.Number denoting one of [ domainValueId, number, currency, percentage ]
- DataType.Boolean denoting a boolean type.
- DataType.Date denoting a date object
- DataType.String denoting a string object, domain's short value
- Specified by:
removeValue
in interfaceIEntityInstance
- Parameters:
attributeName
- the attribute name ( without the entity name )singleValue
- The value that should be removed.- Returns:
- boolean if the value was found in the original value list.
-
clearValue
Description copied from interface:IEntityInstance
Clears the designated value, returning its state to UNKNOWN.- Specified by:
clearValue
in interfaceIEntityInstance
- Parameters:
attributeName
- String the attribute name.- Returns:
- boolean true whether the attribute-value was changed by this action.
-
getAttributeState
Description copied from interface:IEntityInstance
When the attribute is known, it will return the state of the attribute.- Specified by:
getAttributeState
in interfaceIEntityInstance
- Parameters:
attributeName
- String Preferably without the entity name- Returns:
- The state information of the attribute.
-
getInstanceValue
Description copied from interface:IEntityInstance
This method returns the instances that is referred to by the given attribute. If the attribute does not refer to an instance, a null value is returned.- Specified by:
getInstanceValue
in interfaceIEntityInstance
- Parameters:
attributeName
- The name of the attribute containing the instance.- Returns:
- The IEntityInstance referred to by the attribute.
-
getInstanceValues
Description copied from interface:IEntityInstance
This method returns an array containing all the instances that are referred to by the given attribute. If the attribute does not refer to any instance, an empty array is returned.- Specified by:
getInstanceValues
in interfaceIEntityInstance
- Parameters:
attributeName
- The name of the attribute containing the instances.- Returns:
- An array containing all the instances that are referred to by the attribute.
-
getAttributeDefinition
-
equals
-
hashCode
public int hashCode() -
toString
-