Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Jan 26 2008 14:11:34 CET
file stats: LOC: 123   Methods: 6
NCLOC: 31   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SourcePosition.java - 70% 83,3% 75%
coverage coverage
 1    /* $Id: SourcePosition.java,v 1.2 2007/12/21 23:33:47 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2007, Michael Meyling <mime@qedeq.org>.
 6    *
 7    * "Hilbert II" is free software; you can redistribute
 8    * it and/or modify it under the terms of the GNU General Public
 9    * License as published by the Free Software Foundation; either
 10    * version 2 of the License, or (at your option) any later version.
 11    *
 12    * This program is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15    * GNU General Public License for more details.
 16    */
 17   
 18    package org.qedeq.kernel.common;
 19   
 20    import java.io.Serializable;
 21    import java.net.URL;
 22   
 23   
 24    /**
 25    * Describes a file position.
 26    *
 27    * @version $Revision: 1.2 $
 28    * @author Michael Meyling
 29    */
 30    public final class SourcePosition implements Serializable {
 31   
 32    /** Address of input, for identifying source. */
 33    private final URL address;
 34   
 35    /** Line number, starting with 1. */
 36    private int line;
 37   
 38    /** Column number, starting with 1. */
 39    private int column;
 40   
 41    /**
 42    * Constructs source position object.
 43    *
 44    * @param address source address
 45    * @param line Line number.
 46    * @param column Column number.
 47    */
 48  67324 public SourcePosition(final URL address, final int line, final int column) {
 49  67324 this.address = address;
 50  67324 this.line = line;
 51  67324 this.column = column;
 52    }
 53   
 54    /**
 55    * Constructs file position object.
 56    *
 57    * @param address for identifying source
 58    * @param localAddress source address
 59    * @param line Line number.
 60    * @param column Column number.
 61    */
 62  0 public SourcePosition(final URL address, final URL localAddress,
 63    final int line, final int column) {
 64  0 this.address = address;
 65  0 this.line = line;
 66  0 this.column = column;
 67    }
 68   
 69    /**
 70    * Get address (or something to identify it) of input source.
 71    *
 72    * @return address of input source
 73    */
 74  277 public final URL getAddress() {
 75  277 return this.address;
 76    }
 77   
 78    /**
 79    * Get line number, starting with 1.
 80    *
 81    * @return Line number.
 82    */
 83  426 public final int getLine() {
 84  426 return line;
 85    }
 86   
 87    /**
 88    * Get column number, starting with 1.
 89    *
 90    * @return column number
 91    */
 92  314 public final int getColumn() {
 93  314 return column;
 94    }
 95   
 96    // LATER mime 20050608: remove if no use
 97    /*
 98    public final int findCaretPosition(final int line, final int column, final String source) {
 99    if (line == 1) {
 100    return 0;
 101    }
 102    int k = 1;
 103    for (int j = 0; j < source.length(); j++) {
 104    if (source.charAt(j) == '\n') {
 105    k++;
 106    }
 107    if (k == line) {
 108    j += column - 1;
 109    if (j > source.length()) {
 110    j = source.length();
 111    }
 112    return j;
 113    }
 114    }
 115    return 0;
 116    }
 117    */
 118   
 119  16 public final String toString() {
 120  16 return getAddress() + ":" + getLine() + ":" + getColumn();
 121    }
 122   
 123    }