Rewritten toString() methods using String.format().

This commit is contained in:
Simone Bordet 2011-11-24 15:20:06 +01:00
parent 0b85184722
commit 59c111bde1
3 changed files with 28 additions and 16 deletions

View File

@ -360,9 +360,12 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
@Override @Override
public String toString() public String toString()
{ {
return "HttpConnection@" + hashCode() + "//" + return String.format("%s@%x//%s,g=%s,p=%s",
(_destination==null?"?.?.?.?:??":(_destination.getAddress().getHost() + ":" + _destination.getAddress().getPort()))+ getClass().getSimpleName(),
",g="+_generator.getState()+",p="+_parser.getState(); hashCode(),
_destination == null ? "?.?.?.?:??" : _destination.getAddress(),
_generator,
_parser);
} }
public String toDetailString() public String toDetailString()

View File

@ -59,6 +59,12 @@ public abstract class AbstractConnection implements Connection
public String toString() public String toString()
{ {
return this.getClass().getSimpleName()+"@"+_endp.getLocalAddr()+":"+_endp.getLocalPort()+"<->"+_endp.getRemoteAddr()+":"+_endp.getRemotePort(); return String.format("%s@%x//%s:%d<->%s:%d",
getClass().getSimpleName(),
hashCode(),
_endp.getLocalAddr(),
_endp.getLocalPort(),
_endp.getRemoteAddr(),
_endp.getRemotePort());
} }
} }

View File

@ -55,7 +55,6 @@ import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.thread.Timeout;
/** /**
* <p>A HttpConnection represents the connection of a HTTP client to the server * <p>A HttpConnection represents the connection of a HTTP client to the server
@ -680,7 +679,11 @@ public abstract class AbstractHttpConnection extends AbstractConnection
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public String toString() public String toString()
{ {
return super.toString()+" "+_parser+" "+_generator+" "+_requests; return String.format("%s,g=%s,p=%s,r=%d",
super.toString(),
_generator,
_parser,
_requests);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */