DocPosition.java

1
/*
2
 * This file is part of the programmer editor demo
3
 * Copyright (C) 2001-2005 Stephen Ostermiller
4
 * http://ostermiller.org/contact.pl?regarding=Syntax+Highlighting
5
 * 
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * See COPYING.TXT for details.
17
 */
18
package com.jsql.view.swing.sql.lexer;
19
20
/**
21
 * A wrapper for a position in a document appropriate for storing
22
 * in a collection.
23
 */
24
class DocPosition {
25
26
    /**
27
     * The actual position
28
     */
29
    private int position;
30
    
31
    /**
32
     * Construct a DocPosition from the given offset into the document.
33
     *
34
     * @param position The position this DocObject will represent
35
     */
36
    public DocPosition(int position) {
37
        this.position = position;
38
    }
39
40
    /**
41
     * Get the position represented by this DocPosition
42
     *
43
     * @return the position
44
     */
45
    int getPosition() {
46 1 1. getPosition : replaced int return with 0 for com/jsql/view/swing/sql/lexer/DocPosition::getPosition → NO_COVERAGE
        return this.position;
47
    }
48
49
    /**
50
     * Adjust this position.
51
     * This is useful in cases that an amount of text is inserted
52
     * or removed before this position.
53
     *
54
     * @param adjustment amount (either positive or negative) to adjust this position.
55
     */
56
    public void adjustPosition(int adjustment) {
57 1 1. adjustPosition : Replaced integer addition with subtraction → NO_COVERAGE
        this.position += adjustment;
58
    }
59
60
    @Override
61
    public boolean equals(Object obj) {
62
        
63 1 1. equals : negated conditional → NO_COVERAGE
        if (this == obj) {
64 1 1. equals : replaced boolean return with false for com/jsql/view/swing/sql/lexer/DocPosition::equals → NO_COVERAGE
            return true;
65
        }
66
        
67 1 1. equals : negated conditional → NO_COVERAGE
        if (obj == null) {
68 1 1. equals : replaced boolean return with true for com/jsql/view/swing/sql/lexer/DocPosition::equals → NO_COVERAGE
            return false;
69
        }
70
        
71 1 1. equals : negated conditional → NO_COVERAGE
        if (this.getClass() != obj.getClass()) {
72 1 1. equals : replaced boolean return with true for com/jsql/view/swing/sql/lexer/DocPosition::equals → NO_COVERAGE
            return false;
73
        }
74
        
75
        DocPosition other = (DocPosition) obj;
76 2 1. equals : replaced boolean return with true for com/jsql/view/swing/sql/lexer/DocPosition::equals → NO_COVERAGE
2. equals : negated conditional → NO_COVERAGE
        return this.position == other.position;
77
    }
78
79
    @Override
80
    public int hashCode() {
81
        
82
        final int prime = 31;
83
        int result = 1;
84 2 1. hashCode : Replaced integer addition with subtraction → NO_COVERAGE
2. hashCode : Replaced integer multiplication with division → NO_COVERAGE
        result = prime * result + this.position;
85
        
86 1 1. hashCode : replaced int return with 0 for com/jsql/view/swing/sql/lexer/DocPosition::hashCode → NO_COVERAGE
        return result;
87
    }
88
89
    /**
90
     * A string representation useful for debugging.
91
     *
92
     * @return A string representing the position.
93
     */
94
    @Override
95
    public String toString() {
96 1 1. toString : replaced return value with "" for com/jsql/view/swing/sql/lexer/DocPosition::toString → NO_COVERAGE
        return Integer.toString(this.position);
97
    }
98
}

Mutations

46

1.1
Location : getPosition
Killed by : none
replaced int return with 0 for com/jsql/view/swing/sql/lexer/DocPosition::getPosition → NO_COVERAGE

57

1.1
Location : adjustPosition
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

63

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

64

1.1
Location : equals
Killed by : none
replaced boolean return with false for com/jsql/view/swing/sql/lexer/DocPosition::equals → NO_COVERAGE

67

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

68

1.1
Location : equals
Killed by : none
replaced boolean return with true for com/jsql/view/swing/sql/lexer/DocPosition::equals → NO_COVERAGE

71

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

72

1.1
Location : equals
Killed by : none
replaced boolean return with true for com/jsql/view/swing/sql/lexer/DocPosition::equals → NO_COVERAGE

76

1.1
Location : equals
Killed by : none
replaced boolean return with true for com/jsql/view/swing/sql/lexer/DocPosition::equals → NO_COVERAGE

2.2
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

84

1.1
Location : hashCode
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : hashCode
Killed by : none
Replaced integer multiplication with division → NO_COVERAGE

86

1.1
Location : hashCode
Killed by : none
replaced int return with 0 for com/jsql/view/swing/sql/lexer/DocPosition::hashCode → NO_COVERAGE

96

1.1
Location : toString
Killed by : none
replaced return value with "" for com/jsql/view/swing/sql/lexer/DocPosition::toString → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1