1 17 18 19 20 package org.apache.fop.hyphenation; 21 22 27 public class Hyphenation { 28 29 private int[] hyphenPoints; 30 private String word; 31 32 35 private int len; 36 37 41 Hyphenation(String word, int[] points) { 42 this.word = word; 43 hyphenPoints = points; 44 len = points.length; 45 } 46 47 50 public int length() { 51 return len; 52 } 53 54 57 public String getPreHyphenText(int index) { 58 return word.substring(0, hyphenPoints[index]); 59 } 60 61 64 public String getPostHyphenText(int index) { 65 return word.substring(hyphenPoints[index]); 66 } 67 68 71 public int[] getHyphenationPoints() { 72 return hyphenPoints; 73 } 74 75 public String toString() { 76 StringBuffer str = new StringBuffer (); 77 int start = 0; 78 for (int i = 0; i < len; i++) { 79 str.append(word.substring(start, hyphenPoints[i]) + "-"); 80 start = hyphenPoints[i]; 81 } 82 str.append(word.substring(start)); 83 return str.toString(); 84 } 85 86 } 87 | Popular Tags |