KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > pdf > hyphenation > Hyphen


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 JavaDoc;
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 JavaDoc {
35     private static final long serialVersionUID = -7666138517324763063L;
36     public String JavaDoc preBreak;
37     public String JavaDoc noBreak;
38     public String JavaDoc postBreak;
39
40     Hyphen(String JavaDoc pre, String JavaDoc no, String JavaDoc post) {
41         preBreak = pre;
42         noBreak = no;
43         postBreak = post;
44     }
45
46     Hyphen(String JavaDoc pre) {
47         preBreak = pre;
48         noBreak = null;
49         postBreak = null;
50     }
51
52     public String JavaDoc toString() {
53         if (noBreak == null
54                 && postBreak == null
55                 && preBreak != null
56                 && preBreak.equals("-")) {
57             return "-";
58                 }
59         StringBuffer JavaDoc res = new StringBuffer JavaDoc("{");
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
Popular Tags