Atavism Version 2018.1AGIS API

atavism.server.objects
Class Entity

java.lang.Object
  extended by atavism.server.objects.NamedPropertyClass
      extended by atavism.server.objects.Entity
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AgisGroup, AgisGroupMember, AgisQuest, AOObject, Bag, Claim.ClaimEntity, ClassAbilityObject, CombatInfo, FactionStateInfo, Instance, InventoryInfo, ObjectManagerPlugin.MasterObject, ObjectStub, Pet, Purse, QuestStateInfo, ResourceNode.ResourceNodeEntity, ResourceNodeGroup.ResourceNodeEntity, Road, SocialInfo, SpawnData, VolumetricRegion.ResourceNodeEntity, WorldManagerPlugin.WorldManagerInstance

public class Entity
extends NamedPropertyClass
implements java.io.Serializable

Entity is the root class of persistable objects in the Atavism heirarchy. All entities have a unique object ID (OID). Uniqueness is guaranteed through the OIDManager which typically grabs blocks of unallocated IDs from the database.

Examples of Entities include players, monsters, weapons, armor, quests, and templates. Non-persisted configuration data is typically not an entity.

See Also:
Serialized Form

Field Summary
protected static Logger log
          Logger for this object, used to log info/debug messages.
static java.util.concurrent.locks.Lock staticLock
          Dont use this, will probably be moved.
protected  java.lang.Integer subObjectNamespacesInt
          This is the set of sub-object namespaces, compressed into an Integer by using one bit for each Namespace.
protected static java.util.Set<java.lang.Object> transientPropertyKeys
          A set of key values that are always stored in the transient map; all others are always stored in the persistent map
protected  ObjectType type
           
 
Fields inherited from class atavism.server.objects.NamedPropertyClass
lock, name
 
Constructor Summary
Entity()
          Creates an entity and assigns it a new OID.
Entity(OID oid)
          Creates an entity using the passed in OID.
Entity(java.lang.String name)
          Creates an entity with the given name, and assigns it a new OID.
 
Method Summary
 void addSubObjectNamespace(Namespace namespace)
           
static boolean equals(Entity obj1, Entity obj2)
          Returns if two objects are the same - tested by comparing the object id and namespace.
 boolean equals(java.lang.Object other)
          Returns if two objects are the same - tested by comparing the object id.
 java.util.concurrent.locks.Lock getLock()
          Returns the lock for this entity.
 Namespace getNamespace()
          Returns the namespace containing the entity
 OID getOid()
          Returns OID for this Entity
 boolean getPersistenceFlag()
          Returns true if the object has been marked persistent. saved objects maintain this state
 java.io.Serializable getProperty(java.lang.String key)
          If the key is in the transientPropertyKeys set, get the value associated with the key from the transientMap; otherwise get it from the persistent map
 java.util.List<Namespace> getSubObjectNamespaces()
          Get a list of the sub-object Namespace objects associated with the Entity.
 java.lang.Integer getSubObjectNamespacesInt()
          Get the subObjectNamespacesInt; exists only to provide a JavaBean interface, so that the database code will persist the Integer.
 java.util.Map<java.lang.String,java.io.Serializable> getTransientDataRef()
           
 ObjectType getType()
          Entity object type.
 int hashCode()
          Returns the OID as hashcode since it is unique.
 boolean hasSubObjectNamespace(Namespace namespace)
           
 boolean isDeleted()
           
static java.lang.Object registerTransientPropertyKey(java.lang.Object key)
          Adds an object to the transientPropertyKeys map
 java.io.Serializable removeProperty(java.lang.String key)
          Remove the named property.
 void removeSubObjectNamespace(Namespace namespace)
           
 void setDeleted()
           
 void setNamespace(Namespace namespace)
          Sets the entity's namespace
 void setOid(OID oid)
          Sets the OID for this entity.
 void setPersistenceFlag(boolean flag)
          mark this object as being persistent or not. other systems will check this field and save the object to the database when appropriate.
 java.io.Serializable setProperty(java.lang.String key, java.io.Serializable value)
          If the key is in the transientPropertyKeys set, store the key/value pair in the transientMap; otherwise store it in the persistent map
 void setSubObjectNamespaces(java.util.Set<Namespace> namespaces)
          Set the sub-object Namespace objects associated with the Entity.
 void setSubObjectNamespacesInt(java.lang.Integer value)
          Set the subObjectNamespacesInt; exists only to provide a JavaBean interface, so that the database code will persist the Integer.
 void setType(ObjectType type)
          Set the Entity object type.
 byte[] toBytes()
          Serializes this entity and returns the byte array.
 java.lang.String toString()
          Returns the string describing this entity, useful for logging.
static void unregisterTransientPropertyKey(java.lang.Object key)
          Removes an object to the transientPropertyKeys set
 
Methods inherited from class atavism.server.objects.NamedPropertyClass
getBooleanProperty, getIntProperty, getName, getPropertyMap, getPropertyMapRef, getStringProperty, lock, modifyIntProperty, setName, setPropertyMap, setupTransient, unlock
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

transientPropertyKeys

protected static java.util.Set<java.lang.Object> transientPropertyKeys
A set of key values that are always stored in the transient map; all others are always stored in the persistent map


subObjectNamespacesInt

