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
This commit is contained in:
Sergey Vladimirov 2011-07-28 14:21:26 +00:00
parent 88b60c2b9c
commit 5485d4f5d1
2 changed files with 18 additions and 10 deletions

View File

@ -254,12 +254,16 @@ public final class EscherContainerRecord extends EscherRecord {
+ children.toString(); + children.toString();
} }
public EscherSpRecord getChildById(short recordId) { public <T extends EscherRecord> T getChildById( short recordId )
Iterator<EscherRecord> iterator = _childRecords.iterator(); {
while (iterator.hasNext()) { for ( EscherRecord childRecord : _childRecords )
EscherRecord r = iterator.next(); {
if (r.getRecordId() == recordId) if ( childRecord.getRecordId() == recordId )
return (EscherSpRecord) r; {
@SuppressWarnings( "unchecked" )
final T result = (T) childRecord;
return result;
}
} }
return null; return null;
} }

View 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) if ( prop.getPropertyNumber() == propId )
return prop; {
@SuppressWarnings( "unchecked" )
final T result = (T) prop;
return result;
}
} }
return null; return null;
} }