private byte [ ] unifyLData ( final CEMI ldata , final boolean emptySrc , final List < Integer > types ) { final byte [ ] data ; if ( ldata instanceof CEMILDataEx ) { final CEMILDataEx ext = ( ( CEMILDataEx ) ldata ) ; final List < AddInfo > additionalInfo = ext . additionalInfo ( ) ; synchronized ( additionalInfo ) { for ( final Iterator < AddInfo > i = additionalInfo . iterator ( ) ; i . hasNext ( ) ; ) { final AddInfo info = i . next ( ) ; if ( ! types . contains ( info . getType ( ) ) ) { logger . warn ( "remove L-Data additional info {}" , info ) ; i . remove ( ) ; } } } } data = ldata . toByteArray ( ) ; // set msg code field 0 data [ 0 ] = 0 ; // set ctrl1 field 0 data [ 1 + data [ 1 ] + 1 ] = 0 ; // conditionally set source address 0 if ( emptySrc ) { data [ 1 + data [ 1 ] + 3 ] = 0 ; data [ 1 + data [ 1 ] + 4 ] = 0 ; } return data ; }
additional info . types provides the list of add . info types we want to keep everything else is removed