ucot.model.object
Class Entity

java.lang.Object
  extended by ucot.model.object.Entity
All Implemented Interfaces:
java.io.Serializable

public class Entity
extends java.lang.Object
implements java.io.Serializable

This class represents entity in analyze model.

Author:
pajumasu
See Also:
Serialized Form

Field Summary
private  java.util.Map<java.lang.String,Attribute> attributes
          Maps attribute names and attributes.
private  java.util.Set<Entity> childEntities
          The child entities.
(package private)  boolean deleted
          Marks if this entity is deleted or not.
private  java.util.Map<java.lang.String,Method> methods
          Maps method names and methods.
private  java.lang.String name
          The name of this entity.
private  java.util.Set<Entity> parentEntities
          The parent entities.
static long serialVersionUID
           
private  java.lang.String type
          The type of the entity.
 
Constructor Summary
Entity(java.lang.String name)
           Creates the entity.
 
Method Summary
 void addAttribute(Attribute attribute)
           Adds attribute.
 void addAttribute(java.lang.String name, Attribute attribute)
           Adds attribute for this entity
 void addChild(Entity entity)
           Adds child for this Entity.
 void addMethod(Method method)
           Adds method for this entity.
 void addMethod(java.lang.String methodName)
           Creates and adds Method for this Entity using given name.
 void addParent(Entity entity)
           Adds parent for this Entity.
private  void checkEntityCollection(java.util.Collection<Entity> col)
          Removes deleted entites from given collection.
 Attribute getAttribute(java.lang.String name)
           Returns attribute called name.
 java.util.Set<Attribute> getAttributes()
           Returns all the attributes.
 java.util.Set<Entity> getChildren()
           Returns the children of this entity.
 Method getMethod(java.lang.String methodName)
           Returns Method of this Entity that is called 'name'.
 java.util.Set<java.lang.String> getMethodNames()
           Returns the names of the methods.
 java.util.Set<Method> getMethods()
           Get all the methods of this Entity.
 java.lang.String getName()
           Returns the name of this entity.
 java.util.Set<Entity> getParents()
           Returns the parent entities of this entity.
 java.lang.String getType()
           Return the type of this entity.
 void removeAttribute(Attribute toBeRemoved)
           Removes given attribute.
 void removeAttribute(java.lang.String name)
           Removes attribute called name.
 void removeChild(Entity entity)
           Removes child of this entity and also removes this entity from the parent list of a given entity if nessesary.
 void removeMethod(java.lang.String methodName)
           Removes method called 'name'.
 void removeParent(Entity entity)
           Removes parent of this entity and also removes this entity from the child list of a given entity if nessesary.
protected  void setName(java.lang.String name)
           Sets the name of the entity.
 void setType(java.lang.String type)
           Sets the type for this entity.
private  void updateAttributes()
           Removes deleted entities from the attribute list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

attributes

private java.util.Map<java.lang.String,Attribute> attributes
Maps attribute names and attributes. Attribute names are not in use currently.


methods

private java.util.Map<java.lang.String,Method> methods
Maps method names and methods.


childEntities

private java.util.Set<Entity> childEntities
The child entities.


parentEntities

private java.util.Set<Entity> parentEntities
The parent entities.


name

private java.lang.String name
The name of this entity.


type

private java.lang.String type
The type of the entity.


deleted

boolean deleted
Marks if this entity is deleted or not. Because there are many references to entities inside the model it is easier to mark entity deletet when its is removed from the model and the unnessesary references are removed when they are needed. This way we dont need to know all the places for the references and remove them on site when entity is deleted.

Constructor Detail

Entity

public Entity(java.lang.String name)

Creates the entity.

The name is modified so that the first letter is always an uppercase letter.

Parameters:
name - Name of this entity.
Method Detail

setName

protected void setName(java.lang.String name)

Sets the name of the entity.

The name is modified so that the first letter is always an uppercase letter.

Parameters:
name - Name of this entity.

updateAttributes

private void updateAttributes()

Removes deleted entities from the attribute list.


addAttribute

public void addAttribute(java.lang.String name,
                         Attribute attribute)

Adds attribute for this entity

Parameters:
name - Name of the Attribute.
attribute - The Attribute to add.

getAttribute

public Attribute getAttribute(java.lang.String name)

Returns attribute called name.

Parameters:
name - Name of the Attribute to return.
Returns:
The Attribute called 'name'.

getAttributes

public java.util.Set<Attribute> getAttributes()

Returns all the attributes.

Returns:
Attributes of this entity in a Set.

removeAttribute

public void removeAttribute(java.lang.String name)

Removes attribute called name.

Parameters:
name - Name of the attribute to remove.

removeAttribute

public void removeAttribute(Attribute toBeRemoved)

Removes given attribute.

Parameters:
toBeRemoved - Attribute that should be removed.

addAttribute

public void addAttribute(Attribute attribute)

Adds attribute.

Attributes name is set based on the name of the entity defined in attribute.

Parameters:
attribute - Attribute to add.

getName

public java.lang.String getName()

Returns the name of this entity.

Returns:
Name of this entity.

checkEntityCollection

private void checkEntityCollection(java.util.Collection<Entity> col)
Removes deleted entites from given collection.

Parameters:
col - Collection of entities.

getParents

public java.util.Set<Entity> getParents()

Returns the parent entities of this entity.

Returns:
Parent entities of this entity.

getChildren

public java.util.Set<Entity> getChildren()

Returns the children of this entity.

Returns:
Set of children of this entity.

addParent

public void addParent(Entity entity)

Adds parent for this Entity. Also adds this entity as a child of the given entity if nessesary.

Parameters:
entity - Entity that should be added as parent.

addChild

public void addChild(Entity entity)

Adds child for this Entity. Also adds this entity as a parent of the given entity if nessesary

Parameters:
entity - Entity that should be added as child.

removeParent

public void removeParent(Entity entity)

Removes parent of this entity and also removes this entity from the child list of a given entity if nessesary.

Parameters:
entity - Entity that should be removed from this entitys parents.

removeChild

public void removeChild(Entity entity)

Removes child of this entity and also removes this entity from the parent list of a given entity if nessesary.

Parameters:
entity - Entity that should be removed from this entitys children.

getMethod

public Method getMethod(java.lang.String methodName)

Returns Method of this Entity that is called 'name'.

Parameters:
methodName - Name of the Method.
Returns:
method Method called 'name'.

addMethod

public void addMethod(java.lang.String methodName)

Creates and adds Method for this Entity using given name.

Parameters:
methodName - Name of the Method to add.

addMethod

public void addMethod(Method method)

Adds method for this entity.

Parameters:
method - Method to add.

removeMethod

public void removeMethod(java.lang.String methodName)

Removes method called 'name'.

Parameters:
methodName - Name of the method to remove.

getMethodNames

public java.util.Set<java.lang.String> getMethodNames()

Returns the names of the methods.

Returns:
Set of method names of this Entity.

getType

public java.lang.String getType()

Return the type of this entity.

Returns:
The type of this entity.

setType

public void setType(java.lang.String type)

Sets the type for this entity.

Parameters:
type - The type

getMethods

public java.util.Set<Method> getMethods()

Get all the methods of this Entity.

Returns:
Set of Methods of this Entity.