public class XMLTraceBuilder extends XMLBuilder implements TraceFileWriter
Topology
.
This class is used, mainly, through methods inherited from XMLBuilder
. It calls
XMLTopologyBuilder.buildTopologyElement(org.w3c.dom.Document, io.jbotsim.core.Topology)
to build the element that stores the recorded Topology
.
Event of the Topology
are recorded using addTraceEvent(TraceEvent)
method.
XMLBuilder.BuilderException
DEFAULT_VERSION
Constructor and Description |
---|
XMLTraceBuilder(Topology tp)
|
Modifier and Type | Method and Description |
---|---|
void |
addTraceEvent(TraceEvent e)
Adds an event to the
document |
protected FileAsStream |
getFileAccessor() |
void |
write(String filename)
Outputs the current XML document into the specified file.
|
getDocument, writeToString
public XMLTraceBuilder(Topology tp) throws XMLBuilder.BuilderException
document
the trace
element that
stores the topology
tp
and the recorded events.
Since the trace may not exist before the creation of the document, events are stored one by one using
addTraceEvent(TraceEvent)
after the document has been built.tp
- the topology
that is traced.BuilderException
- is raised if an error occurs while the document is built.XMLBuilder.BuilderException
protected FileAsStream getFileAccessor()
public void write(String filename) throws XMLBuilder.BuilderException
write
in interface TraceFileWriter
filename
- the targeted output fileBuilderException
- raised either when an XML error occurs while the document is created or if an IO error
occurs.XMLBuilder.BuilderException
public void addTraceEvent(TraceEvent e)
document
addTraceEvent
in interface TraceFileWriter
e
- the event
added to the stored story