public static int detectRLPObjectType ( ByteBuffer bb ) { bb . mark ( ) ; byte detector = bb . get ( ) ; int unsignedDetector = detector & 0xFF ; int result = EthereumUtil . RLP_OBJECTTYPE_INVALID ; if ( unsignedDetector <= 0x7f ) { result = EthereumUtil . RLP_OBJECTTYPE_ELEMENT ; } else if ( ( unsignedDetector >= 0x80 ) && ( unsignedDetector <= 0xb7 ) ) { result = EthereumUtil . RLP_OBJECTTYPE_ELEMENT ; } else if ( ( unsignedDetector >= 0xb8 ) && ( unsignedDetector <= 0xbf ) ) { result = EthereumUtil . RLP_OBJECTTYPE_ELEMENT ; } else if ( ( unsignedDetector >= 0xc0 ) && ( unsignedDetector <= 0xf7 ) ) { result = EthereumUtil . RLP_OBJECTTYPE_LIST ; } else if ( ( unsignedDetector >= 0xf8 ) && ( unsignedDetector <= 0xff ) ) { result = EthereumUtil . RLP_OBJECTTYPE_LIST ; } else { result = EthereumUtil . RLP_OBJECTTYPE_INVALID ; LOG . error ( "Invalid RLP object type. Internal error or not RLP Data" ) ; } bb . reset ( ) ; return result ; }
Detects the object type of an RLP encoded object . Note that it does not modify the read position in the ByteBuffer .