Search in sources :

Example 1 with ChmLzxcResetTable

use of org.apache.tika.parser.chm.accessor.ChmLzxcResetTable in project tika by apache.

the class TestChmBlockInfo method setUp.

@Before
public void setUp() throws Exception {
    data = TestParameters.chmData;
    /* Creates and parses itsf header */
    ChmItsfHeader chmItsHeader = new ChmItsfHeader();
    // chmItsHeader.parse(Arrays.copyOfRange(data, 0,
    // ChmConstants.CHM_ITSF_V3_LEN - 1), chmItsHeader);
    chmItsHeader.parse(ChmCommons.copyOfRange(data, 0, ChmConstants.CHM_ITSF_V3_LEN - 1), chmItsHeader);
    /* Creates and parses itsp block */
    ChmItspHeader chmItspHeader = new ChmItspHeader();
    // chmItspHeader.parse(Arrays.copyOfRange( data, (int)
    // chmItsHeader.getDirOffset(),
    // (int) chmItsHeader.getDirOffset()
    // + ChmConstants.CHM_ITSP_V1_LEN), chmItspHeader);
    chmItspHeader.parse(ChmCommons.copyOfRange(data, (int) chmItsHeader.getDirOffset(), (int) chmItsHeader.getDirOffset() + ChmConstants.CHM_ITSP_V1_LEN), chmItspHeader);
    /* Creating instance of ChmDirListingContainer */
    chmDirListCont = new ChmDirectoryListingSet(data, chmItsHeader, chmItspHeader);
    int indexOfControlData = chmDirListCont.getControlDataIndex();
    int indexOfResetTable = ChmCommons.indexOfResetTableBlock(data, ChmConstants.LZXC.getBytes(UTF_8));
    byte[] dir_chunk = null;
    if (indexOfResetTable > 0) {
        // dir_chunk = Arrays.copyOfRange( data, indexOfResetTable,
        // indexOfResetTable
        // +
        // chmDirListCont.getDirectoryListingEntryList().get(indexOfControlData).getLength());
        dir_chunk = ChmCommons.copyOfRange(data, indexOfResetTable, indexOfResetTable + chmDirListCont.getDirectoryListingEntryList().get(indexOfControlData).getLength());
    }
    /* Creates and parses control block */
    chmLzxcControlData = new ChmLzxcControlData();
    chmLzxcControlData.parse(dir_chunk, chmLzxcControlData);
    int indexOfFeList = chmDirListCont.getResetTableIndex();
    int startIndex = (int) chmDirListCont.getDataOffset() + chmDirListCont.getDirectoryListingEntryList().get(indexOfFeList).getOffset();
    // dir_chunk = Arrays.copyOfRange(data, startIndex , startIndex +
    // chmDirListCont.getDirectoryListingEntryList().get(indexOfFeList).getLength());
    dir_chunk = ChmCommons.copyOfRange(data, startIndex, startIndex + chmDirListCont.getDirectoryListingEntryList().get(indexOfFeList).getLength());
    clrt = new ChmLzxcResetTable();
    clrt.parse(dir_chunk, clrt);
}
Also used : ChmLzxcControlData(org.apache.tika.parser.chm.accessor.ChmLzxcControlData) ChmItsfHeader(org.apache.tika.parser.chm.accessor.ChmItsfHeader) ChmDirectoryListingSet(org.apache.tika.parser.chm.accessor.ChmDirectoryListingSet) ChmLzxcResetTable(org.apache.tika.parser.chm.accessor.ChmLzxcResetTable) ChmItspHeader(org.apache.tika.parser.chm.accessor.ChmItspHeader) Before(org.junit.Before)

Example 2 with ChmLzxcResetTable

use of org.apache.tika.parser.chm.accessor.ChmLzxcResetTable in project tika by apache.

the class TestChmLzxcResetTable method setUp.

