/** * 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); }
/** * Returns the hyphenation (if present). * @since 2.1.2 */ public HyphenationEvent getHyphenation() { if (attributes == null) return null; return (HyphenationEvent) attributes.get(Chunk.HYPHENATION); }
/** * sets the hyphenation engine to this <CODE>Chunk</CODE>. * * @param hyphenation * the hyphenation engine * @return this <CODE>Chunk</CODE> */ public Chunk setHyphenation(HyphenationEvent hyphenation) { return setAttribute(HYPHENATION, hyphenation); }
/** * Getter for the hyphenation settings. * @return a HyphenationEvent * @since 2.1.2 */ public HyphenationEvent getHyphenation() { return hyphenation; }
/** * Setter for the hyphenation. * @param hyphenation a HyphenationEvent instance * @since 2.1.2 */ public void setHyphenation(HyphenationEvent hyphenation) { this.hyphenation = hyphenation; }
/** * Gets a HyphenationEvent based on the hyphenation entry in ChainedProperties. * @param props ChainedProperties * @return a HyphenationEvent * @since 2.1.2 */ public static HyphenationEvent getHyphenation(ChainedProperties props) { return getHyphenation(props.getProperty("hyphenation")); }
/** * Gets a HyphenationEvent based on the hyphenation entry in a HashMap. * @param props a HashMap with properties * @return a HyphenationEvent * @since 2.1.2 */ public static HyphenationEvent getHyphenation(HashMap props) { return getHyphenation((String) props.get("hyphenation")); }
/** sets the hyphenation engine to this <CODE>Chunk</CODE>. * @param hyphenation the hyphenation engine * @return this <CODE>Chunk</CODE> */ public Chunk setHyphenation(HyphenationEvent hyphenation) { return setAttribute(HYPHENATION, hyphenation); }