@ Override public Object extractValueFromBytes ( int offset , byte [ ] bytes , boolean required ) { // we don't need to extract the value if all we are doing is matching if ( ! required ) { return EMPTY ; } if ( offset >= bytes . length ) { return null ; } // length is from the first byte of the string int len = ( bytes [ offset ] & 0xFF ) ; int left = bytes . length - offset - 1 ; if ( len > left ) { len = left ; } char [ ] chars = new char [ len ] ; for ( int i = 0 ; i < chars . length ; i ++ ) { chars [ i ] = ( char ) ( bytes [ offset + 1 + i ] & 0xFF ) ; } /* * NOTE: we need to make a new string because it might be returned if we don't match below. */ return new String ( chars ) ; }
Extracted value is the extracted string using the first byte as the length .