@ SuppressWarnings ( "unchecked" ) public CDB decode ( ByteBuffer input ) throws IOException { byte [ ] opcode = new byte [ 1 ] ; input . duplicate ( ) . get ( opcode ) ; // Read in the operation code without changing the position DataInputStream in = new DataInputStream ( new ByteArrayInputStream ( opcode ) ) ; int operationCode = in . readUnsignedByte ( ) ; if ( ! _cdbs . containsKey ( operationCode ) ) { throw new IOException ( String . format ( "Could not create new cdb with unsupported operation code: %x" , operationCode ) ) ; } try { CDB cdb = _cdbs . get ( operationCode ) . newInstance ( ) ; cdb . decode ( null , input ) ; return cdb ; } catch ( InstantiationException e ) { throw new IOException ( "Could not create new cdb parser: " + e . getMessage ( ) ) ; } catch ( IllegalAccessException e ) { throw new IOException ( "Could not create new cdb parser: " + e . getMessage ( ) ) ; } }
Used by iSCSI transport layer to decode CDB data off the wire .