private final static Logger logger = LoggerFactory.getLogger(DirectoryComponentRead.class);
@Override
public Component load(CapInputStream in) throws UnableToReadCapFileException {
DirectoryComponent directoryComponent = new DirectoryComponent();
// tag and size reading
super.load((byte) ComponentEnum.DIRECTORY_COMPONENT.getValue(), in, directoryComponent);
// we reset the count of byte read to zero
in.resetCount();
// number of bytes in each of the 12 components in the CAP file
directoryComponent.setComponentSize(new ArrayList<Short>());
directoryComponent.setStaticFieldSize(new StaticFieldSizeInfo());
directoryComponent.setCustomComponent(new ArrayList<CustomComponentInfo>());
// componentSizes reading
for (int i = 0; i < DirectoryComponent.COMPONENT_NUMBER; i++) {
short size = in.readShort();
logger.trace("component number {} has size {}", i, size);
directoryComponent.getComponentSize().add(size);
}
// staticFieldSize reading
directoryComponent.setStaticFieldSize(new StaticFieldSizeInfoRead().load(in));
// importCount reading
directoryComponent.setImportCount(in.readByte());
logger.trace("import count: {}", directoryComponent.getImportCount());
// appletCount reading
directoryComponent.setAppletCount(in.readByte());
logger.trace("applet count: {}", directoryComponent.getAppletCount());
// customCount reading
directoryComponent.setCustomCount(in.readByte());
logger.trace("custom count: {}", directoryComponent.getCustomCount());
// customComponents reading
for (byte i = 0; i < directoryComponent.getCustomCount(); i++) {
CustomComponentInfo customComp = new CustomComponentInfoRead().load(in);
directoryComponent.getCustomComponent().add(customComp);
}
checkSize(in, directoryComponent);
return directoryComponent;