private boolean needAdditionalLengthBytesState(final boolean isBlocking,final boolean throwEofException) throws IOException {
  if (!isBlocking && (in.available() < lengthBytesNeeded)) {
    return false;
  }
  int readByte;
  while (lengthBytesNeeded > 0) {
    readByte=in.read();
    if (readByte == -1) {
      state=ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
      if (throwEofException) {
        final LocalizableMessage message=ERR_ASN1_TRUNCATED_LENGTH_BYTES.get(lengthBytesNeeded);
        throw DecodeException.fatalError(message);
      }
      return false;
    }
    peekLength=(peekLength << 8) | (readByte & 0xFF);
    lengthBytesNeeded--;
  }
  if (maxElementSize > 0 && peekLength > maxElementSize) {
    final LocalizableMessage message=ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED.get(peekLength,maxElementSize);
    throw DecodeException.fatalError(message);
  }
  state=ASN1.ELEMENT_READ_STATE_NEED_VALUE_BYTES;
  return true;
}

private boolean needAdditionalLengthBytesState ( final boolean isBlocking , final boolean throwEofException ) throws IOException { if ( ! isBlocking && ( in . available ( ) < lengthBytesNeeded ) ) { return false ; } int readByte ; while ( lengthBytesNeeded > 0 ) { readByte = in . read ( ) ; if ( readByte == - 1 ) { state = ASN1 . ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES ; if ( throwEofException ) { final LocalizableMessage message = ERR_ASN1_TRUNCATED_LENGTH_BYTES . get ( lengthBytesNeeded ) ; throw DecodeException . fatalError ( message ) ; } return false ; } peekLength = ( peekLength << 8 ) | ( readByte & 0xFF ) ; lengthBytesNeeded -- ; } if ( maxElementSize > 0 && peekLength > maxElementSize ) { final LocalizableMessage message = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED . get ( peekLength , maxElementSize ) ; throw DecodeException . fatalError ( message ) ; } state = ASN1 . ELEMENT_READ_STATE_NEED_VALUE_BYTES ; return true ; }
internal helper method reading the additional asn . 1 length bytes and transition to the next state if successful .
