001/* 002 * Copyright 1999-2004 The Apache Software Foundation. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.itextpdf.text.pdf.hyphenation; 018 019import java.io.Serializable; 020 021/** 022 * This class represents a hyphen. A 'full' hyphen is made of 3 parts: 023 * the pre-break text, post-break text and no-break. If no line-break 024 * is generated at this position, the no-break text is used, otherwise, 025 * pre-break and post-break are used. Typically, pre-break is equal to 026 * the hyphen character and the others are empty. However, this general 027 * scheme allows support for cases in some languages where words change 028 * spelling if they're split across lines, like german's 'backen' which 029 * hyphenates 'bak-ken'. BTW, this comes from TeX. 030 * 031 * @author Carlos Villegas <cav@uniscope.co.jp> 032 */ 033 034public class Hyphen implements Serializable { 035 private static final long serialVersionUID = -7666138517324763063L; 036 public String preBreak; 037 public String noBreak; 038 public String postBreak; 039 040 Hyphen(String pre, String no, String post) { 041 preBreak = pre; 042 noBreak = no; 043 postBreak = post; 044 } 045 046 Hyphen(String pre) { 047 preBreak = pre; 048 noBreak = null; 049 postBreak = null; 050 } 051 052 public String toString() { 053 if (noBreak == null 054 && postBreak == null 055 && preBreak != null 056 && preBreak.equals("-")) { 057 return "-"; 058 } 059 StringBuffer res = new StringBuffer("{"); 060 res.append(preBreak); 061 res.append("}{"); 062 res.append(postBreak); 063 res.append("}{"); 064 res.append(noBreak); 065 res.append('}'); 066 return res.toString(); 067 } 068 069}