@Test public void testValidateInvalidLanguage() { List<String> invalidLanguages = Arrays.asList( "", "+", "en", "en+", "eng+fra+", "rm -rf *"); TesseractOCRConfig config = new TesseractOCRConfig(); for (String language : invalidLanguages) { try { config.setLanguage(language); fail("Invalid language set: " + language); } catch (IllegalArgumentException e) { } } }
public void setLanguage(String language) { if (!language.matches("([a-zA-Z]{3}(_[a-zA-Z]{3,4})?(\\+?))+") || language.endsWith("+")) { throw new IllegalArgumentException("Invalid language code"); } this.language = language; }
TesseractOCRConfig implements Serializable { public void setLanguage(String language) { if (!language.matches("([a-zA-Z]{3}(_[a-zA-Z]{3,4})?(\\+?))+") || language.endsWith("+")) { throw new IllegalArgumentException("Invalid language code"); } this.language = language; } }
TesseractOCRConfig implements Serializable { public void setLanguage(String language) { if (!language.matches("([a-zA-Z]{3}(_[a-zA-Z]{3,4})?(\\+?))+") || language.endsWith("+")) { throw new IllegalArgumentException("Invalid language code"); } this.language = language; } TesseractOCRConfig();  TesseractOCRConfig(InputStream is); }
TesseractOCRConfig implements Serializable { public void setLanguage(String language) { if (!language.matches("([a-zA-Z]{3}(_[a-zA-Z]{3,4})?(\\+?))+") || language.endsWith("+")) { throw new IllegalArgumentException("Invalid language code"); } this.language = language; } TesseractOCRConfig();  TesseractOCRConfig(InputStream is); String getTesseractPath(); void setTesseractPath(String tesseractPath); String getTessdataPath(); void setTessdataPath(String tessdataPath); String getLanguage(); void setLanguage(String language); String getPageSegMode(); void setPageSegMode(String pageSegMode); String getPageSeparator(); void setPageSeparator(String pageSeparator); void setTrustedPageSeparator(String pageSeparator); void setPreserveInterwordSpacing(boolean preserveInterwordSpacing); boolean getPreserveInterwordSpacing(); long getMinFileSizeToOcr(); void setMinFileSizeToOcr(long minFileSizeToOcr); long getMaxFileSizeToOcr(); void setMaxFileSizeToOcr(long maxFileSizeToOcr); void setTimeout(int timeout); int getTimeout(); void setOutputType(OUTPUT_TYPE outputType); void setOutputType(String outputType); OUTPUT_TYPE getOutputType(); int isEnableImageProcessing(); void setEnableImageProcessing(int enableImageProcessing); int getDensity(); void setDensity(int density); int getDepth(); void setDepth(int depth); String getColorspace(); void setColorspace(String colorspace); String getFilter(); void setFilter(String filter); int getResize(); void setResize(int resize); String getImageMagickPath(); void setImageMagickPath(String imageMagickPath); boolean getApplyRotation(); void setApplyRotation(boolean applyRotation); Map<String, String> getOtherTesseractConfig(); void addOtherTesseractConfig(String key, String value); }
TesseractOCRConfig implements Serializable { public void setLanguage(String language) { if (!language.matches("([a-zA-Z]{3}(_[a-zA-Z]{3,4})?(\\+?))+") || language.endsWith("+")) { throw new IllegalArgumentException("Invalid language code"); } this.language = language; } TesseractOCRConfig();  TesseractOCRConfig(InputStream is); String getTesseractPath(); void setTesseractPath(String tesseractPath); String getTessdataPath(); void setTessdataPath(String tessdataPath); String getLanguage(); void setLanguage(String language); String getPageSegMode(); void setPageSegMode(String pageSegMode); String getPageSeparator(); void setPageSeparator(String pageSeparator); void setTrustedPageSeparator(String pageSeparator); void setPreserveInterwordSpacing(boolean preserveInterwordSpacing); boolean getPreserveInterwordSpacing(); long getMinFileSizeToOcr(); void setMinFileSizeToOcr(long minFileSizeToOcr); long getMaxFileSizeToOcr(); void setMaxFileSizeToOcr(long maxFileSizeToOcr); void setTimeout(int timeout); int getTimeout(); void setOutputType(OUTPUT_TYPE outputType); void setOutputType(String outputType); OUTPUT_TYPE getOutputType(); int isEnableImageProcessing(); void setEnableImageProcessing(int enableImageProcessing); int getDensity(); void setDensity(int density); int getDepth(); void setDepth(int depth); String getColorspace(); void setColorspace(String colorspace); String getFilter(); void setFilter(String filter); int getResize(); void setResize(int resize); String getImageMagickPath(); void setImageMagickPath(String imageMagickPath); boolean getApplyRotation(); void setApplyRotation(boolean applyRotation); Map<String, String> getOtherTesseractConfig(); void addOtherTesseractConfig(String key, String value);  }