thinkmap.client
Class EntityType

java.lang.Object
  extended by thinkmap.expression.runtime.PropertyHandler
      extended by thinkmap.client.EntityType
All Implemented Interfaces:
IPropertyHandler

public class EntityType
extends PropertyHandler

Every entity in Thinkmap has an EntityType. EntityTypes are similar to Prototypes in JavaScript. A property set on an EntityType is available to all entities that have that EntityType as a parent. This allows the user to easily implement things like "make all entities that represent employees blue."

EntityTypes belong to a SourceManager, and are identified by a unique name. EntityTypes can be chained, in which case, they have a "super" EntityType, which is the name of the EntityType that they inherit their properties from.

EntityTypes may also contain Entity metadata, which is metadata about the Entities that belong to that EntityType. Metadata consists of two parts, id metadata and property metadata. Id metadata is information about the id's of Entities that belong to this type. Specifically, the number of keys and their types. Property metadata is information about the types of properties that the entities of this type will have.

EntityTypes can also be serialized to/from an IDataSource, via the writeTo() method.

Version:
$Revision: 1.16 $

Field Summary
protected  Byte cacheFlag
           
protected  Hashtable providedProperties
           
 
Fields inherited from class thinkmap.expression.runtime.PropertyHandler
parent
 
Constructor Summary
EntityType()
          Creates a new EntityType object.
EntityType(String entityType, String superType)
          Creates a new EntityType object.
 
Method Summary
 void addProperty(Property pp)
          Adds a property to this EntityType that was configured via XML.
 void addPropertyMD(Property pp)
          Adds metadata this EntityType that was configured via XML.
 Property createProperty()
          Create a property for configuration that will later be added via the addProperty() method.
 Property createPropertyMD()
          Create metadata for configuration that will later be added via the addMetadata() method.
 Object getAttribute(String name)
          Get an attribute from the EntityType
 Class[] getIdMetadata()
          Returns the EntityId that describes the Entities that belong to this EntityType.
 Property[] getMetadata()
           
 String getName()
          Get the name of this EntityType
 Object getPropertyAttribute(String propertyName, String attributeName)
          Get an attribute of a provided property
 Object getPropertyMDAttribute(String propertyName, String attributeName)
          Get an attribute of a provided property
 Enumeration getPropertyMetadataNames()
          Gets the names of the properties that have been defined via the setMetadata method.
 Property[] getProvidedProperties()
           
 String getSuperType()
          Get the super type of this EntityType.
 boolean isCached()
          Returns true if entities of this type are cached.
 void setAttribute(String name, Object value)
          Set an attribute on the EntityType
 void setAttributes(Hashtable cache)
          Set many attributes at once
 void setCached(boolean cache)
          Set to true if all entities of this type should be cached.
 void setIdMetadata(Class[] id)
          Sets the classes that describe the types of the keys of entities that belong to this entity type.
 void setName(String s)
          Set the name of this EntityType.
 void setSuperType(String s)
          Set the name of the super type of this EntityType
 String toString()
           
 void updateFrom(EntityType other)
          Update with values from another copy of this EntityType
protected  void writePersistedProperties(IEntityHandler handler, SourceEntity entity)
          Write all properties to an IEntityHandler if they are supposed to be persisted.
 void writeTo(IEntityHandler handler)
          Serialize this EntityType over the given IEntityHandler
 
Methods inherited from class thinkmap.expression.runtime.PropertyHandler
copyTo, getLocalProperty, getLocalPropertyNames, getNextPropertyHandler, getProperty, getPropertyNames, main, propertyUpdated, removeProperty, setCaching, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

providedProperties

protected Hashtable providedProperties

cacheFlag

protected Byte cacheFlag
Constructor Detail

EntityType

public EntityType()
Creates a new EntityType object.


EntityType

public EntityType(String entityType,
                  String superType)
Creates a new EntityType object.

Parameters:
entityType - the name of this EntityType
superType - the name of this EntityType's parent EntityType, or null if there is none
Method Detail

createProperty

public Property createProperty()
Create a property for configuration that will later be added via the addProperty() method.

Returns:
a property for configuration via XML

createPropertyMD

public Property createPropertyMD()
Create metadata for configuration that will later be added via the addMetadata() method.

Returns:

addProperty

public void addProperty(Property pp)
                 throws Exception
Adds a property to this EntityType that was configured via XML.

Parameters:
pp - a property to add to this EntityType
Throws:
Exception

addPropertyMD

public void addPropertyMD(Property pp)
Adds metadata this EntityType that was configured via XML.

Parameters:
pp - a property to add to this EntityType

getPropertyMetadataNames

public Enumeration getPropertyMetadataNames()
Gets the names of the properties that have been defined via the setMetadata method.

Returns:
the names of the properties that have been defined via the setMetadata method.

getPropertyAttribute

public Object getPropertyAttribute(String propertyName,
                                   String attributeName)
Get an attribute of a provided property


getPropertyMDAttribute

public Object getPropertyMDAttribute(String propertyName,
                                     String attributeName)
Get an attribute of a provided property


getIdMetadata

public Class[] getIdMetadata()
Returns the EntityId that describes the Entities that belong to this EntityType. Note: all of the id's keys must be of the type java.lang.Class.

Returns:
the EntityId that describes the Entities that belong to this EntityType.

setIdMetadata

public void setIdMetadata(Class[] id)
Sets the classes that describe the types of the keys of entities that belong to this entity type. Note: all of the id's keys must be of the type java.lang.Class. TODO: Update this description and remove the @xmlconfig.ignore tag

Parameters:
id - the EntityId that describes the Entities that belong to this EntityType.

getName

public String getName()
Get the name of this EntityType

Returns:
name

setName

public void setName(String s)
Set the name of this EntityType.

Parameters:
s - new name

getSuperType

public String getSuperType()
Get the super type of this EntityType.

Returns:
super type's name

setSuperType

public void setSuperType(String s)
Set the name of the super type of this EntityType

Parameters:
s - new super type name

writeTo

public void writeTo(IEntityHandler handler)
Serialize this EntityType over the given IEntityHandler

Parameters:
handler - the handler to write to.

toString

public String toString()
Overrides:
toString in class Object

getProvidedProperties

public Property[] getProvidedProperties()

getMetadata

public Property[] getMetadata()

setAttribute

public void setAttribute(String name,
                         Object value)
Set an attribute on the EntityType


setAttributes

public void setAttributes(Hashtable cache)
Set many attributes at once


getAttribute

public Object getAttribute(String name)
Get an attribute from the EntityType


setCached

public void setCached(boolean cache)
Set to true if all entities of this type should be cached. The default behavior is true which means entities will be stored until they are reaped by the source manager.

Parameters:
cache -

isCached

public boolean isCached()
Returns true if entities of this type are cached.

Returns:

updateFrom

public void updateFrom(EntityType other)
Update with values from another copy of this EntityType


writePersistedProperties

protected void writePersistedProperties(IEntityHandler handler,
                                        SourceEntity entity)
Write all properties to an IEntityHandler if they are supposed to be persisted. This will write all of the properties of this EntityType as well as its parent (whether it's an EntityType or the SourceManager).

Parameters:
handler - The place to write the properties
entity - The entity being written.


Copyright © 2013 Thinkmap, Inc. All Rights Reserved.