Package org.apache.tika.parser.chm.exception

Examples of org.apache.tika.parser.chm.exception.ChmParsingException


        setContentLength(len);
    }

    private void assertShortArrayNotNull(short[] array) throws TikaException {
        if (array == null)
            throw new ChmParsingException("short[] is null");
    }
View Full Code Here


    private void createLengthTreeLenTable(int offset, int tablelen,
            short[] pretreetable, short[] prelentable) throws TikaException {
        if (prelentable == null || getChmSection() == null
                || pretreetable == null || prelentable == null)
            throw new ChmParsingException("is null");

        int i = offset; // represents offset
        int z, y, x;// local counters
        while (i < tablelen) {
            z = pretreetable[getChmSection().getDesyncBits(
View Full Code Here

    }

    private void createMainTreeLenTable(int offset, int tablelen,
            short[] pretreetable, short[] prelentable) throws TikaException {
        if (pretreetable == null)
            throw new ChmParsingException("pretreetable is null");
        int i = offset;
        int z, y, x;
        while (i < tablelen) {
            int f = getChmSection().getDesyncBits(
                    ChmConstants.LZX_PRETREE_TABLEBITS, 0);
View Full Code Here

        }
    }

    private void assertInRange(short[] array, int index) throws ChmParsingException {
        if (index >= array.length)
            throw new ChmParsingException(index + " is bigger than "
                    + array.length);
    }
View Full Code Here

            byte[] dataSegment, long blockLength) throws TikaException {
        int goodParameter = 0;
        if (blockNumber >= 0)
            ++goodParameter;
        else
            throw new ChmParsingException("block number should be possitive");
        if (dataSegment != null && dataSegment.length > 0)
            ++goodParameter;
        else
            throw new ChmParsingException("data segment should not be null");
        if (blockLength > 0)
            ++goodParameter;
        else
            throw new ChmParsingException(
                    "block length should be more than zero");
        return (goodParameter == 3);
    }
View Full Code Here

        /* Preprocessing */
        if (pattern != null && text != null) {
            next = new int[pattern.length];
            next[0] = -1;
        } else
            throw new ChmParsingException("pattern and/or text should not be null");

        /* Computes a failure function */
        while (i < pattern.length - 1) {
            if (j == -1 || pattern[i] == pattern[j]) {
                i++;
View Full Code Here

    }

    private long unmarshalUInt32(byte[] data, long dest) throws ChmParsingException {
        ChmAssert.assertByteArrayNotNull(data);
        if (4 > getDataRemained())
            throw new ChmParsingException("4 > dataLenght");
        dest = data[this.getCurrentPlace()]
                | data[this.getCurrentPlace() + 1] << 8
                | data[this.getCurrentPlace() + 2] << 16
                | data[this.getCurrentPlace() + 3] << 24;
View Full Code Here

                chmPmglHeader.getBlockNext()));

        /* check structure */
        try {
            if (!new String(chmPmglHeader.getSignature(), "UTF-8").equals(ChmConstants.PMGL))
                throw new ChmParsingException(ChmPmglHeader.class.getName()
                        + " pmgl != pmgl.signature");
        } catch (UnsupportedEncodingException e) {
            throw new AssertionError("UTF-8 not supported.");
        }
    }
View Full Code Here

    // @Override
    public void parse(byte[] data, ChmItspHeader chmItspHeader) throws TikaException {
        /* we only know how to deal with the 0x58 and 0x60 byte structures */
        if (data.length != ChmConstants.CHM_ITSP_V1_LEN)
            throw new ChmParsingException("we only know how to deal with the 0x58 and 0x60 byte structures");

        /* unmarshal common fields */
        chmItspHeader.unmarshalCharArray(data, chmItspHeader, ChmConstants.CHM_SIGNATURE_LEN);
        // ChmCommons.unmarshalCharArray(data, chmItspHeader,
        // ChmConstants.CHM_SIGNATURE_LEN);
        chmItspHeader.setVersion(chmItspHeader.unmarshalInt32(data,
                chmItspHeader.getDataRemained(), chmItspHeader.getVersion()));
        chmItspHeader
                .setHeader_len(chmItspHeader.unmarshalInt32(data,
                        chmItspHeader.getDataRemained(),
                        chmItspHeader.getHeader_len()));
        chmItspHeader.setUnknown_000c(chmItspHeader.unmarshalInt32(data,
                chmItspHeader.getDataRemained(),
                chmItspHeader.getUnknown_000c()));
        chmItspHeader.setBlock_len(chmItspHeader.unmarshalUInt32(data,
                chmItspHeader.getDataRemained(), chmItspHeader.getBlock_len()));
        chmItspHeader.setBlockidx_intvl(chmItspHeader.unmarshalInt32(data,
                chmItspHeader.getDataRemained(),
                chmItspHeader.getBlockidx_intvl()));
        chmItspHeader
                .setIndex_depth(chmItspHeader.unmarshalInt32(data,
                        chmItspHeader.getDataRemained(),
                        chmItspHeader.getIndex_depth()));
        chmItspHeader
                .setIndex_root(chmItspHeader.unmarshalInt32(data,
                        chmItspHeader.getDataRemained(),
                        chmItspHeader.getIndex_root()));
        chmItspHeader
                .setIndex_head(chmItspHeader.unmarshalInt32(data,
                        chmItspHeader.getDataRemained(),
                        chmItspHeader.getIndex_head()));
        chmItspHeader.setUnknown_0024(chmItspHeader.unmarshalInt32(data,
                chmItspHeader.getDataRemained(),
                chmItspHeader.getUnknown_0024()));
        chmItspHeader
                .setNum_blocks(chmItspHeader.unmarshalUInt32(data,
                        chmItspHeader.getDataRemained(),
                        chmItspHeader.getNum_blocks()));
        chmItspHeader.setUnknown_002c((chmItspHeader.unmarshalInt32(data,
                chmItspHeader.getDataRemained(),
                chmItspHeader.getUnknown_002c())));
        chmItspHeader.setLang_id(chmItspHeader.unmarshalUInt32(data,
                chmItspHeader.getDataRemained(), chmItspHeader.getLang_id()));
        chmItspHeader
                .setSystem_uuid(chmItspHeader.unmarshalUuid(data,
                        chmItspHeader.getDataRemained(),
                        chmItspHeader.getSystem_uuid(),
                        ChmConstants.BYTE_ARRAY_LENGHT));
        chmItspHeader
                .setUnknown_0044(chmItspHeader.unmarshalUuid(data,
                        chmItspHeader.getDataRemained(),
                        chmItspHeader.getUnknown_0044(),
                        ChmConstants.BYTE_ARRAY_LENGHT));

        /* Checks validity of the itsp header */
        try {
            if (!new String(chmItspHeader.getSignature(), "UTF-8").equals(ChmConstants.ITSP))
                throw new ChmParsingException("seems not valid signature");
        } catch (UnsupportedEncodingException e) {
            throw new AssertionError("UTF-8 not supported.");
        }
        if (chmItspHeader.getVersion() != ChmConstants.CHM_VER_1)
            throw new ChmParsingException("!=ChmConstants.CHM_VER_1");

        if (chmItspHeader.getHeader_len() != ChmConstants.CHM_ITSP_V1_LEN)
            throw new ChmParsingException("!= ChmConstants.CHM_ITSP_V1_LEN");
    }
View Full Code Here

TOP

Related Classes of org.apache.tika.parser.chm.exception.ChmParsingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.