Brought things up to date with the latest Jakarta Commons world order.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3058 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-07-13 16:34:49 +00:00
parent a6f57205d7
commit 1da753e14d
16 changed files with 119 additions and 138 deletions
@@ -1,5 +1,5 @@
// //
// $Id: BundledComponentRepository.java,v 1.32 2004/07/03 03:41:21 mdb Exp $ // $Id: BundledComponentRepository.java,v 1.33 2004/07/13 16:34:49 mdb Exp $
package com.threerings.cast.bundle; package com.threerings.cast.bundle;
@@ -18,7 +18,7 @@ import com.samskivert.util.HashIntMap;
import com.samskivert.util.IntIntMap; import com.samskivert.util.IntIntMap;
import com.samskivert.util.Tuple; import com.samskivert.util.Tuple;
import org.apache.commons.collections.FilterIterator; import org.apache.commons.collections.iterators.FilterIterator;
import org.apache.commons.collections.Predicate; import org.apache.commons.collections.Predicate;
import com.threerings.resource.ResourceBundle; import com.threerings.resource.ResourceBundle;
@@ -1,5 +1,5 @@
// //
// $Id: ActionRuleSet.java,v 1.2 2002/06/26 23:53:07 mdb Exp $ // $Id: ActionRuleSet.java,v 1.3 2004/07/13 16:34:49 mdb Exp $
package com.threerings.cast.tools.xml; package com.threerings.cast.tools.xml;
@@ -60,14 +60,13 @@ public class ActionRuleSet extends RuleSetBase
ActionSequence.class.getName()); ActionSequence.class.getName());
// grab the name attribute from the <action> tag // grab the name attribute from the <action> tag
digester.addRule(_prefix + ACTION_PATH, digester.addRule(_prefix + ACTION_PATH, new SetPropertyFieldsRule());
new SetPropertyFieldsRule(digester));
// grab the other attributes from their respective tags // grab the other attributes from their respective tags
digester.addRule(_prefix + ACTION_PATH + "/framesPerSecond", digester.addRule(_prefix + ACTION_PATH + "/framesPerSecond",
new SetFieldRule(digester, "framesPerSecond")); new SetFieldRule("framesPerSecond"));
CallMethodSpecialRule origin = new CallMethodSpecialRule(digester) { CallMethodSpecialRule origin = new CallMethodSpecialRule() {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
throws Exception { throws Exception {
int[] coords = StringUtil.parseIntArray(bodyText); int[] coords = StringUtil.parseIntArray(bodyText);
@@ -82,7 +81,7 @@ public class ActionRuleSet extends RuleSetBase
}; };
digester.addRule(_prefix + ACTION_PATH + "/origin", origin); digester.addRule(_prefix + ACTION_PATH + "/origin", origin);
CallMethodSpecialRule orient = new CallMethodSpecialRule(digester) { CallMethodSpecialRule orient = new CallMethodSpecialRule() {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
throws Exception { throws Exception {
ActionSequence seq = ((ActionSequence)target); ActionSequence seq = ((ActionSequence)target);
@@ -1,5 +1,5 @@
// //
// $Id: ClassRuleSet.java,v 1.2 2002/12/16 03:08:39 mdb Exp $ // $Id: ClassRuleSet.java,v 1.3 2004/07/13 16:34:49 mdb Exp $
package com.threerings.cast.tools.xml; package com.threerings.cast.tools.xml;
@@ -56,13 +56,12 @@ public class ClassRuleSet extends RuleSetBase
ComponentClass.class.getName()); ComponentClass.class.getName());
// grab the attributes from the <class> tag // grab the attributes from the <class> tag
digester.addRule(_prefix + CLASS_PATH, digester.addRule(_prefix + CLASS_PATH, new SetPropertyFieldsRule());
new SetPropertyFieldsRule(digester));
// parse render priority overrides // parse render priority overrides
String opath = _prefix + CLASS_PATH + "/override"; String opath = _prefix + CLASS_PATH + "/override";
digester.addObjectCreate(opath, PriorityOverride.class.getName()); digester.addObjectCreate(opath, PriorityOverride.class.getName());
SetPropertyFieldsRule rule = new SetPropertyFieldsRule(digester); SetPropertyFieldsRule rule = new SetPropertyFieldsRule();
rule.addFieldParser("orients", new FieldParser() { rule.addFieldParser("orients", new FieldParser() {
public Object parse (String text) { public Object parse (String text) {
String[] orients = StringUtil.parseStringArray(text); String[] orients = StringUtil.parseStringArray(text);
@@ -1,5 +1,5 @@
// //
// $Id: ColorPositoryParser.java,v 1.1 2003/01/31 23:10:45 mdb Exp $ // $Id: ColorPositoryParser.java,v 1.2 2004/07/13 16:34:49 mdb Exp $
package com.threerings.media.image.tools.xml; package com.threerings.media.image.tools.xml;
@@ -34,13 +34,14 @@ public class ColorPositoryParser extends CompiledConfigParser
// create and configure class record instances // create and configure class record instances
String prefix = "colors/class"; String prefix = "colors/class";
digest.addObjectCreate(prefix, ClassRecord.class.getName()); digest.addObjectCreate(prefix, ClassRecord.class.getName());
digest.addRule(prefix, new SetPropertyFieldsRule(digest)); digest.addRule(prefix, new SetPropertyFieldsRule());
digest.addSetNext(prefix, "addClass", ClassRecord.class.getName()); digest.addSetNext(prefix, "addClass", ClassRecord.class.getName());
// create and configure color record instances // create and configure color record instances
prefix += "/color"; prefix += "/color";
digest.addRule(prefix, new Rule(digest) { digest.addRule(prefix, new Rule() {
public void begin (Attributes attributes) throws Exception { public void begin (String namespace, String name,
Attributes attributes) throws Exception {
// we want to inherit settings from the color class when // we want to inherit settings from the color class when
// creating the record, so we do some custom stuff // creating the record, so we do some custom stuff
ColorRecord record = new ColorRecord(); ColorRecord record = new ColorRecord();
@@ -49,11 +50,11 @@ public class ColorPositoryParser extends CompiledConfigParser
digester.push(record); digester.push(record);
} }
public void end () throws Exception { public void end (String namespace, String name) throws Exception {
digester.pop(); digester.pop();
} }
}); });
digest.addRule(prefix, new SetPropertyFieldsRule(digest)); digest.addRule(prefix, new SetPropertyFieldsRule());
digest.addSetNext(prefix, "addColor", ColorRecord.class.getName()); digest.addSetNext(prefix, "addColor", ColorRecord.class.getName());
} }
} }
@@ -1,5 +1,5 @@
// //
// $Id: SoundManager.java,v 1.72 2004/02/26 18:42:51 ray Exp $ // $Id: SoundManager.java,v 1.73 2004/07/13 16:34:49 mdb Exp $
package com.threerings.media.sound; package com.threerings.media.sound;
@@ -27,8 +27,7 @@ import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine; import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.UnsupportedAudioFileException;
import org.apache.commons.io.StreamUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.Constant;
import com.samskivert.util.Config; import com.samskivert.util.Config;
import com.samskivert.util.Interval; import com.samskivert.util.Interval;
@@ -735,7 +734,7 @@ public class SoundManager
InputStream stream = getTestClip(key); InputStream stream = getTestClip(key);
if (stream != null) { if (stream != null) {
data = new byte[1][]; data = new byte[1][];
data[0] = StreamUtils.streamAsBytes(stream, BUFFER_SIZE); data[0] = IOUtils.toByteArray(stream);
} else { } else {
// otherwise, randomize between all available sounds // otherwise, randomize between all available sounds
@@ -855,7 +854,7 @@ public class SoundManager
} }
} }
return StreamUtils.streamAsBytes(clipin, BUFFER_SIZE); return IOUtils.toByteArray(clipin);
} }
protected Config getConfig (SoundKey key) protected Config getConfig (SoundKey key)
@@ -1271,13 +1270,13 @@ public class SoundManager
protected HashMap _configs = new HashMap(); protected HashMap _configs = new HashMap();
/** Signals to the queue to do different things. */ /** Signals to the queue to do different things. */
protected Constant PLAY = new Constant("PLAY"); protected String PLAY = new String("PLAY");
protected Constant PLAYMUSIC = new Constant("PLAYMUSIC"); protected String PLAYMUSIC = new String("PLAYMUSIC");
protected Constant STOPMUSIC = new Constant("STOPMUSIC"); protected String STOPMUSIC = new String("STOPMUSIC");
protected Constant UPDATE_MUSIC_VOL = new Constant("UPDATE_MUSIC_VOL"); protected String UPDATE_MUSIC_VOL = new String("UPDATE_MUSIC_VOL");
protected Constant LOCK = new Constant("LOCK"); protected String LOCK = new String("LOCK");
protected Constant UNLOCK = new Constant("UNLOCK"); protected String UNLOCK = new String("UNLOCK");
protected Constant DIE = new Constant("DIE"); protected String DIE = new String("DIE");
/** A pref that specifies a directory for us to get test sounds from. */ /** A pref that specifies a directory for us to get test sounds from. */
protected static RuntimeAdjust.FileAdjust _testDir = protected static RuntimeAdjust.FileAdjust _testDir =
@@ -1298,9 +1297,6 @@ public class SoundManager
/** The queue size at which we start to ignore requests to play sounds. */ /** The queue size at which we start to ignore requests to play sounds. */
protected static final int MAX_QUEUE_SIZE = 25; protected static final int MAX_QUEUE_SIZE = 25;
/** The buffer size in bytes used when reading audio file data. */
protected static final int BUFFER_SIZE = 1024 * 16;
/** Used to disable sound entirely. */ /** Used to disable sound entirely. */
protected static final boolean SOUND_ENABLED = true; protected static final boolean SOUND_ENABLED = true;
@@ -1,5 +1,5 @@
// //
// $Id: TileSetBundler.java,v 1.19 2004/02/25 14:43:17 mdb Exp $ // $Id: TileSetBundler.java,v 1.20 2004/07/13 16:34:49 mdb Exp $
package com.threerings.media.tile.bundle.tools; package com.threerings.media.tile.bundle.tools;
@@ -20,7 +20,7 @@ import java.util.zip.Deflater;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.apache.commons.digester.Digester; import org.apache.commons.digester.Digester;
import org.apache.commons.io.StreamUtils; import org.apache.commons.io.CopyUtils;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import com.samskivert.io.NestableIOException; import com.samskivert.io.NestableIOException;
@@ -400,7 +400,7 @@ public class TileSetBundler
} else { } else {
jar.putNextEntry(new JarEntry(imagePath)); jar.putNextEntry(new JarEntry(imagePath));
FileInputStream imgin = new FileInputStream(ifile); FileInputStream imgin = new FileInputStream(ifile);
StreamUtils.pipe(imgin, jar); CopyUtils.copy(imgin, jar);
} }
} catch (Exception e) { } catch (Exception e) {
throw new NestableIOException( throw new NestableIOException(
@@ -1,5 +1,5 @@
// //
// $Id: ObjectTileSetRuleSet.java,v 1.10 2004/02/25 14:43:17 mdb Exp $ // $Id: ObjectTileSetRuleSet.java,v 1.11 2004/07/13 16:34:49 mdb Exp $
package com.threerings.media.tile.tools.xml; package com.threerings.media.tile.tools.xml;
@@ -47,7 +47,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/objectWidths", _prefix + TILESET_PATH + "/objectWidths",
new CallMethodSpecialRule(digester) { new CallMethodSpecialRule() {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
int[] widths = StringUtil.parseIntArray(bodyText); int[] widths = StringUtil.parseIntArray(bodyText);
@@ -57,7 +57,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/objectHeights", _prefix + TILESET_PATH + "/objectHeights",
new CallMethodSpecialRule(digester) { new CallMethodSpecialRule() {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
int[] heights = StringUtil.parseIntArray(bodyText); int[] heights = StringUtil.parseIntArray(bodyText);
@@ -66,8 +66,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
}); });
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/xOrigins", _prefix + TILESET_PATH + "/xOrigins", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
int[] xorigins = StringUtil.parseIntArray(bodyText); int[] xorigins = StringUtil.parseIntArray(bodyText);
@@ -76,8 +75,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
}); });
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/yOrigins", _prefix + TILESET_PATH + "/yOrigins", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
int[] yorigins = StringUtil.parseIntArray(bodyText); int[] yorigins = StringUtil.parseIntArray(bodyText);
@@ -87,7 +85,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/priorities", _prefix + TILESET_PATH + "/priorities",
new CallMethodSpecialRule(digester) { new CallMethodSpecialRule() {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
byte[] prios = StringUtil.parseByteArray(bodyText); byte[] prios = StringUtil.parseByteArray(bodyText);
@@ -96,8 +94,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
}); });
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/zations", _prefix + TILESET_PATH + "/zations", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
String[] zations = StringUtil.parseStringArray(bodyText); String[] zations = StringUtil.parseStringArray(bodyText);
@@ -106,8 +103,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
}); });
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/xspots", _prefix + TILESET_PATH + "/xspots", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
short[] xspots = StringUtil.parseShortArray(bodyText); short[] xspots = StringUtil.parseShortArray(bodyText);
@@ -116,8 +112,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
}); });
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/yspots", _prefix + TILESET_PATH + "/yspots", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
short[] yspots = StringUtil.parseShortArray(bodyText); short[] yspots = StringUtil.parseShortArray(bodyText);
@@ -126,8 +121,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
}); });
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/sorients", _prefix + TILESET_PATH + "/sorients", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
ObjectTileSet set = (ObjectTileSet)target; ObjectTileSet set = (ObjectTileSet)target;
@@ -1,5 +1,5 @@
// //
// $Id: SwissArmyTileSetRuleSet.java,v 1.10 2004/02/25 14:43:17 mdb Exp $ // $Id: SwissArmyTileSetRuleSet.java,v 1.11 2004/07/13 16:34:49 mdb Exp $
package com.threerings.media.tile.tools.xml; package com.threerings.media.tile.tools.xml;
@@ -42,8 +42,7 @@ public class SwissArmyTileSetRuleSet extends TileSetRuleSet
super.addRuleInstances(digester); super.addRuleInstances(digester);
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/widths", _prefix + TILESET_PATH + "/widths", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
int[] widths = StringUtil.parseIntArray(bodyText); int[] widths = StringUtil.parseIntArray(bodyText);
@@ -52,8 +51,7 @@ public class SwissArmyTileSetRuleSet extends TileSetRuleSet
}); });
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/heights", _prefix + TILESET_PATH + "/heights", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
int[] heights = StringUtil.parseIntArray(bodyText); int[] heights = StringUtil.parseIntArray(bodyText);
@@ -63,7 +61,7 @@ public class SwissArmyTileSetRuleSet extends TileSetRuleSet
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/tileCounts", _prefix + TILESET_PATH + "/tileCounts",
new CallMethodSpecialRule(digester) { new CallMethodSpecialRule() {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
int[] tileCounts = StringUtil.parseIntArray(bodyText); int[] tileCounts = StringUtil.parseIntArray(bodyText);
@@ -72,8 +70,7 @@ public class SwissArmyTileSetRuleSet extends TileSetRuleSet
}); });
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/offsetPos", _prefix + TILESET_PATH + "/offsetPos", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
int[] values = StringUtil.parseIntArray(bodyText); int[] values = StringUtil.parseIntArray(bodyText);
@@ -88,8 +85,7 @@ public class SwissArmyTileSetRuleSet extends TileSetRuleSet
}); });
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/gapSize", _prefix + TILESET_PATH + "/gapSize", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
int[] values = StringUtil.parseIntArray(bodyText); int[] values = StringUtil.parseIntArray(bodyText);
@@ -1,5 +1,5 @@
// //
// $Id: XMLTileSetParser.java,v 1.8 2004/02/25 14:43:17 mdb Exp $ // $Id: XMLTileSetParser.java,v 1.9 2004/07/13 16:34:49 mdb Exp $
package com.threerings.media.tile.tools.xml; package com.threerings.media.tile.tools.xml;
@@ -58,8 +58,7 @@ public class XMLTileSetParser
// add a set next rule which will put tilesets with this prefix // add a set next rule which will put tilesets with this prefix
// into the array list that'll be on the top of the stack // into the array list that'll be on the top of the stack
_digester.addRule(prefix + TileSetRuleSet.TILESET_PATH, _digester.addRule(prefix + TileSetRuleSet.TILESET_PATH,
new ValidatedSetNextRule(_digester, new ValidatedSetNextRule("add", Object.class,
"add", Object.class,
ruleset)); ruleset));
} }
@@ -1,5 +1,5 @@
// //
// $Id: BaseTileSetRuleSet.java,v 1.10 2004/02/25 14:43:57 mdb Exp $ // $Id: BaseTileSetRuleSet.java,v 1.11 2004/07/13 16:34:49 mdb Exp $
package com.threerings.miso.tile.tools.xml; package com.threerings.miso.tile.tools.xml;
@@ -28,8 +28,7 @@ public class BaseTileSetRuleSet extends SwissArmyTileSetRuleSet
super.addRuleInstances(digester); super.addRuleInstances(digester);
digester.addRule( digester.addRule(
_prefix + TILESET_PATH + "/passable", _prefix + TILESET_PATH + "/passable", new CallMethodSpecialRule() {
new CallMethodSpecialRule(digester) {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
{ {
int[] values = StringUtil.parseIntArray(bodyText); int[] values = StringUtil.parseIntArray(bodyText);
@@ -1,5 +1,5 @@
// //
// $Id: FringeConfigurationParser.java,v 1.9 2004/02/25 14:43:57 mdb Exp $ // $Id: FringeConfigurationParser.java,v 1.10 2004/07/13 16:34:49 mdb Exp $
package com.threerings.miso.tile.tools.xml; package com.threerings.miso.tile.tools.xml;
@@ -43,33 +43,30 @@ public class FringeConfigurationParser extends CompiledConfigParser
{ {
// configure top-level constraints // configure top-level constraints
String prefix = "fringe"; String prefix = "fringe";
digest.addRule(prefix, new SetPropertyFieldsRule(digest)); digest.addRule(prefix, new SetPropertyFieldsRule());
// create and configure fringe config instances // create and configure fringe config instances
prefix += "/base"; prefix += "/base";
digest.addObjectCreate(prefix, FringeRecord.class.getName()); digest.addObjectCreate(prefix, FringeRecord.class.getName());
// you'd better match parens if you have any hope of wading ValidatedSetNextRule.Validator val;
// in these waters val = new ValidatedSetNextRule.Validator() {
digest.addRule(prefix, public boolean isValid (Object target) {
new ValidatedSetNextRule(digest, "addFringeRecord", if (((FringeRecord) target).isValid()) {
new ValidatedSetNextRule.Validator () { return true;
public boolean isValid (Object target) { } else {
if (((FringeRecord) target).isValid()) { Log.warning("A FringeRecord was not added because it was " +
return true; "improperly specified [rec=" + target + "].");
} else { return false;
Log.warning("A FringeRecord was not added " + }
"because it was improperly specified " + }
"[record=" + target + "]."); };
return false; ValidatedSetNextRule vrule;
} vrule = new ValidatedSetNextRule("addFringeRecord", val) {
} // parse the fringe record, converting tileset names to
}) { // tileset ids
// parse the fringe record, converting tileset names to tileset
// ids
public void begin (Attributes attrs) public void begin (Attributes attrs)
throws Exception throws Exception
{ {
FringeRecord frec = (FringeRecord) digester.peek(); FringeRecord frec = (FringeRecord) digester.peek();
@@ -96,27 +93,29 @@ public class FringeConfigurationParser extends CompiledConfigParser
} }
} }
} }
}); };
digest.addRule(prefix, vrule);
// create the tileset records in each fringe record // create the tileset records in each fringe record
prefix += "/tileset"; prefix += "/tileset";
digest.addObjectCreate(prefix, FringeTileSetRecord.class.getName()); digest.addObjectCreate(prefix, FringeTileSetRecord.class.getName());
digest.addRule(prefix, new ValidatedSetNextRule(digest, "addTileset",
new ValidatedSetNextRule.Validator() { val = new ValidatedSetNextRule.Validator() {
public boolean isValid (Object target) { public boolean isValid (Object target) {
if (((FringeTileSetRecord) target).isValid()) { if (((FringeTileSetRecord) target).isValid()) {
return true; return true;
} else { } else {
Log.warning("A FringeTileSetRecord was not added " + Log.warning("A FringeTileSetRecord was not added because " +
"because it was improperly specified."); "it was improperly specified " +
return false; "[rec=" + target + "].");
} return false;
} }
}) { }
};
vrule = new ValidatedSetNextRule("addTileset", val) {
// parse the fringe tilesetrecord, converting tileset names to ids // parse the fringe tilesetrecord, converting tileset names to ids
public void begin (Attributes attrs) public void begin (Attributes attrs)
throws Exception throws Exception
{ {
FringeTileSetRecord f = (FringeTileSetRecord) digester.peek(); FringeTileSetRecord f = (FringeTileSetRecord) digester.peek();
@@ -143,7 +142,8 @@ public class FringeConfigurationParser extends CompiledConfigParser
} }
} }
} }
}); };
digest.addRule(prefix, vrule);
} }
protected TileSetIDBroker _idBroker; protected TileSetIDBroker _idBroker;
@@ -1,5 +1,5 @@
// //
// $Id: SimpleMisoSceneRuleSet.java,v 1.1 2003/02/12 07:21:50 mdb Exp $ // $Id: SimpleMisoSceneRuleSet.java,v 1.2 2004/07/13 16:34:49 mdb Exp $
package com.threerings.miso.tools.xml; package com.threerings.miso.tools.xml;
@@ -34,21 +34,22 @@ public class SimpleMisoSceneRuleSet implements NestableRuleSet
{ {
// this creates the appropriate instance when we encounter our // this creates the appropriate instance when we encounter our
// prefix tag // prefix tag
dig.addRule(prefix, new Rule(dig) { dig.addRule(prefix, new Rule() {
public void begin (Attributes attributes) throws Exception { public void begin (String namespace, String name,
Attributes attributes) throws Exception {
digester.push(createMisoSceneModel()); digester.push(createMisoSceneModel());
} }
public void end () throws Exception { public void end (String namespace, String name) throws Exception {
digester.pop(); digester.pop();
} }
}); });
// set up rules to parse and set our fields // set up rules to parse and set our fields
dig.addRule(prefix + "/width", new SetFieldRule(dig, "width")); dig.addRule(prefix + "/width", new SetFieldRule("width"));
dig.addRule(prefix + "/height", new SetFieldRule(dig, "height")); dig.addRule(prefix + "/height", new SetFieldRule("height"));
dig.addRule(prefix + "/viewwidth", new SetFieldRule(dig, "vwidth")); dig.addRule(prefix + "/viewwidth", new SetFieldRule("vwidth"));
dig.addRule(prefix + "/viewheight", new SetFieldRule(dig, "vheight")); dig.addRule(prefix + "/viewheight", new SetFieldRule("vheight"));
dig.addRule(prefix + "/base", new SetFieldRule(dig, "baseTileIds")); dig.addRule(prefix + "/base", new SetFieldRule("baseTileIds"));
dig.addObjectCreate(prefix + "/objects", ArrayList.class.getName()); dig.addObjectCreate(prefix + "/objects", ArrayList.class.getName());
dig.addObjectCreate(prefix + "/objects/object", dig.addObjectCreate(prefix + "/objects/object",
@@ -56,10 +57,9 @@ public class SimpleMisoSceneRuleSet implements NestableRuleSet
dig.addSetNext(prefix + "/objects/object", "add", dig.addSetNext(prefix + "/objects/object", "add",
Object.class.getName()); Object.class.getName());
dig.addRule(prefix + "/objects/object", dig.addRule(prefix + "/objects/object", new SetPropertyFieldsRule());
new SetPropertyFieldsRule(dig));
dig.addRule(prefix + "/objects", new CallMethodSpecialRule(dig) { dig.addRule(prefix + "/objects", new CallMethodSpecialRule() {
public void parseAndSet (String bodyText, Object target) public void parseAndSet (String bodyText, Object target)
throws Exception throws Exception
{ {
@@ -1,5 +1,5 @@
// //
// $Id: SparseMisoSceneRuleSet.java,v 1.3 2004/02/25 14:43:57 mdb Exp $ // $Id: SparseMisoSceneRuleSet.java,v 1.4 2004/07/13 16:34:49 mdb Exp $
package com.threerings.miso.tools.xml; package com.threerings.miso.tools.xml;
@@ -33,29 +33,28 @@ public class SparseMisoSceneRuleSet implements NestableRuleSet
{ {
// this creates the appropriate instance when we encounter our // this creates the appropriate instance when we encounter our
// prefix tag // prefix tag
dig.addRule(prefix, new Rule(dig) { dig.addRule(prefix, new Rule() {
public void begin (Attributes attributes) throws Exception { public void begin (String namespace, String name,
Attributes attributes) throws Exception {
digester.push(createMisoSceneModel()); digester.push(createMisoSceneModel());
} }
public void end () throws Exception { public void end (String namespace, String name) throws Exception {
digester.pop(); digester.pop();
} }
}); });
// set up rules to parse and set our fields // set up rules to parse and set our fields
dig.addRule(prefix + "/swidth", new SetFieldRule(dig, "swidth")); dig.addRule(prefix + "/swidth", new SetFieldRule("swidth"));
dig.addRule(prefix + "/sheight", new SetFieldRule(dig, "sheight")); dig.addRule(prefix + "/sheight", new SetFieldRule("sheight"));
dig.addRule(prefix + "/defTileSet", dig.addRule(prefix + "/defTileSet", new SetFieldRule("defTileSet"));
new SetFieldRule(dig, "defTileSet"));
String sprefix = prefix + "/sections/section"; String sprefix = prefix + "/sections/section";
dig.addObjectCreate(sprefix, Section.class.getName()); dig.addObjectCreate(sprefix, Section.class.getName());
dig.addRule(sprefix, new SetPropertyFieldsRule(dig)); dig.addRule(sprefix, new SetPropertyFieldsRule());
dig.addRule(sprefix + "/base", new SetFieldRule(dig, "baseTileIds")); dig.addRule(sprefix + "/base", new SetFieldRule("baseTileIds"));
dig.addObjectCreate(sprefix + "/objects/object", dig.addObjectCreate(sprefix + "/objects/object",
ObjectInfo.class.getName()); ObjectInfo.class.getName());
dig.addRule(sprefix + "/objects/object", dig.addRule(sprefix + "/objects/object", new SetPropertyFieldsRule());
new SetPropertyFieldsRule(dig));
dig.addSetNext(sprefix + "/objects/object", "addObject", dig.addSetNext(sprefix + "/objects/object", "addObject",
ObjectInfo.class.getName()); ObjectInfo.class.getName());
dig.addSetNext(sprefix, "setSection", Section.class.getName()); dig.addSetNext(sprefix, "setSection", Section.class.getName());
@@ -1,12 +1,12 @@
// //
// $Id: DropBoard.java,v 1.4 2004/02/25 14:48:44 mdb Exp $ // $Id: DropBoard.java,v 1.5 2004/07/13 16:34:49 mdb Exp $
package com.threerings.puzzle.drop.data; package com.threerings.puzzle.drop.data;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import org.apache.commons.lang.Strings; import org.apache.commons.lang.StringUtils;
import com.threerings.util.DirectionUtil; import com.threerings.util.DirectionUtil;
@@ -513,7 +513,7 @@ public abstract class DropBoard extends Board
str += "|" + formatPiece(opiece); str += "|" + formatPiece(opiece);
} }
} }
buf.append(Strings.rightPad(str, padwid)); buf.append(StringUtils.rightPad(str, padwid));
} }
Log.warning(buf.toString()); Log.warning(buf.toString());
} }
@@ -1,5 +1,5 @@
// //
// $Id: SpotSceneRuleSet.java,v 1.4 2003/02/12 07:23:31 mdb Exp $ // $Id: SpotSceneRuleSet.java,v 1.5 2004/07/13 16:34:49 mdb Exp $
package com.threerings.whirled.spot.tools.xml; package com.threerings.whirled.spot.tools.xml;
@@ -28,13 +28,12 @@ public class SpotSceneRuleSet implements NestableRuleSet
digester.addObjectCreate(prefix, SpotSceneModel.class.getName()); digester.addObjectCreate(prefix, SpotSceneModel.class.getName());
// set up rules to parse and set our fields // set up rules to parse and set our fields
digester.addRule(prefix, new SetPropertyFieldsRule(digester)); digester.addRule(prefix, new SetPropertyFieldsRule());
// create EditablePortal instances when we see <portal> // create EditablePortal instances when we see <portal>
digester.addObjectCreate(prefix + "/portal", digester.addObjectCreate(prefix + "/portal",
EditablePortal.class.getName()); EditablePortal.class.getName());
digester.addRule(prefix + "/portal", digester.addRule(prefix + "/portal", new SetPropertyFieldsRule());
new SetPropertyFieldsRule(digester));
digester.addSetNext(prefix + "/portal", "addPortal", digester.addSetNext(prefix + "/portal", "addPortal",
Portal.class.getName()); Portal.class.getName());
} }
@@ -1,5 +1,5 @@
// //
// $Id: SceneRuleSet.java,v 1.4 2004/02/25 14:50:28 mdb Exp $ // $Id: SceneRuleSet.java,v 1.5 2004/07/13 16:34:49 mdb Exp $
package com.threerings.whirled.tools.xml; package com.threerings.whirled.tools.xml;
@@ -28,7 +28,7 @@ public class SceneRuleSet implements NestableRuleSet
digester.addObjectCreate(prefix, getSceneClass().getName()); digester.addObjectCreate(prefix, getSceneClass().getName());
// set up rules to parse and set our fields // set up rules to parse and set our fields
digester.addRule(prefix, new SetPropertyFieldsRule(digester)); digester.addRule(prefix, new SetPropertyFieldsRule());
} }
/** /**