Routable decode(DocumentTypeManager docMan, Version version, byte[] data) {
        if (data == null || data.length == 0) {
            log.log(Level.SEVERE, "Received empty byte array for deserialization.");
            return null;
        }
        if (version.getMajor() < 5) {
            log.log(Level.SEVERE,"Can not decode anything from (version " + version + "). Only major version 5 and up supported.");
            return null;
        }
        DocumentDeserializer in = DocumentDeserializerFactory.createHead(docMan, GrowableByteBuffer.wrap(data));


        int type = in.getInt(null);
        RoutableFactory factory = getFactory(version, type);
        if (factory == null) {
            log.log(Level.SEVERE,"No routable factory found for routable type " + type + " (version " + version + ").");
            return null;
        }
        Routable ret = factory.decode(in);
        if (ret == null) {
            log.log(Level.SEVERE,"Routable factory " + factory.getClass().getName() + " failed to deserialize " +
                                               "routable of type " + type + " (version " + version + ").\nData = " + Arrays.toString(data));
            return null;
        }
        return ret;
    }
Decodes a {@link Routable} from the given byte array. This uses the content of the byte array to dispatch the
decode request to the appropriate {@link RoutableFactory} that was previously registered.

If a routable can not be decoded, this method returns null.

@param version The version of the encoded routable.
@param data    The byte array containing the encoded routable.
@return The decoded routable.
documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableRepository.java