From 3ca7d0b7d8f64c570a35797d0f831d8f9c281188 Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Thu, 28 Jul 2011 11:45:25 +0000 Subject: [PATCH] make EscherContainerRecord.toString() indent children even if they don't support toString(indent) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1151802 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/ddf/EscherContainerRecord.java | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/java/org/apache/poi/ddf/EscherContainerRecord.java b/src/java/org/apache/poi/ddf/EscherContainerRecord.java index 6d869b7ae9..a79ebeccf6 100644 --- a/src/java/org/apache/poi/ddf/EscherContainerRecord.java +++ b/src/java/org/apache/poi/ddf/EscherContainerRecord.java @@ -17,14 +17,14 @@ package org.apache.poi.ddf; -import org.apache.poi.util.HexDump; -import org.apache.poi.util.LittleEndian; - +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; -import java.io.PrintWriter; + +import org.apache.poi.util.HexDump; +import org.apache.poi.util.LittleEndian; /** * Escher container records store other escher records as children. @@ -223,43 +223,35 @@ public final class EscherContainerRecord extends EscherRecord { } public String toString() - { - return toString(""); - } - public String toString(String indent) { String nl = System.getProperty( "line.separator" ); StringBuffer children = new StringBuffer(); - if (_childRecords.size() > 0) { + if ( _childRecords.size() > 0 ) + { children.append( " children: " + nl ); int count = 0; - for ( Iterator iterator = _childRecords.iterator(); iterator.hasNext(); ) + for ( Iterator iterator = _childRecords.iterator(); iterator + .hasNext(); ) { - String newIndent = indent + " "; - EscherRecord record = iterator.next(); - children.append(newIndent + "Child " + count + ":" + nl); - - if(record instanceof EscherContainerRecord) { - EscherContainerRecord ecr = (EscherContainerRecord)record; - children.append( ecr.toString(newIndent)); - } else { - children.append( record.toString() ); - } + children.append( " Child " + count + ":" + nl ); + String childResult = String.valueOf( record ); + childResult = childResult.replaceAll( "\n", "\n " ); + children.append( " " ); + children.append( childResult ); + children.append( nl ); count++; } } - return - indent + getClass().getName() + " (" + getRecordName() + "):" + nl + - indent + " isContainer: " + isContainerRecord() + nl + - indent + " options: 0x" + HexDump.toHex( getOptions() ) + nl + - indent + " recordId: 0x" + HexDump.toHex( getRecordId() ) + nl + - indent + " numchildren: " + _childRecords.size() + nl + - indent + children.toString(); - + return getClass().getName() + " (" + getRecordName() + "):" + nl + + " isContainer: " + isContainerRecord() + nl + + " options: 0x" + HexDump.toHex( getOptions() ) + nl + + " recordId: 0x" + HexDump.toHex( getRecordId() ) + nl + + " numchildren: " + _childRecords.size() + nl + + children.toString(); } public EscherSpRecord getChildById(short recordId) { -- 2.39.5