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

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

Introduction

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

Prototype

int VT_VECTOR

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

Click Source Link

Document

[P] simple counted array.

Usage

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

License:Apache License

/**
 * reads the data array and fills in the StringVector values.
 * \warning the//  w  ww  . ja  va 2  s  . c o  m
 * <code>type</code> field <b>must</b> be populated/initialised
 * before this method is called.
 *
 * @param data   byte array containing a vector of strings.
 * @param offset the offset into the array at which the vector starts.
 * @throws IllegalVariantTypeException
 * @throws UnsupportedOperationException
 */
private void read(byte[] data, int offset) throws IllegalVariantTypeException, UnsupportedEncodingException {
    if ((type != (Variant.VT_VECTOR | Variant.VT_LPSTR)) && (type != (Variant.VT_VECTOR | Variant.VT_LPWSTR))) {
        throw new IllegalVariantTypeException(type, data);
    }

    numElements = (int) LittleEndian.getUInt(data, offset);
    offset += LittleEndian.INT_SIZE;
    elements = new StringProperty[numElements];
    for (int i = 0; i < numElements; i++) {
        elements[i] = new StringProperty(data, offset, type & 0x00ff);
        //because the strings are constructed with an already-read type field,
        //we only need to advance over the StringLength field and the string,
        //not the type field (there isn't one in this case).
        offset += elements[i].getSize() - LittleEndian.INT_SIZE;
    }
}

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

License:Apache License

@Before
public void setUp() throws IllegalVariantTypeException, UnsupportedEncodingException {
    ansiTypeGiven = new StringVector(ansiVector, 4, Variant.VT_VECTOR | Variant.VT_LPSTR);
    unicodeTypeGiven = new StringVector(unicodeVector, 4, Variant.VT_VECTOR | Variant.VT_LPWSTR);
    ansiTypeRead = new StringVector(ansiVector, 0);
    unicodeTypeRead = new StringVector(unicodeVector, 0);
}

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

License:Apache License

@Test
public void testVectorValueConstructors() throws IllegalVariantTypeException, UnsupportedEncodingException {
    ansiTypeGiven = new StringVector(ansiVector, 4, Variant.VT_VECTOR | Variant.VT_LPSTR);
    unicodeTypeGiven = new StringVector(unicodeVector, 4, Variant.VT_VECTOR | Variant.VT_LPWSTR);
}