cz.cuni.amis.pogamut.base.communication.translator.impl
Class WorldMessageTranslator

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.communication.translator.impl.WorldMessageTranslator
All Implemented Interfaces:
IWorldChangeEventOutput, IComponent

public class WorldMessageTranslator
extends java.lang.Object
implements IWorldChangeEventOutput

Abstract class for translators between world messages (InfoObjects) and IWorldEvents. It implements IWorldEventOutput interface meaning it can be given to the mediator as the source for IWorldEvents. It is constructed with parser that should provide parsed messages (translated text messages from the world to the java object wrappers) + IWorldMessageHandler that is given those parsed messages to produce IWorldEvents. It should process those messages into IWorldEvents and return them.

Ignores IComponentControlHelper.startPaused(), performs IComponentControlHelper.start() in both start cases.


Field Summary
static Token COMPONENT_ID
           
protected  IWorldMessageTranslator handler
           
protected  LogCategory log
           
protected  IWorldMessageParser parser
          Parser of the world messages, may be used to get additional messages.
 
Constructor Summary
WorldMessageTranslator(IWorldMessageParser parser, IWorldMessageTranslator messageHandler, IComponentBus eventBus, IAgentLogger logger)
           
 
Method Summary
 Token getComponentId()
          Unique identification of the component.
 IWorldChangeEvent getEvent()
          Returns next event of the world.
 java.util.logging.Logger getLog()
           
protected  IWorldChangeEvent[] processMessage(InfoMessage message)
          Method for translating messages into events.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPONENT_ID

public static final Token COMPONENT_ID

parser

protected IWorldMessageParser parser
Parser of the world messages, may be used to get additional messages.


log

protected LogCategory log

handler

protected IWorldMessageTranslator handler
Constructor Detail

WorldMessageTranslator

@Inject
public WorldMessageTranslator(IWorldMessageParser parser,
                                     IWorldMessageTranslator messageHandler,
                                     IComponentBus eventBus,
                                     IAgentLogger logger)
Method Detail

getComponentId

public Token getComponentId()
Description copied from interface: IComponent
Unique identification of the component.

Specified by:
getComponentId in interface IComponent
Returns:

getLog

public java.util.logging.Logger getLog()

processMessage

protected IWorldChangeEvent[] processMessage(InfoMessage message)
                                      throws TranslatorException
Method for translating messages into events.

Parameters:
message -
Returns:
Throws:
WorldMessageHandlerException
TranslatorException

getEvent

public IWorldChangeEvent getEvent()
                           throws ComponentNotRunningException,
                                  ComponentPausedException
Description copied from interface: IWorldChangeEventOutput
Returns next event of the world.

May block.

Specified by:
getEvent in interface IWorldChangeEventOutput
Returns:
Throws:
ComponentNotRunningException
ComponentPausedException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object