1 51 package org.apache.fop.layout.hyphenation; 52 53 58 public class Hyphenation { 59 int[] hyphenPoints; 60 String word; 61 62 65 int len; 66 67 71 Hyphenation(String word, int[] points) { 72 this.word = word; 73 hyphenPoints = points; 74 len = points.length; 75 } 76 77 80 public int length() { 81 return len; 82 } 83 84 87 public String getPreHyphenText(int index) { 88 return word.substring(0, hyphenPoints[index]); 89 } 90 91 94 public String getPostHyphenText(int index) { 95 return word.substring(hyphenPoints[index]); 96 } 97 98 101 public int[] getHyphenationPoints() { 102 return hyphenPoints; 103 } 104 105 public String toString() { 106 StringBuffer str = new StringBuffer (); 107 int start = 0; 108 for (int i = 0; i < len; i++) { 109 str.append(word.substring(start, hyphenPoints[i]) + "-"); 110 start = hyphenPoints[i]; 111 } 112 str.append(word.substring(start)); 113 return str.toString(); 114 } 115 116 } 117 | Popular Tags |