@Before
public void setUp() throws Exception {
    byte[] data = TestParameters.chmData;
    /* Creates and parses itsf header */
    ChmItsfHeader chmItsfHeader = new ChmItsfHeader();
    // chmItsfHeader.parse(Arrays.copyOfRange(data, 0,
    // ChmConstants.CHM_ITSF_V3_LEN - 1), chmItsfHeader);
    chmItsfHeader.parse(ChmCommons.copyOfRange(data, 0, ChmConstants.CHM_ITSF_V3_LEN - 1), chmItsfHeader);
    /* Creates and parses itsp block */
    ChmItspHeader chmItspHeader = new ChmItspHeader();
    // chmItspHeader.parse(Arrays.copyOfRange( data, (int)
    // chmItsfHeader.getDirOffset(),
    // (int) chmItsfHeader.getDirOffset()
    // + ChmConstants.CHM_ITSP_V1_LEN), chmItspHeader);
    chmItspHeader.parse(ChmCommons.copyOfRange(data, (int) chmItsfHeader.getDirOffset(), (int) chmItsfHeader.getDirOffset() + ChmConstants.CHM_ITSP_V1_LEN), chmItspHeader);
    /* Creating instance of ChmDirListingContainer */
    ChmDirectoryListingSet chmDirListCont = new ChmDirectoryListingSet(data, chmItsfHeader, chmItspHeader);
    int indexOfControlData = chmDirListCont.getControlDataIndex();
    int indexOfResetTable = ChmCommons.indexOfResetTableBlock(data, ChmConstants.LZXC.getBytes(UTF_8));
    byte[] dir_chunk = null;
    if (indexOfResetTable > 0) {
        // dir_chunk = Arrays.copyOfRange( data, indexOfResetTable,
        // indexOfResetTable
        // +
        // chmDirListCont.getDirectoryListingEntryList().get(indexOfControlData).getLength());
        dir_chunk = ChmCommons.copyOfRange(data, indexOfResetTable, indexOfResetTable + chmDirListCont.getDirectoryListingEntryList().get(indexOfControlData).getLength());
    }
    /* Creates and parses control block */
    ChmLzxcControlData chmLzxcControlData = new ChmLzxcControlData();
    chmLzxcControlData.parse(dir_chunk, chmLzxcControlData);
    indexOfResetTable = chmDirListCont.getResetTableIndex();
    chmLzxcResetTable = new ChmLzxcResetTable();
    int startIndex = (int) chmDirListCont.getDataOffset() + chmDirListCont.getDirectoryListingEntryList().get(indexOfResetTable).getOffset();
    ChmAssert.assertCopyingDataIndex(startIndex, data.length);
    // dir_chunk = Arrays.copyOfRange(data, startIndex, startIndex
    // +
    // chmDirListCont.getDirectoryListingEntryList().get(indexOfResetTable).getLength());
    dir_chunk = ChmCommons.copyOfRange(data, startIndex, startIndex + chmDirListCont.getDirectoryListingEntryList().get(indexOfResetTable).getLength());
    chmLzxcResetTable.parse(dir_chunk, chmLzxcResetTable);
}
Also used : ChmLzxcControlData(org.apache.tika.parser.chm.accessor.ChmLzxcControlData) ChmItsfHeader(org.apache.tika.parser.chm.accessor.ChmItsfHeader) ChmDirectoryListingSet(org.apache.tika.parser.chm.accessor.ChmDirectoryListingSet) ChmLzxcResetTable(org.apache.tika.parser.chm.accessor.ChmLzxcResetTable) ChmItspHeader(org.apache.tika.parser.chm.accessor.ChmItspHeader) Before(org.junit.Before)

Aggregations

ChmDirectoryListingSet (org.apache.tika.parser.chm.accessor.ChmDirectoryListingSet)2 ChmItsfHeader (org.apache.tika.parser.chm.accessor.ChmItsfHeader)2 ChmItspHeader (org.apache.tika.parser.chm.accessor.ChmItspHeader)2 ChmLzxcControlData (org.apache.tika.parser.chm.accessor.ChmLzxcControlData)2 ChmLzxcResetTable (org.apache.tika.parser.chm.accessor.ChmLzxcResetTable)2 Before (org.junit.Before)2