public static int validateAndComputeLength ( final DirectBufferVector [ ] vectors ) { int messageLength = 0 ; for ( final DirectBufferVector vector : vectors ) { vector . validate ( ) ; messageLength += vector . length ; if ( messageLength < 0 ) { throw new IllegalStateException ( "length overflow: " + Arrays . toString ( vectors ) ) ; } } return messageLength ; }
Validate an array of vectors to make up a message and compute the total length .