public synchronized boolean hasEndOfData() {
        if (hasEndOfBlock()) {
            int potentialEndOfDataIndex = endOfBlockIndex + 1;
            if (potentialEndOfDataIndex < availableByteCount
                    && buffer[potentialEndOfDataIndex] == MllpProtocolConstants.END_OF_DATA) {
                return true;
            }
        }

        return false;
    }
@Test
    public void testHasEndOfData() {
        assertFalse(instance.hasEndOfData(), "Unexpected initial value");

        // Test just the END_OF_DATA
        instance.write(MllpProtocolConstants.END_OF_DATA);
        assertFalse(instance.hasEndOfData());

        instance.reset();
        assertFalse(instance.hasEndOfData());

        // Test just the terminators
        instance.write(MllpProtocolConstants.END_OF_BLOCK);
        assertFalse(instance.hasEndOfData());

        instance.write(MllpProtocolConstants.END_OF_DATA);
        assertFalse(instance.hasEndOfData(), "Need a START_OF_BLOCK before the END_OF_DATA");

        instance.reset();
        assertFalse(instance.hasEndOfData());

        instance.write(MllpProtocolConstants.START_OF_BLOCK);
        assertFalse(instance.hasEndOfData());

        instance.write(TEST_HL7_MESSAGE.getBytes());
        assertFalse(instance.hasEndOfData());

        instance.write(MllpProtocolConstants.END_OF_BLOCK);
        assertFalse(instance.hasEndOfData());

        instance.write(MllpProtocolConstants.END_OF_DATA);
        assertTrue(instance.hasEndOfData());

        instance.reset();
        assertFalse(instance.hasEndOfData());

        instance.write(MllpProtocolConstants.START_OF_BLOCK);
        assertFalse(instance.hasEndOfData());

        instance.write(TEST_HL7_MESSAGE.getBytes());
        assertFalse(instance.hasEndOfData());

        instance.write(MllpProtocolConstants.END_OF_BLOCK);
        assertFalse(instance.hasEndOfData());

        instance.write("BLAH".getBytes());
        assertFalse(instance.hasEndOfData());

        instance.write(MllpProtocolConstants.END_OF_DATA);
        assertFalse(instance.hasEndOfData());
    }