From: Sergey Vladimirov Date: Thu, 28 Jul 2011 14:21:26 +0000 (+0000) Subject: child of ContainerRecord is not only SpContainer; use generics to preserve source... X-Git-Tag: REL_3_8_BETA4~54 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5485d4f5d106bd960ebfbedeb1048032adad9a4b;p=poi.git 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 --- diff --git a/src/java/org/apache/poi/ddf/EscherContainerRecord.java b/src/java/org/apache/poi/ddf/EscherContainerRecord.java index a79ebeccf6..4aa9567a2a 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 d833d86504..c2c0c78dd3 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; }