// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java
// public static boolean contains(int[] array, int value) {
//     for (int i = 0; i < array.length; i++) {
//         if (array[i] == value) {
//             return true;
//         }
//     }
//     return false;
// }
// 
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java
// public static int[] insertArray(int[] original, int index, int[] inserted) {
//     int[] modified = new int[original.length + inserted.length];
//     System.arraycopy(original, 0, modified, 0, index);
//     System.arraycopy(inserted, 0, modified, index, inserted.length);
//     System.arraycopy(original, index, modified, index + inserted.length, modified.length - index - inserted.length);
//     return modified;
// }


import static uk.org.okapibarcode.util.Arrays.contains;
import static uk.org.okapibarcode.util.Arrays.insertArray;
import java.awt.geom.Ellipse2D;
import java.util.Arrays;

        int maxLength;
        if (mode == 2 || mode == 3) {
            maxLength = 84;
        } else if (mode == 4 || mode == 6) {
            maxLength = 93;
        } else if (mode == 5) {
            maxLength = 77;
        } else {
            maxLength = 0; // impossible
        }
        if (length > maxLength) {
            throw new OkapiException("Input data too long");
        }
    }

    /**
     * Guesses the best set to use at the specified index by looking at the surrounding sets. In general, characters in
     * lower-numbered sets are more common, so we choose them if we can. If no good surrounding sets can be found, the default
     * value returned is the first value from the valid set.
     *
     * @param index the current index
     * @param length the maximum length to look at
     * @param valid the valid sets for this index
     * @return the best set to use at the specified index
     */
    private int bestSurroundingSet(int index, int length, int... valid) {
        int option1 = set[index - 1];
        if (index + 1 < length) {
            // we have two options to check
            int option2 = set[index + 1];

// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java
// public static boolean contains(int[] array, int value) {
//     for (int i = 0; i < array.length; i++) {
//         if (array[i] == value) {
//             return true;
//         }
//     }
//     return false;
// }
// 
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java
// public static int[] insertArray(int[] original, int index, int[] inserted) {
//     int[] modified = new int[original.length + inserted.length];
//     System.arraycopy(original, 0, modified, 0, index);
//     System.arraycopy(inserted, 0, modified, index, inserted.length);
//     System.arraycopy(original, index, modified, index + inserted.length, modified.length - index - inserted.length);
//     return modified;
// }


// Path: src/main/java/uk/org/okapibarcode/backend/MaxiCode.java
import static uk.org.okapibarcode.util.Arrays.contains;
import static uk.org.okapibarcode.util.Arrays.insertArray;
import java.awt.geom.Ellipse2D;
import java.util.Arrays;

        int maxLength;
        if (mode == 2 || mode == 3) {
            maxLength = 84;
        } else if (mode == 4 || mode == 6) {
            maxLength = 93;
        } else if (mode == 5) {
            maxLength = 77;
        } else {
            maxLength = 0; // impossible
        }
        if (length > maxLength) {
            throw new OkapiException("Input data too long");
        }
    }

    /**
     * Guesses the best set to use at the specified index by looking at the surrounding sets. In general, characters in
     * lower-numbered sets are more common, so we choose them if we can. If no good surrounding sets can be found, the default
     * value returned is the first value from the valid set.
     *
     * @param index the current index
     * @param length the maximum length to look at
     * @param valid the valid sets for this index
     * @return the best set to use at the specified index
     */
    private int bestSurroundingSet(int index, int length, int... valid) {
        int option1 = set[index - 1];
        if (index + 1 < length) {
            // we have two options to check
            int option2 = set[index + 1];

            if (contains(valid, option1) && contains(valid, option2)) {
