public static <T extends StreamObject> T getCurrent(byte[] byteArray, AtomicInteger index,
                                                        Class<T> clazz)
            throws TikaException, IOException {
        AtomicInteger tmpIndex = new AtomicInteger(index.get());
        int length;
        AtomicReference<StreamObjectHeaderStart> streamObjectHeader = new AtomicReference<>();
        if ((length =
                StreamObjectHeaderStart.tryParse(byteArray, tmpIndex.get(), streamObjectHeader)) ==
                0) {
            throw new StreamObjectParseErrorException(tmpIndex.get(), clazz.getName(),
                    "Failed to extract either 16bit or 32bit stream object header in the current index.",
                    null);
        }

        tmpIndex.addAndGet(length);

        StreamObject streamObject =
                parseStreamObject(streamObjectHeader.get(), byteArray, tmpIndex);

        if (!streamObject.getClass().equals(clazz)) {
            String destClassName = "(null)";
            if (streamObjectTypeMapping.containsKey(streamObjectHeader.get().type)) {
                destClassName =
                        streamObjectTypeMapping.get(streamObjectHeader.get().type).getName();
            }
            throw new StreamObjectParseErrorException(tmpIndex.get(), clazz.getName(),
                    String.format(Locale.US,
                            "Failed to get stream object as expect type %s, actual type is %s",
                            clazz.getName(), destClassName), null);
        }

        // Store the current index to the ref parameter index.
        index.set(tmpIndex.get());
        return (T) streamObject;
    }
Get current stream object.

@param byteArray The byte array which contains message.
@param index     The position where to start.
@return The current object instance.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/onenote/fsshttpb/streamobj/StreamObject.java