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 d11ee82875
commit 19025f6f74
2 changed files with 18 additions and 10 deletions

View 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;
}

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