public static Buffer wrap ( final byte [ ] buffer , final int lowerBoundary , final int upperBoundary ) { if ( buffer == null || buffer . length == 0 ) { throw new IllegalArgumentException ( "the buffer cannot be null or empty" ) ; } if ( upperBoundary > buffer . length ) { throw new IllegalArgumentException ( "The upper boundary cannot exceed the length of the buffer" ) ; } if ( lowerBoundary >= upperBoundary ) { throw new IllegalArgumentException ( "The lower boundary must be lower than the upper boundary" ) ; } if ( lowerBoundary < 0 ) { throw new IllegalArgumentException ( "The lower boundary must be a equal or greater than zero" ) ; } final int readerIndex = 0 ; final int writerIndex = upperBoundary ; return new ByteBuffer ( readerIndex , lowerBoundary , upperBoundary , writerIndex , buffer ) ; }
Wrap the supplied byte array specifying the allowed range of visible bytes .