public static PageSegMode valueOf(int mode) throws TesseractException {
            for (PageSegMode test: PageSegMode.values()) {
                if (mode == test.value) {
                    return test;
                }
            }
            
            throw new TesseractException("No such page sementation mode: " + mode);
        }