private final static void checkMinimal(int ch, int minValue) throws IOException {
        if (ch >= minValue)
            return;

        int actualLen;
        switch (minValue) {
        case MIN_2_BYTES:
            actualLen = 2;
            break;
        case MIN_3_BYTES:
            actualLen = 3;
            break;
        case MIN_4_BYTES:
            actualLen = 4;
            break;
        default:
            throw new IllegalArgumentException("unexpected minValue passed to checkMinimal: " + minValue);
        }
            
        int expectedLen;
        if (ch < MIN_2_BYTES)
            expectedLen = 1;
        else if (ch < MIN_3_BYTES)
            expectedLen = 2;
        else if (ch < MIN_4_BYTES)
            expectedLen = 3;
        else
            throw new IllegalArgumentException("unexpected ch passed to checkMinimal: " + ch);
        
        throw new IOException(MessageFormat.format("Illegal UTF-8 sequence: {0} bytes used to encode a {1} byte value: {2}",
                                    new Object[] { new Integer(actualLen), new Integer(expectedLen), new Integer(ch) }));
    }