Hyphenation.java

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
/**
20
 * This class represents a hyphenated word.
21
 *
22
 * @author Carlos Villegas <cav@uniscope.co.jp>
23
 */
24
public class Hyphenation {
25
    
26
    private int[] hyphenPoints;
27
    private String word;
28
29
    /**
30
     * number of hyphenation points in word
31
     */
32
    private int len;
33
34
    /**
35
     * rawWord as made of alternating strings and {@link Hyphen Hyphen}
36
     * instances
37
     */
38
    Hyphenation(String word, int[] points) {
39
        this.word = word;
40
        hyphenPoints = points;
41
        len = points.length;
42
    }
43
44
    /**
45
     * @return the number of hyphenation points in the word
46
     */
47
    public int length() {
48
        return len;
49
    }
50
51
    /**
52
     * @return the pre-break text, not including the hyphen character
53
     */
54
    public String getPreHyphenText(int index) {
55 1 1. getPreHyphenText : mutated return of Object value for com/lowagie/text/pdf/hyphenation/Hyphenation::getPreHyphenText to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return word.substring(0, hyphenPoints[index]);
56
    }
57
58
    /**
59
     * @return the post-break text
60
     */
61
    public String getPostHyphenText(int index) {
62 1 1. getPostHyphenText : mutated return of Object value for com/lowagie/text/pdf/hyphenation/Hyphenation::getPostHyphenText to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return word.substring(hyphenPoints[index]);
63
    }
64
65
    /**
66
     * @return the hyphenation points
67
     */
68
    public int[] getHyphenationPoints() {
69
        return hyphenPoints;
70
    }
71
72
    public String toString() {
73
        StringBuilder str = new StringBuilder();
74
        int start = 0;
75
        for (int i = 0; i < len; i++) {
76
            str.append(word, start, hyphenPoints[i]).append('-');
77
            start = hyphenPoints[i];
78
        }
79
        str.append(word.substring(start));
80
        return str.toString();
81
    }
82
83
}

Mutations

55

1.1
Location : getPreHyphenText
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/hyphenation/Hyphenation::getPreHyphenText to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

62

1.1
Location : getPostHyphenText
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/hyphenation/Hyphenation::getPostHyphenText to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.4.2