Package org.powertac.logtool.common
Class DomainObjectReader
- java.lang.Object
-
- org.powertac.logtool.common.DomainObjectReader
-
@Service public class DomainObjectReader extends Object
Processor for state log entries; creates domain object instances, stores them in repositories as well as in a master repo indexed by id value.- Author:
- John Collins
-
-
Constructor Summary
Constructors Constructor Description DomainObjectReader()Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddIncludesOnly(String classname)Adds classname to list of classes to be included by this reader, after first ensuring that it's not in the ignores listObjectgetById(long id)booleangetInstantiate()intgetTimeslotPause()ObjectreadObject(String line)Converts a line from the log to an object.voidregisterMessageListener(LogtoolContext listener, Class<?> type)Registers the given LogtoolContext as a messageListener.voidregisterNewObjectListener(NewObjectListener listener, Class<?> type)Registers a NewObjectListener.voidreset()Restores the Reader to initial conditionsvoidsetInstantiate(boolean flag)Sets the instantiation flag.voidsetSchema(HashMap<String,String[]> schema)Sets the schema for this log.voidsetTimeslotPause(int msec)Sets the per-timeslot pause value in msec
-
-
-
Method Detail
-
reset
public void reset()
Restores the Reader to initial conditions
-
setTimeslotPause
public void setTimeslotPause(int msec)
Sets the per-timeslot pause value in msec
-
getTimeslotPause
public int getTimeslotPause()
-
addIncludesOnly
public void addIncludesOnly(String classname)
Adds classname to list of classes to be included by this reader, after first ensuring that it's not in the ignores list
-
setInstantiate
public void setInstantiate(boolean flag)
Sets the instantiation flag. If true, then objects read from the log are instantiated in the current running environment. This is the normal case for re-running games.
-
getInstantiate
public boolean getInstantiate()
-
registerNewObjectListener
public void registerNewObjectListener(NewObjectListener listener, Class<?> type)
Registers a NewObjectListener. The listener will be called with each newly-created object of the given type. If type is null, then the listener will be called for each new object.
-
registerMessageListener
public void registerMessageListener(LogtoolContext listener, Class<?> type)
Registers the given LogtoolContext as a messageListener. Incoming messages must be dispatched using util.MessageDispatcher
-
readObject
public Object readObject(String line) throws MissingDomainObject
Converts a line from the log to an object. Each line is of the form
ms:class::id::method{::arg}*Note that some objects cannot be resolved in the order they appear in a logfile, because they have forward dependencies. This means that a failure to resolve an object does not necessarily mean it's bogus, but could mean that it could be resolved at a later time, typically within one or a very few input lines.- Throws:
MissingDomainObject
-
getById
public Object getById(long id)
-
-