mirror of https://github.com/apache/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
This commit is contained in:
parent
88b60c2b9c
commit
5485d4f5d1
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue