Example usage for org.apache.poi.hpsf Variant VT_I4

List of usage examples for org.apache.poi.hpsf Variant VT_I4

Introduction

In this page you can find the example usage for org.apache.poi.hpsf Variant VT_I4.

Prototype

int VT_I4

To view the source code for org.apache.poi.hpsf Variant VT_I4.

Click Source Link

Document

[V][T][P][S] 4 byte signed int.

Usage

From source file:org.ddt.listener.dsi.HeadingPairProperty.java

License:Apache License

/**
 * the constructor./*from ww  w . j  av  a 2 s .  c o  m*/
 *
 *
 * @param data           the data to read from.
 * @param dataOffset     the offset into the
 * <code>data</code> byte array.
 * @param docPartsOffset the offset of the corresponding docparts.
 * @throws IllegalVariantTypeException  if the data is malformed.
 * @throws UnsupportedEncodingException
 */
HeadingPairProperty(byte[] data, int dataOffset, int docPartsOffset)
        throws IllegalVariantTypeException, UnsupportedEncodingException {
    int off = dataOffset;
    name = new StringProperty(data, off);
    off += name.getSize();
    long type = LittleEndian.getUInt(data, off);
    if (type != Variant.VT_I4) {
        log.log(Level.WARNING, "Not a proper VT_I4 type.");
        throw new IllegalVariantTypeException(type, name);
    }
    off += LittleEndian.INT_SIZE;
    //this is a horrible workaround, around the bug in HPSF, that returns
    //cutoff byte arrays from Section.getProperty() (HPFS Bug #52337)
    //It hopes that there aren't too many parts per heading (i.e. worst
    //case it can be store in one byte...)
    int left = data.length - off;
    if (left >= LittleEndian.INT_SIZE) {
        partsCount = (int) LittleEndian.getUInt(data, off);
        off += LittleEndian.INT_SIZE;
    } else if (left >= LittleEndian.SHORT_SIZE) {
        partsCount = LittleEndian.getShort(data, off);
        off += left;
    } else if (left >= LittleEndian.BYTE_SIZE) {
        partsCount = LittleEndian.getUByte(data, off);
        off += left;
    } else {
        partsCount = 1; //default... maybe not a good idea.
    }
    size = off - dataOffset;

    this.docPartsOffset = docPartsOffset;
}