]> source.dussan.org Git - poi.git/commitdiff
child of ContainerRecord is not only SpContainer; use generics to preserve source...
authorSergey Vladimirov <sergey@apache.org>
Thu, 28 Jul 2011 14:21:26 +0000 (14:21 +0000)
committerSergey Vladimirov <sergey@apache.org>
Thu, 28 Jul 2011 14:21:26 +0000 (14:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1151861 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ddf/EscherContainerRecord.java
src/java/org/apache/poi/ddf/EscherOptRecord.java

index a79ebeccf627151a62aaa22b2ac497ffae17e663..4aa9567a2a347e4141f9bf89b358dcc0e98f65c9 100644 (file)
@@ -254,12 +254,16 @@ public final class EscherContainerRecord extends EscherRecord {
                 + children.toString();
     }
 
-    public EscherSpRecord getChildById(short recordId) {
-        Iterator<EscherRecord> iterator = _childRecords.iterator();
-        while (iterator.hasNext()) {
-            EscherRecord r = iterator.next();
-            if (r.getRecordId() == recordId)
-                return (EscherSpRecord) r;
+    public <T extends EscherRecord> T getChildById( short recordId )
+    {
+        for ( EscherRecord childRecord : _childRecords )
+        {
+            if ( childRecord.getRecordId() == recordId )
+            {
+                @SuppressWarnings( "unchecked" )
+                final T result = (T) childRecord;
+                return result;
+            }
         }
         return null;
     }
index d833d86504c4a2f85a08488faa3147d761793207..c2c0c78dd383a21e0a98a9586f5499af584ef8da 100644 (file)
@@ -160,12 +160,16 @@ public class EscherOptRecord
         } );
     }
 
-    public EscherProperty lookup(int propId)
+    public <T extends EscherProperty> 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;
     }