diff options
author | Sergey Vladimirov <sergey@apache.org> | 2011-07-28 11:45:25 +0000 |
---|---|---|
committer | Sergey Vladimirov <sergey@apache.org> | 2011-07-28 11:45:25 +0000 |
commit | 3ca7d0b7d8f64c570a35797d0f831d8f9c281188 (patch) | |
tree | b022c379f2f4e9a7ac55dc79ccd8b85638f66c40 /src/java/org | |
parent | 49a7f2fc9d1c9357e314b078feb446c4ed727335 (diff) | |
download | poi-3ca7d0b7d8f64c570a35797d0f831d8f9c281188.tar.gz poi-3ca7d0b7d8f64c570a35797d0f831d8f9c281188.zip |
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
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/poi/ddf/EscherContainerRecord.java | 48 |
1 files 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. @@ -224,42 +224,34 @@ 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<EscherRecord> iterator = _childRecords.iterator(); iterator.hasNext(); ) + for ( Iterator<EscherRecord> 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) { |