Fixed up toString().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2945 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-01-31 12:16:12 +00:00
parent 70cb0c1cfd
commit 21c6dbfc48
2 changed files with 21 additions and 5 deletions
@@ -1,5 +1,5 @@
//
// $Id: Credentials.java,v 1.11 2002/12/20 23:41:26 mdb Exp $
// $Id: Credentials.java,v 1.12 2004/01/31 12:16:12 mdb Exp $
package com.threerings.presents.net;
@@ -58,9 +58,23 @@ public abstract class Credentials implements Streamable
}
}
/**
* Generates a string representation of this instance.
*/
public String toString ()
{
return "[username=" + _username + "]";
StringBuffer buf = new StringBuffer("[");
toString(buf);
return buf.append("]").toString();
}
/**
* An easily extensible method via which derived classes can add to
* {@link #toString()}'s output.
*/
protected void toString (StringBuffer buf)
{
buf.append("username=").append(_username);
}
protected String _username;
@@ -1,5 +1,5 @@
//
// $Id: UsernamePasswordCreds.java,v 1.11 2002/12/20 23:41:26 mdb Exp $
// $Id: UsernamePasswordCreds.java,v 1.12 2004/01/31 12:16:12 mdb Exp $
package com.threerings.presents.net;
@@ -45,9 +45,11 @@ public class UsernamePasswordCreds extends Credentials
}
}
public String toString ()
// documentation inherited
protected void toString (StringBuffer buf)
{
return "[username=" + _username + ", password=" + _password + "]";
super.toString(buf);
buf.append(", password=").append(_password);
}
protected String _password;