@Override
public Component load(CapInputStream in) throws UnableToReadCapFileException {
ClassComponent classComponent = new ClassComponent();
// we first read tag and size
super.load((byte) ComponentEnum.CLASS_COMPONENT.getValue(), in, classComponent);
// we reset the count of byte read to zero
in.resetCount();
// TODO: signaturePoolLength only on Java Card 2.2
/*
* //signaturePoolLength reading
* //this.setSignaturePoolLength(in.readShort());
* this.setSignaturePoolLength(in.readShort()); nbByteRead += 2;
*
* //we first clear the signaturePool signaturePool.clear(); for(int
* i=0; i<signaturePoolLength; i++){ signaturePool.add(new
* TypeDescriptor(in)); }
*/
classComponent.setSignaturePool(new ArrayList<TypeDescriptor>());
classComponent.setClasses(new ArrayList<ClassInfo>());
classComponent.setInterfaces(new ArrayList<InterfaceInfo>());
while (in.getByteRead() < classComponent.getSize()) {
// we'll have to check the first nibble to know if it's a
// classInfo or
// interfaceInfo structure
byte buf = in.readByte();
// if the most significant bit of buf is 1 it's an interfaceInfo
// else it's a classInfo
if ((buf & ClassComponent.ACC_INTERFACE) != 0) {
InterfaceInfo intInf = new InterfaceInfoRead().load(buf, in);
classComponent.getInterfaces().add(intInf);
} else {
ClassInfo classInf = new ClassInfoRead().load(buf, in);
classComponent.getClasses().add(classInf);
}
}
checkSize(in, classComponent);