Class Entity
java.lang.Object
com.inductiveautomation.rm.base.RMListenerList
com.inductiveautomation.rm.base.RMObject
com.inductiveautomation.snap.data.Entity
- All Implemented Interfaces:
Archivable
,RMJSONArchiver.GetKeys
,RMKey.Get
,RMPropertyChanger
,PropertyChangeListener
,Cloneable
,EventListener
public class Entity
extends RMObject
implements PropertyChangeListener, RMKey.Get, RMJSONArchiver.GetKeys, Archivable
This class represents an entity for a data source. It has a list of properties, some of which are simple
attributes and some of which are relationships.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProperty
(Property aProperty) Adds a given property.void
addProperty
(Property... theProperties) Adds given properties.void
addProperty
(Property aProperty, int anIndex) Adds a given property at given index.clone()
Standard clone implementation.void
delete()
Saves this entity from its source.boolean
Standard equals method.fromBytes
(byte[] theBytes) Returns entity from bytes.fromXML
(RXArchiver anArchiver, RXElement anElement) XML unarchival.getAttribute
(int anIndex) Returns the attribute at the given index.getAttribute
(String aName) Returns the attribute with the given name.int
Returns the number of attributes.getAttributeSorted
(int anIndex) Returns the attribute at the given index in a sorted attributes list.Returns the key/key-chain to the property(s) that returns best string description of an entity instance.Returns a guess of descriptor key (or the actual one, if set).Returns a named entity using entity resolver.Returns the class that this entity represents.boolean
Returns whether entity exists in data source (has been saved and, if so, not deleted).Returns keys to archive JSON.getKeyPathProperty
(String aKeyPath) Returns the property with the given name.getKeyValue
(String aKey) RMKey.Get implementation to return Property for key.getName()
Returns the name of the entity.Returns the list of primary attributes for this entity.Returns the primary key property.Returns the list of properties.getProperty
(int anIndex) Returns the property at the given index.getProperty
(String aName) Returns the property with the given name.int
Returns the number of properties.getRelation
(int anIndex) Returns the relation at the given index.getRelation
(String aName) Returns the relation for the given key path.int
Returns the number of relations in the entity.Returns the list of relations in the entity.getRelationSorted
(int anIndex) Returns the relation at the given index in the sorted list of relations.Returns the schema that owns this entity.void
propertyChange
(PropertyChangeEvent anEvent) PropertyChangeListener implementation to forward property changes to entity property change listener.removeProperty
(int anIndex) Removes a property at given index.int
removeProperty
(Property aProperty) Removes the given property.void
save()
Saves the entity to its source.void
setDescriptorKey
(String aValue) Sets the key/key-chain to the property(s) that returns best string description of an entity instance.void
setEntityClass
(Class aClass) Sets the class that this entity represents.void
setExists
(boolean aFlag) Sets whether entity exists in data source (has been saved and, if so, not deleted).void
Sets the name of the entity.void
setProperties
(List<Property> theProps) Sets a list of properties.void
Sets the schema that owns this entity.byte[]
toBytes()
Returns bytes for this entity.toString()
Returns a string representation of entity (its name).toXML
(RXArchiver anArchiver) XML archival.Methods inherited from class com.inductiveautomation.rm.base.RMObject
addPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener, sendPropertyChange
Methods inherited from class com.inductiveautomation.rm.base.RMListenerList
addListener, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListener
-
Field Details
-
Name_Prop
- See Also:
-
Exists_Prop
- See Also:
-
-
Constructor Details
-
Entity
public Entity()Creates an empty entity. -
Entity
Creates an entity with the given name.
-
-
Method Details
-
getSchema
Returns the schema that owns this entity. -
setSchema
Sets the schema that owns this entity. -
getEntity
Returns a named entity using entity resolver. -
getName
Returns the name of the entity. -
setName
Sets the name of the entity. -
getExists
public boolean getExists()Returns whether entity exists in data source (has been saved and, if so, not deleted). -
setExists
public void setExists(boolean aFlag) Sets whether entity exists in data source (has been saved and, if so, not deleted). -
getPropertyCount
public int getPropertyCount()Returns the number of properties. -
getProperty
Returns the property at the given index. -
getProperties
Returns the list of properties. -
setProperties
Sets a list of properties. -
addProperty
Adds a given property. -
addProperty
Adds a given property at given index. -
addProperty
Adds given properties. -
removeProperty
Removes a property at given index. -
removeProperty
Removes the given property. -
getProperty
Returns the property with the given name. -
getAttributeCount
public int getAttributeCount()Returns the number of attributes. -
getAttribute
Returns the attribute at the given index. -
getAttribute
Returns the attribute with the given name. -
getRelationCount
public int getRelationCount()Returns the number of relations in the entity. -
getRelation
Returns the relation at the given index. -
getRelations
Returns the list of relations in the entity. -
getRelation
Returns the relation for the given key path. -
getAttributeSorted
Returns the attribute at the given index in a sorted attributes list. -
getRelationSorted
Returns the relation at the given index in the sorted list of relations. -
getPrimary
Returns the primary key property. -
getPrimaries
Returns the list of primary attributes for this entity. -
getEntityClass
Returns the class that this entity represents. -
setEntityClass
Sets the class that this entity represents. -
getKeyPathProperty
Returns the property with the given name. -
getKeyValue
RMKey.Get implementation to return Property for key.- Specified by:
getKeyValue
in interfaceRMKey.Get
-
getDescriptorKey
Returns the key/key-chain to the property(s) that returns best string description of an entity instance. -
setDescriptorKey
Sets the key/key-chain to the property(s) that returns best string description of an entity instance. -
getDescriptorKeyGuess
Returns a guess of descriptor key (or the actual one, if set). -
propertyChange
PropertyChangeListener implementation to forward property changes to entity property change listener.- Specified by:
propertyChange
in interfacePropertyChangeListener
-
equals
Standard equals method. -
clone
Standard clone implementation.- Overrides:
clone
in classRMListenerList
-
toXML
XML archival.- Specified by:
toXML
in interfaceArchivable
-
fromXML
XML unarchival.- Specified by:
fromXML
in interfaceArchivable
-
toBytes
@Nullable public byte[] toBytes()Returns bytes for this entity. -
fromBytes
Returns entity from bytes.- Throws:
RMJSONReader.RMJSONException
-
save
Saves the entity to its source.- Throws:
Exception
-
delete
Saves this entity from its source.- Throws:
Exception
-
getJSONKeys
Returns keys to archive JSON.- Specified by:
getJSONKeys
in interfaceRMJSONArchiver.GetKeys
-
toString
Returns a string representation of entity (its name).
-