try
{
bitStream.setReadBoundary(bitStream.getOffset() + UI16_LENGTH);
// get tag code and length
final int tagCodeAndLength = bitStream.readUI16();
final TagType tagType = TagType.getTagType(tagCodeAndLength >>> BITS_TAG_LENGTH);
int tagLength = tagCodeAndLength & MASK_TAG_LENGTH;
if (tagLength == MASK_TAG_LENGTH)
{
bitStream.setReadBoundary(bitStream.getOffset() + SI32_LENGTH);
// long tag header uses an SI32 field for tag length