public class Entity extends RMObject implements java.beans.PropertyChangeListener, RMKey.Get, RMJSONArchiver.GetKeys, Archivable
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
Exists_Prop |
static java.lang.String |
Name_Prop |
| Constructor and Description |
|---|
Entity()
Creates an empty entity.
|
Entity(java.lang.String aName)
Creates an entity with the given name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addProperty(Property... theProperties)
Adds given properties.
|
void |
addProperty(Property aProperty)
Adds a given property.
|
void |
addProperty(Property aProperty,
int anIndex)
Adds a given property at given index.
|
Entity |
clone()
Standard clone implementation.
|
void |
delete()
Saves this entity from its source.
|
boolean |
equals(java.lang.Object anObj)
Standard equals method.
|
Entity |
fromBytes(byte[] theBytes)
Returns entity from bytes.
|
Entity |
fromXML(RXArchiver anArchiver,
RXElement anElement)
XML unarchival.
|
Property |
getAttribute(int anIndex)
Returns the attribute at the given index.
|
Property |
getAttribute(java.lang.String aName)
Returns the attribute with the given name.
|
int |
getAttributeCount()
Returns the number of attributes.
|
Property |
getAttributeSorted(int anIndex)
Returns the attribute at the given index in a sorted attributes list.
|
java.lang.String |
getDescriptorKey()
Returns the key/key-chain to the property(s) that returns best string description of an entity instance.
|
java.lang.String |
getDescriptorKeyGuess()
Returns a guess of descriptor key (or the actual one, if set).
|
Entity |
getEntity(java.lang.String aName)
Returns a named entity using entity resolver.
|
java.lang.Class |
getEntityClass()
Returns the class that this entity represents.
|
boolean |
getExists()
Returns whether entity exists in data source (has been saved and, if so, not deleted).
|
java.util.List<java.lang.String> |
getJSONKeys()
Returns keys to archive JSON.
|
Property |
getKeyPathProperty(java.lang.String aKeyPath)
Returns the property with the given name.
|
java.lang.Object |
getKeyValue(java.lang.String aKey)
RMKey.Get implementation to return Property for key.
|
java.lang.String |
getName()
Returns the name of the entity.
|
java.util.List<Property> |
getPrimaries()
Returns the list of primary attributes for this entity.
|
Property |
getPrimary()
Returns the primary key property.
|
java.util.List<Property> |
getProperties()
Returns the list of properties.
|
Property |
getProperty(int anIndex)
Returns the property at the given index.
|
Property |
getProperty(java.lang.String aName)
Returns the property with the given name.
|
int |
getPropertyCount()
Returns the number of properties.
|
Property |
getRelation(int anIndex)
Returns the relation at the given index.
|
Property |
getRelation(java.lang.String aName)
Returns the relation for the given key path.
|
int |
getRelationCount()
Returns the number of relations in the entity.
|
java.util.List<Property> |
getRelations()
Returns the list of relations in the entity.
|
Property |
getRelationSorted(int anIndex)
Returns the relation at the given index in the sorted list of relations.
|
Schema |
getSchema()
Returns the schema that owns this entity.
|
void |
propertyChange(java.beans.PropertyChangeEvent anEvent)
PropertyChangeListener implementation to forward property changes to entity property change listener.
|
java.lang.Object |
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(java.lang.String aValue)
Sets the key/key-chain to the property(s) that returns best string description of an entity instance.
|
void |
setEntityClass(java.lang.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 |
setName(java.lang.String aName)
Sets the name of the entity.
|
void |
setProperties(java.util.List<Property> theProps)
Sets a list of properties.
|
void |
setSchema(Schema aSchema)
Sets the schema that owns this entity.
|
byte[] |
toBytes()
Returns bytes for this entity.
|
java.lang.String |
toString()
Returns a string representation of entity (its name).
|
RXElement |
toXML(RXArchiver anArchiver)
XML archival.
|
addPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener, sendPropertyChangeaddListener, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListenerpublic static final java.lang.String Name_Prop
public static final java.lang.String Exists_Prop
public Entity()
public Entity(java.lang.String aName)
public Schema getSchema()
public void setSchema(Schema aSchema)
public Entity getEntity(java.lang.String aName)
public java.lang.String getName()
public void setName(java.lang.String aName)
public boolean getExists()
public void setExists(boolean aFlag)
public int getPropertyCount()
public Property getProperty(int anIndex)
public java.util.List<Property> getProperties()
public void setProperties(java.util.List<Property> theProps)
public void addProperty(Property aProperty)
public void addProperty(Property aProperty, int anIndex)
public void addProperty(Property... theProperties)
public java.lang.Object removeProperty(int anIndex)
public int removeProperty(Property aProperty)
public Property getProperty(java.lang.String aName)
public int getAttributeCount()
public Property getAttribute(int anIndex)
public Property getAttribute(java.lang.String aName)
public int getRelationCount()
public Property getRelation(int anIndex)
public java.util.List<Property> getRelations()
public Property getRelation(java.lang.String aName)
public Property getAttributeSorted(int anIndex)
public Property getRelationSorted(int anIndex)
public Property getPrimary()
public java.util.List<Property> getPrimaries()
public java.lang.Class getEntityClass()
public void setEntityClass(java.lang.Class aClass)
public Property getKeyPathProperty(java.lang.String aKeyPath)
public java.lang.Object getKeyValue(java.lang.String aKey)
getKeyValue in interface RMKey.Getpublic java.lang.String getDescriptorKey()
public void setDescriptorKey(java.lang.String aValue)
public java.lang.String getDescriptorKeyGuess()
public void propertyChange(java.beans.PropertyChangeEvent anEvent)
propertyChange in interface java.beans.PropertyChangeListenerpublic boolean equals(java.lang.Object anObj)
equals in class java.lang.Objectpublic Entity clone()
clone in class RMListenerListpublic RXElement toXML(RXArchiver anArchiver)
toXML in interface Archivablepublic Entity fromXML(RXArchiver anArchiver, RXElement anElement)
fromXML in interface Archivablepublic byte[] toBytes()
public Entity fromBytes(byte[] theBytes) throws RMJSONReader.RMJSONException
RMJSONReader.RMJSONExceptionpublic void save()
throws java.lang.Exception
java.lang.Exceptionpublic void delete()
throws java.lang.Exception
java.lang.Exceptionpublic java.util.List<java.lang.String> getJSONKeys()
getJSONKeys in interface RMJSONArchiver.GetKeys