public static boolean startsWith ( Msg msg , String data , boolean includeLength ) { final int length = data . length ( ) ; assert ( length < 256 ) ; int start = includeLength ? 1 : 0 ; if ( msg . size ( ) < length + start ) { return false ; } boolean comparison = includeLength ? length == ( msg . get ( 0 ) & 0xff ) : true ; if ( comparison ) { for ( int idx = start ; idx < length ; ++ idx ) { comparison = ( msg . get ( idx ) == data . charAt ( idx - start ) ) ; if ( ! comparison ) { break ; } } } return comparison ; }
Checks if the message starts with the given string .