1 /* 2 * Copyright 1999-2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.lowagie.text.pdf.hyphenation; 18 19 import java.io.Serializable; 20 21 /** 22 * This class represents a hyphen. A 'full' hyphen is made of 3 parts: 23 * the pre-break text, post-break text and no-break. If no line-break 24 * is generated at this position, the no-break text is used, otherwise, 25 * pre-break and post-break are used. Typically, pre-break is equal to 26 * the hyphen character and the others are empty. However, this general 27 * scheme allows support for cases in some languages where words change 28 * spelling if they're split across lines, like german's 'backen' which 29 * hyphenates 'bak-ken'. BTW, this comes from TeX. 30 * 31 * @author Carlos Villegas <cav@uniscope.co.jp> 32 */ 33 34 public class Hyphen implements Serializable { 35 private static final long serialVersionUID = -7666138517324763063L; 36 public String preBreak; 37 public String noBreak; 38 public String postBreak; 39 Hyphen(String pre, String no, String post)40 Hyphen(String pre, String no, String post) { 41 preBreak = pre; 42 noBreak = no; 43 postBreak = post; 44 } 45 Hyphen(String pre)46 Hyphen(String pre) { 47 preBreak = pre; 48 noBreak = null; 49 postBreak = null; 50 } 51 toString()52 public String toString() { 53 if (noBreak == null 54 && postBreak == null 55 && preBreak != null 56 && preBreak.equals("-")) { 57 return "-"; 58 } 59 StringBuffer res = new StringBuffer("{"); 60 res.append(preBreak); 61 res.append("}{"); 62 res.append(postBreak); 63 res.append("}{"); 64 res.append(noBreak); 65 res.append('}'); 66 return res.toString(); 67 } 68 69 } 70