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.Comparable;
|
||||||
import com.threerings.util.Hashable;
|
import com.threerings.util.Hashable;
|
||||||
import com.threerings.util.Integer;
|
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;
|
||||||
import com.threerings.presents.dobj.DSet_Entry;
|
import com.threerings.presents.dobj.DSet_Entry;
|
||||||
@@ -168,30 +168,7 @@ public class Card
|
|||||||
return "BJ";
|
return "BJ";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var sb : StringBuilder = new StringBuilder();
|
return rankToString(number) + suitToString(getSuit());
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,6 +216,32 @@ public class Card
|
|||||||
out.writeByte(_value);
|
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. */
|
/** The number of the card. */
|
||||||
protected var _value :int;
|
protected var _value :int;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ package com.threerings.parlor.data {
|
|||||||
import com.threerings.util.ArrayUtil;
|
import com.threerings.util.ArrayUtil;
|
||||||
import com.threerings.util.ClassUtil;
|
import com.threerings.util.ClassUtil;
|
||||||
import com.threerings.util.Hashable;
|
import com.threerings.util.Hashable;
|
||||||
|
import com.threerings.util.Joiner;
|
||||||
import com.threerings.util.Name;
|
import com.threerings.util.Name;
|
||||||
import com.threerings.util.StringBuilder;
|
|
||||||
|
|
||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
@@ -218,12 +218,9 @@ public class Table
|
|||||||
*/
|
*/
|
||||||
public function toString () :String
|
public function toString () :String
|
||||||
{
|
{
|
||||||
var buf :StringBuilder = new StringBuilder();
|
var j :Joiner = Joiner.createFor(this);
|
||||||
buf.append(ClassUtil.shortClassName(this));
|
toStringJoiner(j);
|
||||||
buf.append(" [");
|
return j.toString();
|
||||||
toStringBuilder(buf);
|
|
||||||
buf.append("]");
|
|
||||||
return buf.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -259,14 +256,10 @@ public class Table
|
|||||||
/**
|
/**
|
||||||
* Helper method for toString, ripe for overrideability.
|
* Helper method for toString, ripe for overrideability.
|
||||||
*/
|
*/
|
||||||
protected function toStringBuilder (buf :StringBuilder) :void
|
protected function toStringJoiner (j :Joiner) :void
|
||||||
{
|
{
|
||||||
buf.append("tableId=").append(tableId);
|
j.add("tableId", tableId, "lobbyOid", lobbyOid, "gameOid", gameOid,
|
||||||
buf.append(", lobbyOid=").append(lobbyOid);
|
"players", players, "watchers", watchers, "config", config);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A counter for assigning table ids. */
|
/** 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.ArrayUtil;
|
||||||
import com.threerings.util.Integer;
|
import com.threerings.util.Integer;
|
||||||
|
import com.threerings.util.Joiner;
|
||||||
import com.threerings.util.langBoolean;
|
import com.threerings.util.langBoolean;
|
||||||
import com.threerings.util.Name;
|
import com.threerings.util.Name;
|
||||||
import com.threerings.util.StringBuilder;
|
|
||||||
|
|
||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
@@ -230,11 +230,10 @@ public class GameObject extends PlaceObject
|
|||||||
return playerStatus == PLAYER_IN_PLAY;
|
return playerStatus == PLAYER_IN_PLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected function whichBuf (buf :StringBuilder) :void
|
override protected function whichJoiner (j :Joiner) :void
|
||||||
{
|
{
|
||||||
super.whichBuf(buf);
|
super.whichJoiner(j);
|
||||||
buf.append("(").append(players.join()).append(")");
|
j.addArgs("(" + players.join() + ")", state);
|
||||||
buf.append(":").append(state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// // AUTO-GENERATED: METHODS START
|
// // AUTO-GENERATED: METHODS START
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ package com.threerings.whirled.data {
|
|||||||
|
|
||||||
import flash.errors.IllegalOperationError;
|
import flash.errors.IllegalOperationError;
|
||||||
|
|
||||||
import com.threerings.util.StringBuilder;
|
import com.threerings.util.Joiner;
|
||||||
|
|
||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
@@ -83,9 +83,9 @@ public class SceneUpdate
|
|||||||
*/
|
*/
|
||||||
public function toString () :String
|
public function toString () :String
|
||||||
{
|
{
|
||||||
var buf :StringBuilder = new StringBuilder("[");
|
var j :Joiner = Joiner.createFor(this);
|
||||||
toStringBuilder(buf);
|
toStringJoiner(j);
|
||||||
return buf.append("]").toString();
|
return j.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,10 +149,9 @@ public class SceneUpdate
|
|||||||
* An extensible mechanism for generating a string representation of
|
* An extensible mechanism for generating a string representation of
|
||||||
* this instance.
|
* this instance.
|
||||||
*/
|
*/
|
||||||
protected function toStringBuilder (buf :StringBuilder) :void
|
protected function toStringJoiner (j :Joiner) :void
|
||||||
{
|
{
|
||||||
buf.append("sceneId=").append(_targetId);
|
j.add("sceneId", _targetId, "version", _targetVersion);
|
||||||
buf.append(", version=").append(_targetVersion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The version number of the scene on which we operate. */
|
/** 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.ClassUtil;
|
||||||
import com.threerings.util.Cloneable;
|
import com.threerings.util.Cloneable;
|
||||||
import com.threerings.util.Hashable;
|
import com.threerings.util.Hashable;
|
||||||
import com.threerings.util.StringBuilder;
|
import com.threerings.util.Joiner;
|
||||||
|
|
||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
@@ -143,11 +143,10 @@ public class Portal extends SimpleStreamableObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// from SimpleStreamableObject
|
// from SimpleStreamableObject
|
||||||
override protected function toStringBuilder (buf :StringBuilder): void
|
override protected function toStringJoiner (j :Joiner): void
|
||||||
{
|
{
|
||||||
buf.append("id=").append(portalId);
|
// no super
|
||||||
buf.append(", destScene=").append(targetSceneId);
|
j.add("id", portalId, "destScene", targetSceneId, "loc", loc);
|
||||||
buf.append(", loc=").append(loc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user