From 19025f6f741f2957ebb4e0011ac34d1bc684fb1f Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Thu, 28 Jul 2011 14:21:26 +0000 Subject: [PATCH] child of ContainerRecord is not only SpContainer; use generics to preserve source-compatibility git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1151861 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/ddf/EscherContainerRecord.java | 16 ++++++++++------ src/java/org/apache/poi/ddf/EscherOptRecord.java | 12 ++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/poi/ddf/EscherContainerRecord.java b/src/java/org/apache/poi/ddf/EscherContainerRecord.java index a79ebeccf..4aa9567a2 100644 --- a/src/java/org/apache/poi/ddf/EscherContainerRecord.java +++ b/src/java/org/apache/poi/ddf/EscherContainerRecord.java @@ -254,12 +254,16 @@ public final class EscherContainerRecord extends EscherRecord { + children.toString(); } - public EscherSpRecord getChildById(short recordId) { - Iterator iterator = _childRecords.iterator(); - while (iterator.hasNext()) { - EscherRecord r = iterator.next(); - if (r.getRecordId() == recordId) - return (EscherSpRecord) r; + public T getChildById( short recordId ) + { + for ( EscherRecord childRecord : _childRecords ) + { + if ( childRecord.getRecordId() == recordId ) + { + @SuppressWarnings( "unchecked" ) + final T result = (T) childRecord; + return result; + } } return null; } diff --git a/src/java/org/apache/poi/ddf/EscherOptRecord.java b/src/java/org/apache/poi/ddf/EscherOptRecord.java index d833d8650..c2c0c78dd 100644 --- a/src/java/org/apache/poi/ddf/EscherOptRecord.java +++ b/src/java/org/apache/poi/ddf/EscherOptRecord.java @@ -160,12 +160,16 @@ public class EscherOptRecord } ); } - public EscherProperty lookup(int propId) + public T lookup( int propId ) { - for (EscherProperty prop : properties) + for ( EscherProperty prop : properties ) { - if (prop.getPropertyNumber() == propId) - return prop; + if ( prop.getPropertyNumber() == propId ) + { + @SuppressWarnings( "unchecked" ) + final T result = (T) prop; + return result; + } } return null; }