The KnownSpace Datamanager
"Halfway To Anywhere"


An Active Entity Value Example

import org.datamanager.activeentityvalue.ActiveEntityValue;
import org.datamanager.kernel.Entity;
import org.datamanager.exception.DataManagerException;
import org.datamanager.entityvalue.IntegerEntityValue;

public class ExampleActiveEntityValue implements ActiveEntityValue
   {
   //remember which entity this active entity value works on
   private Entity entity;

   public ExampleActiveEntityValue(Entity entity)
      {
      /*
      Set the entity this active entity value works on.
      (Note that this may be different from the entity
      that this active entity value is stored in)
      */

      this.entity = entity;
      }

   public EntityValue getEntityValue()
      throws DataManagerException
      {
      /*
      Report an EntityValue containing the number of attributes
      currently attached to the entity that this active entity value
      works on.
      */

      Entity[] attributes = entity.getAttributes();
      int numberOfAttributes = attributes.length;

      return new IntegerEntityValue(numberOfAttributes);
      }
   }