From d74c53cd0d72ef2526d877e2347d4ad9d8a080da Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 16 Jun 2002 18:56:19 +0000 Subject: [PATCH] Add a toString() to aid in debugging. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130719 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/collections/DefaultMapBag.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/commons/collections/DefaultMapBag.java b/src/java/org/apache/commons/collections/DefaultMapBag.java index 697d1213c..5f7584bf7 100644 --- a/src/java/org/apache/commons/collections/DefaultMapBag.java +++ b/src/java/org/apache/commons/collections/DefaultMapBag.java @@ -1,7 +1,7 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/DefaultMapBag.java,v 1.3 2002/06/12 03:59:15 mas Exp $ - * $Revision: 1.3 $ - * $Date: 2002/06/12 03:59:15 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/DefaultMapBag.java,v 1.4 2002/06/16 18:56:19 mas Exp $ + * $Revision: 1.4 $ + * $Date: 2002/06/16 18:56:19 $ * * ==================================================================== * @@ -334,6 +334,27 @@ public abstract class DefaultMapBag implements Bag { private int modCount() { return _mods; } + + /** + * Implement a toString() method suitable for debugging + **/ + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append("["); + Iterator i = uniqueSet().iterator(); + while(i.hasNext()) { + Object current = i.next(); + int count = getCount(current); + buf.append(count); + buf.append(":"); + buf.append(current); + if(i.hasNext()) { + buf.append(","); + } + } + buf.append("]"); + return buf.toString(); + } }