public static byte [ ] prepareCachedNameBytes ( String entityName ) { UTF8 name = new UTF8 ( ) ; name . set ( entityName , true ) ; byte nameBytes [ ] = name . getBytes ( ) ; byte cachedName [ ] = new byte [ nameBytes . length + 2 ] ; System . arraycopy ( nameBytes , 0 , cachedName , 2 , nameBytes . length ) ; // we cache the length as well int v = nameBytes . length ; cachedName [ 0 ] = ( byte ) ( ( v >>> 8 ) & 0xFF ) ; cachedName [ 1 ] = ( byte ) ( ( v >>> 0 ) & 0xFF ) ; return cachedName ; }
Prepares a byte array for given name together with lenght as the two trailing bytes .