Search in sources :

Example 1 with ChmLzxcControlData

use of org.apache.tika.parser.chm.accessor.ChmLzxcControlData 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 ChmLzxcControlData

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

the class TestChmLzxcControlData method setUp.

@Before
public void setUp() throws Exception {
    byte[] 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 */
    ChmDirectoryListingSet 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);
}
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) ChmItspHeader(org.apache.tika.parser.chm.accessor.ChmItspHeader) Before(org.junit.Before)

Example 3 with ChmLzxcControlData

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

the class TestChmLzxState method setUp.

@Before
public void setUp() throws Exception {
    byte[] 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 */
    ChmDirectoryListingSet chmDirListCont = new ChmDirectoryListingSet(data, chmItsHeader, chmItspHeader);
    int indexOfControlData = ChmCommons.indexOf(chmDirListCont.getDirectoryListingEntryList(), ChmConstants.CONTROL_DATA);
    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());
    }
    ChmLzxcControlData clcd = new ChmLzxcControlData();
    clcd.parse(dir_chunk, clcd);
    windowSize = (int) clcd.getWindowSize();
}
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) ChmItspHeader(org.apache.tika.parser.chm.accessor.ChmItspHeader) Before(org.junit.Before)

Example 4 with ChmLzxcControlData

use of org.apache.tika.parser.chm.accessor.ChmLzxcControlData 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)4 ChmItsfHeader (org.apache.tika.parser.chm.accessor.ChmItsfHeader)4 ChmItspHeader (org.apache.tika.parser.chm.accessor.ChmItspHeader)4 ChmLzxcControlData (org.apache.tika.parser.chm.accessor.ChmLzxcControlData)4 Before (org.junit.Before)4 ChmLzxcResetTable (org.apache.tika.parser.chm.accessor.ChmLzxcResetTable)2