}
// @Override
public void parse(byte[] data, ChmLzxcControlData chmLzxcControlData) throws TikaException {
if (data == null || (data.length < ChmConstants.CHM_LZXC_MIN_LEN))
throw new ChmParsingException("we want at least 0x18 bytes");
chmLzxcControlData.setDataRemained(data.length);
chmLzxcControlData.setSize(unmarshalUInt32(data, chmLzxcControlData.getSize()));
chmLzxcControlData.unmarshalCharArray(data, chmLzxcControlData,
ChmConstants.CHM_SIGNATURE_LEN);
chmLzxcControlData.setVersion(unmarshalUInt32(data,
chmLzxcControlData.getVersion()));
chmLzxcControlData.setResetInterval(unmarshalUInt32(data,
chmLzxcControlData.getResetInterval()));
chmLzxcControlData.setWindowSize(unmarshalUInt32(data,
chmLzxcControlData.getWindowSize()));
chmLzxcControlData.setWindowsPerReset(unmarshalUInt32(data,
chmLzxcControlData.getWindowsPerReset()));
if (data.length >= ChmConstants.CHM_LZXC_V2_LEN)
chmLzxcControlData.setUnknown_18(unmarshalUInt32(data,
chmLzxcControlData.getUnknown_18()));
else
chmLzxcControlData.setUnknown_18(0);
if (chmLzxcControlData.getVersion() == 2) {
chmLzxcControlData.setWindowSize(getWindowSize()
* ChmConstants.CHM_WINDOW_SIZE_BLOCK);
}
if (chmLzxcControlData.getWindowSize() == 0
|| chmLzxcControlData.getResetInterval() == 0)
throw new ChmParsingException(
"window size / resetInterval should be more than zero");
if (chmLzxcControlData.getWindowSize() == 1)
throw new ChmParsingException(
"window size / resetInterval should be more than 1");
/* checks a signature */
if (!new String(chmLzxcControlData.getSignature())
.equals(ChmConstants.LZXC))
throw new ChmParsingException(
"the signature does not seem to be correct");
}