public static MagicDetector parse(MediaType mediaType, String type, String offset, String value,
                                      String mask) {
        int start = 0;
        int end = 0;
        if (offset != null) {
            int colon = offset.indexOf(':');
            if (colon == -1) {
                start = Integer.parseInt(offset);
                end = start;
            } else {
                start = Integer.parseInt(offset.substring(0, colon));
                end = Integer.parseInt(offset.substring(colon + 1));
            }
        }

        byte[] patternBytes = decodeValue(value, type);
        byte[] maskBytes = null;
        if (mask != null) {
            maskBytes = decodeValue(mask, type);
        }

        return new MagicDetector(mediaType, patternBytes, maskBytes, type.equals("regex"),
                type.equals("stringignorecase"), start, end);
    }
Creates a detector for input documents that meet the specified
magic match.
tika-core/src/main/java/org/apache/tika/detect/MagicDetector.java