Use Joiner instead of StringBuilder.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@880 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -28,7 +28,7 @@ import com.threerings.util.Byte;
|
||||
import com.threerings.util.Comparable;
|
||||
import com.threerings.util.Hashable;
|
||||
import com.threerings.util.Integer;
|
||||
import com.threerings.util.StringBuilder;
|
||||
import com.threerings.util.Joiner;
|
||||
|
||||
import com.threerings.presents.dobj.DSet;
|
||||
import com.threerings.presents.dobj.DSet_Entry;
|
||||
@@ -168,30 +168,7 @@ public class Card
|
||||
return "BJ";
|
||||
|
||||
} else {
|
||||
var sb : StringBuilder = new StringBuilder();
|
||||
if (number >= 2 && number <= 9) {
|
||||
sb.append(number);
|
||||
|
||||
} else {
|
||||
switch (number) {
|
||||
case 10: sb.append('T'); break;
|
||||
case CardCodes.JACK: sb.append('J'); break;
|
||||
case CardCodes.QUEEN: sb.append('Q'); break;
|
||||
case CardCodes.KING: sb.append('K'); break;
|
||||
case CardCodes.ACE: sb.append('A'); break;
|
||||
default: sb.append('?'); break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (getSuit()) {
|
||||
case CardCodes.SPADES: sb.append('s'); break;
|
||||
case CardCodes.HEARTS: sb.append('h'); break;
|
||||
case CardCodes.CLUBS: sb.append('c'); break;
|
||||
case CardCodes.DIAMONDS: sb.append('d'); break;
|
||||
default: sb.append('?'); break;
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
return rankToString(number) + suitToString(getSuit());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +216,32 @@ public class Card
|
||||
out.writeByte(_value);
|
||||
}
|
||||
|
||||
protected function rankToString (rank :int) :String
|
||||
{
|
||||
if (rank >= 2 && rank <= 9) {
|
||||
return String(rank);
|
||||
}
|
||||
switch (rank) {
|
||||
case 10: return "T";
|
||||
case CardCodes.JACK: return "J";
|
||||
case CardCodes.QUEEN: return "Q";
|
||||
case CardCodes.KING: return "K";
|
||||
case CardCodes.ACE: return "A";
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
protected function suitToString (suit :int) :String
|
||||
{
|
||||
switch (suit) {
|
||||
case CardCodes.SPADES: return "s";
|
||||
case CardCodes.HEARTS: return "h";
|
||||
case CardCodes.CLUBS: return "c";
|
||||
case CardCodes.DIAMONDS: return "d";
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
/** The number of the card. */
|
||||
protected var _value :int;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ package com.threerings.parlor.data {
|
||||
import com.threerings.util.ArrayUtil;
|
||||
import com.threerings.util.ClassUtil;
|
||||
import com.threerings.util.Hashable;
|
||||
import com.threerings.util.Joiner;
|
||||
import com.threerings.util.Name;
|
||||
import com.threerings.util.StringBuilder;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
@@ -218,12 +218,9 @@ public class Table
|
||||
*/
|
||||
public function toString () :String
|
||||
{
|
||||
var buf :StringBuilder = new StringBuilder();
|
||||
buf.append(ClassUtil.shortClassName(this));
|
||||
buf.append(" [");
|
||||
toStringBuilder(buf);
|
||||
buf.append("]");
|
||||
return buf.toString();
|
||||
var j :Joiner = Joiner.createFor(this);
|
||||
toStringJoiner(j);
|
||||
return j.toString();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
@@ -259,14 +256,10 @@ public class Table
|
||||
/**
|
||||
* Helper method for toString, ripe for overrideability.
|
||||
*/
|
||||
protected function toStringBuilder (buf :StringBuilder) :void
|
||||
protected function toStringJoiner (j :Joiner) :void
|
||||
{
|
||||
buf.append("tableId=").append(tableId);
|
||||
buf.append(", lobbyOid=").append(lobbyOid);
|
||||
buf.append(", gameOid=").append(gameOid);
|
||||
buf.append(", players=").append(players == null ? "<null?>" : players.join());
|
||||
buf.append(", watchers=").append(watchers == null ? "<null?>" : watchers.join());
|
||||
buf.append(", config=").append(config);
|
||||
j.add("tableId", tableId, "lobbyOid", lobbyOid, "gameOid", gameOid,
|
||||
"players", players, "watchers", watchers, "config", config);
|
||||
}
|
||||
|
||||
/** A counter for assigning table ids. */
|
||||
|
||||
@@ -23,9 +23,9 @@ package com.threerings.parlor.game.data {
|
||||
|
||||
import com.threerings.util.ArrayUtil;
|
||||
import com.threerings.util.Integer;
|
||||
import com.threerings.util.Joiner;
|
||||
import com.threerings.util.langBoolean;
|
||||
import com.threerings.util.Name;
|
||||
import com.threerings.util.StringBuilder;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
@@ -230,11 +230,10 @@ public class GameObject extends PlaceObject
|
||||
return playerStatus == PLAYER_IN_PLAY;
|
||||
}
|
||||
|
||||
override protected function whichBuf (buf :StringBuilder) :void
|
||||
override protected function whichJoiner (j :Joiner) :void
|
||||
{
|
||||
super.whichBuf(buf);
|
||||
buf.append("(").append(players.join()).append(")");
|
||||
buf.append(":").append(state);
|
||||
super.whichJoiner(j);
|
||||
j.addArgs("(" + players.join() + ")", state);
|
||||
}
|
||||
|
||||
// // AUTO-GENERATED: METHODS START
|
||||
|
||||
@@ -23,7 +23,7 @@ package com.threerings.whirled.data {
|
||||
|
||||
import flash.errors.IllegalOperationError;
|
||||
|
||||
import com.threerings.util.StringBuilder;
|
||||
import com.threerings.util.Joiner;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
@@ -83,9 +83,9 @@ public class SceneUpdate
|
||||
*/
|
||||
public function toString () :String
|
||||
{
|
||||
var buf :StringBuilder = new StringBuilder("[");
|
||||
toStringBuilder(buf);
|
||||
return buf.append("]").toString();
|
||||
var j :Joiner = Joiner.createFor(this);
|
||||
toStringJoiner(j);
|
||||
return j.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,10 +149,9 @@ public class SceneUpdate
|
||||
* An extensible mechanism for generating a string representation of
|
||||
* this instance.
|
||||
*/
|
||||
protected function toStringBuilder (buf :StringBuilder) :void
|
||||
protected function toStringJoiner (j :Joiner) :void
|
||||
{
|
||||
buf.append("sceneId=").append(_targetId);
|
||||
buf.append(", version=").append(_targetVersion);
|
||||
j.add("sceneId", _targetId, "version", _targetVersion);
|
||||
}
|
||||
|
||||
/** The version number of the scene on which we operate. */
|
||||
|
||||
@@ -24,7 +24,7 @@ package com.threerings.whirled.spot.data {
|
||||
import com.threerings.util.ClassUtil;
|
||||
import com.threerings.util.Cloneable;
|
||||
import com.threerings.util.Hashable;
|
||||
import com.threerings.util.StringBuilder;
|
||||
import com.threerings.util.Joiner;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
@@ -143,11 +143,10 @@ public class Portal extends SimpleStreamableObject
|
||||
}
|
||||
|
||||
// from SimpleStreamableObject
|
||||
override protected function toStringBuilder (buf :StringBuilder): void
|
||||
override protected function toStringJoiner (j :Joiner): void
|
||||
{
|
||||
buf.append("id=").append(portalId);
|
||||
buf.append(", destScene=").append(targetSceneId);
|
||||
buf.append(", loc=").append(loc);
|
||||
// no super
|
||||
j.add("id", portalId, "destScene", targetSceneId, "loc", loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user