baf655620e
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@678 542714f4-19e9-0310-aa3c-eee0fc999fb1
64 lines
1.9 KiB
Java
64 lines
1.9 KiB
Java
//
|
|
// $Id: MisoSceneRuleSet.java,v 1.4 2001/11/29 19:31:12 mdb Exp $
|
|
|
|
package com.threerings.miso.tools.scene.xml;
|
|
|
|
import org.apache.commons.digester.Digester;
|
|
import org.apache.commons.digester.RuleSetBase;
|
|
|
|
import com.samskivert.xml.SetFieldRule;
|
|
|
|
import com.threerings.miso.scene.MisoSceneModel;
|
|
|
|
/**
|
|
* Used to parse a {@link MisoSceneModel} from XML.
|
|
*/
|
|
public class MisoSceneRuleSet extends RuleSetBase
|
|
{
|
|
/**
|
|
* Configures the rule set to match scenes with the supplied prefix.
|
|
* For example, passing <code>scene.miso</code> will match the scene
|
|
* in the following XML file:
|
|
*
|
|
* <pre>
|
|
* <scene>
|
|
* <miso>
|
|
* <width>50</width>
|
|
* <height>50</height>
|
|
* <!-- ... -->
|
|
* </miso>
|
|
* </scene>
|
|
* </pre>
|
|
*/
|
|
public void setPrefix (String prefix)
|
|
{
|
|
_prefix = prefix;
|
|
}
|
|
|
|
/**
|
|
* Adds the necessary rules to the digester to parse our miso scene
|
|
* data.
|
|
*/
|
|
public void addRuleInstances (Digester digester)
|
|
{
|
|
// this creates the appropriate instance when we encounter our
|
|
// prefix tag
|
|
digester.addObjectCreate(_prefix, MisoSceneModel.class.getName());
|
|
|
|
// set up rules to parse and set our fields
|
|
digester.addRule(_prefix + "/width",
|
|
new SetFieldRule(digester, "width"));
|
|
digester.addRule(_prefix + "/height",
|
|
new SetFieldRule(digester, "height"));
|
|
digester.addRule(_prefix + "/base",
|
|
new SetFieldRule(digester, "baseTileIds"));
|
|
digester.addRule(_prefix + "/fringe",
|
|
new SetFieldRule(digester, "fringeTileIds"));
|
|
digester.addRule(_prefix + "/object",
|
|
new SetFieldRule(digester, "objectTileIds"));
|
|
}
|
|
|
|
/** The prefix at which me match our scenes. */
|
|
protected String _prefix;
|
|
}
|