From 4c2ccc66e0a173af4288097b18274a87763f460e Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Sat, 17 Dec 2011 07:07:15 +0000 Subject: [PATCH] Added a toString method similar to AbstractCollection's. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8940 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../src/core/com/jme3/util/SafeArrayList.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/engine/src/core/com/jme3/util/SafeArrayList.java b/engine/src/core/com/jme3/util/SafeArrayList.java index 7fe7e63fc..fda95aa3e 100644 --- a/engine/src/core/com/jme3/util/SafeArrayList.java +++ b/engine/src/core/com/jme3/util/SafeArrayList.java @@ -320,6 +320,25 @@ public class SafeArrayList implements List { return Collections.unmodifiableList(raw); } + public String toString() { + + E[] array = getArray(); + if( array.length == 0 ) { + return "[]"; + } + + StringBuilder sb = new StringBuilder(); + sb.append('['); + for( int i = 0; i < array.length; i++ ) { + if( i > 0 ) + sb.append( ", " ); + E e = array[i]; + sb.append( e == this ? "(this Collection)" : e ); + } + sb.append(']'); + return sb.toString(); + } + protected class ArrayIterator implements ListIterator { private E[] array; private int next;