org.molwind.model
Class BaseWorldEntity

java.lang.Object
  extended by org.molwind.model.BaseWorldEntity
All Implemented Interfaces:
WorldEntity
Direct Known Subclasses:
PlacedWorldEntity

public class BaseWorldEntity
extends java.lang.Object
implements WorldEntity

BaseWorldEntity provides a basic implementation of a world entity.

Version:
1.0
Author:
Oliver Karch

Field Summary
protected  java.util.ArrayList relationships
           
 
Constructor Summary
protected BaseWorldEntity()
           
 
Method Summary
 void addRelationship(Relationship relation)
          Adds a relationship object to this entity.
 boolean existRelationship(Relationship relation)
          Tests whether the given relationship already exists.
 java.lang.Object getAttribute(java.lang.String name)
          Returns the value of the attribute with the given name.
 int getDimension()
          Returns 0 for this kind of entity
 Relationship[] getRelationship(Relationship relation)
          Searches the relationships for the given relationship.
 java.util.Iterator getRelationships()
          Returns an iterator of relationship objects.
 void putAttribute(java.lang.String name, java.lang.Object value)
          Sets the value of the attribute with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

relationships

protected java.util.ArrayList relationships
Constructor Detail

BaseWorldEntity

protected BaseWorldEntity()
Method Detail

putAttribute

public void putAttribute(java.lang.String name,
                         java.lang.Object value)
Sets the value of the attribute with the given name.

Specified by:
putAttribute in interface WorldEntity
Parameters:
name - the name of the attribute
value - the value of the attribute

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the value of the attribute with the given name.

Specified by:
getAttribute in interface WorldEntity
Parameters:
name - the name of the attribute
Returns:
the value of the attribute

getRelationships

public java.util.Iterator getRelationships()
Returns an iterator of relationship objects.

Specified by:
getRelationships in interface WorldEntity
Returns:
an iterator of relationship objects

existRelationship

public boolean existRelationship(Relationship relation)
Tests whether the given relationship already exists.

Parameters:
relation - the relationship to be tested
Returns:
true if the relationship already exists, false otherwise

addRelationship

public void addRelationship(Relationship relation)
Adds a relationship object to this entity.

Parameters:
relation - the relationship to be added

getRelationship

public Relationship[] getRelationship(Relationship relation)
Searches the relationships for the given relationship.

Parameters:
relation - the query relationship
Returns:
a possibly empty array of relationship(s) matching the query

getDimension

public int getDimension()
Returns 0 for this kind of entity

Specified by:
getDimension in interface WorldEntity
Returns:
int 0


Copyright © 2008-2010. All Rights Reserved.