01: /*
02: * Copyright 1999-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
40: Hyphen(String pre, String no, String post) {
41: preBreak = pre;
42: noBreak = no;
43: postBreak = post;
44: }
45:
46: Hyphen(String pre) {
47: preBreak = pre;
48: noBreak = null;
49: postBreak = null;
50: }
51:
52: public String toString() {
53: if (noBreak == null && postBreak == null && preBreak != null
54: && preBreak.equals("-")) {
55: return "-";
56: }
57: StringBuffer res = new StringBuffer("{");
58: res.append(preBreak);
59: res.append("}{");
60: res.append(postBreak);
61: res.append("}{");
62: res.append(noBreak);
63: res.append('}');
64: return res.toString();
65: }
66:
67: }
|