org.micropsi.common.consoleservice
Class ConsoleServiceProvider

java.lang.Object
  extended byorg.micropsi.common.consoleservice.ConsoleServiceProvider

public class ConsoleServiceProvider
extends java.lang.Object


Nested Class Summary
protected  class ConsoleServiceProvider.StoredQuestionWrapper
          Wrapper class for "stored questions".
 
Constructor Summary
ConsoleServiceProvider(AnswerFactoryIF defFact, Logger logger)
          Creates the ConsoleServiceProvider and sets the AnswerFactoryIF that will create the answer objects.
 
Method Summary
 java.util.ArrayList answerQuestions(java.util.ArrayList questions, long step)
          Answers a list of given questions.
 java.util.ArrayList answerStoredQuestions(java.lang.String forComponent, long step)
          Answers all stored questions for the given component or all components.
 java.lang.String[] getKnownQuestionTypes()
          Returns the names of the registered questionTypes.
 void registerQuestionType(ConsoleQuestionTypeIF newQuestionType)
          Convenience method for registering question types without the "override" flag.
 void registerQuestionType(ConsoleQuestionTypeIF newQuestionType, boolean override)
          Registers a ConsoleQuestionTypeIF so the ConsoleServiceProvider can be asked such questions.
 void shutdown()
          removes all stored questions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsoleServiceProvider

public ConsoleServiceProvider(AnswerFactoryIF defFact,
                              Logger logger)
Creates the ConsoleServiceProvider and sets the AnswerFactoryIF that will create the answer objects.

Parameters:
defFact - the AnswerFactoryIF to be used with this ConsoleServiceProvider.
Method Detail

registerQuestionType

public void registerQuestionType(ConsoleQuestionTypeIF newQuestionType,
                                 boolean override)
                          throws MicropsiException
Registers a ConsoleQuestionTypeIF so the ConsoleServiceProvider can be asked such questions.

Parameters:
newQuestionType - the QuestionType to be added.
override - if true, an already registered questionType with the same ID is overriden without warning.
Throws:
MicropsiException - 20 if there is already a questionType registered with the same questionName and override is false

registerQuestionType

public void registerQuestionType(ConsoleQuestionTypeIF newQuestionType)
                          throws MicropsiException
Convenience method for registering question types without the "override" flag. Calling this is equivalent to calling registerQuestionType(newQuestionType,false);

Parameters:
newQuestionType - the new question type
Throws:
MicropsiException - 20 if there is already a questionType registered with the same questionName

answerStoredQuestions

public java.util.ArrayList answerStoredQuestions(java.lang.String forComponent,
                                                 long step)
Answers all stored questions for the given component or all components.

Parameters:
forComponent - component filter: answer only stored questions from this component. null for all.
step - the current netsteü
Returns:
a list of AnswerIFs

answerQuestions

public java.util.ArrayList answerQuestions(java.util.ArrayList questions,
                                           long step)
Answers a list of given questions.

Parameters:
questions - An ArrayList of questions. All objects in the list must be QuestionIFs. Can be null.
step - The current simulation step
Returns:
An ArrayList of AnswerIFs.
Throws:
java.lang.ClassCastException - if there is anything within the questions parameter that is no QuestionIF

getKnownQuestionTypes

public java.lang.String[] getKnownQuestionTypes()
Returns the names of the registered questionTypes.

Returns:
An array with the registered questionType names. Will not be null.

shutdown

public void shutdown()
removes all stored questions


(c) by Micropsi Project: http://www.cognitive-agents.org

.