private static byte[] decodeValue(String value, String type) {
        // Preliminary check
        if ((value == null) || (type == null)) {
            return null;
        }

        byte[] decoded = null;
        String tmpVal = null;
        int radix = 8;

        // hex
        if (value.startsWith("0x")) {
            tmpVal = value.substring(2);
            radix = 16;
        } else {
            tmpVal = value;
            radix = 8;
        }

        switch (type) {
            case "string":
            case "regex":
            case "unicodeLE":
            case "unicodeBE":
                decoded = decodeString(value, type);
                break;
            case "stringignorecase":
                decoded = decodeString(value.toLowerCase(Locale.ROOT), type);
                break;
            case "byte":
                decoded = tmpVal.getBytes(UTF_8);
                break;
            case "host16":
            case "little16": {
                int i = Integer.parseInt(tmpVal, radix);
                decoded = new byte[]{(byte) (i & 0x00FF), (byte) (i >> 8)};
                break;
            }
            case "big16": {
                int i = Integer.parseInt(tmpVal, radix);
                decoded = new byte[]{(byte) (i >> 8), (byte) (i & 0x00FF)};
                break;
            }
            case "host32":
            case "little32": {
                long i = Long.parseLong(tmpVal, radix);
                decoded = new byte[]{(byte) ((i & 0x000000FF)), (byte) ((i & 0x0000FF00) >> 8),
                        (byte) ((i & 0x00FF0000) >> 16), (byte) ((i & 0xFF000000) >> 24)};
                break;
            }
            case "big32": {
                long i = Long.parseLong(tmpVal, radix);
                decoded = new byte[]{(byte) ((i & 0xFF000000) >> 24), (byte) ((i & 0x00FF0000) >> 16),
                        (byte) ((i & 0x0000FF00) >> 8), (byte) ((i & 0x000000FF))};
                break;
            }
        }
        return decoded;
    }
Creates a detector for input documents that meet the specified
magic match.
tika-core/src/main/java/org/apache/tika/detect/MagicDetector.java