protected java.lang.Integer subObjectNamespacesInt
This is the set of sub-object namespaces, compressed into an Integer by using one bit for each Namespace.


log

protected static final Logger log
Logger for this object, used to log info/debug messages.


type

protected ObjectType type

staticLock

public static java.util.concurrent.locks.Lock staticLock
Dont use this, will probably be moved. Lock for all entities map.

Constructor Detail

Entity

public Entity()
Creates an entity and assigns it a new OID.


Entity

public Entity(java.lang.String name)
Creates an entity with the given name, and assigns it a new OID.

Parameters:
name - name for the entity.

Entity

public Entity(OID oid)
Creates an entity using the passed in OID. This is typically used when loading a saved entity from the database since you want to set the OID to match what was saved.

Parameters:
oid - OID for the constructed entity
Method Detail

toString

public java.lang.String toString()
Returns the string describing this entity, useful for logging.

Overrides:
toString in class java.lang.Object
Returns:
string describing entity

hashCode

public int hashCode()
Returns the OID as hashcode since it is unique.

Overrides:
hashCode in class java.lang.Object

getOid

public OID getOid()
Returns OID for this Entity

Returns:
oid for this Entity

setOid

public void setOid(OID oid)
Sets the OID for this entity. This generally should not be used since it means the old OID is thrown away and probably wasted. Try to use the constructor which takes in an OID instead.

Parameters:
oid - the OID to set for this entity.

getType

public ObjectType getType()
Entity object type.

Returns:
ObjectTypes.unknown if no object type has been set.

setType

public void setType(ObjectType type)
Set the Entity object type.


getTransientDataRef

public java.util.Map<java.lang.String,java.io.Serializable> getTransientDataRef()

equals

public static boolean equals(Entity obj1,
                             Entity obj2)
Returns if two objects are the same - tested by comparing the object id and namespace. null objects are never equal to any other object including other null objects.


equals

public boolean equals(java.lang.Object other)
Returns if two objects are the same - tested by comparing the object id. null objects are never equal to any other object including other null objects.

Overrides:
equals in class java.lang.Object

setPersistenceFlag

public void setPersistenceFlag(boolean flag)
mark this object as being persistent or not. other systems will check this field and save the object to the database when appropriate.


getPersistenceFlag

public boolean getPersistenceFlag()
Returns true if the object has been marked persistent. saved objects maintain this state


getNamespace

public Namespace getNamespace()
Returns the namespace containing the entity


setNamespace

public void setNamespace(Namespace namespace)
Sets the entity's namespace


getSubObjectNamespaces

public java.util.List<Namespace> getSubObjectNamespaces()
Get a list of the sub-object Namespace objects associated with the Entity.

Returns:
List of Namespace objects

setSubObjectNamespaces

public void setSubObjectNamespaces(java.util.Set<Namespace> namespaces)
Set the sub-object Namespace objects associated with the Entity.

Parameters:
namespaces - A list of Namespace objects

addSubObjectNamespace

public void addSubObjectNamespace(Namespace namespace)

removeSubObjectNamespace

public void removeSubObjectNamespace(Namespace namespace)

hasSubObjectNamespace

public boolean hasSubObjectNamespace(Namespace namespace)

getLock

public java.util.concurrent.locks.Lock getLock()
Returns the lock for this entity. Be careful when using the lock, since it can easily lead to a deadlock.

Returns:
A Lock object.

toBytes

public byte[] toBytes()
Serializes this entity and returns the byte array.

Returns:
byte array for serialized entity

setProperty

public java.io.Serializable setProperty(java.lang.String key,
                                        java.io.Serializable value)
If the key is in the transientPropertyKeys set, store the key/value pair in the transientMap; otherwise store it in the persistent map

Overrides:
setProperty in class NamedPropertyClass
Returns:
old value for given key or null if none ever set.

removeProperty

public java.io.Serializable removeProperty(java.lang.String key)
Description copied from class: NamedPropertyClass
Remove the named property.

Overrides:
removeProperty in class NamedPropertyClass
Parameters:
key - serializable key object.
Returns:
old value for given key or null if none ever set.

getProperty

public java.io.Serializable getProperty(java.lang.String key)
If the key is in the transientPropertyKeys set, get the value associated with the key from the transientMap; otherwise get it from the persistent map

Overrides:
getProperty in class NamedPropertyClass
Parameters:
key - serializable key object.
Returns:
value of the property, null if property does not exist.
Throws:
java.lang.InterruptedException
See Also:
NamedPropertyClass.setProperty(String, Serializable)

isDeleted

public boolean isDeleted()

setDeleted

public void setDeleted()

registerTransientPropertyKey

public static java.lang.Object registerTransientPropertyKey(java.lang.Object key)
Adds an object to the transientPropertyKeys map


unregisterTransientPropertyKey

public static void unregisterTransientPropertyKey(java.lang.Object key)
Removes an object to the transientPropertyKeys set


getSubObjectNamespacesInt

public java.lang.Integer getSubObjectNamespacesInt()
Get the subObjectNamespacesInt; exists only to provide a JavaBean interface, so that the database code will persist the Integer.


setSubObjectNamespacesInt

public void setSubObjectNamespacesInt(java.lang.Integer value)
Set the subObjectNamespacesInt; exists only to provide a JavaBean interface, so that the database code will persist the Integer.



Copyright © 2018 Dragonsan Studios Sp. z o.o.