Implemented and/or cleaned up the XML scene writers.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@675 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-11-29 06:36:29 +00:00
parent f3eeae834a
commit 6bbce232b4
3 changed files with 123 additions and 6 deletions
@@ -0,0 +1,44 @@
//
// $Id: SceneWriter.java,v 1.1 2001/11/29 06:36:29 mdb Exp $
package com.threerings.whirled.tools.xml;
import org.xml.sax.SAXException;
import com.megginson.sax.DataWriter;
import com.samskivert.util.StringUtil;
import com.threerings.whirled.data.SceneModel;
/**
* Generates an XML representation of a {@link SceneModel}.
*/
public class SceneWriter
{
/**
* Writes the data for the supplied {@link SceneModel} to the XML
* writer supplied. The writer will already be configured with the
* appropriate indentation level so that this writer can simply output
* its elements and allow the calling code to determine where in the
* greater scene description file the scene data should live.
*/
public void writeScene (SceneModel model, DataWriter writer)
throws SAXException
{
writer.startElement("scene");
writeSceneData(model, writer);
writer.endElement("scene");
}
/**
* Writes just the scene data which is handy for derived classes which
* may wish to add their own scene data to the scene output.
*/
protected void writeSceneData (SceneModel model, DataWriter writer)
throws SAXException
{
writer.dataElement("sceneId", Integer.toString(model.sceneId));
writer.dataElement("version", Integer.toString(model.version));
writer.dataElement("neighborIds",
StringUtil.toString(model.neighborIds, "", ""));
}
}