/** * Gets a HyphenationEvent based on a String. * For instance "en_UK,3,2" returns new HyphenationAuto("en", "UK", 3, 2); * @param s a String, for instance "en_UK,2,2" * @return a HyphenationEvent * @since 2.1.2 */ public static HyphenationEvent getHyphenation(String s) { if (s == null || s.length() == 0) { return null; } String lang = s; String country = null; int leftMin = 2; int rightMin = 2; int pos = s.indexOf('_'); if (pos == -1) { return new HyphenationAuto(lang, country, leftMin, rightMin); } lang = s.substring(0, pos); country = s.substring(pos + 1); pos = country.indexOf(','); if (pos == -1) { return new HyphenationAuto(lang, country, leftMin, rightMin); } s = country.substring(pos + 1); country = country.substring(0, pos); pos = s.indexOf(','); if (pos == -1) { leftMin = Integer.parseInt(s); } else { leftMin = Integer.parseInt(s.substring(0, pos)); rightMin = Integer.parseInt(s.substring(pos + 1)); } return new HyphenationAuto(lang, country, leftMin, rightMin); }